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

>>> num_channels = vision.get_image_num_channels(image)