aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'DCP/airlight.cpp')
-rw-r--r--DCP/airlight.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/DCP/airlight.cpp b/DCP/airlight.cpp
index 08f18d0..78ec9a9 100644
--- a/DCP/airlight.cpp
+++ b/DCP/airlight.cpp
@@ -1,10 +1,7 @@
1#include "dcp_core.h" 1#include "dcp_core.h"
2#include <malloc.h>
3#include <vector>
4#include <iostream>
5#include <algorithm>
6 2
7using namespace std; 3#include <algorithm>
4using std::sort;
8 5
9struct Pixel 6struct Pixel
10{ 7{
@@ -33,7 +30,6 @@ void CalcAirlight(IplImage *darkchannel, IplImage *input, double A[])
33 } 30 }
34 sort(v_darkchannel, v_darkchannel + count, [](struct Pixel &a, struct Pixel &b){ return a.value > b.value; }); 31 sort(v_darkchannel, v_darkchannel + count, [](struct Pixel &a, struct Pixel &b){ return a.value > b.value; });
35 32
36
37 IplImage *mask = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 1); 33 IplImage *mask = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 1);
38 cvZero(mask); 34 cvZero(mask);
39 35
@@ -65,12 +61,12 @@ void CalcAirlight(IplImage *darkchannel, IplImage *input, double A[])
65 61
66 sort(v_channel, v_channel + count, [](struct Pixel &a, struct Pixel &b){ return a.value > b.value; }); 62 sort(v_channel, v_channel + count, [](struct Pixel &a, struct Pixel &b){ return a.value > b.value; });
67 63
68 int channel_airlight = 0; 64 double channel_airlight = 0;
69 for (int i = 0; i < count * 0.01; i++) 65 for (int i = 0; i < count * 0.01; i++)
70 { 66 {
71 channel_airlight += v_channel[i].value; 67 channel_airlight += v_channel[i].value;
72 } 68 }
73 channel_airlight /= (count * 0.01); 69 channel_airlight = channel_airlight / (count * 0.01);
74 A[k] = channel_airlight; 70 A[k] = channel_airlight;
75 71
76 free(v_channel); 72 free(v_channel);
Powered by cgit v1.2.3 (git 2.41.0)