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
757e7f84
Commit
757e7f84
authored
Sep 02, 2013
by
Roman Donchenko
Committed by
OpenCV Buildbot
Sep 02, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1300 from kdrobnyh:FilterBilateral
parents
99043f6f
c1de14c2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
23 deletions
+45
-23
smooth.cpp
modules/imgproc/src/smooth.cpp
+44
-22
test_bilateral_filter.cpp
modules/imgproc/test/test_bilateral_filter.cpp
+1
-1
No files found.
modules/imgproc/src/smooth.cpp
View file @
757e7f84
...
...
@@ -1875,6 +1875,41 @@ private:
float
*
space_weight
,
*
color_weight
;
};
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
class
IPPBilateralFilter_8u_Invoker
:
public
ParallelLoopBody
{
public
:
IPPBilateralFilter_8u_Invoker
(
Mat
&
_src
,
Mat
&
_dst
,
double
_sigma_color
,
double
_sigma_space
,
int
_radius
,
bool
*
_ok
)
:
ParallelLoopBody
(),
src
(
_src
),
dst
(
_dst
),
sigma_color
(
_sigma_color
),
sigma_space
(
_sigma_space
),
radius
(
_radius
),
ok
(
_ok
)
{
*
ok
=
true
;
}
virtual
void
operator
()
(
const
Range
&
range
)
const
{
int
d
=
radius
*
2
+
1
;
IppiSize
kernel
=
{
d
,
d
};
IppiSize
roi
=
{
dst
.
cols
,
range
.
end
-
range
.
start
};
int
bufsize
=
0
;
ippiFilterBilateralGetBufSize_8u_C1R
(
ippiFilterBilateralGauss
,
roi
,
kernel
,
&
bufsize
);
AutoBuffer
<
uchar
>
buf
(
bufsize
);
IppiFilterBilateralSpec
*
pSpec
=
(
IppiFilterBilateralSpec
*
)
alignPtr
(
&
buf
[
0
],
32
);
ippiFilterBilateralInit_8u_C1R
(
ippiFilterBilateralGauss
,
kernel
,
(
Ipp32f
)
sigma_color
,
(
Ipp32f
)
sigma_space
,
1
,
pSpec
);
if
(
ippiFilterBilateral_8u_C1R
(
src
.
ptr
<
uchar
>
(
range
.
start
)
+
radius
*
((
int
)
src
.
step
[
0
]
+
1
),
(
int
)
src
.
step
[
0
],
dst
.
ptr
<
uchar
>
(
range
.
start
),
(
int
)
dst
.
step
[
0
],
roi
,
kernel
,
pSpec
)
<
0
)
*
ok
=
false
;
}
private
:
Mat
&
src
;
Mat
&
dst
;
double
sigma_color
;
double
sigma_space
;
int
radius
;
bool
*
ok
;
const
IPPBilateralFilter_8u_Invoker
&
operator
=
(
const
IPPBilateralFilter_8u_Invoker
&
);
};
#endif
static
void
bilateralFilter_8u
(
const
Mat
&
src
,
Mat
&
dst
,
int
d
,
double
sigma_color
,
double
sigma_space
,
...
...
@@ -1904,31 +1939,18 @@ bilateralFilter_8u( const Mat& src, Mat& dst, int d,
radius
=
MAX
(
radius
,
1
);
d
=
radius
*
2
+
1
;
#if 0 && defined HAVE_IPP && (IPP_VERSION_MAJOR >= 7)
if(cn == 1)
{
IppiSize kernel = {d, d};
IppiSize roi={src.cols, src.rows};
int bufsize=0;
ippiFilterBilateralGetBufSize_8u_C1R( ippiFilterBilateralGauss, roi, kernel, &bufsize);
AutoBuffer<uchar> buf(bufsize+128);
IppiFilterBilateralSpec *pSpec = (IppiFilterBilateralSpec *)alignPtr(&buf[0], 32);
ippiFilterBilateralInit_8u_C1R( ippiFilterBilateralGauss, kernel, sigma_color*sigma_color, sigma_space*sigma_space, 1, pSpec );
Mat tsrc;
const Mat* psrc = &src;
if( src.data == dst.data )
Mat
temp
;
copyMakeBorder
(
src
,
temp
,
radius
,
radius
,
radius
,
radius
,
borderType
);
#if defined HAVE_IPP && (IPP_VERSION_MAJOR >= 7)
if
(
cn
==
1
)
{
src.copyTo(tsrc);
psrc = &tsrc;
}
if( ippiFilterBilateral_8u_C1R(psrc->data, (int)psrc->step[0],
dst.data, (int)dst.step[0],
roi, kernel, pSpec) >= 0 )
return;
bool
ok
;
IPPBilateralFilter_8u_Invoker
body
(
temp
,
dst
,
sigma_color
*
sigma_color
,
sigma_space
*
sigma_space
,
radius
,
&
ok
);
parallel_for_
(
Range
(
0
,
dst
.
rows
),
body
,
dst
.
total
()
/
(
double
)(
1
<<
16
));
if
(
ok
)
return
;
}
#endif
Mat
temp
;
copyMakeBorder
(
src
,
temp
,
radius
,
radius
,
radius
,
radius
,
borderType
);
vector
<
float
>
_color_weight
(
cn
*
256
);
vector
<
float
>
_space_weight
(
d
*
d
);
...
...
modules/imgproc/test/test_bilateral_filter.cpp
View file @
757e7f84
...
...
@@ -251,7 +251,7 @@ namespace cvtest
int
CV_BilateralFilterTest
::
validate_test_results
(
int
test_case_index
)
{
static
const
double
eps
=
1
;
static
const
double
eps
=
4
;
Mat
reference_dst
,
reference_src
;
if
(
_src
.
depth
()
==
CV_32F
)
...
...
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