DGtal 1.4.0
Loading...
Searching...
No Matches
geometry/curves/exampleAlphaThickSegmentNoisy.cpp

This example shows a simple alpha-thick segment recognition given from a noisy input contour with floating point coordinates.

See also
Alpha-thick Segment Recognition
Simple example of some alpha-thick segments recognition with alpha = 2, 9 and 15.
#include <iostream>
#include "ConfigExamples.h"
#include "DGtal/base/Common.h"
#include "DGtal/geometry/curves/AlphaThickSegmentComputer.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/readers/PointListReader.h"
#include "DGtal/io/boards/Board2D.h"
using namespace std;
using namespace DGtal;
int main( )
{
trace.beginBlock ( "Example exampleAlphaThickSegment" );
typedef AlphaThickSegmentComputer< Z2i::RealPoint > AlphaThickSegmentComputer2D;
Board2D aBoard;
std::string file = examplesPath + "samples/contourSnoisy.sdp";
std::vector<Z2i::RealPoint> aContour = PointListReader<Z2i::RealPoint>::getPointsFromFile(file);
// displaying contour
aBoard << SetMode(aContour[0].className(), "Grid");
for (unsigned int i = 0; i< aContour.size(); i++){
aBoard << aContour[i];
aBoard.drawLine(aContour[i][0], aContour[i][1],
aContour[(i+1)%aContour.size()][0], aContour[(i+1)%aContour.size()][1]);
}
//initialisation of an AlphaThickSegmentComputer2D of thickness 10 and forward recognition.
AlphaThickSegmentComputer2D anAlphaSegment(15);
std::vector<Z2i::RealPoint>::const_iterator it = aContour.begin();
while (anAlphaSegment.extendFront(*it)) {
it++;
}
aBoard << anAlphaSegment;
AlphaThickSegmentComputer2D anAlphaSegment2(9);
anAlphaSegment2.init(aContour.begin());
while (anAlphaSegment2.end() != aContour.end() &&
anAlphaSegment2.extendFront()) {
}
aBoard << CustomStyle( anAlphaSegment2.className(), new CustomColors( DGtal::Color::Blue, DGtal::Color::None ) );
aBoard << anAlphaSegment2;
AlphaThickSegmentComputer2D anAlphaSegment3(2);
anAlphaSegment3.init(aContour.begin());
while (anAlphaSegment3.end() != aContour.end() &&
anAlphaSegment3.extendFront()) {
}
aBoard << CustomStyle( anAlphaSegment3.className(), new CustomColors( DGtal::Color::Green, DGtal::Color::None ) );
aBoard << anAlphaSegment3;
aBoard.saveEPS("exampleAlphaThickSegmentNoisy.eps");
trace.endBlock();
return 0;
}
// //
Aim: This class is devoted to the recognition of alpha thick segments as described in FaureTangential...
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition Board2D.h:71
static const Color None
Definition Color.h:412
static const Color Green
Definition Color.h:417
static const Color Blue
Definition Color.h:419
void beginBlock(const std::string &keyword="")
double endBlock()
void drawLine(double x1, double y1, double x2, double y2, int depthValue=-1)
Definition Board.cpp:367
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition Board.cpp:804
DGtal is the top-level namespace which contains all DGtal functions and types.
STL namespace.
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition Board2D.h:279
Aim: Implements method to read a set of points represented in each line of a file.
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition Board2D.h:247
int main()
Definition testBits.cpp:56