DGtal  1.3.beta
Functions
testSphericalHoughNormalVectorEstimator.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "ConfigTest.h"
#include "DGtalCatch.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/shapes/implicit/ImplicitHyperCube.h"
#include "DGtal/shapes/implicit/ImplicitBall.h"
#include "DGtal/shapes/GaussDigitizer.h"
#include "DGtal/topology/LightImplicitDigitalSurface.h"
#include "DGtal/topology/DigitalSurface.h"
#include "DGtal/topology/CanonicSCellEmbedder.h"
#include "DGtal/base/BasicFunctors.h"
#include "DGtal/geometry/volumes/distance/LpMetric.h"
#include "DGtal/geometry/surfaces/estimation/LocalEstimatorFromSurfelFunctorAdapter.h"
#include "DGtal/geometry/surfaces/estimation/estimationFunctors/SphericalHoughNormalVectorEstimator.h"
#include "DGtal/io/boards/Board3D.h"
Include dependency graph for testSphericalHoughNormalVectorEstimator.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("Testing SphericalHoughNormalVectorEstimator")
 

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 Systemes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2016/03/14

Functions for testing class SphericalHoughNormalVectorEstimator.

This file is part of the DGtal library.

Definition in file testSphericalHoughNormalVectorEstimator.cpp.

Function Documentation

◆ TEST_CASE()

TEST_CASE ( "Testing SphericalHoughNormalVectorEstimator"  )

Definition at line 62 of file testSphericalHoughNormalVectorEstimator.cpp.

63 {
64  typedef ImplicitBall<Space> Shape;
65  typedef GaussDigitizer<Space,Shape> Gauss;
66 
67  typedef LightImplicitDigitalSurface<KSpace,Gauss> SurfaceContainer;
69  typedef Surface::Surfel Surfel;
70 
71 
72  Point p1( -50, -50, -50 );
73  Point p2( 50, 50, 50 );
74  KSpace K;
75  REQUIRE( K.init( p1, p2, true ) );
76 
77 
78  //Shape
79  Shape shape(RealPoint::diagonal(0.0), 10.0 );
80  Gauss gauss;
81  gauss.attach(shape);
82  gauss.init(p1,p2,1.0);
83 
84  //Surface
85  Surfel bel = Surfaces<KSpace>::findABel( K, gauss, 10000 );
86  SurfaceContainer* surfaceContainer = new SurfaceContainer( K, gauss, SurfelAdjacency<KSpace::dimension>( true ), bel );
87  Surface surface( surfaceContainer ); // acquired
88 
89 
91  typedef functors::ConstValue<double> ConstFunctor;
92  typedef LocalEstimatorFromSurfelFunctorAdapter<SurfaceContainer, LpMetric<Z3i::Space>, SphericalHough, ConstFunctor> Reporter;
93 
94  CanonicSCellEmbedder<KSpace> embedder(surface.container().space());
95  SphericalHough estimator(embedder,1.0 , 0.001, 1000 , 10, 1);
96 
97  LpMetric<Z3i::Space> l2(2.0);
98  ConstFunctor constFunc(1.0);
99  Reporter reporter(surface, l2, estimator , constFunc);
100  reporter.attach(surface);
101  reporter.setParams(l2, estimator , constFunc, 10.0);
102  reporter.init(1, surface.begin(),surface.end());
103 
104  REQUIRE( reporter.isValid() );
105 
106  typedef Reporter::Quantity Quantity;
107 
108  Quantity result = reporter.eval( surface.begin() );
109  trace.info() << "Result at begin = "<< result <<std::endl;
110 
111  //true normal (implicitBall)
112  RealPoint res = embedder( *(surface.begin()) ).getNormalized();
113  trace.info() << "Expecting = "<< res <<std::endl;
114 
115  REQUIRE( std::abs(result.dot(res)) > 0.9 );
116 
117 
118 #ifdef WITH_VISU3D_QGLVIEWER_TESTS
119  int argc=0;
120  char **argv;
121  QApplication application(argc,argv);
123  viewer.show();
124  for(Surface::ConstIterator it = surface.begin(), itend=surface.end(); it != itend ;
125  ++it)
126  {
127  Quantity normal = reporter.eval( it );
128  viewer << CustomColors3D( DGtal::Color(static_cast<unsigned char>(255*abs(normal[0])),
129  static_cast<unsigned char>(255*abs(normal[1])),
130  static_cast<unsigned char>(255*abs(normal[2]))),
131  DGtal::Color(static_cast<unsigned char>(255*abs(normal[0])),
132  static_cast<unsigned char>(255*abs(normal[1])),
133  static_cast<unsigned char>(255*abs(normal[2]))));
134 
135  viewer << K.unsigns(*it) ;
136 
137  Point center = K.sCoords ( *it );
138  }
139  viewer<< Viewer3D<>::updateDisplay;
140  application.exec();
141 #endif
142 }

References DGtal::DigitalSurface< TDigitalSurfaceContainer >::begin(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::container(), DGtal::PointVector< dim, TEuclideanRing, TContainer >::diagonal(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::end(), DGtal::Trace::info(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, REQUIRE(), DGtal::KhalimskySpaceND< dim, TInteger >::sCoords(), DGtal::Viewer3D< TSpace, TKSpace >::show(), DGtal::trace, and DGtal::KhalimskySpaceND< dim, TInteger >::unsigns().

DGtal::GaussDigitizer
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Definition: GaussDigitizer.h:79
DGtal::Surfaces
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
Definition: Surfaces.h:78
DGtal::Astroid2D< Space >
DGtal::DigitalSurface::ConstIterator
DigitalSurfaceContainer::SurfelConstIterator ConstIterator
Definition: DigitalSurface.h:163
DGtal::detail::center
Point center(const std::vector< Point > &points)
Definition: QuickHullKernels.h:66
DGtal::DigitalSurface
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
Definition: DigitalSurface.h:139
DGtal::SurfelAdjacency< KSpace::dimension >
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:67
DGtal::KhalimskySpaceND::init
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
DGtal::trace
Trace trace
Definition: Common.h:154
K
KSpace K
Definition: testCubicalComplex.cpp:62
REQUIRE
REQUIRE(domain.isInside(aPoint))
DGtal::PointVector::diagonal
static Self diagonal(Component val=1)
DGtal::KhalimskySpaceND::sCoords
Point sCoords(const SCell &c) const
Return its digital coordinates.
DGtal::SignedKhalimskyCell
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Definition: KhalimskySpaceND.h:208
Surface
SH3::DigitalSurface Surface
Definition: exampleMaximalSegmentSliceEstimation.cpp:45
DGtal::Trace::info
std::ostream & info()
Surfel
KSpace::SCell Surfel
Definition: testArithmeticalDSSComputerOnSurfels.cpp:50
DGtal::LightImplicitDigitalSurface
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
Definition: LightImplicitDigitalSurface.h:115
DGtal::Viewer3D
Definition: Viewer3D.h:135
DGtal::PointVector::getNormalized
PointVector< dim, double, std::array< double, dim > > getNormalized() const
DGtal::ImplicitBall
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD....
Definition: ImplicitBall.h:64
Shape
Astroid2D< Space > Shape
Definition: testAstroid2D.cpp:48
DGtal::functors::SphericalHoughNormalVectorEstimator
Aim: This functor estimates normal vector for a collection of surfels using spherical accumulator bas...
Definition: SphericalHoughNormalVectorEstimator.h:84
DGtal::functors::ConstValue
Aim: Define a simple functor that returns a constant value (0 by default).
Definition: BasicFunctors.h:310
DGtal::functions::abs
T abs(const T &a)
Definition: BasicMathFunctions.h:116
DGtal::DigitalSurface::Surfel
DigitalSurfaceContainer::Surfel Surfel
Definition: DigitalSurface.h:162
DGtal::PointVector< dim, Integer >
DGtal::LpMetric
Aim: implements l_p metrics.
Definition: LpMetric.h:74
DGtal::KhalimskySpaceND::unsigns
Cell unsigns(const SCell &p) const
Creates an unsigned cell from a signed one.
DGtal::LocalEstimatorFromSurfelFunctorAdapter
Aim: this class adapts any local functor on digital surface element to define a local estimator....
Definition: LocalEstimatorFromSurfelFunctorAdapter.h:103
DGtal::CanonicSCellEmbedder< KSpace >
DGtal::KhalimskySpaceND
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Definition: KhalimskySpaceND.h:64