opencv2实现实现10张图像上下左右拼接融合张图像上下左右拼接融合
主要为大家详细介绍了opencv2实现10张图像上下左右拼接融合,文中示例代码介绍的非常详细,具有一定的参
考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了opencv2实现多张图像上下左右拼接融合的具体代码,供大家参考,具体内容如下
在前面的“opencv2两张图像拼接融合_基于SURF特征提取”博文中,实现了两张左右图像的拼接融合,后来我也实现了多张图
像的拼接融合。但是opencv2自带一种函数,直接就实现了图像的上下左右拼接。具体程序如下:
#include <iostream>
#include<vector>
#include <fstream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/stitching/stitcher.hpp"
using namespace std;
using namespace cv;
bool try_use_gpu = false;
vector<Mat> imgs;
string result_name = "result.jpg";
int main(int argc, char* argv[])
//int _tmain(int argc, _TCHAR* argv[])
{
// 读取图像
/*Mat img1 = imread("img1.jpg");
Mat img2 = imread("img2.jpg");
Mat img3 = imread("img3.jpg");*/
Mat image11= imread("1.jpg");
Mat image22= imread("2.jpg");
Mat image33= imread("3.jpg");
Mat image44= imread("4.jpg");
Mat image55= imread("5.jpg");
Mat image66= imread("6.jpg");
Mat image77= imread("7.jpg");
Mat image88= imread("8.jpg");
Mat image99= imread("9.jpg");
Mat image1010= imread("10.jpg");
if (!image11.data || !image22.data|| !image33.data|| !image44.data|| !image55.data
|| !image66.data|| !image77.data|| !image88.data|| !image99.data|| !image1010.data
)
return 0;
因为老师给的图像太大,先处理下。处理后的图像存放在imagei中。
Mat image1;
Mat image2;
Mat image3;
Mat image4;
Mat image5;
Mat image6;
Mat image7;
Mat image8;
Mat image9;
Mat image10;
resize(image11,image1,Size(400,300),0,0,CV_INTER_LINEAR);
resize(image22,image2,Size(400,300),0,0,CV_INTER_LINEAR);
resize(image33,image3,Size(400,300),0,0,CV_INTER_LINEAR);
resize(image44,image4,Size(400,300),0,0,CV_INTER_LINEAR);
resize(image55,image5,Size(400,300),0,0,CV_INTER_LINEAR);
resize(image66,image6,Size(400,300),0,0,CV_INTER_LINEAR);
resize(image77,image7,Size(400,300),0,0,CV_INTER_LINEAR);
resize(image88,image8,Size(400,300),0,0,CV_INTER_LINEAR);
resize(image99,image9,Size(400,300),0,0,CV_INTER_LINEAR);
resize(image1010,image10,Size(400,300),0,0,CV_INTER_LINEAR);
imgs.push_back(image1);
imgs.push_back(image2);
imgs.push_back(image3);
imgs.push_back(image4);
imgs.push_back(image5);
imgs.push_back(image6);
imgs.push_back(image7);
评论0
最新资源