用法:
skimage.restoration.denoise_nl_means(image, patch_size=7, patch_distance=11, h=0.1, multichannel=False, fast_mode=True, sigma=0.0, *, preserve_range=False, channel_axis=None)
對 2D-4D 灰度或 RGB 圖像執行非局部方法去噪。
- image:2D 或 3D ndarray
輸入要去噪的圖像,可以是2D或3D,灰度或RGB(僅限2D圖像,見
multichannel
參數)。可以有任意數量的通道(不一定是 RGB)。- patch_size:int 可選
用於去噪的補丁大小。
- patch_distance:int 可選
搜索用於去噪的補丁的最大像素距離。
- h:浮點數,可選
Cut-off 距離(灰度)。 h 越高,接受補丁的可能性就越大。較高的 h 會導致圖像更平滑,但會以模糊特征為代價。對於標準差 sigma 的高斯噪聲,經驗法則是選擇 h 的值略小於 sigma。
- multichannel:布爾型,可選
圖像的最後一個軸是否被解釋為多個通道或另一個空間維度。不推薦使用此參數:改為指定 channel_axis。
- fast_mode:布爾型,可選
如果為 True(默認值),則使用非本地均值算法的快速版本。如果為 False,則使用原始版本的非本地方法。有關算法的更多詳細信息,請參閱注釋部分。
- sigma:浮點數,可選
(高斯)噪聲的標準偏差。如果提供,則計算更穩健的補丁權重計算,將預期噪聲方差考慮在內(請參閱下麵的注釋)。
- preserve_range:布爾型,可選
是否保持原來的取值範圍。否則,輸入圖像將根據以下約定進行轉換img_as_float.另見https://scikit-image.org/docs/dev/user_guide/data_types.html
- channel_axis:int 或無,可選
如果為 None,則假定圖像是灰度(單通道)圖像。否則,此參數指示數組的哪個軸對應於通道。
- result:ndarray
去噪後的圖像,形狀與圖像相同。
- multichannel:DEPRECATED
已棄用以支持channel_axis。
參數:
返回:
其他參數:
注意:
非局部均值算法非常適合對具有特定紋理的圖像進行去噪。該算法的原理是將給定像素的值與有限鄰域中的其他像素的值進行平均,前提是以其他像素為中心的補丁與以感興趣的像素為中心的補丁足夠相似。
在算法[1]的原始版本中,對應於
fast=False
,計算複雜度為:image.size * patch_size ** image.ndim * patch_distance ** image.ndim
因此,改變補丁的大小或它們的最大距離對計算時間有很大的影響,尤其是對於 3D 圖像。
但是,默認行為對應於
fast_mode=True
,為此使用了另一個版本的非本地方法 [2] ,對應的複雜度為:image.size * patch_distance ** image.ndim
由於計算了給定移位的補丁距離積分,計算時間僅取決於補丁大小,這減少了操作[1] 的數量。因此,該算法比經典算法 (
fast_mode=False
) 執行得更快,但代價是使用了兩倍的內存。與其他替代方案相比,此實現已被證明更有效,參見例如[3] 。與經典算法相比,一個patch的所有像素都對到另一個具有相同權重的patch的距離有貢獻,無論它們到patch中心的距離如何。這種更粗略的距離計算會導致去噪性能稍差。此外,對於小圖像(線性大小僅為補丁大小幾倍的圖像),由於邊界效應,經典算法可以更快。
圖像在去噪前使用skimage.util.pad的反射模式進行填充。
如果噪聲標準差,西格瑪, 提供了更穩健的補丁權重計算。從計算的塊距離中減去已知的噪聲方差可以改進塊相似度的估計,從而適度提高去噪性能[4].它也被提到作為算法的快速變體的一個選項[3].
什麽時候西格瑪提供了一個較小的h通常應用於避免過度平滑。的最佳值h取決於圖像內容和噪聲水平,但合理的起點是
h = 0.8 * sigma
當fast_mode是True, 或者h = 0.6 * sigma
當fast_mode是False.參考:
- 1(1,2)
A. Buades, B. Coll, & J-M. Morel. A non-local algorithm for image denoising. In CVPR 2005, Vol. 2, pp. 60-65, IEEE. DOI:10.1109/CVPR.2005.38
- 2
J. Darbon, A. Cunha, T.F. Chan, S. Osher, and G.J. Jensen, Fast nonlocal filtering applied to electron cryomicroscopy, in 5th IEEE International Symposium on Biomedical Imaging: From Nano to Macro, 2008, pp. 1331-1334. DOI:10.1109/ISBI.2008.4541250
- 3(1,2)
Jacques Froment. Parameter-Free Fast Pixelwise Non-Local Means Denoising. Image Processing On Line, 2014, vol. 4, pp. 300-326. DOI:10.5201/ipol.2014.120
- 4
A. Buades, B. Coll, & J-M. Morel. Non-Local Means Denoising. Image Processing On Line, 2011, vol. 1, pp. 208-212. DOI:10.5201/ipol.2011.bcm_nlm
例子:
>>> a = np.zeros((40, 40)) >>> a[10:-10, 10:-10] = 1. >>> rng = np.random.default_rng() >>> a += 0.3 * rng.standard_normal(a.shape) >>> denoised_a = denoise_nl_means(a, 7, 5, 0.1)
相關用法
- Python skimage.restoration.denoise_wavelet用法及代碼示例
- Python skimage.restoration.denoise_tv_chambolle用法及代碼示例
- Python skimage.restoration.denoise_bilateral用法及代碼示例
- Python skimage.restoration.wiener用法及代碼示例
- Python skimage.restoration.cycle_spin用法及代碼示例
- Python skimage.restoration.unwrap_phase用法及代碼示例
- Python skimage.restoration.estimate_sigma用法及代碼示例
- Python skimage.restoration.inpaint_biharmonic用法及代碼示例
- Python skimage.restoration.richardson_lucy用法及代碼示例
- Python skimage.restoration.calibrate_denoiser用法及代碼示例
- Python skimage.restoration.unsupervised_wiener用法及代碼示例
- Python skimage.restoration.rolling_ball用法及代碼示例
- Python skimage.registration.optical_flow_tvl1用法及代碼示例
- Python skimage.registration.optical_flow_ilk用法及代碼示例
- Python skimage.feature.graycomatrix用法及代碼示例
- Python skimage.color.lab2lch用法及代碼示例
- Python skimage.draw.random_shapes用法及代碼示例
- Python skimage.feature.blob_doh用法及代碼示例
- Python skimage.feature.blob_dog用法及代碼示例
- Python skimage.filters.unsharp_mask用法及代碼示例
注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.restoration.denoise_nl_means。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。