From 43f854bc5f216d7e8dacc2144859a5a026c90dff Mon Sep 17 00:00:00 2001 From: Vadzim Piatrou Date: Fri, 22 Apr 2016 18:55:22 +0300 Subject: [PATCH] fixing CLAHE crash with pixels value > 12 bit --- modules/imgproc/src/clahe.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/imgproc/src/clahe.cpp b/modules/imgproc/src/clahe.cpp index fcd6c21a32..8481834e1b 100644 --- a/modules/imgproc/src/clahe.cpp +++ b/modules/imgproc/src/clahe.cpp @@ -227,7 +227,7 @@ namespace } } - template + template class CLAHE_Interpolation_Body : public cv::ParallelLoopBody { public: @@ -277,8 +277,8 @@ namespace float * xa_p, * xa1_p; }; - template - void CLAHE_Interpolation_Body::operator ()(const cv::Range& range) const + template + void CLAHE_Interpolation_Body::operator ()(const cv::Range& range) const { float inv_th = 1.0f / tileSize_.height; @@ -302,7 +302,7 @@ namespace for (int x = 0; x < src_.cols; ++x) { - int srcVal = srcRow[x]; + int srcVal = srcRow[x] >> shift; int ind1 = ind1_p[x] + srcVal; int ind2 = ind2_p[x] + srcVal; @@ -310,7 +310,7 @@ namespace float res = (lutPlane1[ind1] * xa1_p[x] + lutPlane1[ind2] * xa_p[x]) * ya1 + (lutPlane2[ind1] * xa1_p[x] + lutPlane2[ind2] * xa_p[x]) * ya; - dstRow[x] = cv::saturate_cast(res); + dstRow[x] = cv::saturate_cast(res) << shift; } } } @@ -422,9 +422,9 @@ namespace cv::Ptr interpolationBody; if (_src.type() == CV_8UC1) - interpolationBody = cv::makePtr >(src, dst, lut_, tileSize, tilesX_, tilesY_); + interpolationBody = cv::makePtr >(src, dst, lut_, tileSize, tilesX_, tilesY_); else if (_src.type() == CV_16UC1) - interpolationBody = cv::makePtr >(src, dst, lut_, tileSize, tilesX_, tilesY_); + interpolationBody = cv::makePtr >(src, dst, lut_, tileSize, tilesX_, tilesY_); cv::parallel_for_(cv::Range(0, src.rows), *interpolationBody); }