The linear blend operator for two images:

dst = α⋅src1+β⋅src2+γ

we can use the following interface to support combine two pictures.

CV_EXPORTS_W void addWeighted(InputArray src1, double alpha, InputArray src2,
                              double beta, double gamma, OutputArray dst, int dtype = -1);

Notice: we need to use the images which have the same size as input sources.



#include <stdio.h>
#include <opencv2/opencv.hpp>

using namespace cv;

int main(int argc, char** argv )
{
    Mat image1 = imread( "/Users/weiyang/Desktop/Untitled.png", IMREAD_COLOR );
    Mat image2 = imread( "/Users/weiyang/Desktop/fish.png", IMREAD_COLOR );
    Mat dest;
    if( image1.empty() || image2.empty() )
    {
        fprintf( stderr, "No image data \n");
        return -1;
    }
    double alpha = 0.5;
    addWeighted( image1, alpha, image2, 1 - alpha, 0.0, dest );
    namedWindow( "Display Image", WINDOW_AUTOSIZE );
    imshow( "Display Image", dest );
    waitKey(0);
    return 0;
}
Categories: OpenCV

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Tex To PDF
: convert the Latex file which suffix is tex to a PDF file

X
0
Would love your thoughts, please comment.x
()
x