helpers_image.py 文件源码

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

项目:spoofnet-tensorflow 作者: yomna-safaa 项目源码 文件源码
def load_and_resize_image(path, height, width, mode='RGB'):
    """
    Returns an np.ndarray (height x width x channels)

    mode -- (RGB for color or L for grayscale)
    """

    image = PIL.Image.open(path)  # YY => RGB 8 bits, jpeg format, instance of Image class, not ndarray
    image = image.convert(mode)
    image = np.array(image)  # YY => ndarray, uint8 values bet 0 and 255, shape 240x320x3 (h x w x ch)
    if height > 0 and width > 0:
        image = scipy.misc.imresize(image, (height, width),
                                    'bilinear')  # YY => ndarray, uint8 values bet 0 and 255, shape (h2 x w2 x ch)

    return image
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号