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...
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
-
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.
typedef PointVector<2,int>
Point;
typedef std::vector<Point>
Range;
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 theSegmentation(curve.begin(), curve.end(), recognitionAlgorithm);
Segmentation::SegmentComputerIterator i = theSegmentation.begin();
Segmentation::SegmentComputerIterator end = theSegmentation.end();
}
GreedySegmentation::SegmentComputerIterator end() const
TSegmentComputer SegmentComputer
SegmentComputer::ConstIterator ConstIterator
ArithmeticalDSSComputer< std::vector< Z2i::Point >::const_iterator, int, 4 > SegmentComputer
SaturatedSegmentation< SegmentComputer > Segmentation
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:
- "Truncate" (default), the extension of the last segment (and the segmentation) stops just before endIt.
- "Truncate+1", the last segment is extended to endIt too if it is possible, provided that endIt != curve.end().
- "DoNotTruncate", the last segment is extended as far as possible, provided that curve.end() is not reached.
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
Definition at line 149 of file GreedySegmentation.h.