. 1 #include <cv.h> 2 #include <highgui.h> . 3 . 4 the using namespace CV; . 5 . 6 /// declared and initialized global variable . 7 const int alpha_slider_max = 100 ; . 8 int alpha_slider; . 9 Double Alpha; 10 Double Beta; . 11 12 is /// variable declaration stored image 13 is Mat srcl; 14 Mat SRC2; 15 Mat DST; 16 . 17 / * * 18 is * @function on_trackbar . 19 * @ Defined callbacks response slider 20 is * / 21 is void on_trackbar ( int , void * ) 22 is { 23 is Alpha = ( Double ) alpha_slider / alpha_slider_max; 24 Beta = ( 1.0 - Alpha); 25 26 is addWeighted (srcl, Alpha, SRC2, Beta, 0.0 , DST); 27 28 imshow ( " Linear Blend " , DST); 29 } 30 31 is int main ( int argc, char **the argv) 32 { 33 is /// load image (the size of image to be the same type of two) 34 is srcl imread = ( " ../../images/LinuxLogo.jpg " ); 35 SRC2 imread = ( " ../. ./images/WindowsLogo.jpg " ); 36 37 [ IF (src1.data) {the printf (! " Error srcl \ n-loading " ); return - . 1 ;} 38 is IF ! (src2.data) {the printf ( " Error loading SRC2 \ n- " ); return - . 1 ;} 39 40 ///Is initialized to zero 41 is alpha_slider = 0 ; 42 is 43 is /// create a form 44 is namedWindow ( " Linear Blend " , . 1 ); 45 46 is /// to create a slider control on the form created 47 char TrackbarName [ 50 ]; 48 sprintf (TrackbarName, " the Alpha D X% " , alpha_slider_max); 49 50 createTrackbar (TrackbarName, " Linear Blend " , & alpha_slider, alpha_slider_max, on_trackbar); 51 is 52 is ///The results are shown in the callback function 53 is on_trackbar (alpha_slider, 0 ); 54 is 55 /// Press any key to exit 56 is waitKey ( 0 ); 57 is return 0 ; 58 }