Python 不推荐使用的scipy imresize()函数的替代方案?

Python 不推荐使用的scipy imresize()函数的替代方案?,python,image,resize,Python,Image,Resize,我曾经使用scipy resize函数来缩小图像的比例。但由于最新版本的scipy中不推荐使用此函数,因此我正在寻找替代方法。PIL似乎很有前途,但我如何将其用于3d图像?(600800,3)至(300400,3) 我研究了numpy.resize、skimage,但特别是skimage,我不确定它是否与scipy的imresize()完全一样。是使用OpenCV调整彩色图像大小的一种方法 import numpy as np import cv2 image = cv2.imread('im

我曾经使用scipy resize函数来缩小图像的比例。但由于最新版本的scipy中不推荐使用此函数,因此我正在寻找替代方法。PIL似乎很有前途,但我如何将其用于3d图像?(600800,3)至(300400,3)

我研究了numpy.resize、skimage,但特别是skimage,我不确定它是否与scipy的imresize()完全一样。

是使用OpenCV调整彩色图像大小的一种方法

import numpy as np
import cv2

image = cv2.imread('image.png')
cv2.imshow("Original", image)
"""
The ratio is r. The new image will
have a height of 50 pixels. To determine the ratio of the new
height to the old height, we divide 50 by the old height.
"""
r = 50.0 / image.shape[0]
dim = (int(image.shape[1] * r), 50)

resized = cv2.resize(image, dim, interpolation = cv2.INTER_AREA)
cv2.imshow("Resized (Height) ", resized)
cv2.waitKey(0)
如中所述,您可以改用
numpy.array(Image.fromarray(arr.resize())

另外,在
scipy.misc
模块中还有许多其他不推荐使用的图像函数。你可以检查一下。如果网站发生变化,我也会引用它们:


你试过openCV吗?嗨,阿文,我以为cv2的大小调整只需要2d数组?我查看了cv2(openCV),发现:导入cv2内容\u image=scipy.misc.imread(“images/louvre.jpg”)内容\u image=cv2。调整大小(内容\u image,无,fx=0.5,fy=0.5)效果很好!参数是否相同?我假设
def imresize(arr,*args,**kwargs):返回numpy.array(Image.fromarray(arr).resize(*args,**kwargs))
将作为替代品使用?我正在尝试让代码在我不完全理解的1.2上运行。
Deprecated functions:
bytescale(*args, **kwds)  bytescale is deprecated! bytescale is deprecated in SciPy 1.0.0, and will be removed in 1.2.0.
fromimage(*args, **kwds)  fromimage is deprecated! fromimage is deprecated in SciPy 1.0.0.
imfilter(*args, **kwds)   imfilter is deprecated! imfilter is deprecated in SciPy 1.0.0, and will be removed in 1.2.0.
imread(*args, **kwds)     imread is deprecated! imread is deprecated in SciPy 1.0.0, and will be removed in 1.2.0.
imresize(*args, **kwds)   imresize is deprecated! imresize is deprecated in SciPy 1.0.0, and will be removed in 1.3.0.
imrotate(*args, **kwds)   imrotate is deprecated! imrotate is deprecated in SciPy 1.0.0, and will be removed in 1.2.0.
imsave(*args, **kwds)     imsave is deprecated! imsave is deprecated in SciPy 1.0.0, and will be removed in 1.2.0.
imshow(*args, **kwds)     imshow is deprecated! imshow is deprecated in SciPy 1.0.0, and will be removed in 1.2.0.
toimage(*args, **kwds)    toimage is deprecated! toimage is deprecated in SciPy 1.0.0, and will be removed in 1.2.0.