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 – How much to jitter brightness. Chosen uniformly from [max(0, 1 - brightness), 1 + brightness]. Should be non negative numbers.

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

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

  • hue – How much to jitter hue. Chosen uniformly from [-hue, hue]. Should have 0<= hue <= 0.5.

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

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)