有没有更好的方法来调整numpy数组形式的图像的大小?

有没有更好的方法来调整numpy数组形式的图像的大小?,numpy,tensorflow,image-preprocessing,Numpy,Tensorflow,Image Preprocessing,我是神经网络新手,一直在练习图像预处理。我正在尝试调整numpy数组形式的图像大小,这是我当前的方法: # using tensorflow, resize the image im = tf.image.resize(img_as_array, [299, 299]) # then use .eval() which returns a numpy array in the size I want im_arr = im.eval(session=tf.compat.v1.Session()

我是神经网络新手,一直在练习图像预处理。我正在尝试调整numpy数组形式的图像大小,这是我当前的方法:

# using tensorflow, resize the image
im = tf.image.resize(img_as_array, [299, 299])

# then use .eval() which returns a numpy array in the size I want
im_arr = im.eval(session=tf.compat.v1.Session())

有更好的方法吗?

为了避免必须在
tf.tensor
np.ndarray
tensor数据类型之间进行转换,您可以使用
skimage
(scikit image)使用以下代码段直接在
np.ndarray
对象上调整图像大小:

import skimage.transform

kwargs = dict(output_shape=self._size, mode='edge', order=1, preserve_range=True)
im = skimage.transform.resize(im, **kwargs).astype(im.dtype)
要安装
skimage
,请按照此处的安装说明进行操作:。希望这有帮助