How to blend a horizontal and vertical image?
Hello
I have those two images:
I'd like to blend the overlapping parts in order to obtain an image like this (but where the corners are blended):
On the last image you can see that the 2 parts of my image are overlapping, while I actually like to blend that region.
And this is the result i obtained so far by using the code below :
I actually want to obtain a continuous smooth image.
How can this be achieved without creating artifacts?
Thanks
//g++ stitcher2.cpp $(pkg-config --cflags --libs opencv) -o main
#include <opencv2/opencv.hpp>
#include "opencv2/core.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/aruco.hpp"
#include "opencv2/aruco/dictionary.hpp"
#include "opencv2/calib3d.hpp"
#include <sstream>
#include <iostream>
#include <fstream>
using namespace std;
using namespace cv;
int main(void)
{
Mat horizontalImg = imread("/home/a/Desktop/part1.png");
Mat verticalImg = imread("/home/a/Desktop/part2.png");
Mat output = Mat::zeros(horizontalImg.cols, verticalImg.rows, CV_8UC3);
//imshow("a", horizontalImg);
//imshow("b", verticalImg);
//waitKey(0);
int widthOverlap = 149;
int heightOverlap = 152;
Vec3b white = (255, 255, 255);
for(int i=0;i<verticalImg.rows;i++)
{
for(int j=0;j<horizontalImg.cols;j++)
{
if(i<heightOverlap)
{
if(j<widthOverlap)
{
output.at<Vec3b>(i,j) = (0.5 * horizontalImg.at<Vec3b>(i,j)) + (0.5 * verticalImg.at<Vec3b>(i,j));
}
else
{
output.at<Vec3b>(i,j) = horizontalImg.at<Vec3b>(i,j);
}
}
if(j<widthOverlap)
{
if(i>heightOverlap)
{
output.at<Vec3b>(i,j) = verticalImg.at<Vec3b>(i,j);
}
}
if(j>widthOverlap)
{
if(i>heightOverlap)
{
output.at<Vec3b>(i,j) = white;
}
}
}
}
imshow("final result", output);
waitKey(0);
return 0;
}