-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdivision.m
More file actions
44 lines (42 loc) · 866 Bytes
/
Copy pathdivision.m
File metadata and controls
44 lines (42 loc) · 866 Bytes
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
I = imread('path.gif');
%%
Z = double(I < 255);
ind = find(Z);
[x,y] = ind2sub(size(Z),ind);
[xc,yc,r] = circfit(x,y);
% umppx = 0.645089285714286;
% L = 3159.847/umppx; % substitute the path length in um where it says <path length>
% a = L/r;
u = x-xc;
v = y-yc;
[theta,rho] = cart2pol(u,v);
a = max(diff(sort(theta)));
b = a/7;
%%
figure;
hold on;
minX = Inf;
maxX = -Inf;
for ii = 1:7
theta = b*(ii-1);
x0 = xc;
x1 = 2*r*cos(theta)+xc;
maxX = max(maxX,max(x0,x1));
minX = min(minX,min(x0,x1));
fun = @(x) tan(theta)*(x-xc)+yc;
fplot(fun,[x0 x1]);
end
xlim([minX maxX]);
%%
[Y,X] = ndgrid(1:size(Z,1),1:size(Z,2));
Y = Y-yc;
X = X-xc;
T = atan2(Y,X);
R = sqrt(X.^2 + Y.^2);
D = zeros(size(Z));
for ii = 1:7
theta = b*(ii-1);
tol = min(pi/100,pi./R);
D(abs(T-theta) < tol) = 255;
end
imwrite(flipud(255-D),'division.gif');