--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// 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.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "precomp.hpp"
+
+namespace cv
+{
+
+void spatialGradient( InputArray src, OutputArray dx, OutputArray dy, int ksize )
+{
+
+ // TODO: Vectorize using hal intrinsics
+ Sobel( src, dx, CV_16S, 1, 0, 3 );
+ Sobel( src, dy, CV_16S, 0, 1, 3 );
+}
+
+}
}
+/////////////// spatialGradient ///////////////
+
+class CV_SpatialGradientTest : public CV_DerivBaseTest
+{
+public:
+ CV_SpatialGradientTest();
+
+protected:
+ void prepare_to_validation( int test_case_idx );
+ void run_func();
+ void get_test_array_types_and_sizes( int test_case_idx,
+ vector<vector<Size> >& sizes, vector<vector<int> >& types );
+ int ksize;
+};
+
+CV_SpatialGradientTest::CV_SpatialGradientTest() {
+ test_array[OUTPUT].push_back(NULL);
+ test_array[REF_OUTPUT].push_back(NULL);
+ inplace = false;
+}
+
+
+void CV_SpatialGradientTest::get_test_array_types_and_sizes( int test_case_idx,
+ vector<vector<Size> >& sizes,
+ vector<vector<int> >& types )
+{
+ CV_DerivBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
+
+ sizes[OUTPUT][1] = sizes[REF_OUTPUT][1] = sizes[OUTPUT][0];
+
+ // Only CV_16S1 for now
+ types[INPUT][0] = types[OUTPUT][0] = types[OUTPUT][1] = types[REF_OUTPUT][0]
+ = types[REF_OUTPUT][1] = CV_MAKETYPE(CV_16S, 1);
+
+ ksize = 3;
+}
+
+
+void CV_SpatialGradientTest::run_func()
+{
+ spatialGradient( cvarrToMat(test_array[INPUT][0]),
+ cvarrToMat(test_array[OUTPUT][0]),
+ cvarrToMat(test_array[OUTPUT][1]),
+ ksize
+ );
+}
+
+
+void CV_SpatialGradientTest::prepare_to_validation( int /*test_case_idx*/ )
+{
+ int dx, dy;
+
+ dx = 1; dy = 0;
+ Sobel( test_mat[INPUT][0], test_mat[REF_OUTPUT][0], CV_16SC1, dx, dy, ksize );
+
+ dx = 0; dy = 1;
+ Sobel( test_mat[INPUT][0], test_mat[REF_OUTPUT][1], CV_16SC1, dx, dy, ksize );
+}
+
+
/////////////// laplace ///////////////
class CV_LaplaceTest : public CV_DerivBaseTest
TEST(Imgproc_MorphologyEx, accuracy) { CV_MorphExTest test; test.safe_run(); }
TEST(Imgproc_Filter2D, accuracy) { CV_FilterTest test; test.safe_run(); }
TEST(Imgproc_Sobel, accuracy) { CV_SobelTest test; test.safe_run(); }
+TEST(Imgproc_SpatialGradient, accuracy) { CV_SpatialGradientTest test; test.safe_run(); }
TEST(Imgproc_Laplace, accuracy) { CV_LaplaceTest test; test.safe_run(); }
TEST(Imgproc_Blur, accuracy) { CV_BlurTest test; test.safe_run(); }
TEST(Imgproc_GaussianBlur, accuracy) { CV_GaussianBlurTest test; test.safe_run(); }