DGtal
0.6.devel
|
#include <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 ((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) | |
GreedySegmentation & | operator= (const GreedySegmentation &other) |
Private Attributes | |
ConstIterator | myBegin |
ConstIterator | myEnd |
ConstIterator | myStart |
ConstIterator | myStop |
std::string | myMode |
SegmentComputer | mySegmentComputer |
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' <p> This class is a model of CSegmentation. @tparam TSegmentComputer at least a model of 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. @code
//types definition typedef PointVector<2,int> Point; typedef std::vector<Point> Range; typedef Range::const_iterator ConstIterator; typedef ArithmeticalDSS<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);
Segmentation::SegmentComputerIterator i = theSegmentation.begin(); Segmentation::SegmentComputerIterator end = theSegmentation.end(); 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:
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:
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:
Note that the default mode will be used for any unknown modes.
Definition at line 148 of file GreedySegmentation.h.
typedef SegmentComputer::ConstIterator DGtal::GreedySegmentation< TSegmentComputer >::ConstIterator |
Definition at line 155 of file GreedySegmentation.h.
typedef TSegmentComputer DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputer |
Definition at line 154 of file GreedySegmentation.h.
|
inline |
DGtal::GreedySegmentation< TSegmentComputer >::GreedySegmentation | ( | const ConstIterator & | itb, |
const ConstIterator & | ite, | ||
const SegmentComputer & | aSegmentComputer | ||
) |
Constructor.
itb | begin iterator of the underlying range |
ite | end iterator of the underlying range |
aSegmentComputer | an online segment recognition algorithm. |
Definition at line 344 of file GreedySegmentation.ih.
|
inline |
|
private |
Copy constructor.
other | the object to clone. |
|
inline |
ConstIterator service.
Definition at line 387 of file GreedySegmentation.ih.
References DGtal::GreedySegmentation< TSegmentComputer >::mySegmentComputer.
DGtal::GreedySegmentation< TSegmentComputer >::BOOST_CONCEPT_ASSERT | ( | (CForwardSegmentComputer< TSegmentComputer >) | ) |
|
inline |
ConstIterator service.
Definition at line 396 of file GreedySegmentation.ih.
References DGtal::GreedySegmentation< TSegmentComputer >::mySegmentComputer.
|
inline |
Checks the validity/consistency of the object.
Definition at line 415 of file GreedySegmentation.ih.
Referenced by DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::operator==().
|
private |
Assignment.
other | the object to copy. |
|
inline |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
Definition at line 406 of file GreedySegmentation.ih.
|
inline |
Set processing mode
aMode | one of the 3 available modes : "Truncate" (default), "Truncate+1", "DoNotTruncate". |
Definition at line 370 of file GreedySegmentation.ih.
References DGtal::GreedySegmentation< TSegmentComputer >::myMode.
|
inline |
Set a sub-range to process.
itb | begin iterator the range to processed |
ite | end iterator the range to processed |
Nb: must be a valid range included in the underlying range.
Definition at line 359 of file GreedySegmentation.ih.
References DGtal::GreedySegmentation< TSegmentComputer >::myMode, DGtal::GreedySegmentation< TSegmentComputer >::myStart, and DGtal::GreedySegmentation< TSegmentComputer >::myStop.
|
private |
Begin iterator of the underlying range
Definition at line 453 of file GreedySegmentation.h.
|
private |
End iterator of the underlying range
Definition at line 458 of file GreedySegmentation.h.
|
private |
Mode: either "Truncate" (default), "Truncate+1", or "DoNotTruncate".
Definition at line 473 of file GreedySegmentation.h.
Referenced by DGtal::GreedySegmentation< TSegmentComputer >::setMode(), and DGtal::GreedySegmentation< TSegmentComputer >::setSubRange().
|
private |
the segment computer.
Definition at line 478 of file GreedySegmentation.h.
Referenced by DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::begin(), DGtal::GreedySegmentation< TSegmentComputer >::begin(), DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::doesIntersectNext(), DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::end(), DGtal::GreedySegmentation< TSegmentComputer >::end(), DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::get(), DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::longestSegment(), DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::next(), DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::operator*(), DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::operator->(), DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::operator=(), and DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::operator==().
|
private |
Begin iterator of the subrange to segment
Definition at line 463 of file GreedySegmentation.h.
Referenced by DGtal::GreedySegmentation< TSegmentComputer >::setSubRange().
|
private |
End iterator of the subrange to segment
Definition at line 468 of file GreedySegmentation.h.
Referenced by DGtal::GreedySegmentation< TSegmentComputer >::setSubRange().