Skip to content

Wiener deconvolution

Fact Value
Also called Wiener restoration, Wiener frequency filter, Motion deblurring, Linear motion deblurring, Defocus deblurring, Defocus deconvolution
Status Implemented and tested
Family Restoration and reconstruction
Engine Browser
Type Linear, frequency, Wiener deconvolution
Output Image
Operator shown as algorithm (exact)
Support radius global
Code web/src/core/filters/restoration/deconvolve.ts, wienerDeconvFilter
Operator code web/src/core/filters/restoration/deconvolve.ts, wienerGain
Channels RGB, Brightness only

Overview

Wiener deconvolution undoes a known blur as far as the noise allows. Where the blur kept a frequency well, it divides by the blur like the inverse filter. Where the blur kept less of a frequency than the noise holds, it turns the frequency down instead. One parameter, the noise to signal ratio K, sets the balance.

Three panels: disks with motion blur and a little noise, the inverse filter result covered in streaks, and the Wiener result with sharp disks and little noise. Three panels: disks with motion blur and a little noise, the inverse filter result covered in streaks, and the Wiener result with sharp disks and little noise.
With the same noise, Wiener deconvolution with K = 0.01 undoes the blur and keeps the noise low.

How it works

  1. Take the spectrum G of the blurred image and the transform H of the blur.
  2. Multiply each frequency by conj(H) / (|H|^2 + K).
  3. Transform back.

Mathematical foundation

\[ \hat{F}(f) = \frac{\overline{H(f)}}{|H(f)|^2 + K}\, G(f),\quad K = 0.01 \]

The formula shows the default parameter values.

where

  • \(G, H, F\): The spectra of the blurred image, the PSF and the estimate
  • \(\overline{H}\): The complex conjugate of H
  • \(K\): The noise to signal ratio

This is the Wiener filter with a constant noise to signal ratio K, as in Gonzalez and Woods. Where |H|^2 is much larger than K, it divides by H like the inverse filter. Where |H|^2 is smaller than K, the blur left less of the image than the noise, and the frequency is turned down instead of raised. With K = 0 it is the inverse filter. H is the FFT of the PSF h placed with its center at the origin of the grid. The PSF is the kernel of the Gaussian filter cut at 4 sigma, of the motion blur filter, or of the disk averaging filter.

The Wiener filter gives the estimate with the least mean squared error for a linear blur with white noise. With S the power of the image and N the power of the noise, it is conj(H) / (|H|^2 + N / S). Gonzalez and Woods replace N / S by a constant K when the spectra are not known. For |H|^2 much larger than K the gain is 1 / H. For |H|^2 much smaller than K it is about conj(H) / K, which goes to 0 with H.

Kernel or operator

The Inspector lists the stages, with the PSF and the current K.

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 of the image and of the PSF placed at the grid origin.
  3. Multiply each frequency by conj(H) / (|H|^2 + K).
  4. Take the inverse FFT, keep the real part and crop the extension.

Parameters

Parameter Default Values Meaning
Blur psf Gaussian Gaussian, Motion, Defocus The point spread function, the picture a single bright point turns into.
Sigma sigma 2 0.3 to 10 px The standard deviation of the Gaussian blur. The PSF ends at 4 sigma.
Motion length length 9 1 to 51 px The length of the straight motion, for motion blur.
Motion angle angle 0 0 to 180 deg The direction of the motion, counterclockwise from the x axis, as for motion blur.
Defocus radius radius 3 0.5 to 15 px The radius of the defocus disk.
Noise to signal ratio noiseRatio 0.01 0.0001 to 0.5 The constant K, the power of the noise over the power of the image.
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

wienerDeconvFilter in web/src/core/filters/restoration/deconvolve.ts multiplies the spectrum by the gain of wienerGain. As for the frequency filters, the image is extended with the border mode by half its size, at most 256 pixels, on each side. H is the FFT of the PSF placed with its center at the origin of the FFT grid. 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

f_x (cycles per pixel) 0 0.05 0.1 0.15 0.2 0.3
H 1 0.8209 0.4540 0.1692 0.0425 0.0008
Wiener gain, K = 0.01 0.99 1.20 2.10 4.38 3.60 0.08

The gain H / (H^2 + K) for the Gaussian PSF with sigma 2. It follows 1 / H while H is large, peaks near H = 0.1, and falls toward 0 where the blur left less than the noise. For the figure, the PSNR against the clean disks is 25.07 dB for the blurred image with noise, 21.64 dB after the inverse filter and 27.67 dB after Wiener deconvolution.

Complexity

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

N is the number of pixels of the extended image.

Artifacts and limitations

Limitations

  • Needs the blur. A wrong PSF gives ringing.
  • K is the same at every frequency, while real noise to signal ratios change with frequency.

Artifacts

  • Ringing near strong edges and the image border.

Tests

The reference builds the same PSF kernels, places them at the origin of the grid, takes their FFT with numpy.fft and filters the plane extended with numpy.pad. Before the cases are written, the script blurs a plane with a Gaussian PSF. It checks that Wiener deconvolution brings the center of the image at least twice as close to the original. The Wiener cases cover the three PSFs with three values of K.

References

  • Gonzalez, R. C. and Woods, R. E. Digital Image Processing, 4th edition. Pearson, 2018. Chapter 5, image restoration and reconstruction.
  • Wiener, N. Extrapolation, Interpolation, and Smoothing of Stationary Time Series. MIT Press, 1949.