-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathshow_img.m
46 lines (46 loc) · 1.13 KB
/
show_img.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function [ph] = show_img(img, figno, scaled, map)
%SHOW_IMG display an image with possible scaling
% usage: ph = show_img(img, figno, scaled, map)
% img = input image
% figno = figure number to use for the plot
% if 0, re-use the same figure
% if omitted a new figure will be opened
% optional args:
% scaled = 1 (TRUE) to do auto-scale (DEFAULT)
% not equal to 1 (FALSE) to inhibit scaling
% map = user-specified color map
% ph = figure handle
%----
if( nargin > 1 )
if( figno > 0 )
figure( figno );
end
else
figure;
end
if(nargin < 3)
scaled = 1; %--- TRUE
end;
if (scaled)
disp('Image being scaled so that min value is 0 and max value is 255')
mx = max(max(img));
mn = min(min(img));
omg = round(255*(img-mn)/(mx-mn));
elseif (~scaled)
disp('Values > 255 set to 255 and negative values set to 0')
omg = round(img);
I = find(omg < 0);
omg(I) = zeros(size(I));
I = find(omg > 255);
omg(I) = 255 * ones(size(I));
end;
if (nargin < 4)
colormap(gray(256)) %--- Linear color map
else
omg = img;
colormap(map);
end;
pim = image(omg);
%trusize; %--- DSP First version of truesize
axis('image')
ph = gca;