原理
g ( x ) = ( 1 − α ) f 0 ( x ) + α f 1 ( x ) g(x)=(1−α)f0(x)+αf1(x) g(x)=(1−α)f0(x)+αf1(x)
f
0
和
f
1
是
输
入
图
像
,
g
x
是
输
出
图
像
f0和f1是输入图像,gx是输出图像
f0和f1是输入图像,gx是输出图像
代码
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main(void)
{
double alpha=0.5, beta=0.5;
Mat origin,src2,dst;
origin= imread("../res/fruits.jpg");
src2 = imread("../res/lena.jpeg");
int cols= src2.cols;
int rows= src2.rows;
Mat src1(origin,Rect(0,0,cols,rows));
addWeighted(src1,alpha,src2,beta,0,dst);
imshow("Linear Blend",dst);
waitKey(0);
return 0;
}
结果: