MCPcopy Create free account
hub / github.com/NVIDIA/semantic-segmentation / adjust_brightness

Function adjust_brightness

transforms/transforms.py:192–209  ·  view source on GitHub ↗

Adjust brightness of an Image. Args: img (PIL Image): PIL Image to be adjusted. brightness_factor (float): How much to adjust the brightness. Can be any non negative number. 0 gives a black image, 1 gives the original image while 2 increases the brightne

(img, brightness_factor)

Source from the content-addressed store, hash-verified

190
191
192def adjust_brightness(img, brightness_factor):
193 """Adjust brightness of an Image.
194
195 Args:
196 img (PIL Image): PIL Image to be adjusted.
197 brightness_factor (float): How much to adjust the brightness. Can be
198 any non negative number. 0 gives a black image, 1 gives the
199 original image while 2 increases the brightness by a factor of 2.
200
201 Returns:
202 PIL Image: Brightness adjusted image.
203 """
204 if not _is_pil_image(img):
205 raise TypeError('img should be PIL Image. Got {}'.format(type(img)))
206
207 enhancer = ImageEnhance.Brightness(img)
208 img = enhancer.enhance(brightness_factor)
209 return img
210
211
212def adjust_contrast(img, contrast_factor):

Callers 1

get_paramsMethod · 0.85

Calls 1

_is_pil_imageFunction · 0.85

Tested by

no test coverage detected