OTB  9.0.0
Orfeo Toolbox
Public Types | Public Member Functions | List of all members
otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon > Class Template Reference

#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

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)
 
enum  StateType {
  UP_LEFT,
  UP_RIGHT,
  DOWN_LEFT,
  DOWN_RIGHT
}
 
enum  PositionFlagType {
  LEFT_END,
  RIGHT_END
}
 
typedef std::vector< LineTypeRunsPerLineType
 
typedef std::vector< RunsPerLineTypeRunsPerLineVectorType
 
typedef std::vector< IndexTypeIndexVectorType
 
PolygonPointerType m_Polygon
 
RunsPerLineVectorType m_InternalDataSet
 
StateType m_CurrentState
 
PositionFlagType m_PositionFlag
 
IndexType m_StartingPoint
 
IndexType m_CurrentPoint
 
IndexType m_CurrentRun
 
int m_CurrentLine
 
IndexVectorType m_Solution
 
unsigned int m_LineOffset
 
RegionIndexType m_StartIndex
 
PointType m_Origin
 
SpacingType m_Spacing
 
 LabelObjectToPolygonFunctor ()
 
virtual ~LabelObjectToPolygonFunctor ()
 
static bool LexicographicalLineCompare (const LineType &l1, const LineType &l2)
 
bool IsRunIndexValid (const IndexType &index) const
 
IndexType Within (const IndexType &point, unsigned int line) const
 
IndexType LeftEnd (const IndexType &runIndex) const
 
IndexType RightEnd (const IndexType &runIndex) const
 
IndexType RightMostLeftEndInside (unsigned int line, const IndexType &point, const IndexType &run) const
 
IndexType LeftMostRightEndInside (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)
 
void WalkRight (unsigned int line, const IndexType &startPoint, const IndexType &endPoint, PolygonType *polygon, const StateType state)
 
VertexType IndexToPoint (const VertexType &index) const
 

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 62 of file otbLabelObjectToPolygonFunctor.h.

Member Typedef Documentation

◆ ConstLineIteratorType

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

Const iterator over LabelObject lines

Definition at line 69 of file otbLabelObjectToPolygonFunctor.h.

◆ IndexType

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

Definition at line 72 of file otbLabelObjectToPolygonFunctor.h.

◆ IndexVectorType

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

Internal enums.

Definition at line 160 of file otbLabelObjectToPolygonFunctor.h.

◆ LabelObjectType

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

Template parameters typedefs

Definition at line 66 of file otbLabelObjectToPolygonFunctor.h.

◆ LineType

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

Definition at line 71 of file otbLabelObjectToPolygonFunctor.h.

◆ PointType

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

Definition at line 76 of file otbLabelObjectToPolygonFunctor.h.

◆ PolygonPointerType

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

Definition at line 74 of file otbLabelObjectToPolygonFunctor.h.

◆ PolygonType

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

Definition at line 73 of file otbLabelObjectToPolygonFunctor.h.

◆ RegionIndexType

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

Definition at line 78 of file otbLabelObjectToPolygonFunctor.h.

◆ RunsPerLineType

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

Internal structures.

Definition at line 158 of file otbLabelObjectToPolygonFunctor.h.

◆ RunsPerLineVectorType

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

Internal enums.

Definition at line 159 of file otbLabelObjectToPolygonFunctor.h.

◆ SpacingType

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

Definition at line 77 of file otbLabelObjectToPolygonFunctor.h.

◆ VertexType

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

Definition at line 75 of file otbLabelObjectToPolygonFunctor.h.

Member Enumeration Documentation

◆ PositionFlagType

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

Internal enums.

Enumerator
LEFT_END 
RIGHT_END 

Definition at line 170 of file otbLabelObjectToPolygonFunctor.h.

◆ StateType

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 163 of file otbLabelObjectToPolygonFunctor.h.

Constructor & Destructor Documentation

◆ LabelObjectToPolygonFunctor()

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

◆ ~LabelObjectToPolygonFunctor()

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

Destructor

Definition at line 152 of file otbLabelObjectToPolygonFunctor.h.

Member Function Documentation

◆ GetNameOfClass()

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

Get name of class.

Definition at line 87 of file otbLabelObjectToPolygonFunctor.h.

◆ GetOrigin()

template<class TLabelObject , class TPolygon >
const PointType& otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::GetOrigin ( ) const
inline

◆ GetSpacing()

template<class TLabelObject , class TPolygon >
const SpacingType& otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::GetSpacing ( ) const
inline

◆ GetStartIndex()

template<class TLabelObject , class TPolygon >
const RegionIndexType& otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::GetStartIndex ( ) const
inline

◆ IndexToPoint()

template<class TLabelObject , class TPolygon >
LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::VertexType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::IndexToPoint ( const VertexType index) const
private

Internal enums.

Definition at line 579 of file otbLabelObjectToPolygonFunctor.hxx.

◆ IsRunIndexValid()

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 309 of file otbLabelObjectToPolygonFunctor.hxx.

◆ LeftEnd()

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 359 of file otbLabelObjectToPolygonFunctor.hxx.

◆ LeftMostRightEndInside()

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 409 of file otbLabelObjectToPolygonFunctor.hxx.

◆ LexicographicalLineCompare()

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.hxx.

◆ operator()()

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 42 of file otbLabelObjectToPolygonFunctor.hxx.

References otb::ogr::Within().

◆ RightEnd()

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 366 of file otbLabelObjectToPolygonFunctor.hxx.

◆ RightMostLeftEndInside()

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 375 of file otbLabelObjectToPolygonFunctor.hxx.

◆ SetOrigin()

template<class TLabelObject , class TPolygon >
void otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::SetOrigin ( const PointType origin)
inline

◆ SetSpacing()

template<class TLabelObject , class TPolygon >
void otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::SetSpacing ( const SpacingType spacing)
inline

◆ SetStartIndex()

template<class TLabelObject , class TPolygon >
void otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::SetStartIndex ( const RegionIndexType index)
inline

◆ WalkLeft()

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 443 of file otbLabelObjectToPolygonFunctor.hxx.

◆ WalkRight()

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 512 of file otbLabelObjectToPolygonFunctor.hxx.

◆ Within()

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 316 of file otbLabelObjectToPolygonFunctor.hxx.

Member Data Documentation

◆ m_CurrentLine

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

The current line for vectorization.

Definition at line 230 of file otbLabelObjectToPolygonFunctor.h.

◆ m_CurrentPoint

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

◆ m_CurrentRun

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

◆ m_CurrentState

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

The current state.

Definition at line 216 of file otbLabelObjectToPolygonFunctor.h.

◆ m_InternalDataSet

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

Internal enums.

Definition at line 213 of file otbLabelObjectToPolygonFunctor.h.

◆ m_LineOffset

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 236 of file otbLabelObjectToPolygonFunctor.h.

◆ m_Origin

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

◆ m_Polygon

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

Internal enums.

Definition at line 210 of file otbLabelObjectToPolygonFunctor.h.

◆ m_PositionFlag

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

The position flag.

Definition at line 218 of file otbLabelObjectToPolygonFunctor.h.

◆ m_Solution

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

The vector of vectorized boundaries.

Definition at line 233 of file otbLabelObjectToPolygonFunctor.h.

◆ m_Spacing

template<class TLabelObject , class TPolygon >
SpacingType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::m_Spacing
private

◆ m_StartIndex

template<class TLabelObject , class TPolygon >
RegionIndexType otb::Functor::LabelObjectToPolygonFunctor< TLabelObject, TPolygon >::m_StartIndex
private

◆ m_StartingPoint

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: