From 66efed8b335610f9eae59fd3f52eccaffd7a6e0b Mon Sep 17 00:00:00 2001 From: JinweiClarkChao Date: Tue, 25 Aug 2015 16:03:05 +0800 Subject: fix --- DCP/transmission.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'DCP/transmission.cpp') diff --git a/DCP/transmission.cpp b/DCP/transmission.cpp index 48a8299..0079ef7 100644 --- a/DCP/transmission.cpp +++ b/DCP/transmission.cpp @@ -22,7 +22,7 @@ void CalcTransmission(IplImage *transmission, IplImage *input, double A[], int r tmp = tmp / A[k] * 255.0; tmp = tmp > 255 ? 255 : tmp; - *(uchar *)(normalized_input->imageData + i * widthstep + j * nch + k) = tmp; + *(uchar *)(normalized_input->imageData + i * widthstep + j * nch + k) = cvRound(tmp); } } } @@ -35,11 +35,10 @@ void CalcTransmission(IplImage *transmission, IplImage *input, double A[], int r double tran = *(uchar *)(transmission->imageData + i * gwidthstep + j); tran = 1 - w * (tran / 255.0); + tran *= 255.0; + tran = tran > 255 ? 255 : (tran < 0 ? 0 : tran); - tran = tran > 1 ? 1 : tran; - tran = tran < 0 ? 0 : tran; - - *(uchar *)(transmission->imageData + i * gwidthstep + j) = tran * 255; + *(uchar *)(transmission->imageData + i * gwidthstep + j) = cvRound(tran); } } cvReleaseImage(&normalized_input); -- cgit v1.2.3