使用 OpenCV 2.4.10 和 Python 2.7.10 的 imresize 错误
imresize error using OpenCV 2.4.10 and Python 2.7.10
我正在尝试使用 OpenCV 2.4.10 和 Python 2.7.10 调整图像大小。
这个有效:
resized_patch = cv2.resize(patch, (3, 50, 50))
不过,我对使用 INTER_AREA 插值很感兴趣。在 documentation for 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)
但是,我从 cv2.resize 行得到的错误是:
TypeError: 'function takes exactly 2 arguments (3 given)'
有什么线索吗?
您需要为 dst.size()
使用 2D 尺寸而不是 3D :
resized_patch = cv2.resize(patch, (3, 50, 50), dst=dst, fx=0, fy=0, interpolation=cv2.INTER_AREA)
^^^ #here
请使用此“调整大小”而不是“cv2.resize”;
from skimage.transform import resize
我正在尝试使用 OpenCV 2.4.10 和 Python 2.7.10 调整图像大小。
这个有效:
resized_patch = cv2.resize(patch, (3, 50, 50))
不过,我对使用 INTER_AREA 插值很感兴趣。在 documentation for 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)
但是,我从 cv2.resize 行得到的错误是:
TypeError: 'function takes exactly 2 arguments (3 given)'
有什么线索吗?
您需要为 dst.size()
使用 2D 尺寸而不是 3D :
resized_patch = cv2.resize(patch, (3, 50, 50), dst=dst, fx=0, fy=0, interpolation=cv2.INTER_AREA)
^^^ #here
请使用此“调整大小”而不是“cv2.resize”;
from skimage.transform import resize