DGtal 1.4.0
Loading...
Searching...
No Matches
testMetricBalls.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/geometry/volumes/distance/ExactPredicateLpSeparableMetric.h"
#include "DGtal/geometry/volumes/distance/InexactPredicateLpSeparableMetric.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/kernel/BasicPointPredicates.h"
#include "DGtal/geometry/volumes/distance/DistanceTransformation.h"
#include "DGtal/io/colormaps/HueShadeColorMap.h"
Include dependency graph for testMetricBalls.cpp:

Go to the source code of this file.

Functions

template<int norm>
bool testExactMetricBalls ()
 
bool testInexactMetricBalls (double norm)
 
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/11/11

Functions for testing class MetricBalls.

This file is part of the DGtal library.

Definition in file testMetricBalls.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 121 of file testMetricBalls.cpp.

122{
123 trace.beginBlock ( "Testing class MetricBalls" );
124 trace.info() << "Args:";
125 for ( int i = 0; i < argc; ++i )
126 trace.info() << " " << argv[ i ];
127 trace.info() << endl;
128
129 bool res = testExactMetricBalls<2>()
136 ; // && ... other tests
137 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
138 trace.endBlock();
139 return res ? 0 : 1;
140}
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition Common.h:153
bool testInexactMetricBalls(double norm)
bool testExactMetricBalls()

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

◆ testExactMetricBalls()

template<int norm>
bool testExactMetricBalls ( )

Definition at line 52 of file testMetricBalls.cpp.

53{
54 unsigned int nbok = 0;
55 unsigned int nb = 0;
56
60
61 set.insertNew(Z2i::Point(32,32));
63 // SetPredicate<Z2i::DigitalSet> setpred(set);
64 NegPred predicate( set );
65
67 Metric metric;
68 DT dt( &domain, &predicate, &metric);
69
70
71 Board2D board;
75 0.0,
76 32*sqrt(2)/2.0);
77
78 std::string title = "image-ball-" + boost::lexical_cast<string>( norm )+".png" ;
79#ifdef WITH_CAIRO
80 board.saveCairo(title.c_str(), Board2D::CairoPNG );
81#endif
82 return nbok == nb;
83}
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...
Aim: Implementation of the linear in time distance transformation for separable metrics.
Aim: implements separable l_p metrics with exact predicates.
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
void setUnit(Unit unit)
Definition Board.cpp:239
void saveCairo(const char *filename, CairoType type=CairoPNG, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition Board.cpp:1138
static void drawImage(DGtal::Board2D &board, const Image &i, const typename Image::Value &minV, const typename Image::Value &maxV)
Aim: The predicate returns true when the point predicate given at construction return false....
Domain domain

References domain, DGtal::Display2DFactory::drawImage(), dt, LibBoard::Board::saveCairo(), LibBoard::Board::setUnit(), and LibBoard::Board::UCentimeter.

Referenced by main().

◆ testInexactMetricBalls()

bool testInexactMetricBalls ( double norm)

Definition at line 85 of file testMetricBalls.cpp.

86{
87 unsigned int nbok = 0;
88 unsigned int nb = 0;
89
93
94 set.insertNew(Z2i::Point(32,32));
96 // SetPredicate<Z2i::DigitalSet> setpred(set);
97 NegPred predicate( set );
98
100 Metric metric(norm);
101 DT dt( &domain, &predicate, &metric);
102
103
104 Board2D board;
108 0.0,
109 32*sqrt(2)/2.0);
110
111 std::string title = "image-ball-" + boost::lexical_cast<string>( norm )+".png" ;
112#ifdef WITH_CAIRO
113 board.saveCairo(title.c_str(), Board2D::CairoPNG );
114#endif
115 return nbok == nb;
116}
Aim: implements separable l_p metrics with approximated predicates.

References domain, DGtal::Display2DFactory::drawImage(), dt, LibBoard::Board::saveCairo(), LibBoard::Board::setUnit(), and LibBoard::Board::UCentimeter.

Referenced by main().