MATLAB中的Gabor滤波器实现

时间:2016-11-06 08:39:32

标签: matlab gabor-filter

我已经实施了一组Gabor过滤器,但它无法正常工作。任何人都可以帮我解决问题。 这是我实施的代码:

Img=imread('21_training.tif');
Green =  Img( : , : , 2);
Inverted_Green_Channel = 255-Green;
figure, imshow(Inverted_Green_Channel); title('Inverted_Green_Channel');

My_New_Gabor = cell (1,9);
k=1;

Wavelength = [1.5,2.5,3.5];
scales = [3,5,7];
Teta = -15;
N = 12;
bw = 1;
GaborArray = cell(1,1, N);

m=39;
n=39;

%creating the bank
for p = 1 : size (Wavelength,2)
    for t =1 : size (scales,2)
        for f = 1 : N
            Teta = Teta + 15;
            for x = 1: m
                for y = 1:n
                    G(x,y) = exp (-(x^2 + y^2)/(2*(scales(t)^2)))* exp ((1i*pi)/(Wavelength(p)*scales(t))*(x*sin (Teta)- y*cos (Teta)));
                end
            end
            %figure, imshow(G);
            GaborArray{p,t,f} = G;
        end
        Teta = -15;
    end
end


%convolving and getting the maximum
for p = 1 : 3
    for t =1 : 3
        for f = 1 : 12
            gb=  GaborArray{p,t,f};
            im1 = imfilter(Inverted_Green_Channel, gb,'replicate','conv');
            im1 = abs ( double( im1 ));
            if(f == 1)
                Max_Mat = im1;
            else
                Max_Mat = max ( Max_Mat , im1 );
            end

            figure,imshow ( Max_Mat,[] );
            GaborArray{p,t,f}=[];
        end
        My_New_Gabor{1,k} = Max_Mat;

        k=k+1;
        clear im1;
        clear Mat_Mat;
    end
end

这是我的输入图片:

enter image description here

0 个答案:

没有答案