mindspore.dataset.vision.get_image_num_channels

mindspore.dataset.vision.get_image_num_channels(image)[source]

Get the number of input image channels.

Parameters

image (Union[numpy.ndarray, PIL.Image.Image]) – Image to get the number of channels.

Returns

int, the number of input image channels.

Raises
  • RuntimeError – If the dimension of image is less than 2.

  • TypeError – If image is not of type <class 'numpy.ndarray'> or <class 'PIL.Image.Image'>.

Examples

>>> import mindspore.dataset.vision as vision
>>> from PIL import Image
>>> image = Image.open("/path/to/image_file")
>>> num_channels = vision.get_image_num_channels(image)