【问题标题】:Designing a Gabor filter bank in the Fourier domain在傅里叶域中设计一个 Gabor 滤波器组
【发布时间】:2017-01-26 23:56:33
【问题描述】:

我正在尝试使用 Matlab 中的以下代码在傅里叶域中设计一个 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, []);

我在过滤器的中心得到奇怪的图案(如附图所示)。请告诉我我的代码有什么问题?

【问题讨论】:

    标签: matlab fft ifft gabor-filter


    【解决方案1】:

    我发现了问题。与其将中心坐标乘以 [(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));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-26
      • 2011-04-16
      • 1970-01-01
      • 2014-05-26
      • 2016-08-26
      • 1970-01-01
      • 1970-01-01
      • 2013-02-10
      相关资源
      最近更新 更多