resize_and_pad

Function resize_and_pad 

Source
pub fn resize_and_pad(
    img: &RgbImage,
    vcfg: &VisionConfig,
    operator_max: Option<usize>,
) -> RgbImage
Expand description

2026-09-25: Fit img inside the smart_resize canvas preserving aspect, then zero-pad right/bottom to the canvas exactly. Returns the padded canvas.

  • The pad is black pixels applied before normalisation, so padded cells normalise to (0 - mean)/std, not 0.0.
  • The fit never upscales: image c of the reference fixtures (640x360) sits unresampled in a 644x364 canvas.

tests/glm_vision_preprocess_pin.rs compares the output with the reference’s pixel_values for the fixture images.