Python 如果输入的宽度和高度与调整输入和宽度的大小相同,cv2.resize()会做什么?
我喜欢快速紧凑的代码,所以我有一个问题:Python 如果输入的宽度和高度与调整输入和宽度的大小相同,cv2.resize()会做什么?,python,opencv,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_NE
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\u img\u width
和new\u img\u height
与input\u image
中的条件语句相同,或者该条件语句已经在cv2.resize
代码中,是否需要在调用cv2.resize
之前添加条件语句
除非有必要,否则我不想调整图像的大小。第3961行:
if (dsize == ssize)
{
// Source and destination are of same size. Use simple copy.
src.copyTo(dst);
return;
}
所以,如果我不想要不必要的副本,我最好有一个保护语句。是的,似乎resize函数总是返回一个新的Mat对象。