當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。