mindspore.dataset.vision.RgbToHsv

查看源文件
class mindspore.dataset.vision.RgbToHsv(is_hwc=False)[源代码]

将输入的RGB格式numpy.ndarray图像转换为HSV格式。

参数:
  • is_hwc (bool) - 若为 True ,表示输入图像的shape为<H, W, C>或<N, H, W, C>;否则为<C, H, W>或<N, C, H, W>。默认值: False

异常:
  • TypeError - 当 is_hwc 的类型不为bool。

支持平台:

CPU

样例:

>>> 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
教程样例: