mindspore.dataset.vision.read_image
- mindspore.dataset.vision.read_image(filename, mode=ImageReadMode.UNCHANGED)[source]
Read a image file and decode it into one channel grayscale data or RGB color data. Supported file types are JPEG, PNG, BMP, TIFF.
- Parameters
filename (str) – The path to the image file to be read.
mode (ImageReadMode, optional) –
The mode used for decoding the image. It can be
ImageReadMode.UNCHANGED
,ImageReadMode.GRAYSCALE
,IMageReadMode.COLOR
. Default:ImageReadMode.UNCHANGED
.ImageReadMode.UNCHANGED, remain the output in the original format.
ImageReadMode.GRAYSCALE, convert the output into one channel grayscale data.
IMageReadMode.COLOR, convert the output into three channels RGB color data.
- Returns
numpy.ndarray, three dimensions uint8 data in the shape of (Height, Width, Channels).
- Raises
TypeError – If filename is not of type str.
TypeError – If mode is not of type
mindspore.dataset.vision.ImageReadMode
.RuntimeError – If filename does not exist, or not a regular file, or not a supported image file.
- Supported Platforms:
CPU
Examples
>>> import mindspore.dataset.vision as vision >>> from mindspore.dataset.vision import ImageReadMode >>> output = vision.read_image("/path/to/image_file", ImageReadMode.UNCHANGED)