how can i scale an image properly?

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

stillNovice gravatar image

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

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

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

works great.

stillNovice gravatar imagestillNovice ( 2015-05-20 02:49:10 -0500 )edit