OpenCV基础课程笔记06图像混合
程序员文章站
2023-12-23 16:48:52
...
写在前面
注意,本博客图中有恐怖内容,请心脏脆弱者慎重查阅!
代码
#include<iostream>
#include<opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main() {
Mat src1 = imread("A:\\专用\\TestForTheCV\\class6美女.jpg");
Mat src2 = imread("A:\\专用\\TestForTheCV\\class6丧尸.jpg");
imshow("图片1", src1);
imshow("图片2", src2);
cout << src1.rows << " " << src1.cols << endl;
cout << src2.rows << " " << src2.cols << endl;
resize(src2, src2, Size(src1.cols, src1.rows), CV_INTER_LINEAR);
imshow("图片2resize之后", src2);
cout << src2.rows << " " << src2.cols << endl;
Mat dst;
double alpha = 0.5;
if (src1.rows == src2.rows&&src1.cols == src2.cols&&src1.type() == src2.type()) {
addWeighted(src1, alpha, src2, (1.0 - alpha), 0.0, dst);
//multiply(src1, src2, dst, 1.0);
imshow("融合", dst);
}
waitKey(0);
return 0;
}