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
34969204
Commit
34969204
authored
Aug 11, 2014
by
vludv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The functionality was put into ximgproc namespace. Some refactoring. Fixed some warnings.
parent
f45b5602
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
264 additions
and
146 deletions
+264
-146
ximgproc.hpp
modules/ximgproc/include/opencv2/ximgproc.hpp
+42
-0
edge_filter.hpp
modules/ximgproc/include/opencv2/ximgproc/edge_filter.hpp
+3
-0
perf_adaptive_manifold.cpp
modules/ximgproc/perf/perf_adaptive_manifold.cpp
+7
-5
perf_domain_transform.cpp
modules/ximgproc/perf/perf_domain_transform.cpp
+7
-6
perf_guided_filter.cpp
modules/ximgproc/perf/perf_guided_filter.cpp
+7
-5
perf_precomp.hpp
modules/ximgproc/perf/perf_precomp.hpp
+1
-1
pref_joint_bilateral_filter.cpp
modules/ximgproc/perf/pref_joint_bilateral_filter.cpp
+9
-8
live_demo.cpp
modules/ximgproc/samples/live_demo.cpp
+29
-15
adaptive_manifold_filter_n.cpp
modules/ximgproc/src/adaptive_manifold_filter_n.cpp
+22
-11
domain_transform.cpp
modules/ximgproc/src/domain_transform.cpp
+4
-0
dtfilter_cpu.cpp
modules/ximgproc/src/dtfilter_cpu.cpp
+6
-2
dtfilter_cpu.hpp
modules/ximgproc/src/dtfilter_cpu.hpp
+5
-2
dtfilter_cpu.inl.hpp
modules/ximgproc/src/dtfilter_cpu.inl.hpp
+41
-43
edgeaware_filters_common.cpp
modules/ximgproc/src/edgeaware_filters_common.cpp
+7
-3
edgeaware_filters_common.hpp
modules/ximgproc/src/edgeaware_filters_common.hpp
+5
-1
guided_filter.cpp
modules/ximgproc/src/guided_filter.cpp
+8
-5
joint_bilateral_filter.cpp
modules/ximgproc/src/joint_bilateral_filter.cpp
+29
-13
precomp.hpp
modules/ximgproc/src/precomp.hpp
+3
-2
test_adaptive_manifold.cpp
modules/ximgproc/test/test_adaptive_manifold.cpp
+5
-4
test_adaptive_manifold_ref_impl.cpp
modules/ximgproc/test/test_adaptive_manifold_ref_impl.cpp
+7
-3
test_domain_transform.cpp
modules/ximgproc/test/test_domain_transform.cpp
+5
-4
test_guided_filter.cpp
modules/ximgproc/test/test_guided_filter.cpp
+5
-4
test_joint_bilateral_filter.cpp
modules/ximgproc/test/test_joint_bilateral_filter.cpp
+5
-8
test_precomp.hpp
modules/ximgproc/test/test_precomp.hpp
+2
-1
No files found.
modules/ximgproc/include/opencv2/ximgproc.hpp
0 → 100644
View file @
34969204
/*
* Software License Agreement (BSD License)
*
* Copyright (c) 2009, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __OPENCV_XIMGPROC_HPP__
#define __OPENCV_XIMGPROC_HPP__
#include "ximgproc/edge_filter.hpp"
#endif
\ No newline at end of file
modules/ximgproc/include/opencv2/edge_filter.hpp
→
modules/ximgproc/include/opencv2/
ximgproc/
edge_filter.hpp
View file @
34969204
...
...
@@ -41,6 +41,8 @@
namespace
cv
{
namespace
ximgproc
{
enum
EdgeAwareFiltersList
{
...
...
@@ -119,6 +121,7 @@ CV_EXPORTS_W void amFilter(InputArray joint, InputArray src, OutputArray dst, do
CV_EXPORTS_W
void
jointBilateralFilter
(
InputArray
joint
,
InputArray
src
,
OutputArray
dst
,
int
d
,
double
sigmaColor
,
double
sigmaSpace
,
int
borderType
=
BORDER_DEFAULT
);
}
}
#endif
#endif
modules/ximgproc/perf/perf_adaptive_manifold.cpp
View file @
34969204
#include "perf_precomp.hpp"
using
namespace
std
;
using
namespace
std
::
tr1
;
using
namespace
cv
;
namespace
cvtest
{
using
std
::
tr1
::
tuple
;
using
std
::
tr1
::
get
;
using
namespace
perf
;
using
namespace
testing
;
using
namespace
cv
;
using
namespace
cv
::
ximgproc
;
namespace
cvtest
{
typedef
tuple
<
bool
,
Size
,
int
,
int
,
MatType
>
AMPerfTestParam
;
typedef
TestBaseWithParam
<
AMPerfTestParam
>
AdaptiveManifoldPerfTest
;
...
...
modules/ximgproc/perf/perf_domain_transform.cpp
View file @
34969204
#include "perf_precomp.hpp"
using
namespace
std
;
using
namespace
std
::
tr1
;
using
namespace
cv
;
using
namespace
perf
;
using
namespace
testing
;
namespace
cvtest
{
using
std
::
tr1
::
tuple
;
using
std
::
tr1
::
get
;
using
namespace
perf
;
using
namespace
testing
;
using
namespace
cv
;
using
namespace
cv
::
ximgproc
;
CV_ENUM
(
GuideMatType
,
CV_8UC1
,
CV_8UC3
,
CV_32FC1
,
CV_32FC3
)
//reduced set
CV_ENUM
(
SourceMatType
,
CV_8UC1
,
CV_8UC2
,
CV_8UC3
,
CV_8UC4
,
CV_32FC1
,
CV_32FC2
,
CV_32FC3
,
CV_32FC4
)
//full supported set
CV_ENUM
(
DTFMode
,
DTF_NC
,
DTF_IC
,
DTF_RF
)
...
...
modules/ximgproc/perf/perf_guided_filter.cpp
View file @
34969204
#include "perf_precomp.hpp"
using
namespace
std
;
using
namespace
std
::
tr1
;
using
namespace
cv
;
namespace
cvtest
{
using
std
::
tr1
::
tuple
;
using
std
::
tr1
::
get
;
using
namespace
perf
;
using
namespace
testing
;
using
namespace
cv
;
using
namespace
cv
::
ximgproc
;
namespace
cvtest
{
CV_ENUM
(
GuideTypes
,
CV_8UC1
,
CV_8UC2
,
CV_8UC3
,
CV_32FC1
,
CV_32FC2
,
CV_32FC3
);
CV_ENUM
(
SrcTypes
,
CV_8UC1
,
CV_8UC3
,
CV_32FC1
,
CV_32FC3
);
typedef
tuple
<
GuideTypes
,
SrcTypes
,
Size
>
GFParams
;
...
...
modules/ximgproc/perf/perf_precomp.hpp
View file @
34969204
...
...
@@ -5,6 +5,6 @@
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/
edge_filter
.hpp>
#include <opencv2/
ximgproc
.hpp>
#endif
modules/ximgproc/perf/pref_joint_bilateral_filter.cpp
View file @
34969204
#include "perf_precomp.hpp"
using
namespace
std
;
using
namespace
std
::
tr1
;
using
namespace
cv
;
using
namespace
perf
;
using
namespace
testing
;
namespace
cvtest
{
using
std
::
tr1
::
tuple
;
using
std
::
tr1
::
get
;
using
namespace
perf
;
using
namespace
testing
;
using
namespace
cv
;
using
namespace
cv
::
ximgproc
;
typedef
tuple
<
double
,
Size
,
MatType
,
int
,
int
>
JBFTestParam
;
typedef
TestBaseWithParam
<
JBFTestParam
>
JointBilateralFilterTest
;
...
...
@@ -35,8 +36,8 @@ PERF_TEST_P(JointBilateralFilterTest, perf,
cv
::
setNumThreads
(
cv
::
getNumberOfCPUs
());
declare
.
in
(
joint
,
src
,
WARMUP_RNG
).
out
(
dst
).
tbb_threads
(
cv
::
getNumberOfCPUs
());
RNG
rnd
(
sigmaS
+
sz
.
height
+
depth
+
jCn
+
srcCn
);
double
sigmaC
=
rnd
.
uniform
(
0
.0
,
255.0
);
RNG
rnd
(
cvRound
(
10
*
sigmaS
)
+
sz
.
height
+
depth
+
jCn
+
srcCn
);
double
sigmaC
=
rnd
.
uniform
(
1
.0
,
255.0
);
TEST_CYCLE_N
(
1
)
{
...
...
modules/ximgproc/samples/live_demo.cpp
View file @
34969204
...
...
@@ -2,8 +2,9 @@
#include <opencv2/core/utility.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/
edge_filter
.hpp>
#include <opencv2/
ximgproc
.hpp>
using
namespace
cv
;
using
namespace
cv
::
ximgproc
;
#include <iostream>
using
namespace
std
;
...
...
@@ -12,6 +13,12 @@ typedef void(*FilteringOperation)(const Mat& src, Mat& dst);
//current mode (filtering operation example)
FilteringOperation
g_filterOp
=
NULL
;
//list of filtering operations
void
filterDoNothing
(
const
Mat
&
frame
,
Mat
&
dst
);
void
filterBlurring
(
const
Mat
&
frame
,
Mat
&
dst
);
void
filterStylize
(
const
Mat
&
frame
,
Mat
&
dst
);
void
filterDetailEnhancement
(
const
Mat
&
frame8u
,
Mat
&
dst
);
//common sliders for every mode
int
g_sigmaColor
=
25
;
int
g_sigmaSpatial
=
10
;
...
...
@@ -25,6 +32,12 @@ int g_detailsLevel = 100;
int
g_numberOfCPUs
=
cv
::
getNumberOfCPUs
();
//We will use two callbacks to change parameters
void
changeModeCallback
(
int
state
,
void
*
filter
);
void
changeNumberOfCpuCallback
(
int
count
,
void
*
);
void
splitScreen
(
const
Mat
&
rawFrame
,
Mat
&
outputFrame
,
Mat
&
srcFrame
,
Mat
&
processedFrame
);
//trivial filter
void
filterDoNothing
(
const
Mat
&
frame
,
Mat
&
dst
)
{
...
...
@@ -100,32 +113,33 @@ void filterDetailEnhancement(const Mat& frame8u, Mat& dst)
frame
.
convertTo
(
dst
,
CV_8U
,
255
);
}
void
splitScreen
(
const
Mat
&
rawFrame
,
Mat
&
outputFrame
,
Mat
&
srcFrame
,
Mat
&
processedFrame
)
{
int
h
=
rawFrame
.
rows
;
int
w
=
rawFrame
.
cols
;
int
cn
=
rawFrame
.
channels
();
outputFrame
.
create
(
h
,
2
*
w
,
CV_MAKE_TYPE
(
CV_8U
,
cn
));
srcFrame
=
outputFrame
(
Range
::
all
(),
Range
(
0
,
w
));
processedFrame
=
outputFrame
(
Range
::
all
(),
Range
(
w
,
2
*
w
));
rawFrame
.
convertTo
(
srcFrame
,
srcFrame
.
type
());
}
void
changeModeCallback
(
int
state
,
void
*
filter
)
{
if
(
state
==
1
)
g_filterOp
=
(
FilteringOperation
)
filter
;
}
void
changeNumberOfCpuCallback
(
int
count
,
void
*
data
)
void
changeNumberOfCpuCallback
(
int
count
,
void
*
)
{
count
=
std
::
max
(
1
,
count
);
cv
::
setNumThreads
(
count
);
g_numberOfCPUs
=
count
;
}
int
main
(
int
argc
,
char
**
argv
)
//divide screen on two parts: srcFrame and processed Frame
void
splitScreen
(
const
Mat
&
rawFrame
,
Mat
&
outputFrame
,
Mat
&
srcFrame
,
Mat
&
processedFrame
)
{
int
h
=
rawFrame
.
rows
;
int
w
=
rawFrame
.
cols
;
int
cn
=
rawFrame
.
channels
();
outputFrame
.
create
(
h
,
2
*
w
,
CV_MAKE_TYPE
(
CV_8U
,
cn
));
srcFrame
=
outputFrame
(
Range
::
all
(),
Range
(
0
,
w
));
processedFrame
=
outputFrame
(
Range
::
all
(),
Range
(
w
,
2
*
w
));
rawFrame
.
convertTo
(
srcFrame
,
srcFrame
.
type
());
}
int
main
()
{
VideoCapture
cap
(
0
);
if
(
!
cap
.
isOpened
())
...
...
modules/ximgproc/src/adaptive_manifold_filter_n.cpp
View file @
34969204
...
...
@@ -2,22 +2,21 @@
#include <opencv2/core/private.hpp>
#include <cmath>
#include <cstring>
#include <opencv2/edge_filter.hpp>
#include "edgeaware_filters_common.hpp"
using
namespace
cv
::
eaf
;
namespace
{
using
std
::
numeric_limits
;
using
std
::
vector
;
using
namespace
cv
;
using
namespace
cv
::
ximgproc
;
using
namespace
cv
::
ximgproc
::
intrinsics
;
#ifndef SQR
#define SQR(x) ((x)*(x))
#endif
namespace
{
void
computeEigenVector
(
const
Mat1f
&
X
,
const
Mat1b
&
mask
,
Mat1f
&
dst
,
int
num_pca_iterations
,
const
Mat1f
&
rand_vec
);
inline
double
Log2
(
double
n
)
...
...
@@ -725,9 +724,9 @@ void computeEigenVector(const Mat1f& X, const Mat1b& mask, Mat1f& dst, int num_p
}
dst
.
setTo
(
0.0
);
for
(
int
i
=
0
;
i
<
X
.
rows
;
++
i
)
for
(
int
k
=
0
;
k
<
X
.
rows
;
++
k
)
{
const
float
*
t_row
=
t
[
i
];
const
float
*
t_row
=
t
[
k
];
for
(
int
c
=
0
;
c
<
X
.
cols
;
++
c
)
{
...
...
@@ -741,12 +740,19 @@ void computeEigenVector(const Mat1f& X, const Mat1b& mask, Mat1f& dst, int num_p
}
}
Ptr
<
AdaptiveManifoldFilter
>
cv
::
AdaptiveManifoldFilter
::
create
()
namespace
cv
{
namespace
ximgproc
{
Ptr
<
AdaptiveManifoldFilter
>
AdaptiveManifoldFilter
::
create
()
{
return
Ptr
<
AdaptiveManifoldFilter
>
(
new
AdaptiveManifoldFilterN
());
}
CV_EXPORTS_W
Ptr
<
AdaptiveManifoldFilter
>
cv
::
createAMFilter
(
double
sigma_s
,
double
sigma_r
,
bool
adjust_outliers
)
CV_EXPORTS_W
Ptr
<
AdaptiveManifoldFilter
>
createAMFilter
(
double
sigma_s
,
double
sigma_r
,
bool
adjust_outliers
)
{
Ptr
<
AdaptiveManifoldFilter
>
amf
(
new
AdaptiveManifoldFilterN
());
...
...
@@ -757,8 +763,12 @@ CV_EXPORTS_W Ptr<AdaptiveManifoldFilter> cv::createAMFilter(double sigma_s, doub
return
amf
;
}
CV_EXPORTS_W
void
cv
::
amFilter
(
InputArray
joint
,
InputArray
src
,
OutputArray
dst
,
double
sigma_s
,
double
sigma_r
,
bool
adjust_outliers
)
CV_EXPORTS_W
void
amFilter
(
InputArray
joint
,
InputArray
src
,
OutputArray
dst
,
double
sigma_s
,
double
sigma_r
,
bool
adjust_outliers
)
{
Ptr
<
AdaptiveManifoldFilter
>
amf
=
createAMFilter
(
sigma_s
,
sigma_r
,
adjust_outliers
);
amf
->
filter
(
src
,
dst
,
joint
);
}
}
}
\ No newline at end of file
modules/ximgproc/src/domain_transform.cpp
View file @
34969204
...
...
@@ -3,6 +3,8 @@
namespace
cv
{
namespace
ximgproc
{
CV_EXPORTS_W
Ptr
<
DTFilter
>
createDTFilter
(
InputArray
guide
,
double
sigmaSpatial
,
double
sigmaColor
,
int
mode
,
int
numIters
)
...
...
@@ -18,4 +20,5 @@ void dtFilter(InputArray guide, InputArray src, OutputArray dst, double sigmaSpa
dtf
->
filter
(
src
,
dst
);
}
}
}
\ No newline at end of file
modules/ximgproc/src/dtfilter_cpu.cpp
View file @
34969204
...
...
@@ -3,6 +3,8 @@
namespace
cv
{
namespace
ximgproc
{
typedef
Vec
<
uchar
,
1
>
Vec1b
;
typedef
Vec
<
float
,
1
>
Vec1f
;
...
...
@@ -37,7 +39,7 @@ Ptr<DTFilterCPU> DTFilterCPU::createRF(InputArray adistHor, InputArray adistVert
return
dtf
;
}
void
DTFilterCPU
::
init
(
InputArray
guide_
,
double
sigmaSpatial
,
double
sigmaColor
,
int
mode
,
int
numIters
)
void
DTFilterCPU
::
init
(
InputArray
guide_
,
double
sigmaSpatial
_
,
double
sigmaColor_
,
int
mode_
,
int
numIters_
)
{
Mat
guide
=
guide_
.
getMat
();
...
...
@@ -47,7 +49,7 @@ void DTFilterCPU::init(InputArray guide_, double sigmaSpatial, double sigmaColor
CV_Assert
(
cn
<=
4
);
CV_Assert
((
depth
==
CV_8U
||
depth
==
CV_32F
)
&&
!
guide
.
empty
());
#define CREATE_DTF(Vect) init_<Vect>(guide, sigmaSpatial
, sigmaColor, mode, numIters
);
#define CREATE_DTF(Vect) init_<Vect>(guide, sigmaSpatial
_, sigmaColor_, mode_, numIters_
);
if
(
cn
==
1
)
{
...
...
@@ -171,4 +173,5 @@ Range DTFilterCPU::getWorkRangeByThread(int items, const Range& rangeThread, int
return
getWorkRangeByThread
(
Range
(
0
,
items
),
rangeThread
,
declaredNumThreads
);
}
}
}
\ No newline at end of file
modules/ximgproc/src/dtfilter_cpu.hpp
View file @
34969204
...
...
@@ -12,6 +12,8 @@
namespace
cv
{
namespace
ximgproc
{
class
DTFilterCPU
:
public
DTFilter
{
...
...
@@ -238,7 +240,7 @@ void domainTransformFilter( const Mat_<GuideVec>& guide,
const
Mat_
<
SrcVec
>&
source
,
Mat
&
dst
,
double
sigmaSpatial
,
double
sigmaColor
,
int
mode
=
cv
::
DTF_NC
,
int
numPasses
=
3
int
mode
=
DTF_NC
,
int
numPasses
=
3
);
template
<
typename
GuideVec
,
typename
SrcVec
>
...
...
@@ -246,9 +248,10 @@ void domainTransformFilter( const Mat& guide,
const
Mat
&
source
,
Mat
&
dst
,
double
sigmaSpatial
,
double
sigmaColor
,
int
mode
=
cv
::
DTF_NC
,
int
numPasses
=
3
int
mode
=
DTF_NC
,
int
numPasses
=
3
);
}
}
#include "dtfilter_cpu.inl.hpp"
...
...
modules/ximgproc/src/dtfilter_cpu.inl.hpp
View file @
34969204
#ifndef __OPENCV_DTFILTER_INL_HPP__
#define __OPENCV_DTFILTER_INL_HPP__
#include "precomp.hpp"
#include <iostream>
#include "edgeaware_filters_common.hpp"
using
namespace
cv
::
eaf
;
#define NC_USE_INTEGRAL_SRC
//#undef NC_USE_INTEGRAL_SRC
namespace
cv
{
namespace
ximgproc
{
using
namespace
cv
::
ximgproc
::
intrinsics
;
#define NC_USE_INTEGRAL_SRC
//#undef NC_USE_INTEGRAL_SRC
template
<
typename
GuideVec
>
DTFilterCPU
DTFilterCPU
::
create_
(
const
Mat
&
guide
,
double
sigmaSpatial
,
double
sigmaColor
,
int
mode
,
int
numIters
)
...
...
@@ -28,60 +30,55 @@ DTFilterCPU* DTFilterCPU::create_p_(const Mat& guide, double sigmaSpatial, doubl
}
template
<
typename
GuideVec
>
void
DTFilterCPU
::
init_
(
Mat
&
guide
,
double
sigmaSpatial
,
double
sigmaColor
,
int
mode
,
int
numIters
)
void
DTFilterCPU
::
init_
(
Mat
&
guide
,
double
sigmaSpatial
_
,
double
sigmaColor_
,
int
mode_
,
int
numIters_
)
{
CV_Assert
(
guide
.
type
()
==
cv
::
DataType
<
GuideVec
>::
type
);
this
->
release
();
this
->
h
=
guide
.
rows
;
this
->
w
=
guide
.
cols
;
h
=
guide
.
rows
;
w
=
guide
.
cols
;
this
->
sigmaSpatial
=
std
::
max
(
1.0
f
,
(
float
)
sigmaSpatial
);
this
->
sigmaColor
=
std
::
max
(
0.01
f
,
(
float
)
sigmaColor
);
sigmaSpatial
=
std
::
max
(
1.0
f
,
(
float
)
sigmaSpatial_
);
sigmaColor
=
std
::
max
(
0.01
f
,
(
float
)
sigmaColor_
);
this
->
mode
=
mode
;
this
->
numIters
=
std
::
max
(
1
,
numIters
);
mode
=
mode_
;
numIters
=
std
::
max
(
1
,
numIters_
);
switch
(
this
->
mode
)
if
(
mode
==
DTF_NC
)
{
case
DTF_NC
:
{
{
ComputeIDTHor_ParBody
<
GuideVec
>
horBody
(
*
this
,
guide
,
idistHor
);
parallel_for_
(
horBody
.
getRange
(),
horBody
);
}
{
Mat
guideT
=
guide
.
t
();
ComputeIDTHor_ParBody
<
GuideVec
>
horBody
(
*
this
,
guideT
,
idistVert
);
parallel_for_
(
horBody
.
getRange
(),
horBody
);
}
ComputeIDTHor_ParBody
<
GuideVec
>
horBody
(
*
this
,
guide
,
idistHor
);
parallel_for_
(
horBody
.
getRange
(),
horBody
);
}
break
;
case
DTF_IC
:
{
{
ComputeDTandIDTHor_ParBody
<
GuideVec
>
horBody
(
*
this
,
guide
,
distHor
,
idistHor
);
parallel_for_
(
horBody
.
getRange
(),
horBody
);
}
{
Mat
guideT
=
guide
.
t
();
ComputeDTandIDTHor_ParBody
<
GuideVec
>
horBody
(
*
this
,
guideT
,
distVert
,
idistVert
);
parallel_for_
(
horBody
.
getRange
(),
horBody
);
}
Mat
guideT
=
guide
.
t
();
ComputeIDTHor_ParBody
<
GuideVec
>
horBody
(
*
this
,
guideT
,
idistVert
);
parallel_for_
(
horBody
.
getRange
(),
horBody
);
}
}
else
if
(
mode
==
DTF_IC
)
{
{
ComputeDTandIDTHor_ParBody
<
GuideVec
>
horBody
(
*
this
,
guide
,
distHor
,
idistHor
);
parallel_for_
(
horBody
.
getRange
(),
horBody
);
}
break
;
case
DTF_RF
:
{
ComputeA0DTHor_ParBody
<
GuideVec
>
horBody
(
*
this
,
guide
);
Compute
A0DTVert_ParBody
<
GuideVec
>
vertBody
(
*
this
,
guide
);
Mat
guideT
=
guide
.
t
(
);
Compute
DTandIDTHor_ParBody
<
GuideVec
>
horBody
(
*
this
,
guideT
,
distVert
,
idistVert
);
parallel_for_
(
horBody
.
getRange
(),
horBody
);
parallel_for_
(
vertBody
.
getRange
(),
vertBody
);
}
break
;
default
:
}
else
if
(
mode
==
DTF_RF
)
{
ComputeA0DTHor_ParBody
<
GuideVec
>
horBody
(
*
this
,
guide
);
ComputeA0DTVert_ParBody
<
GuideVec
>
vertBody
(
*
this
,
guide
);
parallel_for_
(
horBody
.
getRange
(),
horBody
);
parallel_for_
(
vertBody
.
getRange
(),
vertBody
);
}
else
{
CV_Error
(
Error
::
StsBadFlag
,
"Incorrect DT filter mode"
);
break
;
}
}
...
...
@@ -586,5 +583,5 @@ void domainTransformFilter( const Mat& guide,
}
}
}
#endif
\ No newline at end of file
modules/ximgproc/src/edgeaware_filters_common.cpp
View file @
34969204
...
...
@@ -21,7 +21,8 @@ static volatile bool CPU_SUPPORT_SSE2 = cv::checkHardwareSupport(CV_CPU_SSE2);
namespace
cv
{
namespace
ximgproc
{
Ptr
<
DTFilter
>
createDTFilterRF
(
InputArray
adistHor
,
InputArray
adistVert
,
double
sigmaSpatial
,
double
sigmaColor
,
int
numIters
)
{
...
...
@@ -94,7 +95,7 @@ void checkSameSizeAndDepth(InputArrayOfArrays src, Size &sz, int &depth)
}
}
namespace
eaf
namespace
intrinsics
{
inline
float
getFloatSignBit
()
...
...
@@ -508,5 +509,7 @@ void rf_vert_row_pass(register float *curRow, register float *prevRow, float alp
curRow
[
j
]
+=
alphaVal
*
(
prevRow
[
j
]
-
curRow
[
j
]);
}
}
//end of cv::eaf
}
//end of cv::ximgproc::intrinsics
}
//end of cv::ximgproc
}
//end of cv
\ No newline at end of file
modules/ximgproc/src/edgeaware_filters_common.hpp
View file @
34969204
...
...
@@ -4,6 +4,8 @@
namespace
cv
{
namespace
ximgproc
{
Ptr
<
DTFilter
>
createDTFilterRF
(
InputArray
adistHor
,
InputArray
adistVert
,
double
sigmaSpatial
,
double
sigmaColor
,
int
numIters
);
...
...
@@ -11,7 +13,7 @@ int getTotalNumberOfChannels(InputArrayOfArrays src);
void
checkSameSizeAndDepth
(
InputArrayOfArrays
src
,
Size
&
sz
,
int
&
depth
);
namespace
eaf
namespace
intrinsics
{
void
add_
(
register
float
*
dst
,
register
float
*
src1
,
int
w
);
...
...
@@ -51,6 +53,8 @@ namespace eaf
void
rf_vert_row_pass
(
register
float
*
curRow
,
register
float
*
prevRow
,
float
alphaVal
,
int
w
);
}
}
}
#endif
...
...
modules/ximgproc/src/guided_filter.cpp
View file @
34969204
#include "precomp.hpp"
#include <vector>
#include <iostream>
using
std
::
vector
;
#include "edgeaware_filters_common.hpp"
using
namespace
cv
::
eaf
;
#include <vector>
#ifdef _MSC_VER
# pragma warning(disable: 4512)
...
...
@@ -12,6 +8,11 @@ using namespace cv::eaf;
namespace
cv
{
namespace
ximgproc
{
using
std
::
vector
;
using
namespace
cv
::
ximgproc
::
intrinsics
;
template
<
typename
T
>
struct
SymArray2D
...
...
@@ -750,4 +751,5 @@ void guidedFilter(InputArray guide, InputArray src, OutputArray dst, int radius,
gf
->
filter
(
src
,
dst
,
dDepth
);
}
}
}
\ No newline at end of file
modules/ximgproc/src/joint_bilateral_filter.cpp
View file @
34969204
...
...
@@ -9,6 +9,8 @@ using namespace std;
namespace
cv
{
namespace
ximgproc
{
typedef
Vec
<
float
,
1
>
Vec1f
;
typedef
Vec
<
uchar
,
1
>
Vec1b
;
...
...
@@ -17,6 +19,10 @@ typedef Vec<uchar, 1> Vec1b;
#define SQR(a) ((a)*(a))
#endif
void
jointBilateralFilter_32f
(
Mat
&
joint
,
Mat
&
src
,
Mat
&
dst
,
int
radius
,
double
sigmaColor
,
double
sigmaSpace
,
int
borderType
);
void
jointBilateralFilter_8u
(
Mat
&
joint
,
Mat
&
src
,
Mat
&
dst
,
int
radius
,
double
sigmaColor
,
double
sigmaSpace
,
int
borderType
);
template
<
typename
JointVec
,
typename
SrcVec
>
class
JointBilateralFilter_32f
:
public
ParallelLoopBody
{
...
...
@@ -49,9 +55,9 @@ public:
JointVec
*
jointCenterPixPtr
=
joint
.
ptr
<
JointVec
>
(
i
)
+
j
;
SrcVec
*
srcCenterPixPtr
=
src
.
ptr
<
SrcVec
>
(
i
)
+
j
;
register
JointVec
jointPix0
=
*
jointCenterPixPtr
;
register
SrcVec
srcSum
=
SrcVec
::
all
(
0.0
f
);
register
float
wSum
=
0.0
f
;
JointVec
jointPix0
=
*
jointCenterPixPtr
;
SrcVec
srcSum
=
SrcVec
::
all
(
0.0
f
);
float
wSum
=
0.0
f
;
for
(
int
k
=
0
;
k
<
maxk
;
k
++
)
{
...
...
@@ -198,9 +204,9 @@ public:
JointVec
*
jointCenterPixPtr
=
joint
.
ptr
<
JointVec
>
(
i
)
+
j
;
SrcVec
*
srcCenterPixPtr
=
src
.
ptr
<
SrcVec
>
(
i
)
+
j
;
register
JointVeci
jointPix0
=
JointVeci
(
*
jointCenterPixPtr
);
register
SrcVecf
srcSum
=
SrcVecf
::
all
(
0.0
f
);
register
float
wSum
=
0.0
f
;
JointVeci
jointPix0
=
JointVeci
(
*
jointCenterPixPtr
);
SrcVecf
srcSum
=
SrcVecf
::
all
(
0.0
f
);
float
wSum
=
0.0
f
;
for
(
int
k
=
0
;
k
<
maxk
;
k
++
)
{
...
...
@@ -313,9 +319,8 @@ void jointBilateralFilter(InputArray joint_, InputArray src_, OutputArray dst_,
return
;
}
CV_Assert
(
src
.
size
()
==
joint
.
size
()
&&
src
.
depth
()
==
joint
.
depth
());
CV_Assert
(
src
.
type
()
==
CV_32FC1
||
src
.
type
()
==
CV_32FC3
||
src
.
type
()
==
CV_8UC1
||
src
.
type
()
==
CV_8UC3
);
CV_Assert
(
joint
.
type
()
==
CV_32FC1
||
joint
.
type
()
==
CV_32FC3
||
joint
.
type
()
==
CV_8UC1
||
joint
.
type
()
==
CV_8UC3
);
CV_Assert
(
src
.
size
()
==
joint
.
size
());
CV_Assert
(
src
.
depth
()
==
joint
.
depth
()
&&
(
src
.
depth
()
==
CV_8U
||
src
.
depth
()
==
CV_32F
)
);
if
(
sigmaColor
<=
0
)
sigmaColor
=
1
;
...
...
@@ -337,15 +342,25 @@ void jointBilateralFilter(InputArray joint_, InputArray src_, OutputArray dst_,
if
(
dst
.
data
==
src
.
data
)
src
=
src
.
clone
();
if
(
joint
.
depth
()
==
CV_8U
)
int
jointCnNum
=
joint
.
channels
();
int
srcCnNum
=
src
.
channels
();
if
(
(
srcCnNum
==
1
||
srcCnNum
==
3
)
&&
(
jointCnNum
==
1
||
jointCnNum
==
3
)
)
{
jointBilateralFilter_8u
(
joint
,
src
,
dst
,
radius
,
sigmaColor
,
sigmaSpace
,
borderType
);
if
(
joint
.
depth
()
==
CV_8U
)
{
jointBilateralFilter_8u
(
joint
,
src
,
dst
,
radius
,
sigmaColor
,
sigmaSpace
,
borderType
);
}
else
{
jointBilateralFilter_32f
(
joint
,
src
,
dst
,
radius
,
sigmaColor
,
sigmaSpace
,
borderType
);
}
}
else
{
jointBilateralFilter_32f
(
joint
,
src
,
dst
,
radius
,
sigmaColor
,
sigmaSpace
,
borderType
);
CV_Error
(
Error
::
BadNumChannels
,
"Unsupported number of channels"
);
}
}
}
}
\ No newline at end of file
modules/ximgproc/src/precomp.hpp
View file @
34969204
#ifndef _OPENCV_EDGEFILTER_PRECOMP_HPP_
#define _OPENCV_EDGEFILTER_PRECOMP_HPP_
#include <opencv2/edge_filter.hpp>
#include <opencv2/core.hpp>
#include <opencv2/core/ocl.hpp>
#include <opencv2/core/base.hpp>
...
...
@@ -10,6 +9,7 @@
#include <opencv2/core/core_c.h>
#include <opencv2/core/private.hpp>
#include <opencv2/imgproc.hpp>
#include <limits>
#include <opencv2/ximgproc.hpp>
#endif
\ No newline at end of file
modules/ximgproc/test/test_adaptive_manifold.cpp
View file @
34969204
#include "test_precomp.hpp"
namespace
cvtest
{
using
namespace
std
;
using
namespace
std
::
tr1
;
using
namespace
cv
;
using
namespace
testing
;
using
namespace
cv
;
using
namespace
cv
::
ximgproc
;
#ifndef SQR
#define SQR(x) ((x)*(x))
#endif
namespace
cvtest
{
static
string
getOpenCVExtraDir
()
{
return
cvtest
::
TS
::
ptr
()
->
get_data_path
();
...
...
modules/ximgproc/test/test_adaptive_manifold_ref_impl.cpp
View file @
34969204
...
...
@@ -25,11 +25,13 @@
#include <opencv2/core/private.hpp>
#include <cmath>
using
std
::
numeric_limits
;
using
namespace
cv
;
namespace
{
using
std
::
numeric_limits
;
using
namespace
cv
;
using
namespace
cv
::
ximgproc
;
struct
Buf
{
Mat_
<
Point3f
>
eta_1
;
...
...
@@ -930,6 +932,8 @@ namespace
namespace
cvtest
{
using
namespace
cv
::
ximgproc
;
Ptr
<
AdaptiveManifoldFilter
>
createAMFilterRefImpl
(
double
sigma_s
,
double
sigma_r
,
bool
adjust_outliers
)
{
Ptr
<
AdaptiveManifoldFilter
>
amf
(
new
AdaptiveManifoldFilterRefImpl
());
...
...
modules/ximgproc/test/test_domain_transform.cpp
View file @
34969204
#include "test_precomp.hpp"
namespace
cvtest
{
using
namespace
std
;
using
namespace
std
::
tr1
;
using
namespace
cv
;
using
namespace
testing
;
using
namespace
perf
;
namespace
cvtest
{
using
namespace
cv
;
using
namespace
cv
::
ximgproc
;
static
string
getOpenCVExtraDir
()
{
...
...
modules/ximgproc/test/test_guided_filter.cpp
View file @
34969204
#include "test_precomp.hpp"
namespace
cvtest
{
using
namespace
std
;
using
namespace
std
::
tr1
;
using
namespace
cv
;
using
namespace
testing
;
using
namespace
cv
;
using
namespace
cv
::
ximgproc
;
#ifndef SQR
#define SQR(x) ((x)*(x))
#endif
namespace
cvtest
{
static
string
getOpenCVExtraDir
()
{
return
cvtest
::
TS
::
ptr
()
->
get_data_path
();
...
...
modules/ximgproc/test/test_joint_bilateral_filter.cpp
View file @
34969204
#include "test_precomp.hpp"
namespace
cvtest
{
using
namespace
std
;
using
namespace
std
::
tr1
;
using
namespace
cv
;
using
namespace
testing
;
#ifdef _MSC_VER
# pragma warning(disable: 4512)
#endif
namespace
cvtest
{
using
namespace
cv
;
using
namespace
cv
::
ximgproc
;
static
std
::
string
getOpenCVExtraDir
()
{
...
...
modules/ximgproc/test/test_precomp.hpp
View file @
34969204
...
...
@@ -8,6 +8,6 @@
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/
edge_filter
.hpp>
#include <opencv2/
ximgproc
.hpp>
#endif
\ No newline at end of file
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