mindspore.dataset.vision.py_transforms.RandomColorAdjust

class mindspore.dataset.vision.py_transforms.RandomColorAdjust(brightness=(1, 1), contrast=(1, 1), saturation=(1, 1), hue=(0, 0))[source]

Randomly adjust the brightness, contrast, saturation, and hue of the input PIL Image.

Parameters
  • brightness (Union[float, Sequence[float, float]], optional) – Range of brightness adjustment factor to select from, must be non negative. If float is provided, the factor will be uniformly selected from [max(0, 1 - brightness), 1 + brightness). If Sequence[float, float] is provided, it should be arranged in order of (min, max). Default: (1, 1).

  • contrast (Union[float, Sequence[float, float]], optional) – Range of contrast adjustment factor to select from, must be non negative. If float is provided, the factor will be uniformly selected from [max(0, 1 - contrast), 1 + contrast). If Sequence[float, float] is provided, it should be arranged in order of (min, max). Default: (1, 1).

  • saturation (Union[float, Sequence[float, float]], optional) – Range of saturation adjustment factor to select from, must be non negative. If float is provided, the factor will be uniformly selected from [max(0, 1 - saturation), 1 + saturation). If Sequence[float, float] is provided, it should be arranged in order of (min, max). Default: (1, 1).

  • hue (Union[float, Sequence[float, float]], optional) – Range of hue adjustment factor to select from. If float is provided, it must be in range of [0, 0.5], and the factor will be uniformly selected from [-hue, hue). If Sequence[float, float] is provided, the elements must be in range of [-0.5, 0.5] and arranged in order of (min, max). Default: (0, 0).

Raises
  • TypeError – If brightness is not of type float or Sequence[float, float].

  • TypeError – If contrast is not of type float or Sequence[float, float].

  • TypeError – If saturation is not of type float or Sequence[float, float].

  • TypeError – If hue is not of type float or Sequence[float, float].

  • ValueError – If brightness is negative.

  • ValueError – If contrast is negative.

  • ValueError – If saturation is negative.

  • ValueError – If hue is not in range of [-0.5, 0.5].

Supported Platforms:

CPU

Examples

>>> from mindspore.dataset.transforms.py_transforms import Compose
>>>
>>> transforms_list = Compose([py_vision.Decode(),
...                            py_vision.RandomColorAdjust(0.4, 0.4, 0.4, 0.1),
...                            py_vision.ToTensor()])
>>> # apply the transform to dataset through map function
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns="image")