bundles / scipy latest / scipy / ndimage / _measurements / minimum_position
function
scipy.ndimage._measurements:minimum_position
Signature
def minimum_position ( input , labels = None , index = None ) Summary
Find the positions of the minimums of the values of an array at labels.
Parameters
input: array_likeArray_like of values.
labels: array_like, optionalAn array of integers marking different regions over which the position of the minimum value of
inputis to be computed.labelsmust have the same shape asinput. Iflabelsis not specified, the location of the first minimum over the whole array is returned.The
labelsargument only works whenindexis specified.index: array_like, optionalA list of region labels that are taken into account for finding the location of the minima. If
indexis None, thefirstminimum over all elements wherelabelsis non-zero is returned.The
indexargument only works whenlabelsis specified.
Returns
output: list of tuples of intsTuple of ints or list of tuples of ints that specify the location of minima of
inputover the regions determined bylabelsand whose index is inindex.If
indexorlabelsare not specified, a tuple of ints is returned specifying the location of the first minimal value ofinput.
Notes
Array API Standard Support
minimum_position 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
import numpy as np a = np.array([[10, 20, 30], [40, 80, 100], [1, 100, 200]]) b = np.array([[1, 2, 0, 1], [5, 3, 0, 4], [0, 0, 0, 7], [9, 3, 0, 0]])✓
from scipy import ndimage
✓ndimage.minimum_position(a) ndimage.minimum_position(b)✗
label, pos = ndimage.label(a)
✓ndimage.minimum_position(a, label, index=np.arange(1, pos+1))
✗label, pos = ndimage.label(b)
✓ndimage.minimum_position(b, label, index=np.arange(1, pos+1))
✗See also
- extrema
- label
- maximum_position
- mean
- median
- minimum
- standard_deviation
- sum
- variance
Aliases
-
scipy.ndimage.minimum_position