Skip to content

Notch-pass filter

Fact Value
Also called Notch pass filter, Notch filter (pass)
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, notchPassFilter
Operator code web/src/core/filters/frequency/notch.ts, notchResponse
Channels Brightness only, RGB

Overview

The notch-pass filter keeps only small regions of the spectrum around chosen frequencies and removes the rest. Placed on the peaks of a periodic pattern, it extracts the pattern on its own. This shows what a notch-reject filter at the same place removes.

Three panels: disks with diagonal stripes, the spectrum with the regions around the two peaks kept, and the result, which shows only the stripes on flat gray. Three panels: disks with diagonal stripes, the spectrum with the regions around the two peaks kept, and the result, which shows only the stripes on flat gray.
A notch-pass filter at (0.1, 0.05) cycles per pixel keeps only the stripes.

How it works

  1. Place notches on the peaks of the pattern.
  2. The filter takes the spectrum of the image with the FFT.
  3. It keeps the spectrum around each notch and its mirror points and sets the rest to 0.
  4. It transforms back. Only the pattern remains, around 0.

Mathematical foundation

\[ H = 1 - \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. The notch-pass filter is 1 minus the notch-reject filter, so it keeps only the notched regions and the result has no mean brightness.

The notch-pass response is 1 minus the notch-reject response with the same notches. The two results add up to the image. The result has no mean brightness, so the output mapping shows 0 as gray 128 by default. 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. The Spectrum panel tints what it removes, which is everything outside the notches.

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.
Output mapping outputMapping Offset by 128 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

notchPassFilter 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.

Worked example

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

The same notch as a notch-pass filter. H is 1 minus the notch-reject response, so it is 1 at the centers and 0 far away.

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.