use kornia_rs::image::Image; use kornia_rs::io::functional as F; fn main() -> Result<(), Box> { // read the image let image_path = std::path::Path::new("tests/data/dog.jpeg"); let image: Image = F::read_image_any(image_path)?; // cast the image to floating point let image_f32: Image = image.clone().cast::()?; // normalize the image between 0 and 255 let _image_f32_norm: Image = kornia_rs::normalize::normalize_mean_std( &image_f32, &[127.5, 127.5, 127.5], &[127.5, 127.5, 127.5], )?; // alternative way to normalize the image between 0 and 255 let _image_f32_norm: Image = image.clone().cast_and_scale::(1.0 / 255.0)?; // Or: image.cast_and_scale::(1.0 / 255.0)?; // alternative way to normalize the image between 0 and 1 let _image_f32_norm: Image = image_f32.mul(1.0 / 255.0); // Or: let image_f32_norm = image_f32.div(255.0); let (min, max) = kornia_rs::normalize::find_min_max(&image_f32)?; println!("min: {:?}, max: {:?}", min, max); Ok(()) }