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, tuple], optional) – Brightness adjustment factor, which must be non negative (default=(1, 1)). If brightness is a float, the factor is uniformly chosen in range of [max(0, 1-brightness), 1+brightness]. If brightness is a sequence of length 2, it should be in shape of [min, max].

  • contrast (Union[float, tuple], optional) – Contrast adjustment factor, which must be non negative (default=(1, 1)). If contrast is a float, the factor is uniformly chosen in range of [max(0, 1-contrast), 1+contrast]. If contrast is a sequence of length 2, it should be in shape of [min, max].

  • saturation (Union[float, tuple], optional) – Saturation adjustment factor, which must be non negative(default=(1, 1)). If saturation is a float, the factor is uniformly chosen in range of [max(0, 1-saturation), 1+saturation]. If saturation is a sequence of length 2, it should be in shape of [min, max].

  • hue (Union[float, tuple], optional) – Hue adjustment factor (default=(0, 0)). If hue is a float, the range will be [-hue, hue], where 0 <= hue <= 0.5. If hue is a sequence of length 2, it should be in shape of [min, max], where -0.5 <= min <= max <= 0.5.

Raises
  • TypeError – If brightness is not of type float or sequence of float.

  • TypeError – If contrast is not of type float or sequence of float.

  • TypeError – If saturation is not of type float or sequence of float.

  • TypeError – If hue is not of type float or sequence of float.

  • ValueError – If brightness is negative.

  • ValueError – If contrast is negative.

  • ValueError – If saturation is negative.

  • ValueError – If hue is not in range [-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")