Skip to content

Notch-reject filter

Fact Value
Also called Notch filter, Notch reject filter
Status Implemented and tested
Family Frequency-domain filters
Engine Browser
Type Linear, frequency, frequency response
Output Image
Operator shown as frequency-response (exact)
Support radius global
Code web/src/core/filters/frequency/notch.ts, notchRejectFilter
Operator code web/src/core/filters/frequency/notch.ts, notchResponse
Channels RGB, Brightness only

Overview

The notch-reject filter removes small regions of the spectrum around chosen frequencies. A periodic pattern, such as stripes or moire, makes bright peaks in the spectrum. Notches on those peaks remove the pattern and leave the rest of the image almost unchanged. Click a peak in the Spectrum panel to place a notch.

Three panels: disks with diagonal stripes, the spectrum with two bright peaks tinted red by the notches, and the result with the stripes gone. Three panels: disks with diagonal stripes, the spectrum with two bright peaks tinted red by the notches, and the result with the stripes gone.
A Gaussian notch at (0.1, 0.05) cycles per pixel removes the stripes.

How it works

  1. Find the peaks of the pattern in the Spectrum panel and place a notch on each.
  2. The filter takes the spectrum of the image with the FFT.
  3. It sets the spectrum to 0 around each notch and its mirror points, with smooth or sharp edges.
  4. It transforms back. The pattern is gone.

Mathematical foundation

\[ H = \prod_k H_k,\quad H_k = \frac{1}{1 + (D_0 / D_k)^{2n}},\quad D_k = \sqrt{(f_x - u_k)^2 + (f_y - v_k)^2},\ D_0 = 0.01 \]

The formula shows the default parameter values.

where

  • \((u_k, v_k)\): The center of notch k: a notch, its mirror point through the origin, and with a mirror border also the mirror points across the axes
  • \(D_k\): The distance from center k in cycles per pixel
  • \(D_0\): The notch radius
  • \(n\): The order of Butterworth notches

The formula shows Butterworth notches. Ideal notches are 0 within D_0 of a center and 1 elsewhere, and Gaussian notches are 1 - exp(-D_k^2 / 2 D_0^2). Each factor H_k is a high-pass filter centered at (u_k, v_k), as in Gonzalez and Woods. A real image has a symmetric spectrum, so a pattern at (fx, fy) also shows at (-fx, -fy), and every notch acts at both points.

Each notch is a high-pass filter H_k centered at its frequency. The response is the product of all of them, as in Gonzalez and Woods. A real image has a symmetric spectrum, so a pattern at (fx, fy) also shows at (-fx, -fy), and each notch acts at both points. The reflect and reflect 101 border modes mirror the image at its edges. So a pattern at (fx, fy) also shows up in the extension at (-fx, fy). For these modes each notch also acts at (-fx, fy) and (fx, -fy). The Spectrum panel draws those points as dashed rings.

Kernel or operator

The operator is the response H. The Inspector draws it over the spectrum, with frequency 0 in the center. The Spectrum panel tints what it removes on the spectrum of the image itself.

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.
  3. Multiply each frequency by H.
  4. Take the inverse FFT and keep the real part.
  5. Crop the extension.

Parameters

Parameter Default Values Meaning
Notches notches 0.2 0.1 Pairs fx fy from -0.5 to 0.5 cycles/px, up to 32 The notch centers as pairs of fx and fy in cycles per pixel, one per line. Click a peak in the Spectrum panel to add one.
Notch shape shape Butterworth Ideal, Butterworth, Gaussian The shape of each notch, as for the low-pass and high-pass filters.
Notch radius radius 0.01 0.002 to 0.1 cycles/px The radius D_0 of each notch, in cycles per pixel.
Order order 2 1 to 10 The order n of Butterworth notches. Other shapes ignore it.
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 RGB RGB, Brightness only Which part of the color image the filter changes.

Implementation

notchRejectFilter in web/src/core/filters/frequency/notch.ts builds H with notchResponse, and the functions in web/src/core/filters/frequency/spectral.ts filter the plane. 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 spectrum of the extended image is multiplied by H. The filter needs the whole spectrum, so it always runs on the whole image, and a selection is cut out of the result. A pattern that does not fit the image a whole number of times is cut off at the image edges. Its peak then leaks into nearby frequencies, so a little of the pattern stays near the edges.

Worked example

Frequency (fx, fy) Where H
(0.1, 0.05) at the notch 0
(-0.1, -0.05) at its mirror point 0
(0.1, -0.05) across the x axis 0
(0.11, 0.05) 0.01 away 0.1993
(0.13, 0.05) 0.03 away 0.8647
(0.3, 0.2) far away 1

A Gaussian notch with radius 0.015 at (0.1, 0.05), with the reflect border. The border mirrors the image, so the notch also acts across the axes, at (0.1, -0.05) and (-0.1, 0.05). Far from the centers H is 1, so the rest of the spectrum is kept.

Complexity

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

N is the number of pixels of the extended image and K the number of notch centers.

Artifacts and limitations

Limitations

  • Notches must be placed on the peaks by hand. Periodic noise suppression finds them on its own.
  • A pattern that does not fit the image a whole number of times leaks around its peak, so some of it stays near the image edges.

Artifacts

  • Faint waves near the image edges where the pattern was cut off.
  • Ringing around strong edges with ideal notches.

Tests

The reference builds the same product of high-pass factors with NumPy and filters the plane extended with numpy.pad. Before the cases are written, the script adds a wave to a smooth ramp. It checks that a Gaussian notch at the wave frequency leaves an error below 5 percent of the wave height in the center of the image. It does so for the reflect, wrap and reflect 101 modes.

References

  • Gonzalez, R. C. and Woods, R. E. Digital Image Processing, 4th edition. Pearson, 2018. Chapter 4, filtering in the frequency domain.