Orfeo Toolbox  4.2
Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon > Class Template Reference

This class vectorizes a LabelObject to a Polygon. More...

#include <otbLabelObjectToPolygonFunctor.h>

+ Collaboration diagram for otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >:

Public Types

typedef
LabelObjectType::ConstLineIterator 
ConstLineIteratorType
 
typedef LineType::IndexType IndexType
 
typedef TLabelObject LabelObjectType
 
typedef LabelObjectType::LineType LineType
 
typedef itk::Point< double, 2 > PointType
 
typedef PolygonType::Pointer PolygonPointerType
 
typedef TPolygon PolygonType
 
typedef itk::Index< 2 > RegionIndexType
 
typedef itk::Vector< double, 2 > SpacingType
 
typedef PolygonType::VertexType VertexType
 

Public Member Functions

 LabelObjectToPolygonFunctor ()
 
virtual ~LabelObjectToPolygonFunctor ()
 
const char * GetNameOfClass ()
 
const PointTypeGetOrigin () const
 
const SpacingTypeGetSpacing () const
 
const RegionIndexTypeGetStartIndex () const
 
PolygonTypeoperator() (LabelObjectType *labelObject)
 
void SetOrigin (const PointType &origin)
 
void SetSpacing (const SpacingType &spacing)
 
void SetStartIndex (const RegionIndexType &index)
 

Private Types

typedef std::vector< IndexTypeIndexVectorType
 
enum  PositionFlagType {
  LEFT_END,
  RIGHT_END
}
 
typedef std::vector< LineTypeRunsPerLineType
 Internal structures. More...
 
typedef std::vector
< RunsPerLineType
RunsPerLineVectorType
 
enum  StateType {
  UP_LEFT,
  UP_RIGHT,
  DOWN_LEFT,
  DOWN_RIGHT
}
 Internal enums. More...
 

Private Member Functions

VertexType IndexToPoint (const VertexType &index) const
 
bool IsRunIndexValid (const IndexType &index) const
 Check if the given run index (index in line, line) is valid. More...
 
IndexType LeftEnd (const IndexType &runIndex) const
 Return the left-end of the run. More...
 
IndexType LeftMostRightEndInside (unsigned int line, const IndexType &point, const IndexType &run) const
 
IndexType RightEnd (const IndexType &runIndex) const
 Return the right-end of the run. More...
 
IndexType RightMostLeftEndInside (unsigned int line, const IndexType &point, const IndexType &run) const
 
void WalkLeft (unsigned int line, const IndexType &startPoint, const IndexType &endPoint, PolygonType *polygon, const StateType state)
 Walk left to update the finite states machine. More...
 
void WalkRight (unsigned int line, const IndexType &startPoint, const IndexType &endPoint, PolygonType *polygon, const StateType state)
 Walk right to update the finite states machine. More...
 
IndexType Within (const IndexType &point, unsigned int line) const
 Check if the point lies within the range of the line. More...
 

Static Private Member Functions

static bool LexicographicalLineCompare (const LineType &l1, const LineType &l2)
 Compare two line in the lexicographical order. More...
 

Private Attributes

int m_CurrentLine
 The current line for vectorization. More...
 
IndexType m_CurrentPoint
 The current point for vectorization. More...
 
IndexType m_CurrentRun
 The current run for vectorization. More...
 
StateType m_CurrentState
 The current state. More...
 
RunsPerLineVectorType m_InternalDataSet
 
unsigned int m_LineOffset
 The line offset from start of the region. More...
 
PointType m_Origin
 
PolygonPointerType m_Polygon
 
PositionFlagType m_PositionFlag
 The position flag. More...
 
IndexVectorType m_Solution
 The vector of vectorized boundaries. More...
 
SpacingType m_Spacing
 
RegionIndexType m_StartIndex
 
IndexType m_StartingPoint
 

Detailed Description

template<class TLabelObject, class TPolygon>
class otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >

This class vectorizes a LabelObject to a Polygon.

The algorithm follows a finite states machine described in the following paper:

"An algorithm for the rapid computation of boundaries of run-length encoded regions", Francis K. H. Queck, in Pattern Recognition 33 (2000), p 1637-1649.

Lines in the RLE are first sorted in lexicographical order (to ensure ordered RLE), and the finite states machine tracks the edge following 8 canonical states given by the configuration of two consecutive raws of lines.

Iterations are done until convergence which is guaranteed to happen.

Please be aware that this functor is not thread-safe.

Definition at line 58 of file otbLabelObjectToPolygonFunctor.h.

Member Typedef Documentation

template<class TLabelObject, class TPolygon>
typedef LabelObjectType::ConstLineIterator otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::ConstLineIteratorType

Const iterator over LabelObject lines

Definition at line 64 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
typedef LineType::IndexType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::IndexType

Definition at line 67 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
typedef std::vector<IndexType> otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::IndexVectorType
private

Definition at line 146 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
typedef TLabelObject otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::LabelObjectType

Template parameters typedefs

Definition at line 62 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
typedef LabelObjectType::LineType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::LineType

Definition at line 66 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
typedef itk::Point<double, 2> otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::PointType

Definition at line 71 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
typedef PolygonType::Pointer otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::PolygonPointerType

Definition at line 69 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
typedef TPolygon otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::PolygonType

Definition at line 68 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
typedef itk::Index<2> otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::RegionIndexType

Definition at line 73 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
typedef std::vector<LineType> otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::RunsPerLineType
private

Internal structures.

Definition at line 144 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
typedef std::vector<RunsPerLineType> otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::RunsPerLineVectorType
private

Definition at line 145 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
typedef itk::Vector<double, 2> otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::SpacingType

Definition at line 72 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
typedef PolygonType::VertexType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::VertexType

Definition at line 70 of file otbLabelObjectToPolygonFunctor.h.

Member Enumeration Documentation

template<class TLabelObject, class TPolygon>
enum otb::Functor::LabelObjectToPolygonFunctor::PositionFlagType
private
Enumerator
LEFT_END 
RIGHT_END 

Definition at line 150 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
enum otb::Functor::LabelObjectToPolygonFunctor::StateType
private

Internal enums.

Enumerator
UP_LEFT 
UP_RIGHT 
DOWN_LEFT 
DOWN_RIGHT 

Definition at line 149 of file otbLabelObjectToPolygonFunctor.h.

Constructor & Destructor Documentation

template<class TLabelObject, class TPolygon>
otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::LabelObjectToPolygonFunctor ( )
inline
template<class TLabelObject, class TPolygon>
virtual otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::~LabelObjectToPolygonFunctor ( )
inlinevirtual

Destructor

Definition at line 140 of file otbLabelObjectToPolygonFunctor.h.

Member Function Documentation

template<class TLabelObject, class TPolygon>
const char* otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::GetNameOfClass ( )
inline

Get name of class.

Definition at line 82 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
const PointType& otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::GetOrigin ( ) const
inline
template<class TLabelObject, class TPolygon>
const SpacingType& otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::GetSpacing ( ) const
inline
template<class TLabelObject, class TPolygon>
const RegionIndexType& otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::GetStartIndex ( ) const
inline
template<class TLabelObject , class TPolygon >
LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::VertexType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::IndexToPoint ( const VertexType index) const
private

Definition at line 624 of file otbLabelObjectToPolygonFunctor.txx.

template<class TLabelObject , class TPolygon >
bool otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::IsRunIndexValid ( const IndexType index) const
inlineprivate

Check if the given run index (index in line, line) is valid.

Definition at line 328 of file otbLabelObjectToPolygonFunctor.txx.

template<class TLabelObject , class TPolygon >
LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::IndexType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::LeftEnd ( const IndexType runIndex) const
inlineprivate

Return the left-end of the run.

Definition at line 383 of file otbLabelObjectToPolygonFunctor.txx.

template<class TLabelObject , class TPolygon >
LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::IndexType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::LeftMostRightEndInside ( unsigned int  line,
const IndexType point,
const IndexType run 
) const
inlineprivate

Return the left-most run whose right end lies within the range of the given run.

Index is a the left of point

right end is inside run range

Definition at line 440 of file otbLabelObjectToPolygonFunctor.txx.

template<class TLabelObject , class TPolygon >
bool otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::LexicographicalLineCompare ( const LineType l1,
const LineType l2 
)
staticprivate

Compare two line in the lexicographical order.

Definition at line 33 of file otbLabelObjectToPolygonFunctor.txx.

template<class TLabelObject , class TPolygon >
LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::PolygonType * otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::operator() ( LabelObjectType labelObject)
inline
Parameters
labelObjectthe label object to vectorize
Returns
The vectorized label object as a polygon.

Definition at line 46 of file otbLabelObjectToPolygonFunctor.txx.

References otb::ogr::Within().

template<class TLabelObject , class TPolygon >
LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::IndexType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::RightEnd ( const IndexType runIndex) const
inlineprivate

Return the right-end of the run.

Definition at line 392 of file otbLabelObjectToPolygonFunctor.txx.

template<class TLabelObject , class TPolygon >
LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::IndexType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::RightMostLeftEndInside ( unsigned int  line,
const IndexType point,
const IndexType run 
) const
inlineprivate

Return the right-most run whose left end lies within the range of the given run.

Index is a the right of point

Index is inside run range

Definition at line 403 of file otbLabelObjectToPolygonFunctor.txx.

template<class TLabelObject, class TPolygon>
void otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::SetOrigin ( const PointType origin)
inline
template<class TLabelObject, class TPolygon>
void otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::SetSpacing ( const SpacingType spacing)
inline
template<class TLabelObject, class TPolygon>
void otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::SetStartIndex ( const RegionIndexType index)
inline
template<class TLabelObject , class TPolygon >
void otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::WalkLeft ( unsigned int  line,
const IndexType startPoint,
const IndexType endPoint,
PolygonType polygon,
const StateType  state 
)
inlineprivate

Walk left to update the finite states machine.

Definition at line 477 of file otbLabelObjectToPolygonFunctor.txx.

template<class TLabelObject , class TPolygon >
void otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::WalkRight ( unsigned int  line,
const IndexType startPoint,
const IndexType endPoint,
PolygonType polygon,
const StateType  state 
)
inlineprivate

Walk right to update the finite states machine.

Definition at line 552 of file otbLabelObjectToPolygonFunctor.txx.

template<class TLabelObject , class TPolygon >
LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::IndexType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::Within ( const IndexType point,
unsigned int  line 
) const
inlineprivate

Check if the point lies within the range of the line.

Definition at line 337 of file otbLabelObjectToPolygonFunctor.txx.

Member Data Documentation

template<class TLabelObject, class TPolygon>
int otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::m_CurrentLine
private

The current line for vectorization.

Definition at line 214 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
IndexType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::m_CurrentPoint
private
template<class TLabelObject, class TPolygon>
IndexType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::m_CurrentRun
private
template<class TLabelObject, class TPolygon>
StateType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::m_CurrentState
private

The current state.

Definition at line 200 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
RunsPerLineVectorType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::m_InternalDataSet
private

Definition at line 197 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
unsigned int otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::m_LineOffset
private

The line offset from start of the region.

Definition at line 220 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
PointType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::m_Origin
private
template<class TLabelObject, class TPolygon>
PolygonPointerType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::m_Polygon
private

Definition at line 194 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
PositionFlagType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::m_PositionFlag
private

The position flag.

Definition at line 202 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
IndexVectorType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::m_Solution
private

The vector of vectorized boundaries.

Definition at line 217 of file otbLabelObjectToPolygonFunctor.h.

template<class TLabelObject, class TPolygon>
SpacingType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::m_Spacing
private
template<class TLabelObject, class TPolygon>
RegionIndexType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::m_StartIndex
private
template<class TLabelObject, class TPolygon>
IndexType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::m_StartingPoint
private

The documentation for this class was generated from the following files:

Generated at Sat Aug 30 2014 19:25:08 for Orfeo Toolbox with doxygen 1.8.3.1