If I have an image called inImg
and an image named outImg
how can I resize outImg
so that it is 75% the size of inImg
?
Again, the width of the new image will be 150 pixels. The height is then calculated by multiplying the old height by our ratio and converting it to an integer. By performing this operation, we preserve the image's original aspect ratio. The actual resizing of the image takes place on Line 23.
resize() Function. To resize images with OpenCV, use the cv2. resize() function. It takes the original image, modifies it, and returns a new image.
Introduction to OpenCV scale image Open CV scale image is a Function present in the open CV library, which enables the images entered by the user to be upscaled in terms of the dimension and size of the original image provided.
If you want 75% along each axis, you should be able to use cv::resize to do:
cv::resize(inImg, outImg, cv::Size(), 0.75, 0.75);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With