OpenCV入门:(四:混合两张图片)
2024-10-19 11:56:51
1. 原理
对两张图片使用如下公式可以得到两张图片的混合图片,
其中f0(x),f1(x)分别是图片1和图片2同一位置的像素点。
2. OpenCV中的AddWeight函数
函数和参数说明:
void addWeighted(InputArray src1, double alpha, InputArray src2, double beta, double gamma, OutputArray dst, int dtype=-)
src1 – first input array.
alpha – weight of the first array elements.
src2 – second input array of the same size and channel number as src1.
beta – weight of the second array elements.
dst – output array that has the same size and number of channels as the input arrays.
gamma – scalar added to each sum.
dtype – optional depth of the output array; when both input arrays have the same depth, dtype can be set to -, which will be equivalent to src1.depth().
实现的转换公式为:
3. 实现代码
void Blend(const Mat& Src1,const Mat& Src2,double alpha,Mat& Dst)
{
double beta = 1.0 - alpha;
addWeighted(Src1,alpha,Src2,beta,0.0,Dst);
namedWindow("原图1");
imshow("原图1",Src1);
waitKey();
namedWindow("原图2");
imshow("原图2",Src2);
waitKey();
namedWindow("混合图");
imshow("混合图",Dst);
waitKey();
}
4. 结果
下图为设置alpha为0.5的处理结果:
5. 相关下载
6. 结束
最新文章
- CLR中的程序集加载
- 3D Grid Effect – 使用 CSS3 制作网格动画效果
- 解析sql语句中left_join、inner_join中的on与where的区别
- 操作系统性能分析与优化V1.0
- ubuntu支持shh远程连接记录
- 从扩展方法到匿名方法再到LINQ
- Mac下关于——你不能拷贝项目“”,因为它的名称太长或包括的字符在目的宗卷上无效。文件的删除
- AndroidTestCase测试用法
- Yii2 独立操作
- 【Netty】ChannelHandler和ChannelPipeline
- ResourceBundle读取文件学习
- sql多表数据查询
- LoadRunner JAVA Vuser接口测试
- 一个优秀的 ring buffer 或 cycle buffer 的实现代码
- The Little Prince-11/29
- 查看 postgresql 数据库编码,以及修改数据库编码
- 关于mysql-connector-java(JDBC驱动)的一些坑
- Android 8 wifi 扫描时间间隔
- [Java学习] Java类的基本运行顺序
- Linux时间子系统(一) 基本概念
热门文章
- 2018.11.8 Error contacting service. It is probably not running.
- IntelliJ IDEA 快速搭建 Spring MVC环境
- git报错error: src refspec refs/heads/master does not match any.
- Android学习笔记_40_系统结构 目录结构
- Android学习笔记_10_ContentProvider内容提供者的使用
- 【题解】洛谷P2607【ZJOI2008】骑士
- PHP中级面试经历
- LeetCode10.正则表达式匹配 JavaScript
- BFC、IFC、GFC、FFC
- swift计算label动态宽度和高度