resize.py 文件源码

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

项目:chainercv 作者: chainer 项目源码 文件源码
def _resize(img, size, interpolation):
        img = img.transpose((1, 2, 0))
        if interpolation == PIL.Image.NEAREST:
            cv_interpolation = cv2.INTER_NEAREST
        elif interpolation == PIL.Image.BILINEAR:
            cv_interpolation = cv2.INTER_LINEAR
        elif interpolation == PIL.Image.BICUBIC:
            cv_interpolation = cv2.INTER_CUBIC
        elif interpolation == PIL.Image.LANCZOS:
            cv_interpolation = cv2.INTER_LANCZOS4
        H, W = size
        img = cv2.resize(img, dsize=(W, H), interpolation=cv_interpolation)

        # If input is a grayscale image, cv2 returns a two-dimentional array.
        if len(img.shape) == 2:
            img = img[:, :, np.newaxis]
        return img.transpose((2, 0, 1))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号