File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/config/TeX-MML-AM_CHTML/MathJax.js
DGtal 2.0.0
testNormalVectorEstimatorEmbedder.cpp File Reference
#include <iostream>
#include <iterator>
#include "DGtal/base/Common.h"
#include "ConfigTest.h"
#include "DGtal/topology/CanonicDigitalSurfaceEmbedder.h"
#include "DGtal/topology/DigitalSurface.h"
#include "DGtal/topology/DigitalSetBoundary.h"
#include "DGtal/topology/ImplicitDigitalSurface.h"
#include "DGtal/topology/LightImplicitDigitalSurface.h"
#include "DGtal/topology/ExplicitDigitalSurface.h"
#include "DGtal/topology/LightExplicitDigitalSurface.h"
#include "DGtal/graph/BreadthFirstVisitor.h"
#include "DGtal/topology/helpers/FrontierPredicate.h"
#include "DGtal/topology/helpers/BoundaryPredicate.h"
#include "DGtal/graph/CUndirectedSimpleLocalGraph.h"
#include "DGtal/graph/CUndirectedSimpleGraph.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/kernel/CanonicEmbedder.h"
#include "DGtal/geometry/surfaces/estimation/LocalEstimatorFromSurfelFunctorAdapter.h"
#include "DGtal/geometry/surfaces/estimation/DigitalSurfaceEmbedderWithNormalVectorEstimator.h"
#include "DGtal/geometry/surfaces/estimation/estimationFunctors/ElementaryConvolutionNormalVectorEstimator.h"
#include "DGtal/geometry/volumes/distance/LpMetric.h"
Include dependency graph for testNormalVectorEstimatorEmbedder.cpp:

Go to the source code of this file.

Functions

bool testLocalConvolutionNormalVectorEstimator (int, char **)
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 Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Jacques-Olivier Lachaud (jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr ) Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
Date
2012/04/08

Functions for testing class NormalVectorEstimatorEmbedder.

This file is part of the DGtal library.

Definition in file testNormalVectorEstimatorEmbedder.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 185 of file testNormalVectorEstimatorEmbedder.cpp.

186{
187 trace.beginBlock ( "Testing class LocalConvolutionNormalVectorEstimator" );
188 trace.info() << "Args:";
189 for ( int i = 0; i < argc; ++i )
190 trace.info() << " " << argv[ i ];
191 trace.info() << endl;
192
193 bool res = testLocalConvolutionNormalVectorEstimator ( argc,argv ); // && ... other tests
194 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
195 trace.endBlock();
196
197 return res ? 0 : 1;
198
199}
Trace trace
bool testLocalConvolutionNormalVectorEstimator(int, char **)

References testLocalConvolutionNormalVectorEstimator(), and DGtal::trace.

◆ testLocalConvolutionNormalVectorEstimator()

bool testLocalConvolutionNormalVectorEstimator ( int ,
char **  )

Example of a test. To be completed.

Definition at line 75 of file testNormalVectorEstimatorEmbedder.cpp.

76{
77 trace.beginBlock ( "Testing convolution neighborhood ..." );
78
79 std::string filename = testPath + "samples/cat10.vol";
80
83 trace.info() <<image<<std::endl;
84 DigitalSet set3d ( image.domain() );
86 0,256 );
87
88 KSpace ks;
89 bool space_ok = ks.init ( image.domain().lowerBound(),
90 image.domain().upperBound(), true );
91 if ( !space_ok )
92 {
93 trace.error() << "Error in the Khamisky space construction."<<std::endl;
94 return 2;
95 }
96 trace.endBlock();
97 typedef SurfelAdjacency<KSpace::dimension> MySurfelAdjacency;
98 MySurfelAdjacency surfAdj ( true ); // interior in all directions.
99
100 trace.beginBlock ( "Set up digital surface." );
104 SCell bel = Surfaces<KSpace>::findABel ( ks, set3d, 100000 );
105 MyDigitalSurfaceContainer* ptrSurfContainer =
106 new MyDigitalSurfaceContainer ( ks, set3d, surfAdj, bel );
107 MyDigitalSurface digSurf ( ptrSurfContainer ); // acquired
108 MyDigitalSurface::ConstIterator it = digSurf.begin();
109 trace.endBlock();
110
111 trace.beginBlock ( "Compute and output surface <cat10-constant.off> with trivial normals." );
112 //Convolution kernel
114 typedef DGtal::functors::ConstValue< double > ConvFunctor;
115
116 LpMetric<Z3i::Space> l1(1.0);
117 CanonicSCellEmbedder<KSpace> embedder(digSurf.container().space());
118
121 Functor, ConvFunctor> MyConstantEstimator;
122 ConvFunctor kernel(1.0);
123 Functor estimator(embedder, 1.0);
124
125 MyConstantEstimator myNormalEstimator;
126 myNormalEstimator.attach(digSurf);
127 myNormalEstimator.setParams(l1, estimator, kernel, 2.0);
128 myNormalEstimator.init(1.0, digSurf.begin(), digSurf.end());
129
130 // Embedder definition
132 SurfaceEmbedder surfaceEmbedder ( digSurf );
134 < SurfaceEmbedder, MyConstantEstimator > SurfaceEmbedderWithTrivialNormal;
135 SurfaceEmbedderWithTrivialNormal mySurfelEmbedder ( surfaceEmbedder,
136 myNormalEstimator );
137
138 MyConstantEstimator::Quantity res = myNormalEstimator.eval ( it );
139 trace.info() << "Normal vector at begin() : "<< res << std::endl;
140
141 ofstream out ( "cat10-constant.off" );
142 if ( out.good() )
143 digSurf.exportAs3DNOFF ( out,mySurfelEmbedder );
144 out.close();
145 trace.endBlock();
146
147 trace.beginBlock ( "Compute and output surface <cat10-gaussian.off> with gaussian convoluted normals." );
148
149 //Convolution kernel
150 typedef DGtal::functors::GaussianKernel ConvFunctorGaussian;
152 Functor, ConvFunctorGaussian> MyGaussianEstimator;
153
154 ConvFunctorGaussian kernelGaussian(4.0);
155 Functor estimatorGaussian(embedder, 1.0); // Passed by alias, can't reuse previous
156
157 MyGaussianEstimator myNormalEstimatorG;
158 myNormalEstimatorG.attach(digSurf);
159 myNormalEstimatorG.setParams(l1, estimatorGaussian, kernelGaussian, 5.0);
160 myNormalEstimatorG.init(1.0, digSurf.begin(), digSurf.end());
161
162 // Embedder definition
164 SurfaceEmbedderWithGaussianNormal mySurfelEmbedderG ( surfaceEmbedder, myNormalEstimatorG );
165
166 MyGaussianEstimator::Quantity res2 = myNormalEstimatorG.eval ( it );
167 trace.info() << "Normal vector at begin() : "<< res2 << std::endl;
168 std::vector<MyGaussianEstimator::Quantity> allNormals;
169 myNormalEstimatorG.evalAll ( std::back_inserter ( allNormals ) );
170 trace.info() << "Normal vector field of size "<< allNormals.size() << std::endl;
171
172 ofstream out2 ( "cat10-gaussian.off" );
173 if ( out2.good() )
174 digSurf.exportAs3DNOFF ( out2 ,mySurfelEmbedderG );
175 out2.close();
176
177 trace.endBlock();
178
179 return true;
180}
Aim: Combines a digital surface embedder with a normal vector estimator to get a model of CDigitalSur...
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
DigitalSurfaceContainer::SurfelConstIterator ConstIterator
Aim: implements association bewteen points lying in a digital domain and values.
Definition Image.h:70
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).
Aim: Estimates normal vector by convolution of elementary normal vector to adjacent surfel.
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
DigitalSetBoundary< KSpace, DigitalSet > MyDigitalSurfaceContainer
KhalimskySpaceND< 3, Integer > KSpace
Definition StdDefs.h:146
KSpace::SCell SCell
Definition StdDefs.h:149
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition StdDefs.h:173
Aim: A trivial embedder for digital surfaces, which corresponds to the canonic injection of cell cent...
Aim: A trivial embedder for signed cell, which corresponds to the canonic injection of cell centroids...
ImageContainerBySTLVector< Domain, Value > Type
static void append(Set &aSet, const ForegroundPredicate &isForeground, typename Image::Domain::ConstIterator itBegin, typename Image::Domain::ConstIterator itEnd)
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
Aim: defines a functor on double numbers which corresponds to a Gaussian convolution kernel....
Image image(domain)

References DGtal::SetFromImage< TSet >::append(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::begin(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::container(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::end(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::exportAs3DNOFF(), DGtal::Surfaces< TKSpace >::findABel(), image(), DGtal::VolReader< TImageContainer, TFunctor >::importVol(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), DGtal::DigitalSetBoundary< TKSpace, TDigitalSet >::space(), and DGtal::trace.

Referenced by main().