util.py 文件源码

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

项目:ISeeNN 作者: sunshaoyan 项目源码 文件源码
def load_image(path, height=None, width=None):
    img = skimage.io.imread(path)
    if len(img.shape) == 2:
        img = skimage.color.gray2rgb(img)
    img = img / 255.0
    if height is not None and width is not None:
        ny = height
        nx = width
    elif height is not None:
        ny = height
        nx = img.shape[1] * ny / img.shape[0]
    elif width is not None:
        nx = width
        ny = img.shape[0] * nx / img.shape[1]
    else:
        ny = img.shape[0]
        nx = img.shape[1]
    return skimage.transform.resize(img, (ny, nx))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号