imageutil.py 文件源码

python
阅读 67 收藏 0 点赞 0 评论 0

项目:nuts-ml 作者: maet3608 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号