This is documentation for an old release of SciPy (version 0.9.0). Read this page in the documentation of the latest stable release (version 1.15.1).
Calculate the variance of the values of an n-D image array, optionally at specified sub-regions.
Parameters : | input : array_like
labels : array_like, or None, optional
index : None, int, or sequence of int, optional
|
---|---|
Returns : | vars : float or ndarray
|
See also
Examples
>>> a = np.array([[1, 2, 0, 0],
[5, 3, 0, 4],
[0, 0, 0, 7],
[9, 3, 0, 0]])
>>> from scipy import ndimage
>>> ndimage.variance(a)
7.609375
Features to process can be specified using labels and index:
>>> lbl, nlbl = ndimage.label(a)
>>> ndimage.variance(a, lbl, index=np.arange(1, nlbl+1))
array([ 2.1875, 2.25 , 9. ])
If no index is given, all non-zero labels are processed:
>>> ndimage.variance(a, lbl)
6.1875