function O=Edgedectect(I)
%使用Zernike矩进行边缘检测
%O:边界检测结果
%I:输入灰度图
N=size(I,1);
M11R=[ 0 -0.0150 -0.0190 0 0.0190 0.0150 0
-0.0224 -0.0466 -0.0233 0 0.0233 0.0466 0.0224
-0.0573 -0.0466 -0.0233 0 0.0233 0.0466 0.0573
-0.0690 -0.0466 -0.0233 0 0.0233 0.0466 0.0690
-0.0573 -0.0466 -0.0233 0 0.0233 0.0466 0.0573
-0.0224 -0.0466 -0.0233 0 0.0233 0.0466 0.0224
0 -0.0150 -0.0190 0 0.0190 0.0150 0];
M11I=[ 0 -0.0224 -0.0573 -0.0690 -0.0573 -0.0224 0
-0.0150 -0.0466 -0.0466 -0.0466 -0.0466 -0.0466 -0.0150
-0.0190 -0.0233 -0.0233 -0.0233 -0.0233 -0.0233 -0.0190
0 0 0 0 0 0 0
0.0190 0.0233 0.0233 0.0233 0.0233 0.0233 0.0190
0.0150 0.0466 0.0466 0.0466 0.0466 0.0466 0.0150
0 0.0224 0.0573 0.0690 0.0573 0.0224 0];
M20=[ 0 0.0224 0.0394 0.0396 0.0394 0.0224 0
0.0224 0.0272 -0.0128 -0.0261 -0.0128 0.0272 0.0224
0.0394 -0.0128 -0.0528 -0.0661 -0.0528 -0.0128 0.0394
0.0396 -0.0261 -0.0661 -0.0794 -0.0661 -0.0261 0.0396
0.0394 -0.0128 -0.0528 -0.0661 -0.0528 -0.0128 0.0394
0.0224 0.0272 -0.0128 -0.0261 -0.0128 0.0272 0.0224
0 0.0224 0.0394 0.0396 0.0394 0.0224 0];
I=padarray(I,[3,3],'symmetric','both');
Z11R=conv2(I,M11R,'same');
Z11I=conv2(I,M11I,'same');
Z20=conv2(I,M20,'same');
Z11R=Z11R(4:end-3,4:end-3);
Z11I=Z11I(4:end-3,4:end-3);
Z20=Z20(4:end-3,4:end-3);
Phi=atan2(Z11I,Z11R);
Z11p=Z11R.*cos(Phi)+Z11I.*sin(Phi);
L=Z20./Z11p;
K=1.5*Z11p./((1-L.^2).^1.5);
[X,Y]=meshgrid(1:N,1:N);
x=X-(N+1)/2;y=(N+1)/2-Y;
index=(abs(L)<0.14)&(abs(K)>40);
xx=x+(7/2).*L.*cos(Phi);
yy=y+(7/2).*L.*sin(Phi);
O=zeros(size(I));
for i=1:N
for j=1:N
if(index(i,j)==0)continue;end
col=round(xx(i,j)+(N+1)/2);
row=round((N+1)/2-yy(i,j));
if(row<1||row>N||col<1||col>N) continue;end
O(row,col)=1;
end
end
- 1
- 2
前往页