summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/MultiNcut/showmask.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/common/toolbox/MultiNcut/showmask.m')
-rwxr-xr-xSD-VBS/common/toolbox/MultiNcut/showmask.m65
1 files changed, 65 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/MultiNcut/showmask.m b/SD-VBS/common/toolbox/MultiNcut/showmask.m
new file mode 100755
index 0000000..6fd1142
--- /dev/null
+++ b/SD-VBS/common/toolbox/MultiNcut/showmask.m
@@ -0,0 +1,65 @@
1% function RGB=showmask(V,M,hue);
2% Input:
3% V = image
4% M = nonnegative mask
5% hue = a number in [0,1], red,yellow,green,cyan,...,red
6% a char, 'r','g','b','y','c','m'
7% or a matrix of the same size of image
8% eg. hue = mask1 * 0.7 + mask2 * 1;
9%
10% Output:
11% RGB = an RGB image with V as shades and M as saturated hues
12% If no output is required, this image is displayed.
13
14% Stella X. YU, 2000. Based on Jianbo Shi's version.
15
16function RGB=showmask(V,M,hue);
17
18if nargin<3 | isempty(hue),
19 hue = 0;
20end
21if ischar(hue),
22 switch hue,
23 case 'r', hue = 1.0;
24 case 'g', hue = 0.3;
25 case 'b', hue = 0.7;
26 case 'y', hue = 0.15;
27 case 'c', hue = 0.55;
28 case 'm', hue = 0.85;
29 end
30end
31
32
33V=V-min(V(:));
34V=V/max(V(:));
35V=.25+0.75*V; %brighten things up a bit
36
37M = double(M);
38M = M-min(M(:));
39M = M/max(M(:));
40
41H = hue+zeros(size(V));
42S = M;
43RGB = hsv2rgb(H,S,V);
44
45if nargout>0,
46 return;
47end
48
49hold off; image(RGB); axis('image');
50s = cell(1,2);
51if isempty(inputname(1)),
52 s{1} = 'image';
53else
54 s{1} = inputname(1);
55end
56if isempty(inputname(2)),
57 s{2} = 'mask';
58else
59 s{2} = inputname(2);
60end
61title(sprintf('%s and colored %s',s{1},s{2}));
62
63if nargout==0,
64 clear RGB;
65end