kernels.variance
kernels.variance(arr, *, ddof=0, return_mean=False, validate=True)Return the NaN-aware variance along the stack axis.
Parameters
arr : (ndarray, shape(N, *spatial))-
Image stack. Accepted dtypes are
uint8,uint16,int16,int32,float32, andfloat64. Integer inputs are promoted to the package’s floating workspace whenvalidateisTrue. Inputs with more than 3 dimensions are flattened internally; output shapes match the trailing spatial dimensions of the input. ddof : int = 0-
Delta degrees of freedom. The returned value is
sum((valid - mean)**2) / (nvalid - ddof). Pixels withnvalid <= ddofreturnNaN. return_mean : bool = False-
If
True, also return the per-pixel mean from the same accumulation pass. validate : bool = True-
If
True, check dimensionality and normalize dtype/contiguity before entering the Rust kernel. IfFalse, callers must provide inputs that satisfy the compiled kernel assumptions.
Returns
variance : (ndarray, shape(*spatial))-
Per-pixel variance of finite values. Use
np.sqrt(var)if a standard-deviation or error-like map is needed. mean : (ndarray, shape(*spatial))-
Returned only when
return_mean=True.