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/ExactPredicateLpSeparableMetric.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"
48 #include "DGtal/shapes/implicit/ImplicitHyperCube.h"
49 #include "DGtal/shapes/implicit/ImplicitBall.h"
50 #include "DGtal/shapes/GaussDigitizer.h"
52 #include "DGtal/io/viewers/Viewer3D.h"
53 #include "DGtal/io/colormaps/GradientColorMap.h"
58 using namespace DGtal;
68 template<
typename Shape>
69 bool testLocalEstimatorFromFunctorAdapter(
int argc,
char **argv)
71 unsigned int nbok = 0;
83 typedef typename Surface::Surfel Surfel;
87 Point p1( -100, -100, -100 );
88 Point p2( 100, 100, 100 );
90 nbok += K.init( p1, p2,
true ) ? 1 : 0;
92 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
93 <<
"K.init() is ok" << std::endl;
96 Shape shape(RealPoint::diagonal(0.0), 30.0 );
99 gauss.init(p1,p2,1.0);
103 SurfaceContainer* surfaceContainer =
new SurfaceContainer
105 Surface surface( surfaceContainer );
115 FunctorVoting estimator(embedder,1);
117 ConvFunctor convFunc(4.0);
119 reporter.attach(surface);
120 reporter.setParams(l2Metric, estimator , convFunc, 5.0);
122 reporter.init(1, surface.begin() , surface.end());
124 std::vector<double> values;
125 reporter.eval( surface.begin(), surface.end(), std::back_insert_iterator<std::vector<double> >(values));
127 double maxval = *std::max_element(values.begin(), values.end());
128 double minval = *std::min_element(values.begin(), values.end());
129 trace.
info() <<
"Min/max= "<< minval<<
"/"<<maxval<<std::endl;
130 QApplication application( argc, argv );
133 viewer.setWindowTitle(
"Features from Tensor Voting");
137 Gradient cmap_grad( minval, maxval );
138 cmap_grad.addColor(
Color( 50, 50, 255 ) );
139 cmap_grad.addColor(
Color( 255, 0, 0 ) );
140 cmap_grad.addColor(
Color( 255, 255, 10 ) );
143 viewer <<
SetMode3D((*(surface.begin())).className(),
"Basic" );
146 for(
typename Surface::ConstIterator it = surface.begin(), itend=surface.end();
155 viewer << Viewer3D<>::updateDisplay;
166 int main(
int argc,
char** argv )
170 for (
int i = 0; i < argc; ++i )
174 bool res = testLocalEstimatorFromFunctorAdapter<ImplicitHyperCube<Z3i::Space> >(argc,argv)
177 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
void beginBlock(const std::string &keyword="")
Aim: defines a functor on double numbers which corresponds to a Gaussian convolution kernel...
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
KhalimskySpaceND< 2, Integer > KSpace
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD...
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: this class adapts any local functor on digital surface element to define a local estimator...
Structure representing an RGB triple with alpha component.
Modifier class in a Display3D stream. Useful to choose your own mode for a given class. Realizes the concept CDrawableWithDisplay3D.