DGtal 1.4.0
Loading...
Searching...
No Matches
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/Viewer3D.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/geometry/surfaces/estimation/BasicConvolutionWeights.h"
#include "DGtal/geometry/surfaces/estimation/LocalConvolutionNormalVectorEstimator.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 181 of file testLocalConvolutionNormalVectorEstimator.cpp.

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

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), 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 QApplication application ( argc,argv );
76
77 std::string filename = testPath + "samples/cat10.vol";
78
80 Image image = VolReader<Image>::importVol ( filename );
81 trace.info() <<image<<std::endl;
82 DigitalSet set3d ( image.domain() );
84 0,256 );
85
86 KSpace ks;
87 bool space_ok = ks.init ( image.domain().lowerBound(),
88 image.domain().upperBound(), true );
89 if ( !space_ok )
90 {
91 trace.error() << "Error in the Khamisky space construction."<<std::endl;
92 return true; //2; (return a bool !!!)
93 }
95 typedef SurfelAdjacency<KSpace::dimension> MySurfelAdjacency;
96 MySurfelAdjacency surfAdj ( true ); // interior in all directions.
97
98 trace.beginBlock ( "Set up digital surface." );
102 SCell bel = Surfaces<KSpace>::findABel ( ks, set3d, 100000 );
103 MyDigitalSurfaceContainer* ptrSurfContainer =
104 new MyDigitalSurfaceContainer ( ks, set3d, surfAdj, bel );
105 MyDigitalSurface digSurf ( ptrSurfContainer ); // acquired
106
107 MyDigitalSurface::ConstIterator it = digSurf.begin();
108
109
110 //Convolution kernel
112
113 //Estimator definition
116 MyEstimator myNormalEstimator ( digSurf, kernel );
117
118 myNormalEstimator.init ( 1.0, 5 );
119
120 MyEstimator::Quantity res = myNormalEstimator.eval ( it );
121 trace.info() << "Normal vector at begin() : "<< res << std::endl;
122
124 viewer.show();
125
126 DGtal::Color lineColorSave = viewer.getLineColor();
127 viewer.setLineColor( DGtal::Color ( 20,200,20 ));
128 for ( MyDigitalSurface::ConstIterator itbis = digSurf.begin(),itend=digSurf.end();
129 itbis!=itend; ++itbis )
130 {
131 viewer << ks.unsigns ( *itbis );
132
133 Point center = ks.sCoords ( *itbis );
134 MyEstimator::Quantity normal = myNormalEstimator.eval ( itbis );
135
136 viewer.addLine ( center,
137 DGtal::Z3i::RealPoint(center[0]-3*normal[0],
138 center[1]-3*normal[1],
139 center[2]-3*normal[2]) );
140 }
141 viewer.setLineColor( lineColorSave);
142 viewer<< Viewer3D<>::updateDisplay;
143
144 //Convolution kernel
146
147 //Estimator definition
150 MyEstimatorGaussian myNormalEstimatorG ( digSurf, Gkernel );
151
152 myNormalEstimatorG.init ( 1.0, 15 );
153
154 MyEstimatorGaussian::Quantity res2 = myNormalEstimatorG.eval ( it );
155 trace.info() << "Normal vector at begin() : "<< res2 << std::endl;
156
157 viewer<< CustomColors3D ( Color ( 200, 0, 0 ),Color ( 200, 0,0 ) );
158 lineColorSave = viewer.getLineColor();
159 viewer.setLineColor( DGtal::Color ( 200,20,20 ));
160 for ( MyDigitalSurface::ConstIterator itbis = digSurf.begin(),itend=digSurf.end();
161 itbis!=itend; ++itbis )
162 {
163 viewer << ks.unsigns ( *itbis );
164
165 Point center = ks.sCoords ( *itbis );
166 MyEstimatorGaussian::Quantity normal = myNormalEstimatorG.eval ( itbis );
167 viewer.addLine ( center,
168 DGtal::Z3i::RealPoint(center[0]-3*normal[0],
169 center[1]-3*normal[1],
170 center[2]-3*normal[2]) );
171 }
172 viewer.setLineColor( lineColorSave);
173 viewer<< Viewer3D<>::updateDisplay;
174
175 return application.exec();
176}
Structure representing an RGB triple with alpha component.
Definition Color.h:68
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: 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.
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...
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
Point center(const std::vector< Point > &points)
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())
ImageContainerBySTLVector< Domain, Value > Image

References DGtal::Display3D< Space, KSpace >::addLine(), DGtal::SetFromImage< TSet >::append(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::begin(), DGtal::Trace::beginBlock(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::end(), DGtal::Trace::endBlock(), DGtal::Trace::error(), DGtal::Surfaces< TKSpace >::findABel(), DGtal::Display3D< Space, KSpace >::getLineColor(), DGtal::VolReader< TImageContainer, TFunctor >::importVol(), DGtal::Trace::info(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), DGtal::KhalimskySpaceND< dim, TInteger >::sCoords(), DGtal::Display3D< Space, KSpace >::setLineColor(), DGtal::Viewer3D< TSpace, TKSpace >::show(), DGtal::trace, and DGtal::KhalimskySpaceND< dim, TInteger >::unsigns().

Referenced by main().