scipy.ndimage.grey_closing

scipy.ndimage.grey_closing(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_closingndarray

的灰度关闭的结果 input 使用 structure

注意事项

灰度闭合与扁平结构元素的作用相当于平滑深层局部极小值,而二进制闭合则填充小孔。

参考文献

1

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

示例

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