This is a pre-release version (latest).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy latest / 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 : ndarray

N-D image data to process.

labels : ndarray, optional

Labels of features in input. If not None, must be same shape as input.

index : int or sequence of ints, optional

Labels to include in output. If None (default), all values where non-zero labels are used.

Returns

minimums, maximums : int or ndarray

Values of minimums and maximums in each feature.

min_positions, max_positions : tuple or list of tuples

Each 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

center_of_mass
maximum
maximum_position
minimum
minimum_position

Aliases

  • scipy.ndimage.extrema

Referenced by