ColorJitter

class paddle.vision.transforms. ColorJitter ( brightness=0, contrast=0, saturation=0, hue=0, keys=None ) [source]

Randomly change the brightness, contrast, saturation and hue of an image.

Parameters
  • brightness (float, optional) – How much to jitter brightness. Chosen uniformly from [max(0, 1 - brightness), 1 + brightness]. Should be non negative numbers. Default: 0.

  • contrast (float, optional) – How much to jitter contrast. Chosen uniformly from [max(0, 1 - contrast), 1 + contrast]. Should be non negative numbers. Default: 0.

  • saturation (float, optional) – How much to jitter saturation. Chosen uniformly from [max(0, 1 - saturation), 1 + saturation]. Should be non negative numbers. Default: 0.

  • hue (float, optional) – How much to jitter hue. Chosen uniformly from [-hue, hue]. Should have 0<= hue <= 0.5. Default: 0.

  • keys (list[str]|tuple[str], optional) – Same as BaseTransform. Default: None.

Shape:
  • img(PIL.Image|np.ndarray|Paddle.Tensor): The input image with shape (H x W x C).

  • output(PIL.Image|np.ndarray|Paddle.Tensor): A color jittered image.

Returns

A callable object of ColorJitter.

Examples

>>> import numpy as np
>>> from PIL import Image
>>> from paddle.vision.transforms import ColorJitter

>>> transform = ColorJitter(0.4, 0.4, 0.4, 0.4)
>>> fake_img = Image.fromarray((np.random.rand(224, 224, 3) * 255.).astype(np.uint8))
>>> fake_img = transform(fake_img)
>>> print(fake_img.size)
(224, 224)