about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/KPMtools/image_rgb.m
diff options
context:
space:
mode:
authorziejd22018-03-14 23:23:33 -0500
committerGitHub2018-03-14 23:23:33 -0500
commit1ff6baa44e22b91eefb48aea6f3befa078c0489b (patch)
treee0fd79d2e32fd2aedda2eadaed0f19af3514c520 /sourcecodes/bnt-master/KPMtools/image_rgb.m
parent6882395afdadf4e982b25b5215071a0932730950 (diff)
parentc80226899f5cdd9f11c163817d59445213f5bef0 (diff)
downloadBNW-1ff6baa44e22b91eefb48aea6f3befa078c0489b.tar.gz
Merge pull request #1 from ziejd2/octave_php_separate
Octave php separate
Diffstat (limited to 'sourcecodes/bnt-master/KPMtools/image_rgb.m')
-rw-r--r--sourcecodes/bnt-master/KPMtools/image_rgb.m36
1 files changed, 36 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/KPMtools/image_rgb.m b/sourcecodes/bnt-master/KPMtools/image_rgb.m
new file mode 100644
index 00000000..e8d65883
--- /dev/null
+++ b/sourcecodes/bnt-master/KPMtools/image_rgb.m
@@ -0,0 +1,36 @@
+function image_rgb(M)
+% Show a matrix of integers as a color image.
+% This is like imagesc, except we know what the mapping is from integer to color.
+% If entries of M contain integers in {1,2,3}, we map
+% this to red/green/blue 
+
+cmap = [1 0 0; % red
+	0 1 0; % green
+	0 0 1; % blue
+	127/255 1 212/255]; % aquamarine
+image(M)
+set(gcf,'colormap', cmap);
+
+if 1
+  % make dummy handles, one per object type, for the legend
+  str = {};
+  for i=1:size(cmap,1)
+    dummy_handle(i) = line([0 0.1], [0 0.1]);
+    set(dummy_handle(i), 'color', cmap(i,:));
+    set(dummy_handle(i), 'linewidth', 2);
+    str{i} = num2str(i);
+  end
+  legend(dummy_handle, str, -1);
+end
+
+if 0
+[nrows ncols] = size(M);
+img = zeros(nrows, ncols, 3);
+for r=1:nrows
+  for c=1:ncols
+    q = M(r,c);
+    img(r,c,q) = 1;
+  end
+end
+image(img)
+end