原理见文献[1]
结果如图
MATALB实现
clear;clc;close all;
I=im2gray(imread('xxx.jpg'));
Coor=Pzernike5(I);
function coordinate=Pzernike5(I)
M00 = [
0.1600, 0.1600, 0.1600, 0.1600, 0.1600;
0.1600, 0.1600, 0.1600, 0.1600, 0.1600;
0.1600, 0.1600, 0.1600, 0.1600, 0.1600;
0.1600, 0.1600, 0.1600, 0.1600, 0.1600;
0.1600, 0.1600, 0.1600, 0.1600, 0.1600];
M11R = [
0.0452, 0.0226, 0.0, -0.0226, -0.0452;
0.0453, 0.0226, 0.0, -0.0226, -0.0453;
0.0452, 0.0226, 0.0, -0.0226, -0.0452;
0.0453, 0.0226, 0.0, -0.0226, -0.0453;
0.0452, 0.0226, 0.0, -0.0226, -0.0452];
M11I = [
0.0452, 0.0453, 0.0452, 0.0453, 0.0452;
0.0226, 0.0226, 0.0226, 0.0226, 0.0226;
0.0, 0.0, 0.0, 0.0, 0.0;
- 0.0226, -0.0226, -0.0226, -0.0226, -0.0226;
- 0.0452, -0.0453, -0.0452, -0.0453, -0.0452];
M10 = [
0.0330, -0.0069, -0.0228, -0.0069, 0.0330;
-0.0069, -0.0620, -0.0892, -0.0620, -0.0069;
-0.0288, -0.0892, -0.1340, -0.0892, -0.0288;
-0.0069, -0.0620, -0.0892, -0.0620, -0.0069;
0.0330, -0.0069, -0.0228, -0.0069, 0.0330];
M20 = [
-0.0093, -0.0416, -0.0421, -0.0416, -0.0093;
-0.0416, -0.0133, 0.0313, -0.0133, -0.0416;
-0.0421, 0.0313, 0.1467, 0.0313, -0.0421;
-0.0416, -0.0133, 0.0313, -0.0133, -0.0416;
-0.0093, -0.0416, -0.0421, -0.0416, -0.0093];
I=double(I);
I=padarray(I,[3,3],'symmetric','both');
PZ00=conv2(I,M00,'same');
PZ11R=conv2(I,M11R,'same');
PZ11I=conv2(I,M11I,'same');
PZ10=conv2(I,M10,'same');
PZ20=conv2(I,M20,'same');
theta=atan2(PZ11I,PZ11R);
PZ11p=PZ11R.*cos(theta)+PZ11I.*sin(theta);
L=(PZ20+4.*PZ10)./(5.*PZ11p+eps);
K=(1.5.*PZ11p)./((1 - L.^2).^1.5+eps);
H=(PZ00-0.5.*K.*pi+K.*asin(L)+K.*L.*sqrt(1 - L.^2))./pi;
Threshold=30;
delta=0.2;
g_N=5;
Out=zeros(size(I));
Out(abs(K-H)>Threshold & abs(L./g_N)<delta)=1;
figure;imshow(imcomplement(Out));
[x,y]=find(Out==1);%边缘的像素级坐标
%亚像素坐标
coordinate=[x+g_N/sqrt(2).*L(Out==1).*cos(theta(Out==1)),y+g_N/sqrt(2).*L(Out==1).*sin(theta(Out==1))];
end
参考文献
[1] Kaur A , Singh C . Sub-Pixel Edge Detection Using Pseudo Zernike Moment[J]. international journal of signal processing image processing & pattern recognition, 2011.