adjust_contrast

paddle.vision.transforms. adjust_contrast ( img, contrast_factor ) [source]

Adjusts contrast of an Image.

Parameters
  • img (PIL.Image|np.array|paddle.Tensor) – Image to be adjusted.

  • contrast_factor (float) – How much to adjust the contrast. Can be any non negative number. 0 gives a solid gray image, 1 gives the original image while 2 increases the contrast by a factor of 2.

Returns

Contrast adjusted image.

Return type

PIL.Image|np.array|paddle.Tensor

Examples

>>> import numpy as np
>>> from PIL import Image
>>> from paddle.vision.transforms import functional as F
>>> fake_img = (np.random.rand(256, 300, 3) * 255.).astype('uint8')
>>> fake_img = Image.fromarray(fake_img)
>>> converted_img = F.adjust_contrast(fake_img, 0.4)
>>> print(converted_img.size)
(300, 256)