From c29ea1056dbe7541d2cf9ba364b21ca26ac32e48 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Fri, 23 Dec 2011 16:09:53 +0000 Subject: [PATCH] Added perf test for cv::threshold --- modules/imgproc/perf/perf_threshold.cpp | 62 +++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 modules/imgproc/perf/perf_threshold.cpp diff --git a/modules/imgproc/perf/perf_threshold.cpp b/modules/imgproc/perf/perf_threshold.cpp new file mode 100644 index 0000000000..31d166316d --- /dev/null +++ b/modules/imgproc/perf/perf_threshold.cpp @@ -0,0 +1,62 @@ +#include "perf_precomp.hpp" + +using namespace std; +using namespace cv; +using namespace perf; + +CV_ENUM(ThreshType, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV) + +typedef std::tr1::tuple Size_MatType_ThreshType_t; +typedef perf::TestBaseWithParam Size_MatType_ThreshType; + +PERF_TEST_P(Size_MatType_ThreshType, threshold, + testing::Combine( + testing::Values(TYPICAL_MAT_SIZES), + testing::Values(CV_8UC1, CV_16SC1), + testing::ValuesIn(ThreshType::all()) + ) + ) +{ + + Size sz = std::tr1::get<0>(GetParam()); + int type = std::tr1::get<1>(GetParam()); + ThreshType threshType = std::tr1::get<2>(GetParam()); + + Mat src(sz, type); + Mat dst(sz, type); + + double thresh = cv::theRNG().uniform(1, 254); + double maxval = cv::theRNG().uniform(1, 254); + + declare.in(src, WARMUP_RNG).out(dst); + + TEST_CYCLE(100) + { + cv::threshold(src, dst, thresh, maxval, threshType); + } + + SANITY_CHECK(dst); +} + + +typedef perf::TestBaseWithParam Size_Only; + +PERF_TEST_P(Size_Only, threshold_otsu, testing::Values(TYPICAL_MAT_SIZES) ) +{ + Size sz = GetParam(); + + Mat src(sz, CV_8UC1); + Mat dst(sz, CV_8UC1); + + double maxval = cv::theRNG().uniform(1, 254); + + declare.in(src, WARMUP_RNG).out(dst); + + TEST_CYCLE(100) + { + cv::threshold(src, dst, 0, maxval, THRESH_BINARY|THRESH_OTSU); + } + + SANITY_CHECK(dst); +} +