相关文章推荐
小眼睛的香菇  ·  python学习笔记- ...·  9 月前    · 
安静的麻辣香锅  ·  使用 ...·  1 年前    · 
想出国的饼干  ·  VMware vSphere ...·  1 年前    · 
重感情的风衣  ·  使用Java ...·  1 年前    · 

废弃的scipy imresize()函数的替代品?

1 人关注

我曾经使用scipy的resize函数来降低图像的比例。但由于这个函数在最新版本的scipy中被废弃了,我正在寻找一个替代方案。PIL似乎很有前途,但我怎么能用它来处理3D图像?(600,800,3)到(300,400,3)

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

3 个评论
Did you try openCV?
嗨,阿文,我以为cv2调整大小只需要2d阵列?
我研究了cv2(openCV),发现: import cv2 content_image = scipy.misc.imread("images/louvre.jpg") content_image = cv2.resize(content_image, None,fx=0.5,fy=0.5) 工作正常
python
image
resize
user10229833
user10229833
发布于 2019-08-16
2 个回答
Achintha Ihalage
Achintha Ihalage
发布于 2019-09-05
已采纳
0 人赞同

Here 是用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)
    
pgmank
pgmank
发布于 2019-09-05
0 人赞同

正如在 官方文件 ,你可以用 numpy.array(Image.fromarray(arr).resize()) 代替。

P.S: scipy.misc 模块中还有许多其他的图像功能被废弃。你可以查看它们 here .我还在下面引用了他们的话,以防网站发生变化。

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.