Ask Your Question
-1

Resize while Keeping Ratio

asked 2019-03-04 05:13:23 -0600

cjacquel gravatar image

Hello,

How to do a resize with Opencv while keeping the aspect ratio ?

Is it automatically integrated ?

Thank you, Christophe

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2019-03-04 08:54:25 -0600

Yashas gravatar image

The aspect ratio is preserved when both width and height are scaled by the same factor.

To resize an image to a fixed width (similar logic for fixed height), scale both the width and height by a scale factor given by:

double scale = float(width)/input.size().width;

cv::resize(inputArray, outputArray, cv::Size(0, 0), scale, scale);

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-03-04 05:13:23 -0600

Seen: 12,861 times

Last updated: Mar 04 '19