diff options
Diffstat (limited to 'SD-VBS/common/toolbox/MultiNcut/showmask.m')
-rwxr-xr-x | SD-VBS/common/toolbox/MultiNcut/showmask.m | 65 |
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 | |||
16 | function RGB=showmask(V,M,hue); | ||
17 | |||
18 | if nargin<3 | isempty(hue), | ||
19 | hue = 0; | ||
20 | end | ||
21 | if 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 | ||
30 | end | ||
31 | |||
32 | |||
33 | V=V-min(V(:)); | ||
34 | V=V/max(V(:)); | ||
35 | V=.25+0.75*V; %brighten things up a bit | ||
36 | |||
37 | M = double(M); | ||
38 | M = M-min(M(:)); | ||
39 | M = M/max(M(:)); | ||
40 | |||
41 | H = hue+zeros(size(V)); | ||
42 | S = M; | ||
43 | RGB = hsv2rgb(H,S,V); | ||
44 | |||
45 | if nargout>0, | ||
46 | return; | ||
47 | end | ||
48 | |||
49 | hold off; image(RGB); axis('image'); | ||
50 | s = cell(1,2); | ||
51 | if isempty(inputname(1)), | ||
52 | s{1} = 'image'; | ||
53 | else | ||
54 | s{1} = inputname(1); | ||
55 | end | ||
56 | if isempty(inputname(2)), | ||
57 | s{2} = 'mask'; | ||
58 | else | ||
59 | s{2} = inputname(2); | ||
60 | end | ||
61 | title(sprintf('%s and colored %s',s{1},s{2})); | ||
62 | |||
63 | if nargout==0, | ||
64 | clear RGB; | ||
65 | end | ||