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


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


用法:

skimage.restoration.rolling_ball(image, *, radius=100, kernel=None, nansafe=False, num_threads=None)

通过滚动/平移内核来估计背景强度。

在曝光不均匀的情况下,这种滚球算法会估计 ndimage 的背景强度。它是常用的滚球算法[1]的推广。

参数

imagendarray

要过滤的图像。

radiusint 可选

要在图像中滚动/平移的球形内核的半径。如果 kernel = None 使用。

kernelndarray,可选

要在图像中滚动/翻译的内核。它必须具有与 image 相同的维数。内核在该位置填充了内核的强度。

nansafe: bool, optional

如果 False (默认)假定 image 中的所有值都不是 np.nan ,并使用更快的实现。

num_threads: int, optional

要使用的最大线程数。如果None使用OpenMP默认值;通常等于最大虚拟内核数。注意:这是线程数的上限。确切的数字由系统的OpenMP 库确定。

返回

backgroundndarray

图像的估计背景。

注意

对于估计了其背景强度的像素(在 center 处不失一般性),滚动球方法将 kernel 居中并提升内核直到表面在某个 pos=(y,x) 处接触图像本影。然后使用该位置的图像强度 (image[pos]) 加上 kernel[center] - kernel[pos] 的差异来估计背景强度。

该算法假设暗像素对应于背景。如果您有明亮的背景,请在将图像传递给函数之前反转图像,例如,使用 utils.invert 有关详细信息,请参阅图库示例。

该算法对噪声(尤其是椒盐噪声)敏感。如果这是您的图像中的问题,您可以在将图像传递给此函数之前应用温和的高斯平滑。

参考

1

Sternberg, Stanley R. “Biomedical image processing.” Computer 1 (1983): 22-34. DOI:10.1109/MC.1983.1654163

例子

>>> import numpy as np
>>> from skimage import data
>>> from skimage.restoration import rolling_ball
>>> image = data.coins()
>>> background = rolling_ball(data.coins())
>>> filtered_image = image - background
>>> import numpy as np
>>> from skimage import data
>>> from skimage.restoration import rolling_ball, ellipsoid_kernel
>>> image = data.coins()
>>> kernel = ellipsoid_kernel((101, 101), 75)
>>> background = rolling_ball(data.coins(), kernel=kernel)
>>> filtered_image = image - background

相关用法


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