Function grpc_vision_svc::image_captioning::utils::process_image
source · pub fn process_image(
image_bytes: &[u8]
) -> ImageResult<ImageBuffer<Rgb<u8>, Vec<u8>>>Expand description
Processes an image from raw bytes into an ImageBuffer of RGB values.
This function takes a byte slice representing an image, reads it into a DynamicImage,
resizes it to a 384x384 image using the Triangle filter, and then converts it to an ImageBuffer
of RGB values.
§Arguments
image_bytes- A byte slice representing the image to be processed.
§Returns
ImageResult<ImageBuffer<Rgb<u8>, Vec<u8>>>- AnImageResultcontaining the processedImageBuffer, or animage::ImageErrorif the image could not be processed.
§Examples
let image_bytes: Vec<u8> = fs::read("path/to/image.jpg")?;
let image_buffer: ImageBuffer<Rgb<u8>, Vec<u8>> = process_image(&image_bytes)?;
image_buffer.save("path/to/save/processed_image.jpg")?;