DGtal  1.3.beta
Data Structures | Public Types | Public Member Functions | Private Member Functions | Private Attributes
DGtal::GreedySegmentation< TSegmentComputer > Class Template Reference

Aim: Computes the greedy segmentation of a range given by a pair of ConstIterators. The last element of a given segment is the first one one of the next segment. More...

#include <DGtal/geometry/curves/GreedySegmentation.h>

Data Structures

class  SegmentComputerIterator
 Aim: Specific iterator to visit all the segments of a greedy segmentation. More...
 

Public Types

typedef TSegmentComputer SegmentComputer
 
typedef SegmentComputer::ConstIterator ConstIterator
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CForwardSegmentComputer< TSegmentComputer >))
 
 GreedySegmentation ()
 
 GreedySegmentation (const ConstIterator &itb, const ConstIterator &ite, const SegmentComputer &aSegmentComputer)
 
void setSubRange (const ConstIterator &itb, const ConstIterator &ite)
 
void setMode (const std::string &aMode)
 
 ~GreedySegmentation ()
 
GreedySegmentation::SegmentComputerIterator begin () const
 
GreedySegmentation::SegmentComputerIterator end () const
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 

Private Member Functions

 GreedySegmentation (const GreedySegmentation &other)
 
GreedySegmentationoperator= (const GreedySegmentation &other)
 

Private Attributes

ConstIterator myBegin
 
ConstIterator myEnd
 
ConstIterator myStart
 
ConstIterator myStop
 
std::string myMode
 
SegmentComputer mySegmentComputer
 

Detailed Description

template<typename TSegmentComputer>
class DGtal::GreedySegmentation< TSegmentComputer >

Aim: Computes the greedy segmentation of a range given by a pair of ConstIterators. The last element of a given segment is the first one one of the next segment.

Description of template class 'GreedySegmentation'

This class is a model of CSegmentation.

Template Parameters
TSegmentComputerat least a model of concepts::CForwardSegmentComputer (an online algorithm for the recognition of a given class of segments).

In the short example below, a digital curve stored in a STL vector is decomposed into 8-connected DSSs whose parameters are sent to the standard output.

//types definition
typedef PointVector<2,int> Point;
typedef std::vector<Point> Range;
typedef Range::const_iterator ConstIterator;
typedef ArithmeticalDSSComputer<ConstIterator,int,8> SegmentComputer;
typedef GreedySegmentation<SegmentComputer> Segmentation;
//input points
Range curve;
curve.push_back(Point(1,1));
curve.push_back(Point(2,1));
curve.push_back(Point(3,2));
curve.push_back(Point(4,2));
curve.push_back(Point(5,2));
curve.push_back(Point(6,2));
curve.push_back(Point(7,2));
curve.push_back(Point(8,1));
curve.push_back(Point(9,1));
//Segmentation
SegmentComputer recognitionAlgorithm;
Segmentation theSegmentation(curve.begin(), curve.end(), recognitionAlgorithm);
for ( ; i != end; ++i) {
SegmentComputer current(*i);
trace.info() << current << std::endl; //standard output
}

If you want to get the DSSs segmentation of the digital curve when it is scanned in the reverse way, you can use the reverse iterator of the STL vector:

typedef Range::const_reverse_iterator ConstReverseIterator;
Segmentation theSegmentation(curve.rbegin(), curve.rend(), recognitionAlgorithm);

If you want to get the DSSs segmentation of a part of the digital curve (not the whole digital curve), you can give the range to process as a pair of iterators when calling the setSubRange() method as follow:

theSegmentation.setSubRange(beginIt, endIt);

Obviously, [beginIt, endIt) has to be a valid range included in the wider range [curve.begin(), curve.end()).

Moreover, a part of a digital curve may be processed either as an independant (open) digital curve or as a part whose segmentation at the ends depends of the underlying digital curve. That's why 3 processing modes are available:

In order to set a mode (before getting a SegmentComputerIterator), use the setMode() method as follow:

theSegmentation.setMode("DoNotTruncate");

Note that the default mode will be used for any unknown modes.

See also
testSegmentation.cpp
Examples
geometry/curves/exampleArithDSS3d.cpp, geometry/curves/exampleFrechetShortcut.cpp, geometry/curves/greedy-dss-decomposition.cpp, and geometry/curves/greedyAlphaThickDecomposition.cpp.

Definition at line 149 of file GreedySegmentation.h.

Member Typedef Documentation

◆ ConstIterator

template<typename TSegmentComputer >
typedef SegmentComputer::ConstIterator DGtal::GreedySegmentation< TSegmentComputer >::ConstIterator

Definition at line 156 of file GreedySegmentation.h.

◆ SegmentComputer

template<typename TSegmentComputer >
typedef TSegmentComputer DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputer

Definition at line 155 of file GreedySegmentation.h.

Constructor & Destructor Documentation

◆ GreedySegmentation() [1/3]

template<typename TSegmentComputer >
DGtal::GreedySegmentation< TSegmentComputer >::GreedySegmentation ( )
inline

Default constructor.

Nb: not valid

Definition at line 385 of file GreedySegmentation.h.

385 {};

◆ GreedySegmentation() [2/3]

template<typename TSegmentComputer >
DGtal::GreedySegmentation< TSegmentComputer >::GreedySegmentation ( const ConstIterator itb,
const ConstIterator ite,
const SegmentComputer aSegmentComputer 
)

Constructor.

Parameters
itbbegin iterator of the underlying range
iteend iterator of the underlying range
aSegmentComputeran online segment recognition algorithm.

◆ ~GreedySegmentation()

template<typename TSegmentComputer >
DGtal::GreedySegmentation< TSegmentComputer >::~GreedySegmentation ( )

Destructor.

◆ GreedySegmentation() [3/3]

template<typename TSegmentComputer >
DGtal::GreedySegmentation< TSegmentComputer >::GreedySegmentation ( const GreedySegmentation< TSegmentComputer > &  other)
private

Copy constructor.

Parameters
otherthe object to clone.

Member Function Documentation

◆ begin()

template<typename TSegmentComputer >
GreedySegmentation::SegmentComputerIterator DGtal::GreedySegmentation< TSegmentComputer >::begin ( ) const

ConstIterator service.

Returns
an iterator pointing on the first segment.

◆ BOOST_CONCEPT_ASSERT()

template<typename TSegmentComputer >
DGtal::GreedySegmentation< TSegmentComputer >::BOOST_CONCEPT_ASSERT ( (concepts::CForwardSegmentComputer< TSegmentComputer >)  )

◆ end()

template<typename TSegmentComputer >
GreedySegmentation::SegmentComputerIterator DGtal::GreedySegmentation< TSegmentComputer >::end ( ) const

ConstIterator service.

Returns
an iterator pointing after the last segment.

◆ isValid()

template<typename TSegmentComputer >
bool DGtal::GreedySegmentation< TSegmentComputer >::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

◆ operator=()

template<typename TSegmentComputer >
GreedySegmentation& DGtal::GreedySegmentation< TSegmentComputer >::operator= ( const GreedySegmentation< TSegmentComputer > &  other)
private

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.

◆ selfDisplay()

template<typename TSegmentComputer >
void DGtal::GreedySegmentation< TSegmentComputer >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

◆ setMode()

template<typename TSegmentComputer >
void DGtal::GreedySegmentation< TSegmentComputer >::setMode ( const std::string &  aMode)

Set processing mode

Parameters
aModeone of the 3 available modes : "Truncate" (default), "Truncate+1", "DoNotTruncate".

◆ setSubRange()

template<typename TSegmentComputer >
void DGtal::GreedySegmentation< TSegmentComputer >::setSubRange ( const ConstIterator itb,
const ConstIterator ite 
)

Set a sub-range to process.

Parameters
itbbegin iterator the range to processed
iteend iterator the range to processed

Nb: must be a valid range included in the underlying range.

Field Documentation

◆ myBegin

template<typename TSegmentComputer >
ConstIterator DGtal::GreedySegmentation< TSegmentComputer >::myBegin
private

Begin iterator of the underlying range

Definition at line 454 of file GreedySegmentation.h.

◆ myEnd

template<typename TSegmentComputer >
ConstIterator DGtal::GreedySegmentation< TSegmentComputer >::myEnd
private

End iterator of the underlying range

Definition at line 459 of file GreedySegmentation.h.

◆ myMode

template<typename TSegmentComputer >
std::string DGtal::GreedySegmentation< TSegmentComputer >::myMode
private

Mode: either "Truncate" (default), "Truncate+1", or "DoNotTruncate".

Definition at line 474 of file GreedySegmentation.h.

◆ mySegmentComputer

template<typename TSegmentComputer >
SegmentComputer DGtal::GreedySegmentation< TSegmentComputer >::mySegmentComputer
private

the segment computer.

Definition at line 479 of file GreedySegmentation.h.

◆ myStart

template<typename TSegmentComputer >
ConstIterator DGtal::GreedySegmentation< TSegmentComputer >::myStart
private

Begin iterator of the subrange to segment

Definition at line 464 of file GreedySegmentation.h.

◆ myStop

template<typename TSegmentComputer >
ConstIterator DGtal::GreedySegmentation< TSegmentComputer >::myStop
private

End iterator of the subrange to segment

Definition at line 469 of file GreedySegmentation.h.


The documentation for this class was generated from the following file:
DGtal::ArithmeticalDSSComputer< std::vector< Z2i::Point >::const_iterator, int, 4 >
DGtal::SimpleRandomAccessRangeFromPoint::begin
Iterator begin()
Definition: SimpleRandomAccessRangeFromPoint.h:203
DGtal::SimpleRandomAccessRangeFromPoint::rend
ReverseIterator rend()
Definition: SimpleRandomAccessRangeFromPoint.h:319
DGtal::GreedySegmentation::SegmentComputer
TSegmentComputer SegmentComputer
Definition: GreedySegmentation.h:155
DGtal::trace
Trace trace
Definition: Common.h:154
DGtal::SimpleRandomAccessRangeFromPoint::end
Iterator end()
Definition: SimpleRandomAccessRangeFromPoint.h:243
DGtal::SaturatedSegmentation::SegmentComputerIterator
Aim: Specific iterator to visit all the maximal segments of a saturated segmentation.
Definition: SaturatedSegmentation.h:179
DGtal::Trace::info
std::ostream & info()
DGtal::SimpleRandomAccessRangeFromPoint::rbegin
ReverseIterator rbegin()
Definition: SimpleRandomAccessRangeFromPoint.h:299
DGtal::SaturatedSegmentation::SegmentComputerIterator::begin
const ConstIterator begin() const
DGtal::SaturatedSegmentation::SegmentComputerIterator::end
const ConstIterator end() const
DGtal::SimpleRandomAccessRangeFromPoint
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
Definition: SimpleRandomAccessRangeFromPoint.h:73
DGtal::GreedySegmentation::ConstIterator
SegmentComputer::ConstIterator ConstIterator
Definition: GreedySegmentation.h:156
DGtal::GreedySegmentation::end
GreedySegmentation::SegmentComputerIterator end() const
Range
Image::Range Range
Definition: testSimpleRandomAccessRangeFromPoint.cpp:46
Segmentation
SaturatedSegmentation< SegmentComputer > Segmentation
Definition: testArithmeticalDSSComputerOnSurfels.cpp:56
DGtal::SaturatedSegmentation
Aim: Computes the saturated segmentation, that is the whole set of maximal segments within a range gi...
Definition: SaturatedSegmentation.h:153
Point
MyPointD Point
Definition: testClone2.cpp:383