Hi. I'm can't resize the size of images I saved in text file to a particular size. [closed]

asked 2016-01-02 13:57:01 -0600

Maarran gravatar image

updated 2016-01-02 13:59:27 -0600

theodore gravatar image
for (unsigned int i = 0; i < testImages.size(); i++)
    {
        Mat img_2;
        img_2 = testImages[i];
        Size size(50,50);//the dst image size,e.g.100x100
        Mat dst;//dst image
        resize(img_2,dst,size);//resize image
 }
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by theodore
close date 2016-01-02 19:08:30.757986

Comments

try cv::resize(img, dst, cv::Size(), 2, 2); 2 is the scale factor in x and y you can choose whatever you want instead

theodore gravatar imagetheodore ( 2016-01-02 14:06:47 -0600 )edit

Just tried. but the output is still the same. Same as the original size.

Maarran gravatar imageMaarran ( 2016-01-02 14:14:47 -0600 )edit

then your problem is somewhere else. Try to go step by step. First load one image, and try to see if it works.

Mat img = imread("img.png");
Mat dst;
resize(img, dst, cv::Size(), 2, 2);
imshow("src", dst);
waitKey();

The above code should do the trick, and it should work for you as well.

theodore gravatar imagetheodore ( 2016-01-02 15:07:41 -0600 )edit

Got it. Managed to fix it. Thanks man..

Maarran gravatar imageMaarran ( 2016-01-02 15:49:31 -0600 )edit