Skip to content

Plug-and-play restoration

Fact Value
Also called PnP-ADMM, Plug-and-play ADMM, Plug-and-play priors
Status Implemented and tested
Family Restoration and reconstruction
Engine Science engine
Type Nonlinear, iterative, plug-and-play ADMM deconvolution
Output Image
Operator shown as iterative (exact)
Support radius global
Code engine/src/pixelnexus_engine/filters/plugplay.py, pnp_admm_filter
Operator code engine/src/pixelnexus_engine/filters/plugplay.py, pnp_representation
Packages SciPy, PyWavelets, scikit-image
Channels Brightness only, RGB

Overview

Plug-and-play restoration undoes a known blur with a denoiser of your choice. It splits the work into two steps that take turns. The data step sharpens the image so that its blurred copy matches the photo. The denoiser step removes the noise that the sharpening raised. A third quantity keeps track of how far the two disagree, so they settle on one image. This is ADMM, with the denoiser in the place where an image prior would be. The filter runs in the PixelNexus engine on your computer.

Four panels: blurred disks with fine grain, and three restored versions. Wavelet thresholding gives sharp disks with a few dark specks. The stationary wavelet gives sharp disks with a thin dark halo. Non-local means gives the cleanest disks and the flattest ground. Four panels: blurred disks with fine grain, and three restored versions. Wavelet thresholding gives sharp disks with a few dark specks. The stationary wavelet gives sharp disks with a thin dark halo. Non-local means gives the cleanest disks and the flattest ground.
Disks blurred with a Gaussian of sigma 2 and Gaussian noise of sigma 5, and plug-and-play ADMM 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 denoised image, and the difference at zero.
  3. Data step: find the image that best matches the photo when blurred and stays close to the denoised image minus the difference. The FFT solves this exactly.
  4. Denoiser step: denoise the result plus the difference, with sigma = sqrt(lambda / rho).
  5. Add the new disagreement to the difference, multiply rho by gamma, and repeat.
  6. Crop the last denoised image to the image.

Mathematical foundation

\[ x_{k+1} = \mathcal{F}^{-1}\!\left(\frac{\overline{H}\, \mathcal{F} g + \rho_k\, \mathcal{F}(v_k - u_k)}{\lvert H \rvert^2 + \rho_k}\right), \qquad v_{k+1} = D_{\sigma_k}(x_{k+1} + u_k), \quad \sigma_k = \sqrt{\lambda / \rho_k}, \qquad u_{k+1} = u_k + x_{k+1} - v_{k+1}, \quad \rho_{k+1} = \gamma\, \rho_k, \qquad \lambda = 10,\ \rho_0 = 0.1,\ \gamma = 1 \]

The formula shows the default parameter values.

where

  • \(g\): The blurred image extended with the border mode
  • \(H\): The Fourier transform of the PSF
  • \(x, v\): The data copy and the prior copy of the image
  • \(u\): The scaled difference between the copies
  • \(D_\sigma\): The denoiser for Gaussian noise of standard deviation sigma
  • \(\rho_k\): The ADMM penalty at step k

ADMM splits the energy 1/2 ||h * x - g||^2 + lambda phi(x) into two copies of the image: x for the data and v for the prior. A scaled difference u makes them agree. The data step has an exact solution in the Fourier domain. H is the transform of the PSF. The prior step is a proximal map of lambda / rho phi, which is a denoising problem for Gaussian noise of variance lambda / rho. Venkatakrishnan, Bouman and Wohlberg replaced it with any good denoiser D, run with sigma = sqrt(lambda / rho). The prior phi is never written down. Chan, Wang and Elgendy showed that the iteration settles when rho grows. Here rho is multiplied by gamma after every step, a simple form of their rule. With gamma = 1, rho stays fixed. The first estimate v is the photo and u starts at 0. The result is the last v.

Many restoration methods minimize a data term plus a prior, 1/2 ||h * x - g||^2 + lambda phi(x). ADMM, the alternating direction method of multipliers, solves such problems by splitting the image into two copies, one for each term, and forcing them to agree. Each half step is then short. The data half is a linear system that the FFT solves at once. The prior half is a proximal map, and the proximal map of a prior is exactly a denoiser for Gaussian noise of variance lambda / rho. Venkatakrishnan, Bouman and Wohlberg took the last step: use any good denoiser there, even one that comes from no written prior. Chan, Wang and Elgendy showed that the iteration settles when rho grows over time. The parameter gamma sets that growth. The tests check the idea with a denoiser that is the exact proximal map of a quadratic prior. Then ADMM must reach the closed-form Tikhonov answer.

Kernel or operator

The Inspector asks the engine for the stages with the current settings. They are the PSF, the data step, the denoiser step with its sigma, and the dual update with rho and gamma.

Algorithm

  1. Extend the image with the border mode by half its size, at most 256 pixels, on each side.
  2. Start with v equal to the extended image g, u equal to 0 and rho equal to rho_0.
  3. Solve the data step for x with the FFT.
  4. Denoise x + u with sigma = sqrt(lambda / rho). This is the new v.
  5. Add x - v to u, multiply rho by gamma, and repeat.
  6. Crop the last v 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 10 0 to 200 The weight of the prior. The denoiser works with sigma = sqrt(lambda / rho).
Rho rho 0.1 0.001 to 10 The ADMM penalty at the start. It sets how strongly the data step and the denoiser step must agree.
Gamma gamma 1 1 to 1.5 Rho is multiplied by gamma after every step. 1 keeps rho fixed.
Iterations iterations 20 1 to 200 How many ADMM 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

pnp_admm_filter in engine/src/pixelnexus_engine/filters/plugplay.py runs pnp_plane on each channel the scope names. The pnp_admm function holds the iteration and takes the denoiser as a function, so the tests can pass one with a known answer. The denoise function calls the wavelet thresholding or stationary wavelet code of the engine with a given sigma. For non-local means, it calls denoise_nl_means of scikit-image. 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.55 19.30
Stationary 27.99 19.06
Non-local means 31.12 20.49
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 10, rho 0.1, gamma 1 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. Non-local means costs about 15 times as much as wavelet thresholding here.

Artifacts and limitations

Limitations

  • Slow with non-local means on large images.
  • With gamma = 1 there is no general proof that the iteration settles. It did on every test image.
  • 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 the exact proximal map of a quadratic prior as the denoiser, ADMM must reach the Tikhonov answer to within 1e-6. The denoiser must receive sigma = sqrt(lambda / rho) with rho growing by gamma. The data step must solve its linear system. The denoisers must equal the engine wavelet filters with the given sigma and denoise_nl_means with the stated settings. The defaults must improve a blurred, noisy image. The engine API tests run jobs and check the stages of the representation.

References

  • Venkatakrishnan, S. V., Bouman, C. A., and Wohlberg, B. Plug-and-play priors for model based reconstruction. IEEE Global Conference on Signal and Information Processing, 945 to 948, 2013. DOI 10.1109/GlobalSIP.2013.6737048.
  • Chan, S. H., Wang, X., and Elgendy, O. A. Plug-and-play ADMM for image restoration. Fixed-point convergence and applications. IEEE Transactions on Computational Imaging 3(1), 84 to 98, 2017. DOI 10.1109/TCI.2016.2629286.
  • Boyd, S., Parikh, N., Chu, E., Peleato, B., and Eckstein, J. Distributed optimization and statistical learning via the alternating direction method of multipliers. Foundations and Trends in Machine Learning 3(1), 1 to 122, 2011. DOI 10.1561/2200000016.
  • 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.