First time here? Check out the FAQ!

Ask Your Question
0

how can i scale an image properly?

asked May 19 '15

stillNovice gravatar image

updated Oct 11 '0

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?

Preview: (hide)

Comments

could you provide some example of the it with images?

theodore gravatar imagetheodore (May 20 '15)edit
1

try this:

cv::Mat newSize;
cv::resize(SmallImage,newSize,cv::Size(SmallImage.cols*2,SmallImage.rows*2));
sturkmen gravatar imagesturkmen (May 20 '15)edit

1 answer

Sort by » oldest newest most voted
1

answered May 20 '15

stillNovice gravatar image

updated May 20 '15

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

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

works great.

Preview: (hide)

Question Tools

1 follower

Stats

Asked: May 19 '15

Seen: 259 times

Last updated: May 19 '15