Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
testTensorVotingViewer.cpp
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/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"
47#include "DGtal/geometry/volumes/distance/LpMetric.h"
48
49#include "DGtal/shapes/implicit/ImplicitHyperCube.h"
50#include "DGtal/shapes/implicit/ImplicitBall.h"
51#include "DGtal/shapes/GaussDigitizer.h"
52
53#include "DGtal/io/viewers/PolyscopeViewer.h"
54#include "DGtal/io/colormaps/GradientColorMap.h"
55
57
58using namespace std;
59using namespace DGtal;
60
62// Functions for testing class LocalEstimatorFromFunctorAdapter.
64
69template<typename Shape>
70bool testLocalEstimatorFromFunctorAdapter(int argc, char **argv)
71{
72 unsigned int nbok = 0;
73 unsigned int nb = 0;
74 trace.beginBlock ( "Testing init ..." );
75
76 using namespace Z3i;
77
78 typedef GaussDigitizer<Space,Shape> Gauss;
79
80 typedef LightImplicitDigitalSurface<KSpace,Gauss> SurfaceContainer;
82 //typedef Surface::SurfelConstIterator ConstIterator;
83 //typedef Surface::Tracker Tracker;
84 typedef typename Surface::Surfel Surfel;
85
86
87 trace.beginBlock("Creating Surface");
88 Point p1( -100, -100, -100 );
89 Point p2( 100, 100, 100 );
90 KSpace K;
91 nbok += K.init( p1, p2, true ) ? 1 : 0;
92 nb++;
93 trace.info() << "(" << nbok << "/" << nb << ") "
94 << "K.init() is ok" << std::endl;
95
96 //Shape
97 Shape shape(RealPoint::diagonal(0.0), 30.0 );
98 Gauss gauss;
99 gauss.attach(shape);
100 gauss.init(p1,p2,1.0);
101
102 //Surface
103 Surfel bel = Surfaces<KSpace>::findABel( K, gauss, 10000 );
104 SurfaceContainer* surfaceContainer = new SurfaceContainer
105 ( K, gauss, SurfelAdjacency<KSpace::dimension>( true ), bel );
106 Surface surface( surfaceContainer ); // acquired
107 trace.endBlock();
108
109 trace.beginBlock("Creating adapters");
111
112 typedef functors::GaussianKernel ConvFunctor;
113 typedef LocalEstimatorFromSurfelFunctorAdapter<SurfaceContainer, LpMetric<Space>, FunctorVoting, ConvFunctor> Reporter;
114
115 CanonicSCellEmbedder<KSpace> embedder(surface.container().space());
116 FunctorVoting estimator(embedder,1);
117
118 LpMetric<Space> l2(2.0); // L2 metric in R^3 for surface propagation.
119
120 ConvFunctor convFunc(4.0);
121 Reporter reporter;
122 reporter.attach(surface);
123 reporter.setParams(l2, estimator , convFunc, 5.0);
124
125 reporter.init(1, surface.begin() , surface.end());
126
127 std::vector<double> values;
128 reporter.eval( surface.begin(), surface.end(), std::back_insert_iterator<std::vector<double> >(values));
129
130 double maxval = *std::max_element(values.begin(), values.end());
131 double minval = *std::min_element(values.begin(), values.end());
132 trace.info() << "Min/max= "<< minval<<"/"<<maxval<<std::endl;
134 Viewer viewer( K );
135 viewer.allowReuseList = true; // Group elements together
136
137 unsigned int i=0;
138
139 for(typename Surface::ConstIterator it = surface.begin(), itend=surface.end();
140 it!= itend;
141 ++it, ++i)
142 {
143 viewer << WithQuantity(*it, "value", values[i]);
144 }
145
146 trace.endBlock();
147
148 viewer.show();
149 return true;
150}
151
153// Standard services - public :
154
155int main( int argc, char** argv )
156{
157 trace.beginBlock ( "Testing class TensorVotingFeatureExtraction" );
158 trace.info() << "Args:";
159 for ( int i = 0; i < argc; ++i )
160 trace.info() << " " << argv[ i ];
161 trace.info() << endl;
162
165
166 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
167 trace.endBlock();
168 return res ? 0 : 1;
169}
170// //
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
DigitalSurfaceContainer::SurfelConstIterator ConstIterator
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....
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
Aim: this class adapts any local functor on digital surface element to define a local estimator....
Aim: implements l_p metrics.
Definition LpMetric.h:75
static Self diagonal(Component val=1)
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
Aim: Implements a functor to detect feature points from normal tensor voting strategy.
CountedPtr< SH3::DigitalSurface > surface
SH3::DigitalSurface Surface
Z3i this namespace gathers the standard of types for 3D imagery.
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
STL namespace.
Aim: A trivial embedder for signed cell, which corresponds to the canonic injection of cell centroids...
Attach a property to an element.
Definition Display3D.h:327
Aim: defines a functor on double numbers which corresponds to a Gaussian convolution kernel....
Astroid2D< Space > Shape
int main()
Definition testBits.cpp:56
KSpace K
bool testLocalEstimatorFromFunctorAdapter()