2011-12-24 00:09:53 +08:00
|
|
|
#include "perf_precomp.hpp"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace cv;
|
|
|
|
using namespace perf;
|
2011-12-30 00:46:16 +08:00
|
|
|
using std::tr1::make_tuple;
|
|
|
|
using std::tr1::get;
|
2011-12-24 00:09:53 +08:00
|
|
|
|
|
|
|
CV_ENUM(ThreshType, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV)
|
|
|
|
|
|
|
|
typedef std::tr1::tuple<Size, MatType, ThreshType> Size_MatType_ThreshType_t;
|
|
|
|
typedef perf::TestBaseWithParam<Size_MatType_ThreshType_t> Size_MatType_ThreshType;
|
|
|
|
|
|
|
|
PERF_TEST_P(Size_MatType_ThreshType, threshold,
|
|
|
|
testing::Combine(
|
|
|
|
testing::Values(TYPICAL_MAT_SIZES),
|
|
|
|
testing::Values(CV_8UC1, CV_16SC1),
|
2013-04-15 23:39:49 +08:00
|
|
|
ThreshType::all()
|
2011-12-30 00:46:16 +08:00
|
|
|
)
|
2011-12-24 00:09:53 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int type = get<1>(GetParam());
|
|
|
|
ThreshType threshType = get<2>(GetParam());
|
2011-12-24 00:09:53 +08:00
|
|
|
|
|
|
|
Mat src(sz, type);
|
|
|
|
Mat dst(sz, type);
|
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
double thresh = theRNG().uniform(1, 254);
|
|
|
|
double maxval = theRNG().uniform(1, 254);
|
2011-12-24 00:09:53 +08:00
|
|
|
|
|
|
|
declare.in(src, WARMUP_RNG).out(dst);
|
|
|
|
|
2013-06-14 01:14:42 +08:00
|
|
|
int runs = (sz.width <= 640) ? 40 : 1;
|
2013-02-06 18:53:33 +08:00
|
|
|
TEST_CYCLE_MULTIRUN(runs) threshold(src, dst, thresh, maxval, threshType);
|
2011-12-24 00:09:53 +08:00
|
|
|
|
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef perf::TestBaseWithParam<Size> Size_Only;
|
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
PERF_TEST_P(Size_Only, threshold_otsu, testing::Values(TYPICAL_MAT_SIZES))
|
2011-12-24 00:09:53 +08:00
|
|
|
{
|
|
|
|
Size sz = GetParam();
|
|
|
|
|
|
|
|
Mat src(sz, CV_8UC1);
|
|
|
|
Mat dst(sz, CV_8UC1);
|
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
double maxval = theRNG().uniform(1, 254);
|
2011-12-24 00:09:53 +08:00
|
|
|
|
|
|
|
declare.in(src, WARMUP_RNG).out(dst);
|
|
|
|
|
2013-06-26 19:07:39 +08:00
|
|
|
int runs = 15;
|
|
|
|
TEST_CYCLE_MULTIRUN(runs) threshold(src, dst, 0, maxval, THRESH_BINARY|THRESH_OTSU);
|
2011-12-24 00:09:53 +08:00
|
|
|
|
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|
|
|
|
|
2012-01-16 21:35:16 +08:00
|
|
|
CV_ENUM(AdaptThreshType, THRESH_BINARY, THRESH_BINARY_INV)
|
|
|
|
CV_ENUM(AdaptThreshMethod, ADAPTIVE_THRESH_MEAN_C, ADAPTIVE_THRESH_GAUSSIAN_C)
|
|
|
|
|
|
|
|
typedef std::tr1::tuple<Size, AdaptThreshType, AdaptThreshMethod, int> Size_AdaptThreshType_AdaptThreshMethod_BlockSize_t;
|
|
|
|
typedef perf::TestBaseWithParam<Size_AdaptThreshType_AdaptThreshMethod_BlockSize_t> Size_AdaptThreshType_AdaptThreshMethod_BlockSize;
|
|
|
|
|
|
|
|
PERF_TEST_P(Size_AdaptThreshType_AdaptThreshMethod_BlockSize, adaptiveThreshold,
|
|
|
|
testing::Combine(
|
|
|
|
testing::Values(TYPICAL_MAT_SIZES),
|
2013-04-15 23:39:49 +08:00
|
|
|
AdaptThreshType::all(),
|
|
|
|
AdaptThreshMethod::all(),
|
2012-01-16 21:35:16 +08:00
|
|
|
testing::Values(3, 5)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
AdaptThreshType adaptThreshType = get<1>(GetParam());
|
|
|
|
AdaptThreshMethod adaptThreshMethod = get<2>(GetParam());
|
|
|
|
int blockSize = get<3>(GetParam());
|
|
|
|
|
|
|
|
double maxValue = theRNG().uniform(1, 254);
|
|
|
|
double C = 10.0;
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2012-01-16 21:35:16 +08:00
|
|
|
int type = CV_8UC1;
|
|
|
|
Mat src(sz, type);
|
|
|
|
Mat dst(sz, type);
|
|
|
|
|
|
|
|
declare.in(src, WARMUP_RNG).out(dst);
|
|
|
|
|
|
|
|
TEST_CYCLE() adaptiveThreshold(src, dst, maxValue, adaptThreshMethod, adaptThreshType, blockSize, C);
|
|
|
|
|
|
|
|
SANITY_CHECK(dst);
|
|
|
|
}
|