DGtal
1.5.beta
|
Aim: This class is devoted to the recognition of alpha thick segments as described in [51] . From a maximal diagonal alphaMax thickness, it recognizes thick segments and may thus take into account some noise in the input contour. Moreover points of the segment may not be (digitally) connected and may have floating point coordinates. Connection is only given by the order of the points. More...
#include <DGtal/geometry/curves/AlphaThickSegmentComputer.h>
Data Structures | |
struct | State |
Public Types | |
typedef TInputPoint | InputPoint |
typedef std::vector< InputPoint > | InputPointContainer |
typedef InputPointContainer::size_type | Size |
typedef InputPointContainer::const_iterator | ContainerConstIterator |
typedef DGtal::functions::Hull2D::ThicknessDefinition | ThicknessDef |
typedef InputPointContainer::iterator | Iterator |
typedef TConstIterator | ConstIterator |
typedef ParallelStrip< SpaceND< 2, DGtal::int32_t >,true, true > | Primitive |
typedef DGtal::PointVector< 2, double > | PointD |
typedef AlphaThickSegmentComputer< InputPoint, ConstIterator > | Self |
typedef AlphaThickSegmentComputer< InputPoint, ReverseIterator< ConstIterator > > | Reverse |
typedef DGtal::InHalfPlaneBySimple3x3Matrix< InputPoint, typename InputPoint::Component > | Functor |
typedef DGtal::MelkmanConvexHull< InputPoint, Functor >::ConstIterator | ConvexhullConstIterator |
Protected Member Functions | |
bool | melkmanIsConvexValid () |
double | updateMainHeightAndAntiPodal () |
template<typename TPoint , typename TPointD > | |
bool | projectOnStraightLine (const TPoint &ptA, const TPoint &ptB, const TPoint &ptC, TPointD &ptProjected) const |
template<typename TConstIteratorG > | |
void | computeExtremaPoints (const TConstIteratorG &itBegin, const TConstIteratorG &itEnd, InputPoint &aFirstExtrPt, InputPoint &aLastExtrPt) const |
Protected Attributes | |
ConstIterator | myBegin |
ConstIterator | myEnd |
Private Member Functions | |
BOOST_STATIC_ASSERT ((TInputPoint::dimension==2)) | |
BOOST_CONCEPT_ASSERT ((boost_concepts::ReadableIterator< TConstIterator >)) | |
Private Attributes | |
InputPointContainer | myPointContainer |
double | myMaximalThickness |
double | myThicknessCompPrecision |
ThicknessDef | myThicknessDefinition |
State | myState |
State | myPreviousState |
bool | myIsStoringPoints |
unsigned int | myNbPointsAddedFromIterators |
Aim: This class is devoted to the recognition of alpha thick segments as described in [51] . From a maximal diagonal alphaMax thickness, it recognizes thick segments and may thus take into account some noise in the input contour. Moreover points of the segment may not be (digitally) connected and may have floating point coordinates. Connection is only given by the order of the points.
Description of class 'AlphaThickSegmentComputer'
As other solutions like [47] the algorithm given here is based on the height/width computation of the convex hull computed from a given set of points. The actual implementation exploits the height/width update defined in the [51] (see [51] page 363) which reduces the complexity from \(O(n\ log\ n) \) in \(O( log\ n) \). Note that the convexhull update in linear time (with point substraction) proposed by Buzer [86] is not yet implemented.
TInputPoint | the type of input points: their dimension must be two but their components may be integers or floating-point values. |
TConstIterator | the type of iterator of candidate points (used in initialization) which should be readable and forward. By default the iterator is set to the const_iterator of std::vector< TInputPoint > . |
This class is a model of boost::ForwardContainer and CForwardSegmentComputer. It is also default constructible, copy constructible, assignable and equality comparable.
Alpha thick segment recognition may be typically done as follows:
The proposed implementation is mainly a backport from ImaGene with some various refactoring.
Definition at line 127 of file AlphaThickSegmentComputer.h.
typedef TConstIterator DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::ConstIterator |
Definition at line 149 of file AlphaThickSegmentComputer.h.
typedef InputPointContainer::const_iterator DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::ContainerConstIterator |
Definition at line 145 of file AlphaThickSegmentComputer.h.
typedef DGtal::MelkmanConvexHull<InputPoint, Functor>::ConstIterator DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::ConvexhullConstIterator |
Definition at line 161 of file AlphaThickSegmentComputer.h.
typedef DGtal::InHalfPlaneBySimple3x3Matrix<InputPoint, typename InputPoint::Component> DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::Functor |
Definition at line 160 of file AlphaThickSegmentComputer.h.
typedef TInputPoint DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::InputPoint |
Type of input point.
Definition at line 138 of file AlphaThickSegmentComputer.h.
typedef std::vector< InputPoint > DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::InputPointContainer |
The container type of Input Point
Definition at line 143 of file AlphaThickSegmentComputer.h.
typedef InputPointContainer::iterator DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::Iterator |
Definition at line 148 of file AlphaThickSegmentComputer.h.
typedef DGtal::PointVector<2, double> DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::PointD |
Type of embedded points
Definition at line 156 of file AlphaThickSegmentComputer.h.
typedef ParallelStrip< SpaceND< 2, DGtal::int32_t > ,true,true> DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::Primitive |
Definition at line 150 of file AlphaThickSegmentComputer.h.
typedef AlphaThickSegmentComputer<InputPoint, ReverseIterator<ConstIterator> > DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::Reverse |
Definition at line 159 of file AlphaThickSegmentComputer.h.
typedef AlphaThickSegmentComputer<InputPoint, ConstIterator> DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::Self |
Definition at line 158 of file AlphaThickSegmentComputer.h.
typedef InputPointContainer::size_type DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::Size |
Definition at line 144 of file AlphaThickSegmentComputer.h.
typedef DGtal::functions::Hull2D::ThicknessDefinition DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::ThicknessDef |
Definition at line 146 of file AlphaThickSegmentComputer.h.
DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::AlphaThickSegmentComputer | ( | const double | maximalThickness = 1.0 , |
const ThicknessDef & | thicknessDefinition = functions::Hull2D::HorizontalVerticalThickness , |
||
const double | thickCompPrecision = 1e-6 |
||
) |
Constructor.
[in] | maximalThickness | the maximal thickness of the segment (default 1). |
[in] | thicknessDefinition | the definition of the thickness used in the segment extension (can be DGtal::functions::Hull2D::HorizontalVerticalThickness (default) or DGtal::functions::Hull2D::EuclideanThickness). |
[in] | thickCompPrecision | to adjust the precision of the thickness estimation used in the comparison during the segment extension (default set to 1e-6). |
DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::~AlphaThickSegmentComputer | ( | ) |
Destructor.
DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::AlphaThickSegmentComputer | ( | const AlphaThickSegmentComputer< TInputPoint, TConstIterator > & | other | ) |
Copy constructor.
[in] | other | the object to clone. |
ConstIterator DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::begin | ( | ) | const |
|
private |
|
private |
std::string DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::className | ( | ) | const |
|
protected |
From an point iterator (itBegin and itEnd) it computes the two extrem points (aFirstExtrPt and aLastExtrPt) defined according to the direction of the current segment.
[in] | itBegin | the start iterator of the input points. |
[in] | itEnd | the end iterator of the input points. |
[out] | aFirstExtrPt | the first extrem point. |
[out] | aLastExtrPt | the last extrem point. |
void DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::computeParallelStripParams | ( | double & | mu, |
PointD & | N, | ||
double & | nu | ||
) | const |
Computes the paralell strip params from the current state of the segment.
[out] | mu | the minimal value of N.X (with N is the normal vector of the segment). |
[out] | N | the normal of the vector (not normalized). |
[out] | nu | the width of the strip. |
ContainerConstIterator DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::containerBegin | ( | ) | const |
ContainerConstIterator DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::containerEnd | ( | ) | const |
ConvexhullConstIterator DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::convexhullBegin | ( | ) | const |
ConvexhullConstIterator DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::convexhullEnd | ( | ) | const |
bool DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::empty | ( | ) | const |
ConstIterator DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::end | ( | ) | const |
bool DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::extendFront | ( | ) |
Tries to extend front the current alpha thick segment with the next contour point and checks if we have still an alpha thick segment of thickness less or equal to the initial value alpha_max. If it is the case the new point is added and the segment parameters are updated, otherwise the alpha thick segment is keep in its original state.
bool DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::extendFront | ( | const InputPoint & | aPoint | ) |
Tries to add the point aPoint at the front of the current alpha thick segment and checks if we have still an alpha thick segment of thickness less or equal to the initial value alpha_max. If it is the case the new point is added and the segment parameters are updated, otherwise the alpha thick segment is keep in its original state.
[in] | aPoint | the new point to extend the current segment. |
std::pair<std::pair<InputPoint, InputPoint>, InputPoint> DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::getAntipodalLeaningPoints | ( | ) | const |
void DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::getBoundingBox | ( | PointD & | pt1LongestSegment1, |
PointD & | pt2LongestSegment1, | ||
PointD & | pt3LongestSegment2, | ||
PointD & | pt4LongestSegment2 | ||
) | const |
Computes the segment bounding box defined from the extremity points computed after a scan of the current convexhull. Note that this bouding box differs from the begin/end points bounding box when a large amount of noise is present in the initial curve. The sequence of resulting points (pt1LongestSegment1, pt2LongestSegment1, pt3LongestSegment2, pt4LongestSegment4) are ccw oriented.
[out] | pt1LongestSegment1 | the first point of one of the longest segment. |
[out] | pt2LongestSegment1 | the second point of one of the longest segment. |
[out] | pt3LongestSegment2 | the first point of one of the second longest segment. |
[out] | pt4LongestSegment2 | the second point of one of the second longest segment. |
void DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::getBoundingBoxFromExtremPoints | ( | const InputPoint & | aFirstPt, |
const InputPoint & | aLastPt, | ||
PointD & | pt1LongestSegment1, | ||
PointD & | pt2LongestSegment1, | ||
PointD & | pt3LongestSegment2, | ||
PointD & | pt4LongestSegment2, | ||
double | minVisibleWidthBounds = 0.2 |
||
) | const |
Computes the segment bounding box according to two extremity points (aFirstPt, aLastPt).
[in] | aFirstPt | the first extrem point. |
[in] | aLastPt | the last extrem point. |
[out] | pt1LongestSegment1 | the first point of one of the longest segment. |
[out] | pt2LongestSegment1 | the second point of one of the longest segment. |
[out] | pt3LongestSegment2 | the first point of one of the second longest segment. |
[out] | pt4LongestSegment2 | the second point of one of the second longest segment. |
[in] | minVisibleWidthBounds | the minimal width of the resulting bounding box (for drawing issue when the segment thickness is 0). The sequence of resulting points (pt1LongestSegment1, pt2LongestSegment1, pt3LongestSegment2, pt4LongestSegment4) are ccw oriented. |
std::vector<InputPoint> DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::getConvexHull | ( | ) | const |
std::pair<InputPoint, InputPoint> DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::getExtremityPoints | ( | ) | const |
Get the extremity points of the segment. These points are not necessary the last point of the segment.
double DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::getMu | ( | ) | const |
PointD DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::getNormal | ( | ) | const |
double DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::getNu | ( | ) | const |
unsigned int DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::getNumberSegmentPoints | ( | ) | const |
Reverse DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::getReverse | ( | ) | const |
double DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::getSegmentLength | ( | ) | const |
Self DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::getSelf | ( | ) | const |
double DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::getThickness | ( | ) | const |
void DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::init | ( | const ConstIterator & | it | ) |
Initialisation with an ConstIterator (to conform to CForwardSegmentComputer). The maximal thickness corresponds to the width of the ParallelStrip primitive (set to 1 by default).
[in] | it | an iterator on input points. |
bool DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::isExtendableFront | ( | ) |
Tests whether the current alpha thick segment can be extended at the front with the next contour point i.e checks if we have still an alpha thick segment of width alpha_max after adding the given point aPoint. The segment parameters are keep in its original state.
bool DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::isExtendableFront | ( | const InputPoint & | aPoint | ) |
Tests whether the current alpha thick segment can be extended, i.e checks if we have still an alpha thick segment of width alpha_max after adding the given point aPoint. The segment parameters are keep in its original state.
[in] | aPoint | the point to be tested for the segment extension. |
bool DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::isStoringSegmentPoints | ( | ) | const |
bool DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
Size DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::max_size | ( | ) | const |
|
protected |
Depending on connexity, return true if a convex is valid.
bool DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::operator!= | ( | const AlphaThickSegmentComputer< TInputPoint, TConstIterator > & | other | ) | const |
Difference operator.
other | the object to compare with. |
AlphaThickSegmentComputer& DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::operator= | ( | const AlphaThickSegmentComputer< TInputPoint, TConstIterator > & | other | ) |
Assignment.
other | the object to copy. |
bool DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::operator== | ( | const AlphaThickSegmentComputer< TInputPoint, TConstIterator > & | other | ) | const |
Equality operator.
other | the object to compare with. |
Primitive DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::primitive | ( | ) | const |
Returns the current primitive recognized by this computer, which is a ParallelStrip of axis width smaller than the one specified at instanciation.
|
protected |
Computes the projection of a Point ptC on the real line defined by the two points (ptA, ptB), and return true if the projected point is inside the segment closed interval [A,B].
[in] | ptA | one of the two points defining the straight line. |
[in] | ptB | one of the two points defining the straight line. |
[in] | ptC | the point to be projected. |
[out] | ptProjected | the projected point. |
void DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
[out] | out | the output stream where the object is written. |
Size DGtal::AlphaThickSegmentComputer< TInputPoint, TConstIterator >::size | ( | ) | const |
|
protected |
Updates the main height of the melkman convex hull and update the antipodal pairs.
|
protected |
begin iterator (associated to input data)
Definition at line 577 of file AlphaThickSegmentComputer.h.
|
protected |
begin iterator (associated to input data)
Definition at line 582 of file AlphaThickSegmentComputer.h.
|
private |
Definition at line 622 of file AlphaThickSegmentComputer.h.
|
private |
The maximal thickness of the segment.
Definition at line 598 of file AlphaThickSegmentComputer.h.
|
private |
Used by the size method.
Definition at line 627 of file AlphaThickSegmentComputer.h.
|
mutableprivate |
The set of points contained in the alpha thick segment which can be changed during computations.
Definition at line 593 of file AlphaThickSegmentComputer.h.
|
mutableprivate |
Previous saved computer state
Definition at line 620 of file AlphaThickSegmentComputer.h.
|
private |
State of the actual computer
Definition at line 615 of file AlphaThickSegmentComputer.h.
|
private |
To adjust the precision of the thickness estimation used in the comparison during the segment extension.
Definition at line 603 of file AlphaThickSegmentComputer.h.
|
private |
To set a specific thickness definition.
Definition at line 609 of file AlphaThickSegmentComputer.h.