Adaptive local noise reduction¶
| Fact | Value |
|---|---|
| Also called | Adaptive mean filter |
| Status | Implemented and tested |
| Family | Adaptive and statistical filters |
| Engine | Browser |
| Type | Nonlinear, statistical, local linear estimator |
| Output | Image |
| Operator shown as | estimator (exact) |
| Support radius | floor(size / 2) |
| Code | web/src/core/filters/adaptive/local-noise.ts, adaptiveLocalNoiseFilter |
| Operator code | web/src/core/filters/adaptive/local-noise.ts, localNoisePlane |
| Channels | RGB, Brightness only |
Overview¶
The adaptive local noise reduction filter of Gonzalez and Woods subtracts a share of the difference between each pixel and its local mean. The share is the noise variance divided by the local variance, at most 1. In flat, noisy areas the pixel becomes the local mean. Near edges, where the local variance is large, the pixel stays almost as it is.
How it works¶
- Find the local mean and the local variance of the window.
- Divide the noise variance by the local variance, at most 1.
- Subtract that share of the difference between the pixel and the mean.
Mathematical foundation¶
The formula shows the default parameter values.
where
- \(g\): The noisy image
- \(m_L\): The local mean
- \(\sigma_L^2\): The local variance
- \(\sigma_\eta^2\): The noise variance
g is the noisy image, m_L and sigma_L squared are the mean and variance of the window, and sigma_eta squared is the noise variance. If the local variance is near the noise variance, the ratio is near 1 and the output is the local mean. If the local variance is much larger, the ratio is small and the pixel is kept. Gonzalez and Woods limit the ratio to 1 when the noise variance is larger. That makes this the same estimator as the adaptive Wiener filter of Lee, written in another form.
Gonzalez and Woods ask for three things. Where the noise variance is 0, return g. Where the local variance is high, return a value close to g. Where the two variances are equal, return the local mean. The formula meets all three. With the ratio limited to 1, it is the same estimator as the adaptive Wiener filter of Lee (1980). The two entries exist because the textbook and the literature name it differently.
Kernel or operator¶
There is no kernel. The Inspector shows the window and the statistic. The Rank stepper in the Learn panel shows the window values at any pixel, sorted, next to the value the filter gives there.
Algorithm¶
- Pad the image with the border mode.
- Compute the local mean and variance with running sums in float64.
- Compute the ratio of the noise variance to the local variance, limited to 1.
- Subtract the ratio times the difference between the pixel and the local mean.
Parameters¶
| Parameter | Default | Values | Meaning |
|---|---|---|---|
Window size size |
5 | 3 to 25, odd px | Width and height of the window S_xy for the local mean and variance. |
Noise sigma noise |
10 | 0 to 100 | The standard deviation of the noise, sigma_eta, in 8-bit levels. |
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. |
Channels channelScope |
RGB | RGB, Brightness only | Which part of the color image the filter changes. |
Implementation¶
adaptiveLocalNoiseFilter in web/src/core/filters/adaptive/local-noise.ts shares localNoisePlane with the adaptive Wiener filter. The filter runs in the browser engine, in Web Workers, through the shared filter framework in web/src/core/filters/run.ts. It handles the border mode, the channel scope, alpha and the mapping to 8 bits. Each strip of the image gets a halo as wide as the support radius, so strips give exactly the pixels of a whole-image run.
Worked example¶
The local mean is m_L = 61.556 and the local variance sigma_L^2 = 126.469. With sigma_eta = 10, the ratio is 100 / 126.469 = 0.7907. The output is 90 - 0.7907 x (90 - 61.556) = 67.509, the same as the adaptive Wiener filter gives.
Complexity¶
- Time: \(O(N)\)
- Memory: \(O(N)\)
N is the number of pixels per channel. Running sums make the cost independent of the window size.
Artifacts and limitations¶
Limitations
- Needs the noise variance.
- Assumes the noise is additive and the same everywhere.
Artifacts
- Noisy halos next to edges, where the local variance is high.
Tests¶
The reference and its checks are the same as for the adaptive Wiener filter. The formula runs on NumPy windows and is checked against scipy.signal.wiener and against the box mean for a huge noise level. The test covers two sizes and noise levels for all five border modes.
References¶
- Gonzalez, R. C. and Woods, R. E. Digital Image Processing, 4th edition. Pearson, 2018. Section 5.3, adaptive, local noise reduction filter.
- Lee, J.-S. Digital image enhancement and noise filtering by use of local statistics. IEEE Transactions on Pattern Analysis and Machine Intelligence PAMI-2(2), 165 to 168, 1980. DOI 10.1109/TPAMI.1980.4766994.