scipy.ndimage.grey_opening

scipy.ndimage.grey_opening(input, size=None, footprint=None, structure=None, output=None, mode='reflect', cval=0.0, origin=0)[源代码]

多维灰度开口。

灰度级开口包括灰度级侵蚀和灰度级膨胀的连续。

参数
inputarray_like

要在其上计算灰度开口的数组。

size整数元组

用于灰度洞口的扁平且完整的结构元素的形状。在以下情况下可选 footprintstructure 是提供的。

footprint整型数组,可选

用于灰度洞口的平面结构元素的非无限元素的位置。

structure整型数组,可选

用于灰度开口的结构元素。 structure 可以是非平坦的结构元素。

output数组,可选

可以提供用于存储开口的输出的阵列。

mode{‘反射’,‘常量’,‘最近’,‘镜像’,‘换行’},可选

这个 mode 参数确定如何处理数组边框, cval 模式等于‘Constant’时的值。默认值为‘Reflect’

cval标量,可选

在以下情况下填充输入的过去边缘的值 mode 是“恒定的”。默认值为0.0。

origin标量,可选

这个 origin 参数控制过滤的位置。默认%0

退货
grey_openingndarray

的灰度打开的结果 input 使用 structure

注意事项

具有平坦结构元素的灰度开口的动作相当于平滑高局部最大值,而二进制开口擦除小对象。

参考文献

1

https://en.wikipedia.org/wiki/Mathematical_morphology

示例

>>> from scipy import ndimage
>>> a = np.arange(36).reshape((6,6))
>>> a[3, 3] = 50
>>> a
array([[ 0,  1,  2,  3,  4,  5],
       [ 6,  7,  8,  9, 10, 11],
       [12, 13, 14, 15, 16, 17],
       [18, 19, 20, 50, 22, 23],
       [24, 25, 26, 27, 28, 29],
       [30, 31, 32, 33, 34, 35]])
>>> ndimage.grey_opening(a, size=(3,3))
array([[ 0,  1,  2,  3,  4,  4],
       [ 6,  7,  8,  9, 10, 10],
       [12, 13, 14, 15, 16, 16],
       [18, 19, 20, 22, 22, 22],
       [24, 25, 26, 27, 28, 28],
       [24, 25, 26, 27, 28, 28]])
>>> # Note that the local maximum a[3,3] has disappeared