我正在尝试使用OpenCV 2.4.10和Python 2.7.10调整图像的大小。
这有效:
resized_patch = cv2.resize(patch, (3, 50, 50))
Run Code Online (Sandbox Code Playgroud)
但是,我对使用INTER_AREA插值感兴趣。按照Python的文档,我尝试了:
dst = numpy.zeros((3, 50, 50))
resized_patch = cv2.resize(patch, (3, 50, 50), dst=dst, fx=0, fy=0, interpolation=cv2.INTER_AREA)
Run Code Online (Sandbox Code Playgroud)
但是,我从cv2.resize行中得到的错误是:
TypeError: 'function takes exactly 2 arguments (3 given)'
Run Code Online (Sandbox Code Playgroud)
有什么线索吗?
我想使用Python 2.7调整RGB图像的大小。我尝试使用cv2.resize函数,但是它总是返回单个通道图像:
(Pdb) x = cv2.imread('image.jpg')
(Pdb) x.shape
(50, 50, 3)
(Pdb) x = cv2.resize(x, (40, 40))
(Pdb) x.shape
(40, 40)
Run Code Online (Sandbox Code Playgroud)
我希望x.shape的最终输出为(40,40,3)。
除了遍历三个通道并分别调整每个通道的大小之外,还有其他更Python化的方法来调整RGB图像的大小吗?