32#include "DGtal/base/Common.h"
33#include "DGtal/helpers/StdDefs.h"
34#include "DGtal/geometry/volumes/distance/DistanceTransformation.h"
35#include "DGtal/geometry/volumes/distance/ExactPredicateLpSeparableMetric.h"
36#include "DGtal/geometry/volumes/distance/InexactPredicateLpSeparableMetric.h"
37#include "DGtal/images/ImageContainerBySTLVector.h"
38#include "DGtal/kernel/sets/DigitalSetBySTLSet.h"
46template<
typename Image>
49 typename Image::Point p, low = input.domain().lowerBound(), up = input.domain().upperBound();
52 for (
Dimension i = 0; i < Image::Domain::dimension; i++)
53 ext[i] = up[i] - low[i] + 1;
56 for (
unsigned int k = 0 ; k < nb; k++)
58 for (
unsigned int dim = 0;
dim < Image::dimension;
dim++)
62 input.setValue(p, value);
67template<
typename Image,
typename Pred,
typename Metric>
73 itend=result.domain().end();
76 typename Metric::Value dist = result(*it);
79 itendbis=result.domain().end();
80 itbis != itendbis; ++itbis)
82 if (!pointPredicate(*itbis) && (metric(*it, *itbis) < dist))
84 trace.
error()<<
"Error in Voronoi map at "<< *it<<
" computed="<<dist<<
" but find="<<metric(*it, *itbis) << std::endl;
93template <
typename Space,
int norm>
103 Point low=Point::diagonal(0),
104 up=Point::diagonal(size);
109 for(
unsigned int i = 0; i<nb; ++i)
113 p[
dim] = rand() % size;
117 trace.
info()<<
"Testing metrics "<<MetricEx()<<std::endl;
119 trace.
info()<<
"Inserting "<<set.size() <<
" points."<<std::endl;
121 NegPredicate negPred(set);
125 DTEx dtex(&
domain, &negPred, &metricEx);
135template <
typename Space>
145 Point low=Point::diagonal(0),
146 up=Point::diagonal(size);
151 for(
unsigned int i = 0; i<nb; ++i)
155 p[
dim] = rand() % size;
159 trace.
info()<<
"Testing metrics "<<MetricInex(norm)<<std::endl;
161 trace.
info()<<
"Inserting "<<set.size() <<
" points."<<std::endl;
163 NegPredicate negPred(set);
166 MetricInex metricInex(norm);
167 DTIn dtinex(&
domain, &negPred, &metricInex);
178int main(
int argc,
char** argv )
182 for (
int i = 0; i < argc; ++i )
186 bool res = testCompareExactBruteForce<Z2i::Space, 2>(16, 8)
187 && testCompareExactBruteForce<Z2i::Space, 1>(16, 8)
188 && testCompareExactBruteForce<Z3i::Space, 2>(16, 8)
189 && testCompareExactBruteForce<Z2i::Space, 4>(16, 8)
190 && testCompareInexactBruteForce<Z2i::Space>(2.0,16, 8)
191 && testCompareInexactBruteForce<Z2i::Space>(1.33,16, 8)
192 && testCompareInexactBruteForce<Z2i::Space>(2.6,16, 8)
193 && testCompareInexactBruteForce<Z3i::Space>(2.44,10, 5)
194 && testCompareInexactBruteForce<Z3i::Space>(12.3,10, 5);
195 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: A container class for storing sets of digital points within some given domain.
Aim: implements separable l_p metrics with exact predicates.
Iterator for HyperRectDomain.
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Aim: implements association bewteen points lying in a digital domain and values.
Aim: implements separable l_p metrics with approximated predicates.
static const Dimension dimension
static constants to store the dimension.
void beginBlock(const std::string &keyword="")
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::uint32_t Dimension
Aim: The predicate returns true when the point predicate given at construction return false....
HyperRectDomain< Space > Domain