def change_contrast(image, contrast=1.0):
"""
Change contrast of image.
>>> image = np.eye(3, dtype='uint8') * 255
>>> change_contrast(image, 0.5)
array([[170, 42, 42],
[ 42, 170, 42],
[ 42, 42, 170]], dtype=uint8)
See
http://pillow.readthedocs.io/en/3.1.x/reference/ImageEnhance.html#PIL.ImageEnhance.Contrast
:param numpy array image: Numpy array with range [0,255] and dtype 'uint8'.
:param float contrast: Contrast [0, 1]
:return: Image with changed contrast
:rtype: numpy array with range [0,255] and dtype 'uint8'
"""
return enhance(image, ie.Contrast, contrast)
评论列表
文章目录