34 #include "DGtal/base/Common.h"
35 #include "DGtal/io/boards/Board2D.h"
36 #include "DGtal/io/Color.h"
37 #include "DGtal/shapes/Shapes.h"
38 #include "DGtal/helpers/StdDefs.h"
39 #include "DGtal/geometry/curves/ArithmeticalDSS.h"
40 #include "DGtal/geometry/curves/FreemanChain.h"
41 #include "DGtal/geometry/curves/SaturatedSegmentation.h"
43 #include "ConfigExamples.h"
46 using namespace DGtal;
58 template <
typename Iterator,
typename Board>
59 void drawCCP(
const Iterator& itb,
const Iterator& ite, Board& aBoard)
62 typedef typename Iterator::SegmentComputer::ConstIterator PointIterator;
64 aBoard <<
SetMode(
"ArithmeticalDSS",
"BoundingBox" );
65 string aStyleName =
"ArithmeticalDSS/BoundingBox";
67 for (Iterator i(itb); i != ite; ++i) {
72 if ( !(i.intersectNext() && i.intersectPrevious()) ) {
80 PointIterator begin = i->begin(); --begin;
81 PointIterator end = i->end();
85 int omega = i->getOmega();
88 if ( (i->getRemainder(begin)<=mu-1)&&
89 (i->getRemainder(end)<=mu-1) ) {
91 }
else if ( (i->getRemainder(begin)>=mu+omega)&&
92 (i->getRemainder(end)>=mu+omega) ) {
94 }
else if ( (i->getRemainder(begin)>=mu+omega)&&
95 (i->getRemainder(end)<=mu-1) ) {
97 }
else if ( (i->getRemainder(begin)<=mu-1)&&
98 (i->getRemainder(end)>=mu+omega) ) {
117 template <
typename Iterator,
typename Board>
118 void segmentationIntoMaximalDSSs(
const Iterator& itb,
const Iterator& ite,
125 RecognitionAlgorithm algo;
126 Segmentation s(itb,ite,algo);
128 typename Segmentation::SegmentComputerIterator i = s.begin();
129 typename Segmentation::SegmentComputerIterator end = s.end();
131 drawCCP<typename Segmentation::SegmentComputerIterator, Board>
137 int main(
int argc,
char** argv )
143 for (
int i = 0; i < argc; ++i )
149 if (argc >= 2) codes = argv[1];
150 else codes =
"030030330303303030300001010101101011010000030330303303030300001010110101011010000033";
152 stringstream ss(stringstream::in | stringstream::out);
153 ss <<
"0 0 " << codes << endl;
154 Range theContour( ss );
156 trace.
info() <<
"Processing of " << ss.str() << endl;
161 <<
SetMode(
"PointVector",
"Grid" )
164 segmentationIntoMaximalDSSs(theContour.begin(), theContour.end(), aBoard);
166 aBoard.
saveSVG(
"convex-and-concave-parts.svg");