Skip to content

Periodic-noise suppression

Fact Value
Also called Automatic notch filter, Periodic noise removal
Status Implemented and tested
Family Frequency-domain filters
Engine Browser
Type Nonlinear, frequency, peak detection and notch rejection
Output Image
Operator shown as algorithm (exact)
Support radius global
Code web/src/core/filters/frequency/notch.ts, periodicNoiseFilter
Operator code web/src/core/filters/frequency/notch.ts, findPeaks
Channels RGB, Brightness only

Overview

Periodic-noise suppression removes stripes, moire and other periodic noise without placing notches by hand. It finds the peaks of the noise in the spectrum, the points that are much brighter than the rest of their ring, and removes each with a Gaussian notch. The rule for finding peaks is PixelNexus's own.

Three panels: disks with diagonal stripes, the spectrum with the found peaks tinted red, and the result with the stripes gone. Three panels: disks with diagonal stripes, the spectrum with the found peaks tinted red, and the result with the stripes gone.
Periodic noise suppression finds the peaks of the wave on its own and removes them.

How it works

  1. Remove the mean of the image and fade it to 0 at the edges with a Hann window, so a pattern makes a sharp peak in the spectrum.
  2. Find the points of the spectrum that are the largest in their 5 x 5 neighborhood and much brighter than the median of their ring.
  3. Keep the strongest, up to the most peaks.
  4. Remove them with Gaussian notches, as the notch-reject filter does.

Mathematical foundation

\[ L(f) = \ln\left(1 + \left|\mathcal{F}\{(I - \bar{I})\, w\}(f)\right|\right),\quad L(p) - \operatorname{median}_{|f| \approx |p|} L(f) \ge 3,\quad H = \prod_k \left(1 - e^{-D_k^2 / 2 D_0^2}\right) \]

The formula shows the default parameter values.

where

  • \(L\): The log magnitude of the windowed spectrum
  • \(w\): A 2D Hann window
  • \(p\): A peak frequency
  • \(D_k\): The distance from notch center k in cycles per pixel
  • \(D_0\): The notch radius

This is PixelNexus's own rule. The peaks are found in the spectrum of the image itself, with its mean removed and a 2D Hann window w applied. There, a periodic pattern makes a sharp peak. A peak is a local maximum of L in its 5 x 5 window. It must rise above the median of L on its ring, the frequencies at the same distance from the center, by at least the threshold. Only peaks at least the lowest frequency away from the center count. Each peak then gets a Gaussian notch, at its mirror points too, as in the notch-reject filter, and the image extended with the border mode is filtered.

The spectrum of a natural image falls off with frequency. A single threshold for the whole spectrum would miss weak peaks far from the center and find false ones near it. Comparing each point with the median of its ring, the frequencies at the same distance from the center, follows that fall-off. The median ignores the few bright peaks in a ring. The threshold is in natural log units, so 3 means a peak at least e^3, about 20, times the median. The window keeps the peak of a pattern compact, so the 5 x 5 test sees it as one maximum. 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 peaks depend on the image, so the Inspector lists the four stages: the windowed spectrum, the peak test, the notches and the result. The Frequency explorer and the Spectrum panel show the notches found.

Algorithm

  1. Remove the mean of the image and multiply it by a 2D Hann window.
  2. Take the FFT and the log magnitude L.
  3. Find the local maxima of L that rise above the median of their ring by the threshold.
  4. Keep the strongest, up to the most peaks.
  5. Reject them with Gaussian notches on the spectrum of the image extended with the border mode.

Parameters

Parameter Default Values Meaning
Threshold threshold 3 0.5 to 10 How far a peak must rise above the median of its ring, in natural log units. 3 means about 20 times stronger.
Lowest frequency minFrequency 0.05 0.01 to 0.4 cycles/px Peaks closer than this to the center of the spectrum are left alone, since the center holds the main content of the image.
Most peaks maxPeaks 8 1 to 32 The most peaks to remove, the strongest first.
Notch radius radius 0.01 0.002 to 0.1 cycles/px The radius D_0 of the Gaussian notch at each peak, in cycles per pixel.
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

periodicNoiseFilter in web/src/core/filters/frequency/notch.ts finds the peaks with windowedSpectrum and findPeaks, then filters with Gaussian notches. Values within a relative 1e-9 count as equal, so mirror-image points of the spectrum, which differ only by rounding, are both found as peaks. 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

Peak fx fy Period (pixels)
1 0.1000 0.0500 8.94

The peaks found on the noisy disks image of the figure, with the default settings. The wave has the frequency (0.1, 0.05), a period of 8.94 pixels. On this 160 x 160 image the wave lies exactly on the grid of the FFT, in steps of 1 / 160 = 0.00625, so the peak is found at the wave frequency itself. Other waves give the grid frequency next to them. The peak gets a Gaussian notch at its mirror points too.

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

  • Strong straight edges make streaks in the spectrum that can pass as peaks. Raise the threshold or the lowest frequency.
  • A pattern that does not fit the image a whole number of times leaks around its peaks, so some of it stays near the image edges.

Artifacts

  • Faint waves near the image edges where the pattern was cut off.

Tests

The reference finds the peaks with the same rule in NumPy, with numpy.hanning for the window and the lower median of each ring. Before the cases are written, the script adds waves to a smooth ramp, one that fits the image a whole number of times and one that does not. It checks that the peaks are found next to the wave frequency. It also checks that the error left in the center of the image is below 5 percent of the wave height, for three border modes.

References

  • Gonzalez, R. C. and Woods, R. E. Digital Image Processing, 4th edition. Pearson, 2018. Chapter 5, periodic noise and its reduction.