DGtal  0.9.3
Functions
testBinomialConvolver.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/PointVector.h"
#include "DGtal/geometry/curves/BinomialConvolver.h"
#include "DGtal/geometry/curves/estimation/CCurveLocalGeometricEstimator.h"
Include dependency graph for testBinomialConvolver.cpp:

Go to the source code of this file.

Functions

bool testBinomialConvolver ()
 
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
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
2011/07/06

Functions for testing class Signal.

This file is part of the DGtal library.

Definition in file testBinomialConvolver.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 120 of file testBinomialConvolver.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testBinomialConvolver(), and DGtal::trace.

121 {
122  trace.beginBlock ( "Testing class BinomialConvolver" );
123  trace.info() << "Args:";
124  for ( int i = 0; i < argc; ++i )
125  trace.info() << " " << argv[ i ];
126  trace.info() << endl;
127 
128  bool res = testBinomialConvolver(); // && ... other tests
129  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
130  trace.endBlock();
131  return res ? 0 : 1;
132 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
double endBlock()
std::ostream & emphase()
std::ostream & info()
bool testBinomialConvolver()

◆ testBinomialConvolver()

bool testBinomialConvolver ( )

Example of a test. To be completed.

Definition at line 48 of file testBinomialConvolver.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

49 {
50  unsigned int nbok = 0;
51  unsigned int nb = 0;
52 
53  trace.beginBlock ( "Testing block ..." );
55  std::vector< RealPoint > points;
56  points.push_back( RealPoint( { 0.0, 0.0 } ) );
57  points.push_back( RealPoint( { 1.0, 0.0 } ) );
58  points.push_back( RealPoint( { 2.0, 0.0 } ) );
59  points.push_back( RealPoint( { 2.0, 1.0 } ) );
60  points.push_back( RealPoint( { 2.0, 2.0 } ) );
61  points.push_back( RealPoint( { 1.0, 2.0 } ) );
62  points.push_back( RealPoint( { 0.0, 2.0 } ) );
63  points.push_back( RealPoint( { 0.0, 1.0 } ) );
64 
65  typedef std::vector< RealPoint >::const_iterator ConstIteratorOnPoints;
66  typedef BinomialConvolver<ConstIteratorOnPoints, double> MyBinomialConvolver;
67 
68  for ( unsigned int n = 1; n < 10; ++n )
69  {
70  trace.info() << "Binomial convolver n=" << n << std::endl;
71  MyBinomialConvolver bcc( n );
72  bcc.init( 1.0, points.begin(), points.end(), true );
73  for ( unsigned int i = 0; i < 8; ++i )
74  std::cout << i
75  << " " << bcc.x( i ).first
76  << " " << bcc.x( i ).second
77  << " " << bcc.tangent( i ).first
78  << " " << bcc.tangent( i ).second
79  << " " << bcc.curvature( i )
80  << std::endl;
81  }
82  unsigned int n = MyBinomialConvolver::suggestedSize( 1.0, points.begin(), points.end() );
83  trace.info() << "Binomial convolver suggested n="
84  << n
85  << std::endl;
86 
88  TangentBCFct;
90  CurvatureBCFct;
95  BCTangentEstimator tgtEstimator;
96  BCCurvatureEstimator curvEstimator;
97 
98  tgtEstimator.init( 1.0, points.begin(), points.end(), true );
99  curvEstimator.init( 1.0, points.begin(), points.end(), true );
100  for ( ConstIteratorOnPoints it = points.begin(), it_end = points.end();
101  it != it_end; ++it )
102  {
103  std::cout << *it
104  << " " << tgtEstimator.eval( it )
105  << " " << curvEstimator.eval( it )
106  << std::endl;
107  }
108  nbok += true ? 1 : 0;
109  nb++;
110  trace.info() << "(" << nbok << "/" << nb << ") "
111  << "true == true" << std::endl;
112  trace.endBlock();
113 
114  return nbok == nb;
115 }
Aim: This class is a functor for getting the tangent vector of a binomial convolver.
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
double endBlock()
Aim: This class is a functor for getting the curvature of a binomial convolver.
Aim: This class represents a 2D contour convolved by some binomial. It computes first and second orde...
Aim: This concept describes an object that can process a range so as to return one estimated quantity...
std::ostream & info()
Space::RealPoint RealPoint
Definition: StdDefs.h:97
Aim: This class encapsulates a BinomialConvolver and a functor on BinomialConvolver so as to be a mod...