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
0ea4ee25
Commit
0ea4ee25
authored
Sep 20, 2016
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #777 from sovrasov:guided_filter_fix
parents
246ea8f3
7cc7414a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
2 deletions
+49
-2
guided_filter.cpp
modules/ximgproc/src/guided_filter.cpp
+8
-2
test_guided_filter.cpp
modules/ximgproc/test/test_guided_filter.cpp
+41
-0
No files found.
modules/ximgproc/src/guided_filter.cpp
View file @
0ea4ee25
...
...
@@ -424,6 +424,13 @@ void GuidedFilterImpl::ComputeCovGuideInv_ParBody::operator()(const Range& range
add_mul
(
det
,
a
,
ac
,
gf
.
w
);
}
if
(
gf
.
eps
<
1e-2
)
{
for
(
int
j
=
0
;
j
<
gf
.
w
;
j
++
)
if
(
abs
(
det
[
j
])
<
1e-6
f
)
det
[
j
]
=
1.
f
;
}
for
(
int
k
=
0
;
k
<
gf
.
covarsInv
.
total
();
k
+=
1
)
{
div_1x
(
gf
.
covarsInv
(
k
).
ptr
<
float
>
(
i
),
det
,
gf
.
w
);
...
...
@@ -788,4 +795,4 @@ void guidedFilter(InputArray guide, InputArray src, OutputArray dst, int radius,
}
}
}
\ No newline at end of file
}
modules/ximgproc/test/test_guided_filter.cpp
View file @
0ea4ee25
...
...
@@ -387,6 +387,47 @@ TEST_P(GuidedFilterTest, accuracy)
}
}
TEST_P
(
GuidedFilterTest
,
smallParamsIssue
)
{
GFParams
params
=
GetParam
();
string
guideFileName
=
get
<
1
>
(
params
);
string
srcFileName
=
get
<
2
>
(
params
);
int
guideCnNum
=
3
;
int
srcCnNum
=
get
<
0
>
(
params
);
Mat
guide
=
imread
(
getOpenCVExtraDir
()
+
guideFileName
);
Mat
src
=
imread
(
getOpenCVExtraDir
()
+
srcFileName
);
ASSERT_TRUE
(
!
guide
.
empty
()
&&
!
src
.
empty
());
Size
dstSize
(
guide
.
cols
,
guide
.
rows
);
guide
=
convertTypeAndSize
(
guide
,
CV_MAKE_TYPE
(
guide
.
depth
(),
guideCnNum
),
dstSize
);
src
=
convertTypeAndSize
(
src
,
CV_MAKE_TYPE
(
src
.
depth
(),
srcCnNum
),
dstSize
);
Mat
output
;
ximgproc
::
guidedFilter
(
guide
,
src
,
output
,
3
,
1e-6
);
size_t
whitePixels
=
0
;
for
(
int
i
=
0
;
i
<
output
.
cols
;
i
++
)
{
for
(
int
j
=
0
;
j
<
output
.
rows
;
j
++
)
{
if
(
output
.
channels
()
==
1
)
{
if
(
output
.
ptr
<
uchar
>
(
i
)[
j
]
==
255
)
whitePixels
++
;
}
else
if
(
output
.
channels
()
==
3
)
{
Vec3b
currentPixel
=
output
.
ptr
<
Vec3b
>
(
i
)[
j
];
if
(
currentPixel
==
Vec3b
(
255
,
255
,
255
))
whitePixels
++
;
}
}
}
double
whiteRate
=
whitePixels
/
(
double
)
output
.
total
();
EXPECT_LE
(
whiteRate
,
0.1
);
}
INSTANTIATE_TEST_CASE_P
(
TypicalSet
,
GuidedFilterTest
,
Combine
(
Values
(
1
,
3
),
...
...
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