码迷,mamicode.com
首页 > 其他好文 > 详细

OpenCV入门 - 调整图片尺寸

时间:2015-05-12 17:11:43      阅读:743      评论:0      收藏:0      [点我收藏+]

标签:resize   cvsize   

OpenCV入门 - 调整图片尺寸(image resize)


   通过Mat::size()方法得到关于图像大小的Size实例,通过resize方法调整图像大小。代码如下:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/nonfree/features2d.hpp> //
#include <opencv2/imgproc/imgproc.hpp> // resize()


#include <iostream>
using namespace cv;
using namespace std;


int main(int argc, const char *argv[]){
    Mat big = imread("imgs/linux.jpg",-1);//CV_LOAD_IMAGE_ANYDEPTH);// the big pic
    Mat dst = imread("imgs/200X200.jpg", -1);


    cout << "Mat info:" << endl;
    cout << "Original pic," << big.rows << " : "<< big.cols << endl;
    cout << "dst pic, " << dst.rows << " : "<< dst.cols << endl;
    
    Size s = big.size();
    cout << "Pic Size info:" << endl;
    cout << "Original pic," << s.width << " : "<< s.height << endl;
    s = dst.size();
    cout << "dst  pic," << s.width << " : "<< s.height << endl;
    // resize big to dst 
    cv::resize(big, dst, dst.size());






    // show it on an image
    imshow("big", big);
    imshow("test", dst);
    waitKey(0);


    return 0;
}





效果:
技术分享















参考:
1.cv::resize()
http://docs.opencv.org/2.4.10/modules/imgproc/doc/geometric_transformations.html#resize
2.cv::Size
http://docs.opencv.org/modules/core/doc/basic_structures.html#mat-size



OpenCV入门 - 调整图片尺寸

标签:resize   cvsize   

原文地址:http://blog.csdn.net/vonzhoufz/article/details/45671249

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!