From: Seon-Wook Park Date: Thu, 18 Jun 2015 15:42:32 +0000 (+0200) Subject: spatialGradient: Add test class and Sobel proxy method X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~2388^2~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9f1c641199f639fda3bf91c1338696c25e6604f7;p=platform%2Fupstream%2Fopencv.git spatialGradient: Add test class and Sobel proxy method --- diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index a9fa7ae..c93975e 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -1369,6 +1369,15 @@ CV_EXPORTS_W void Sobel( InputArray src, OutputArray dst, int ddepth, double scale = 1, double delta = 0, int borderType = BORDER_DEFAULT ); +/** @brief TODO + +TODO + + */ + +CV_EXPORTS_W void spatialGradient( InputArray src, OutputArray dx, + OutputArray dy, int ksize ); + /** @brief Calculates the first x- or y- image derivative using Scharr operator. The function computes the first x- or y- spatial image derivative using the Scharr operator. The diff --git a/modules/imgproc/src/spatialgradient.cpp b/modules/imgproc/src/spatialgradient.cpp new file mode 100644 index 0000000..9b1ac89 --- /dev/null +++ b/modules/imgproc/src/spatialgradient.cpp @@ -0,0 +1,56 @@ +/*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 ); +} + +} diff --git a/modules/imgproc/test/test_filter.cpp b/modules/imgproc/test/test_filter.cpp index 9253132..e618c1b 100644 --- a/modules/imgproc/test/test_filter.cpp +++ b/modules/imgproc/test/test_filter.cpp @@ -552,6 +552,66 @@ void CV_SobelTest::prepare_to_validation( int /*test_case_idx*/ ) } +/////////////// 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 >& sizes, vector >& 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 >& sizes, + vector >& 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 @@ -1773,6 +1833,7 @@ TEST(Imgproc_Dilate, accuracy) { CV_DilateTest test; test.safe_run(); } 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(); }