{ } Raw JSON

bundles / scipy latest / scipy / ndimage / _measurements / extrema

function

scipy.ndimage._measurements:extrema

source: /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.

Notes

Array API Standard Support

extrema 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-arrayapi for more information.

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)
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))
If no index is given, non-zero `labels` are processed:
ndimage.extrema(a, lbl)

See also

center_of_mass
maximum
maximum_position
minimum
minimum_position

Aliases

  • scipy.ndimage.extrema

Referenced by

This package