imageio.plugins.opencv.OpenCVPlugin.read#

OpenCVPlugin.read(*, index: Optional[int] = None, colorspace: Optional[Union[int, str]] = None, flags: int = cv2.IMREAD_COLOR) ndarray[source]#

Read an image from the ImageResource.

Parameters:
indexint, Ellipsis

If int, read the index-th image from the ImageResource. If ..., read all images from the ImageResource and stack them along a new, prepended, batch dimension. If None (default), use index=0 if the image contains exactly one image and index=... otherwise.

colorspacestr, int

The colorspace to convert into after loading and before returning the image. If None (default) keep grayscale images as is, convert images with an alpha channel to RGBA and all other images to RGB. If int, interpret colorspace as one of OpenCVs conversion flags and use it for conversion. If str, convert the image into the given colorspace. Possible string values are: "RGB", "BGR", "RGBA", "BGRA", "GRAY", "HSV", or "LAB".

flagsint

The OpenCV flag(s) to pass to the reader. Refer to the OpenCV docs for details.

Returns:
ndimagenp.ndarray

The decoded image as a numpy array.