Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
icl::math::MatrixSubRectIterator< Type > Class Template Reference

Iterator class used to iterate through a sub rect of 2D data. More...

#include <MatrixSubRectIterator.h>

Inheritance diagram for icl::math::MatrixSubRectIterator< Type >:
icl::core::ImgIterator< Type >

List of all members.

Public Member Functions

 MatrixSubRectIterator ()
 Default Constructor.
 MatrixSubRectIterator (Type *ptData, int matrixWidth, int subRectX, int subRectY, int subRectWidth, int subRectHeight)
MatrixSubRectIteratoroperator= (const MatrixSubRectIterator &other)
const MatrixSubRectIteratoroperator= (const MatrixSubRectIterator &other) const
const Type & operator* () const
 retuns a reference of the current pixel value (const)
Type & operator* ()
 retuns a reference of the current pixel value
MatrixSubRectIteratoroperator++ ()
 moves to the next iterator position (Prefix ++it)
const MatrixSubRectIteratoroperator++ () const
 const version of pre increment operator
MatrixSubRectIterator operator++ (int)
const MatrixSubRectIterator operator++ (int) const
 const version of post increment operator
bool inSubRect () const
 to check if iterator is still inside the ROI
bool operator!= (const MatrixSubRectIterator< Type > &it) const
 compare two iterators
bool operator== (const MatrixSubRectIterator< Type > &it) const
 compare two iterators
bool operator< (const MatrixSubRectIterator< Type > &it) const
 compare two iterators
bool operator> (const MatrixSubRectIterator< Type > &it) const
 compare two iterators
bool operator<= (const MatrixSubRectIterator< Type > &it) const
 compare two iterators
bool operator>= (const MatrixSubRectIterator< Type > &it) const
 compare two iterators
int getSubRectWidth () const
 returns the length of each row processed by this iterator
int getSubRectHeight () const
void incRow (int numLines=1) const
 move the pixel vertically forward
int x ()
 returns the current x position of the iterator (wrt matrix origin);
int y ()
 returns the current y position of the iterator (wrt matrix origin)

Static Public Member Functions

static const
MatrixSubRectIterator< Type > 
create_end_iterator (const Type *dataOrigin, int matrixWidth, int subRectX, int subRectY, int subRectWidth, int subRectHeight)

Protected Member Functions

void init ()

Protected Attributes

int m_matrixWidth
 corresponding matrix width
int m_subRectWidth
 sub rect size of the iterator
int m_subRectHeight
int m_lineStep
 result of m_matrixWidth - m_subRectWidth
Type * m_dataOrigin
 pointer to the upper matrix data origin (upper left element)
Type * m_dataCurr
 pointer to the current data element
Type * m_dataEnd
 pointer to the first element behind the subrect
Type * m_currLineEnd
 pointer to the first invalid element of the current line

Detailed Description

template<typename Type>
class icl::math::MatrixSubRectIterator< Type >

Iterator class used to iterate through a sub rect of 2D data.

The MatrixSubRectIterator is a utility to iterate line by line through all elements of a sub-rectangle of a row-major-order aligned data block. The following ASCII image shows an images ROI.

      1st element
        |
    ....|.................... 
    ....+->Xoooooooo......... ---
    .......ooooooooo.........  |
    .......ooooooooo......... Rect-Height
    .......ooooooooo.........  |
    .......ooooooooo......... ---
    ......................... 
           |-RectW-|
    |---------MatrixW-------|
    

const-ness

Please note that the const-ness of an MatrixSubRectIterator instance does not say anything about the sturcture itselft. Hence also const MatrixSubRectIterators can be 'moved' using ++-operators or incRow() method.
Instead, const-ness relates to the underlying data block is referenced by the iterator instance.


Constructor & Destructor Documentation

template<typename Type>
icl::math::MatrixSubRectIterator< Type >::MatrixSubRectIterator ( ) [inline]

Default Constructor.

Creates an MatrixSubRectIterator object

template<typename Type>
icl::math::MatrixSubRectIterator< Type >::MatrixSubRectIterator ( Type *  ptData,
int  matrixWidth,
int  subRectX,
int  subRectY,
int  subRectWidth,
int  subRectHeight 
) [inline]

2nd Constructor creates an MatrixSubRectIterator object with Type "Type"

Parameters:
ptDatapointer to the corresponding channel data
matrixWidthwidth of the corresponding image
subRectXROI upper-left X-coordinate
subRectYROI upper-left Y-coordinate
subRectWidthROI width
subRectHeightROI height

Member Function Documentation

template<typename Type>
static const MatrixSubRectIterator<Type> icl::math::MatrixSubRectIterator< Type >::create_end_iterator ( const Type *  dataOrigin,
int  matrixWidth,
int  subRectX,
int  subRectY,
int  subRectWidth,
int  subRectHeight 
) [inline, static]
template<typename Type>
int icl::math::MatrixSubRectIterator< Type >::getSubRectHeight ( ) const [inline]
template<typename Type>
int icl::math::MatrixSubRectIterator< Type >::getSubRectWidth ( ) const [inline]

returns the length of each row processed by this iterator

Returns:
row length
template<typename Type>
void icl::math::MatrixSubRectIterator< Type >::incRow ( int  numLines = 1) const [inline]

move the pixel vertically forward

current x value is hold, the current y-value is incremented by iLines

Parameters:
numLinesamount of lines to jump over
template<typename Type>
void icl::math::MatrixSubRectIterator< Type >::init ( ) [inline, protected]
template<typename Type>
bool icl::math::MatrixSubRectIterator< Type >::inSubRect ( ) const [inline]

to check if iterator is still inside the ROI

This function was replaced by STL-like begin(), end() logic Although in some cases it might be quite useful, so we renamed it rather than deleting it

See also:
operator++
template<typename Type>
bool icl::math::MatrixSubRectIterator< Type >::operator!= ( const MatrixSubRectIterator< Type > &  it) const [inline]

compare two iterators

template<typename Type>
const Type& icl::math::MatrixSubRectIterator< Type >::operator* ( ) const [inline]

retuns a reference of the current pixel value (const)

changes on *p (p is of type MatrixSubRectIterator) will effect the image data

template<typename Type>
Type& icl::math::MatrixSubRectIterator< Type >::operator* ( ) [inline]

retuns a reference of the current pixel value

changes on *p (p is of type MatrixSubRectIterator) will effect the image data

template<typename Type>
MatrixSubRectIterator& icl::math::MatrixSubRectIterator< Type >::operator++ ( ) [inline]

moves to the next iterator position (Prefix ++it)

The image ROI will be scanned line by line beginning on the bottom left iterator.

             +-- begin here (index 0)
             |  
      .......|.................
      .......V.................
      .......012+-->+8<---------- first line wrap after 
      .......9++++++++.........   this pixel (index 8)
      .......+++++++++.........
      .......+++++++++.........
      .......++++++++X<---------- last valid pixel
      ....+->I.................
          |  
      'I' is the first invalid iterator
      (p.inRegion() will become false)
         

In most cases The ++ operator will just increase the current x position and update the reference to the current pixel data. If the end of a line is reached, then the position is set to the beginning of the next line.

template<typename Type>
const MatrixSubRectIterator& icl::math::MatrixSubRectIterator< Type >::operator++ ( ) const [inline]

const version of pre increment operator

template<typename Type>
MatrixSubRectIterator icl::math::MatrixSubRectIterator< Type >::operator++ ( int  ) [inline]

postfix operator++ (used -O3 to avoid loss of performace when using the "it++"-operator In most cases the "++it"-operator will ensure best performace.

template<typename Type>
const MatrixSubRectIterator icl::math::MatrixSubRectIterator< Type >::operator++ ( int  ) const [inline]

const version of post increment operator

template<typename Type>
bool icl::math::MatrixSubRectIterator< Type >::operator< ( const MatrixSubRectIterator< Type > &  it) const [inline]

compare two iterators

template<typename Type>
bool icl::math::MatrixSubRectIterator< Type >::operator<= ( const MatrixSubRectIterator< Type > &  it) const [inline]

compare two iterators

template<typename Type>
MatrixSubRectIterator& icl::math::MatrixSubRectIterator< Type >::operator= ( const MatrixSubRectIterator< Type > &  other) [inline]

Reimplemented in icl::core::ImgIterator< Type >.

template<typename Type>
const MatrixSubRectIterator& icl::math::MatrixSubRectIterator< Type >::operator= ( const MatrixSubRectIterator< Type > &  other) const [inline]

Reimplemented in icl::core::ImgIterator< Type >.

template<typename Type>
bool icl::math::MatrixSubRectIterator< Type >::operator== ( const MatrixSubRectIterator< Type > &  it) const [inline]

compare two iterators

template<typename Type>
bool icl::math::MatrixSubRectIterator< Type >::operator> ( const MatrixSubRectIterator< Type > &  it) const [inline]

compare two iterators

template<typename Type>
bool icl::math::MatrixSubRectIterator< Type >::operator>= ( const MatrixSubRectIterator< Type > &  it) const [inline]

compare two iterators

template<typename Type>
int icl::math::MatrixSubRectIterator< Type >::x ( ) [inline]

returns the current x position of the iterator (wrt matrix origin);

Returns:
current x position
template<typename Type>
int icl::math::MatrixSubRectIterator< Type >::y ( ) [inline]

returns the current y position of the iterator (wrt matrix origin)

Returns:
current y position

Member Data Documentation

template<typename Type>
Type* icl::math::MatrixSubRectIterator< Type >::m_currLineEnd [mutable, protected]

pointer to the first invalid element of the current line

template<typename Type>
Type* icl::math::MatrixSubRectIterator< Type >::m_dataCurr [mutable, protected]

pointer to the current data element

template<typename Type>
Type* icl::math::MatrixSubRectIterator< Type >::m_dataEnd [protected]

pointer to the first element behind the subrect

template<typename Type>
Type* icl::math::MatrixSubRectIterator< Type >::m_dataOrigin [protected]

pointer to the upper matrix data origin (upper left element)

template<typename Type>
int icl::math::MatrixSubRectIterator< Type >::m_lineStep [protected]

result of m_matrixWidth - m_subRectWidth

template<typename Type>
int icl::math::MatrixSubRectIterator< Type >::m_matrixWidth [protected]

corresponding matrix width

template<typename Type>
int icl::math::MatrixSubRectIterator< Type >::m_subRectHeight [protected]
template<typename Type>
int icl::math::MatrixSubRectIterator< Type >::m_subRectWidth [protected]

sub rect size of the iterator


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines