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


Python SciPy ndimage.white_tophat用法及代码示例


本文简要介绍 python 语言中 scipy.ndimage.white_tophat 的用法。

用法:

scipy.ndimage.white_tophat(input, size=None, footprint=None, structure=None, output=None, mode='reflect', cval=0.0, origin=0)#

多维白色礼帽过滤器。

参数

input array_like

输入。

size 整数元组

用于过滤器的扁平且完整的结构元素的形状。如果提供了足迹或结构,则可选。

footprint 整数数组,可选

用于白色顶帽过滤器的平面结构元素的元素位置。

structure 整数数组,可选

用于过滤器的结构元素。结构可以是非平面结构元素。

output 数组,可选

可以提供用于存储滤波器的输出的数组。

mode {‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’},可选

mode 参数确定如何处理数组边界,其中 cval 是 mode 等于 ‘constant’ 时的值。默认为‘reflect’

cval 标量,可选

如果模式为‘constant’,则填充过去输入边的值。默认值为 0.0。

origin 标量,可选

origin 参数控制过滤器的位置。默认值为 0。

返回

output ndarray

输入结构过滤的结果。

例子

从明亮的峰中减去灰色背景。

>>> from scipy.ndimage import generate_binary_structure, white_tophat
>>> import numpy as np
>>> square = generate_binary_structure(rank=2, connectivity=3)
>>> bright_on_gray = np.array([[2, 3, 3, 3, 2],
...                            [3, 4, 5, 4, 3],
...                            [3, 5, 9, 5, 3],
...                            [3, 4, 5, 4, 3],
...                            [2, 3, 3, 3, 2]])
>>> white_tophat(input=bright_on_gray, structure=square)
array([[0, 0, 0, 0, 0],
       [0, 0, 1, 0, 0],
       [0, 1, 5, 1, 0],
       [0, 0, 1, 0, 0],
       [0, 0, 0, 0, 0]])

相关用法


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