Non-negative least-squares deconvolution¶
| Fact | Value |
|---|---|
| Also called | Projected Landweber, NNLS deconvolution, Non-negative deconvolution |
| Status | Implemented and tested |
| Family | Restoration and reconstruction |
| Engine | Browser |
| Type | Nonlinear, iterative, projected gradient descent |
| Output | Image |
| Operator shown as | iterative (exact) |
| Support radius | global |
| Code | web/src/core/filters/restoration/iterative.ts, nnlsDeconvFilter |
| Operator code | web/src/core/filters/restoration/iterative.ts, iterate |
| Channels | RGB, Brightness only |
Overview¶
Non-negative least-squares deconvolution is Landweber iteration with one more rule: after each step, negative values are set to 0. The method is called projected Landweber. It keeps the result at black or above, which removes ringing below black.
How it works¶
- Start with the blurred image as the estimate, with negative values set to 0.
- Take a Landweber step.
- Set negative values to 0.
- Repeat for the chosen number of iterations.
Mathematical foundation¶
The formula shows the default parameter values.
where
- \(g\): The blurred image extended with the border mode
- \(f_k\): The estimate after k steps
- \(K\): The number of steps
- \(h, h'\): The PSF and the PSF turned by a half turn
- \(\tau\): The step size
This is the Landweber step followed by a projection onto the non-negative values. It is projected gradient descent on |h * f - g|^2 with f at least 0, a method for non-negative least squares. With tau below 2 for a normalized PSF it converges toward the non-negative least squares solution. The entry is labeled with its method, projected Landweber. The first estimate is the image itself, with negative values set to 0. The PSF is the kernel of the Gaussian filter cut at 4 sigma, of the motion blur filter, or of the disk averaging filter.
Setting negative values to 0 is the projection onto the set of non-negative images. A gradient step followed by this projection is projected gradient descent, which solves least squares with the constraint f at least 0. For a PSF that adds up to 1, steps tau below 2 converge.
Kernel or operator¶
The Inspector shows the update rule, tau and the number of iterations. The Iteration viewer in the Learn panel shows the estimate after a few iterations and the residual at every iteration.
Algorithm¶
- Extend the image with the border mode by half its size, at most 256 pixels, on each side.
- Start with the estimate f equal to the extended image g.
- Take a Landweber step.
- Set negative values to 0.
- Repeat for the chosen number of iterations.
- Crop the last estimate 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. |
Iterations iterations |
30 | 1 to 200 | How many update steps to run. |
Step size tau |
1.5 | 0.05 to 1.95 | The step size tau of each update. The PSF adds up to 1, so steps below 2 converge. |
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¶
nnlsDeconvFilter in web/src/core/filters/restoration/iterative.ts runs iterate with the projected Landweber method. The image is extended with the border mode by half its size, at most 256 pixels, on each side, and every convolution runs through the FFT of the extended grid. The filter needs the whole image, so it always runs on the whole image, and a selection is cut out of the result. It is slow, so its preview runs on request.
Worked example¶
| Iterations | 1 | 5 | 10 | 20 | 50 | 100 |
|---|---|---|---|---|---|---|
| PSNR (dB) | 26.37 | 27.34 | 27.73 | 28.06 | 28.33 | 28.26 |
The PSNR against the clean disks for the image of the figure, 25.27 dB before the filter, with step size 1.5. The value rises while the iterations restore detail. When it falls again, the iterations have started to raise the noise, so stopping early acts as regularization.
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.
Artifacts and limitations¶
Limitations
- Like Landweber iteration, slow to restore weak frequencies.
- Values above 255 are not limited.
Artifacts
- Ringing near strong edges, above black only.
Tests¶
The reference runs the same iteration with numpy.fft on the plane extended with numpy.pad. Before the cases are written, the script checks that 30 iterations bring a blurred plane closer to the original in the center of the image. Unit tests check that the result stays non-negative.
web/src/core/filters/filters.test.tsweb/src/core/filters/run.test.tsweb/src/core/filters/restoration/restoration.test.ts
References¶
- Landweber, L. An iteration formula for Fredholm integral equations of the first kind. American Journal of Mathematics 73(3), 615 to 624, 1951. DOI 10.2307/2372313.
- Gonzalez, R. C. and Woods, R. E. Digital Image Processing, 4th edition. Pearson, 2018. Chapter 5, image restoration and reconstruction.