kernels.nanaverage
Return the NaN-aware weighted average along the stack axis.
Parameters
arr : (ndarray, shape(N, *spatial))-
Image stack. Accepted dtypes are
uint8,uint16,int16,int32,float32, andfloat64. Weighted averages returnfloat64. Output shapes match the trailing spatial dimensions. weights : (ndarray, shape(N))-
Per-plane weights. The weighted sum skips non-finite pixels, so the effective denominator is the sum of weights for finite values at each output pixel.
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
nanaverage : (ndarray, shape(*spatial))-
Per-pixel weighted average. Pixels with no finite weighted samples return
NaN.
Notes
At each output pixel, compute sum(w_i * x_i) / sum(w_i) over finite input values only; a missing value removes its weight from both sums. An empty selection or zero total selected weight returns NaN. Weights apply per image plane, not per output pixel.