Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
testLocalConvolutionNormalVectorEstimator.cpp File Reference
#include <iostream>
#include "ConfigTest.h"
#include "DGtal/base/Common.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/io/viewers/PolyscopeViewer.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/geometry/surfaces/estimation/LocalEstimatorFromSurfelFunctorAdapter.h"
#include "DGtal/geometry/surfaces/estimation/estimationFunctors/ElementaryConvolutionNormalVectorEstimator.h"
#include "DGtal/geometry/volumes/distance/LpMetric.h"
Include dependency graph for testLocalConvolutionNormalVectorEstimator.cpp:

Go to the source code of this file.

Functions

bool testLocalConvolutionNormalVectorEstimator (int argc, char **argv)
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
Date
2012/03/03

Functions for testing class LocalConvolutionNormalVectorEstimator.

This file is part of the DGtal library.

Definition in file testLocalConvolutionNormalVectorEstimator.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 175 of file testLocalConvolutionNormalVectorEstimator.cpp.

176{
177 trace.beginBlock ( "Testing class LocalConvolutionNormalVectorEstimator" );
178 trace.info() << "Args:";
179 for ( int i = 0; i < argc; ++i )
180 trace.info() << " " << argv[ i ];
181 trace.info() << endl;
182
183 bool res = testLocalConvolutionNormalVectorEstimator ( argc,argv ); // && ... other tests
184 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
185 trace.endBlock();
186
187 return (res ? 0:1);
188}
Trace trace
bool testLocalConvolutionNormalVectorEstimator(int argc, char **argv)

References testLocalConvolutionNormalVectorEstimator(), and DGtal::trace.

◆ testLocalConvolutionNormalVectorEstimator()

bool testLocalConvolutionNormalVectorEstimator ( int argc,
char ** argv )

Example of a test. To be completed.

Definition at line 71 of file testLocalConvolutionNormalVectorEstimator.cpp.

72{
73 trace.beginBlock ( "Testing convolution neighborhood ..." );
74
75 std::string filename = testPath + "samples/cat10.vol";
76
79 trace.info() <<image<<std::endl;
80 DigitalSet set3d ( image.domain() );
82 0,256 );
83
84 KSpace ks;
85 bool space_ok = ks.init ( image.domain().lowerBound(),
86 image.domain().upperBound(), true );
87 if ( !space_ok )
88 {
89 trace.error() << "Error in the Khamisky space construction."<<std::endl;
90 return true; //2; (return a bool !!!)
91 }
92 trace.endBlock();
93 typedef SurfelAdjacency<KSpace::dimension> MySurfelAdjacency;
94 MySurfelAdjacency surfAdj ( true ); // interior in all directions.
95
96 trace.beginBlock ( "Set up digital surface." );
100 SCell bel = Surfaces<KSpace>::findABel ( ks, set3d, 100000 );
101 MyDigitalSurfaceContainer* ptrSurfContainer =
102 new MyDigitalSurfaceContainer ( ks, set3d, surfAdj, bel );
103 MyDigitalSurface digSurf ( ptrSurfContainer ); // acquired
104
105 MyDigitalSurface::ConstIterator it = digSurf.begin();
106
107
108 //Convolution kernel
110 typedef DGtal::functors::ConstValue< double > ConvFunctor;
111
112 LpMetric<Z3i::Space> l1(1.0);
113 CanonicSCellEmbedder<KSpace> embedder(digSurf.container().space());
114
117 Functor, ConvFunctor> MyEstimator;
118 ConvFunctor kernel(1.0);
119 Functor estimator(embedder, 1.0);
120
121 MyEstimator myNormalEstimator;
122 myNormalEstimator.attach(digSurf);
123 myNormalEstimator.setParams(l1, estimator, kernel, 5.0);
124 myNormalEstimator.init(1.0, digSurf.begin(), digSurf.end());
125
126 MyEstimator::Quantity res = myNormalEstimator.eval ( it );
127 trace.info() << "Normal vector at begin() : "<< res << std::endl;
128
130 viewer.allowReuseList = true; // Enable auto grouping, which is to some extend, way better
131
132 // KCell will be rendered as quads (not signed)
133 viewer.newQuadList("Constant estimator");
134 for ( MyDigitalSurface::ConstIterator itbis = digSurf.begin(),itend=digSurf.end();
135 itbis!=itend; ++itbis )
136 {
137 Point center = ks.sCoords ( *itbis );
138 MyEstimator::Quantity normal = myNormalEstimator.eval ( itbis );
139 viewer << Color(200, 0, 0) << WithQuantity(ks.unsigns( *itbis ), "normal", -normal);
140 }
141
142 //Convolution kernel
143 typedef DGtal::functors::GaussianKernel ConvFunctorGaussian;
145 Functor, ConvFunctorGaussian> MyEstimatorGaussian;
146
147 ConvFunctorGaussian kernelGaussian(14.0);
148 Functor estimatorGaussian(embedder, 1.0); // Passed by alias, can't reuse previous
149
150 MyEstimatorGaussian myNormalEstimatorG;
151 myNormalEstimatorG.attach(digSurf);
152 myNormalEstimatorG.setParams(l1, estimatorGaussian, kernelGaussian, 15.0);
153 myNormalEstimatorG.init(1.0, digSurf.begin(), digSurf.end());
154
155 MyEstimatorGaussian::Quantity res2 = myNormalEstimatorG.eval ( it );
156 trace.info() << "Normal vector at begin() : "<< res2 << std::endl;
157
158 // KCell will be rendered as quads (not signed)
159 viewer.newQuadList("Gaussian estimator");
160 for ( MyDigitalSurface::ConstIterator itbis = digSurf.begin(),itend=digSurf.end();
161 itbis!=itend; ++itbis )
162 {
163 Point center = ks.sCoords ( *itbis );
164 MyEstimatorGaussian::Quantity normal = myNormalEstimatorG.eval ( itbis );
165 viewer << Color(200, 0, 0) << WithQuantity(ks.unsigns( *itbis ), "normal", -normal);
166 }
167
168 viewer.show();
169 return 0;
170}
Structure representing an RGB triple with alpha component.
Definition Color.h:77
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.
Cell unsigns(const SCell &p) const
Creates an unsigned cell from a signed one.
Point sCoords(const SCell &c) const
Return its digital 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
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
Point center(const std::vector< Point > &points)
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())
Attach a property to an element.
Definition Display3D.h:327
Aim: defines a functor on double numbers which corresponds to a Gaussian convolution kernel....
Image image(domain)

References DGtal::Display3D< Space, KSpace >::allowReuseList, DGtal::SetFromImage< TSet >::append(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::begin(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::container(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::end(), DGtal::Surfaces< TKSpace >::findABel(), image(), DGtal::VolReader< TImageContainer, TFunctor >::importVol(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), DGtal::Display3D< Space, KSpace >::newQuadList(), DGtal::KhalimskySpaceND< dim, TInteger >::sCoords(), DGtal::PolyscopeViewer< Space, KSpace >::show(), DGtal::DigitalSetBoundary< TKSpace, TDigitalSet >::space(), DGtal::trace, and DGtal::KhalimskySpaceND< dim, TInteger >::unsigns().

Referenced by main().