使用Matlab中的pzernfun函数得到图像的伪泽尼克矩(Pseudo Zernike Moment)

本文介绍了MATLAB中的pzernfun函数,用于计算图像的伪泽尼克矩,通过示例展示了如何使用该函数生成数据并恢复原始图像。函数操作的核心是将图像映射到单位圆并计算相关矩度量。
摘要由CSDN通过智能技术生成

获取函数及其使用方法

pzernfun函数可在下面的链接中获取:

https://ww2.mathworks.cn/matlabcentral/fileexchange/33644-pseudo-zernike-functions?s_tid=FX_rc3_behav作者很贴心地在函数里添加了示例,如果我们想要获取一个图像的伪泽尼克矩,可参考其中的Example2,具体代码见下:

%   Example 2: Pseudo-Zernike moments
%
%        % Build a grid
%        N = 100;
%        x = (-N:2:N)/N;
%        [X,Y] = meshgrid(x);
%        [theta,r] = cart2pol(X,Y);
%        
%        is_in_circle = r <= 1;
%        r = r(is_in_circle);
%        theta = theta(is_in_circle);
%        
%        % Create some data
%        F = peaks(N+1);F = F/max(abs(F(:))); % Normalize
%        F(~is_in_circle) = nan;
%        
%        % Compute a (finite) basis of pseudo-Zernike functions
%        n_max = 7;
%        n = zeros(1,(n_max+1)^2);
%        m = zeros(1,(n_max+1)^2);
%        for k = 0:n_max
%            n(k^2+1:(k+1)^2) = repmat(k,1,2*k+1);
%            m(k^2+1:(k+1)^2) = -k:k;
%        end
%        P = pzernfun(n,m,r,theta);
%        
%        % Estimate the pseudo-Zernike moments, using simple
%        % summation to approxmiate the integrals
%        M = zeros(1,(n_max+1)^2);
%        for k = 1:(n_max+1)^2
%            M(k) = sum(F(is_in_circle)'*P(:,k))*(2/N)^2;
%        end
%        
%        % Use the computed moments to recover the original data
%        F_recovered = nan(size(X));
%        F_recovered(is_in_circle) = P*M';

它相当于是将图像先映射到单位圆中,n_max是阶数,先根据pzernfun函数得到一个矩阵P,再将其与图像F进行一系列运算即可得到维泽尼克矩。

  • 5
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值