Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/imgproc/perf/perf_blur.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
#include "perf_precomp.hpp"
5
6
namespace opencv_test {
7
8
typedef tuple<Size, MatType, int> Size_MatType_kSize_t;
9
typedef perf::TestBaseWithParam<Size_MatType_kSize_t> Size_MatType_kSize;
10
11
PERF_TEST_P(Size_MatType_kSize, medianBlur,
12
testing::Combine(
13
testing::Values(szODD, szQVGA, szVGA, sz720p),
14
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1),
15
testing::Values(3, 5)
16
)
17
)
18
{
19
Size size = get<0>(GetParam());
20
int type = get<1>(GetParam());
21
int ksize = get<2>(GetParam());
22
23
Mat src(size, type);
24
Mat dst(size, type);
25
26
declare.in(src, WARMUP_RNG).out(dst);
27
28
if (CV_MAT_DEPTH(type) > CV_16S || CV_MAT_CN(type) > 1)
29
declare.time(15);
30
31
TEST_CYCLE() medianBlur(src, dst, ksize);
32
33
SANITY_CHECK(dst);
34
}
35
36
CV_ENUM(BorderType3x3, BORDER_REPLICATE, BORDER_CONSTANT)
37
CV_ENUM(BorderType, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_REFLECT101)
38
39
typedef tuple<Size, MatType, BorderType3x3> Size_MatType_BorderType3x3_t;
40
typedef perf::TestBaseWithParam<Size_MatType_BorderType3x3_t> Size_MatType_BorderType3x3;
41
42
typedef tuple<Size, MatType, BorderType> Size_MatType_BorderType_t;
43
typedef perf::TestBaseWithParam<Size_MatType_BorderType_t> Size_MatType_BorderType;
44
45
typedef tuple<Size, int, BorderType3x3> Size_ksize_BorderType_t;
46
typedef perf::TestBaseWithParam<Size_ksize_BorderType_t> Size_ksize_BorderType;
47
48
PERF_TEST_P(Size_MatType_BorderType3x3, gaussianBlur3x3,
49
testing::Combine(
50
testing::Values(szODD, szQVGA, szVGA, sz720p),
51
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1),
52
BorderType3x3::all()
53
)
54
)
55
{
56
Size size = get<0>(GetParam());
57
int type = get<1>(GetParam());
58
BorderType3x3 btype = get<2>(GetParam());
59
60
Mat src(size, type);
61
Mat dst(size, type);
62
63
declare.in(src, WARMUP_RNG).out(dst);
64
65
TEST_CYCLE() GaussianBlur(src, dst, Size(3,3), 0, 0, btype);
66
67
SANITY_CHECK(dst, 1);
68
}
69
70
PERF_TEST_P(Size_MatType_BorderType3x3, blur3x3,
71
testing::Combine(
72
testing::Values(szODD, szQVGA, szVGA, sz720p),
73
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1),
74
BorderType3x3::all()
75
)
76
)
77
{
78
Size size = get<0>(GetParam());
79
int type = get<1>(GetParam());
80
BorderType3x3 btype = get<2>(GetParam());
81
82
Mat src(size, type);
83
Mat dst(size, type);
84
85
declare.in(src, WARMUP_RNG).out(dst);
86
87
TEST_CYCLE() blur(src, dst, Size(3,3), Point(-1,-1), btype);
88
89
SANITY_CHECK(dst, 1);
90
}
91
92
PERF_TEST_P(Size_MatType_BorderType, blur16x16,
93
testing::Combine(
94
testing::Values(szVGA, sz720p),
95
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1),
96
BorderType::all()
97
)
98
)
99
{
100
Size size = get<0>(GetParam());
101
int type = get<1>(GetParam());
102
BorderType btype = get<2>(GetParam());
103
double eps = 1e-3;
104
105
eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : eps;
106
107
Mat src(size, type);
108
Mat dst(size, type);
109
110
declare.in(src, WARMUP_RNG).out(dst);
111
112
TEST_CYCLE() blur(src, dst, Size(16,16), Point(-1,-1), btype);
113
114
SANITY_CHECK(dst, eps);
115
}
116
117
PERF_TEST_P(Size_MatType_BorderType3x3, box3x3,
118
testing::Combine(
119
testing::Values(szODD, szQVGA, szVGA, sz720p),
120
testing::Values(CV_8UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_32FC3),
121
BorderType3x3::all()
122
)
123
)
124
{
125
Size size = get<0>(GetParam());
126
int type = get<1>(GetParam());
127
BorderType3x3 btype = get<2>(GetParam());
128
129
Mat src(size, type);
130
Mat dst(size, type);
131
132
declare.in(src, WARMUP_RNG).out(dst);
133
134
TEST_CYCLE() boxFilter(src, dst, -1, Size(3,3), Point(-1,-1), false, btype);
135
136
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
137
}
138
139
PERF_TEST_P(Size_ksize_BorderType, box_CV8U_CV16U,
140
testing::Combine(
141
testing::Values(szODD, szQVGA, szVGA, sz720p),
142
testing::Values(3, 5, 15),
143
BorderType3x3::all()
144
)
145
)
146
{
147
Size size = get<0>(GetParam());
148
int ksize = get<1>(GetParam());
149
BorderType3x3 btype = get<2>(GetParam());
150
151
Mat src(size, CV_8UC1);
152
Mat dst(size, CV_16UC1);
153
154
declare.in(src, WARMUP_RNG).out(dst);
155
156
TEST_CYCLE() boxFilter(src, dst, CV_16UC1, Size(ksize, ksize), Point(-1,-1), false, btype);
157
158
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
159
}
160
161
PERF_TEST_P(Size_MatType_BorderType3x3, box3x3_inplace,
162
testing::Combine(
163
testing::Values(szODD, szQVGA, szVGA, sz720p),
164
testing::Values(CV_8UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_32FC3),
165
BorderType3x3::all()
166
)
167
)
168
{
169
Size size = get<0>(GetParam());
170
int type = get<1>(GetParam());
171
BorderType3x3 btype = get<2>(GetParam());
172
173
Mat src(size, type);
174
Mat dst(size, type);
175
176
declare.in(src, WARMUP_RNG).out(dst);
177
178
while(next())
179
{
180
src.copyTo(dst);
181
startTimer();
182
boxFilter(dst, dst, -1, Size(3,3), Point(-1,-1), false, btype);
183
stopTimer();
184
}
185
186
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
187
}
188
189
PERF_TEST_P(Size_MatType_BorderType, gaussianBlur5x5,
190
testing::Combine(
191
testing::Values(szODD, szQVGA, szVGA, sz720p),
192
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1),
193
BorderType::all()
194
)
195
)
196
{
197
Size size = get<0>(GetParam());
198
int type = get<1>(GetParam());
199
BorderType btype = get<2>(GetParam());
200
201
Mat src(size, type);
202
Mat dst(size, type);
203
204
declare.in(src, WARMUP_RNG).out(dst);
205
206
TEST_CYCLE() GaussianBlur(src, dst, Size(5,5), 0, 0, btype);
207
208
SANITY_CHECK(dst, 1);
209
}
210
211
PERF_TEST_P(Size_MatType_BorderType, blur5x5,
212
testing::Combine(
213
testing::Values(szVGA, sz720p),
214
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1, CV_32FC3),
215
BorderType::all()
216
)
217
)
218
{
219
Size size = get<0>(GetParam());
220
int type = get<1>(GetParam());
221
BorderType btype = get<2>(GetParam());
222
223
Mat src(size, type);
224
Mat dst(size, type);
225
226
declare.in(src, WARMUP_RNG).out(dst);
227
228
TEST_CYCLE() blur(src, dst, Size(5,5), Point(-1,-1), btype);
229
230
SANITY_CHECK(dst, 1);
231
}
232
233
} // namespace
234
235