Ask Your Question

How to change aspect ratio?

asked 2013-11-19 05:09:53 -0600

anon321 gravatar image

I need to change the aspect ratio of a video frame without changing the size of the image which is 640x480. For example I would like to to squeeze the 640x480 image so that the excess space becomes black but the size of the actual image is still 640x480. Is this possible?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-11-19 05:32:38 -0600

Michael Burdinov gravatar image

Here is simple example of squeezing the image in y direction by factor 2:

Mat squeezedImg(Size(640,480), CV_8U, Scalar(0));
Rect squeezedRect(0, 120, 640, 240);
resize(inputImg, squeezedImg(squeezedRect), Size(640,240));
edit flag offensive delete link more


Thank you!

anon321 gravatar imageanon321 ( 2013-11-19 05:36:50 -0600 )edit

You are welcome

Michael Burdinov gravatar imageMichael Burdinov ( 2013-11-19 07:10:14 -0600 )edit

Question Tools


Asked: 2013-11-19 05:09:53 -0600

Seen: 3,420 times

Last updated: Nov 19 '13