基础代码展示
1 #include<iostream> 2 #include<opencv.hpp> 3 4 5 using namespace std; 6 using namespace cv; 7 8 9 int main() 10 { 11 Mat src1, src2, dest; 12 src1 = imread("C:\Users\32829\Desktop\aa.jpg"); 13 src2 = imread("C:\Users\32829\Desktop\cc.jpg"); 14 if (!src1.data) { 15 printf("could not load LinuxLogo image... "); 16 return -1; 17 } 18 if (!src2.data) { 19 printf("could not load win7logo image... "); 20 return -1; 21 } 22 if (src1.rows == src2.rows && src1.cols == src2.cols) { 23 double alpha = 0.5; 24 namedWindow("line-blend", CV_WINDOW_AUTOSIZE); 25 addWeighted(src1, (1 - alpha), src2, alpha, 0.0, dest);//权重相加 26 //add(src1,src2,dst,Mat());//直接将两张图对应的像素相加 27 //add(src1,src2,dst,1.0);//直接将两张图对应的像素相乘 28 imshow("line-blend", dest); 29 waitKey(0); 30 return 0; 31 } 32 else { 33 printf("image size is not same... "); 34 return -1; 35 } 36 37 }
然后基础知识展示:
=================================================================
===============================================================================