简体   繁体   English

如何在matlab中显示40 gabor过滤器

[英]How to show 40 gabor filter in matlab

can someone help me how to show gabor filter in matlab, i can show it but its not what i want. 有人可以帮助我如何在matlab中显示gabor过滤器,我可以展示它,但它不是我想要的。 this is my code : 这是我的代码:

 [Gf,gabout] = gaborfilter1(B,sx,sy,f,theta(j));


G{m,n,i,j} = Gf;

and this is gabor filter class: 这是gabor过滤器类:

function [Gf,gabout] = gaborfilter(I,Sx,Sy,f,theta);

if isa(I,'double')~=1 
    I = double(I);
end

for x = -fix(Sx):fix(Sx)
    for y = -fix(Sy):fix(Sy)
        xPrime = x * cos(theta) + y * sin(theta);
        yPrime = y * cos(theta) - x * sin(theta);
        Gf(fix(Sx)+x+1,fix(Sy)+y+1) = exp(-.5*((xPrime/Sx)^2+(yPrime/Sy)^2))*cos(2*pi*f*xPrime);
    end
end

Imgabout = conv2(I,double(imag(Gf)),'same');
Regabout = conv2(I,double(real(Gf)),'same');

gabout = sqrt(Imgabout.*Imgabout + Regabout.*Regabout);

Then, I imshow with this code: 然后,我用这段代码表达:

imshow(G{m,n,i,j},[]);

and the results : 结果:

在此输入图像描述

But i want this result, can someone help me how to slove this? 但我想要这个结果,有人可以帮我解决这个问题吗?

gabor过滤器

Use the following function. 使用以下功能。 I hope this is useful. 我希望这很有用。
---------------------------------------------------------------- -------------------------------------------------- --------------

gfs = GaborFilter(51,0.45,0.05,6,4);
n=0;
for s=1:6
   for d=1:4
        n=n+1;
        subplot(6,4,n)
        imshow(real(squeeze(gfs(s,d,:,:))),[])
   end
end

Sample Image 示例图像
---------------------------------------------------------------- -------------------------------------------------- --------------

function gfs = GaborFilter(winLen,uh,ul,S,D)

% gfs(SCALE, DIRECTION, :, :)

winLen = winLen + mod(winLen, 2) -1;
x0 = (winLen + 1)/2;
y0 = x0;

if S==1
    a = 1;
    su = uh/sqrt(log(4));
    sv = su;
else
    a = (uh/ul)^(1/(S-1));
    su = (a-1)*uh/((a+1)*sqrt(log(4)));
    if D==1
        tang = 1;
    else
        tang = tan(pi/(2*D));
    end
    sv = tang * (uh - log(4)*su^2/uh)/sqrt(log(4) - (log(4)*su/uh)^2);
end

sx = 1/(2*pi*su);
sy = 1/(2*pi*sv);
coef = 1/(2*pi*sx*sy);

gfs = zeros(S, D, winLen, winLen);

for d = 1:D
    theta = (d-1)*pi/D;
    for s = 1:S
        scale = a^(-(s-1));
        gab = zeros(winLen);
        for x = 1:winLen
            for y = 1:winLen
                X = scale * ((x-x0)*cos(theta) + (y-y0)*sin(theta));
                Y = scale * (-(x-x0)*sin(theta) + (y-y0)*cos(theta));
                gab(x, y) = -0.5 * ( (X/sx).^2 + (Y/sy).^2 ) + (2*pi*1j*uh)*X ;
            end
        end
        gfs(s, d, :, :) = scale * coef * exp(gab); 
    end
end

用复数部分 - > complex(0, (2*pi*f*xprime))替换“cos”分量,并且通过比例因子(1/sqrt(2*Sy*Sx))乘以等式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM