skimage2.restoration.denoise_bilateral#

skimage2.restoration.denoise_bilateral(image, win_size=None, sigma_color=None, sigma_spatial=1, bins=10000, mode='constant', cval=0, *, channel_axis=None)[source]#

Denoise image using bilateral filter.

Parameters:
imagendarray, shape (M, N[, 3])

Input image, 2D grayscale or RGB.

win_sizeint

Window size for filtering. If win_size is not specified, it is calculated as max(5, 2 * ceil(3 * sigma_spatial) + 1).

sigma_colorfloat

Standard deviation for grayvalue/color distance (radiometric similarity). A larger value results in averaging of pixels with larger radiometric differences. If None, the standard deviation of image will be used.

sigma_spatialfloat

Standard deviation for range distance. A larger value results in averaging of pixels with larger spatial differences.

binsint

Number of discrete values for Gaussian weights of color filtering. A larger value results in improved accuracy.

mode{‘constant’, ‘edge’, ‘symmetric’, ‘reflect’, ‘wrap’}

How to handle values outside the image borders. See numpy.pad for detail.

cvalint or float

Used in conjunction with mode ‘constant’, the value outside the image boundaries.

channel_axisint or None, optional

If None, the image is assumed to be grayscale (single-channel). Otherwise, this parameter indicates which axis of the array corresponds to channels.

Added in version 0.19: channel_axis was added in 0.19.

Returns:
denoisedndarray

Denoised image.

Notes

This is an edge-preserving, denoising filter. It averages pixels based on their spatial closeness and radiometric similarity [1].

Spatial closeness is measured by the Gaussian function of the Euclidean distance between two pixels and a certain standard deviation (sigma_spatial).

Radiometric similarity is measured by the Gaussian function of the Euclidean distance between two color values and a certain standard deviation (sigma_color).

Note that, if the image is of any int dtype, image will be converted using the img_as_float function and thus the standard deviation (sigma_color) will be in range [0, 1].

For more information on scikit-image’s data type conversions and how images are rescaled in these conversions, see: https://scikit-image.org/docs/stable/user_guide/data_types.html.

References

[1]

C. Tomasi and R. Manduchi. “Bilateral Filtering for Gray and Color Images.” IEEE International Conference on Computer Vision (1998) 839-846. DOI:10.1109/ICCV.1998.710815

Examples

>>> from _skimage2 import data, img_as_float
>>> astro = img_as_float(data.astronaut())
>>> astro = astro[220:300, 220:320]
>>> rng = np.random.default_rng()
>>> noisy = astro + 0.6 * astro.std() * rng.random(astro.shape)
>>> noisy = np.clip(noisy, 0, 1)
>>> denoised = denoise_bilateral(noisy, sigma_color=0.05, sigma_spatial=15,
...                              channel_axis=-1)