Expand description
Utility functions for image processing.
This module provides functions for loading, converting, and manipulating images in the OCR pipeline. It includes functions for converting between different image formats, loading single or batch images from files, creating images from raw data, and resize-and-pad operations.
Structs§
- OCRResize
PadConfig - Configuration for OCR-style resize-and-pad operations with width constraints.
- Resize
PadConfig - Configuration for resize-and-pad operations.
Enums§
- Padding
Strategy - Padding strategy for resize-and-pad operations.
Functions§
- calculate_
center_ crop_ coords - Calculates centered crop coordinates for a target size.
- check_
image_ size - Checks if the given image size is valid (non-zero dimensions).
- create_
rgb_ image - Creates an RgbImage from raw pixel data.
- dynamic_
to_ gray - Converts a DynamicImage to a GrayImage.
- dynamic_
to_ rgb - Converts a DynamicImage to an RgbImage.
- load_
image - Loads an image from a file path and converts it to RgbImage.
- load_
image_ from_ memory - Loads an image from the given bytes and converts it to RgbImage.
- load_
images - Loads a batch of images from file paths.
- load_
images_ batch_ with_ policy - Load multiple images from file paths using centralized parallel policy.
- load_
images_ batch_ with_ threshold - Loads a batch of images from file paths with a custom parallel threshold.
- mask_
region - Masks a rectangular region in an RGB image with a solid color.
- mask_
regions - Masks multiple bounding box regions in an RGB image.
- ocr_
resize_ and_ pad - Resize an image for OCR processing with width constraints and padding.
- pad_
image - Pads an image to the specified dimensions with a fill color.
- resize_
and_ pad - Resize an image to fit within target dimensions while maintaining aspect ratio, then pad to exact target dimensions.
- resize_
gray_ image - Resizes a grayscale image to the target dimensions using Lanczos3 filtering.
- resize_
image - Resizes an RGB image to the target dimensions using Lanczos3 filtering.
- resize_
images_ batch - Resizes a batch of images to the specified dimensions.
- resize_
images_ batch_ to_ dynamic - Resizes a batch of images and converts them to DynamicImage format.
- rgb_
to_ grayscale - Converts an RGB image to grayscale.
- slice_
gray_ image - Extracts a rectangular region from a grayscale image.
- slice_
image - Extracts a rectangular region from an RGB image.
- validate_
crop_ bounds - Validates that crop coordinates stay within image bounds.