Newer
Older
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
47
48
49
50
51
function [thresh_val,mask]=gtAdjustThreshold(thresh_val,img,h)
%if ~exist('h','var')
% h=figure;
% state=uisuspend(h,false); %create a new figure
%end
quit=0;
subplot(1,2,1);
imshow(img,[])
subplot(1,2,2);
colormap(gray)
set(h,'KeyPressFcn',@sfKeyPress)
while 1
sfUpdateFigure
if quit==1
break
end
end
function sfKeyPress(varargin)
c=varargin{2};
switch c.Key
case 'rightarrow'
thresh_val=thresh_val+thresh_val/10;
sfUpdateFigure;
case 'leftarrow'
thresh_val=thresh_val-thresh_val/10;
sfUpdateFigure;
case 'return'
%exit interactive mode and return current shift
set(h,'KeyPressFcn','');
mask=double(img>thresh_val);
quit=1;
end
end
function sfUpdateFigure
%thresh_val
imshow(img>thresh_val,[]);
drawnow;
end
end