OOF2: The Manual
Name
NonlocalMeans (NonlocalMeans) — Denoise using nonlocal means filtering (suitable for images with regions of repetitive texture).
Synopsis
NonlocalMeans(patch_size, patch_distance, h, sigma)
Details
-
Base class:
DenoiseMethod -
Parameters:
patch_size- Size of patches used for denoising, in pixel units. Type: Integer.
patch_distance- Maximum distance over which to search for similar patches, in pixel units. Type: Integer.
h- Cut-off, in gray levels. A higher h results in a smoother image. Type: A real number.
sigma- The standard deviation of the noise. Type: A real number, or the value
automatic.
Description
NonlocalMeans can be used as the
method parameter to the OOF.Image.Modify.Denoise command. It calls
skimage.restoration.denoise_nl_means
from the scikit-image library. It works by searching a local region
for patches of pixels that are similar (see below), and somehow
averaging them. The patch_distance parameter
determines the radius of the local region. The patches are squares
with sides of length patch_size, or
patch_size+1 if patch_size is
even.
h determines what “similar” means.
The scikit-image documentation says “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 or slightly less.”
sigma is the standard deviation of the noise in
the image, assuming that it's Gaussian. If the noise is not known,
set sigma to automatic. The scikit-image
documentation says that if a noise value is provided, “a more
robust computation of patch weights is computed that takes the
expected noise variance into account.”
Figure 6.96. A Noisy Image

The image on the left is a 200×200 pixel section of an
Escher print. The image on the right is the same section,
with noise added. The RGB values range from 0 to 1, and the
standard deviation of the noise is 0.15. The norm of the
difference, e, between the two images is
44.1.
Figure 6.97. Denoising with NonlocalMeans

The results of applying NonlocalMeans
to the noisy image in Figure 6.96, with
the given values of patch_size,
patch_distance, and
h. sigma was set to
automatic.
Generally, large values of h yield smoother
images, and small values of patch_size
preserve more detail. The results are better for large values
of patch_distance, at the expense of
computation time.
The e value in each image is the norm of
the difference between the denoised image and the original
image (without noise). Smaller values tend to be better
reconstructions, but your needs may vary. That is, the norm
may not be the best way of measuring error in your situation.



