Ask Your Question
1

How to change aspect ratio?

asked Nov 19 '13

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?

Preview: (hide)

1 answer

Sort by » oldest newest most voted
3

answered Nov 19 '13

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));
Preview: (hide)

Comments

Thank you!

anon321 gravatar imageanon321 (Nov 19 '13)edit

You are welcome

Michael Burdinov gravatar imageMichael Burdinov (Nov 19 '13)edit

Question Tools

Stats

Asked: Nov 19 '13

Seen: 3,836 times

Last updated: Nov 19 '13