denoise_nl_means(image, patch_size=7, patch_distance=11, h=0.1, multichannel=False, fast_mode=True, sigma=0.0, *, preserve_range=None)
The non-local means algorithm is well suited for denoising images with specific textures. The principle of the algorithm is to average the value of a given pixel with values of other pixels in a limited neighbourhood, provided that the patches centered on the other pixels are similar enough to the patch centered on the pixel of interest.
In the original version of the algorithm , corresponding to fast=False
, the computational complexity is:
image.size * patch_size ** image.ndim * patch_distance ** image.ndim
Hence, changing the size of patches or their maximal distance has a strong effect on computing times, especially for 3-D images.
However, the default behavior corresponds to fast_mode=True
, for which another version of non-local means is used, corresponding to a complexity of:
image.size * patch_distance ** image.ndim
The computing time depends only weakly on the patch size, thanks to the computation of the integral of patches distances for a given shift, that reduces the number of operations . Therefore, this algorithm executes faster than the classic algorithm ( fast_mode=False
), at the expense of using twice as much memory. This implementation has been proven to be more efficient compared to other alternatives, see e.g. .
Compared to the classic algorithm, all pixels of a patch contribute to the distance to another patch with the same weight, no matter their distance to the center of the patch. This coarser computation of the distance can result in a slightly poorer denoising performance. Moreover, for small images (images with a linear size that is only a few times the patch size), the classic algorithm can be faster due to boundary effects.
The image is padded using the :None:None:`reflect`
mode of skimage.util.pad
before denoising.
If the noise standard deviation, :None:None:`sigma`
, is provided a more robust computation of patch weights is used. Subtracting the known noise variance from the computed patch distances improves the estimates of patch similarity, giving a moderate improvement to denoising performance . It was also mentioned as an option for the fast variant of the algorithm in .
When :None:None:`sigma`
is provided, a smaller h
should typically be used to avoid oversmoothing. The optimal value for h
depends on the image content and noise level, but a reasonable starting point is h = 0.8 * sigma
when :None:None:`fast_mode`
is :None:None:`True`
, or h = 0.6 * sigma
when :None:None:`fast_mode`
is :None:None:`False`
.
Input image to be denoised, which can be 2D or 3D, and grayscale or RGB (for 2D images only, see multichannel
parameter).
Size of patches used for denoising.
Maximal distance in pixels where to search patches used for denoising.
Cut-off distance (in gray levels). The higher h, the more permissive one is in accepting patches. A higher h results in a smoother image, at the expense of blurring features. For a Gaussian noise of standard deviation sigma, a rule of thumb is to choose the value of h to be sigma of slightly less.
Whether the last axis of the image is to be interpreted as multiple channels or another spatial dimension.
If True (default value), a fast version of the non-local means algorithm is used. If False, the original version of non-local means is used. See the Notes section for more details about the algorithms.
The standard deviation of the (Gaussian) noise. If provided, a more robust computation of patch weights is computed that takes the expected noise variance into account (see Notes below).
Whether to keep the original range of values. Otherwise, the input image is converted according to the conventions of img_as_float
. Also see https://scikit-image.org/docs/dev/user_guide/data_types.html
Denoised image, of same shape as :None:None:`image`
.
Perform non-local means denoising on 2-D or 3-D grayscale images, and 2-D RGB images.
>>> a = np.zeros((40, 40))See :
... a[10:-10, 10:-10] = 1.
... a += 0.3 * np.random.randn(*a.shape)
... denoised_a = denoise_nl_means(a, 7, 5, 0.1)
The following pages refer to to this document either explicitly or contain code examples using this.
skimage.restoration.non_local_means.denoise_nl_means
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them