1. Overview

In this tutorial, we’ll talk about the Gabor filters, a classic tool in image processing.

First, we’ll explain how to compute them. Then we’ll illustrate how to generate features for machine learning using Gabor filters.

2. What Are Gabor Filters?

A Gabor filter is a linear filter used in image processing for edge detection, texture classification, feature extraction and disparity estimation. It is a bandpass filter, i.e. it passes frequencies in a certain band and attenuates the other frequencies outside such band. A Gabor filter is a Gaussian modulated by a plane wave.

The convolution kernel can be expressed as:

(1)   \begin{equation*} g(x, y ; \lambda, \theta, \psi, \sigma, \gamma)=\exp \left(-\frac{x^{\prime 2}+\gamma^{2} y^{\prime 2}}{2 \sigma^{2}}\right) \exp \left[i\left(2 \pi \frac{x^{\prime}}{\lambda}+\psi\right)\right] \end{equation*}

where x^{\prime}=x \cos \theta+y \sin \theta and y^{\prime}=-x \sin \theta+y \cos \theta. In Eq. 1 \lambda is the wavelength of the plane wave, \theta represents the orientation of the parallel stripes of the filter, \sigma is the standard deviation of the Gaussian component, \gamma is the aspect ratio that defines the ellipticity of the function support, \psi is the phase of the plane wave.

The response matrix R(x,y) is obtained by convolving the original image I(x,y) with the Gabor filter g(x, y ; \lambda, \theta, \psi, \sigma, \gamma):

(2)   \begin{equation*} R(x, y ; \lambda, \theta, \psi, \sigma, \gamma)  =  \sum_{x^{\prime}} \sum_{y^{\prime}} I(x - x^{\prime}, y - y^{\prime})g(x^{\prime}, y^{\prime} ; \lambda, \theta, \psi, \sigma, \gamma) . \end{equation*}

Several filters can be defined by changing the parameters \lambda, \theta, \sigma, \psi and \gamma. A Gabor filter bank is a set of Gabor filters with different parameters.

Different low-level features can be extracted from the original image via the convolution operation by varying the Gabor parameters. The following figure shows several filtered images obtained using the real parts of Gabor filters with different orientations \theta and wavelength \lambda:

gabor filter application

We can see that horizontal and vertical features are extracted with \theta=0 and \theta=90, respectively. Furthermore, we can extract finer details with lower wavelength values.

The image analysis with Gabor filters well represents the perception in the human visual system.

3. Generating Features With Gabor Filters

There are several ways to extract features with Gabor filters. The most relevant ones are discussed below:

  • The simplest way to generate features with Gabor Filters is to use the real or the imaginary part of the response matrix as a feature vector
  • The phase of the response matrix can be taken as a feature vector since it contains relevant information about the edges
  • The amplitude of the response matrix can be taken as a feature vector since it includes the frequency spectrum
  • The squared sum of different wavelength responses with the same orientation can be taken as a feature vector. It represents the local energy in a particular direction

4. Conclusion

In this article, we reviewed the Gabor convolution filters, commonly used in image processing. Finally, we illustrated how to extract features from images using Gabor filters.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.