mindspore.dataset.vision.ConvertColor
- class mindspore.dataset.vision.ConvertColor(convert_mode)[source]
Change the color space of the image.
- Parameters
convert_mode (ConvertMode) –
The mode of image channel conversion.
ConvertMode.COLOR_BGR2BGRA, Convert BGR image to BGRA image.
ConvertMode.COLOR_RGB2RGBA, Convert RGB image to RGBA image.
ConvertMode.COLOR_BGRA2BGR, Convert BGRA image to BGR image.
ConvertMode.COLOR_RGBA2RGB, Convert RGBA image to RGB image.
ConvertMode.COLOR_BGR2RGBA, Convert BGR image to RGBA image.
ConvertMode.COLOR_RGB2BGRA, Convert RGB image to BGRA image.
ConvertMode.COLOR_RGBA2BGR, Convert RGBA image to BGR image.
ConvertMode.COLOR_BGRA2RGB, Convert BGRA image to RGB image.
ConvertMode.COLOR_BGR2RGB, Convert BGR image to RGB image.
ConvertMode.COLOR_RGB2BGR, Convert RGB image to BGR image.
ConvertMode.COLOR_BGRA2RGBA, Convert BGRA image to RGBA image.
ConvertMode.COLOR_RGBA2BGRA, Convert RGBA image to BGRA image.
ConvertMode.COLOR_BGR2GRAY, Convert BGR image to GRAY image.
ConvertMode.COLOR_RGB2GRAY, Convert RGB image to GRAY image.
ConvertMode.COLOR_GRAY2BGR, Convert GRAY image to BGR image.
ConvertMode.COLOR_GRAY2RGB, Convert GRAY image to RGB image.
ConvertMode.COLOR_GRAY2BGRA, Convert GRAY image to BGRA image.
ConvertMode.COLOR_GRAY2RGBA, Convert GRAY image to RGBA image.
ConvertMode.COLOR_BGRA2GRAY, Convert BGRA image to GRAY image.
ConvertMode.COLOR_RGBA2GRAY, Convert RGBA image to GRAY image.
- Raises
TypeError – If convert_mode is not of type
mindspore.dataset.vision.ConvertMode
.RuntimeError – If given tensor shape is not <H, W> or <H, W, C>.
- Supported Platforms:
CPU
Examples
>>> import mindspore.dataset as ds >>> import mindspore.dataset.vision as vision >>> >>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory") >>> >>> # Convert RGB images to GRAY images >>> convert_op = vision.ConvertColor(vision.ConvertMode.COLOR_RGB2GRAY) >>> image_folder_dataset = image_folder_dataset.map(operations=convert_op, ... input_columns=["image"]) >>> # Convert RGB images to BGR images >>> convert_op = vision.ConvertColor(vision.ConvertMode.COLOR_RGB2BGR) >>> image_folder_dataset = image_folder_dataset.map(operations=convert_op, ... input_columns=["image"])
- Tutorial Examples: