DGtal  1.4.beta
testTensorVoting.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/base/BasicFunctors.h"
#include "DGtal/graph/GraphVisitorRange.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/io/Color.h"
#include "DGtal/io/colormaps/GradientColorMap.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/topology/CanonicSCellEmbedder.h"
#include "DGtal/graph/DistanceBreadthFirstVisitor.h"
#include "DGtal/geometry/volumes/distance/LpMetric.h"
#include "DGtal/geometry/surfaces/estimation/LocalEstimatorFromSurfelFunctorAdapter.h"
#include "DGtal/geometry/surfaces/estimation/estimationFunctors/BasicEstimatorFromSurfelsFunctors.h"
#include "DGtal/topology/LightImplicitDigitalSurface.h"
#include "DGtal/geometry/surfaces/estimation/estimationFunctors/TensorVotingFeatureExtraction.h"
#include "DGtal/shapes/implicit/ImplicitHyperCube.h"
#include "DGtal/shapes/implicit/ImplicitBall.h"
#include "DGtal/shapes/GaussDigitizer.h"
Include dependency graph for testTensorVoting.cpp:

Go to the source code of this file.

Functions

template<typename Shape >
bool testLocalEstimatorFromFunctorAdapter ()
 
bool testCube ()
 
int main (int argc, char **argv)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systemes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2013/05/28

Functions for testing class LocalEstimatorFromFunctorAdapter.

This file is part of the DGtal library.

Definition in file testTensorVoting.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 212 of file testTensorVoting.cpp.

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> >()
222  && testCube();// && ... other tests
223  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
224  trace.endBlock();
225  return res ? 0 : 1;
226 }
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD....
Definition: ImplicitBall.h:65
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition: Common.h:153
bool testCube()
bool testLocalEstimatorFromFunctorAdapter()

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testCube(), testLocalEstimatorFromFunctorAdapter(), and DGtal::trace.

◆ testCube()

bool testCube ( )

Definition at line 137 of file testTensorVoting.cpp.

138 {
139  unsigned int nbok = 0;
140  unsigned int nb = 0;
141  trace.beginBlock ( "Testing cube ..." );
142 
143  using namespace Z3i;
145  typedef GaussDigitizer<Space,Shape> Gauss;
146 
147  typedef LightImplicitDigitalSurface<KSpace,Gauss> SurfaceContainer;
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");
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 }
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
DigitalSurfaceContainer::Surfel Surfel
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 an hypercube in n...
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
const Point & sKCoords(const SCell &c) const
Return its Khalimsky coordinates.
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
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
Definition: Surfaces.h:79
Aim: Implements a functor to detect feature points from normal tensor voting strategy.
SH3::DigitalSurface Surface
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Aim: defines a functor on double numbers which corresponds to a Gaussian convolution kernel....
Astroid2D< Space > Shape
MyPointD Point
Definition: testClone2.cpp:383
KSpace K

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, DGtal::KhalimskySpaceND< dim, TInteger >::sKCoords(), and DGtal::trace.

Referenced by main().

◆ testLocalEstimatorFromFunctorAdapter()

template<typename Shape >
bool testLocalEstimatorFromFunctorAdapter ( )

Example of a test. To be completed.

Definition at line 65 of file testTensorVoting.cpp.

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;
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");
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 }

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, and DGtal::trace.

Referenced by main().