title: Filtering using Gabor filter
body: <p>I have implemented a Gabor filter but don't know how to convolve it with the input image so as to get the desired result.My input image is of size 240*320 and i am dividing it into a block of 17*17..so there are 14*18 =255  blocks in total..I am also not sure what should be the size of Gabor filter and should i need to convolve each filter (14*18 = 252 filters)to each block or whole image..</p>
  
  <p>here is my code.. </p>
  
  <pre><code>    % compute Gabor filter  
          sigma_x = 4;
          sigma_y = 4;
          w = 17;   % size of block
          wg = 5;  % size of filter
          Gabor = zeros(m1,n1);  
  
          for i = 9:w:240-w           
              for j3 = 9:w:320-w
  
                  pim = im(i-ww:i+ww,j-ww:j+ww);  % block of input image
                  f = F(i,j);                     %each block contains single value 
                                                  of freuency and theta
                  O = theta(i,j);
                  [x,y] = meshgrid(-floor(wg/2):floor(wg/2));
  
  
                  x_phi = x.*cos(O) + y.*sin(O);
                  y_phi = -x.*sin(O) + y.*cos(O);
  
                  x_val = ((x_phi).^2)./(sigma_x.^2);
                  y_val = ((y_phi).^2)./(sigma_y.^2);
  
                  h = exp(-0.5*(x_val+y_val)).*cos((2*pi*f).*(x_phi));
                  Gabor(i-ww:i+ww,j-ww:j+ww) = conv2(pim,h,'same');
  
                  end;              
              end; 
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/BzfS3.jpg" alt="my output"></p>
  
  <p>output image is of fingerprint and should not consisit of white dots on black fingerprint line.</p>