当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python skimage.restoration.denoise_bilateral用法及代码示例


用法:

skimage.restoration.denoise_bilateral(image, win_size=None, sigma_color=None, sigma_spatial=1, bins=10000, mode='constant', cval=0, multichannel=False, *, channel_axis=None)

使用双边滤波器对图像进行去噪。

参数

imagendarray,形状(M,N[,3])

输入图像,2D 灰度或 RGB。

win_sizeint

过滤的窗口大小。如果未指定win_size,则计算为max(5, 2 * ceil(3 * sigma_spatial) + 1)

sigma_color浮点数

灰度值/颜色距离的标准偏差(辐射相似度)。较大的值会导致对具有较大辐射差异的像素进行平均。如果 None ,将使用 image 的标准偏差。

sigma_spatial浮点数

距离的标准偏差。较大的值导致具有较大空间差异的像素的平均。

binsint

颜色过滤的高斯权重的离散值的数量。较大的值会提高准确性。

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

如何处理图像边界之外的值。有关详细信息,请参阅 numpy.pad

cvalstring

与模式‘constant’(图像边界外的值)结合使用。

multichannelbool

图像的最后一个轴是否被解释为多个通道或另一个空间维度。不推荐使用此参数:改为指定 channel_axis。

channel_axisint 或无,可选

如果为 None,则假定图像是灰度(单通道)图像。否则,此参数指示数组的哪个轴对应于通道。

返回

denoisedndarray

去噪图像。

其他参数

multichannelDEPRECATED

已弃用以支持channel_axis。

注意

这是一个edge-preserving,去噪滤波器。它根据像素的空间接近度和辐射相似度对像素进行平均 [1]

空间接近度是通过两个像素之间的欧几里得距离和一定标准偏差(sigma_spatial)的高斯函数来衡量的。

辐射相似度是通过两个颜色值之间的欧几里得距离和某个标准偏差 (sigma_color) 的高斯函数来衡量的。

请注意,如果图像是任何int数据类型,image将使用img_as_float函数和标准差 (sigma_color) 将在范围内[0, 1].

有关scikit-image 的数据类型转换以及如何在这些转换中重新缩放图像的更多信息,请参阅:https://scikit-image.org/docs/stable/user_guide/data_types.html.

参考

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

例子

>>> from skimage 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)

相关用法


注:本文由纯净天空筛选整理自scikit-image.org大神的英文原创作品 skimage.restoration.denoise_bilateral。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。