mindspore.dataset.vision.read_image
- mindspore.dataset.vision.read_image(filename, mode=ImageReadMode.UNCHANGED)[source]
Read an image file and decode it into single-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-dimensional 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 is not a regular file, or is 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)