Gabor filter

Dennis Gabor (1900-1979) was Hungarian electrical engineer and physicst. He is most known for inventing holography, for which he received Nobel Prize in 1971. Among many other achievements he proposed so called Gabor filter (1D version, later generalized into 2D) , which will be subject of discussion in current post.

From mathematical point of view two-dimensional Gabor filter is obtained by mulitpling complex sinusoid (referred to as the carrier) by Gaussian function (referred to as an envelope)

where i represtens imaginary unit , psi - phase and sigma standard deviation of the envelope in the x and y axes. The coordinates x and y are rotated in the xy plane by theta angle. They can be obtained using following formula:

initial equation can be transformed using Euler’s formula to a form

In practical applications, the even part (based on cosine carrier, which is an even function) or the odd part (based on sine) is usually used. Example filter (even part) with its components is presented below (f=0.4, sigma=2, theta=pi/4, psi=pi/4)

carrierevelopegabor filter

OK, now you can ask long awaited question: where it is actually used ? It turns out that it can be utilized in image processing, primarly in texture analysis. And to be honest with you it was main topic in my engineering thesis😅. I’m not considering myself as expert in this matter, but as a practitioner. Thanks to adjustable filter parameters (frequency and orientation) we can identify image features like edges, or in more general extract features from image. Feature extraction is based on a two-dimensional discrete convolution operation, where as a mask we use Gabor filter. As a mask we understand 2D image, which as a pixels stores values of the complex Gabor function calculated at discrete points. Example masks you can find below (see how frequency and orientation effects on a mask).

gabor mask variant 1gabor mask variant 2

Alright, since we’ve just delved into some heavy mathematics, it’s a suitable time to wrap up for today and take a breather. Just to sum up from technical aspects I used simple Python script with matplotlib and numpy to visualize filters. Entire script you can find here.

In next posts you will find information how to use Gabor filters to realize certain image processing algorithms. Btw. if you’ve noticed that equations are not written in standard HTML way, I’ll suggest you to read about KaTeX, which is web wrapper for

I’am adding LaTeX to my list of upcoming posts as well, so stay tuned. See you in next episode !