开发者

image Texture Feature using Gabor filter

I have the following gabor filter to extract image texture feature..

a=imread('image0001.jpg');
a=double(a); 
a=a-mean(a(:)); 
[r,c,l]=size(a); 

 K=5;  S=6;
 Uh=0.4;
 Ul=0.05;
 alpha=(Uh/Ul)^(1/(S-1));  
 sigmau=(alpha-1)*Uh/((alpha+1)*sqrt(2*log(2))); 
 sigmav=tan(pi/(2*K))*(Uh-2*log(2)*((sigmau^2)/Uh))/sqrt((2*log(2))-(((2*log(2))^2)*(sigmau^2)/(Uh^2)));
 sigmax=1/(2*pi*sigmau);
 sigmay=1/(2*pi*sigmav);
 b=fft2(a);
 [e d]=size(b);
  i=1;
 G=zeros(r,c,S*K);
 IZ=zeros开发者_Go百科(r,c,S*K);
for m=0:S-1
    for n=0:K-1 
       fprintf(1,'.');
       for x=-r/2+1:r/2;
          for y=-c/2+1:c/2;
             xdash=(alpha^(-m))*((x)*cos(n*pi/K)+(y)*sin(n*pi/K));
             ydash=(alpha^(-m))*((y)*cos(n*pi/K)-(x)*sin(n*pi/K));
             g(r/2+x,r/2+y)=(alpha^(-m))*((1/(2*pi*sigmax*sigmay))*exp(-0.5*(((xdash^2)/(sigmax^2))+((ydash^2)/(sigmay^2)))+0.8i*pi*xdash));
          end
       end
       [rr cc]=size(g); 
       G(:,:,i)=g;
       h=fft2(g); 
       z=b.*h;
       iz=ifft2(z);
       IZ(:,:,i)=iz;
       FeatureVector(i)=mean(abs(iz(:)));
       i=i+1;
    end
 end
 fprintf(1,'\n');

%%%%%%%%%

When I run this code I get this Error:

Error using ==> times Matrix dimensions must agree. Error in ==> ComputeGaborFeatures4 at 37 z=b.*h;

Please if any one can help me to solve this error or any one can give me another simple gabor filter?


The error is due to the calling of Array Multiplication (.*) with b and h of non equal size, because rr doesn't equal r and cc doesn't c.

Either you wanted to use Matrix Multiplication (*) or you need to make g and a the same size before calling fft2.


the error might change the g(r/2+x,r/2+y) to g(r/2+x,c/2+y), the the

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜