Reputation: 5434
I like fast, compact code so I have a question about this:
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
Do I need to add a conditional statement before the call to cv2.resize
for the case where new_img_width
and new_img_height
are the same as in input_image
or this conditional statement already in the cv2.resize
code?
I don't want spend cycles resizing the image unless it's necessary.
Upvotes: 5
Views: 1794
Reputation: 3775
From the source code of resize function, line 4082:
if (dsize == ssize)
{
// Source and destination are of same size. Use simple copy.
src.copyTo(dst);
return;
}
Upvotes: 9