void addWeighted(InputArray src1,double alpha,InputArray src2,double beta,double gamma,OutputArray dst,int dtype =-1);
dst = src1[I] * alpha + src2[I] * beta + gamma ;
代码示例:
#include<opencv.hpp>
using namespace cv;
int main() {
Mat srcImage1, srcImage2, dstImage;
int intAlpha = 50;//接收控制条数值
//创建控制条
namedWindow("Control", WINDOW_AUTOSIZE);
createTrackbar("Alpha", "Control", &intAlpha, 100);
double alpha, beat;
srcImage1 = imread("C:/Users/齐明洋/Desktop/3.jpg");
srcImage2 = imread("C:/Users/齐明洋/Desktop/4.jpg");
while (true) {
alpha = intAlpha / 100.0;//第一个数组权重
beat = 1.0 - alpha;//第二个数组权重
addWeighted(srcImage1, alpha, srcImage2, beat, 0.0, dstImage);
imshow("合成图", dstImage);
char Key = (char)waitKey(1);
if (Key == 1)
break;
}
}
结果:
opencv —— 线性混合操作 addWeighted()
原文:https://www.cnblogs.com/bjxqmy/p/11986135.html