图片单色渐变效果叠加
来源:互联网 发布:万家购物模式网站源码 编辑:程序博客网 时间:2024/04/29 02:30
<span style="font-family: Arial, Helvetica, sans-serif;">#include<iostream></span>
using namespace cv;using namespace std;int main() {Mat img1 = imread("D://图片//1.png");if (!img1.data)return -1;img1.convertTo(img1, CV_32F);Mat result = img1.clone();Point2f center(img1.cols / 2, img1.rows / 2);Point2f org(0, 0);float dis;if (org.x <= center.x && org.y <= center.y) {dis = sqrt((img1.cols - 1 - org.x)*(img1.cols - 1 - org.x) + (img1.rows - 1 - org.y)*(img1.rows - 1 - org.y));}else if (org.x <= center.x && org.y > center.y) {dis = sqrt((img1.cols - 1)*(img1.cols - 1) + org.y * org.y);}else if (org.x > center.x && org.y <= center.y) {dis = sqrt(org.x * org.x + (img1.rows - 1)*(img1.rows - 1));}else {dis = sqrt(org.x * org.x + org.y * org.y);}Scalar c1(255, 255, 255);Scalar c2(0, 0, 0);float weightB = (c1[0] - c2[0]) / dis;float weightG = (c1[1] - c2[1]) / dis;float weightR = (c1[2] - c2[2]) / dis;float dis2;for (int i = 0; i < result.rows; i++) {float *pp = result.ptr<float>(i);for (int j = 0; j < result.cols; j++) {dis2 = sqrt((i - org.y)*(i - org.y) + (j - org.x)*(j - org.x));pp[j * 3 + 0] += weightB*dis2;pp[j * 3 + 1] += weightG*dis2;pp[j * 3 + 2] += weightR*dis2;}}result.convertTo(result, CV_8U);imshow("result", result);waitKey(0);destroyAllWindows;return 0;}
原图:
效果:
参考博主:http://blog.csdn.net/matrix_space
0 0
- 图片单色渐变效果叠加
- android 图片叠加效果
- android 图片叠加效果
- SWT 图片叠加效果
- IOS图片叠加效果
- Android图片叠加效果
- 实现渐变色与图像叠加效果
- 用java实现图片渐变叠加
- android 图片叠加效果实现
- JAVA实现图片叠加效果
- JAVA实现图片叠加效果
- 图片渐变轮换效果
- 图片渐变轮换效果
- 图片渐变轮换效果
- 图片渐变轮换效果
- 图片渐变轮换效果
- 图片渐变轮换效果
- 图片轮换渐变效果
- 南非市场之车祸现场
- Set集合的简单总结
- leetcode-Plus One-66
- html中的垂直居中实现
- 联合查询
- 图片单色渐变效果叠加
- 常用Java代码混淆器 助你保护你的代码
- 严重: Exception occurred during processing request: null原因解析
- Tire
- csdn可能待改进点之10------>建议显示名次排在博主前面一名的博主的分数
- Linux搭建Tomcat服务器
- mysql单表数据操作优化(一)
- English short country names
- Read Large Files in Python