Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's tools.

GaborFilter is a tool to perform Gabor filtering on images.

The source code is hosted at the GaborFilter GitHub.

I learned about Gabor filters while working on my Bochum Project.

- View an example image of 'GaborFilter' (png)
- View a screenshot of 'GaborFilter' (png)(version 2.0)
- Download the 'GaborFilter' Windows executable (latest version)(zip)
- Download the 'GaborFilter' Windows executable (latest version)(zip)
- Download the 'GaborFilter' Windows executable (latest version)(zip)

A Gabor filter can have any number of dimension. Below the formula (and a bit of derivation) for the one-dimensional and two-dimensional Gabor filters are described.

The function of a one-dimensional Gabor filter is:

```
f_Gabor(x) = cos(frequency*x) * exp(-(x*x)/(sigma*sigma))
``` |

In the range [-5,5] a nice combination of values is frequency = 4.0 and sigma = 2.0:

```
f_Gabor = cos(4.0*x) * exp(-(x*x)/(2.0*2.0))
``` |

The one-dimensional Gabor filter formula consists out of three parts:

- the cosine part
- the Gaussian function part
- a constant

These three parts are described in detail below.

The cosine part of a Gabor function is dependent on distance and frequency

the Gaussian function part of a Gabor function is dependent on distance and sigma.

A Gaussian function has the form

```
F_Gauss(x)
``` |

The Gaussian function used in the one-dimensional Gabor filter has

```
a = 1
``` |

which results in

```
f_Gabor_part2
``` |

The third term of a Gabor function is a constant that might be used to make the Gaussian integral (that is, the surface underneath the Gaussian function) equal to 1.0.

I have set this term to one, because in my case, the Gaussian integral does not matter, due to rescaling.

Continue reading to find out how to make the Gaussian integral (that is, the surface underneath the Gaussian function) equal to 1.0:

A Gaussian function has the form

```
f_Gauss(x)
``` |

and has the Gaussian integral of

```
F_Gauss(x) = a * c * sqrt(pi)
``` |

Because in the Gabor filter

```
a = 1
``` |

the integral becomes

```
F_Gabor_part2(x)
``` |

This integral denotes the surface underneath a one-dimensional Gaussian function. To make the surface underneath the one-dimensional Gaussian function 1.0, one needs multiply the Gaussian function by the reciprocal of the integral.

The function of a two-dimensional Gabor filter is:

```
f_Gabor(x)
``` |

In the range [-5,5] a nice combination of values is frequency = 4.0 and sigma = 1.5:

```
F_Gabor
``` |

The two-dimensional Gabor filter formula consists out of three parts:

- the cosine part
- the Gaussian function part
- a constant

These three parts are described in detail below.

The cosine part of the two-dimensional Gabor filter formula is dependent on distance and frequency.

The Gaussian function part of the two-dimensional Gabor filter formula is dependent on distance and sigma.

A Gaussian function has the form

```
F_Gauss(x,y)
``` |

The Gaussian function used in the two-dimensional Gabor filter has

```
a = 1
``` |

which results in

```
F_Gabor_part2(x,y)
``` |

The third term is a constant that might make the two-dimensional Gaussian integral (that is, the volume underneath the the Gaussian function) equal to 1.0.

I have set this term to one, because in my case, the Gaussian integral does not matter, due to rescaling.

Furthermore, there is no formula (known to me) that allows the calculate the two-dimensional Gaussian integral. Therefore, only by approximation this value's constant can be found.

For the one-dimensional and two-dimensional Gabor filters I calculate a value of sigma for the filter's size. Sigma determines how fast the Gaussian function starts approaching zero.

If a filter has a size of s pixels, it would be inefficient to have the Gaussian function already approaching zero at s/2. It would be strange that at the edges of a filter, the Gaussian function still have high values.

In this part, I calculate sigma from the filter's size, that the Gaussian function yields a value of 1/510 at the edges. I choose the value of 1/510, because in viewing a filter as a bitmap (with grey values from [0,255], these values will appear as black/zero due to rounding off.

The Gaussian function part (part 2, as described above) of a Gabor filter, has the following formula:

```
f_Gabor_part2(x) = exp(-(x * x)/(2.0 * sigma * sigma))
``` |

Assume a filter size and halve it to obtain s (s is like a radius), then

```
x = s
``` |

Which, by approximation is:

```
sigma = sqrt(-(s * s) / -12.46882145143674291132554261896)
``` |

Go back to Richel Bilderbeek's tools.

Go back to Richel Bilderbeek's homepage.

This page has been created by the tool CodeToHtml