Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/imgproc/perf/perf_histogram.cpp
16354 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
#include "perf_precomp.hpp"
5
6
namespace opencv_test {
7
8
typedef tuple<Size, MatType> Size_Source_t;
9
typedef TestBaseWithParam<Size_Source_t> Size_Source;
10
typedef TestBaseWithParam<Size> TestMatSize;
11
12
static const float rangeHight = 256.0f;
13
static const float rangeLow = 0.0f;
14
15
PERF_TEST_P(Size_Source, calcHist1d,
16
testing::Combine(testing::Values(sz3MP, sz5MP),
17
testing::Values(CV_8U, CV_16U, CV_32F) )
18
)
19
{
20
Size size = get<0>(GetParam());
21
MatType type = get<1>(GetParam());
22
Mat source(size.height, size.width, type);
23
Mat hist;
24
int channels [] = {0};
25
int histSize [] = {256};
26
int dims = 1;
27
int numberOfImages = 1;
28
29
const float range[] = {rangeLow, rangeHight};
30
const float* ranges[] = {range};
31
32
randu(source, rangeLow, rangeHight);
33
34
declare.in(source);
35
36
TEST_CYCLE_MULTIRUN(3)
37
{
38
calcHist(&source, numberOfImages, channels, Mat(), hist, dims, histSize, ranges);
39
}
40
41
SANITY_CHECK(hist);
42
}
43
44
PERF_TEST_P(Size_Source, calcHist2d,
45
testing::Combine(testing::Values(sz3MP, sz5MP),
46
testing::Values(CV_8UC2, CV_16UC2, CV_32FC2) )
47
)
48
{
49
Size size = get<0>(GetParam());
50
MatType type = get<1>(GetParam());
51
Mat source(size.height, size.width, type);
52
Mat hist;
53
int channels [] = {0, 1};
54
int histSize [] = {256, 256};
55
int dims = 2;
56
int numberOfImages = 1;
57
58
const float r[] = {rangeLow, rangeHight};
59
const float* ranges[] = {r, r};
60
61
randu(source, rangeLow, rangeHight);
62
63
declare.in(source);
64
TEST_CYCLE()
65
{
66
calcHist(&source, numberOfImages, channels, Mat(), hist, dims, histSize, ranges);
67
}
68
69
SANITY_CHECK(hist);
70
}
71
72
PERF_TEST_P(Size_Source, calcHist3d,
73
testing::Combine(testing::Values(sz3MP, sz5MP),
74
testing::Values(CV_8UC3, CV_16UC3, CV_32FC3) )
75
)
76
{
77
Size size = get<0>(GetParam());
78
MatType type = get<1>(GetParam());
79
Mat hist;
80
int channels [] = {0, 1, 2};
81
int histSize [] = {32, 32, 32};
82
int dims = 3;
83
int numberOfImages = 1;
84
Mat source(size.height, size.width, type);
85
86
const float r[] = {rangeLow, rangeHight};
87
const float* ranges[] = {r, r, r};
88
89
randu(source, rangeLow, rangeHight);
90
91
declare.in(source);
92
TEST_CYCLE()
93
{
94
calcHist(&source, numberOfImages, channels, Mat(), hist, dims, histSize, ranges);
95
}
96
97
SANITY_CHECK(hist);
98
}
99
100
#define MatSize TestMatSize
101
PERF_TEST_P(MatSize, equalizeHist,
102
testing::Values(TYPICAL_MAT_SIZES)
103
)
104
{
105
Size size = GetParam();
106
Mat source(size.height, size.width, CV_8U);
107
Mat destination;
108
declare.in(source, WARMUP_RNG);
109
110
TEST_CYCLE()
111
{
112
equalizeHist(source, destination);
113
}
114
115
SANITY_CHECK(destination);
116
}
117
#undef MatSize
118
119
typedef tuple<Size, double> Sz_ClipLimit_t;
120
typedef TestBaseWithParam<Sz_ClipLimit_t> Sz_ClipLimit;
121
122
PERF_TEST_P(Sz_ClipLimit, CLAHE,
123
testing::Combine(testing::Values(::perf::szVGA, ::perf::sz720p, ::perf::sz1080p),
124
testing::Values(0.0, 40.0))
125
)
126
{
127
const Size size = get<0>(GetParam());
128
const double clipLimit = get<1>(GetParam());
129
130
Mat src(size, CV_8UC1);
131
declare.in(src, WARMUP_RNG);
132
133
Ptr<CLAHE> clahe = createCLAHE(clipLimit);
134
Mat dst;
135
136
TEST_CYCLE() clahe->apply(src, dst);
137
138
SANITY_CHECK(dst);
139
}
140
141
} // namespace
142
143