aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJinweiClarkChao <[email protected]>2015-08-24 10:15:00 +0800
committerJinweiClarkChao <[email protected]>2015-08-24 10:15:00 +0800
commit17fbf4355747b1ceb9caca120aec9830a44621cf (patch)
tree6ec188fe59b0ae8c65a812765ef8f621ecf87ec3 /DCP/transmission.cpp
downloadDehaze-17fbf4355747b1ceb9caca120aec9830a44621cf.tar.gz
init
Diffstat (limited to 'DCP/transmission.cpp')
-rw-r--r--DCP/transmission.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/DCP/transmission.cpp b/DCP/transmission.cpp
new file mode 100644
index 0000000..5bb2ece
--- /dev/null
+++ b/DCP/transmission.cpp
@@ -0,0 +1,51 @@
1#include "dcp_core.h"
2
3void Estimate_transmission(IplImage *Transmission_maps, IplImage *InputImage, double A[], double heap[], double real_trans[])
4{
5 double w = 0.95;
6 double tmp;
7 double tran;
8 int i, j, k;
9 int e = 0;
10
11 IplImage *tmp_Trans = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
12
13 for (k = 0; k < 3; k++)
14 {
15 for (i = 1; i <= height; i++)
16 {
17 for (j = 1; j <= width; j++)
18 {
19 tmp = *(uchar *)(InputImage->imageData + (i - 1) * widthstep + (j - 1) * nch + k);
20 tmp /= A[k];
21
22 if (tmp > 255)
23 tmp = 255;
24 *(uchar *)(tmp_Trans->imageData + (i - 1) * widthstep + (j - 1) * nch + k) = tmp;
25 }
26 }
27 }
28 Cal_DarkChannel(Transmission_maps, tmp_Trans, nInteger, heap);
29
30 for (i = 1; i <= height; i++)
31 {
32 for (j = 1; j <= width; j++)
33 {
34 tran = *(uchar *)(Transmission_maps->imageData + (i - 1) * gwidthstep + (j - 1));
35
36 tran /= 255.0;
37 tran = 1 - w * tran;
38
39 real_trans[e++] = tran * 255.0;
40
41 if (tran > 1)
42 tran = 1;
43 else if (tran < 0)
44 tran = 0;
45
46 *(uchar *)(Transmission_maps->imageData + (i - 1) * gwidthstep + (j - 1)) = tran * 255;
47 }
48 }
49 //cvSaveImage("Estimated-Trans.bmp", Transmission_maps);
50 cvReleaseImage(&tmp_Trans);
51}
Powered by cgit v1.2.3 (git 2.41.0)