1 #include <cv.h> 2 #include <highgui.h> 3 #include <iostream> 4 5 using namespace cv; 6 7 int main( int argc, char** argv ) 8 { 9 double alpha = 0.5; double beta; double input; 10 11 Mat src1, src2, dst; 12 13 /// Ask the user enter alpha 14 std::cout<<" Simple Linear Blender "<<std::endl; 15 std::cout<<"-----------------------"<<std::endl; 16 std::cout<<"* Enter alpha [0-1]: "; 17 std::cin>>input; 18 19 /// We use the alpha provided by the user iff it is between 0 and 1 20 if( alpha >= 0 && alpha <= 1 ) 21 { alpha = input; } 22 23 /// Read image ( same size, same type ) 24 src1 = imread("../../images/LinuxLogo.jpg"); 25 src2 = imread("../../images/WindowsLogo.jpg"); 26 27 if( !src1.data ) { printf("Error loading src1 \n"); return -1; } 28 if( !src2.data ) { printf("Error loading src2 \n"); return -1; } 29 30 /// Create Windows 31 namedWindow("Linear Blend", 1); 32 33 beta = ( 1.0 - alpha ); 34 addWeighted( src1, alpha, src2, beta, 0.0, dst); 35 36 imshow( "Linear Blend", dst ); 37 38 waitKey(0); 39 return 0; 40 }