DGtal  1.3.beta
Functions
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 }

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 }

References DGtal::DigitalSurface< TDigitalSurfaceContainer >::begin(), DGtal::Trace::beginBlock(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::container(), DGtal::PointVector< dim, TEuclideanRing, TContainer >::diagonal(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::end(), 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::DigitalSurface< TDigitalSurfaceContainer >::begin(), DGtal::Trace::beginBlock(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::container(), DGtal::PointVector< dim, TEuclideanRing, TContainer >::diagonal(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::end(), DGtal::Trace::endBlock(), DGtal::Trace::info(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, and DGtal::trace.

Referenced by main().

DGtal::ImplicitHyperCube
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create an hypercube in n...
Definition: ImplicitHyperCube.h:59
DGtal::GaussDigitizer
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Definition: GaussDigitizer.h:79
DGtal::Surfaces
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
Definition: Surfaces.h:78
DGtal::Astroid2D< Space >
DGtal::DigitalSurface::ConstIterator
DigitalSurfaceContainer::SurfelConstIterator ConstIterator
Definition: DigitalSurface.h:163
DGtal::Trace::endBlock
double endBlock()
DGtal::DigitalSurface
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
Definition: DigitalSurface.h:139
DGtal::SurfelAdjacency< KSpace::dimension >
testCube
bool testCube()
Definition: testTensorVoting.cpp:137
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::Trace::emphase
std::ostream & emphase()
DGtal::trace
Trace trace
Definition: Common.h:154
testLocalEstimatorFromFunctorAdapter
bool testLocalEstimatorFromFunctorAdapter()
Definition: testTensorVoting.cpp:65
K
KSpace K
Definition: testCubicalComplex.cpp:62
DGtal::functors::GaussianKernel
Aim: defines a functor on double numbers which corresponds to a Gaussian convolution kernel....
Definition: BasicFunctors.h:946
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::functors::TensorVotingFeatureExtraction
Aim: Implements a functor to detect feature points from normal tensor voting strategy.
Definition: TensorVotingFeatureExtraction.h:81
DGtal::PointVector::diagonal
static Self diagonal(Component val=1)
DGtal::SignedKhalimskyCell
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Definition: KhalimskySpaceND.h:208
Surface
SH3::DigitalSurface Surface
Definition: exampleMaximalSegmentSliceEstimation.cpp:45
DGtal::Trace::info
std::ostream & info()
Surfel
KSpace::SCell Surfel
Definition: testArithmeticalDSSComputerOnSurfels.cpp:50
DGtal::LightImplicitDigitalSurface
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
Definition: LightImplicitDigitalSurface.h:115
DGtal::ImplicitBall
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD....
Definition: ImplicitBall.h:64
DGtal::KhalimskySpaceND::sKCoords
const Point & sKCoords(const SCell &c) const
Return its Khalimsky coordinates.
Shape
Astroid2D< Space > Shape
Definition: testAstroid2D.cpp:48
DGtal::DigitalSurface::Surfel
DigitalSurfaceContainer::Surfel Surfel
Definition: DigitalSurface.h:162
DGtal::PointVector< dim, Integer >
DGtal::LpMetric
Aim: implements l_p metrics.
Definition: LpMetric.h:74
DGtal::LocalEstimatorFromSurfelFunctorAdapter
Aim: this class adapts any local functor on digital surface element to define a local estimator....
Definition: LocalEstimatorFromSurfelFunctorAdapter.h:103
DGtal::CanonicSCellEmbedder< KSpace >
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::KhalimskySpaceND
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Definition: KhalimskySpaceND.h:64