58 #include "DGtal/base/Common.h" 59 #include "DGtal/io/boards/Board2D.h" 60 #include "DGtal/io/Color.h" 61 #include "DGtal/shapes/Shapes.h" 62 #include "DGtal/helpers/StdDefs.h" 63 #include "DGtal/geometry/curves/ArithmeticalDSSComputer.h" 64 #include "DGtal/geometry/curves/FreemanChain.h" 65 #include "DGtal/geometry/curves/SaturatedSegmentation.h" 67 #include "ConfigExamples.h" 70 using namespace DGtal;
94 template <
typename Iterator,
typename Board>
95 void drawCCP(
const Iterator& itb,
const Iterator& ite, Board& aBoard)
99 aBoard <<
SetMode(
"ArithmeticalDSS",
"BoundingBox" );
101 string aStyleName =
"ArithmeticalDSS/BoundingBox";
105 for (Iterator i(itb); i != ite; ++i) {
108 typedef typename Iterator::SegmentComputer::Primitive DSS;
109 DSS maximalDSS = i->primitive();
112 if ( !(i.intersectNext() && i.intersectPrevious()) ) {
121 Point beforeFirst = *(--(i->begin()));
122 Point afterLast = *(i->end());
125 typedef typename DSS::Integer Integer;
126 Integer r1 = maximalDSS.remainder(beforeFirst);
127 Integer r2 = maximalDSS.remainder(afterLast);
128 Integer mu = maximalDSS.mu();
129 Integer omega = maximalDSS.omega();
132 if ( (r1<=mu-1)&&(r2<=mu-1) ) {
134 }
else if ( (r1>=mu+omega)&&(r2>=mu+omega) ) {
136 }
else if ( (r1>=mu+omega)&&(r2<=mu-1) ) {
138 }
else if ( (r1<=mu-1)&&(r2>=mu+omega) ) {
166 template <
typename Iterator,
typename Board>
177 RecognitionAlgorithm algo;
178 Segmentation s(itb,ite,algo);
181 drawCCP(s.begin(), s.end(), aBoard);
194 int main(
int argc,
char** argv )
203 if (argc >= 2) codes = argv[1];
204 else codes =
"030030330303303030300001010101101011010000030330303303030300001010110101011010000033";
206 stringstream ss(stringstream::in | stringstream::out);
207 ss <<
"0 0 " << codes << endl;
210 trace.
info() <<
"Processing of " << ss.str() << endl;
214 <<
SetMode(
"PointVector",
"Grid" )
221 aBoard.
saveSVG(
"convex-and-concave-parts.svg");
223 aBoard.
saveCairo(
"convex-and-concave-parts.png");
void beginBlock(const std::string &keyword="")
void segmentationIntoMaximalDSSs(const Iterator &itb, const Iterator &ite, Board &aBoard)
Perform a saturated segmentation into maximal digital straight segments of a given range of integer p...
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
void saveCairo(const char *filename, CairoType type=CairoPNG, PageSize size=Board::BoundingBox, double margin=10.0) const
Aim: This class is a wrapper around ArithmeticalDSS that is devoted to the dynamic recognition of dig...
Aim: Provides nested types for both iterators and circulators: Type, Category, Value, Difference, Pointer and Reference.
void drawCCP(const Iterator &itb, const Iterator &ite, Board &aBoard)
Function that draws the maximal segments with a color that depends on the local convexity: ...
DGtal is the top-level namespace which contains all DGtal functions and types.
Modifier class in a Board2D stream. Useful to choose your own mode for a given class. Realizes the concept CDrawableWithBoard2D.
int main(int argc, char **argv)
Program that draws the maximal segments of digital curve whose chain code may be given as an argument...
Aim: Computes the saturated segmentation, that is the whole set of maximal segments within a range gi...
Custom style class redefining the pen color. You may use Board2D::Color::None for transparent color...
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)...