傅里葉描繪子原理及應用簡介


 

1 引言

物體的形狀識別是模式識別的重要研究方向,廣泛用於圖像分析、機器視覺和目標識別的應用中。在計算機中物體的形狀表示方式有多種:邊界曲線上點的坐標序列,邊界上的點到物體中心的距離以及邊界上的點隨弧長變化的切線方向等。基於形狀不同的表示方式,已有大量的形狀識別方法被提出,如:基於邊界特征點,不變矩、傅里葉描繪子和自回歸模型等。Kauppien 比較了各種典型的形狀識別方法,實驗表明基於物體輪廓坐標序列的傅里葉描述子具有最佳形狀識別性能。

2 傅里葉描述子

傅里葉描述子的基本思想是:假定物體的形狀是一條封閉的曲線,沿邊界曲線上的一個動點P(l)的坐標變化x(l)+iy(l)是一個以形狀邊界周長為周期的函數,這個周期函數可以用傅里葉級數展開表示,傅里葉級數中的一系列系數z(k)是直接與邊界曲線的形狀有關的,稱為傅里葉描述子。

The outline of the shape is seen as a closed curve, described by its arc length s from an origin A.  We normalize this parameter so that its sum over the whole curve is equal to 2.Pi, it is the parameter t as shown below. We define a function of t, called Phi, that gives the angular variation between the tangent at the origin A and the tangent at position s.

(1)

此函數是連續的周期的(周期為2.pi),所以可以通過傅里葉級數來表示:

(2)

式中a(k)就是傅里葉描繪子

3測試算法

3.1 尋找形狀的閉合邊界

 

 1 function [new_indeces]=find_close_indeces(im_in)
 2 
 3 [r,c]=find(im_in);
 4 
 5 p=pdist([r c]);
 6 psqr=squareform(p);
 7 
 8  nl=length(r);
 9  
10 new_indeces=[r(1) c(1)];
11 ind_ind_data=1;
12 lenindata=1;
13 newind=1;
14  for ind=2:nl
15   
16     mcur_dist=psqr(newind,:);
17     [dist_min,dist_min_ind]=sort(mcur_dist);
18     [dmin inddmin]=setdiff( dist_min_ind,ind_ind_data);
19     dist_min_ind =  dist_min_ind(sort(inddmin));
20     newind=dist_min_ind(1);
21     new_indeces  =[new_indeces; [r(newind) c(newind)]];
22     
23      ind_ind_data=[ind_ind_data; newind];
24     lenindata=length(ind_ind_data);
25     
26  end
27  

3.2  傅里葉描述子對形狀進行處理並且重建

 1 function [border_fft,border_restored,xx,yy] = make_fft_sec(image_edged,ncoef)
 2 
 3 border_fft=zeros(size(image_edged));border_restored=zeros(size(image_edged));
 4 [a,b]=size(image_edged);
 5 
 6 % find border
 7  f=find(image_edged);
 8  lenf=length(f);
 9 
10  
11   [new_indeces]=find_close_indeces(image_edged);
12   ii=new_indeces(:,1);jj=new_indeces(:,2);
13  border_cmplx=ii+j*jj;
14 
15    border_fft =fftshift(fft(border_cmplx));
16    
17    if mod(lenf,2) % odd
18     lenf = lenf-1;
19    end
20     rc = fix(lenf/2)+1;  
21 
22 
23 p1=[ (rc+1):(rc+1+ncoef-1)];
24 p2=[ (rc-1):-1:(rc-1-ncoef+1)];
25 
26 
27 
28 border_ifft=zeros(1,lenf);
29 for ind=1:(ncoef)
30     mfreq_vec=zeros(1,lenf);
31    mfreq_vec(p1(ind))=border_fft(p1(ind));
32     mfreq_vec(p2(ind))=border_fft(p2(ind));
33     
34     border_ifft = border_ifft+(ifft(ifftshift(mfreq_vec)));
35 end
36 
37 %add dc
38  mfreq_vec=zeros(1,lenf);
39  mfreq_vec(rc)=border_fft(rc);
40  border_ifft = border_ifft+(ifft(ifftshift(mfreq_vec)));
41 
42 
43 border_restored = zeros(size(image_edged));
44 xx=real(border_ifft);yy=imag(border_ifft);
45 
46 
47 yyt=round(yy);xxt=round(xx);
48 
49 if(length(xxt)==0)
50     return ;
51 end
52 
53 hind=sub2ind(size(border_restored),yyt,xxt);
54 border_restored(round(hind))=1;
55 
56 figure(4),plot((xx),yy,'ro');

 

3.3 測試代碼 

 1 %% create the matrix
 2 shapes=2;
 3 
 4 switch shapes
 5     case 1
 6         m=zeros(22);
 7         m(4:19,4)=1;m(4:19,19)=1;
 8         m(4,5:19)=1;m(19,5:19)=1;
 9     case 2
10         m=zeros(41);
11         m(5,18:24)=1;
12         m(5:19,18)=1; m(5:19,24)=1; m(19:25,5)=1;
13         m(19,5:18)=1;m(19,24:37)=1; m(19:25,37)=1;
14         m(25,5:18)=1;m(25,24:37)=1;
15         m(25:39,18)=1; m(25:39,24)=1;
16         m(39,18:24)=1;
17     case  3
18         m=zeros(30);
19          m(10,14:20)=1;
20          m(10:22,14)=1;
21           m(16,14:20)=1;
22 end
23 
24 figure(1),imagesc(m);length(find(m))
25 %% make fft transform                       
26 
27 [border_fft,border_restored]=make_fft_sec(m,10);
28 figure(2),imagesc(border_restored);

參考:

http://www.tsi.telecom-paristech.fr/pages/enseignement/ressources/beti/descript_fourier/index.html

王濤, 劉文印, 孫家廣, 張宏江 - 《計算機研究與發展》2002年12期


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM