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) – Number of channels of the output grayscale image, which can be 1 or 3 (default=1). If num_output_channels is 3, the returned image will have 3 identical RGB channels.
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")