fixed OpenCL morph operations for case when kernel does not have zero element
authorIlya Lavrenov <ilya.lavrenov@itseez.com>
Mon, 28 Oct 2013 12:46:41 +0000 (16:46 +0400)
committerAlexander Alekhin <alexander.alekhin@itseez.com>
Mon, 28 Oct 2013 16:09:49 +0000 (20:09 +0400)
modules/ocl/src/filtering.cpp

index 954d1d5..4a04e2d 100644 (file)
@@ -416,8 +416,8 @@ void morphOp(int op, const oclMat &src, oclMat &dst, const Mat &_kernel, Point a
     else if (iterations > 1 && countNonZero(_kernel) == _kernel.rows * _kernel.cols)
     {
         anchor = Point(anchor.x * iterations, anchor.y * iterations);
-        kernel = getStructuringElement(MORPH_RECT, Size(ksize.width + iterations * (ksize.width - 1),
-                                       ksize.height + iterations * (ksize.height - 1)), anchor);
+        kernel = getStructuringElement(MORPH_RECT, Size(ksize.width + (iterations - 1) * (ksize.width - 1),
+                                       ksize.height + (iterations - 1) * (ksize.height - 1)), anchor);
         iterations = 1;
     }
     else