四元数指数矩与Zernike矩的代码(Matlab)比较

(1)---------
Zernike


image.png
image.png
Product = p(x,y).*Rad.*exp(-1i*m*Theta);
Z = sum(Product(:));        % calculate the moments
Z = (p+1)/π

==================================================
指数矩

屏幕快照 2020-01-22 下午10.41.21.png
Product = f(x,y).*Ar.*exp(-1j*m*Theta);
Z = sum(Product(:));        % calculate the moments
Z = 1/4π

(2)---------


屏幕快照 2020-01-22 下午10.15.07.png
N = size(p,1); %N是p的行数, p是输入的图像矩阵
x = 1:N; y = x;
[X,Y] = meshgrid(x,y);
R = sqrt((2.*X-N-1).^2+(2.*Y-N-1).^2)/N;
R = R./sqrt(2);

Theta = atan2((N-1-2.*Y+2),(2.*X-N+1-2));
R = (R<=1).*R;

指数矩相同
(3)


image.png
for s = 0:(p-abs(q))/2
  c = (-1)^s*factorial(p-s)/(factorial(s)*factorial((p+abs(q))/2-s)*...
      factorial((p-abs(q))/2-s));
  rad = rad + c*r.^(n-2*s);
end

==================================================

屏幕快照 2020-01-22 下午10.43.15.png

可以看出 指数矩的计算比Zernike矩简单快捷

Ar = sqrt(2/r)*exp(j*2n*π*r)

(4)归一化处理 获取幅值和角度值

cnt = nnz(R)+1;             % count the number of pixels inside the unit circle
Z = (n+1)*Z/cnt;            % normalize the amplitude of moments
A = abs(Z);                 % calculate the amplitude of the moment
Phi = angle(Z)*180/pi;      % calculate the phase of the mement (in degrees)

(5)重建图像


屏幕快照 2020-01-22 下午11.07.06.png
%利用Zernike矩重建图像
%F:重建结果
%I:输入二值图像
%m:Zernike矩的阶数
N=size(I,1);
F=zeros(size(I));
x = 1:N;
y = x;
[X,Y] = meshgrid(x,y);
Theta = atan2((N-1-2.*Y+2),(2.*X-N+1-2));

for n=0:m
    for m=-n:2:n
    [Znm,Rad]=Zernikmoment(I,n,m);
    Exp=exp(1i*m*Theta);
    F=F+Znm.*Rad.*Exp;
    end
end

==================================================
指数矩


屏幕快照 2020-01-22 下午11.13.55.png

归一化的反过程同上

for n=  -n_man:1:n_max
    for m=-m_man:1:m_max
    [Em,Ar]=EX(I,n,m);
    Exp=exp(j*m*Theta);
    F=F+Em.*Ar.*Exp;
    end
end

参考
1.https://blog.csdn.net/qq_26898461/article/details/47123009
2.https://www.cnblogs.com/luo-peng/p/5170602.html

你可能感兴趣的:(四元数指数矩与Zernike矩的代码(Matlab)比较)