DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testTensorVoting.cpp
Go to the documentation of this file.
1
16
29
31
#include <iostream>
32
#include "DGtal/base/Common.h"
33
#include "DGtal/helpers/StdDefs.h"
34
#include "DGtal/base/BasicFunctors.h"
35
#include "DGtal/graph/GraphVisitorRange.h"
36
#include "DGtal/io/boards/Board2D.h"
37
#include "DGtal/io/Color.h"
38
#include "DGtal/io/colormaps/GradientColorMap.h"
39
#include "DGtal/shapes/Shapes.h"
40
#include "DGtal/topology/CanonicSCellEmbedder.h"
41
#include "DGtal/graph/DistanceBreadthFirstVisitor.h"
42
#include "DGtal/geometry/volumes/distance/LpMetric.h"
43
#include "DGtal/geometry/surfaces/estimation/LocalEstimatorFromSurfelFunctorAdapter.h"
44
#include "DGtal/geometry/surfaces/estimation/estimationFunctors/BasicEstimatorFromSurfelsFunctors.h"
45
#include "DGtal/topology/LightImplicitDigitalSurface.h"
46
#include "DGtal/geometry/surfaces/estimation/estimationFunctors/TensorVotingFeatureExtraction.h"
47
48
#include "DGtal/shapes/implicit/ImplicitHyperCube.h"
49
#include "DGtal/shapes/implicit/ImplicitBall.h"
50
#include "DGtal/shapes/GaussDigitizer.h"
52
53
using namespace
std
;
54
using namespace
DGtal
;
55
57
// Functions for testing class LocalEstimatorFromFunctorAdapter.
59
64
template
<
typename
Shape>
65
bool
testLocalEstimatorFromFunctorAdapter
()
66
{
67
unsigned
int
nbok = 0;
68
unsigned
int
nb = 0;
69
trace
.
beginBlock
(
"Testing init ..."
);
70
71
using namespace
Z3i
;
72
73
typedef
GaussDigitizer<Space,Shape>
Gauss;
74
75
typedef
LightImplicitDigitalSurface<KSpace,Gauss>
SurfaceContainer;
76
typedef
DigitalSurface<SurfaceContainer>
Surface
;
77
typedef
typename
Surface::Surfel
Surfel
;
78
79
80
trace
.
beginBlock
(
"Creating Surface"
);
81
Point
p1( -10, -10, -10 );
82
Point
p2( 10, 10, 10 );
83
KSpace
K
;
84
nbok +=
K
.
init
( p1, p2,
true
) ? 1 : 0;
85
nb++;
86
trace
.
info
() <<
"("
<< nbok <<
"/"
<< nb <<
") "
87
<<
"K.init() is ok"
<< std::endl;
88
89
//Shape
90
Shape
shape(
RealPoint::diagonal
(0.0), 6.0 );
91
Gauss gauss;
92
gauss.attach(shape);
93
gauss.init(p1,p2,1.0);
94
95
//Surface
96
Surfel
bel =
Surfaces<KSpace>::findABel
(
K
, gauss, 10000 );
97
SurfaceContainer* surfaceContainer =
new
SurfaceContainer
98
(
K
, gauss,
SurfelAdjacency<KSpace::dimension>
(
true
), bel );
99
Surface
surface
( surfaceContainer );
// acquired
100
trace
.
endBlock
();
101
102
trace
.
beginBlock
(
"Creating adapters"
);
103
typedef
functors::TensorVotingFeatureExtraction<Surfel, CanonicSCellEmbedder<KSpace>
> FunctorVoting;
104
105
typedef
functors::GaussianKernel
ConvFunctor;
106
typedef
LocalEstimatorFromSurfelFunctorAdapter<SurfaceContainer, LpMetric<Z3i::Space>
, FunctorVoting, ConvFunctor> Reporter;
107
108
CanonicSCellEmbedder<KSpace>
embedder(
surface
.container().space());
109
FunctorVoting estimator(embedder,1);
110
111
ConvFunctor convFunc(1.0);
112
Reporter reporter;
113
reporter.attach(
surface
);
114
LpMetric<Z3i::Space>
l2double(2.0);
115
reporter.setParams(l2double, estimator , convFunc, 2.0);
116
117
reporter.init(1,
surface
.begin(),
surface
.end());
118
119
typename
FunctorVoting::Quantity val = reporter.eval(
surface
.begin());
120
trace
.
info
() <<
"probing at "
<< *(
surface
.begin())<<std::endl;
121
122
trace
.
info
() <<
"Voting = "
<<val <<std::endl;
123
124
trace
.
endBlock
();
125
trace
.
endBlock
();
126
127
nbok +=
true
? 1 : 0;
128
nb++;
129
trace
.
info
() <<
"("
<< nbok <<
"/"
<< nb <<
") "
130
<<
"true == true"
<< std::endl;
131
132
return
nbok == nb;
133
}
134
137
bool
testCube
()
138
{
139
unsigned
int
nbok = 0;
140
unsigned
int
nb = 0;
141
trace
.
beginBlock
(
"Testing cube ..."
);
142
143
using namespace
Z3i
;
144
typedef
ImplicitHyperCube<Space>
Shape
;
145
typedef
GaussDigitizer<Space,Shape>
Gauss;
146
147
typedef
LightImplicitDigitalSurface<KSpace,Gauss>
SurfaceContainer;
148
typedef
DigitalSurface<SurfaceContainer>
Surface
;
149
typedef
Surface::Surfel
Surfel
;
150
151
152
trace
.
beginBlock
(
"Creating Surface"
);
153
Point
p1( -10, -10, -10 );
154
Point
p2( 10, 10, 10 );
155
KSpace
K
;
156
nbok +=
K
.
init
( p1, p2,
true
) ? 1 : 0;
157
nb++;
158
trace
.
info
() <<
"("
<< nbok <<
"/"
<< nb <<
") "
159
<<
"K.init() is ok"
<< std::endl;
160
161
//Shape
162
Shape
shape(
RealPoint::diagonal
(0.0), 6.0 );
163
Gauss gauss;
164
gauss.attach(shape);
165
gauss.init(p1,p2,1.0);
166
167
//Surface
168
Surfel
bel =
Surfaces<KSpace>::findABel
(
K
, gauss, 10000 );
169
SurfaceContainer* surfaceContainer =
new
SurfaceContainer
170
(
K
, gauss,
SurfelAdjacency<KSpace::dimension>
(
true
), bel );
171
Surface
surface
( surfaceContainer );
// acquired
172
trace
.
endBlock
();
173
174
trace
.
beginBlock
(
"Creating adapters"
);
175
typedef
functors::TensorVotingFeatureExtraction<Surfel, CanonicSCellEmbedder<KSpace>
> FunctorVoting;
176
177
typedef
functors::GaussianKernel
ConvFunctor;
178
typedef
LocalEstimatorFromSurfelFunctorAdapter<SurfaceContainer, LpMetric<Z3i::Space>
, FunctorVoting, ConvFunctor> Reporter;
179
180
CanonicSCellEmbedder<KSpace>
embedder(
surface
.container().space());
181
FunctorVoting estimator(embedder,1);
182
183
LpMetric<Z3i::Space>
l2(2.0);
184
185
ConvFunctor convFunc(1.0);
186
Reporter reporter(
surface
, l2, estimator , convFunc);
187
reporter.attach(
surface
);
188
reporter.setParams(l2, estimator , convFunc, 2.0);
189
reporter.init(1,
surface
.begin(),
surface
.end());
190
trace
.
endBlock
();
191
192
trace
.
beginBlock
(
"Probing ..."
);
193
Z3i::KSpace::Point
p(11,-12,1);
194
for
(
Surface::ConstIterator
it =
surface
.begin(), itend =
surface
.end(); it!= itend; ++it)
195
{
196
if
(
K
.
sKCoords
(*it) == p)
197
{
198
Reporter::Quantity val = reporter.eval( it );
199
trace
.
info
() <<
"probing at "
<< *it<<std::endl;
200
trace
.
info
() <<
"Voting = "
<<val <<std::endl;
201
}
202
}
203
trace
.
endBlock
();
204
trace
.
endBlock
();
205
206
return
nbok == nb;
207
}
208
210
// Standard services - public :
211
212
int
main
(
int
argc,
char
** argv )
213
{
214
trace
.
beginBlock
(
"Testing class TensorVotingFeatureExtraction"
);
215
trace
.
info
() <<
"Args:"
;
216
for
(
int
i = 0; i < argc; ++i )
217
trace
.
info
() <<
" "
<< argv[ i ];
218
trace
.
info
() << endl;
219
220
bool
res =
testLocalEstimatorFromFunctorAdapter<ImplicitHyperCube<Z3i::Space>
>()
221
&&
testLocalEstimatorFromFunctorAdapter
<
ImplicitBall<Z3i::Space>
>()
222
&&
testCube
();
// && ... other tests
223
trace
.
emphase
() << ( res ?
"Passed."
:
"Error."
) << endl;
224
trace
.
endBlock
();
225
return
res ? 0 : 1;
226
}
227
// //
DGtal::DigitalSurface
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
Definition
DigitalSurface.h:140
DGtal::DigitalSurface< ExplicitSurfaceContainer >::Surfel
DigitalSurfaceContainer::Surfel Surfel
Definition
DigitalSurface.h:162
DGtal::DigitalSurface< ExplicitSurfaceContainer >::ConstIterator
DigitalSurfaceContainer::SurfelConstIterator ConstIterator
Definition
DigitalSurface.h:163
DGtal::GaussDigitizer
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Definition
GaussDigitizer.h:80
DGtal::ImplicitBall
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD....
Definition
ImplicitBall.h:65
DGtal::ImplicitHyperCube
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create an hypercube in n...
Definition
ImplicitHyperCube.h:60
DGtal::KhalimskySpaceND::init
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
DGtal::KhalimskySpaceND< 3, Integer >::Point
PointVector< dim, Integer > Point
Definition
KhalimskySpaceND.h:425
DGtal::KhalimskySpaceND::sKCoords
const Point & sKCoords(const SCell &c) const
Return its Khalimsky coordinates.
DGtal::LightImplicitDigitalSurface
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
Definition
LightImplicitDigitalSurface.h:116
DGtal::LocalEstimatorFromSurfelFunctorAdapter
Aim: this class adapts any local functor on digital surface element to define a local estimator....
Definition
LocalEstimatorFromSurfelFunctorAdapter.h:104
DGtal::LpMetric
Aim: implements l_p metrics.
Definition
LpMetric.h:75
DGtal::PointVector< 3, double >::diagonal
static Self diagonal(Component val=1)
DGtal::Point
DGtal::Surfaces::findABel
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
DGtal::SurfelAdjacency
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
Definition
SurfelAdjacency.h:66
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::emphase
std::ostream & emphase()
DGtal::Trace::info
std::ostream & info()
DGtal::Trace::endBlock
double endBlock()
DGtal::functors::TensorVotingFeatureExtraction
Aim: Implements a functor to detect feature points from normal tensor voting strategy.
Definition
TensorVotingFeatureExtraction.h:82
surface
CountedPtr< SH3::DigitalSurface > surface
Definition
dgtalCalculus-geodesic.cpp:66
Surface
SH3::DigitalSurface Surface
Definition
exampleMaximalSegmentSliceEstimation.cpp:45
DGtal::Z3i
Z3i this namespace gathers the standard of types for 3D imagery.
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::trace
Trace trace
std
STL namespace.
DGtal::CanonicSCellEmbedder
Aim: A trivial embedder for signed cell, which corresponds to the canonic injection of cell centroids...
Definition
CanonicSCellEmbedder.h:66
DGtal::functors::GaussianKernel
Aim: defines a functor on double numbers which corresponds to a Gaussian convolution kernel....
Definition
BasicFunctors.h:947
Surfel
KSpace::SCell Surfel
Definition
testArithmeticalDSSComputerOnSurfels.cpp:50
KSpace
Z3i::KSpace KSpace
Definition
testArithmeticalDSSComputerOnSurfels.cpp:48
Shape
Astroid2D< Space > Shape
Definition
testAstroid2D.cpp:45
K
KSpace K
Definition
testCubicalComplex.cpp:62
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
testLocalEstimatorFromFunctorAdapter
bool testLocalEstimatorFromFunctorAdapter()
Definition
testLocalEstimatorFromFunctorAdapter.cpp:96
testCube
bool testCube()
Definition
testTensorVoting.cpp:137
tests
geometry
surfaces
testTensorVoting.cpp
Generated on
for DGtal by
1.18.0