Skip to content

Commit 0a5fd16

Browse files
committed
Add PS二维高斯蒙版算法.cpp
1 parent 12f6920 commit 0a5fd16

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Mat GaussDistributionMask(Mat src) {
2+
int row = src.rows;
3+
int col = src.cols;
4+
int center_x = row / 2;
5+
int center_y = col / 2;
6+
//获得二维高斯分布蒙版
7+
int R = sqrt(center_x * center_x + center_y * center_y);
8+
Mat Gauss_map(row, col, CV_32FC1);
9+
for (int i = 0; i < row; i++) {
10+
for (int j = 0; j < col; j++) {
11+
float dis = sqrt(1.0 * (i - center_x) * (i - center_x) + 1.0 * (j - center_y) * (j - center_y));
12+
Gauss_map.at<float>(i, j) = exp(-0.5 * dis / R);
13+
}
14+
}
15+
//和原图相乘得到渐变映射的效果
16+
Mat dst(row, col, CV_8UC3);
17+
for (int i = 0; i < row; i++) {
18+
for (int j = 0; j < col; j++) {
19+
for (int k = 0; k < 3; k++) {
20+
dst.at<Vec3b>(i, j)[k] = src.at<Vec3b>(i, j)[k] * Gauss_map.at<float>(i, j);
21+
}
22+
}
23+
}
24+
return dst;
25+
}

PhotoShop Algorithm/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@
3535
- PS模糊滤镜之表面模糊算法.cpp 其作用是在保留图像边缘的情况下,对图像的表面进行模糊处理,效果比双边滤波好。
3636
- PS模糊滤镜之水波效果算法.cpp 这个算法原理不清楚,最先出处是这个博客:https://blog.csdn.net/matrix_space/article/details/42396829 。但他也没说明原理,还需研究下。
3737
- PS模糊滤镜之波浪特效.cpp 和水波效果一样,使用坐标变换实现。
38+
- PS二维高斯蒙版算法.cpp 实现了二维高斯蒙版算法,原理请看:https://chenjunkai.blog.csdn.net/article/details/57942262
3839

0 commit comments

Comments
 (0)