Skip to content

Regularization by Denoising

Fact Value
Also called RED, RED deconvolution
Status Implemented and tested
Family Restoration and reconstruction
Engine Science engine
Type Nonlinear, iterative, regularization by denoising deconvolution
Output Image
Operator shown as iterative (exact)
Support radius global
Code engine/src/pixelnexus_engine/filters/plugplay.py, red_filter
Operator code engine/src/pixelnexus_engine/filters/plugplay.py, red_representation
Packages SciPy, PyWavelets, scikit-image
Channels Brightness only, RGB

Overview

Regularization by Denoising, or RED, undoes a known blur with the help of a denoiser. It builds a penalty from the denoiser: an image costs little when the denoiser would leave it almost unchanged. The filter minimizes the data term plus this penalty with simple fixed-point steps. Each step runs the denoiser once and solves one linear system with the FFT. It runs in the PixelNexus engine on your computer.

Four panels: blurred disks with fine grain, and three restored versions. Wavelet thresholding and the stationary wavelet give sharp disks with dark halos. Non-local means gives sharp disks on a flat ground with a faint halo. Four panels: blurred disks with fine grain, and three restored versions. Wavelet thresholding and the stationary wavelet give sharp disks with dark halos. Non-local means gives sharp disks on a flat ground with a faint halo.
Disks blurred with a Gaussian of sigma 2 and Gaussian noise of sigma 5, and RED with each of the three denoisers and the other defaults.

How it works

  1. Extend each channel with the border mode, as the frequency filters do.
  2. Start with the photo as the estimate.
  3. Run the denoiser on the estimate.
  4. Find the image that best matches the photo when blurred and stays close to the denoised estimate. The FFT solves this exactly.
  5. Repeat with the new estimate, then crop it to the image.

Mathematical foundation

\[ E(x) = \frac{1}{2 \sigma_n^2} \lVert h * x - g \rVert^2 + \frac{\lambda}{2}\, x^T \big(x - D(x)\big), \qquad x_{k+1} = \mathcal{F}^{-1}\!\left(\frac{\overline{H}\, \mathcal{F} g + \lambda \sigma_n^2\, \mathcal{F} D(x_k)}{\lvert H \rvert^2 + \lambda \sigma_n^2}\right), \qquad \lambda = 0.02,\ \sigma_n = 5 \]

The formula shows the default parameter values.

where

  • \(g\): The blurred image extended with the border mode
  • \(H\): The Fourier transform of the PSF
  • \(D\): The denoiser, run with the denoiser sigma
  • \(\sigma_n\): The noise sigma of the photo
  • \(\lambda\): The weight of the denoiser penalty

Romano, Elad and Milanfar built a prior from a denoiser D. The penalty x^T (x - D(x)) is small when the image is close to what the denoiser would make of it. It is also small when the leftover x - D(x) does not line up with the image. Some denoisers change smoothly with the image and have a symmetric Jacobian. For them, the gradient of the penalty is lambda (x - D(x)). Setting the gradient of E to 0 gives (H^T H / sigma_n^2 + lambda) x = H^T g / sigma_n^2 + lambda D(x). The fixed-point method holds D(x) at the last estimate and solves this linear system exactly with the FFT. H is the transform of the PSF. Common denoisers only roughly meet the conditions, so the energy is a guide rather than a guarantee. The first estimate is the photo.

Plug-and-play methods put a denoiser where a prior would be, but the energy they minimize is never written down. Romano, Elad and Milanfar wrote one. The penalty is lambda / 2 times x^T (x - D(x)), the image times what the denoiser would remove from it. For denoisers that change smoothly and have a symmetric Jacobian, its gradient is lambda (x - D(x)). Setting the gradient of the whole energy to 0 gives a linear system with D(x) on the right side. The fixed-point method holds D(x) at the last estimate and solves the system. Here the system is diagonal in the Fourier domain, so each step is exact. The denoisers here meet the conditions only roughly, so the energy is a guide rather than a guarantee. The tests use a linear denoiser with a symmetric matrix, where the conditions hold, and check that RED reaches the exact minimum.

Kernel or operator

The Inspector asks the engine for the stages with the current settings. They are the PSF, the energy with lambda and the two sigmas, and the fixed-point step.

Algorithm

  1. Extend the image with the border mode by half its size, at most 256 pixels, on each side.
  2. Start with x equal to the extended image g.
  3. Run the denoiser on x.
  4. Solve the linear system for the next x with the FFT, with the denoised image held fixed.
  5. Repeat, then crop the last x to the image.

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.
Denoiser denoiser Stationary wavelet Wavelet thresholding, Stationary wavelet, Non-local means The denoiser that takes the place of the prior. Wavelet thresholding and the stationary wavelet use BayesShrink with sym4, 3 levels and soft shrinking. Non-local means is the one of scikit-image, with h = 0.8 sigma, 5 x 5 patches, a search distance of 6 and the fast mode.
Lambda lambda 0.02 0 to 1 The weight of the denoiser penalty.
Noise sigma noise 5 0.5 to 50 px The standard deviation of the noise in the photo, which weighs the data term.
Denoiser sigma strength 5 0.5 to 50 The sigma the denoiser is run with, in pixel values.
Iterations iterations 20 1 to 200 How many fixed-point steps to run. Each step runs the denoiser once.
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

red_filter in engine/src/pixelnexus_engine/filters/plugplay.py runs red_plane on each channel the scope names. red_fixed_point holds the iteration and takes the denoiser as a function. The denoisers are the same as for plug-and-play restoration. The PSF comes from engine/src/pixelnexus_engine/psf.py. By default only luma is restored, since the denoisers are slow. There is no live preview. The result arrives when you click Apply.

Worked example

Denoiser Disks Siemens star
Wavelet 27.47 18.84
Stationary 27.60 18.49
Non-local means 29.01 19.12
Total variation restoration 30.92 19.42

The PSNR in dB against the sharp image. Both images are 160 by 160 pixels, blurred with the Gaussian PSF of sigma 2 and the reflect border, with Gaussian noise of sigma 5 from NumPy's default_rng with seed 7. The blurred images have 24.81 and 15.85 dB. The denoiser rows use lambda 0.02, a noise sigma of 5, a denoiser sigma of 5 and 20 iterations. The last row is total variation restoration with its defaults, for comparison. Non-local means gives the best result and takes by far the longest.

Complexity

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

N is the number of pixels of the extended image, K the number of iterations and T the cost of one run of the denoiser.

Artifacts and limitations

Limitations

  • The gradient formula holds only for denoisers with a symmetric Jacobian, which the denoisers here meet only roughly.
  • Slow with non-local means on large images.
  • The PSF must be known.

Artifacts

  • The artifacts of the denoiser, such as blocky traces with wavelet thresholding.
  • Ringing next to strong edges when lambda is small.

Tests

With a linear denoiser that blurs with a symmetric kernel, the RED energy is quadratic. After 3000 steps, the fixed-point method must reach its exact minimum, computed in the Fourier domain, to within 1e-4. The defaults must improve a blurred, noisy image. The denoisers are tested with plug-and-play restoration. The engine API tests run jobs and check the stages of the representation.

References

  • Romano, Y., Elad, M., and Milanfar, P. The little engine that could. Regularization by denoising (RED). SIAM Journal on Imaging Sciences 10(4), 1804 to 1844, 2017. DOI 10.1137/16M1102884.
  • Buades, A., Coll, B., and Morel, J.-M. A review of image denoising algorithms, with a new one. Multiscale Modeling and Simulation 4(2), 490 to 530, 2005. DOI 10.1137/040616024.