scipy.ndimage与scipy.misc.imresize的替代方案

问题:

module 'scipy.ndimage' has no attribute 'imread'
module 'scipy.misc' has no attribute 'imresize'
由于我使用的scipy是1.6.2版本的,出现了这两个问题,在此整理问题

两函数功能:

scipy.ndimage.imread:读取图像文件作为数组
scipy.misc.imresize:调整图像大小

替代方案:

  1. 网友的方案
  2. imageio + Image.fromarray
    效果与原函数一致
import numpy as np
import imageio
from PIL import Image
image = np.array(imageio.imread(file_path_and_name))
my_image = np.array(Image.fromarray(image).resize((x,y))).reshape((x*y*3, 1))
  1. imageio + skimage.transform
    需要注意的是,skimage.transform返回值是归一化的,数值范围在[0,1]
import imageio
import skimage.transform as sktrans
image = np.array(imageio.imread(file_path_and_name))
my_image = sktrans.resize(image, output_shape=(x,y,3)))
  1. 其他方案以后补充

你可能感兴趣的:(scipy.ndimage与scipy.misc.imresize的替代方案)