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
b1b36cd2
Commit
b1b36cd2
authored
Oct 04, 2014
by
vludv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adaptive manifold filter: downsample/upsample operations where paralleled.
parent
a31a70bf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
10 deletions
+45
-10
adaptive_manifold_filter_n.cpp
modules/ximgproc/src/adaptive_manifold_filter_n.cpp
+39
-10
test_adaptive_manifold.cpp
modules/ximgproc/test/test_adaptive_manifold.cpp
+6
-0
No files found.
modules/ximgproc/src/adaptive_manifold_filter_n.cpp
View file @
b1b36cd2
...
...
@@ -40,6 +40,10 @@
#include <cstring>
#include <limits>
#ifdef _MSC_VER
# pragma warning(disable: 4512)
#endif
namespace
{
...
...
@@ -182,24 +186,20 @@ private: /*inline functions*/
CV_DbgAssert
(
dst
.
size
()
==
smallSize
);
}
void
downsample
(
const
vector
<
Mat
>&
srcv
,
vector
<
Mat
>&
dstv
)
{
dstv
.
resize
(
srcv
.
size
());
for
(
int
i
=
0
;
i
<
(
int
)
srcv
.
size
();
i
++
)
downsample
(
srcv
[
i
],
dstv
[
i
]);
}
void
upsample
(
const
Mat
&
src
,
Mat
&
dst
)
{
CV_DbgAssert
(
src
.
empty
()
||
src
.
size
()
==
smallSize
);
resize
(
src
,
dst
,
srcSize
,
0
,
0
);
}
void
downsample
(
const
vector
<
Mat
>&
srcv
,
vector
<
Mat
>&
dstv
)
{
mapParallel
(
&
AdaptiveManifoldFilterN
::
downsample
,
srcv
,
dstv
);
}
void
upsample
(
const
vector
<
Mat
>&
srcv
,
vector
<
Mat
>&
dstv
)
{
dstv
.
resize
(
srcv
.
size
());
for
(
int
i
=
0
;
i
<
(
int
)
srcv
.
size
();
i
++
)
upsample
(
srcv
[
i
],
dstv
[
i
]);
mapParallel
(
&
AdaptiveManifoldFilterN
::
upsample
,
srcv
,
dstv
);
}
private
:
...
...
@@ -230,6 +230,35 @@ private:
static
void
computeEigenVector
(
const
vector
<
Mat
>&
X
,
const
Mat1b
&
mask
,
Mat1f
&
vecDst
,
int
num_pca_iterations
,
const
Mat1f
&
vecRand
);
static
void
computeOrientation
(
const
vector
<
Mat
>&
X
,
const
Mat1f
&
vec
,
Mat1f
&
dst
);
private
:
/*Parallelization routines*/
typedef
void
(
AdaptiveManifoldFilterN
::*
MapFunc
)(
const
Mat
&
src
,
Mat
&
dst
);
void
mapParallel
(
MapFunc
func
,
const
vector
<
Mat
>&
srcv
,
vector
<
Mat
>&
dstv
)
{
dstv
.
resize
(
srcv
.
size
());
parallel_for_
(
Range
(
0
,
(
int
)
srcv
.
size
()),
MapPrallelLoopBody
(
this
,
func
,
srcv
,
dstv
));
}
struct
MapPrallelLoopBody
:
public
cv
::
ParallelLoopBody
{
MapPrallelLoopBody
(
AdaptiveManifoldFilterN
*
_instancePtr
,
MapFunc
_transform
,
const
vector
<
Mat
>&
_srcv
,
vector
<
Mat
>&
_dstv
)
:
instancePtr
(
_instancePtr
),
transform
(
_transform
),
srcv
(
_srcv
),
dstv
(
_dstv
)
{}
AdaptiveManifoldFilterN
*
instancePtr
;
MapFunc
transform
;
const
vector
<
Mat
>&
srcv
;
vector
<
Mat
>&
dstv
;
void
operator
()
(
const
Range
&
range
)
const
{
for
(
int
i
=
range
.
start
;
i
<
range
.
end
;
i
++
)
(
instancePtr
->*
transform
)(
srcv
[
i
],
dstv
[
i
]);
}
};
};
CV_INIT_ALGORITHM
(
AdaptiveManifoldFilterN
,
"AdaptiveManifoldFilter"
,
...
...
modules/ximgproc/test/test_adaptive_manifold.cpp
View file @
b1b36cd2
...
...
@@ -67,6 +67,8 @@ TEST(AdaptiveManifoldTest, SplatSurfaceAccuracy)
{
RNG
rnd
(
0
);
cv
::
setNumThreads
(
cv
::
getNumberOfCPUs
());
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
Size
sz
(
rnd
.
uniform
(
512
,
1024
),
rnd
.
uniform
(
512
,
1024
));
...
...
@@ -126,6 +128,8 @@ TEST(AdaptiveManifoldTest, AuthorsReferenceAccuracy)
Mat
srcImg
=
imread
(
getOpenCVExtraDir
()
+
srcImgPath
);
ASSERT_TRUE
(
!
srcImg
.
empty
());
cv
::
setNumThreads
(
cv
::
getNumberOfCPUs
());
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
Mat
refRes
=
imread
(
getOpenCVExtraDir
()
+
refPaths
[
i
]);
...
...
@@ -190,9 +194,11 @@ TEST_P(AdaptiveManifoldRefImplTest, RefImplAccuracy)
double
sigma_r
=
rnd
.
uniform
(
0.1
,
0.9
);
bool
adjust_outliers
=
(
iter
%
2
==
0
);
cv
::
setNumThreads
(
cv
::
getNumberOfCPUs
());
Mat
res
;
amFilter
(
guide
,
src
,
res
,
sigma_s
,
sigma_r
,
adjust_outliers
);
cv
::
setNumThreads
(
1
);
Mat
resRef
;
Ptr
<
AdaptiveManifoldFilter
>
amf
=
createAMFilterRefImpl
(
sigma_s
,
sigma_r
,
adjust_outliers
);
amf
->
filter
(
src
,
resRef
,
guide
);
...
...
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