nareshmlx/opencv-pr huggingface dataset:
**File:** modules/ml/src/lr.cpp
**Change Type:** added
**Context:** PR #3119: Reworked logistic regression classifier - Merged PR #1227 to master and reworked logistic regression module to conform with new machine lear...

**Code Changes:**
```diff
@@ -0,0 +1,622 @@
+///////////////////////////////////////////////////////////////////////////////////////
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+
+//  By downloading, copying, installing or using the software you agree to this license.
+//  If you do not agree to this license, do not download, install,
+//  copy or use the software.
+
+// This is a implementation of the Logistic Regression algorithm in C++ in OpenCV.
+
```

Review comment:
for cleaner code, please remove all the "cv::"; all the code is already within cv namespace.
**File:** samples/cpp/logistic_regression.cpp
**Change Type:** added
**Context:** PR #3119: Reworked logistic regression classifier - Merged PR #1227 to master and reworked logistic regression module to conform with new machine lear...

**Code Changes:**
```diff
@@ -0,0 +1,186 @@
+/*//////////////////////////////////////////////////////////////////////////////////////
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+
+//  By downloading, copying, installing or using the software you agree to this license.
+//  If you do not agree to this license, do not download, install,
+//  copy or use the software.
+
+// This is a implementation of the Logistic Regression algorithm in C++ in OpenCV.
+
```

Review comment:
this is very minor, but since we are trying to make things consistent, please, replace <pre> &lt;opencv2/modname/modname.hpp&gt; </pre> to <pre> &lt;opencv2/modname.hpp&gt; </pre>
**File:** modules/imgproc/src/histogram.cpp
**Change Type:** modified
**Context:** PR #2765: Implemented Kullback-Leibler divergence - This pull request implements non-symmetric Kullback-Leibler divergence for comparing histograms.

**Code Changes:**
```diff
@@ -2323,6 +2323,21 @@ double cv::compareHist( InputArray _H1, InputArray _H2, int method )
                 s2 += b;
             }
         }
+        else if( method == CV_COMP_KL_DIV )
+        {
+            for( j = 0; j < len; j++ )
+            {
+                double p = h1[j];
+                double q = h2[j];
```

Review comment:
Seems fine. KL divergence is an important non-symmetric measure of distance of probability distributions. This was missing in OpenCV. Nice addition.
**File:** modules/cudaoptflow/perf/perf_optflow.cpp
**Change Type:** modified
**Context:** PR #2942: Tvl1 chambolle - I adapted the TVL1 optical flow computation method to accomodate illumination variation according to the method described b...
**Review Line:** 388

**Code Changes:**
```diff
-
         TEST_CYCLE() alg->calc(frame0, frame1, flow);
 
         CPU_SANITY_CHECK(flow);
@@ -389,7 +388,7 @@ PERF_TEST_P(ImagePair, OpticalFlowDual_TVL1,
 // OpticalFlowBM
 
 PERF_TEST_P(ImagePair, OpticalFlowBM,
-            Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
+    Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
 {
```

Review comment:
Please also remove the following line in the begging of the file: ``` #include "opencv2/legacy.hpp" ```
**File:** modules/cudaoptflow/test/test_optflow.cpp
**Change Type:** modified
**Context:** PR #2942: Tvl1 chambolle - I adapted the TVL1 optical flow computation method to accomodate illumination variation according to the method described b...
**Review Line:** 372

**Code Changes:**
```diff
+    EXPECT_MAT_SIMILAR(gold[1], d_flowy, 4e-3);
+    d_alg.gamma = 1;
+    alg->set("gamma", 1);
+    d_alg(loadMat(frame0, useRoi), loadMat(frame1, useRoi), d_flowx, d_flowy);
+    alg->calc(frame0, frame1, flow);
+    cv::split(flow, gold);
+    mx = cv::Mat(d_flowx);
+    my = cv::Mat(d_flowx);
 
     EXPECT_MAT_SIMILAR(gold[0], d_flowx, 4e-3);
     EXPECT_MAT_SIMILAR(gold[1], d_flowy, 4e-3);
```

Review comment:
Please also remove the following line in the begging of the file: ``` #include "opencv2/legacy.hpp" ```
**File:** modules/cudaoptflow/perf/perf_optflow.cpp
**Change Type:** modified
**Context:** PR #2942: Tvl1 chambolle - I adapted the TVL1 optical flow computation method to accomodate illumination variation according to the method described b...

**Code Changes:**
```diff
@@ -54,7 +54,7 @@ typedef pair<string, string> pair_string;
 DEF_PARAM_TEST_1(ImagePair, pair_string);
 
 PERF_TEST_P(ImagePair, InterpolateFrames,
-            Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
+    Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
 {
     cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(frame0.empty());
@@ -73,7 +73,7 @@ PERF_TEST_P(ImagePair, InterpolateFrames,
```

Review comment:
Please leave the performance test for CUDA implementation, but remove the call for CPU one and replace it with: ``` FAIL_NO_CPU(); ```
**File:** modules/cudaoptflow/perf/perf_optflow.cpp
**Change Type:** modified
**Context:** PR #2942: Tvl1 chambolle - I adapted the TVL1 optical flow computation method to accomodate illumination variation according to the method described b...

**Code Changes:**
```diff
@@ -54,7 +54,7 @@ typedef pair<string, string> pair_string;
 DEF_PARAM_TEST_1(ImagePair, pair_string);
 
 PERF_TEST_P(ImagePair, InterpolateFrames,
-            Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
+    Values<pair_string>(make_pair("gpu/opticalflow/frame0.png", "gpu/opticalflow/frame1.png")))
 {
     cv::Mat frame0 = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
     ASSERT_FALSE(frame0.empty());
@@ -73,7 +73,7 @@ PERF_TEST_P(ImagePair, InterpolateFrames,
```

Review comment:
I mean leave performance test for CUDA `OpticalFlowBM`. Please restore CPU part for TVL1 performance test.
**File:** modules/core/src/stat.cpp
**Change Type:** modified
**Context:** PR #3003: OCL: Fixed bug in reduce.cl - check_regression=_OCL_Norm_:_OCL_Sum_:_OCL_PSNR* test_filter=_OCL_Norm_:_OCL_Sum_:_OCL_PSNR* test_modules=core...
**Review Line:** 485

**Code Changes:**
```diff
     int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type),
-            kercn = cn == 1 && !haveMask ? ocl::predictOptimalVectorWidth(_src) : 1,
+            kercn = cn == 1 && !haveMask ? ocl::predictOptimalVectorWidth(_src, _src2) : 1,
             mcn = std::max(cn, kercn);
     CV_Assert(!haveSrc2 || _src2.type() == type);
+    int convert_cn = haveSrc2 ? mcn : cn;
 
     if ( (!doubleSupport && depth == CV_64F) || cn > 4 )
         return false;
@@ -513,7 +514,7 @@ static bool ocl_sum( InputArray _src, Scalar & res, int sum_op, InputArray _mask
                          haveMask && _mask.isContinuous() ? " -D HAVE_MASK_CONT" : "", kercn,
```

Review comment:
Can we use `ocl::predictOptimalVectorWidth(_src1, _src2)` in this case?
**File:** modules/imgproc/test/ocl/test_histogram.cpp
**Change Type:** modified
**Context:** PR #3050: OCL: fixed some ocl tests from imgproc (test_loop_times = 30) - fixed tests for: - Filter2D - MatchTemplate - CalcBackProject test_modules=i...

**Code Changes:**
```diff
@@ -99,6 +99,10 @@ PARAM_TEST_CASE(CalcBackProject, MatDepth, int, bool)
         Size roiSize = randomSize(1, MAX_VALUE);
 
         int totalChannels = 0;
+
+        ranges.clear();
+        channels.clear();
+
         for (int i = 0; i < N; ++i)
         {
```

Review comment:
`dstSize.area()` would be better.
**File:** modules/imgproc/src/morph.cpp
**Change Type:** modified
**Context:** PR #3011: OCL: Optimize OpenCL version of morphology and box filters for small filter kernels - Optimization: optimization effort for morph kernel, th...

**Code Changes:**
```diff
@@ -1339,22 +1339,190 @@ static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
 
 #ifdef HAVE_OPENCL
 
+#define ROUNDUP(sz, n)      ((sz) + (n) - 1 - (((sz) + (n) - 1) % (n)))
+
+static bool ocl_morphSmall( InputArray _src, OutputArray _dst, InputArray _kernel, Point anchor, int borderType,
+                            int op, int actual_op = -1, InputArray _extraMat = noArray())
+{
+    const ocl::Device & dev = ocl::Device::getDefault();
```

Review comment:
Please, remove commented code
**File:** modules/imgproc/src/morph.cpp
**Change Type:** modified
**Context:** PR #3011: OCL: Optimize OpenCL version of morphology and box filters for small filter kernels - Optimization: optimization effort for morph kernel, th...

**Code Changes:**
```diff
@@ -1339,22 +1339,190 @@ static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
 
 #ifdef HAVE_OPENCL
 
+#define ROUNDUP(sz, n)      ((sz) + (n) - 1 - (((sz) + (n) - 1) % (n)))
+
+static bool ocl_morphSmall( InputArray _src, OutputArray _dst, InputArray _kernel, Point anchor, int borderType,
+                            int op, int actual_op = -1, InputArray _extraMat = noArray())
+{
+    const ocl::Device & dev = ocl::Device::getDefault();
```

Review comment:
This `CV_Assert` is better to move to the beginning of the function.
**File:** modules/imgproc/src/morph.cpp
**Change Type:** modified
**Context:** PR #3011: OCL: Optimize OpenCL version of morphology and box filters for small filter kernels - Optimization: optimization effort for morph kernel, th...

**Code Changes:**
```diff
@@ -1339,22 +1339,190 @@ static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
 
 #ifdef HAVE_OPENCL
 
+#define ROUNDUP(sz, n)      ((sz) + (n) - 1 - (((sz) + (n) - 1) % (n)))
+
+static bool ocl_morphSmall( InputArray _src, OutputArray _dst, InputArray _kernel, Point anchor, int borderType,
+                            int op, int actual_op = -1, InputArray _extraMat = noArray())
+{
+    const ocl::Device & dev = ocl::Device::getDefault();
```

Review comment:
It is better to call `CV_Assert(actual_op <= 3 || haveExtraMat);` before `ocl_morphSmall`. And maybe check `if ((depth == CV_64F && !doubleSupport))`.
**File:** modules/imgproc/src/morph.cpp
**Change Type:** modified
**Context:** PR #3011: OCL: Optimize OpenCL version of morphology and box filters for small filter kernels - Optimization: optimization effort for morph kernel, th...
**Review Line:** 1510

**Code Changes:**
```diff
+            cn = CV_MAT_CN(type), esz = CV_ELEM_SIZE(type);
+    Mat kernel = _kernel.getMat();
+    Size ksize = kernel.data ? kernel.size() : Size(3, 3), ssize = _src.size();
 
+    bool doubleSupport = dev.doubleFPConfig() > 0;
     if ((depth == CV_64F && !doubleSupport) || borderType != BORDER_CONSTANT)
         return false;
 
-    Mat kernel = _kernel.getMat();
     bool haveExtraMat = !_extraMat.empty();
-    Size ksize = kernel.data ? kernel.size() : Size(3, 3), ssize = _src.size();
```

Review comment:
In my opinion `if (borderType != BORDER_CONSTANT)` must be after call ocl_morphSmall.
**File:** modules/imgproc/src/morph.cpp
**Change Type:** modified
**Context:** PR #3011: OCL: Optimize OpenCL version of morphology and box filters for small filter kernels - Optimization: optimization effort for morph kernel, th...
**Review Line:** 1510

**Code Changes:**
```diff
+            cn = CV_MAT_CN(type), esz = CV_ELEM_SIZE(type);
+    Mat kernel = _kernel.getMat();
+    Size ksize = kernel.data ? kernel.size() : Size(3, 3), ssize = _src.size();
 
+    bool doubleSupport = dev.doubleFPConfig() > 0;
     if ((depth == CV_64F && !doubleSupport) || borderType != BORDER_CONSTANT)
         return false;
 
-    Mat kernel = _kernel.getMat();
     bool haveExtraMat = !_extraMat.empty();
-    Size ksize = kernel.data ? kernel.size() : Size(3, 3), ssize = _src.size();
```

Review comment:
It does not matter, we call ocl version of morphology only with `borderType == cv::BORDER_CONSTANT`.
**File:** modules/imgproc/src/opencl/cvtcolor.cl
**Change Type:** modified
**Context:** PR #3027: Fix Luv2RGB function - Merge with Itseez/opencv_extra#200

**Code Changes:**
```diff
@@ -441,18 +441,18 @@ __kernel void YCrCb2RGB(__global const uchar* src, int src_step, int src_offset,
                 __global DATA_TYPE * dstptr = (__global DATA_TYPE*)(dst + dst_index);
 
                 DATA_TYPE_4 src_pix = vload4(0, srcptr);
-                DATA_TYPE y = src_pix.x, cr = src_pix.y, cb = src_pix.z;
+                DATA_TYPE yp = src_pix.x, cr = src_pix.y, cb = src_pix.z;
 
 #ifdef DEPTH_5
                 __constant float * coeff = c_YCrCb2RGBCoeffs_f;
-                float r = fma(coeff[0], cr - HALF_MAX, y);
```

Review comment:
Please use `clamp` here and below
**File:** modules/imgproc/src/floodfill.cpp
**Change Type:** modified
**Context:** PR #3093: GCC 4.8 warning array subscript is above array bounds fixed.

**Code Changes:**
```diff
@@ -470,6 +470,12 @@ cvFloodFill( CvArr* arr, CvPoint seed_point,
     depth = CV_MAT_DEPTH(type);
     cn = CV_MAT_CN(type);
 
+    if ( (cn != 1) && (cn != 3) )
+    {
+        CV_Error( CV_StsBadArg, "Number of channels in input image must be 1 or 3" );
+        return;
+    }
+
```

Review comment:
It's not a flag.
**File:** modules/imgproc/src/floodfill.cpp
**Change Type:** modified
**Context:** PR #3093: GCC 4.8 warning array subscript is above array bounds fixed.

**Code Changes:**
```diff
@@ -470,6 +470,12 @@ cvFloodFill( CvArr* arr, CvPoint seed_point,
     depth = CV_MAT_DEPTH(type);
     cn = CV_MAT_CN(type);
 
+    if ( (cn != 1) && (cn != 3) )
+    {
+        CV_Error( CV_StsBadArg, "Number of channels in input image must be 1 or 3" );
+        return;
+    }
+
```

Review comment:
Wouldn't 3 also work? I can see below that `Scalar`s are indexed with 0..`cn`, meaning `cn` has to be in [0..3], which I presume is what triggers the warning. Is there another constraint that prohibits 3?
**File:** modules/imgproc/src/floodfill.cpp
**Change Type:** modified
**Context:** PR #3093: GCC 4.8 warning array subscript is above array bounds fixed.

**Code Changes:**
```diff
@@ -470,6 +470,12 @@ cvFloodFill( CvArr* arr, CvPoint seed_point,
     depth = CV_MAT_DEPTH(type);
     cn = CV_MAT_CN(type);
 
+    if ( (cn != 1) && (cn != 3) )
+    {
+        CV_Error( CV_StsBadArg, "Number of channels in input image must be 1 or 3" );
+        return;
+    }
+
```

Review comment:
There is explicit data type check in code bellow and it handles 1 and 3 channel images. I'll change condition on more accurate here.
**File:** modules/imgproc/src/floodfill.cpp
**Change Type:** modified
**Context:** PR #3093: GCC 4.8 warning array subscript is above array bounds fixed.

**Code Changes:**
```diff
@@ -470,6 +470,12 @@ cvFloodFill( CvArr* arr, CvPoint seed_point,
     depth = CV_MAT_DEPTH(type);
     cn = CV_MAT_CN(type);
 
+    if ( (cn != 1) && (cn != 3) )
+    {
+        CV_Error( CV_StsBadArg, "Number of channels in input image must be 1 or 3" );
+        return;
+    }
+
```

Review comment:
For the record, when I said 3, I meant 4, and when I said [0..3] I meant [1..4].
**File:** modules/imgproc/src/clahe.cpp
**Change Type:** modified
**Context:** PR #3033: CPU (non-OpenCL) CLAHE Support for CV_16UC1 Images - The CPU implementation (non-OpenCL) implementation algorithm now supports image types o...

**Code Changes:**
```diff
@@ -126,10 +126,11 @@ namespace clahe
 
 namespace
 {
+    template <class T, int histSize, int shift>
     class CLAHE_CalcLut_Body : public cv::ParallelLoopBody
     {
     public:
-        CLAHE_CalcLut_Body(const cv::Mat& src, cv::Mat& lut, cv::Size tileSize, int tilesX, int clipLimit, float lutScale) :
+        CLAHE_CalcLut_Body(const cv::Mat& src, const cv::Mat& lut, const cv::Size& tileSize, const int& tilesX, const int& clipLimit, const float& lutScale) :
```

Review comment:
1. this will degrade the speed of 8u version quite a bit. 2. the code is not correct. Assume that the image covers not the entire value range, say, from 0 to 128. Then binSize will be 0 and the results will be completely wrong. 3. even for 16-bit images it would probably be better to have fixed-size histogram (say, including 4096 bins or something like that).
**File:** modules/imgproc/src/clahe.cpp
**Change Type:** modified
**Context:** PR #3033: CPU (non-OpenCL) CLAHE Support for CV_16UC1 Images - The CPU implementation (non-OpenCL) implementation algorithm now supports image types o...

**Code Changes:**
```diff
@@ -126,10 +126,11 @@ namespace clahe
 
 namespace
 {
+    template <class T, int histSize, int shift>
     class CLAHE_CalcLut_Body : public cv::ParallelLoopBody
     {
     public:
-        CLAHE_CalcLut_Body(const cv::Mat& src, cv::Mat& lut, cv::Size tileSize, int tilesX, int clipLimit, float lutScale) :
+        CLAHE_CalcLut_Body(const cv::Mat& src, const cv::Mat& lut, const cv::Size& tileSize, const int& tilesX, const int& clipLimit, const float& lutScale) :
```

Review comment:
this is another quite severe performance degradation. Division is very slow operation and you perform it in the inner-most loop. And for 8u it's not needed at all. I suggest to completely revise this part, make sure that 8u version performance does not degrade
**File:** modules/imgproc/src/clahe.cpp
**Change Type:** modified
**Context:** PR #3033: CPU (non-OpenCL) CLAHE Support for CV_16UC1 Images - The CPU implementation (non-OpenCL) implementation algorithm now supports image types o...

**Code Changes:**
```diff
@@ -126,10 +126,11 @@ namespace clahe
 
 namespace
 {
+    template <class T, int histSize, int shift>
     class CLAHE_CalcLut_Body : public cv::ParallelLoopBody
     {
     public:
-        CLAHE_CalcLut_Body(const cv::Mat& src, cv::Mat& lut, cv::Size tileSize, int tilesX, int clipLimit, float lutScale) :
+        CLAHE_CalcLut_Body(const cv::Mat& src, const cv::Mat& lut, const cv::Size& tileSize, const int& tilesX, const int& clipLimit, const float& lutScale) :
```

Review comment:
here the division is missing, thus in the case of 16-bit images with width not divisible by 4 you will likely get heap corruption
**File:** modules/imgproc/src/clahe.cpp
**Change Type:** modified
**Context:** PR #3033: CPU (non-OpenCL) CLAHE Support for CV_16UC1 Images - The CPU implementation (non-OpenCL) implementation algorithm now supports image types o...

**Code Changes:**
```diff
@@ -126,10 +126,11 @@ namespace clahe
 
 namespace
 {
+    template <class T, int histSize, int shift>
     class CLAHE_CalcLut_Body : public cv::ParallelLoopBody
     {
     public:
-        CLAHE_CalcLut_Body(const cv::Mat& src, cv::Mat& lut, cv::Size tileSize, int tilesX, int clipLimit, float lutScale) :
+        CLAHE_CalcLut_Body(const cv::Mat& src, const cv::Mat& lut, const cv::Size& tileSize, const int& tilesX, const int& clipLimit, const float& lutScale) :
```

Review comment:
memory allocation inside the loop is not a good idea. Since you chose the histSize to always be 256, I suggest to leave the line as-is
**File:** modules/imgproc/src/clahe.cpp
**Change Type:** modified
**Context:** PR #3033: CPU (non-OpenCL) CLAHE Support for CV_16UC1 Images - The CPU implementation (non-OpenCL) implementation algorithm now supports image types o...

**Code Changes:**
```diff
@@ -126,10 +126,11 @@ namespace clahe
 
 namespace
 {
+    template <class T, int histSize, int shift>
     class CLAHE_CalcLut_Body : public cv::ParallelLoopBody
     {
     public:
-        CLAHE_CalcLut_Body(const cv::Mat& src, cv::Mat& lut, cv::Size tileSize, int tilesX, int clipLimit, float lutScale) :
+        CLAHE_CalcLut_Body(const cv::Mat& src, const cv::Mat& lut, const cv::Size& tileSize, const int& tilesX, const int& clipLimit, const float& lutScale) :
```

Review comment:
please, use smart pointer cv::Ptr&lt;&gt; instead of plain pointer.
**File:** modules/imgproc/src/clahe.cpp
**Change Type:** modified
**Context:** PR #3033: CPU (non-OpenCL) CLAHE Support for CV_16UC1 Images - The CPU implementation (non-OpenCL) implementation algorithm now supports image types o...

**Code Changes:**
```diff
@@ -126,10 +126,11 @@ namespace clahe
 
 namespace
 {
+    template <class T, int histSize, int shift>
     class CLAHE_CalcLut_Body : public cv::ParallelLoopBody
     {
     public:
-        CLAHE_CalcLut_Body(const cv::Mat& src, cv::Mat& lut, cv::Size tileSize, int tilesX, int clipLimit, float lutScale) :
+        CLAHE_CalcLut_Body(const cv::Mat& src, const cv::Mat& lut, const cv::Size& tileSize, const int& tilesX, const int& clipLimit, const float& lutScale) :
```

Review comment:
correspondingly, use makePtr&lt;&gt; template function to create the smart pointer
**File:** modules/imgproc/src/clahe.cpp
**Change Type:** modified
**Context:** PR #3033: CPU (non-OpenCL) CLAHE Support for CV_16UC1 Images - The CPU implementation (non-OpenCL) implementation algorithm now supports image types o...

**Code Changes:**
```diff
@@ -126,10 +126,11 @@ namespace clahe
 
 namespace
 {
+    template <class T, int histSize, int shift>
     class CLAHE_CalcLut_Body : public cv::ParallelLoopBody
     {
     public:
-        CLAHE_CalcLut_Body(const cv::Mat& src, cv::Mat& lut, cv::Size tileSize, int tilesX, int clipLimit, float lutScale) :
+        CLAHE_CalcLut_Body(const cv::Mat& src, const cv::Mat& lut, const cv::Size& tileSize, const int& tilesX, const int& clipLimit, const float& lutScale) :
```

Review comment:
this should be removed once you switch to smart pointers
**File:** modules/imgproc/src/clahe.cpp
**Change Type:** modified
**Context:** PR #3033: CPU (non-OpenCL) CLAHE Support for CV_16UC1 Images - The CPU implementation (non-OpenCL) implementation algorithm now supports image types o...

**Code Changes:**
```diff
@@ -126,10 +126,11 @@ namespace clahe
 
 namespace
 {
+    template <class T, int histSize, int shift>
     class CLAHE_CalcLut_Body : public cv::ParallelLoopBody
     {
     public:
-        CLAHE_CalcLut_Body(const cv::Mat& src, cv::Mat& lut, cv::Size tileSize, int tilesX, int clipLimit, float lutScale) :
+        CLAHE_CalcLut_Body(const cv::Mat& src, const cv::Mat& lut, const cv::Size& tileSize, const int& tilesX, const int& clipLimit, const float& lutScale) :
```

Review comment:
please, use makePtr&lt;CLAHE_CalcLut_Body&lt;uchar, 256, 0&gt; &gt;(srcForLut, ...)
**File:** modules/imgproc/src/clahe.cpp
**Change Type:** modified
**Context:** PR #3033: CPU (non-OpenCL) CLAHE Support for CV_16UC1 Images - The CPU implementation (non-OpenCL) implementation algorithm now supports image types o...

**Code Changes:**
```diff
@@ -126,10 +126,11 @@ namespace clahe
 
 namespace
 {
+    template <class T, int histSize, int shift>
     class CLAHE_CalcLut_Body : public cv::ParallelLoopBody
     {
     public:
-        CLAHE_CalcLut_Body(const cv::Mat& src, cv::Mat& lut, cv::Size tileSize, int tilesX, int clipLimit, float lutScale) :
+        CLAHE_CalcLut_Body(const cv::Mat& src, const cv::Mat& lut, const cv::Size& tileSize, const int& tilesX, const int& clipLimit, const float& lutScale) :
```

Review comment:
please, use lut_.step/sizeof(T)
**File:** modules/imgproc/src/clahe.cpp
**Change Type:** modified
**Context:** PR #3033: CPU (non-OpenCL) CLAHE Support for CV_16UC1 Images - The CPU implementation (non-OpenCL) implementation algorithm now supports image types o...

**Code Changes:**
```diff
@@ -126,10 +126,11 @@ namespace clahe
 
 namespace
 {
+    template <class T, int histSize, int shift>
     class CLAHE_CalcLut_Body : public cv::ParallelLoopBody
     {
     public:
-        CLAHE_CalcLut_Body(const cv::Mat& src, cv::Mat& lut, cv::Size tileSize, int tilesX, int clipLimit, float lutScale) :
+        CLAHE_CalcLut_Body(const cv::Mat& src, const cv::Mat& lut, const cv::Size& tileSize, const int& tilesX, const int& clipLimit, const float& lutScale) :
```

Review comment:
use src_.step/sizeof(T)