32 #include "DGtal/base/Common.h"
33 #include "DGtal/base/Common.h"
34 #include "DGtal/kernel/SpaceND.h"
35 #include "DGtal/kernel/domains/HyperRectDomain.h"
36 #include "DGtal/images/ImageSelector.h"
37 #include "DGtal/geometry/volumes/distance/SeparableMetricHelper.h"
38 #include "DGtal/geometry/volumes/distance/DistanceTransformation.h"
39 #include "DGtal/io/colormaps/HueShadeColorMap.h"
40 #include "DGtal/io/colormaps/GrayscaleColorMap.h"
41 #include "DGtal/io/boards/Board2D.h"
42 #include "DGtal/images/imagesSetsUtils/SimpleThresholdForegroundPredicate.h"
46 using namespace DGtal;
55 bool testDistanceTransformND()
57 unsigned int nbok = 0;
63 typedef TSpace::Point
Point;
67 int t[5] = {0,0,0,0,0};
69 int t2[5] = {15,15,15,15,15};
71 int t3[5] = {3,3,3,3,3};
80 for (
Image::Iterator it=image.begin(),itend=image.end(); it!=itend; ++it)
82 image.setValue( c , 0 );
85 Predicate aPredicate(image,0);
90 dt.checkTypesValidity ( );
93 ImageLong result = dt.compute ( );
97 for(Domain::ConstIterator itDom = domain.begin(), itDomend = domain.end();
98 itDom != itDomend; ++itDom)
102 ImageLong::Value norm2=0;
103 for(Point::Iterator itd=d.begin(), itdend=d.end(); itd!=itdend; ++itd)
104 norm2+= (*itd)*(*itd);
106 if ( result( (*itDom) ) != norm2)
109 <<
": expected="<<norm2<<
" and computed="<<result(*itDom)<<endl;
115 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
116 <<
"true == true" << std::endl;
125 int main(
int argc,
char** argv )
129 for (
int i = 0; i < argc; ++i )
133 bool res = testDistanceTransformND();
134 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;