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


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。