DGtal 1.4.0
Loading...
Searching...
No Matches
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/CNormalVectorEstimator.h"
#include "DGtal/geometry/surfaces/estimation/BasicConvolutionWeights.h"
#include "DGtal/geometry/surfaces/estimation/LocalConvolutionNormalVectorEstimator.h"
#include "DGtal/geometry/surfaces/estimation/DigitalSurfaceEmbedderWithNormalVectorEstimator.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 179 of file testNormalVectorEstimatorEmbedder.cpp.

180{
181 trace.beginBlock ( "Testing class LocalConvolutionNormalVectorEstimator" );
182 trace.info() << "Args:";
183 for ( int i = 0; i < argc; ++i )
184 trace.info() << " " << argv[ i ];
185 trace.info() << endl;
186
187 bool res = testLocalConvolutionNormalVectorEstimator ( argc,argv ); // && ... other tests
188 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
189 trace.endBlock();
190
191 return res ? 0 : 1;
192
193}
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition Common.h:153
bool testLocalConvolutionNormalVectorEstimator(int, char **)

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), 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
82 Image image = VolReader<Image>::importVol ( filename );
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 }
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
115 //Estimator definition
120 MyConstantEstimator myNormalEstimator ( digSurf, kernel );
121
122 // Embedder definition
124 SurfaceEmbedder surfaceEmbedder ( digSurf );
126 < SurfaceEmbedder, MyConstantEstimator > SurfaceEmbedderWithTrivialNormal;
127 SurfaceEmbedderWithTrivialNormal mySurfelEmbedder ( surfaceEmbedder,
128 myNormalEstimator );
129
130 // Compute normal vector field and displays it.
131 myNormalEstimator.init ( 1.0, 2 );
132
133 MyConstantEstimator::Quantity res = myNormalEstimator.eval ( it );
134 trace.info() << "Normal vector at begin() : "<< res << std::endl;
135
136 ofstream out ( "cat10-constant.off" );
137 if ( out.good() )
138 digSurf.exportAs3DNOFF ( out,mySurfelEmbedder );
139 out.close();
140 trace.endBlock();
141
142 trace.beginBlock ( "Compute and output surface <cat10-gaussian.off> with gaussian convoluted normals." );
143
144 //Convolution kernel
145 deprecated::GaussianConvolutionWeights < MyDigitalSurface::Size > Gkernel ( 4.0 );
146
147 //Estimator definition
151 MyGaussianEstimator myNormalEstimatorG ( digSurf, Gkernel );
152
153 // Embedder definition
155 SurfaceEmbedderWithGaussianNormal mySurfelEmbedderG ( surfaceEmbedder, myNormalEstimatorG );
156
157 // Compute normal vector field and displays it.
158 myNormalEstimatorG.init ( 1.0, 5 );
159
160 MyGaussianEstimator::Quantity res2 = myNormalEstimatorG.eval ( it );
161 trace.info() << "Normal vector at begin() : "<< res2 << std::endl;
162 std::vector<MyGaussianEstimator::Quantity> allNormals;
163 myNormalEstimatorG.evalAll ( std::back_inserter ( allNormals ) );
164 trace.info() << "Normal vector field of size "<< allNormals.size() << std::endl;
165
166 ofstream out2 ( "cat10-gaussian.off" );
167 if ( out2.good() )
168 digSurf.exportAs3DNOFF ( out2 ,mySurfelEmbedderG );
169 out2.close();
170
171 trace.endBlock();
172
173 return true;
174}
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of a given...
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
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
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...
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...
std::ostream & error()
Aim: implement a trivial constant convolution kernel which returns 1 to each distance.
Aim: implement a Gaussian centered convolution kernel.
Aim: Computes the normal vector at a surface element by convolution of elementary normal vector to ad...
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
DigitalSetBoundary< KSpace, DigitalSet > MyDigitalSurfaceContainer
Aim: A trivial embedder for digital surfaces, which corresponds to the canonic injection of cell cent...
ImageContainerBySTLVector< Domain, Value > Type
static void append(Set &aSet, const ForegroundPredicate &isForeground, typename Image::Domain::ConstIterator itBegin, typename Image::Domain::ConstIterator itEnd)
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
Aim: Represents the concept of estimator of normal vector along digital surfaces.
ImageContainerBySTLVector< Domain, Value > Image

References DGtal::SetFromImage< TSet >::append(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::begin(), DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::error(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::exportAs3DNOFF(), DGtal::Surfaces< TKSpace >::findABel(), DGtal::VolReader< TImageContainer, TFunctor >::importVol(), DGtal::Trace::info(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), and DGtal::trace.

Referenced by main().