Closed vvvin333 closed 3 years ago
Ok, just had the same problem and I think I figured it out:
The imutils.resize
function is not really intended to take a width and a height argument simultaneously because the method preserves the aspect ratio. The idea is to specify one dimension as target and the other will be calculated. The documentation and the implementation make that very clear.
So if you want exact width and height dimensions you don't really need this function and you can call the cv2.resize
function directly.
If you want to preserve the aspect ratio though, just don't specify the dimension that you allow to change.
Also have a look at this pr
I hope this helps
Thnx for reference to implementation.
When I resize jpg-files to (2000,2000,3) from (3932,3933,3) with imutils.resize(x,2000,2000) I have got this image with (1999,2000,3) shape! But with cv2.resize(x, (2000,2000)) I have no such a problem.