scipy.ndimage.iterate_structure

scipy.ndimage.iterate_structure(structure, iterations, origin=None)[源代码]

通过用其自身展开结构来迭代该结构。

参数
structurearray_like

结构化元素(例如,布尔数组),用其自身展开。

iterations集成

对具有自身的结构执行的扩张次数

origin可选

如果Origin为None,则只返回迭代结构。如果不是,则返回迭代结构和修改后的原点的元组。

退货
iterate_structure一群野猪

A new structuring element obtained by dilating structure (iterations - 1) times with itself.

示例

>>> from scipy import ndimage
>>> struct = ndimage.generate_binary_structure(2, 1)
>>> struct.astype(int)
array([[0, 1, 0],
       [1, 1, 1],
       [0, 1, 0]])
>>> ndimage.iterate_structure(struct, 2).astype(int)
array([[0, 0, 1, 0, 0],
       [0, 1, 1, 1, 0],
       [1, 1, 1, 1, 1],
       [0, 1, 1, 1, 0],
       [0, 0, 1, 0, 0]])
>>> ndimage.iterate_structure(struct, 3).astype(int)
array([[0, 0, 0, 1, 0, 0, 0],
       [0, 0, 1, 1, 1, 0, 0],
       [0, 1, 1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1, 1, 1],
       [0, 1, 1, 1, 1, 1, 0],
       [0, 0, 1, 1, 1, 0, 0],
       [0, 0, 0, 1, 0, 0, 0]])