scipy.ndimage.minimum

scipy.ndimage.minimum(input, labels=None, index=None)[源代码]

计算已标记区域上数组的最小值。

参数
inputarray_like

值的类似数组。对于由指定的每个区域 labels 的最小值 input 对该区域进行了计算。

labelsARRAY_LIKE,可选

一组类似整数的数组,用于标记不同的区域,在这些区域上, input 是要计算出来的。 labels 必须具有与的形状相同的形状 input 。如果 labels 未指定,则返回整个数组的最小值。

indexARRAY_LIKE,可选

计算最小值时要考虑的区域标签列表。如果index为NONE,则为以下所有元素的最小值 labels 是非零的,则返回。

退货
minimum浮点数或浮点数列表

的最小值列表 input 在由以下因素确定的区域范围内 labels 以及谁的索引在 index 。如果 indexlabels 未指定,则返回一个浮点数: input 如果 labels 为NONE,并且元素的最小值为 labels 如果出现以下情况,则大于零 index 是没有的。

注意事项

该函数返回Python列表而不是NumPy数组,请使用 np.array 若要将列表转换为数组,请执行以下操作。

示例

>>> from scipy import ndimage
>>> a = np.array([[1, 2, 0, 0],
...               [5, 3, 0, 4],
...               [0, 0, 0, 7],
...               [9, 3, 0, 0]])
>>> labels, labels_nb = ndimage.label(a)
>>> labels
array([[1, 1, 0, 0],
       [1, 1, 0, 2],
       [0, 0, 0, 2],
       [3, 3, 0, 0]])
>>> ndimage.minimum(a, labels=labels, index=np.arange(1, labels_nb + 1))
[1.0, 4.0, 3.0]
>>> ndimage.minimum(a)
0.0
>>> ndimage.minimum(a, labels=labels)
1.0