DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
testReducedMedialAxis.cpp File Reference
#include <iostream>
#include <array>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/geometry/volumes/distance/PowerMap.h"
#include "DGtal/geometry/volumes/distance/ReducedMedialAxis.h"
#include "DGtal/geometry/volumes/distance/ExactPredicateLpPowerSeparableMetric.h"
#include "DGtal/kernel/sets/DigitalSetDomain.h"
#include "DGtal/kernel/sets/DigitalSetBySTLSet.h"

Go to the source code of this file.

Functions

bool testReducedMedialAxis (std::array< bool, 2 > const &aPeriodicity={{ false, false }})
 
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/12/08

Functions for testing class ReducedMedialAxis.

This file is part of the DGtal library.

Definition in file testReducedMedialAxis.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 161 of file testReducedMedialAxis.cpp.

162{
163 trace.beginBlock ( "Testing class ReducedMedialAxis" );
164 trace.info() << "Args:";
165 for ( int i = 0; i < argc; ++i )
166 trace.info() << " " << argv[ i ];
167 trace.info() << endl;
168
169 bool res =
171 && testReducedMedialAxis( {{ true, false }} )
172 && testReducedMedialAxis( {{ false, true }} )
173 && testReducedMedialAxis( {{ true, true }} )
174 ; // && ... other tests
175
176 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
177 trace.endBlock();
178 return res ? 0 : 1;
179}
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition: Common.h:154
bool testReducedMedialAxis(std::array< bool, 2 > const &aPeriodicity={{ false, false }})

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

◆ testReducedMedialAxis()

bool testReducedMedialAxis ( std::array< bool, 2 > const &  aPeriodicity = {{ false, false }})

Example of a test. To be completed.

Definition at line 53 of file testReducedMedialAxis.cpp.

53 {{ false, false }} )
54{
55 unsigned int nbok = 0;
56 unsigned int nb = 0;
57
58 trace.beginBlock ( "Testing PowerMap2D ..." );
59
61 Z2i::Domain domainLarge(Z2i::Point(0,0),Z2i::Point(10,10));
62
64 set.insertNew(Z2i::Point(3,3));
65 //set.insertNew(Z2i::Point(3,7));
66 set.insertNew(Z2i::Point(7,7));
67
70 Image image( new SetDomain( set ) );
71
72 //Setting some values
73 image.setValue(Z2i::Point(3,3), 9);
74 // image.setValue(Z2i::Point(3,7), 0);
75 image.setValue(Z2i::Point(7,7), 16);
76
77 Z2i::L2PowerMetric l2power;
78 PowerMap<Image, Z2i::L2PowerMetric> power(&domainLarge, &image, &l2power, aPeriodicity );
79
80 for(unsigned int i=0; i<11; i++)
81 {
82 for(unsigned int j=0; j<11; j++)
83 if (image.domain().isInside(Z2i::Point(i,j)))
84 trace.info()<< image(Z2i::Point(i,j))<<" ";
85 else
86 trace.info()<< "0 ";
87
88 trace.info()<<std::endl;
89 }
90 trace.info()<<std::endl;
91
92 //Power Map
93 for(unsigned int i=0; i<11; i++)
94 {
95 for(unsigned int j=0; j<11; j++)
96 trace.info()<< power(Z2i::Point(i,j))[0]<<","<<power(Z2i::Point(i,j))[1]<<" ";
97 trace.info()<<std::endl;
98 }
99
100 trace.info()<<std::endl;
101 //Reconstruction
102 for(unsigned int i=0; i<11; i++)
103 {
104 for(unsigned int j=0; j<11; j++)
105 {
106 Z2i::Point p(i,j);
107 auto dist = (i-power(p)[0])*(i-power(p)[0]) +
108 ( j-power(p)[1])*(j-power(p)[1]) - image(power.projectPoint(power(p)));
109 trace.info()<< dist;
110 }
111 std::cerr<<std::endl;
112 }
113 trace.info()<<std::endl;
114
115 //Medial Axis extraction
117
118 //Reconstruction
119 for(unsigned int i=0; i<11; i++)
120 {
121 for(unsigned int j=0; j<11; j++)
122 {
123 Z2i::Point p(i,j);
124 if (rdma.domain().isInside(p) )
125 trace.info()<< rdma(p);
126 else
127 trace.info()<< " - ";
128
129 }
130 std::cerr<<std::endl;
131 }
132 trace.info()<<std::endl;
133
134
135 ++nbok;
136 nb++;
137 trace.info() << "(" << nbok << "/" << nb << ") "
138 << "true == true" << std::endl;
139 trace.endBlock();
140
141 bool isEqual = true;
142 for ( auto const & pt : domain )
143 {
144 const Image::Value a = image.domain().isInside(pt) ? image(pt) : 0;
145 const Image::Value b = rdma.domain().isInside(pt) ? rdma(pt) : 0;
146 if ( a != b )
147 {
148 isEqual = false;
149 break;
150 }
151 }
152
153 trace.info() << "Equality ? " << isEqual << std::endl;
154
155 return nbok == nb;
156}
Aim: A container class for storing sets of digital points within some given domain.
Aim: Constructs a domain limited to the given digital set.
Aim: implements weighted separable l_p metrics with exact predicates.
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:70
Aim: Implementation of the linear in time Power map construction.
Definition: PowerMap.h:111
T power(const T &aVal, const unsigned int exponent)
Aim: Implementation of the separable medial axis extraction.
bool isEqual(Container1 &c1, Container2 &c2)
Domain domain

Referenced by main().