mindspore.dataset.vision.RandomColor

View Source On Gitee
class mindspore.dataset.vision.RandomColor(degrees=(0.1, 1.9))[source]

Adjust the color of the input image by a fixed or random degree. This operation works only with 3-channel color images.

Parameters

degrees (Sequence[float], optional) – Range of random color adjustment degrees, which must be non-negative. It should be in (min, max) format. If min=max, then it is a single fixed magnitude operation. Default: (0.1, 1.9).

Raises
Supported Platforms:

CPU

Examples

>>> import numpy as np
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>>
>>> # Use the transform in dataset pipeline mode
>>> data = np.random.randint(0, 255, size=(1, 100, 100, 3)).astype(np.uint8)
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data, ["image"])
>>> transforms_list = [vision.RandomColor((0.5, 2.0))]
>>> 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
(100, 100, 3) uint8
>>>
>>> # Use the transform in eager mode
>>> data = np.random.randint(0, 255, size=(100, 100, 3)).astype(np.uint8)
>>> output = vision.RandomColor((0.1, 1.9))(data)
>>> print(output.shape, output.dtype)
(100, 100, 3) uint8
Tutorial Examples: