-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathratio.m
More file actions
84 lines (70 loc) · 2.73 KB
/
ratio.m
File metadata and controls
84 lines (70 loc) · 2.73 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
function [Rate] = ratio(img,y_center,x_center)
r1=25;
r2=76;
r3=152;
[m,n] = size(img);
area_whole=0;
area_in_cir1 = 0;
area_up_cir1 = 0;
area_down_cir1 = 0;
area_in_cir2 = 0;
area_down_cir2 = 0;
area_up_cir2 = 0;
area_in_cir3 = 0;
area_down_cir3 = 0;
area_up_cir3 = 0;
for i = 1:m
for j = 1:n
if ((sqrt(((i-round(y_center))^2) + ((j-round(x_center))^2))< r1) )
area_in_cir1 = area_in_cir1 +1;
if ((i<y_center) && img(i,j))
area_up_cir1 = area_up_cir1 +1;
end
if ((i>y_center) && (img(i,j)==1))
area_down_cir1 = area_down_cir1 +1;
end
end
end
end
Rate.up_ratio_cir1=area_up_cir1/( area_in_cir1/2);
Rate.down_ratio_cir1=area_down_cir1/( area_in_cir1/2);
Rate. whole_cir1 = (area_up_cir1+ area_down_cir1) / area_in_cir1;
for i = 1:m
for j = 1:n
if ((sqrt(((i-round(y_center))^2) + ((j-round(x_center))^2))>r1) && ...
(sqrt(((i-round(y_center))^2) + ((j-round(x_center))^2))<r2) )
area_in_cir2 = area_in_cir2 +1;
if ((i<y_center) && (img(i,j)))
area_down_cir2 = area_down_cir2 +1;
end
if ((i>y_center) && (img(i,j)==1))
area_up_cir2 = area_up_cir2 +1;
end
end
end
end
Rate.down_cir2=area_down_cir2 /( area_in_cir2/2);
Rate.up_cir2=area_up_cir2 /( area_in_cir2/2);
Rate. whole_cir2 = (area_up_cir2+ area_down_cir2) / area_in_cir2;
for i = 1:m
for j = 1:n
if (img(i,j))
area_whole = area_whole+1;
end
if ((sqrt(((i-round(y_center))^2) + ((j-round(x_center))^2))>r2) && ...
(sqrt(((i-round(y_center))^2) + ((j-round(x_center))^2))<r3) )
area_in_cir3 = area_in_cir3 +1;
if ((i<y_center) && (img(i,j)))
area_down_cir3 = area_down_cir3 +1;
end
if ((i>y_center) && (img(i,j)==1))
area_up_cir3 = area_up_cir3 +1;
end
end
end
end
Rate.down_cir3=area_down_cir3 /( area_in_cir3/2);
Rate.up_cir3=area_up_cir3 /( area_in_cir3/2);
Rate.whole = area_whole / (m*n);
Rate. whole_cir3 = (area_up_cir3+ area_down_cir3) / area_in_cir3;
end