fixed ocl::Laplacian for case when scale != 1
authorIlya Lavrenov <ilya.lavrenov@itseez.com>
Sat, 19 Oct 2013 08:12:16 +0000 (12:12 +0400)
committerIlya Lavrenov <ilya.lavrenov@itseez.com>
Mon, 21 Oct 2013 10:27:34 +0000 (14:27 +0400)
modules/ocl/src/filtering.cpp
modules/ocl/test/test_filters.cpp

index 185bf74..0a2562d 100644 (file)
@@ -1416,7 +1416,7 @@ void cv::ocl::Laplacian(const oclMat &src, oclMat &dst, int ddepth, int ksize, d
 
     CV_Assert(ksize == 1 || ksize == 3);
 
-    static const int K[2][9] =
+    int K[2][9] =
     {
         {0, 1, 0, 1, -4, 1, 0, 1, 0},
         {2, 0, 2, 0, -8, 0, 2, 0, 2}
index 3dcd4c7..86eb8ab 100644 (file)
@@ -128,8 +128,11 @@ OCL_TEST_P(LaplacianTest, Accuracy)
     {
         random_roi();
 
-        Laplacian(src_roi, dst_roi, -1, ksize, 1);
-        ocl::Laplacian(gsrc_roi, gdst_roi, -1, ksize, 1); // TODO scale
+        // border type is used as a scale factor for the Laplacian kernel
+        double scale = static_cast<double>(borderType);
+
+        Laplacian(src_roi, dst_roi, -1, ksize, scale);
+        ocl::Laplacian(gsrc_roi, gdst_roi, -1, ksize, scale);
 
         Near(1e-5);
     }
@@ -371,7 +374,7 @@ INSTANTIATE_TEST_CASE_P(Filter, LaplacianTest, Combine(
                             Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4),
                             Values(1, 3),
                             Values(Size(0, 0)), // not used
-                            Values(0), // not used
+                            Values(1, 2), // value is used as scale factor for kernel
                             Bool()));
 
 INSTANTIATE_TEST_CASE_P(Filter, Erode, Combine(