bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / ndimage / _measurements / extrema
function
scipy.ndimage._measurements:extrema
source: build-install/usr/lib/python3.14/site-packages/scipy/ndimage/_measurements.py:1406
Signature
def extrema(input, labels = None, index = None)Summary
Calculate the minimums and maximums of the values of an array at labels, along with their positions.
Parameters
input: ndarrayN-D image data to process.
labels: ndarray, optionalLabels of features in input. If not None, must be same shape as
input.index: int or sequence of ints, optionalLabels to include in output. If None (default), all values where non-zero
labelsare used.
Returns
minimums, maximums: int or ndarrayValues of minimums and maximums in each feature.
min_positions, max_positions: tuple or list of tuplesEach tuple gives the N-D coordinates of the corresponding minimum or maximum.
Examples
import numpy as np a = np.array([[1, 2, 0, 0], [5, 3, 0, 4], [0, 0, 0, 7], [9, 3, 0, 0]]) from scipy import ndimage✓
ndimage.extrema(a)
✗(np.int64(0), np.int64(9), (np.int64(0), np.int64(2)), (np.int64(3), np.int64(0)))Features to process can be specified using `labels` and `index`:
lbl, nlbl = ndimage.label(a)
✓ndimage.extrema(a, lbl, index=np.arange(1, nlbl+1))
✗(array([1, 4, 3]), array([5, 7, 9]), [(np.int64(0), np.int64(0)), (np.int64(1), np.int64(3)), (np.int64(3), np.int64(1))], [(np.int64(1), np.int64(0)), (np.int64(2), np.int64(3)), (np.int64(3), np.int64(0))])If no index is given, non-zero `labels` are processed:
ndimage.extrema(a, lbl)
✗(np.int64(1), np.int64(9), (np.int64(0), np.int64(0)), (np.int64(3), np.int64(0)))
See also
Aliases
scipy.ndimage.extrema