OpenCV to realize multi image mosaic

Posted on

The example of this paper shares the simple splicing of multiple images by opencv for your reference. The details are as follows

#include <iostream>
#include <core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include<opencv2/stitching.hpp>
 
using namespace std;
using namespace cv;
int main()
{
 
 Mat combine, combine1, combine2;
 Mat a = imread("idol1.jpg");
 Mat b = imread("idol2.jpg");
 Mat c = imread("idol3.jpg");
 Mat d = imread("idol4.jpg");
 
 cv::resize(a, a, cv::Size(100, 100), 0, 0, CV_INTER_LINEAR);
 cv::resize(b, b, cv::Size(100, 100), 0, 0, CV_INTER_LINEAR);
 cv::resize(c, c, cv::Size(100, 100), 0, 0, CV_INTER_LINEAR);
 cv::resize(d, d, cv::Size(100, 100), 0, 0, CV_INTER_LINEAR);
 //Horizontal splicing
 hconcat(a, b, combine1);
 hconcat(c, d, combine2);
 
 //Vertical splicing
 vconcat(combine1, combine2, combine);
 namedWindow("Combine", CV_WINDOW_AUTOSIZE);
 imshow("Combine", combine);
 cv::waitKey(1);
 
 system("pause");
 return 0;
}

The effect is as follows:

The above is the whole content of this article. I hope it will help you in your study, and I hope you can support developepaer more.

Leave a Reply

Your email address will not be published.