DGtal  1.3.beta
geometry/curves/exampleAlphaThickSegmentTgtCover.cpp

This example shows the tangential cover of an noisy contour from the alpha-thick segment primitive with alpha = 4.

See also
Alpha-thick Segment Recognition
Tangential cover with alpha-thick segments with alpha = 4
#include <iostream>
#include "ConfigExamples.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/base/Common.h"
#include "DGtal/geometry/curves/AlphaThickSegmentComputer.h"
#include "DGtal/geometry/curves/SaturatedSegmentation.h"
#include "DGtal/base/Circulator.h"
#include "DGtal/geometry/curves/SegmentComputerUtils.h"
#include "DGtal/io/boards/Board2D.h"
using namespace std;
using namespace DGtal;
int main()
{
trace.beginBlock ( "Example of AlphaThickSegment tangential cover obtained from SaturatedSegmentation" );
typedef std::vector<Z2i::RealPoint>::const_iterator RAConstIterator;
typedef Circulator<RAConstIterator> ConstCirculator;
Board2D aBoard, aBoard2;
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");
aBoard2 << SetMode(aContour[0].className(), "Grid");
std::vector<LibBoard::Point> poly;
for (unsigned int i = 0; i< aContour.size(); i++) poly.push_back(LibBoard::Point(aContour[i][0], aContour[i][1]));
aBoard.setPenColor(DGtal::Color(200, 200, 200));
aBoard.fillPolyline(poly);
aBoard2.setPenColor(DGtal::Color(200, 200, 200));
aBoard2.fillPolyline(poly);
Circulator<RAConstIterator> circulator (aContour.begin(), aContour.begin(), aContour.end());
AlphaThickSegmentComputer2D computer(4, functions::Hull2D::EuclideanThickness);
AlphaSegmentation segmentator(circulator, circulator, computer);
AlphaSegmentation::SegmentComputerIterator i = segmentator.begin();
AlphaSegmentation::SegmentComputerIterator end = segmentator.end();
for ( ; i != end; ++i) {
AlphaThickSegmentComputer2D current(*i);
aBoard << SetMode(current.className(), "BoundingBox");
aBoard << current;
}
aBoard.saveEPS("exampleAlphaThickSegmentTgtCover.eps");
trace.beginBlock ( "Example of AlphaThickSegment tangential cover obtained for a single point" );
// Displaying Tangential cover associated to a single point:
unsigned int index = 80;
firstMaximalSegment(computer, circulator+index, circulator, circulator);
AlphaThickSegmentComputer2D first (computer);
lastMaximalSegment(computer, circulator+index, circulator, circulator);
AlphaThickSegmentComputer2D last (computer);
aBoard2.fillCircle((*(circulator+index))[0], (*(circulator+index))[1], 1.0);
while(first.end() != last.end()){
aBoard2 << SetMode(first.className(), "BoundingBox");
aBoard2 << first;
nextMaximalSegment(first, circulator);
}
aBoard2 << last;
stringstream name;
name << "exampleAlphaThickSegmentTgtCoverPoint" << index<< ".eps";
aBoard2.saveEPS(name.str().c_str());
return 0;
}
// //
DGtal::firstMaximalSegment
void firstMaximalSegment(SC &s, const typename SC::ConstIterator &i, const typename SC::ConstIterator &begin, const typename SC::ConstIterator &end, DGtal::ForwardSegmentComputer)
Definition: SegmentComputerUtils.h:412
LibBoard::Board::setPenColor
Board & setPenColor(const DGtal::Color &color)
Definition: Board.cpp:298
DGtal::Circulator
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
Definition: Circulator.h:85
DGtal::Trace::endBlock
double endBlock()
DGtal::nextMaximalSegment
void nextMaximalSegment(SC &s, const typename SC::ConstIterator &end, DGtal::ForwardSegmentComputer)
Definition: SegmentComputerUtils.h:797
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
LibBoard::Board::fillPolyline
void fillPolyline(const std::vector< Point > &points, int depthValue=-1)
Definition: Board.cpp:551
DGtal::trace
Trace trace
Definition: Common.h:154
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::PointListReader
Aim: Implements method to read a set of points represented in each line of a file.
Definition: PointListReader.h:84
DGtal::Color::Blue
static const Color Blue
Definition: Color.h:395
DGtal::AlphaThickSegmentComputer
Aim: This class is devoted to the recognition of alpha thick segments as described in ....
Definition: AlphaThickSegmentComputer.h:127
LibBoard::Point
Struct representing a 2D point.
Definition: Point.h:27
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
LibBoard::Board::fillCircle
void fillCircle(double x, double y, double radius, int depthValue=-1)
Definition: Board.cpp:471
DGtal::lastMaximalSegment
void lastMaximalSegment(SC &s, const typename SC::ConstIterator &i, const typename SC::ConstIterator &begin, const typename SC::ConstIterator &end, DGtal::ForwardSegmentComputer)
Definition: SegmentComputerUtils.h:681
main
int main(int argc, char **argv)
Definition: testArithmeticDSS-benchmark.cpp:147
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:70
LibBoard::Board::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
DGtal::SetMode
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition: Board2D.h:247
DGtal::SaturatedSegmentation
Aim: Computes the saturated segmentation, that is the whole set of maximal segments within a range gi...
Definition: SaturatedSegmentation.h:153