scipy.ndimage.white_tophat¶
- scipy.ndimage.white_tophat(input, size=None, footprint=None, structure=None, output=None, mode='reflect', cval=0.0, origin=0)[源代码]¶
多维白大头帽过滤。
- 参数
- inputarray_like
输入。
- size整数元组
用于过滤的扁平且完整的结构元素的形状。在以下情况下可选 footprint 或 structure 是提供的。
- footprint整型数组,可选
用于白大帽过滤的平面结构元素的元素位置。
- structure整型数组,可选
用于过滤的结构元素。 structure 可以是非平坦的结构元素。
- output数组,可选
可以提供用于存储过滤的输出的阵列。
- mode{‘反射’,‘常量’,‘最近’,‘镜像’,‘换行’},可选
这个 mode 参数确定如何处理数组边框, cval 模式等于‘Constant’时的值。默认值为‘Reflect’
- cval标量,可选
在以下情况下填充输入的过去边缘的值 mode 是“恒定的”。默认值为0.0。
- origin标量,可选
这个 origin 参数控制过滤的位置。默认值为0。
- 退货
- outputndarray
中欧共建“过滤”的成果 input 使用 structure 。
参见
示例
从亮峰中减去灰色背景。
>>> from scipy.ndimage import generate_binary_structure, white_tophat >>> 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]])