mindspore.dataset.vision.RgbToHsv

class mindspore.dataset.vision.RgbToHsv(is_hwc=False)[source]

Convert the input numpy.ndarray images from RGB to HSV.

Parameters

is_hwc (bool) – If True, means the input image is in shape of <H, W, C> or <N, H, W, C>. Otherwise, it is in shape of <C, H, W> or <N, C, H, W>. Default: False.

Raises

TypeError – If is_hwc is not of type bool.

Supported Platforms:

CPU

Examples

>>> import numpy as np
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>> from mindspore.dataset.transforms import Compose
>>>
>>> # Use the transform in dataset pipeline mode
>>> transforms_list = Compose([vision.CenterCrop(20),
...                            vision.ToTensor(),
...                            vision.RgbToHsv()])
>>> # apply the transform to dataset through map function
>>> data = np.random.randint(0, 255, size=(1, 100, 100, 3)).astype(np.uint8)
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data, ["image"])
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms_list, input_columns="image")
>>> for item in numpy_slices_dataset.create_dict_iterator(num_epochs=1, output_numpy=True):
...     print(item["image"].shape, item["image"].dtype)
...     break
(3, 20, 20) float64
>>>
>>> # Use the transform in eager mode
>>> data = np.random.randint(0, 255, size=(100, 100, 3)).astype(np.uint8)
>>> output = vision.RgbToHsv(is_hwc=True)(data)
>>> print(output.shape, output.dtype)
(100, 100, 3) float64
Tutorial Examples: