mindspore.dataset.vision.HsvToRgb
- class mindspore.dataset.vision.HsvToRgb(is_hwc=False)[源代码]
将输入的HSV格式numpy.ndarray图像转换为RGB格式。
- 参数:
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.HsvToRgb()]) >>> # 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.array([[0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]], dtype=np.uint8).reshape((2, 2, 3)) >>> output = vision.HsvToRgb(is_hwc=True)(data) >>> print(output.shape, output.dtype) (2, 2, 3) float64
- 教程样例: