pub fn normalize_chw(
img: &[f32],
channels: usize,
h: usize,
w: usize,
mean: &[f32],
std: &[f32],
) -> VisionResult<Vec<f32>>Expand description
Normalize a CHW image channel-wise: output[c, h, w] = (input[c, h, w] - mean[c]) / std[c].
§Parameters
img: flat[channels × h × w]input buffer.channels: number of channels; must equalmean.len()andstd.len().h: image height in pixels.w: image width in pixels.mean: per-channel mean values; length must equalchannels.std: per-channel standard deviation values; length must equalchannels. Each element must be positive.
§Errors
Returns VisionError::InvalidImageSize if any dimension is zero.
Returns VisionError::DimensionMismatch if img.len() != channels * h * w.
Returns VisionError::ShapeMismatch if mean.len() != channels or std.len() != channels.
Returns VisionError::NonFinite if any std[c] <= 0 (would produce NaN/Inf).