Ask Your Question
0

how can i scale an image properly?

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

stillNovice gravatar image

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

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

Comments

could you provide some example of the it with images?

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

try this:

cv::Mat newSize;
cv::resize(SmallImage,newSize,cv::Size(SmallImage.cols*2,SmallImage.rows*2));
sturkmen gravatar imagesturkmen ( 2015-05-20 02:30:31 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

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

stillNovice gravatar image

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

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

Question Tools

1 follower

Stats

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

Seen: 245 times

Last updated: May 19 '15