mindspore.dataset.vision.Grayscale
- class mindspore.dataset.vision.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
or3
. If3
is provided, the returned image will have 3 identical RGB channels. Default:1
.- Raises
TypeError – If num_output_channels is not of type integer.
ValueError – If num_output_channels is not
1
or3
.
- Supported Platforms:
CPU
Examples
>>> import mindspore.dataset as ds >>> import mindspore.dataset.vision as vision >>> from mindspore.dataset.transforms import Compose >>> >>> transforms_list = Compose([vision.Decode(to_pil=True), ... vision.Grayscale(3), ... vision.ToTensor()]) >>> # apply the transform to dataset through map function >>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory") >>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list, ... input_columns="image")
- Tutorial Examples: