【问题标题】:imresize error using OpenCV 2.4.10 and Python 2.7.10使用 OpenCV 2.4.10 和 Python 2.7.10 的 imresize 错误
【发布时间】:2015-10-12 10:36:39
【问题描述】:

我正在尝试使用 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)'

有什么线索吗?

【问题讨论】:

    标签: python opencv image-processing


    【解决方案1】:

    dst.size() 需要使用 2D 尺寸而不是 3D:

    resized_patch = cv2.resize(patch, (3, 50, 50), dst=dst, fx=0, fy=0, interpolation=cv2.INTER_AREA)
                                          ^^^ #here 
    

    【讨论】:

    【解决方案2】:

    请使用这个“resize”而不是“cv2.resize”;

    from skimage.transform import resize
    

    【讨论】:

    • 这应该是一条评论。
    猜你喜欢
    • 2015-04-04
    • 2016-01-22
    • 2016-01-06
    • 2015-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-03
    • 2015-08-17
    相关资源
    最近更新 更多