Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/imgproc/perf/perf_floodfill.cpp
16339 views
1
// This file is part of OpenCV project.
2
// It is subject to the license terms in the LICENSE file found in the top-level directory
3
// of this distribution and at http://opencv.org/license.html.
4
5
// Copyright (C) 2014, Itseez, Inc., all rights reserved.
6
// Third party copyrights are property of their respective owners.
7
8
#include "perf_precomp.hpp"
9
10
namespace opencv_test {
11
12
typedef tuple<string, Point, int, int, int, int> Size_Source_Fl_t;
13
typedef perf::TestBaseWithParam<Size_Source_Fl_t> Size_Source_Fl;
14
15
PERF_TEST_P(Size_Source_Fl, floodFill1, Combine(
16
testing::Values("cv/shared/fruits.png", "cv/optflow/RubberWhale1.png"), //images
17
testing::Values(Point(120, 82), Point(200, 140)), //seed points
18
testing::Values(4,8), //connectivity
19
testing::Values((int)IMREAD_COLOR, (int)IMREAD_GRAYSCALE), //color image, or not
20
testing::Values(0, 1, 2), //use fixed(1), gradient (2) or simple(0) mode
21
testing::Values((int)CV_8U, (int)CV_32F, (int)CV_32S) //image depth
22
))
23
{
24
//test given image(s)
25
string filename = getDataPath(get<0>(GetParam()));
26
Point pseed;
27
pseed = get<1>(GetParam());
28
29
int connectivity = get<2>(GetParam());
30
int colorType = get<3>(GetParam());
31
int modeType = get<4>(GetParam());
32
int imdepth = get<5>(GetParam());
33
34
Mat image0 = imread(filename, colorType);
35
36
Scalar newval, loVal, upVal;
37
if (modeType == 0)
38
{
39
loVal = Scalar(0, 0, 0);
40
upVal = Scalar(0, 0, 0);
41
}
42
else
43
{
44
loVal = Scalar(4, 4, 4);
45
upVal = Scalar(20, 20, 20);
46
}
47
int newMaskVal = 255; //base mask for floodfill type
48
int flags = connectivity + (newMaskVal << 8) + (modeType == 1 ? FLOODFILL_FIXED_RANGE : 0);
49
50
int b = 152;//(unsigned)theRNG() & 255;
51
int g = 136;//(unsigned)theRNG() & 255;
52
int r = 53;//(unsigned)theRNG() & 255;
53
newval = (colorType == IMREAD_COLOR) ? Scalar(b, g, r) : Scalar(r*0.299 + g*0.587 + b*0.114);
54
55
Rect outputRect = Rect();
56
Mat source = Mat();
57
58
for (; next(); )
59
{
60
image0.convertTo(source, imdepth);
61
startTimer();
62
cv::floodFill(source, pseed, newval, &outputRect, loVal, upVal, flags);
63
stopTimer();
64
}
65
EXPECT_EQ(image0.cols, source.cols);
66
EXPECT_EQ(image0.rows, source.rows);
67
SANITY_CHECK_NOTHING();
68
}
69
70
} // namespace
71
72