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)
| 190 | |
| 191 | |
| 192 | def 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 | |
| 212 | def adjust_contrast(img, contrast_factor): |
no test coverage detected