-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCandidateMicroExtract.asv
executable file
·127 lines (111 loc) · 2.83 KB
/
CandidateMicroExtract.asv
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
function output4=CandidateMicroExtract(jj,)
gussian1=zeros(9,9);
gussian2=zeros(9,9);
gussian3=zeros(9,9);
gussian4=zeros(11,11);
gussian5=zeros(11,11);
sigma1=1.1;
sigma2=1.2;
sigma3=1.3;
sigma4=1.4;
sigma5=1.5;
for i=1:9
for j=1:9
gussian1(i,j)=(1/(2*pi*(sigma1^2)))*exp(-((i-5)^2+(j-5)^2)/(2*(sigma1^2)));
end
end
for i=1:9
for j=1:9
gussian2(i,j)=(1/(2*pi*(sigma2^2)))*exp(-((i-5)^2+(j-5)^2)/(2*(sigma2^2)));
end
end
for i=1:9
for j=1:9
gussian3(i,j)=(1/(2*pi*(sigma3^2)))*exp(-((i-5)^2+(j-5)^2)/(2*(sigma3^2)));
end
end
%%%
for i=1:11
for j=1:11
gussian4(i,j)=(1/(2*pi*(sigma4^2)))*exp(-((i-6)^2+(j-6)^2)/(2*(sigma4^2)));
end
end
%%%
for i=1:11
for j=1:11
gussian5(i,j)=(1/(2*pi*(sigma5^2)))*exp(-((i-6)^2+(j-6)^2)/(2*(sigma5^2)));
end
end
gussian1=imcomplement((mat2gray(gussian1)));
gussian2=imcomplement((mat2gray(gussian2)));
gussian3=imcomplement((mat2gray(gussian3)));
gussian4=imcomplement((mat2gray(gussian4)));
gussian5=imcomplement((mat2gray(gussian5)));
Maxrr=zeros(R,C);
Minrr=zeros(R,C);
Avgrr=zeros(R,C);
r1=CorrAB(NormInput,gussian1);
r2=CorrAB(NormInput,gussian2);
r3=CorrAB(NormInput,gussian3);
r4=CorrAB(NormInput,gussian4);
r5=CorrAB(NormInput,gussian5);
for i=5:R-6
for j=5:C-6
r=i-4;
c=j-4;
A=[r1(r,c),r2(r,c),r3(r,c),r4(r,c),r5(r,c)];
Maxrr(i,j)=max(A);
Minrr(i,j)=min(A);
Avgrr(i,j)=mean(A);
end
end
imwrite(Maxrr, strcat('Out1\Out1',int2str(jj),'.jpg'));
%threshold1
output=zeros(R,C);
for r=1:R
for c=1:C
if Maxrr(r,c)>0.4
output(r,c)=1;
end
end
end
imwrite(output, strcat('Out2\Out2',int2str(jj),'.jpg'));
%Removing any candidates on the vessels
Stage1=output-bloodVessels;
for r=1:R
for c=1:C
if Stage1(r,c)<0
Stage1(r,c)=0;
end
end
end
imwrite(Stage1, strcat('Out3\Out3',int2str(jj),'.jpg'));
output4=Stage1;
Backgrond = medfilt2(input, [25 25]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%% Region Growing %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
mask1 = false(size(input));
[L1,num1]=bwlabel(output4);
stats1 = regionprops(L1,'all');
for i=1:num1
vlcent=stats1(i).Centroid;
jm=vlcent(1,1);
im=vlcent(1,2);
rms=2;
[x,y]=meshgrid((im-rms):(im+rms),(jm-rms):(jm+rms));
c_mask=(((x-im).^2+(y-jm).^2)<=rms^2);
[r1 c1]=size(c_mask);
for cnt1=1:r1
for cnt2=1:c1
if c_mask(cnt1,cnt2)==1
x1=round(x(cnt1,cnt2));
y1=round(y(cnt1,cnt2));
if x1>0 && x1<R && y1>0 && y1<C
mask1(x1,y1)=1;
end
end
end
end
end
output4=mask1-bloodVessels;