Mercurial > hg > mauch-mirex-2010
annotate _FullBNT/KPMtools/image_rgb.m @ 9:4ea6619cb3f5 tip
removed log files
author | matthiasm |
---|---|
date | Fri, 11 Apr 2014 15:55:11 +0100 |
parents | b5b38998ef3b |
children |
rev | line source |
---|---|
matthiasm@8 | 1 function image_rgb(M) |
matthiasm@8 | 2 % Show a matrix of integers as a color image. |
matthiasm@8 | 3 % This is like imagesc, except we know what the mapping is from integer to color. |
matthiasm@8 | 4 % If entries of M contain integers in {1,2,3}, we map |
matthiasm@8 | 5 % this to red/green/blue |
matthiasm@8 | 6 |
matthiasm@8 | 7 cmap = [1 0 0; % red |
matthiasm@8 | 8 0 1 0; % green |
matthiasm@8 | 9 0 0 1; % blue |
matthiasm@8 | 10 127/255 1 212/255]; % aquamarine |
matthiasm@8 | 11 image(M) |
matthiasm@8 | 12 set(gcf,'colormap', cmap); |
matthiasm@8 | 13 |
matthiasm@8 | 14 if 1 |
matthiasm@8 | 15 % make dummy handles, one per object type, for the legend |
matthiasm@8 | 16 str = {}; |
matthiasm@8 | 17 for i=1:size(cmap,1) |
matthiasm@8 | 18 dummy_handle(i) = line([0 0.1], [0 0.1]); |
matthiasm@8 | 19 set(dummy_handle(i), 'color', cmap(i,:)); |
matthiasm@8 | 20 set(dummy_handle(i), 'linewidth', 2); |
matthiasm@8 | 21 str{i} = num2str(i); |
matthiasm@8 | 22 end |
matthiasm@8 | 23 legend(dummy_handle, str, -1); |
matthiasm@8 | 24 end |
matthiasm@8 | 25 |
matthiasm@8 | 26 if 0 |
matthiasm@8 | 27 [nrows ncols] = size(M); |
matthiasm@8 | 28 img = zeros(nrows, ncols, 3); |
matthiasm@8 | 29 for r=1:nrows |
matthiasm@8 | 30 for c=1:ncols |
matthiasm@8 | 31 q = M(r,c); |
matthiasm@8 | 32 img(r,c,q) = 1; |
matthiasm@8 | 33 end |
matthiasm@8 | 34 end |
matthiasm@8 | 35 image(img) |
matthiasm@8 | 36 end |