getImgs.py 文件源码

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

项目:crawl-dataset 作者: e-lab 项目源码 文件源码
def resizeImg(imgPath,img_size):
    try:
        img = imread(imgPath)
        h, w, _ = img.shape
        scale = 1
        if w >= h:
            new_w = img_size
            if w  >= new_w:
                scale = float(new_w) / w
            new_h = int(h * scale)
        else:
            new_h = img_size
            if h >= new_h:
                scale = float(new_h) / h
            new_w = int(w * scale)
        new_img = imresize(img, (new_h, new_w), interp='bilinear')
        imsave(imgPath,new_img)
        print('Img Resized as {}'.format(img_size))
    except Exception as e:
        print(e)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号