Adjust contrast of an Image. Args: img (PIL Image): PIL 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 b
(img, contrast_factor)
| 210 | |
| 211 | |
| 212 | def adjust_contrast(img, contrast_factor): |
| 213 | """Adjust contrast of an Image. |
| 214 | |
| 215 | Args: |
| 216 | img (PIL Image): PIL Image to be adjusted. |
| 217 | contrast_factor (float): How much to adjust the contrast. Can be any |
| 218 | non negative number. 0 gives a solid gray image, 1 gives the |
| 219 | original image while 2 increases the contrast by a factor of 2. |
| 220 | |
| 221 | Returns: |
| 222 | PIL Image: Contrast adjusted image. |
| 223 | """ |
| 224 | if not _is_pil_image(img): |
| 225 | raise TypeError('img should be PIL Image. Got {}'.format(type(img))) |
| 226 | |
| 227 | enhancer = ImageEnhance.Contrast(img) |
| 228 | img = enhancer.enhance(contrast_factor) |
| 229 | return img |
| 230 | |
| 231 | |
| 232 | def adjust_saturation(img, saturation_factor): |
no test coverage detected