Skip to content

Commit 0a48098

Browse files
committed
Update Local Color Correction
1 parent 6e93f45 commit 0a48098

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

Local Color Correction.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Mat LCC(const Mat &src){
2+
int rows = src.rows;
3+
int cols = src.cols;
4+
int **I;
5+
I = new int *[rows];
6+
for(int i = 0; i < rows; i++){
7+
I[i] = new int [cols];
8+
}
9+
int **inv_I;
10+
inv_I = new int *[rows];
11+
for(int i = 0; i < rows; i++){
12+
inv_I[i] = new int [cols];
13+
}
14+
Mat Mast(rows, cols, CV_8UC1);
15+
for(int i = 0; i < rows; i++){
16+
uchar *data = Mast.ptr<uchar>(i);
17+
for(int j = 0; j < cols; j++){
18+
I[i][j] = (src.at<Vec3b>(i, j)[0] + src.at<Vec3b>(i, j)[1] + src.at<Vec3b>(i, j)[1]) / 3.0;
19+
inv_I[i][j] = 255;
20+
*data = inv_I[i][j] - I[i][j];
21+
data++;
22+
}
23+
}
24+
GaussianBlur(Mast, Mast, Size(41, 41), BORDER_DEFAULT);
25+
Mat dst(rows, cols, CV_8UC3);
26+
for(int i = 0; i < rows; i++){
27+
uchar *data = Mast.ptr<uchar>(i);
28+
for(int j = 0; j < cols; j++){
29+
for(int k = 0; k < 3; k++){
30+
float Exp = pow(2, (128 - data[j]) / 128.0);
31+
int value = int(255 * pow(src.at<Vec3b>(i, j)[k] / 255.0, Exp));
32+
dst.at<Vec3b>(i, j)[k] = value;
33+
}
34+
}
35+
}
36+
return dst;
37+
}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
- Adaptive Logarithmic Mapping For Displaying High Contrast Scenes.cpp 《Adaptive Logarithmic Mapping For Displaying High Contrast Scenes》c++朴素实现 ,详情请看:https://blog.csdn.net/just_sort/article/details/84066390
77

88
- Single Image Haze Removal Using Dark Channel Prior.cpp 《Single Image Haze Removal Using Dark Channel Prior》论文阅读及复现,详情请看:https://blog.csdn.net/just_sort/article/details/84110518
9-
9+
- Local Color Correction.cpp C++复现了《Local Color Correction》论文,详情请参考:https://blog.csdn.net/just_sort/article/details/84539295
1010

1111

0 commit comments

Comments
 (0)