-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfringes_position.m
38 lines (33 loc) · 1020 Bytes
/
fringes_position.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
function [FL_dist,center,radius] = fringes_position(fc,fringes,spacing,px_nm)
figure(6)
imshow(fc)
escape = 0;
while escape == 0
[x(1),y(1), button(1)] = ginput(1);
if max(button(1)) == 3
% right click to finish adding
break
elseif max(button(1)) == 27
% press ESC to discard
continue
end
[x(2),y(2), button(2)] = ginput_custom(1,x(1),y(1));
if max(button(2)) == 3
% right click to finish adding
break
elseif max(button(2)) == 27
% press ESC to discard
imshow(fc)
continue
end
% Calculate radius and center of new measurement
center = [x(1), y(1)];
radius = sqrt((x(2)-x(1))^2+(y(2)-y(1))^2)/px_nm;
% Annotate the figure
viscircles(center,radius,'Color','b', 'lineWidth', 0.5);
end
for i=1:length(fringes.coordinates)
distance_px(i)= mean(sqrt((fringes.coordinates(i).XY(:,1)-center(1,2)).^2+(fringes.coordinates(i).XY(:,2)-center(1,1)).^2));
end
FL_dist=distance_px/px_nm;
return