32#include "DGtal/base/Common.h"
33#include "DGtal/helpers/StdDefs.h"
34#include "DGtal/images/ImageSelector.h"
35#include "DGtal/geometry/volumes/distance/DistanceTransformation.h"
36#include "DGtal/geometry/volumes/distance/ExactPredicateLpSeparableMetric.h"
37#include "DGtal/geometry/volumes/distance/ReverseDistanceTransformation.h"
38#include "DGtal/io/colormaps/HueShadeColorMap.h"
39#include "DGtal/kernel/sets/DigitalSetBySTLSet.h"
40#include "DGtal/io/boards/Board2D.h"
41#include "DGtal/images/SimpleThresholdForegroundPredicate.h"
50template<
typename Image>
58 for (
unsigned int k = 0 ; k < nb; k++)
60 for (
unsigned int dim = 0;
dim < Image::dimension;
dim++)
79 unsigned int nbok = 0;
82 trace.beginBlock (
"Testing Reverse DT in 2D ..." );
90 for (
unsigned k = 0; k < 49; k++ )
94 image.setValue ( a, 128 );
100 Predicate aPredicate(
image,0);
107 trace.info() <<
dt<< std::endl;
109 trace.warning()<<
"DT:"<<endl;
111 for (
unsigned int y = 2; y < 16; y++)
113 for (
unsigned int x = 2; x < 16; x++)
115 std::cout << (*it) <<
" ";
118 std::cout << std::endl;
123 RDT reverseDT(&dom,&
dt,&l2power);
126 for(
unsigned int j=2; j<16; j++)
128 for(
unsigned int i=2; i<16; i++)
130 trace.info()<<std::endl;
133 trace.warning()<<
"REDT:"<<endl;
134 RDT::ConstRange::ConstIterator it2 = reverseDT.constRange().begin();
135 for (
unsigned int y = 2; y < 16; y++)
137 for (
unsigned int x = 2; x < 16; x++)
139 std::cout << (*it2) <<
" ";
142 std::cout << std::endl;
147 RDT::ConstRange::ConstIterator itrec = reverseDT.constRange().begin(), itend = reverseDT.constRange().end();
149 for( ; itrec != itend; ++itrec,++itinit)
151 ok = ok & ((*itinit) == 0);
154 trace.info() <<
"vector (4,7)= "<< reverseDT.getPowerVector(
Z2i::Point(4,7))<<std::endl;
157 trace.info() <<
"(" << nbok <<
"/" << nb <<
") "
158 <<
"ok" << std::endl;
160 trace.info() <<
"dist (4,7)= "<< reverseDT.metricPtr()->exactDistanceRepresentation(
Z2i::Point(4,7),
Z2i::Point(5,7))<<std::endl;
161 nbok += (reverseDT.metricPtr()->exactDistanceRepresentation(
Z2i::Point(4,7),
Z2i::Point(5,7))==1) ? 1 : 0;
163 trace.info() <<
"(" << nbok <<
"/" << nb <<
") "
164 <<
"true == true" << std::endl;
166 trace.info() <<
"power (4,7)= "<< reverseDT(
Z2i::Point(4,7))<<std::endl;
167 nbok += (reverseDT(
Z2i::Point(4,7))==0) ? 1 : 0;
169 trace.info() <<
"(" << nbok <<
"/" << nb <<
") "
170 <<
"true == true" << std::endl;
177 trace.info() <<
"(" << nbok <<
"/" << nb <<
") "
178 <<
"true == true" << std::endl;
186 unsigned int nbok = 0;
189 trace.beginBlock (
"Testing Reverse DT in 2D with L1 metric ..." );
197 for (
unsigned k = 0; k < 49; k++ )
199 a[0] = ( k / 7 ) + 5;
200 a[1] = ( k % 7 ) + 5;
201 image.setValue ( a, 128 );
207 Predicate aPredicate(
image,0);
215 trace.warning()<<
"DT:"<<endl;
217 for (
unsigned int y = 2; y < 16; y++)
219 for (
unsigned int x = 2; x < 16; x++)
221 std::cout << (int)(*it) <<
" ";
224 std::cout << std::endl;
229 RDT reverseDT(&dom, &
dt, &l1power);
232 trace.warning()<<
"Power"<<std::endl;
233 for(
unsigned int j=2; j<16; j++)
235 for(
unsigned int i=2; i<16; i++)
237 trace.info()<<std::endl;
240 trace.warning()<<
"REDT:"<<endl;
241 RDT::ConstRange::ConstIterator it2 = reverseDT.constRange().begin();
242 for (
unsigned int y = 2; y < 16; y++)
244 for (
unsigned int x = 2; x < 16; x++)
246 std::cout << (int)(*it2) <<
" ";
249 std::cout << std::endl;
254 RDT::ConstRange::ConstIterator itrec = reverseDT.constRange().begin(), itend = reverseDT.constRange().end();
256 for( ; itrec != itend; ++itrec,++itinit)
258 ok = ok & ((*itinit) == 0);
262 trace.info() <<
"(" << nbok <<
"/" << nb <<
") "
263 <<
"true == true" << std::endl;
271int main(
int argc,
char** argv )
273 trace.beginBlock (
"Testing class ReverseDT" );
274 trace.info() <<
"Args:";
275 for (
int i = 0; i < argc; ++i )
276 trace.info() <<
" " << argv[ i ];
277 trace.info() << endl;
282 trace.emphase() << ( res ?
"Passed." :
"Error." ) << endl;
ConstIteratorAdapter< typename Domain::ConstIterator, Self, Value > ConstIterator
Aim: implements separable l_p metrics with exact predicates.
std::vector< Value >::const_iterator ConstIterator
Aim: implements association bewteen points lying in a digital domain and values.
void setValue(const Point &aPoint, const Value &aValue)
Aim: Define a simple Foreground predicate thresholding image values given a single thresold....
ExactPredicateLpPowerSeparableMetric< Space, 2 > L2PowerMetric
HyperRectDomain< Space > Domain
ExactPredicateLpPowerSeparableMetric< Space, 1 > L1PowerMetric
functors namespace gathers all DGtal functors.
DGtal is the top-level namespace which contains all DGtal functions and types.
ImageContainerBySTLVector< Domain, Value > Type
void randomSeeds(Image &input, const unsigned int nb, const int value)