Explicit fusion of two images of OPENCV learning notes

Source: Internet
Author: User

An explicit fusion of images

That is, by the following formula


Two images are superimposed on each other, and alpha controls the weight of the image in the fused image.

The following two images are implemented using the addweighted () function.


Fig. 1 Fig. 2

#include <opencv2/opencv.hpp>
#include <iostream>

using namespace std;
using namespace CV;
int main ()
{
	Mat img1,img2,out;
	Img1=imread ("1.jpg", 0);
	Img2=imread ("2.jpg", 0);

	if (!img1.data)
		cout<< "Error loading IMG1" <<endl;
	if (!img2.data)
		cout<< "Error loading Img2" <<endl;

	Double alpha=0.5;
	Double beta,input;

	cin>>input;

	if (input>=0.0 && input<=1.0)
		alpha=input;
	Beta= (1.0-alpha);
	Addweighted (img1,alpha,img2,beta,0.0,out);

	Namedwindow ("Out", 1);
	Imshow ("Out", out);

	Waitkey (0);
	return 0;
}

Effect:
Post-Fusion image

The parameters of the function are as follows:


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.