mindspore.dataset.vision.py_transforms.Grayscale
- class mindspore.dataset.vision.py_transforms.Grayscale(num_output_channels=1)[source]
Convert the input PIL Image to grayscale.
- Parameters
num_output_channels (int) – The number of channels desired for the output image, must be 1 or 3. If 3 is provided, the returned image will have 3 identical RGB channels. Default: 1.
- Raises
TypeError – If num_output_channels is not of type int.
ValueError – If num_output_channels is not 1 or 3.
- Supported Platforms:
CPU
Examples
>>> from mindspore.dataset.transforms.py_transforms import Compose >>> >>> transforms_list = Compose([py_vision.Decode(), ... py_vision.Grayscale(3), ... py_vision.ToTensor()]) >>> # apply the transform to dataset through map function >>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list, ... input_columns="image")