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 image has invalid dimensions which should be larger than 1.

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

Examples

>>> num_channels = vision.get_image_num_channels(image)