This example shows a simple alpha-thick segment recognition given from a noisy input contour with floating point coordinates.
#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;
{
typedef AlphaThickSegmentComputer< Z2i::RealPoint > AlphaThickSegmentComputer2D;
Board2D aBoard;
std::string file = examplesPath + "samples/contourSnoisy.sdp";
std::vector<Z2i::RealPoint> aContour = PointListReader<Z2i::RealPoint>::getPointsFromFile(file);
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]);
}
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 << anAlphaSegment2;
AlphaThickSegmentComputer2D anAlphaSegment3(2);
anAlphaSegment3.init(aContour.begin());
while (anAlphaSegment3.end() != aContour.end() &&
anAlphaSegment3.extendFront()) {
}
aBoard << anAlphaSegment3;
aBoard.saveEPS("exampleAlphaThickSegmentNoisy.eps");
return 0;
}
void beginBlock(const std::string &keyword="")
DGtal is the top-level namespace which contains all DGtal functions and types.
int main(int argc, char **argv)