Alternative to scipy.misc.imresize()

前端 未结 5 1804
一个人的身影
一个人的身影 2021-01-01 17:44

I want to use an old script which still uses scipy.misc.imresize() which is not only deprevated but removed entirely from scipy. Instead the devs recommend to u

5条回答
  •  清歌不尽
    2021-01-01 17:51

    You can lookup the documentation and the source code of the deprecated function. In short, using Pillow (Image.resize) you can do:

    im = Image.fromarray(old_image)
    size = tuple((np.array(im.size) * 0.99999).astype(int))
    new_image = np.array(im.resize(size, PIL.Image.BICUBIC))
    

    With skimage (skimage.transform.resize) you should get the same with:

    size = (np.array(old_image.size) * 0.99999).astype(int)
    new_image  = skimage.transform.resize(old_image, size, order=3)
    

提交回复
热议问题