Code covered by the BSD License  

Highlights from
Gabor filter

4.6

4.6 | 5 ratings Rate this file 115 Downloads (last 30 days) File Size: 65.43 KB File ID: #23253
image thumbnail

Gabor filter

by Gao Yang

 

11 Mar 2009 (Updated 17 Nov 2010)

Generates Gabor filters using bandwidth, aspect ratio, phase, wavelength and angle as parameters.

| Watch this File

File Information
Description

#5237 implements a Gabor filter for image processing. From the comments and through my own use, the implementation seems to have limited freedom, and also the variances are defined in the original x,y instead of the rotated x', y' directions.

The code is a modified version based on http://en.wikipedia.org/wiki/Gabor_filter following the conventions and parameters used in http://matlabserver.cs.rug.nl/edgedetectionweb/web/edgedetection_params.html.

The function accepts scalar inputs only, and each call generates one filter. The filter generated is always real. Should you wish to build a complex Gabor filter, you may use (0 phase) + j(pi/2 phase). Filtering can be performed using conv2( ) or imfilter( ).

An example file is included, which mimics the behavior of http://matlabserver.cs.rug.nl/edgedetectionweb/web/index.html at default settings with Lena.jpg image as input. Note that the scaling of numbers is different from the web-app, but consistent with the formulae in http://matlabserver.cs.rug.nl/edgedetectionweb/web/edgedetection_params.html

Update 18-Nov-2010: Thanks to Rachel (see comment below), I have corrected a mistake in the example file. The results are unchanged though. Also, the cs.rug.nl website seems offline.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
2D Gabor Filter(Ver1,2,3)

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (10)
01 Mar 2010 David Conger  
01 Aug 2010 Mario

Please, someone can add some usage example of this code to an image to reproduce "exactly" the same results of the matlab's website http://matlabserver.cs.rug.nl ?

29 Sep 2010 James Kelly

hey, do you have any idea how to convert this to c#? I want to convert it but have no idea on how this loops trough pixels on the source image and how it produces the output image...

If you can write c#/c++/java/c code or at least explain to me as in what happens to the pixels that would be great, thanks. :)

04 Nov 2010 Jon Hornstein

I superficially looked at the code and this looks like a gaussian filter with polar rotation of coordinates only 1/2 of the answer. Can you please advise.

My thoughts were:
2D gaussian = g(x,y) = 1/(2*PI*Theta(x)*Theta(y)) * exp(-0.5*[(x/theta(x)).^2 +(y/theta(y)).^2])

gabor = h(x, y) = g(x, y)* exp[j*2*pi*(U*x+V*y)]

04 Nov 2010 Jon Hornstein

Thanks I see now you are using just the real component

16 Nov 2010 Rachel

Very good implementation. And good job normalizing it! What I do notice is: you seem to do (a+b).^2 to get the modulus of the result. I thought for a complex number a+bj, you are supposed to do a.^2+b.^2 for the modulus. Lucky enough for this case, the cross term 2ab is simply zero because we are summing some trigonometric functions from 0 to 2pi.

02 Dec 2010 Marc

Can someone explain me why when a bandwidth >1 is used the result differs from http://matlabserver.cs.rug.nl

using a bandwith of 10 I had to replace

    img_out_disp = sum(abs(img_out).^2, 3).^0.5;
with
    img_out_disp = sum(imag(img_out).^2, 3).^0.5;

in order to have the same results as http://matlabserver.cs.rug.nl

but don't know why. I believe this come from the ratio sigma to lamda < 0.5. Any mathematical explanation?

02 Mar 2011 shuai  
22 Mar 2011 Jason

Great one, thanks a lot. By the way, may I know, what does the size denote? Also, I can't seem to understand how the meshgrid in your code works.

11 Jan 2012 Rakesh Chalasani  
Please login to add a comment or rating.
Updates
30 Sep 2010

Added an example file to mimic the behavior of a known web-app and to demonstrate the usage of the function.

17 Nov 2010

Corrected procedures in the example file. Results are the same but the principle is more generally applicable.

Tag Activity for this File
Tag Applied By Date/Time
gabor filter Cristina McIntire 11 Mar 2009 10:30:34
image processing Gao Yang 11 Mar 2009 10:30:47
gabor filter Ashok kumar 25 Jul 2009 04:48:50
gabor filter that 11 Apr 2010 23:36:49
gabor filter lee joongkeun 08 Jun 2010 22:10:04
image processing lee joongkeun 08 Jun 2010 22:10:07
gabor filter Ahmad 05 Aug 2010 13:35:05
gabor filter Gao Yang 29 Sep 2010 23:02:44
gabor filtergabor_examplem mani 05 Mar 2011 03:26:33
gabor filter Chaoshun 06 Jun 2011 11:49:56

Contact us at files@mathworks.com