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"
94template <
typename Iterator,
typename Board>
95void 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()) ) {
120 typedef typename DSS::Point
Point;
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);
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) ) {
166template <
typename Iterator,
typename Board>
177 RecognitionAlgorithm algo;
181 drawCCP(s.begin(), s.end(), aBoard);
194int 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");
Aim: This class is a wrapper around ArithmeticalDSS that is devoted to the dynamic recognition of dig...
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
static const Color Yellow
ConstIterator end() const
ConstIterator begin() const
Aim: Computes the saturated segmentation, that is the whole set of maximal segments within a range gi...
void beginBlock(const std::string &keyword="")
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
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 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.
Custom style class redefining the pen color. You may use Board2D::Color::None for transparent color.
Aim: Provides nested types for both iterators and circulators: Type, Category, Value,...
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
SaturatedSegmentation< SegmentComputer > Segmentation