aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'DCP/recover.cpp')
-rw-r--r--DCP/recover.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/DCP/recover.cpp b/DCP/recover.cpp
index a99b0f2..5dbd75e 100644
--- a/DCP/recover.cpp
+++ b/DCP/recover.cpp
@@ -1,7 +1,13 @@
1#include "dcp_core.h" 1#include "dcp_core.h"
2 2
3void Recover(IplImage *Result, IplImage *InputImage, double A[]) 3void CalcRecover(IplImage *result, IplImage *input, IplImage *transmission, double A[])
4{ 4{
5 int height = input->height;
6 int width = input->width;
7 int widthstep = input->widthStep;
8 int gwidthstep = transmission->widthStep;
9 int nch = input->nChannels;
10
5 double t0 = 0.1; 11 double t0 = 0.1;
6 double t, tmp_res; 12 double t, tmp_res;
7 13
@@ -9,27 +15,29 @@ void Recover(IplImage *Result, IplImage *InputImage, double A[])
9 int e = 0, number = 0; 15 int e = 0, number = 0;
10 double a = 0; 16 double a = 0;
11 17
12 for (i = 1; i <= height; i++) 18 A[0] /= 255.0;
19 A[1] /= 255.0;
20 A[2] /= 255.0;
21
22 for (i = 0; i < height; i++)
13 { 23 {
14 for (j = 1; j <= width; j++) 24 for (j = 0; j < width; j++)
15 { 25 {
16 t = real_trans[e++]; 26 t = *(uchar *)(transmission->imageData + i * gwidthstep + j);
17 t /= 255.0; 27 t /= 255.0;
18 for (k = 0; k < 3; k++) 28 for (k = 0; k < 3; k++)
19 { 29 {
20 a = *(uchar *)(InputImage->imageData + (i - 1) * widthstep + (j - 1) * nch + k); 30 a = *(uchar *)(input->imageData + (i) * widthstep + (j) * nch + k);
21 a /= 255; 31 a /= 255.0;
22
23 tmp_res = ((a - A[k]) / MaxTwo(t, t0)) + A[k];
24 32
25 real_recover[number++] = tmp_res; 33 tmp_res = ((a - A[k]) / MAX(t, t0)) + A[k];
26 34
27 if (tmp_res > 1) 35 if (tmp_res > 1)
28 tmp_res = 1; 36 tmp_res = 1;
29 else if (tmp_res < 0) 37 else if (tmp_res < 0)
30 tmp_res = 0; 38 tmp_res = 0;
31 39
32 *(uchar *)(Result->imageData + (i - 1) * widthstep + (j - 1) * nch + k) = tmp_res * 255.0; 40 *(uchar *)(result->imageData + (i) * widthstep + (j) * nch + k) = tmp_res * 255.0;
33 } 41 }
34 } 42 }
35 } 43 }
Powered by cgit v1.2.3 (git 2.41.0)