Mercurial > octave-nkf
comparison scripts/image/imshow.m @ 4911:14027e0bafa4
[project @ 2004-07-22 19:58:06 by jwe]
author | jwe |
---|---|
date | Thu, 22 Jul 2004 19:58:06 +0000 |
parents | 518e495e489f |
children | 048db020498c |
comparison
equal
deleted
inserted
replaced
4910:1242acab4246 | 4911:14027e0bafa4 |
---|---|
66 | 66 |
67 ## All except imshow (r, g, b) | 67 ## All except imshow (r, g, b) |
68 | 68 |
69 if (mvars != 3) | 69 if (mvars != 3) |
70 I = varargin{1}; | 70 I = varargin{1}; |
71 if (max (varargin{1}(:)) <= 1) | 71 if iscomplex (I) |
72 warning("imshow: displaying real part of complex image"); | |
73 I = real (I); | |
74 endif | |
75 if (max (I(:)) <= 1) | |
72 # image in [0-1]; scale to [0-255] | 76 # image in [0-1]; scale to [0-255] |
73 I = I * 255; | 77 I = I * 255; |
74 M = gray (256); | 78 M = gray (256); |
75 endif | 79 endif |
76 endif | 80 endif |
77 | 81 |
78 if (mvars == 1) | 82 if (mvars == 1) |
79 ## imshow (x) | 83 ## imshow (x) |
80 ## Grayscale image [0-N] -- estimate gray levels. | 84 ## Grayscale image [0-N] -- estimate gray levels. |
81 N = 2^ceil (log2 (max(I(:)))); | 85 N = 2^ceil (log2 (max(I(:)))); |
82 M = gray (N); | 86 if (N <= 65536) |
87 M = gray (N); | |
88 else | |
89 M = gray (256); | |
90 I = I / max (I(:)) * 255; | |
91 endif | |
83 elseif (mvars == 2) | 92 elseif (mvars == 2) |
84 ## imshow (x, map) or imshow (x, N) | 93 ## imshow (x, map) or imshow (x, N) |
85 M = varargin{2}; | 94 M = varargin{2}; |
86 if (isscalar (M)) | 95 if (isscalar (M)) |
87 M = gray (M); | 96 M = gray (M); |
90 ## imshow (r, g, b) | 99 ## imshow (r, g, b) |
91 r = varargin{1}; | 100 r = varargin{1}; |
92 g = varargin{2}; | 101 g = varargin{2}; |
93 b = varargin{3}; | 102 b = varargin{3}; |
94 tmp = [r; g; b]; | 103 tmp = [r; g; b]; |
104 if iscomplex (tmp) | |
105 warning("imshow: displaying real part of complex rgb image"); | |
106 r = real (r); g = real (g); b = real (b); | |
107 endif | |
95 if (max (tmp(:)) > 1) | 108 if (max (tmp(:)) > 1) |
96 ## Normalise to [0-1]. | 109 ## Normalise to [0-1]. |
97 r = r/255; | 110 r = r/255; |
98 g = g/255; | 111 g = g/255; |
99 b = b/255; | 112 b = b/255; |