DGtal  1.5.beta
testKanungo.cpp
Go to the documentation of this file.
1 
31 #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 
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 
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 ++;
88  nb++;
89  trace.info() << "(" << nbok << "/" << nb << ") "
90  << "true == true" << std::endl;
91  trace.endBlock();
92 
93  return nbok == nb;
94 }
95 
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 // //
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Iterator for HyperRectDomain.
const ConstIterator & end() const
const ConstIterator & begin() const
Aim: From a point predicate (model of concepts::CPointPredicate), this class constructs another point...
Definition: KanungoNoise.h:85
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:151
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1011
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:153
Aim: Defines a predicate on a point.
int main(int argc, char **argv)
bool testKanungo2D()
Definition: testKanungo.cpp:50
bool CheckingConcept()
Definition: testKanungo.cpp:96
Domain domain