基于FPGA的Alpha半透明图像叠加算法实现
2016-07-22 09:22
381 查看
#include<opencv2\opencv.hpp> #include<iostream> using namespace cv; using namespace std; Mat dealImg(Mat &img); int main() { Mat img = imread("E://ͼƬ//1.png"); if (img.empty()) { return -1; } Mat result; result = dealImg(img); waitKey(0); destroyAllWindows; return 0; } Mat dealImg(Mat & img){ Mat temp; Mat img1 = imread("E://ͼƬ//5.jpg"); if (img1.empty()) { return Mat(); } img.convertTo(temp, CV_32F); Mat img2(temp.size(), img1.type()); resize(img1, img2, temp.size()); img2.convertTo(img2, CV_32F); Mat result = temp.clone(); float alpha = 0.35; //调整透光 for (int i = 0; i < temp.rows; i++) { float *ptr_result = result.ptr<float>(i); float *ptr_temp = temp.ptr<float>(i); float *ptr_img1 = img2.ptr<float>(i); for (int j = 0; j < temp.cols; j++) { ptr_result[j * 3 + 0] = (1 - alpha)*ptr_img1[j * 3 + 0] + alpha*ptr_temp[j * 3 + 0]; ptr_result[j * 3 + 1] = (1 - alpha)*ptr_img1[j * 3 + 1] + alpha*ptr_temp[j * 3 + 1]; ptr_result[j * 3 + 2] = (1 - alpha)*ptr_img1[j * 3 + 2] + alpha*ptr_temp[j * 3 + 2]; } } result.convertTo(result, CV_8U); imshow("result", result); return result; }
相关文章推荐
- crontab运行shell脚本报sudo错误
- [李景山php]每天laravel-20160921|Redis Database.php
- Post Views Options怎么设置,WP-PostViews的后台设置五步法详解
- java反向工程神器ermaster
- hdu-1242 Rescue DFS解法
- Android 6.0 通话UI设计模式分析(MVC\MVP\MVVM)
- 深入理解 Android 中的 Matrix
- const 指针与指向const的指针
- Mybatis关联查询,查询出的记录数量与数据库直接查询不一致,如何解决?
- .NET之美——C# 中的委托和事件
- python 模拟登录csdn并获取博客列表等操作
- [李景山php]每天laravel-20160921|Redis Database.php
- solr学习笔记-导入mysql数据
- 【codeforces】Uncowed Forces
- MPI和MapReduce对比
- Kefa and Company
- Android编译系统详解(一)——build/envsetup.sh
- nodejs连接mysql数据库简单封装-mysql模块
- windows下面安装Python和pip终极教程
- 【数字信号处理】十大经典软件滤波算法