DGtal 1.4.0
Loading...
Searching...
No Matches
testLocalEstimatorFromFunctorAdapter.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "ConfigTest.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/kernel/CanonicEmbedder.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/geometry/surfaces/estimation/estimationFunctors/CLocalEstimatorFromSurfelFunctor.h"
#include "DGtal/topology/LightImplicitDigitalSurface.h"
#include "DGtal/topology/DigitalSurface.h"
#include "DGtal/geometry/surfaces/estimation/estimationFunctors/ElementaryConvolutionNormalVectorEstimator.h"
#include "DGtal/geometry/surfaces/estimation/estimationFunctors/MongeJetFittingGaussianCurvatureEstimator.h"
#include "DGtal/geometry/surfaces/estimation/estimationFunctors/MongeJetFittingMeanCurvatureEstimator.h"
#include "DGtal/geometry/surfaces/estimation/estimationFunctors/MongeJetFittingNormalVectorEstimator.h"
#include "DGtal/geometry/surfaces/estimation/estimationFunctors/LinearLeastSquareFittingNormalVectorEstimator.h"
Include dependency graph for testLocalEstimatorFromFunctorAdapter.cpp:

Go to the source code of this file.

Functions

bool testLocalEstimatorFromFunctorAdapter ()
 
bool testConcepts ()
 
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 testLocalEstimatorFromFunctorAdapter.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 203 of file testLocalEstimatorFromFunctorAdapter.cpp.

204{
205 trace.beginBlock ( "Testing class LocalEstimatorFromFunctorAdapter" );
206 trace.info() << "Args:";
207 for ( int i = 0; i < argc; ++i )
208 trace.info() << " " << argv[ i ];
209 trace.info() << endl;
210
211 bool res = testConcepts() && testLocalEstimatorFromFunctorAdapter(); // && ... other tests
212 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
213 trace.endBlock();
214 return res ? 0 : 1;
215}
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition Common.h:153
bool testLocalEstimatorFromFunctorAdapter()

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

◆ testConcepts()

bool testConcepts ( )

Definition at line 181 of file testLocalEstimatorFromFunctorAdapter.cpp.

182{
184 typedef CanonicSCellEmbedder<Z3i::KSpace> Embedder;
185 trace.beginBlock("Checking concepts");
188
189#ifdef WITH_CGAL
194#endif
195
196 trace.endBlock();
197 return true;
198}
Aim: Estimates normal vector by convolution of elementary normal vector to adjacent surfel.
Aim: Estimates normal vector using CGAL linear least squares plane fitting.
Aim: Estimates Gaussian curvature using CGAL Jet Fitting and Monge Form.
Aim: Estimates Mean curvature using CGAL Jet Fitting and Monge Form.
Aim: Estimates normal vector using CGAL Jet Fitting and Monge Form.
Aim: A trivial embedder for signed cell, which corresponds to the canonic injection of cell centroids...
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Aim: this concept describes functors on digtal surface surfel which can be used to define local estim...

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), and DGtal::trace.

Referenced by main().

◆ testLocalEstimatorFromFunctorAdapter()

bool testLocalEstimatorFromFunctorAdapter ( )

Example of a test. To be completed.

Definition at line 96 of file testLocalEstimatorFromFunctorAdapter.cpp.

97{
98 unsigned int nbok = 0;
99 unsigned int nb = 0;
100 trace.beginBlock ( "Testing init ..." );
101
102 using namespace Z3i;
103 typedef ImplicitDigitalEllipse3<Point> ImplicitDigitalEllipse;
106 typedef SurfaceContainer::SurfelConstIterator ConstIterator;
107 typedef SurfaceContainer::Surfel Surfel;
108
109
110 trace.beginBlock("Creating Surface");
111 Point p1( -10, -10, -10 );
112 Point p2( 10, 10, 10 );
113 KSpace K;
114 nbok += K.init( p1, p2, true ) ? 1 : 0;
115 nb++;
116 trace.info() << "(" << nbok << "/" << nb << ") "
117 << "K.init() is ok" << std::endl;
118 ImplicitDigitalEllipse ellipse( 6.0, 4.5, 3.4 );
119 Surfel bel = Surfaces<KSpace>::findABel( K, ellipse, 10000 );
120 SurfaceContainer* surfaceContainer = new SurfaceContainer
121 ( K, ellipse, SurfelAdjacency<KSpace::dimension>( true ), bel );
122 Surface surface( surfaceContainer ); // acquired
123 unsigned int nbsurfels = 0;
124 for ( ConstIterator it = surface.begin(), it_end = surface.end();
125 it != it_end; ++it )
126 {
127 ++nbsurfels;
128 }
129 trace.info() << nbsurfels << " surfels found." << std::endl;
130 trace.endBlock();
131
132 trace.beginBlock("Creating adapter");
134 typedef DGtal::functors::ConstValue< double > ConvFunctor;
136 Functor, ConvFunctor> Reporter;
137
139 Functor, DGtal::functors::GaussianKernel> ReporterGaussian;
140
141 LpMetric<Z3i::Space> l2(2.0);
142 CanonicSCellEmbedder<KSpace> embedder(surface.container().space());
143 Functor estimator(embedder, 1);
144
145 ConvFunctor convFunc(1.0);
146 Reporter reporter;
147 reporter.attach(surface);
148 reporter.setParams(l2,estimator,convFunc, 5);
149
150 //We just test the init for Gaussian
151 DGtal::functors::GaussianKernel gaussKernelFunc(1.0);
152 ReporterGaussian reporterGaussian;
153 reporterGaussian.attach(surface);
154 reporterGaussian.setParams(l2,estimator,gaussKernelFunc, 5.0);
155 reporterGaussian.init(1, surface.begin(), surface.end());
156
157 reporter.init(1.0, surface.begin(), surface.end());
158 Functor::Quantity val = reporter.eval( surface.begin() );
159 trace.info() << "Value with radius 5= "<<val << std::endl;
160 nbok += ((fabs((double)val - 124.0)) < 40) ? 1 : 0;
161 nb++;
162
163 reporter.setParams(l2,estimator,convFunc, 20.0);
164 reporter.init(1, surface.begin(), surface.end());
165 Functor::Quantity val2 = reporter.eval( surface.begin() );
166 trace.info() << "Value with radius 20= "<<val2 << std::endl;
167
168 nbok += ((fabs((double)val2 - 398.0)) < 120) ? 1 : 0;
169 nb++;
170
171 trace.endBlock();
172 trace.endBlock();
173
174 trace.info() << "(" << nbok << "/" << nb << ") "
175 << "true == true" << std::endl;
176
177 return nbok == nb;
178}
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
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.
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 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: Define a simple functor that returns a constant value (0 by default).
CountedPtr< SH3::DigitalSurface > surface
SH3::DigitalSurface Surface
MyDigitalSurface::ConstIterator ConstIterator
Aim: defines a functor on double numbers which corresponds to a Gaussian convolution kernel....
MyPointD Point
InHalfPlaneBySimple3x3Matrix< Point, double > Functor
KSpace K

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

Referenced by main().