testMain.py 文件源码

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

项目:DQN 作者: Ivehui 项目源码 文件源码
def transfer(rgbImage, new_dims):
    im = np.dot(rgbImage[..., :3],
                [0.229, 0.587, 0.144])

    im_min, im_max = im.min(), im.max()
    if im_max > im_min:
        # skimage is fast but only understands {1,3} channel images
        # in [0, 1].
        im_std = (im - im_min) / (im_max - im_min)
        resized_std = resize(im_std, new_dims, order=1)
        resized_im = resized_std * (im_max - im_min) + im_min
    else:
        # the image is a constant -- avoid divide by 0
        ret = np.empty((new_dims[0], new_dims[1], im.shape[-1]),
                       dtype=np.float32)
        ret.fill(im_min)
        return ret
    return resized_im.astype(np.float32)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号