Adjust color saturation of an image. Args: img (PIL Image): PIL Image to be adjusted. saturation_factor (float): How much to adjust the saturation. 0 will give a black and white image, 1 will give the original image while 2 will enhance the saturation by
(img, saturation_factor)
| 230 | |
| 231 | |
| 232 | def adjust_saturation(img, saturation_factor): |
| 233 | """Adjust color saturation of an image. |
| 234 | |
| 235 | Args: |
| 236 | img (PIL Image): PIL Image to be adjusted. |
| 237 | saturation_factor (float): How much to adjust the saturation. 0 will |
| 238 | give a black and white image, 1 will give the original image while |
| 239 | 2 will enhance the saturation by a factor of 2. |
| 240 | |
| 241 | Returns: |
| 242 | PIL Image: Saturation adjusted image. |
| 243 | """ |
| 244 | if not _is_pil_image(img): |
| 245 | raise TypeError('img should be PIL Image. Got {}'.format(type(img))) |
| 246 | |
| 247 | enhancer = ImageEnhance.Color(img) |
| 248 | img = enhancer.enhance(saturation_factor) |
| 249 | return img |
| 250 | |
| 251 | |
| 252 | def adjust_hue(img, hue_factor): |
no test coverage detected