def enhance(image, func, *args, **kwargs):
"""
Enhance image using a PIL enhance function
See the following link for details on PIL enhance functions:
http://pillow.readthedocs.io/en/3.1.x/reference/ImageEnhance.html
>>> from PIL.ImageEnhance import Brightness
>>> image = np.ones((3,2), dtype='uint8')
>>> enhance(image, Brightness, 0.0)
array([[0, 0],
[0, 0],
[0, 0]], dtype=uint8)
:param numpy array image: Numpy array with range [0,255] and dtype 'uint8'.
:param function func: PIL ImageEnhance function
:param args args: Argument list passed on to enhance function.
:param kwargs kwargs: Key-word arguments passed on to enhance function
:return: Enhanced image
:rtype: numpy array with range [0,255] and dtype 'uint8'
"""
image = arr_to_pil(image)
image = func(image).enhance(*args, **kwargs)
return pil_to_arr(image)
评论列表
文章目录