frdescp.m

%frdescp源程序
function z = frdescp(s) 
%FRDESCP Computes Fourier descriptors. 
%   Z = FRDESCP(S) computes the Fourier descriptors of S, which is an 
%   np-by-2 sequence of image coordinates describing a boundary.   
% 
%   Due to symmetry considerations when working with inverse Fourier 
%   descriptors based on fewer than np terms, the number of points in 
%   S when computing the descriptors must be even.  If the number of 
%   points is odd, FRDESCP duplicates the end point and adds it at 
%   the end of the sequence. If a different treatment is desired, the 
%   sequence must be processed externally so that it has an even 
%   number of points. 
% 
%   See function IFRDESCP for computing the inverse descriptors.  
 
%   Copyright 2002-2004 R. C. Gonzalez, R. E. Woods, & S. L. Eddins 
%   Digital Image Processing Using MATLAB, Prentice-Hall, 2004 
%   $Revision: 1.4 $  $Date: 2003/10/26 23:13:28 $ 
 
% Preliminaries 
[np, nc] = size(s); 
if nc ~= 2  
   error('S must be of size np-by-2.');  
end 
if np/2 ~= round(np/2); 
   s(end + 1, :) = s(end, :); 
   np = np + 1; 
end 
 
% Create an alternating sequence of 1s and -1s for use in centering 
% the transform. 
x = 0:(np - 1); 
m = ((-1) .^ x)'; 
  
% Multiply the input sequence by alternating 1s and -1s to 
% center the transform. 
s(:, 1) = m .* s(:, 1); 
s(:, 2) = m .* s(:, 2); 
% Convert coordinates to complex numbers. 
s = s(:, 1) + i*s(:, 2); 
% Compute the descriptors. 
z = fft(s); 

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值