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