Skip to content

Wiener filter (global)

Fact Value
Also called Global Wiener filter, Wiener smoothing filter
Status Implemented and tested
Family Linear spatial filters (also Frequency-domain filters)
Engine Browser
Type Nonlinear, frequency, Wiener gain from a power estimate
Output Image
Operator shown as estimator (exact)
Support radius global
Code web/src/core/filters/frequency/shaping.ts, wienerDenoiseFilter
Operator code web/src/core/filters/frequency/shaping.ts, wienerValues
Channels RGB, Brightness only

Overview

The global Wiener filter removes white noise in the frequency domain. At each frequency it estimates how much of the power is noise and turns the frequency down by that share. It needs the noise level. The adaptive Wiener filter is the local version, which uses statistics of a window instead.

Three panels: disks with strong gray noise, the Wiener result with most of the noise gone, and the clean disks. Three panels: disks with strong gray noise, the Wiener result with most of the noise gone, and the clean disks.
The global Wiener filter with sigma 20 removes most of Gaussian noise of sigma 20.

How it works

  1. Transform the image with the FFT and measure the power at each frequency.
  2. Average the power over the 5 x 5 nearest frequencies.
  3. Keep each frequency in proportion 1 - sigma^2 / P, and remove it where P is not above the noise power.
  4. Transform back.

Mathematical foundation

\[ H(f) = \max\left(0,\ 1 - \frac{\sigma^2}{P(f)}\right),\quad P(f) = \operatorname{mean}_{5 \times 5} \frac{|G(f)|^2}{N},\quad \sigma = 10 \]

The formula shows the default parameter values.

where

  • \(G\): The spectrum of the noisy image
  • \(P\): The averaged power of G
  • \(N\): The number of FFT samples
  • \(\sigma\): The noise standard deviation

The Wiener filter for noise alone is H = S / (S + sigma^2), with S the power of the clean image at each frequency. White noise adds sigma^2 to the power at every frequency. So S is estimated as P - sigma^2, which gives H = 1 - sigma^2 / P, and 0 where P is below sigma^2. Here P is the power |G|^2 / N of the image extended with the border mode, with N the number of FFT samples. It is averaged over the 5 x 5 nearest frequencies to steady it. This estimate of S is this filter's own. The Wiener filter itself follows Gonzalez and Woods.

For an image with added white noise, the Wiener filter with the least mean squared error is H = S / (S + sigma^2). S is the power of the clean image at each frequency. White noise adds sigma^2 at every frequency, so the power of the noisy image is about P = S + sigma^2. Estimating S as P - sigma^2 gives H = 1 - sigma^2 / P. A single frequency is a poor estimate of P, so the filter averages the power over 5 x 5 frequencies. This estimate is the filter's own. The Wiener filter follows Gonzalez and Woods, and is the frequency-domain filter of Lim.

Kernel or operator

The gain depends on the image, so the Inspector lists the stages. The Frequency explorer shows the gain on the patch.

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 the power |G|^2 / N.
  3. Average the power over 5 x 5 frequencies.
  4. Multiply each frequency by max(0, 1 - sigma^2 / P).
  5. Take the inverse FFT and keep the real part.
  6. Crop the extension.

Parameters

Parameter Default Values Meaning
Noise sigma noiseSigma 10 0 to 100 levels The standard deviation sigma of the white noise, in 8-bit levels.
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

wienerDenoiseFilter in web/src/core/filters/frequency/shaping.ts computes the gains with wienerValues. 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

Power P 1 sigma^2 1.5 sigma^2 2 sigma^2 4 sigma^2 10 sigma^2
H 0 0.3333 0.5000 0.7500 0.9000

The gain for a few values of the averaged power P. Where the power is not above the noise power sigma^2, the frequency is removed. For the figure, the PSNR against the clean disks rises from 22.59 dB with the noise to 28.26 dB after the filter.

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

  • The same gain applies everywhere, so it smooths edges and flat areas alike.
  • The noise level must be known. Too low leaves noise, too high removes detail.

Artifacts

  • A faint ripple in flat areas, from frequencies that are partly kept.

Tests

The reference extends the plane with numpy.pad, filters it with numpy.fft and crops it. The power average uses scipy.ndimage.uniform_filter with the wrap mode. Before the cases are written, the script checks that sigma 0 keeps the image.

References

  • Gonzalez, R. C. and Woods, R. E. Digital Image Processing, 4th edition. Pearson, 2018. Chapter 5, Wiener filtering.
  • Lim, J. S. Two-Dimensional Signal and Image Processing. Prentice Hall, 1990.