preprocessing.py 文件源码

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

项目:deepjets 作者: deepjets 项目源码 文件源码
def zoom_image_fixed_size(image, zoom):
    """Return rescaled and cropped image array.
    """
    if zoom < 1:
        raise ValueError("Zoom scale factor must be at least 1.")
    elif zoom == 1:
        # copy
        return np.array(image)

    width, height = image.shape
    t_width = int(np.ceil(zoom*width))
    t_height = int(np.ceil(zoom*height))
    if t_width//2 != width//2:
        t_width -= 1
    if t_height//2 != height//2:
        t_height -= 1
    t_image = transform.resize(image, (t_width, t_height), order=3)
    return t_image[(t_width-width)/2:(t_width+width)/2,
                   (t_height-height)/2:(t_height+height)/2]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号