Chroma denoising¶
| Fact | Value |
|---|---|
| Also called | Color noise reduction, Chrominance smoothing |
| Status | Implemented and tested |
| Family | Enhancement, illumination and color |
| Engine | Browser |
| Type | Nonlinear, color, smoothing of the chroma channels |
| Output | Image |
| Operator shown as | algorithm (exact) |
| Support radius | floor(size / 2) for the median, floor(3 sigma + 0.5) for the Gaussian |
| Code | web/src/core/filters/enhancement/chroma.ts, chromaDenoiseFilter |
| Operator code | web/src/core/filters/enhancement/chroma.ts, chromaDenoiseFilter |
Overview¶
Noise in color photos often shows as colored blotches. Chroma denoising splits each pixel into brightness and two color differences, smooths only the color differences, and keeps the brightness. Detail lives mostly in brightness, so it stays sharp.
How it works¶
- Convert each pixel to luma Y and the color differences Cb and Cr.
- Smooth Cb and Cr with a median or a Gaussian.
- Convert back to red, green and blue with the original Y.
Mathematical foundation¶
The formula shows the default parameter values.
where
- \(Y\): Luma
- \(C_b, C_r\): The blue and red color differences, centered at 128
These are the luma and color differences of ITU-R BT.601, as JPEG uses them. Cb and Cr are smoothed with the median or the Gaussian, and Y is kept. R, G and B come back from the exact inverse. It is R = Y + 1.402 (Cr - 128), B = Y + 1.772 (Cb - 128) and G = (Y - 0.299 R - 0.114 B) / 0.587. The eye sees fine detail mostly in brightness, which is why JPEG may store Cb and Cr at a lower resolution. So smoothing them removes color noise and keeps the detail. The combination is PixelNexus's own. The median works on whole levels, so Cb and Cr are rounded for it.
The conversion is linear and has an exact inverse, so with no smoothing the image comes back unchanged. Since Y is kept, every pixel keeps its luma, and only its color moves toward that of its neighbors. A median keeps the boundary between two colored areas where it is. A Gaussian mixes the colors on both sides, so a color can bleed a few pixels into its neighbor.
Kernel or operator¶
The Inspector shows the conversion, the smoothing of Cb and Cr and the conversion back, with the current settings.
Algorithm¶
- Convert each pixel to Y, Cb and Cr.
- Smooth Cb and Cr with the median or the Gaussian.
- Convert back to R, G and B with the original Y.
Parameters¶
| Parameter | Default | Values | Meaning |
|---|---|---|---|
Method method |
Median | Median, Gaussian | How Cb and Cr are smoothed. |
Median size size |
5 | 3 to 31, odd px | The side of the median window, for the median method. |
Gaussian sigma sigma |
2 | 0.5 to 20 px | The standard deviation of the Gaussian, for the Gaussian method. It is cut at 3 sigma. |
Border mode border |
Reflect 101 (default) | Reflect 101 (default), Reflect, Replicate, Constant (zero), Wrap | How pixels outside the image are filled when the window reaches past the edge. |
Implementation¶
chromaDenoiseFilter in web/src/core/filters/enhancement/chroma.ts uses medianPlane of the median filter and the Gaussian kernel of the Gaussian blur.
Worked example¶
| Image | Luma error | Chroma error |
|---|---|---|
| Noisy | 7.90 | 7.61 |
| Median, 5 x 5 | 7.90 | 4.39 |
| Gaussian, sigma 2 | 7.86 | 8.85 |
The patch chart of the figure, 180 by 120 pixels, with Gaussian noise of sigma 12 in each channel (seed 41). The errors are root mean square differences from the clean chart, in BT.601 luma and in Cb and Cr together. Chroma denoising keeps luma, so the luma error stays, apart from rounding and clipping to whole levels.
The median almost halves the chroma error. The Gaussian lowers the noise within each patch, but it bleeds color across the patch edges. On this chart of small patches, its error ends higher than that of the noisy image. That is why the median is the default.
Complexity¶
- Time: \(O(N r)\)
- Memory: \(O(N)\)
N is the number of pixels and r the window radius. The median slides a histogram along each row, the Gaussian runs on rows and columns.
Artifacts and limitations¶
Limitations
- Leaves the noise in luma. Use a denoiser on brightness for that.
- Small, thin colored details, such as a red thread, can fade.
Artifacts
- Colors bleeding across edges with the Gaussian method.
- Small color details lost with large windows.
Tests¶
The fixture cases smooth BT.601 Cb and Cr with scipy.ndimage.median_filter and gaussian_filter for four border modes. Unit tests check that the luma of every pixel stays and that a gray image stays as it is.
web/src/core/filters/filters.test.tsweb/src/core/filters/run.test.tsweb/src/core/filters/enhancement/chroma.test.ts
References¶
- ITU-R Recommendation BT.601. Studio encoding parameters of digital television for standard 4:3 and wide-screen 16:9 aspect ratios.
- ITU-T Recommendation T.871. Information technology, Digital compression and coding of continuous-tone still images, JPEG File Interchange Format (JFIF), 2011.