Total variation denoising¶
| Fact | Value |
|---|---|
| Also called | Rudin-Osher-Fatemi denoising, ROF denoising, TV denoising |
| Status | Implemented and tested |
| Family | Nonlinear spatial filters |
| Engine | Science engine |
| Type | Nonlinear, iterative, total variation minimization |
| Output | Image |
| Operator shown as | algorithm (exact) |
| Support radius | global |
| Code | engine/src/pixelnexus_engine/filters/edge_preserving.py, tv_denoise |
| Operator code | engine/src/pixelnexus_engine/filters/edge_preserving.py, tv_representation |
| Packages | scikit-image |
| Channels | RGB, Brightness only, Color only |
Overview¶
Total variation denoising finds the image closest to yours that has the least total variation, after Rudin, Osher and Fatemi. Total variation adds up the size of the gradient over the image. Noise adds a lot of it, while one sharp edge adds only its height. So the result keeps sharp edges and turns noisy areas flat. The filter runs in the PixelNexus engine, with scikit-image's two solvers.
How it works¶
- Scale the channel from 0 to 1.
- Run the chosen solver until it settles or reaches the most steps.
- Scale back to pixel levels.
Mathematical foundation¶
The formula shows the default parameter values.
where
- \(f\): The noisy image
- \(u\): The result
- \(\lambda\): The weight of closeness to f
- \(w\): The smoothing weight
f is the noisy image and u the result. The first sum is the total variation of u, the size of its gradient added over the image. The second sum keeps u close to f, weighed by lambda. Rudin, Osher and Fatemi chose total variation because it charges an edge only for its height, not its steepness. So the minimum keeps sharp edges and flattens small wiggles. Chambolle solves the problem through its dual, a projection that repeats until the energy settles. Goldstein and Osher split the gradient into its own variable and solve two simpler problems in turn. Both run on the image from 0 to 1.
The model is an energy, not a recipe. Any solver that finds its minimum gives the same image, in theory. Chambolle solves the dual problem with a projection. Goldstein and Osher split the gradient into a separate variable, and solve two simpler problems in turn.
Kernel or operator¶
There is no fixed kernel. The Inspector asks the engine for the stages with the current settings.
Parameters¶
| Parameter | Default | Values | Meaning |
|---|---|---|---|
Smoothing weight weight |
0.1 | 0.001 to 2 | The weight w = 1 / lambda, on the image from 0 to 1. Chambolle gets w, and split Bregman gets 1 / (2 w). That is how the scikit-image docstrings relate the two. scikit-image uses 0.1 for Chambolle and 5 for split Bregman, the same lambda. |
Solver solver |
Chambolle | Chambolle, Split Bregman | Chambolle's dual projection, or the split Bregman method of Goldstein and Osher, both from scikit-image. They do not give the same image at the same weight, see the docs page. |
Iterations iterations |
200 | 1 to 2000 | The most steps. scikit-image uses 200 for Chambolle and 100 for split Bregman. Each solver also stops at its own tolerance. |
Isotropic isotropic |
on | On or off | For split Bregman only. On, the gradient size is the square root of the sum of squares. Off, it is the sum of the absolute values, which favors edges along the axes. scikit-image uses isotropic. |
Channels channelScope |
RGB | RGB, Brightness only, Color only | Which part of the color image the filter changes. |
Implementation¶
tv_denoise in engine/src/pixelnexus_engine/filters/edge_preserving.py passes each plane of the channel scope, scaled from 0 to 1, to skimage.restoration.denoise_tv_chambolle with the weight w, or to denoise_tv_bregman with 1 / (2 w). That is how the scikit-image docstrings relate their weights to the same lambda.
The two solvers do not give the same image, though. On a noisy disk, even after 2000 steps with a tight tolerance, no split Bregman weight came within 22 levels of Chambolle's result everywhere. Their discrete total variations or stop rules must differ, and we did not trace which. So treat them as two filters that share a model, not as two routes to one answer.
Worked example¶
| Weight | Solver | PSNR (dB) |
|---|---|---|
| 0.05 | chambolle | 34.08 |
| 0.05 | bregman | 33.28 |
| 0.1 | chambolle | 34.45 |
| 0.1 | bregman | 35.97 |
| 0.2 | chambolle | 36.32 |
| 0.2 | bregman | 36.27 |
The image of the figure, with the other defaults. The PSNR compares the result with the image before the noise. The noisy input scores 22.22 dB.
Both solvers raise the PSNR by 11 to 14 dB. They differ at the same weight: at 0.1, split Bregman scores 1.5 dB higher than Chambolle. At a weight of 0.4, the figure shows that edges lose contrast. Total variation keeps edges sharp, but it shrinks the height of small shapes.
Complexity¶
- Time: \(O(N K)\)
- Memory: \(O(N)\)
N is the number of pixels and K the number of steps.
Artifacts and limitations¶
Limitations
- Turns smooth shading into steps.
- Removes small, low-contrast detail and texture.
Artifacts
- Staircasing, flat terraces in smooth ramps.
- A slight loss of contrast in small objects.
Tests¶
Each solver must get the weight its docstring defines, compared with a direct call. On a noisy step, both must bring the error below 0.6 of the input's. The representation must have its three stages.
References¶
- Rudin, L. I., Osher, S., and Fatemi, E. Nonlinear total variation based noise removal algorithms. Physica D, Nonlinear Phenomena 60(1 to 4), 259 to 268, 1992. DOI 10.1016/0167-2789(92)90242-F.
- Chambolle, A. An algorithm for total variation minimization and applications. Journal of Mathematical Imaging and Vision 20(1 to 2), 89 to 97, 2004. DOI 10.1023/B:JMIV.0000011325.36760.1e.
- Goldstein, T., and Osher, S. The split Bregman method for L1-regularized problems. SIAM Journal on Imaging Sciences 2(2), 323 to 343, 2009. DOI 10.1137/080725891.
- scikit-image documentation, skimage.restoration.denoise_tv_chambolle and denoise_tv_bregman.