Gabor filter

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Example of a two-dimensional Gabor filter

In image processing, a Gabor filter, named after Dennis Gabor, is a linear filter used for edge detection. Frequency and orientation representations of Gabor filters are similar to those of the human visual system, and they have been found to be particularly appropriate for texture representation and discrimination. In the spatial domain, a 2D Gabor filter is a Gaussian kernel function modulated by a sinusoidal plane wave.

Simple cells in the visual cortex of mammalian brains can be modeled by Gabor functions.[1][2] Thus, image analysis with Gabor filters is thought to be similar to perception in the human visual system.


Its impulse response is defined by a sinusoidal wave (a plane wave for 2D Gabor filters) multiplied by a Gaussian function.[3] Because of the multiplication-convolution property (Convolution theorem), the Fourier transform of a Gabor filter's impulse response is the convolution of the Fourier transform of the harmonic function and the Fourier transform of the Gaussian function. The filter has a real and an imaginary component representing orthogonal directions.[4] The two components may be formed into a complex number or used individually.


g(x,y;\lambda,\theta,\psi,\sigma,\gamma) = \exp\left(-\frac{x'^2+\gamma^2y'^2}{2\sigma^2}\right)\exp\left(i\left(2\pi\frac{x'}{\lambda}+\psi\right)\right)


g(x,y;\lambda,\theta,\psi,\sigma,\gamma) = \exp\left(-\frac{x'^2+\gamma^2y'^2}{2\sigma^2}\right)\cos\left(2\pi\frac{x'}{\lambda}+\psi\right)


g(x,y;\lambda,\theta,\psi,\sigma,\gamma) = \exp\left(-\frac{x'^2+\gamma^2y'^2}{2\sigma^2}\right)\sin\left(2\pi\frac{x'}{\lambda}+\psi\right)


x' = x \cos\theta + y \sin\theta\,


y' = -x \sin\theta + y \cos\theta\,

In this equation, \lambda represents the wavelength of the sinusoidal factor, \theta represents the orientation of the normal to the parallel stripes of a Gabor function, \psi is the phase offset, \sigma is the sigma/standard deviation of the Gaussian envelope and \gamma is the spatial aspect ratio, and specifies the ellipticity of the support of the Gabor function.

Feature extraction[edit]

A set of Gabor filters with different frequencies and orientations may be helpful for extracting useful features from an image.[5] Gabor filters have been widely used in pattern analysis applications. For example, it has been used to study the directionality distribution inside the porous spongy trabecular bone in the spine.[6]

Wavelet space[edit]

Demonstration of a Gabor filter applied to Chinese OCR. Four orientations are shown on the right 0°, 45°, 90° and 135°. The original character picture and the superposition of all four orientations are shown on the left.

Gabor filters are directly related to Gabor wavelets, since they can be designed for a number of dilations and rotations. However, in general, expansion is not applied for Gabor wavelets, since this requires computation of bi-orthogonal wavelets, which may be very time-consuming. Therefore, usually, a filter bank consisting of Gabor filters with various scales and rotations is created. The filters are convolved with the signal, resulting in a so-called Gabor space. This process is closely related to processes in the primary visual cortex.[7] Jones and Palmer showed that the real part of the complex Gabor function is a good fit to the receptive field weight functions found in simple cells in a cat's striate cortex.[8]

The Gabor space is very useful in image processing applications such as optical character recognition, iris recognition and fingerprint recognition. Relations between activations for a specific spatial location are very distinctive between objects in an image. Furthermore, important activations can be extracted from the Gabor space in order to create a sparse object representation.

See also: Morlet wavelet

Example implementation[edit]

This is an example implementation in Python:

import numpy

def gabor_fn(sigma,theta,Lambda,psi,gamma):
    sigma_x = sigma;
    sigma_y = float(sigma)/gamma;
    # Bounding box
    nstds = 3;
    xmax = max(abs(nstds*sigma_x*numpy.cos(theta)),abs(nstds*sigma_y*numpy.sin(theta)));
    xmax = numpy.ceil(max(1,xmax));
    ymax = max(abs(nstds*sigma_x*numpy.sin(theta)),abs(nstds*sigma_y*numpy.cos(theta)));
    ymax = numpy.ceil(max(1,ymax));
    xmin = -xmax; ymin = -ymax;
    (x,y) = numpy.meshgrid(numpy.arange(xmin,xmax+1),numpy.arange(ymin,ymax+1 ));
    (y,x) = numpy.meshgrid(numpy.arange(ymin,ymax+1),numpy.arange(xmin,xmax+1 ));
    # Rotation 
    gb= numpy.exp(-.5*(x_theta**2/sigma_x**2+y_theta**2/sigma_y**2))*numpy.cos(2*numpy.pi/Lambda*x_theta+psi);
    return gb

For an implementation on images, see [1].

MATLAB code for Gabor feature extraction from images can be found at . This is an example implementation in MATLAB/Octave:

function gb=gabor_fn(sigma,theta,lambda,psi,gamma)

sigma_x = sigma;
sigma_y = sigma/gamma;

% Bounding box
nstds = 3;
xmax = max(abs(nstds*sigma_x*cos(theta)),abs(nstds*sigma_y*sin(theta)));
xmax = ceil(max(1,xmax));
ymax = max(abs(nstds*sigma_x*sin(theta)),abs(nstds*sigma_y*cos(theta)));
ymax = ceil(max(1,ymax));
xmin = -xmax; ymin = -ymax;
[x,y] = meshgrid(xmin:xmax,ymin:ymax);

% Rotation 

gb= exp(-.5*(x_theta.^2/sigma_x^2+y_theta.^2/sigma_y^2)).*cos(2*pi/lambda*x_theta+psi);

This is another example implementation in Haskell:

gabor λ θ ψ σ γ x y = exp ( (-0.5) * ((x2^2 + γ^2*y2^2) / (σ^2)) :+ 0) * exp ( 0 :+ (2*pi*(x2/λ+ψ)) )
    where x2 =  x * cos θ + y * sin θ
          y2 = -x * sin θ + y * cos θ

(Note: a :+ b should be read as a + i b)

See also[edit]

External links[edit]


  1. ^ Marčelja, S. (1980). "Mathematical description of the responses of simple cortical cells". Journal of the Optical Society of America 70 (11): 1297–1300. doi:10.1364/JOSA.70.001297. 
  2. ^ J. G. Daugman. Uncertainty relation for resolution in space, spatial frequency, and orientation optimized by two-dimensional visual cortical filters. Journal of the Optical Society of America A, 2(7):1160–1169, July 1985.
  3. ^ Fogel, I.; Sagi, D. (1989). "Gabor filters as texture discriminator". Biological Cybernetics 61 (2). doi:10.1007/BF00204594. ISSN 0340-1200. 
  4. ^ 3D surface tracking and approximation using Gabor filters, Jesper Juul Henriksen, South Denmark University, March 28, 2007
  5. ^ Haghighat, M.; Zonouz, S.; Abdel-Mottaleb, M. (2013). "Identification Using Encrypted Biometrics". Computer Analysis of Images and Patterns. Lecture Notes in Computer Science 8048. p. 440. doi:10.1007/978-3-642-40246-3_55. ISBN 978-3-642-40245-6. 
  6. ^ Gdyczynski, C.M.; Manbachi, A.; et al. (2014). "On estimating the directionality distribution in pedicle trabecular bone from micro-CT images". Journal of Physiological Measurements 35 (12): 2415–2428. doi:10.1088/0967-3334/35/12/2415. 
  7. ^ Daugman, J.G. (1980), "Two-dimensional spectral analysis of cortical receptive field profiles", Vision Res. 20 (10): 847–56, doi:10.1016/0042-6989(80)90065-6, PMID 7467139 
  8. ^ Jones, J.P.; Palmer, L.A. (1987). "An evaluation of the two-dimensional gabor filter model of simple receptive fields in cat striate cortex". J. Neurophysiol 58 (6): 1233–1258. 

Further reading[edit]