Attention! This forum will be made read-only by Dec-20. Please migrate to Most of existing active users should've received invitation by e-mail.
Ask Your Question

how can i scale an image properly?

asked 2015-05-19 12:10:49 -0500

stillNovice gravatar image

updated 2020-10-11 14:26:59 -0500

I have a 640 x 480 camera feed that i am trying to stretch up to 1280 x 960.

I want double the pixels, so that a 4 x 4 blob of colour becomes 8 x 8, etc.

Using this code:

        cv::Size sizeUp(1280, 1024);
        cv::Mat newSize(cv::Size(sizeUp), CV_8UC1);
        cv::resize(SmallImage,newSize, sizeUp);

just puts the small image in the top left corner of the new Mat, and leaves the rest blank.

Am I going about this the wrong way?

edit retag flag offensive close merge delete


could you provide some example of the it with images?

theodore gravatar imagetheodore ( 2015-05-19 18:48:37 -0500 )edit

try this:

cv::Mat newSize;
sturkmen gravatar imagesturkmen ( 2015-05-20 02:30:31 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-05-20 02:49:10 -0500

stillNovice gravatar image

updated 2015-05-20 02:49:23 -0500

thanks guys, i just found it. I was missing the interpolation mode.

cv::resize(smalImage, newSize, sizeUp, 2, 2, INTER_CUBIC);

works great.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-05-19 12:10:49 -0500

Seen: 84 times

Last updated: May 19 '15