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 (int, optional) –

    The mode used for decoding the image. It can be any of [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
Supported Platforms:

CPU

Examples

>>> from mindspore.dataset.vision import ImageReadMode
>>> output = vision.read_image("/path/to/image_file", ImageReadMode.UNCHANGED)