DGtal  0.9.2
testKanungo.cpp
1 
30 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/geometry/volumes/KanungoNoise.h"
34 #include "DGtal/io/boards/Board2D.h"
35 #include "DGtal/helpers/StdDefs.h"
36 #include "DGtal/shapes/Shapes.h"
37 #include "DGtal/kernel/CPointPredicate.h"
39 
40 using namespace std;
41 using namespace DGtal;
42 
44 // Functions for testing class Kanungo.
46 
50 bool testKanungo2D()
51 {
52  unsigned int nbok = 0;
53  unsigned int nb = 0;
54 
55  trace.beginBlock ( "Testing 2DNoise ..." );
56 
57  Z2i::Domain domain(Z2i::Point(0,0), Z2i::Point(128,128));
58 
59  Z2i::DigitalSet set(domain);
60 
62 
63  Board2D board;
64  board << domain << set;
65  board.saveSVG("input-set-kanungo.svg");
66 
67  board.clear();
68 
69  //Noisification
70  KanungoNoise<Z2i::DigitalSet, Z2i::Domain> nosifiedObject(set,domain,0.5);
71  board << domain ;
72  for(Z2i::Domain::ConstIterator it = domain.begin(), itend=domain.end(); it != itend; ++it)
73  if (nosifiedObject( * it ))
74  board << *it;
75  board.saveSVG("output-set-kanungo-0.5.svg");
76 
77 
78  board.clear();
79  //Noisification
80  KanungoNoise<Z2i::DigitalSet, Z2i::Domain> nosifiedObject2(set,domain,0.1);
81  board << domain ;
82  for(Z2i::Domain::ConstIterator it = domain.begin(), itend=domain.end(); it != itend; ++it)
83  if (nosifiedObject2( * it ))
84  board << *it;
85  board.saveSVG("output-set-kanungo-0.1.svg");
86 
87  nbok += true ? 1 : 0;
88  nb++;
89  trace.info() << "(" << nbok << "/" << nb << ") "
90  << "true == true" << std::endl;
91  trace.endBlock();
92 
93  return nbok == nb;
94 }
95 
96 bool CheckingConcept()
97 {
99  return true;
100 }
101 
102 
104 // Standard services - public :
105 
106 int main( int argc, char** argv )
107 {
108  trace.beginBlock ( "Testing class Kanungo" );
109  trace.info() << "Args:";
110  for ( int i = 0; i < argc; ++i )
111  trace.info() << " " << argv[ i ];
112  trace.info() << endl;
113 
114  bool res = CheckingConcept() && testKanungo2D(); // && ... other tests
115  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
116  trace.endBlock();
117  return res ? 0 : 1;
118 }
119 // //
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:130
STL namespace.
double endBlock()
Aim: Defines a predicate on a point.
std::ostream & emphase()
Aim: From a point predicate (model of concepts::CPointPredicate), this class constructs another point...
Definition: KanungoNoise.h:84
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:152
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
std::ostream & info()
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)...
Definition: Board2D.h:70