bundles / scipy 1.17.1 / scipy / ndimage / _measurements / standard_deviation
function
scipy.ndimage._measurements:standard_deviation
Signature
def standard_deviation ( input , labels = None , index = None ) Summary
Calculate the standard deviation of the values of an N-D image array, optionally at specified sub-regions.
Parameters
input: array_likeN-D image data to process.
labels: array_like, optionalLabels to identify sub-regions in
input. If not None, must be same shape asinput.index: int or sequence of ints, optionallabelsto include in output. If None (default), all values wherelabelsis non-zero are used.
Returns
standard_deviation: float or ndarrayValues of standard deviation, for each sub-region if
labelsandindexare specified.
Notes
Array API Standard Support
standard_deviation 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([[1, 2, 0, 0], [5, 3, 0, 4], [0, 0, 0, 7], [9, 3, 0, 0]]) from scipy import ndimage✓
ndimage.standard_deviation(a)
✗lbl, nlbl = ndimage.label(a)
✓ndimage.standard_deviation(a, lbl, index=np.arange(1, nlbl+1))
✗ndimage.standard_deviation(a, lbl)
✗See also
Aliases
-
scipy.ndimage.standard_deviation