mindspore.dataset.vision.HsvToRgb
- class mindspore.dataset.vision.HsvToRgb(is_hwc=False)[source]
Convert the input numpy.ndarray images from HSV to RGB.
- 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.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
- Tutorial Examples: