opencv实现两幅图像的拼接

先看结果图:

原图 :741x966(这里是两幅一样的图拼接)


结果图:1482x966(真的是csdn视觉上放大了原图,分辨率这里是没问题的)


#include <iostream>  
#include <fstream>  
#include "opencv2/highgui/highgui.hpp"  
#include "opencv2/stitching/stitcher.hpp"  

using namespace std;
using namespace cv;

void main()
{
	Mat image_one = imread("1.jpg");  //待拼接左图  我的1.jpg和2.jpg都是上述原图
	Mat image_two = imread("2.jpg");  //待拼接右图
	Mat result(image_one.rows, image_one.cols +
		image_two.cols, image_one.type());

	//colRange(int x,int y)  取图像的第x~y-1行
	image_one.colRange(0, image_one.cols).
		copyTo(result.colRange(0, image_one.cols));

	image_two.colRange(0, image_two.cols).copyTo(
	   result.colRange(image_one.cols, result.cols));
	imwrite("result.jpg",result);
	waitKey(0);
}

猜你喜欢

转载自blog.csdn.net/ranghanqiao5058/article/details/79392567