image_conversion module
Converts between PIL and OpenCV image formats.
This module provides functions to convert between Python Imaging Library (PIL) image format and OpenCV image format.
- utilities.image_conversion.pil_to_cv2(pil_image: Image) ndarray
Converts a PIL image to OpenCV image format.
- Parameters:
pil_image (Image.Image) – A PIL image object.
- Returns:
A NumPy array representing the image in OpenCV format (BGR channel order).
- Raises:
ValueError – If the input image mode is not compatible with RGB or BGR.
- utilities.image_conversion.cv2_to_pil(cv2_image: ndarray) Image
Converts an OpenCV image to PIL image format.
- Parameters:
cv2_image (np.ndarray) – A NumPy array representing an image in OpenCV format (BGR channel order).
- Returns:
A PIL image object.