-
Notifications
You must be signed in to change notification settings - Fork 0
/
selectRectangle.m
34 lines (26 loc) · 1.09 KB
/
selectRectangle.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
function [posMin,posMax,sRectangle,c]=selectRectangle
% selects region in an image for speckle modulation analysis
%
% SYNOPSIS selectRectangle
%
% Alexandre Matov Sept 17, 2003
k = waitforbuttonpress; % only if you dont have an open figure
enough = 0;
c = 1; % counter of RsOI
while ~enough
answer = questdlg('Please select region or Exit','','Select','Exit','Select');
if strcmp (answer,'Select')
k = waitforbuttonpress;
point1 = get(gca,'CurrentPoint'); % button down detected
finalRect = rbbox; % return figure units
point2 = get(gca,'CurrentPoint'); % button up detected
point1 = point1(1,1:2); % extract x and y
point2 = point2(1,1:2);
posMin(c,:) = min(point1,point2); % lower left corner
posMax(c,:) = max(point1,point2); % upper right corner
sRectangle = rectangle('Position',[posMin(c,:),posMax(c,:)-posMin(c,:)],'EdgeColor','r');
c = c + 1;
else
enough = 1;
end
end % ~enough