DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
exampleAlphaThickSegmentNoisy.cpp File Reference
#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"

Go to the source code of this file.

Functions

int main ()
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Bertrand Kerautret (kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), University of Nancy, France
Date
2015/01/30

An example file named exampleAlphaThickSegmentNoisy.

This file is part of the DGtal library.

Definition in file exampleAlphaThickSegmentNoisy.cpp.

Function Documentation

◆ main()

int main ( void  )

[exampleAlphaThickSegmentNoisyTypedef]

[exampleAlphaThickSegmentNoisyTypedef]

[exampleAlphaThickSegmentNoisyReadFile]

[exampleAlphaThickSegmentNoisyReadFile]

[exampleAlphaThickSegmentNoisInitAndReco] [exampleAlphaThickSegmentNoisInit]

[exampleAlphaThickSegmentNoisInit] [exampleAlphaThickSegmentNoisReco]

[exampleAlphaThickSegmentNoisReco] [exampleAlphaThickSegmentNoisInitAndReco]

[exampleAlphaThickSegmentDisplay]

[exampleAlphaThickSegmentDisplay]

[exampleAlphaThickSegmentNoisInitAndReco2]

[exampleAlphaThickSegmentNoisInitAndReco2]

[exampleAlphaThickSegmentNoisCustomColor]

[exampleAlphaThickSegmentNoisCustomColor]

Definition at line 59 of file exampleAlphaThickSegmentNoisy.cpp.

60{
61 trace.beginBlock ( "Example exampleAlphaThickSegment" );
62
64 typedef AlphaThickSegmentComputer< Z2i::RealPoint > AlphaThickSegmentComputer2D;
66
67 Board2D aBoard;
68 std::string file = examplesPath + "samples/contourSnoisy.sdp";
70 std::vector<Z2i::RealPoint> aContour = PointListReader<Z2i::RealPoint>::getPointsFromFile(file);
72
73 // displaying contour
74 aBoard << SetMode(aContour[0].className(), "Grid");
75 for (unsigned int i = 0; i< aContour.size(); i++){
76 aBoard << aContour[i];
77 aBoard.drawLine(aContour[i][0], aContour[i][1],
78 aContour[(i+1)%aContour.size()][0], aContour[(i+1)%aContour.size()][1]);
79 }
80
81
82 //initialisation of an AlphaThickSegmentComputer2D of thickness 10 and forward recognition.
85 AlphaThickSegmentComputer2D anAlphaSegment(15);
88 std::vector<Z2i::RealPoint>::const_iterator it = aContour.begin();
89 while (anAlphaSegment.extendFront(*it)) {
90 it++;
91 }
94
96 aBoard << anAlphaSegment;
98 AlphaThickSegmentComputer2D anAlphaSegment2(9);
100 anAlphaSegment2.init(aContour.begin());
101 while (anAlphaSegment2.end() != aContour.end() &&
102 anAlphaSegment2.extendFront()) {
103 }
105
107 aBoard << CustomStyle( anAlphaSegment2.className(), new CustomColors( DGtal::Color::Blue, DGtal::Color::None ) );
108 aBoard << anAlphaSegment2;
110
111 AlphaThickSegmentComputer2D anAlphaSegment3(2);
112 anAlphaSegment3.init(aContour.begin());
113 while (anAlphaSegment3.end() != aContour.end() &&
114 anAlphaSegment3.extendFront()) {
115 }
116 aBoard << CustomStyle( anAlphaSegment3.className(), new CustomColors( DGtal::Color::Green, DGtal::Color::None ) );
117 aBoard << anAlphaSegment3;
118
119
120 aBoard.saveEPS("exampleAlphaThickSegmentNoisy.eps");
121
122 trace.endBlock();
123 return 0;
124}
Aim: This class is devoted to the recognition of alpha thick segments as described in ....
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:368
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
Trace trace
Definition: Common.h:154
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:279
static std::vector< TPoint > getPointsFromFile(const std::string &filename, std::vector< unsigned int > aVectPosition=std::vector< unsigned int >())
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition: Board2D.h:247

References DGtal::Trace::beginBlock(), DGtal::Color::Blue, LibBoard::Board::drawLine(), DGtal::Trace::endBlock(), DGtal::PointListReader< TPoint >::getPointsFromFile(), DGtal::Color::Green, DGtal::Color::None, LibBoard::Board::saveEPS(), and DGtal::trace.