-
Notifications
You must be signed in to change notification settings - Fork 2
/
PCNN_withParameters.m
43 lines (40 loc) · 995 Bytes
/
PCNN_withParameters.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
39
40
41
42
43
function R=PCNN_withParameters(matrix,Para)
link_arrange=Para.link_arrange;
np=Para.iterTimes;
alpha_L=Para.alpha_L;
alpha_Theta=Para.alpha_Theta ;
beta=Para.beta;
vL=Para.vL;
vTheta=Para.vTheta;
%=============================================================
[p,q]=size(matrix);
F_NA=abs(matrix);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
L=zeros(p,q);
U=zeros(p,q);
Y=zeros(p,q);
Y0=zeros(p,q);
Theta=zeros(p,q);
center_x=round(link_arrange/2);
center_y=round(link_arrange/2);
W=zeros(link_arrange,link_arrange);
for i=1:link_arrange
for j=1:link_arrange
if (i==center_x)&&(j==center_y)
W(i,j)=0;
else
W(i,j)=1./sqrt((i-center_x).^2+(j-center_y).^2);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%
F=F_NA;
for n=1:np
K=conv2(Y,W,'same');
L=exp(-alpha_L)*L+vL*K;
Theta=exp(-alpha_Theta)*Theta+vTheta*Y;
U=F.*(1+beta*L);
Y=im2double(U>Theta);
Y0=Y0+Y;
end
R=Y0;