使用 Gabor 滤波器的图像纹理特征
我有以下 gabor 过滤器来提取图像纹理特征。
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(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');
%%%%%%%%%
当我运行此代码时,我收到此错误:
使用 ==> 时出错次矩阵 尺寸必须一致。错误==> 计算GaborFeatures4 位于 37 z=b.*h;
请问是否有人可以帮助我解决此错误,或者有人可以给我另一个简单的 gabor 过滤器吗?
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(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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该错误是由于调用 b 和 h 大小不相等的数组乘法 (.*) 造成的,因为 rr 不等于 r,cc 不等于 c。
您想要使用矩阵乘法 (*),或者需要在调用 fft2 之前使 g 和 a 大小相同。
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.
该错误可能会将 g(r/2+x,r/2+y) 更改为 g(r/2+x,c/2+y),
the error might change the g(r/2+x,r/2+y) to g(r/2+x,c/2+y), the the