bundles / scipy latest / scipy / ndimage / _measurements / minimum
function
scipy.ndimage._measurements:minimum
Signature
def minimum ( input , labels = None , index = None ) Summary
Calculate the minimum of the values of an array over labeled regions.
Parameters
input: array_likeArray_like of values. For each region specified by
labels, the minimal values ofinputover the region is computed.labels: array_like, optionalAn array_like of integers marking different regions over which the minimum value of
inputis to be computed.labelsmust have the same shape asinput. Iflabelsis not specified, the minimum over the whole array is returned.index: array_like, optionalA list of region labels that are taken into account for computing the minima. If index is None, the minimum over all elements where
labelsis non-zero is returned.
Returns
output: a scalar or list of integers or floats based on input type.List of minima of
inputover the regions determined bylabelsand whose index is inindex. Ifindexorlabelsare not specified, a float is returned: the minimal value ofinputiflabelsis None, and the minimal value of elements wherelabelsis greater than zero ifindexis None.
Notes
The function returns a Python list and not a NumPy array, use np.array to convert the list to an array.
Array API Standard Support
minimum has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.
==================== ==================== ==================== Library CPU GPU ==================== ==================== ==================== NumPy ✅ n/a CuPy n/a ✅ PyTorch ✅ ⛔ JAX ⚠️ no JIT ⛔ Dask ⚠️ computes graph n/a ==================== ==================== ====================
See
dev-arrayapifor more information.
Examples
from scipy import ndimage import numpy as np 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✓
ndimage.minimum(a, labels=labels, index=np.arange(1, labels_nb + 1)) ndimage.minimum(a) ndimage.minimum(a, labels=labels)✗
See also
- extrema
- label
- maximum
- mean
- median
- minimum_position
- standard_deviation
- sum
- variance
Aliases
-
scipy.ndimage.minimum