Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
2d5d98ec
Commit
2d5d98ec
authored
May 23, 2018
by
yuki takehara
Committed by
Alexander Alekhin
May 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge pull request #11551 from take1014:filter2d_10683
* Add arguments to dftFilter2D * test: add expected test values
parent
19239169
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
8 deletions
+85
-8
filter.cpp
modules/imgproc/src/filter.cpp
+10
-8
test_filter.cpp
modules/imgproc/test/test_filter.cpp
+75
-0
No files found.
modules/imgproc/src/filter.cpp
View file @
2d5d98ec
...
...
@@ -4643,7 +4643,8 @@ static bool ippFilter2D(int stype, int dtype, int kernel_type,
static
bool
dftFilter2D
(
int
stype
,
int
dtype
,
int
kernel_type
,
uchar
*
src_data
,
size_t
src_step
,
uchar
*
dst_data
,
size_t
dst_step
,
int
width
,
int
height
,
int
full_width
,
int
full_height
,
int
offset_x
,
int
offset_y
,
uchar
*
kernel_data
,
size_t
kernel_step
,
int
kernel_width
,
int
kernel_height
,
int
anchor_x
,
int
anchor_y
,
...
...
@@ -4666,8 +4667,8 @@ static bool dftFilter2D(int stype, int dtype, int kernel_type,
Point
anchor
=
Point
(
anchor_x
,
anchor_y
);
Mat
kernel
=
Mat
(
Size
(
kernel_width
,
kernel_height
),
kernel_type
,
kernel_data
,
kernel_step
);
Mat
src
(
Size
(
width
,
height
),
stype
,
src_data
,
src_step
);
Mat
dst
(
Size
(
width
,
height
),
dtype
,
dst_data
,
dst_step
);
Mat
src
(
Size
(
full_width
-
offset_x
,
full_height
-
offset_y
),
stype
,
src_data
,
src_step
);
Mat
dst
(
Size
(
full_width
,
full_
height
),
dtype
,
dst_data
,
dst_step
);
Mat
temp
;
int
src_channels
=
CV_MAT_CN
(
stype
);
int
dst_channels
=
CV_MAT_CN
(
dtype
);
...
...
@@ -4680,10 +4681,10 @@ static bool dftFilter2D(int stype, int dtype, int kernel_type,
// we just use that.
int
corrDepth
=
ddepth
;
if
((
ddepth
==
CV_32F
||
ddepth
==
CV_64F
)
&&
src_data
!=
dst_data
)
{
temp
=
Mat
(
Size
(
width
,
height
),
dtype
,
dst_data
,
dst_step
);
temp
=
Mat
(
Size
(
full_width
,
full_
height
),
dtype
,
dst_data
,
dst_step
);
}
else
{
corrDepth
=
ddepth
==
CV_64F
?
CV_64F
:
CV_32F
;
temp
.
create
(
Size
(
width
,
height
),
CV_MAKETYPE
(
corrDepth
,
dst_channels
));
temp
.
create
(
Size
(
full_width
,
full_
height
),
CV_MAKETYPE
(
corrDepth
,
dst_channels
));
}
crossCorr
(
src
,
kernel
,
temp
,
src
.
size
(),
CV_MAKETYPE
(
corrDepth
,
src_channels
),
...
...
@@ -4694,9 +4695,9 @@ static bool dftFilter2D(int stype, int dtype, int kernel_type,
}
}
else
{
if
(
src_data
!=
dst_data
)
temp
=
Mat
(
Size
(
width
,
height
),
dtype
,
dst_data
,
dst_step
);
temp
=
Mat
(
Size
(
full_width
,
full_
height
),
dtype
,
dst_data
,
dst_step
);
else
temp
.
create
(
Size
(
width
,
height
),
dtype
);
temp
.
create
(
Size
(
full_width
,
full_
height
),
dtype
);
crossCorr
(
src
,
kernel
,
temp
,
src
.
size
(),
CV_MAKETYPE
(
ddepth
,
src_channels
),
anchor
,
delta
,
borderType
);
...
...
@@ -4830,7 +4831,8 @@ void filter2D(int stype, int dtype, int kernel_type,
res
=
dftFilter2D
(
stype
,
dtype
,
kernel_type
,
src_data
,
src_step
,
dst_data
,
dst_step
,
width
,
height
,
full_width
,
full_height
,
offset_x
,
offset_y
,
kernel_data
,
kernel_step
,
kernel_width
,
kernel_height
,
anchor_x
,
anchor_y
,
...
...
modules/imgproc/test/test_filter.cpp
View file @
2d5d98ec
...
...
@@ -2119,4 +2119,79 @@ TEST(Imgproc_MorphEx, hitmiss_zero_kernel)
ASSERT_DOUBLE_EQ
(
cvtest
::
norm
(
dst
,
src
,
NORM_INF
),
0.
);
}
TEST
(
Imgproc_Filter2D
,
dftFilter2d_regression_10683
)
{
uchar
src_
[
24
*
24
]
=
{
0
,
40
,
0
,
0
,
255
,
0
,
0
,
78
,
131
,
0
,
196
,
0
,
255
,
0
,
0
,
0
,
0
,
255
,
70
,
0
,
255
,
0
,
0
,
0
,
0
,
0
,
255
,
204
,
0
,
0
,
255
,
93
,
255
,
0
,
0
,
255
,
12
,
0
,
0
,
0
,
255
,
121
,
0
,
255
,
0
,
0
,
0
,
255
,
0
,
178
,
0
,
25
,
67
,
0
,
165
,
0
,
255
,
0
,
0
,
181
,
151
,
175
,
0
,
0
,
32
,
0
,
0
,
255
,
165
,
93
,
0
,
255
,
255
,
255
,
0
,
0
,
255
,
126
,
0
,
0
,
0
,
0
,
133
,
29
,
9
,
0
,
220
,
255
,
0
,
142
,
255
,
255
,
255
,
0
,
255
,
0
,
255
,
32
,
255
,
0
,
13
,
237
,
0
,
0
,
0
,
0
,
0
,
19
,
90
,
0
,
0
,
85
,
122
,
62
,
95
,
29
,
255
,
20
,
0
,
0
,
0
,
0
,
166
,
41
,
0
,
48
,
70
,
0
,
68
,
0
,
255
,
0
,
139
,
7
,
63
,
144
,
0
,
204
,
0
,
0
,
0
,
98
,
114
,
255
,
105
,
0
,
0
,
0
,
0
,
255
,
91
,
0
,
73
,
0
,
255
,
0
,
0
,
0
,
255
,
198
,
21
,
0
,
0
,
0
,
255
,
43
,
153
,
128
,
0
,
98
,
26
,
0
,
101
,
0
,
0
,
0
,
255
,
0
,
0
,
0
,
255
,
77
,
56
,
0
,
241
,
0
,
169
,
132
,
0
,
255
,
186
,
255
,
255
,
87
,
0
,
1
,
0
,
0
,
10
,
39
,
120
,
0
,
23
,
69
,
207
,
0
,
0
,
0
,
0
,
84
,
0
,
0
,
0
,
0
,
255
,
0
,
255
,
0
,
0
,
136
,
255
,
77
,
247
,
0
,
67
,
0
,
15
,
255
,
0
,
143
,
0
,
243
,
255
,
0
,
0
,
238
,
255
,
0
,
255
,
8
,
42
,
0
,
0
,
255
,
29
,
0
,
0
,
0
,
255
,
255
,
255
,
75
,
0
,
0
,
0
,
255
,
0
,
0
,
255
,
38
,
197
,
0
,
255
,
87
,
0
,
123
,
17
,
0
,
234
,
0
,
0
,
149
,
0
,
0
,
255
,
16
,
0
,
0
,
0
,
255
,
0
,
255
,
0
,
38
,
0
,
114
,
255
,
76
,
0
,
0
,
8
,
0
,
255
,
0
,
0
,
0
,
220
,
0
,
11
,
255
,
0
,
0
,
55
,
98
,
0
,
0
,
0
,
255
,
0
,
175
,
255
,
110
,
235
,
0
,
175
,
0
,
255
,
227
,
38
,
206
,
0
,
0
,
255
,
246
,
0
,
0
,
123
,
183
,
255
,
0
,
0
,
255
,
0
,
156
,
0
,
54
,
0
,
255
,
0
,
202
,
0
,
0
,
0
,
0
,
157
,
0
,
255
,
63
,
0
,
0
,
0
,
0
,
0
,
255
,
132
,
0
,
255
,
0
,
0
,
0
,
0
,
0
,
0
,
255
,
0
,
0
,
128
,
126
,
0
,
243
,
46
,
7
,
0
,
211
,
108
,
166
,
0
,
0
,
162
,
227
,
0
,
204
,
0
,
51
,
255
,
216
,
0
,
0
,
43
,
0
,
255
,
40
,
188
,
188
,
255
,
0
,
0
,
255
,
34
,
0
,
0
,
168
,
0
,
0
,
0
,
35
,
0
,
0
,
0
,
80
,
131
,
255
,
0
,
255
,
10
,
0
,
0
,
0
,
180
,
255
,
209
,
255
,
173
,
34
,
0
,
66
,
0
,
49
,
0
,
255
,
83
,
0
,
0
,
204
,
0
,
91
,
0
,
0
,
0
,
205
,
84
,
0
,
0
,
0
,
92
,
255
,
91
,
0
,
126
,
0
,
185
,
145
,
0
,
0
,
9
,
0
,
255
,
0
,
0
,
255
,
255
,
0
,
0
,
255
,
0
,
0
,
216
,
0
,
187
,
221
,
0
,
0
,
141
,
0
,
0
,
209
,
0
,
0
,
255
,
0
,
255
,
0
,
0
,
154
,
150
,
0
,
0
,
0
,
148
,
0
,
201
,
255
,
0
,
255
,
16
,
0
,
0
,
160
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
255
,
0
,
255
,
0
,
255
,
0
,
255
,
198
,
255
,
147
,
131
,
0
,
255
,
202
,
0
,
0
,
0
,
0
,
255
,
0
,
0
,
0
,
0
,
164
,
181
,
0
,
0
,
0
,
69
,
255
,
31
,
0
,
255
,
195
,
0
,
0
,
255
,
164
,
109
,
0
,
0
,
202
,
0
,
206
,
0
,
0
,
61
,
235
,
33
,
255
,
77
,
0
,
0
,
0
,
0
,
85
,
0
,
228
,
0
,
0
,
0
,
0
,
255
,
0
,
0
,
5
,
255
,
255
};
Mat_
<
uchar
>
src
(
24
,
24
,
src_
);
Mat
dst
=
Mat
::
zeros
(
src
.
size
(),
src
.
type
());
int
sz
=
12
,
size2
=
sz
*
sz
;
Mat
kernel
=
Mat
::
ones
(
sz
,
sz
,
CV_32F
)
/
size2
;
uchar
expected_
[
24
*
24
]
=
{
83
,
83
,
77
,
80
,
76
,
76
,
76
,
75
,
71
,
67
,
72
,
71
,
73
,
70
,
80
,
83
,
86
,
84
,
89
,
88
,
88
,
96
,
99
,
98
,
83
,
83
,
77
,
80
,
76
,
76
,
76
,
75
,
71
,
67
,
72
,
71
,
73
,
70
,
80
,
83
,
86
,
84
,
89
,
88
,
88
,
96
,
99
,
98
,
82
,
82
,
77
,
80
,
77
,
75
,
74
,
75
,
70
,
68
,
71
,
72
,
72
,
72
,
82
,
84
,
88
,
88
,
93
,
92
,
93
,
100
,
105
,
104
,
76
,
76
,
72
,
77
,
73
,
74
,
73
,
74
,
69
,
68
,
71
,
71
,
73
,
72
,
82
,
81
,
86
,
87
,
92
,
91
,
92
,
98
,
103
,
102
,
75
,
75
,
72
,
77
,
73
,
72
,
75
,
76
,
74
,
71
,
73
,
75
,
76
,
72
,
81
,
80
,
85
,
87
,
90
,
89
,
90
,
97
,
102
,
97
,
74
,
74
,
71
,
77
,
72
,
74
,
77
,
76
,
74
,
72
,
74
,
76
,
77
,
76
,
84
,
83
,
85
,
87
,
90
,
92
,
93
,
100
,
102
,
99
,
72
,
72
,
69
,
71
,
68
,
73
,
73
,
73
,
70
,
69
,
74
,
72
,
75
,
75
,
81
,
82
,
85
,
87
,
90
,
94
,
96
,
103
,
102
,
101
,
71
,
71
,
68
,
70
,
68
,
71
,
73
,
71
,
69
,
68
,
74
,
72
,
73
,
73
,
81
,
80
,
84
,
89
,
91
,
99
,
102
,
107
,
106
,
105
,
74
,
74
,
70
,
69
,
67
,
73
,
76
,
72
,
69
,
70
,
79
,
75
,
74
,
75
,
82
,
83
,
88
,
91
,
92
,
100
,
104
,
108
,
106
,
105
,
75
,
75
,
71
,
70
,
67
,
75
,
76
,
71
,
67
,
68
,
75
,
72
,
72
,
75
,
81
,
83
,
87
,
89
,
89
,
97
,
102
,
107
,
103
,
103
,
69
,
69
,
67
,
67
,
65
,
72
,
74
,
71
,
70
,
70
,
75
,
74
,
74
,
75
,
80
,
80
,
84
,
85
,
85
,
92
,
96
,
100
,
97
,
97
,
67
,
67
,
67
,
68
,
67
,
77
,
79
,
75
,
74
,
76
,
81
,
78
,
81
,
80
,
84
,
81
,
84
,
83
,
83
,
91
,
94
,
95
,
93
,
93
,
73
,
73
,
71
,
73
,
70
,
80
,
82
,
79
,
80
,
83
,
85
,
82
,
82
,
82
,
87
,
84
,
88
,
87
,
84
,
91
,
93
,
94
,
93
,
92
,
72
,
72
,
74
,
75
,
71
,
80
,
81
,
79
,
80
,
82
,
82
,
80
,
82
,
84
,
88
,
83
,
87
,
87
,
83
,
88
,
88
,
89
,
90
,
90
,
78
,
78
,
81
,
80
,
74
,
84
,
86
,
82
,
85
,
86
,
85
,
81
,
83
,
83
,
86
,
84
,
85
,
84
,
78
,
85
,
82
,
83
,
85
,
84
,
81
,
81
,
84
,
81
,
75
,
86
,
90
,
85
,
89
,
91
,
89
,
84
,
86
,
87
,
90
,
87
,
89
,
85
,
78
,
84
,
79
,
80
,
81
,
81
,
76
,
76
,
80
,
79
,
73
,
86
,
90
,
87
,
92
,
95
,
92
,
87
,
91
,
92
,
93
,
87
,
89
,
84
,
77
,
81
,
76
,
74
,
76
,
76
,
77
,
77
,
80
,
77
,
72
,
83
,
86
,
86
,
93
,
95
,
91
,
87
,
92
,
92
,
93
,
87
,
90
,
84
,
79
,
79
,
75
,
72
,
75
,
72
,
80
,
80
,
81
,
79
,
72
,
82
,
86
,
86
,
95
,
97
,
89
,
87
,
89
,
89
,
91
,
85
,
88
,
84
,
79
,
80
,
73
,
69
,
74
,
73
,
82
,
82
,
82
,
80
,
74
,
83
,
86
,
87
,
98
,
100
,
90
,
90
,
93
,
94
,
94
,
89
,
90
,
84
,
82
,
79
,
71
,
68
,
72
,
69
,
76
,
76
,
77
,
76
,
70
,
81
,
83
,
88
,
99
,
102
,
92
,
91
,
97
,
97
,
97
,
90
,
90
,
86
,
83
,
81
,
70
,
67
,
70
,
68
,
75
,
75
,
76
,
74
,
69
,
79
,
84
,
88
,
102
,
106
,
95
,
94
,
99
,
98
,
98
,
90
,
89
,
86
,
82
,
79
,
67
,
62
,
65
,
62
,
80
,
80
,
82
,
78
,
71
,
82
,
87
,
90
,
105
,
108
,
96
,
94
,
99
,
98
,
97
,
88
,
88
,
85
,
81
,
79
,
65
,
61
,
65
,
60
,
77
,
77
,
80
,
75
,
66
,
76
,
81
,
87
,
102
,
105
,
92
,
91
,
95
,
97
,
96
,
88
,
89
,
88
,
84
,
81
,
67
,
63
,
68
,
63
};
Mat_
<
uchar
>
expected
(
24
,
24
,
expected_
);
for
(
int
r
=
0
;
r
<
src
.
rows
/
3
;
++
r
)
{
for
(
int
c
=
0
;
c
<
src
.
cols
/
3
;
++
c
)
{
cv
::
Rect
region
(
c
*
3
,
r
*
3
,
3
,
3
);
Mat
roi_i
(
src
,
region
);
Mat
roi_o
(
dst
,
region
);
cv
::
filter2D
(
roi_i
,
roi_o
,
-
1
,
kernel
);
}
}
EXPECT_LE
(
cvtest
::
norm
(
dst
,
expected
,
NORM_INF
),
2
);
}
}}
// namespace
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment