#include <cv.h>

#include <highgui.h>

#include <iostream>

using namespace cv;

int main( int argc, char** argv )

{

 double alpha = 0.5; double beta; double input;

 Mat src1, src2, dst;

 /// Ask the user enter alpha

 std::cout<<" Simple Linear Blender "<<std::endl;

 std::cout<<"-----------------------"<<std::endl;

 std::cout<<"* Enter alpha [0-1]: ";

 std::cin>>input;

 /// We use the alpha provided by the user if it is between 0 and 1

 if( input >= 0.0 && input <= 1.0 )

   { alpha = input; }

 /// Read image ( same size, same type )

 src1 = imread("green.png");

 src2 = imread("red.png");

 if( !src1.data ) { printf("Error loading src1 \n"); return -1; }

 if( !src2.data ) { printf("Error loading src2 \n"); return -1; }

 /// Create Windows

 namedWindow("Linear Blend", 1);

 beta = ( 1.0 - alpha );

 addWeighted( src1, alpha, src2, beta, 0.0, dst);

 imshow( "Linear Blend", dst );

 waitKey(0);

 return 0;

}

#Python Code

import cv2

img1 = cv2.imread('red.png')

img2 = cv2.imread('green.jpg')

dst = cv2.addWeighted(img1,0.7,img2,0.3,0)

cv2.imshow('dst',dst)

cv2.waitKey(0)

cv2.destroyAllWindows()