Merge remote-tracking branch 'upstream/3.4' into merge-3.4
[platform/upstream/opencv.git] / modules / imgproc / src / smooth.cpp
index 8cef382..f407752 100644 (file)
@@ -1709,6 +1709,7 @@ void cv::sqrBoxFilter( InputArray _src, OutputArray _dst, int ddepth,
 
 cv::Mat cv::getGaussianKernel( int n, double sigma, int ktype )
 {
+    CV_Assert(n > 0);
     const int SMALL_GAUSSIAN_SIZE = 7;
     static const float small_gaussian_tab[][SMALL_GAUSSIAN_SIZE] =
     {
@@ -1747,6 +1748,7 @@ cv::Mat cv::getGaussianKernel( int n, double sigma, int ktype )
         }
     }
 
+    CV_DbgAssert(fabs(sum) > 0);
     sum = 1./sum;
     for( i = 0; i < n; i++ )
     {
@@ -3614,9 +3616,9 @@ public:
     virtual void operator() (const Range& range) const CV_OVERRIDE
     {
         AutoBuffer<FT> _buf(width*cn*kylen);
-        FT* buf = _buf;
+        FT* buf = _buf.data();
         AutoBuffer<FT*> _ptrs(kylen*2);
-        FT** ptrs = _ptrs;
+        FT** ptrs = _ptrs.data();
 
         if (kylen == 1)
         {
@@ -5329,6 +5331,7 @@ public:
                         wsum += w;
                     }
                     // overflow is not possible here => there is no need to use cv::saturate_cast
+                    CV_DbgAssert(fabs(wsum) > 0);
                     dptr[j] = (uchar)cvRound(sum/wsum);
                 }
             }
@@ -5414,6 +5417,7 @@ public:
                         sum_b += b*w; sum_g += g*w; sum_r += r*w;
                         wsum += w;
                     }
+                    CV_DbgAssert(fabs(wsum) > 0);
                     wsum = 1.f/wsum;
                     b0 = cvRound(sum_b*wsum);
                     g0 = cvRound(sum_g*wsum);
@@ -5673,6 +5677,7 @@ public:
                         sum += val*w;
                         wsum += w;
                     }
+                    CV_DbgAssert(fabs(wsum) > 0);
                     dptr[j] = (float)(sum/wsum);
                 }
             }
@@ -5763,6 +5768,7 @@ public:
                         sum_b += b*w; sum_g += g*w; sum_r += r*w;
                         wsum += w;
                     }
+                    CV_DbgAssert(fabs(wsum) > 0);
                     wsum = 1.f/wsum;
                     b0 = sum_b*wsum;
                     g0 = sum_g*wsum;