DGtal  1.0.0
Functions
exampleAlphaThickSegmentTgtCover.cpp File Reference
#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"
Include dependency graph for exampleAlphaThickSegmentTgtCover.cpp:

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/11/08

An example file named exampleAlphaThickSegmentTgtCover.

This file is part of the DGtal library.

Definition in file exampleAlphaThickSegmentTgtCover.cpp.

Function Documentation

◆ main()

int main ( )

[SaturatedAlphaThickCoverTypes]

[SaturatedAlphaThickCoverTypes]

[SaturatedAlphaThickCoverCirculator]

[SaturatedAlphaThickCoverCirculator]

[SaturatedAlphaThickCoverComputerSeg]

[SaturatedAlphaThickCoverComputerSeg]

[SaturatedAlphaThickCoverDisplay]

[SaturatedAlphaThickCoverDisplay]

[SaturatedAlphaThickCoverSingleInit]

[SaturatedAlphaThickCoverSingleInit]

[SaturatedAlphaThickCoverDisplaySingle]

[SaturatedAlphaThickCoverDisplaySingle]

Definition at line 67 of file exampleAlphaThickSegmentTgtCover.cpp.

68 {
69  trace.beginBlock ( "Example of AlphaThickSegment tangential cover obtained from SaturatedSegmentation" );
70 
72  typedef std::vector<Z2i::RealPoint>::const_iterator RAConstIterator;
73  typedef Circulator<RAConstIterator> ConstCirculator;
74  typedef AlphaThickSegmentComputer<Z2i::RealPoint, ConstCirculator> AlphaThickSegmentComputer2D;
77 
78 
79  Board2D aBoard, aBoard2;
80  std::string file = examplesPath + "samples/contourSnoisy.sdp";
81  std::vector<Z2i::RealPoint> aContour = PointListReader<Z2i::RealPoint>::getPointsFromFile (file);
82 
83  // displaying contour
84  aBoard << SetMode(aContour[0].className(), "Grid");
85  aBoard2 << SetMode(aContour[0].className(), "Grid");
86  std::vector<LibBoard::Point> poly;
87  for (unsigned int i = 0; i< aContour.size(); i++) poly.push_back(LibBoard::Point(aContour[i][0], aContour[i][1]));
88  aBoard.setPenColor(DGtal::Color(200, 200, 200));
89  aBoard.fillPolyline(poly);
90  aBoard2.setPenColor(DGtal::Color(200, 200, 200));
91  aBoard2.fillPolyline(poly);
92 
94  Circulator<RAConstIterator> circulator (aContour.begin(), aContour.begin(), aContour.end());
96 
98  AlphaThickSegmentComputer2D computer(4, functions::Hull2D::EuclideanThickness);
99  AlphaSegmentation segmentator(circulator, circulator, computer);
101 
103  AlphaSegmentation::SegmentComputerIterator i = segmentator.begin();
104  AlphaSegmentation::SegmentComputerIterator end = segmentator.end();
105 
106  for ( ; i != end; ++i) {
107  AlphaThickSegmentComputer2D current(*i);
108  aBoard << SetMode(current.className(), "BoundingBox");
109  aBoard << current;
110  }
112  aBoard.saveEPS("exampleAlphaThickSegmentTgtCover.eps");
113  trace.endBlock();
114 
115  trace.beginBlock ( "Example of AlphaThickSegment tangential cover obtained for a single point" );
116 
117  // Displaying Tangential cover associated to a single point:
118 
120  unsigned int index = 80;
121  firstMaximalSegment(computer, circulator+index, circulator, circulator);
122  AlphaThickSegmentComputer2D first (computer);
123  lastMaximalSegment(computer, circulator+index, circulator, circulator);
124  AlphaThickSegmentComputer2D last (computer);
126 
128  aBoard2.fillCircle((*(circulator+index))[0], (*(circulator+index))[1], 1.0);
130  while(first.end() != last.end()){
131  aBoard2 << SetMode(first.className(), "BoundingBox");
132  aBoard2 << first;
133  nextMaximalSegment(first, circulator);
134  }
135  aBoard2 << last;
137 
138  stringstream name;
139  name << "exampleAlphaThickSegmentTgtCoverPoint" << index<< ".eps";
140  aBoard2.saveEPS(name.str().c_str());
141  trace.endBlock();
142 
143 
144 
145 
146  return 0;
147 }
void beginBlock(const std::string &keyword="")
void fillPolyline(const std::vector< Point > &points, int depthValue=-1)
Definition: Board.cpp:551
void nextMaximalSegment(SC &s, const typename SC::ConstIterator &end, DGtal::ForwardSegmentComputer)
Trace trace
Definition: Common.h:144
double endBlock()
Struct representing a 2D point.
Definition: Point.h:27
void fillCircle(double x, double y, double radius, int depthValue=-1)
Definition: Board.cpp:471
static const Color Blue
Definition: Color.h:394
Aim: Implements method to read a set of points represented in each line of a file.
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
Definition: Circulator.h:85
void lastMaximalSegment(SC &s, const typename SC::ConstIterator &i, const typename SC::ConstIterator &begin, const typename SC::ConstIterator &end, DGtal::ForwardSegmentComputer)
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition: Board2D.h:247
Aim: Computes the saturated segmentation, that is the whole set of maximal segments within a range gi...
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
Board & setPenColor(const DGtal::Color &color)
Definition: Board.cpp:298
Aim: This class is devoted to the recognition of alpha thick segments as described in ....
void firstMaximalSegment(SC &s, const typename SC::ConstIterator &i, const typename SC::ConstIterator &begin, const typename SC::ConstIterator &end, DGtal::ForwardSegmentComputer)
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:70

References DGtal::Trace::beginBlock(), DGtal::Color::Blue, DGtal::Trace::endBlock(), LibBoard::Board::fillCircle(), LibBoard::Board::fillPolyline(), DGtal::firstMaximalSegment(), DGtal::lastMaximalSegment(), DGtal::nextMaximalSegment(), LibBoard::Board::saveEPS(), LibBoard::Board::setPenColor(), and DGtal::trace.