Tikhonov regularization¶
| Fact | Value |
|---|---|
| Also called | Tikhonov deconvolution, Regularized deconvolution, Ridge deconvolution |
| Status | Implemented and tested |
| Family | Restoration and reconstruction |
| Engine | Browser |
| Type | Linear, frequency, regularized deconvolution |
| Output | Image |
| Operator shown as | algorithm (exact) |
| Support radius | global |
| Code | web/src/core/filters/restoration/deconvolve.ts, tikhonovFilter |
| Operator code | web/src/core/filters/restoration/deconvolve.ts, regularizedGain |
| Channels | RGB, Brightness only |
Overview¶
Tikhonov regularization undoes a known blur and keeps the result smooth. It looks for the image that, blurred, matches the input best, plus a penalty on its roughness or size. The weight lambda sets the balance between sharpness and noise.
How it works¶
- Take the spectrum G of the blurred image and the transform H of the blur.
- Multiply each frequency by conj(H) / (|H|^2 + lambda |L|^2), where L is the penalty.
- Transform back.
Mathematical foundation¶
The formula shows the default parameter values.
where
- \(G, H, F\): The spectra of the blurred image, the PSF and the estimate
- \(L\): The transform of the penalty operator
- \(\lambda\): The weight of the penalty
The estimate minimizes |h * f - g|^2 + lambda |L f|^2, the error of the blurred estimate plus a penalty. For a convolution the minimizer has this closed form in the frequency domain. L is one of three operators. The identity has |L|^2 = 1. The forward-difference gradient has |L|^2 = 4 sin^2(pi f_x) + 4 sin^2(pi f_y). The third is the 4-neighbor Laplacian kernel of Gonzalez and Woods. With the identity the filter equals Wiener deconvolution with K = lambda. H is the FFT of the PSF 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.
Deblurring is ill-posed: many images blur to nearly the same result, and the exact inverse raises noise without limit. Tikhonov adds a penalty lambda |L f|^2 to the error |h * f - g|^2. For a convolution the best f has a closed form, one division per frequency. The gradient penalty is 0 at frequency 0 and grows with frequency, so it holds back fine noise and keeps the mean brightness. With the identity as L, the filter is Wiener deconvolution with K = lambda.
Kernel or operator¶
The Inspector lists the stages, with the PSF, lambda and the penalty.
Algorithm¶
- Extend the image with the border mode by half its size, at most 256 pixels, on each side.
- Take the 2D FFT of the image and of the PSF placed at the grid origin.
- Multiply each frequency by conj(H) / (|H|^2 + lambda |L|^2).
- 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. |
Lambda lambda |
0.01 | 0.0001 to 1 | The weight lambda of the penalty. |
Penalty operator |
Gradient | Gradient, Laplacian, Size of the values | What the penalty measures. The gradient and the Laplacian penalize rough results, the identity large values. |
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¶
tikhonovFilter in web/src/core/filters/restoration/deconvolve.ts multiplies the spectrum by the gain of regularizedGain. 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 |
| Gain, identity | 0.99 | 1.20 | 2.10 | 4.38 | 3.60 | 0.08 |
| Gain, gradient | 1 | 1.22 | 2.16 | 4.59 | 2.72 | 0.03 |
The gain for the Gaussian PSF with sigma 2 and lambda 0.01. With the identity it equals the Wiener gain with K = 0.01. The gradient penalty is 0 at frequency 0, so the mean brightness is kept exactly, and it grows with frequency, so high frequencies are held back more.
Complexity¶
- Time: \(O(N log N)\)
- Memory: \(O(N)\)
N is the number of pixels of the extended image.
Artifacts and limitations¶
Limitations
- Lambda must be chosen by hand. Constrained least squares chooses it from the noise level.
- Needs the blur. A wrong PSF gives ringing.
Artifacts
- Ringing near strong edges and the image border.
Tests¶
The reference builds the same gain with NumPy for the three penalties and three PSFs, and filters the plane extended with numpy.pad.
References¶
- Tikhonov, A. N. and Arsenin, V. Y. Solutions of Ill-Posed Problems. Winston, 1977.
- Gonzalez, R. C. and Woods, R. E. Digital Image Processing, 4th edition. Pearson, 2018. Chapter 5, image restoration and reconstruction.