2016-09-19 81 views
0

我試圖利用Matlab軟件下面的代碼設計在傅立葉域Gabor濾波器銀行:設計Gabor濾波銀行在傅立葉域

for i=1:u 
for j = 1:v 
    theta =theta_list(j); 
    w_1_x=(centerFreq(1,i)*((m+1)/2)*cos(theta)); % size of filter and image is m-by-n 
    w_1_y=(centerFreq(2,i)*((n+1)/2)*sin(theta)); 
    w_2_x=(-centerFreq(1,i)*((m+1)/2)*cos(theta)); 
    w_2_y=(-centerFreq(2,i)*((n+1)/2)*sin(theta)); 
    sigma=sqrt((w_1_x)^2+(w_1_y)^2); 
    sigma_H=sigma/(2*pi); 
    gF=fspecial('gaussian', [m,n], sigma_H); 
    gFilter1=circshift(gF, [round(w_1_x), round(w_1_y)]); 
    gFilter2=circshift(gF, [round(w_2_x), round(w_2_y)]); 
    gaborArray1{i,j} = 0.5*gFilter1+0.5*gFilter2; 
    gaborArray2{i,j} = 0.5*1i*gFilter1-0.5*1i*gFilter2; 
    gaborFilterBank{i,j}=gaborArray1{i,j}+1i.*gaborArray2{i,j}; 
end 
end 

然而,當我變換過濾器的圖像域使用下面的代碼和可視化的濾波器的相位圖:

filter=ifft2(ifftshift(gaborFilterBank{i,j})); 
phase=zeros(m, n); 
for p=1:m 
for q=1:n 
    phase(p,q)=atan(imag(filter(p,q)/real(filter(p,q))); 
    end 
end 
figure, imshow(phase, []); 

得到奇怪模式在過濾器的中心(如圖中附圖)。請讓我知道我的代碼有什麼問題?

enter image description here

回答

0

我發現了這個問題。我不應該把中心座標乘以[(m + 1)/ 2,(n + 1)/ 2],而應該乘以[m,n]。更具體地講,而不是:

w_1_x=(centerFreq(1,i)*((m+1)/2)*cos(theta)); % size of filter and image is m-by-n 
w_1_y=(centerFreq(2,i)*((n+1)/2)*sin(theta)); 
w_2_x=(-centerFreq(1,i)*((m+1)/2)*cos(theta)); 
w_2_y=(-centerFreq(2,i)*((n+1)/2)*sin(theta)); 

它應該是:

w_1_x=(centerFreq(1,i)*m*cos(theta)); % size of filter and image is m-by-n 
w_1_y=(centerFreq(2,i)*n*sin(theta)); 
w_2_x=(-centerFreq(1,i)*m*cos(theta)); 
w_2_y=(-centerFreq(2,i)*n*sin(theta));