File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change
1
+ Mat Contrast (Mat src, int degree) {
2
+ int row = src.rows ;
3
+ int col = src.cols ;
4
+ // 验证参数范围
5
+ if (degree < -100 ) degree = -100 ;
6
+ if (degree > 100 ) degree = 100 ;
7
+ double contrast = (100.0 + degree) / 100.0 ;
8
+ contrast *= contrast;
9
+ Mat dst (row, col, CV_8UC3);
10
+ for (int i = 0 ; i < row; i++) {
11
+ for (int j = 0 ; j < col; j++) {
12
+ for (int k = 0 ; k < 3 ; k++) {
13
+ int val = (int )(((1.0 * src.at <Vec3b>(i, j)[k] / 255.0 - 0.5 ) * contrast + 0.5 ) * 255 );
14
+ if (val < 0 ) val = 0 ;
15
+ else if (val > 255 ) val = 255 ;
16
+ dst.at <Vec3b>(i, j)[k] = val;
17
+ }
18
+ }
19
+ }
20
+ return dst;
21
+ }
Original file line number Diff line number Diff line change 29
29
- PS色彩均衡化算法.cpp 实现了PS色彩均衡化算法,原理请看:https://blog.csdn.net/just_sort/article/details/94430129
30
30
- PS负像算法.cpp 实现了PS负像算法。
31
31
- PS亮度调节(曝光不足或过量).cpp 实现了PS中的亮度调整,调整曝光不足和过量。
32
+ - PS对比度增强算法.cpp 实现了PS中的对比度增强,根据用户指定的一个对比度,分别与原始R、G、B色彩分量进行一定比例的缩放,从而拉开原色色彩亮度级别的分布,达到对比度增强的作用。
32
33
You can’t perform that action at this time.
0 commit comments