如果输入宽度和高度与调整输入和宽度的大小相同, cv2.resize() 会做什么?

Kev*_*ude 3 python opencv

我喜欢快速、紧凑的代码,所以我有一个问题:

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
Run Code Online (Sandbox Code Playgroud)

我是否需要在调用之前添加条件语句cv2.resize,以处理其中new_img_widthnew_img_height相同的情况input_imagecv2.resize代码中已经存在的条件语句?

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

unl*_*lut 5

来自resize function源代码,第 3961 行:

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