- Antoni Buades
toni.buades@uib.es - Bartomeu Coll
tomeu.coll@uib.es - Jean-Michel Morel
morel@cmla.ens-cachan.fr
Overview
In any digital image, the measurement of the three observed color values at each pixel is subject to some perturbations. These perturbations are due to the random nature of the photon counting process in each sensor. The noise can be amplified by digital corrections of the camera or any image processing software. For example, the tools removing blur from images or increasing the contrast.
The principle of most denoising methods is quite simple: Replace the color of a pixel with an average of the nearby pixels colors. This method is well-known to statisticians. The variance law in probability theory ensures that if nine times more pixels are averaged, the noise is divided by 3. Thus, one should find for each pixel nine other pixels in the image with the same color (up to the fluctuations due to noise). This looks promising, but where can these nine pixels be found?
The most similar pixels to a given pixel have no reason to be close at all. Think of the periodic patterns, or the elongated edges which appear in most images. It is therefore licit to scan a vast portion of the image in search of all the pixels that really resemble the pixel one wants to denoise. Denoising is then done by computing the average color of these most resembling pixels. The resemblance is evaluated by comparing a whole window around each pixel, not just the color. This new filter is called non-local means and it writes
where d(B(p), B(q)) is an euclidean distance between image blocks centered respectively at p and q, f is a decreasing function and C(p) is the normalizing factor.
References
A. Buades, B. Coll, J.M. Morel "A review of image denoising methods, with a new one"
Multiscale Modeling and Simulation, Vol4 (2), pp: 490-530, 2006. on line articleA. Buades, B. Coll, J.M. Morel "A non local algorithm for image denoising"
IEEE Computer Vision and Pattern Recognition 2005, Vol 2, pp: 60-65, 2005. on line article
Implementation
The denoising of a color image u=(u1, u2, u3) and a certain pixel p writes
where i=1, 2, 3 and B(p, r) indicates a neighborhood centered at p and size 2r+1 × 2r+1 pixels.
The weight w(p, q) depends on the squared Euclidean distance d² = d²(B(p), B(q)) of the N × N color patches centered respectively at p and q
That is, each pixel value is restored by an average of the most resembling pixels where this resemblance is computed in the color image. So for each pixel, each channel value is the result of the average of the same pixels.
We use a piece-wise linear function for computing the weights w(p, q)
where σ denotes the standard deviation of the noise and γ is the standard deviation of the distance between two noise patches.
The weight function is set in order to average similar patches up to noise. That is, patches which dissimilarity only due to noise. In order to compute such a standard deviation we can rewrite
being u a noise image. Using the fact that such an expressions
follows a
and its variance
equals 6 N², we can isolate the variance of the square distance of
the two noise patches as γ = 8 σ⁴ / N².
By applying the above averaging procedure we recover the denoised value at each pixel p. The presented formulas can be easily modified in order to denoise the whole N × N patch centered at p at the same time. In that way, by applying the procedure for all pixels in the image, we shall dispose of N² possible estimates for each pixel. These estimates are finally averaged at each location.
The parameters on the online demo are set in the following way: the size of the research window B(p, r) is 21×21 pixels and the comparison patch has size 3×3 pixels for color images. When the algorithm is applied to gray images a slightly larger patch of 5×5 pixels is used.
Source Code
A C/C++ implementation is provided.
It should compile on any system since it's only strict ANSI C/C++ and is distributed under the GPL licence.
Basic compilation and usage instructions are included in the
README.txt file. This code requires
libtiff and is limited to
8bit RGB or grayscale TIFF image files.
The same code is used for the online demo.
On Line Demo: Try It!
An on-line demo of this algorithm is available.
The demo permits to upload any color image, optionally add gaussian noise, then automatically estimate the noise and denoise it.
Examples
The example below illustrates how the NLmeans algorithm is able to remove the noise while keeping the fine structures and details.
| original | noisy, standard deviation 15 | denoised |
|---|---|---|
|
|
![]() |
strollerdos, Flickr CC-BY-NC
ecatoncheires, Flickr CC-BY-NC-SA
Hervé Bry, Flickr CC-BY-NC-SA
Nesster, Flickr CC-BY-SA
chem7, Flickr CC-BY
Jason Adams, Flickr CC-BY-NC-SA


