Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
aba73af7
Commit
aba73af7
authored
Mar 31, 2017
by
Vladislav Sovrasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ximgproc: fix weightedMedianFilter crash on zero mask
parent
8b831fef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
weighted_median_filter.cpp
modules/ximgproc/src/weighted_median_filter.cpp
+8
-3
test_weighted_median_filter.cpp
modules/ximgproc/test/test_weighted_median_filter.cpp
+10
-0
No files found.
modules/ximgproc/src/weighted_median_filter.cpp
View file @
aba73af7
...
...
@@ -493,7 +493,7 @@ Mat filterCore(Mat &I, Mat &F, float **wMap, int r=20, int nF=256, int nI=256, M
// Move cut-point to the left
if
(
balanceWeight
>=
0
)
{
for
(;
balanceWeight
>=
0
&&
curMedianVal
;
curMedianVal
--
)
for
(;
balanceWeight
>=
0
&&
curMedianVal
>
0
;
curMedianVal
--
)
{
float
curWeight
=
0
;
int
*
nextHist
=
H
[
curMedianVal
];
...
...
@@ -539,8 +539,13 @@ Mat filterCore(Mat &I, Mat &F, float **wMap, int r=20, int nF=256, int nI=256, M
}
// Weighted median is found and written to the output image
if
(
balanceWeight
<
0
)
outImg
.
ptr
<
int
>
(
y
,
x
)[
0
]
=
curMedianVal
+
1
;
else
outImg
.
ptr
<
int
>
(
y
,
x
)[
0
]
=
curMedianVal
;
if
(
curMedianVal
!=
-
1
)
{
if
(
balanceWeight
<
0
)
outImg
.
ptr
<
int
>
(
y
,
x
)[
0
]
=
curMedianVal
+
1
;
else
outImg
.
ptr
<
int
>
(
y
,
x
)[
0
]
=
curMedianVal
;
}
// Update joint-histogram and BCB when local window is shifted.
int
fval
,
gval
,
*
curHist
;
...
...
modules/ximgproc/test/test_weighted_median_filter.cpp
View file @
aba73af7
...
...
@@ -102,6 +102,16 @@ TEST(WeightedMedianFilterTest, ReferenceAccuracy)
EXPECT_LE
(
cvtest
::
norm
(
res
,
ref
,
NORM_L2
),
totalMaxError
);
}
TEST
(
WeightedMedianFilterTest
,
mask_zeros_no_crash
)
{
Mat
img
=
imread
(
getDataDir
()
+
"cv/ximgproc/sources/01.png"
);
Mat
mask
=
Mat
::
zeros
(
img
.
size
(),
CV_8U
);
Mat
filtered
;
weightedMedianFilter
(
img
,
img
,
filtered
,
3
,
20
,
WMF_EXP
,
mask
);
EXPECT_EQ
(
cv
::
norm
(
img
,
filtered
,
NORM_INF
),
0.0
);
}
INSTANTIATE_TEST_CASE_P
(
TypicalSET
,
WeightedMedianFilterTest
,
Combine
(
Values
(
szODD
,
szQVGA
),
Values
(
WMF_EXP
,
WMF_IV2
,
WMF_OFF
)));
}
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