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


Python skimage.restoration.cycle_spin用法及代碼示例

用法:

skimage.restoration.cycle_spin(x, func, max_shifts, shift_steps=1, num_workers=None, multichannel=False, func_kw={}, *, channel_axis=- 1)

循環旋轉(重複將 func 應用於 x 的移位版本)。

參數

xarray-like

輸入到 func 的數據。

func函數

適用於 x 的循環移位版本的函數。應該將x 作為它的第一個參數。可以通過 func_kw 提供任何其他參數。

max_shiftsint 或元組

如果是整數,將沿 x 的每個軸使用 range(0, max_shifts+1) 中的移位。如果是元組,range(0, max_shifts[i]+1) 將沿著 i 軸。

shift_stepsint 或元組,可選

沿軸 i 應用的移位的步長為::range((0, max_shifts[i]+1, shift_steps[i])) 。如果提供整數,則所有軸使用相同的步長。

num_workersint 或無,可選

在循環旋轉期間使用的並行線程數。如果設置為 None ,則使用完整的可用內核集。

multichannel布爾型,可選

是否將最終軸視為通道(在通道軸上不執行循環移位)。不推薦使用此參數:改為指定 channel_axis。

func_kw字典,可選

要提供給 func 的其他關鍵字參數。

channel_axisint 或無,可選

如果為 None,則假定圖像是灰度(單通道)圖像。否則,此參數指示數組的哪個軸對應於通道。

返回

avg_ynp.ndarray

func(x, **func_kw) 的輸出對指定軸偏移的所有組合進行平均。

其他參數

multichannelDEPRECATED

已棄用以支持channel_axis。

注意

循環旋轉被提議作為一種通過執行 shift-variant 變換 [1] 的幾個循環移位來接近移位不變性的方法。

對於 n-level 離散小波變換,可能希望執行所有移位直到 max_shifts = 2**n - 1 。在實踐中,很多好處通常可以通過每個軸的少量移位來實現。

對於諸如逐塊離散餘弦變換之類的變換,人們可能希望將移位評估為變換使用的塊大小。

參考

1

R.R. Coifman and D.L. Donoho. “Translation-Invariant De-Noising”. Wavelets and Statistics, Lecture Notes in Statistics, vol.103. Springer, New York, 1995, pp.125-150. DOI:10.1007/978-1-4612-2544-7_9

例子

>>> import skimage.data
>>> from skimage import img_as_float
>>> from skimage.restoration import denoise_wavelet, cycle_spin
>>> img = img_as_float(skimage.data.camera())
>>> sigma = 0.1
>>> img = img + sigma * np.random.standard_normal(img.shape)
>>> denoised = cycle_spin(img, func=denoise_wavelet,
...                       max_shifts=3)

相關用法


注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.restoration.cycle_spin。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。