#include <opencv2/opencv.hpp> #include <iostream> #include <math.h> using namespace cv; using namespace std; int main() { Mat src1,src2,dst; //原图 src1 = imread(".//pic//kate.png",IMREAD_UNCHANGED); src2 = imread(".//pic//sword.png", IMREAD_UNCHANGED); if (src1.empty() || src2.empty()) { cout << "can not load image" << endl; return -1; } double alpha = 0.6; if (src1.rows == src2.rows && src1.cols == src2.cols && src1.type() == src2.type()) { addWeighted(src1, alpha, src2, (1 - alpha), 0.0, dst); namedWindow("input", CV_WINDOW_AUTOSIZE); imshow("src1", src1); imshow("src2", src2); imshow("混合", dst); } waitKey(0); return 0; }