35#include "DGtal/base/Common.h"
36#include "ConfigTest.h"
37#include "DGtal/topology/CanonicDigitalSurfaceEmbedder.h"
38#include "DGtal/topology/DigitalSurface.h"
39#include "DGtal/topology/DigitalSetBoundary.h"
40#include "DGtal/topology/ImplicitDigitalSurface.h"
41#include "DGtal/topology/LightImplicitDigitalSurface.h"
42#include "DGtal/topology/ExplicitDigitalSurface.h"
43#include "DGtal/topology/LightExplicitDigitalSurface.h"
44#include "DGtal/graph/BreadthFirstVisitor.h"
45#include "DGtal/topology/helpers/FrontierPredicate.h"
46#include "DGtal/topology/helpers/BoundaryPredicate.h"
47#include "DGtal/graph/CUndirectedSimpleLocalGraph.h"
48#include "DGtal/graph/CUndirectedSimpleGraph.h"
50#include "DGtal/io/readers/VolReader.h"
51#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
53#include "DGtal/images/ImageSelector.h"
54#include "DGtal/shapes/Shapes.h"
55#include "DGtal/helpers/StdDefs.h"
56#include "DGtal/kernel/CanonicEmbedder.h"
58#include "DGtal/geometry/surfaces/estimation/LocalEstimatorFromSurfelFunctorAdapter.h"
59#include "DGtal/geometry/surfaces/estimation/DigitalSurfaceEmbedderWithNormalVectorEstimator.h"
60#include "DGtal/geometry/surfaces/estimation/estimationFunctors/ElementaryConvolutionNormalVectorEstimator.h"
61#include "DGtal/geometry/volumes/distance/LpMetric.h"
77 trace.beginBlock (
"Testing convolution neighborhood ..." );
79 std::string filename = testPath +
"samples/cat10.vol";
89 bool space_ok = ks.
init (
image.domain().lowerBound(),
90 image.domain().upperBound(),
true );
93 trace.error() <<
"Error in the Khamisky space construction."<<std::endl;
98 MySurfelAdjacency surfAdj (
true );
100 trace.beginBlock (
"Set up digital surface." );
111 trace.beginBlock (
"Compute and output surface <cat10-constant.off> with trivial normals." );
121 Functor, ConvFunctor> MyConstantEstimator;
122 ConvFunctor kernel(1.0);
123 Functor estimator(embedder, 1.0);
125 MyConstantEstimator myNormalEstimator;
126 myNormalEstimator.attach(digSurf);
127 myNormalEstimator.setParams(l1, estimator, kernel, 2.0);
128 myNormalEstimator.init(1.0, digSurf.
begin(), digSurf.
end());
132 SurfaceEmbedder surfaceEmbedder ( digSurf );
134 < SurfaceEmbedder, MyConstantEstimator > SurfaceEmbedderWithTrivialNormal;
135 SurfaceEmbedderWithTrivialNormal mySurfelEmbedder ( surfaceEmbedder,
138 MyConstantEstimator::Quantity res = myNormalEstimator.eval ( it );
139 trace.info() <<
"Normal vector at begin() : "<< res << std::endl;
141 ofstream out (
"cat10-constant.off" );
147 trace.beginBlock (
"Compute and output surface <cat10-gaussian.off> with gaussian convoluted normals." );
152 Functor, ConvFunctorGaussian> MyGaussianEstimator;
154 ConvFunctorGaussian kernelGaussian(4.0);
155 Functor estimatorGaussian(embedder, 1.0);
157 MyGaussianEstimator myNormalEstimatorG;
158 myNormalEstimatorG.attach(digSurf);
159 myNormalEstimatorG.setParams(l1, estimatorGaussian, kernelGaussian, 5.0);
160 myNormalEstimatorG.init(1.0, digSurf.
begin(), digSurf.
end());
164 SurfaceEmbedderWithGaussianNormal mySurfelEmbedderG ( surfaceEmbedder, myNormalEstimatorG );
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;
172 ofstream out2 (
"cat10-gaussian.off" );
185int main (
int argc,
char** argv )
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;
194 trace.emphase() << ( res ?
"Passed." :
"Error." ) << endl;
185int main (
int argc,
char** argv ) {
…}
const KSpace & space() const
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::Surfel Surfel
const DigitalSurfaceContainer & container() const
DigitalSurfaceContainer::SurfelConstIterator ConstIterator
ConstIterator begin() const
ConstIterator end() const
void exportAs3DNOFF(std::ostream &out, const SCellEmbedderWithGradientMap &scembedder) const
Aim: implements association bewteen points lying in a digital domain and values.
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.
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
Z3i this namespace gathers the standard of types for 3D imagery.
KhalimskySpaceND< 3, Integer > KSpace
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
DGtal is the top-level namespace which contains all DGtal functions and types.
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....
bool testLocalConvolutionNormalVectorEstimator(int, char **)