【问题标题】:What does cv2.resize() do if input width and height same as resize input and width?如果输入宽度和高度与调整输入和宽度的大小相同,cv2.resize() 会做什么?
【发布时间】:2019-01-18 08:30:52
【问题描述】:

我喜欢快速、紧凑的代码,所以我对此有疑问:

def loader(input_path, new_img_width, new_img_height):
    input_image = tifffile.imread(input_path)
    input_image = cv2.resize(input_image, (new_img_width, new_img_height),
                           interpolation=cv2.INTER_NEAREST)
    return input_image

如果new_img_widthnew_img_heightinput_image 中的相同或cv2.resize 代码中已经存在此条件语句,我是否需要在调用cv2.resize 之前添加条件语句?

除非必要,否则我不希望花费周期调整图像大小。

【问题讨论】:

    标签: python opencv


    【解决方案1】:

    来自source code of resize function,第 4082 行:

    if (dsize == ssize)
    {
        // Source and destination are of same size. Use simple copy.
        src.copyTo(dst);
        return;
    }
    

    【讨论】:

    • 所以如果我不想要不必要的副本,最好有一个保护声明。
    • 是的,好像 resize 函数总是返回一个新的 Mat 对象。
    猜你喜欢
    • 1970-01-01
    • 2020-08-04
    • 2019-04-12
    • 1970-01-01
    • 1970-01-01
    • 2017-12-08
    • 1970-01-01
    • 2013-08-23
    • 1970-01-01
    相关资源
    最近更新 更多