3
votes

I am a very much new to image processing.I want to know how to apply gabor filter on an image with 12 different orientations say 0,15,30,45 to 165.I want to apply this gabor filter for 12 orientations and output of each orientation has to be displayed.My input is a image of retina and output of orientation should be fine tuned image of retina after applying gabor filter.How do i do it?

 %code for gabor filter                
 I = getimage();         
 I=I(:,:,2);    
 lambda  = 8;    
theta   = 0;    
psi     = [0 pi/2];    
gamma   = 0.5;    
 bw      = 1;    
 N       = 12;    
img_in = im2double(I);    
%img_in(:,:,2:3) = [];  % discard redundant channels, it's gray anyway    
 img_out = zeros(size(img_in,1), size(img_in,2), N);        
 for n=1:N         
        gb = gabor_fn(bw,gamma,psi(1),lambda,theta)...          
         + 1i * gabor_fn(bw,gamma,psi(2),lambda,theta);     
         % gb is the n-th gabor filter         
         img_out(:,:,n) = imfilter(img_in, gb, 'symmetric');          
        % filter output to the n-th channel       
        %theta = theta + 2*pi/N;          
        theta = 15 * n;   % i wrote this because my angles are multiples of 15       
        % next orientation           
 end 

 figure(1);           
 imshow(img_in);                  
 title('input image');                    
 figure(2);            
 img_out_disp = sum(abs(img_out).^2, 3).^0.5;        
 %default superposition method, L2-norm        
 img_out_disp = img_out_disp./max(img_out_disp(:));           
 % normalize        
 imshow(img_out_disp);         
 title('gabor output, L-2 super-imposed, normalized');        

my input image is enter image description here

and my output image is enter image description here

how do i orient my image in 12 different direction by applying gabor filter

I am supposed to get a ouput of a retinal image but i am getting my output image as

enter image description here

2
What you are getting is the visualization of the Gabor Filter you are using. You need to apply this filter to the retina image to get the image you want.skytreader
oh oh k sir...i will try doing it...thanks a lot sirvidya
sir, how can i apply this filter to retinal image. i tried using conv2 function but it din work any other methodvidya
the last image is the filter's image right?zenpoy
yes sir ..its the filter image..now i want to impose this image on my original imagevidya

2 Answers

2
votes

You should add these two lines:

...
% gb is the n-th gabor filter 
img_out(:,:,n) = imfilter(img_in, gb, 'symmetric');   
figure;
imshow(img_out(:,:,n));
...  
0
votes

I understand from your question that you want to apply gabor filter 12 time and each time with specified direction(theta) right? to do this --> before for loop write this ----> ...

responses = {}; % to save each response from filter.

and after filtering your image convolve it like this ---->
...

response =  conv2(img_in,gb,'same'); 

...

then get your amplitudes like this ---> ...

realpart = real(response);
imagpart = imag(response);
response = sqrt(realpart.^2 + imagpart.^2);

...

replace ---> img_out(:,:,n) with this ---->
...

responses = cat(1,responses,response);

this code will save your responses from each filter to a cell and if you want to see the responses just do this ...

X = responses{1}; % or 2 or 3...

this link will give a better information about gabor filter http://matlabserver.cs.rug.nl/edgedetectionweb/web/edgedetection_params.html

hope this will help you. best regard.