Skip to content

Log-Gabor filter

Fact Value
Also called Log Gabor filter, Log-Gabor wavelet
Status Implemented and tested
Family Frequency-domain filters (also Texture, corners, blobs and features)
Engine Browser
Type Linear, frequency, frequency response
Output Image
Operator shown as frequency-response (exact)
Support radius global
Code web/src/core/filters/frequency/shaping.ts, logGaborFilter
Operator code web/src/core/filters/frequency/shaping.ts, logGaborResponse
Channels Brightness only, RGB

Overview

The log-Gabor filter is a band-pass filter that is a Gaussian on a log frequency scale. Unlike a Gabor filter, it has no response at frequency 0, so flat areas give 0. Its band can be wide, with a long tail toward fine detail, which matches the spectrum of natural images. With one direction it finds lines and edges like a Gabor filter.

Three panels: a Siemens star, the response H as a bright blob on the right of the spectrum, and the magnitude result, bright where the spokes run up and down. Three panels: a Siemens star, the response H as a bright blob on the right of the spectrum, and the magnitude result, bright where the spokes run up and down.
A log-Gabor filter with wavelength 8 and angle 0 responds to the parts of the star whose stripes run up and down.

How it works

  1. Transform the image with the FFT.
  2. Multiply by the log-Gabor response, which keeps a band of frequencies around 1 / wavelength.
  3. With one direction, the response keeps only frequencies near that direction.
  4. Transform back and show the magnitude, the real part or the imaginary part.

Mathematical foundation

\[ H = e^{-\frac{(\ln(f / f_0))^2}{2 (\ln(\sigma / f_0))^2}}\, e^{-\Delta\theta^2 / 2 \sigma_\theta^2},\quad f_0 = 1 / 8,\ \sigma / f_0 = 0.55 \]

The formula shows the default parameter values.

where

  • \(f\): The distance from the center of the spectrum in cycles per pixel
  • \(f_0\): The center frequency
  • \(\sigma / f_0\): The bandwidth ratio
  • \(\Delta\theta\): The angle between a frequency and the filter direction
  • \(\sigma_\theta\): The angular spread

The radial part is Field's log-Gabor function, a Gaussian of ln(f / f_0). It is 0 at frequency 0 and falls off slowly toward high frequencies. The angular part is Kovesi's Gaussian of the angle Delta theta between a frequency and the filter direction. Here f is the distance from the center of the spectrum in cycles per pixel. The y axis points down, so the direction of a frequency is atan2(-f_y, f_x). With one direction the filter covers one side of the spectrum, so the result is complex. Without a direction the angular part is left out and the result is real.

Field's radial log-Gabor function is a Gaussian of ln(f / f_0). On a log scale it is symmetric, so it falls as fast toward 2 f_0 as toward f_0 / 2, and it is 0 at frequency 0. The ratio sigma / f_0 sets the bandwidth: 0.55 gives about 2 octaves. Kovesi multiplies it by a Gaussian of the angle to the filter direction. That response covers one side of the spectrum, so the result is complex. Its real part is an even, line-like response and its imaginary part an odd, edge-like one. The angle turns counterclockwise on screen, as for the Gabor filter.

Kernel or operator

The operator is the response H, which the Inspector draws over the spectrum, with its profile along the f_x axis.

Algorithm

  1. Extend the image with the border mode by half its size, at most 256 pixels, on each side.
  2. Take the 2D FFT and multiply each frequency by H.
  3. Take the inverse FFT.
  4. Return the real part, the imaginary part or the magnitude, and crop the extension.

Parameters

Parameter Default Values Meaning
Wavelength wavelength 8 3 to 64 px The wavelength 1 / f_0 at the center of the pass band, in pixels.
Bandwidth ratio sigmaOnf 0.55 0.3 to 0.9 The ratio sigma / f_0 of the log-Gaussian. 0.55 gives about 2 octaves, 0.75 about 1 octave.
One direction oriented on On or off With this on, the filter keeps one direction of the spectrum. With it off, it keeps all directions.
Angle angle 0 0 to 360 deg The direction in which the wave changes, counterclockwise on screen. 0 finds vertical stripes.
Angular spread angularSigma 25 5 to 90 deg The standard deviation sigma_theta of the angular Gaussian.
Output output Magnitude Magnitude, Real part (lines), Imaginary part (edges) Which part of the complex result to show, when the filter has one direction.
Output mapping outputMapping Stretch to full range Absolute value, Offset by 128, Stretch to full range, Clip to 0 to 255 How signed results, such as gradients, become 8-bit pixel values.
Border mode border Reflect Reflect 101 (default), Reflect, Replicate, Constant (zero), Wrap How pixels outside the image are filled when the window reaches past the edge.
Channels channelScope Brightness only RGB, Brightness only Which part of the color image the filter changes.

Implementation

logGaborFilter in web/src/core/filters/frequency/shaping.ts builds H with logGaborResponse. As for the other frequency filters, the image is extended with the border mode by half its size, at most 256 pixels, on each side. The filter needs the whole spectrum, so it always runs on the whole image, and a selection is cut out of the result.

Worked example

Frequency along the filter direction H
0.25 f_0 0.0680
0.5 f_0 0.5106
1 f_0 1
2 f_0 0.5106
4 f_0 0.0680
Angle from the filter direction, at f_0 H
0 degrees 1
25 degrees 0.6065
50 degrees 0.1353
90 degrees 0.0015

The response for wavelength 8, so f_0 = 0.125, bandwidth ratio 0.55 and angular spread 25 degrees. On a log scale the band is symmetric: H at f_0 / 2 equals H at 2 f_0. At one angular spread from the direction it is e^-0.5.

Complexity

  • Time: \(O(N log N)\)
  • Memory: \(O(N)\)

N is the number of pixels of the extended image, about 4 times the image for images up to 512 pixels on a side.

Artifacts and limitations

Limitations

  • It has no closed form in space, so it runs in the frequency domain.
  • One filter sees one scale and one direction.

Artifacts

  • Ringing next to strong edges, from the band shape.

Tests

The reference extends the plane with numpy.pad, filters it with numpy.fft and crops it. The cases cover the three outputs with one direction and the real result without a direction.

References

  • Field, D. J. Relations between the statistics of natural images and the response properties of cortical cells. Journal of the Optical Society of America A 4(12), 2379 to 2394, 1987. DOI 10.1364/JOSAA.4.002379.
  • Kovesi, P. Phase congruency, a low-level image invariant. Psychological Research 64(2), 136 to 148, 2000. DOI 10.1007/s004260000024.