Skip to content

Sparse regularization

Fact Value
Also called FISTA deconvolution, Wavelet-regularized deconvolution, L1 wavelet deblurring
Status Implemented and tested
Family Restoration and reconstruction
Engine Science engine
Type Nonlinear, iterative, wavelet L1 regularized deconvolution
Output Image
Operator shown as iterative (exact)
Support radius global
Code engine/src/pixelnexus_engine/filters/restoration.py, sparse_fista
Operator code engine/src/pixelnexus_engine/filters/restoration.py, fista_representation
Packages PyWavelets, SciPy
Channels RGB, Brightness only

Overview

Sparse regularization undoes a known blur. It looks for the sharp image whose blurred copy matches the photo and whose wavelet details are sparse: a few large values and many zeros. Noise spreads over many small wavelet details, so the penalty removes it while the deblurring sharpens. The filter minimizes this energy with FISTA, the fast iterative shrinkage algorithm of Beck and Teboulle. It runs in the PixelNexus engine on your computer.

Four panels: blurred disks with fine grain; the data term alone, with sharp disks drowned in strong blotchy noise; sparse regularization with sym8, with clean disks and faint ripples at their edges; and Haar with lambda 4, with blocky disks. Four panels: blurred disks with fine grain; the data term alone, with sharp disks drowned in strong blotchy noise; sparse regularization with sym8, with clean disks and faint ripples at their edges; and Haar with lambda 4, with blocky disks.
Disks blurred with a Gaussian of sigma 2 and Gaussian noise of sigma 5. Then the data term alone after 100 steps, sparse regularization with the defaults, and the Haar wavelet with lambda 4.

How it works

  1. Extend each channel with the border mode to a size the wavelet transform can halve J times.
  2. Start with the blurred photo as the estimate.
  3. Take a gradient step on the data term: blur the estimate, compare with the photo, and spread the difference back.
  4. Transform with the wavelet, shrink the details by lambda and transform back.
  5. Push the next step along the direction the estimate is moving, and repeat.
  6. Crop the estimate to the image.

Mathematical foundation

\[ \hat{f} = \arg\min_f\ \tfrac{1}{2} \lVert h * f - g \rVert^2 + \lambda \lVert D W f \rVert_1, \qquad x_k = W^{-1} \eta_\lambda\big(W (y_k - h' * (h * y_k - g))\big), \qquad t_{k+1} = \tfrac{1 + \sqrt{1 + 4 t_k^2}}{2}, \quad y_{k+1} = x_k + \tfrac{t_k - 1}{t_{k+1}} (x_k - x_{k-1}), \qquad \lambda = 1,\ J = 3,\ K = 100 \]

The formula shows the default parameter values.

where

  • \(g\): The blurred image extended with the border mode
  • \(h, h'\): The PSF and the PSF turned by a half turn
  • \(W\): The orthogonal wavelet transform
  • \(D\): Keeps the detail bands and drops the approximation
  • \(\eta_\lambda\): Soft thresholding of the details at lambda
  • \(x_k, y_k, t_k\): The estimate, the extrapolated point and the momentum weight

The filter looks for the image f whose blurred copy h * f is close to the photo g. Its wavelet details should also be sparse, with few large values and many zeros. W is an orthogonal wavelet transform and D keeps its detail bands, so the coarse approximation costs nothing. The L1 norm, the sum of absolute values, is the convex penalty that favors zeros. Daubechies, Defrise and De Mol showed that alternating a gradient step on the data term with soft thresholding, eta, converges to the minimum (ISTA). Beck and Teboulle added a momentum step that makes the error fall like 1 / k^2 instead of 1 / k (FISTA). h' is the PSF turned by a half turn. The PSF is normalized and has no negative weights, so |H| is at most 1 and the step can be 1. Then the threshold of each step is lambda itself. W is orthogonal, so thresholding in W and transforming back is the exact proximal map. The first estimate is the photo, and t_1 = 1.

The penalty is the L1 norm of the wavelet details, the sum of their absolute values. It is the convex penalty closest to counting the details that are not zero, so it favors sparse answers. The approximation band, the coarse average, is left free. The minimum has no closed form. Daubechies, Defrise and De Mol showed that a gradient step on the data term followed by soft thresholding of the details converges to it. That is ISTA. Its error falls like 1 / k after k steps. Beck and Teboulle added a momentum step in the style of Nesterov, which makes the error fall like 1 / k^2. The wavelet transform is orthogonal here, with the periodization mode of PyWavelets on a grid whose sides are multiples of 2^J. So thresholding in the wavelet domain is the exact proximal step of the penalty.

Kernel or operator

The Inspector asks the engine for the stages with the current settings. They are the PSF, the energy with the value of lambda and the wavelet, the gradient step, the shrink step and the momentum step.

Algorithm

  1. Extend the image with the border mode to a fast FFT size that is a multiple of 2^J.
  2. Start with x_0 and y_1 equal to the extended image g, and t_1 = 1.
  3. Take a gradient step on the data term from y_k.
  4. Transform with W, soft-threshold the details at lambda and transform back. This is x_k.
  5. Update t and extrapolate y from the last two estimates, and repeat.
  6. Crop the last estimate 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.
Wavelet wavelet Symlet 8 (sym8) Haar, Daubechies 2 (db2), Daubechies 4 (db4), Symlet 4 (sym4), Symlet 8 (sym8) The orthogonal wavelet of the prior. Its filter taps come from PyWavelets.
Levels levels 3 1 to 6 How many levels the wavelet transform has. It is capped at the deepest level the image size allows.
Lambda lambda 1 0 to 50 The weight of the L1 term, in pixel values. It is also the soft threshold of each step. 0 leaves only the data term.
Iterations iterations 100 1 to 1000 How many FISTA steps to run.
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

sparse_fista in engine/src/pixelnexus_engine/filters/restoration.py runs sparse_fista_plane on each channel the scope names. fista holds the iteration and wavelet_prox the shrink step, with pywt.wavedec2 and pywt.waverec2. The PSF comes from engine/src/pixelnexus_engine/psf.py, and the shrink rule from wavelet thresholding. There is no live preview. The result arrives when you click Apply.

Worked example

Wavelet Lambda 0 Lambda 0.5 Lambda 1 Lambda 2 Lambda 4
haar 18.51 25.23 25.31 24.79 23.79
db4 18.51 26.80 27.06 26.94 26.27
sym8 18.51 27.19 27.71 27.28 26.41

The PSNR in dB against the sharp disks, 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 image itself has 24.81 dB. All rows use 3 levels and 100 iterations. Lambda 0 is the data term alone, which raises the noise as it sharpens. Total variation restoration reaches 30.92 dB on the same image with its defaults, since the disks are flat shapes.

Complexity

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

N is the number of pixels of the extended image and K the number of iterations. Each iteration takes four FFTs and two wavelet transforms of O(N L) for L filter taps.

Artifacts and limitations

Limitations

  • A decimated wavelet transform is not shift invariant, so results change a little when the image moves.
  • Edges keep less contrast than with total variation on images of flat shapes.
  • The PSF must be known.

Artifacts

  • Blocky or wavy patterns shaped like the wavelet with large lambda.
  • Ringing next to strong edges with small lambda.

Tests

The wavelet transform must keep the energy of the image and give it back with a threshold of 0. After 600 steps, FISTA must reach the energy that plain iterative shrinkage, written in the test with pywt.threshold, reaches after 6000 steps, to within 0.1 percent. One FISTA step must equal one ISTA step. A blurred noisy image must gain at least 1.5 dB. The engine API tests run jobs and check the stages of the representation.

References

  • Beck, A., and Teboulle, M. A fast iterative shrinkage-thresholding algorithm for linear inverse problems. SIAM Journal on Imaging Sciences 2(1), 183 to 202, 2009. DOI 10.1137/080716542.
  • Daubechies, I., Defrise, M., and De Mol, C. An iterative thresholding algorithm for linear inverse problems with a sparsity constraint. Communications on Pure and Applied Mathematics 57(11), 1413 to 1457, 2004. DOI 10.1002/cpa.20042.