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

Function adjust_saturation

transforms/transforms.py:232–249  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

230
231
232def 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
252def adjust_hue(img, hue_factor):

Callers 1

get_paramsMethod · 0.85

Calls 1

_is_pil_imageFunction · 0.85

Tested by

no test coverage detected