dlr::numeric::Stencil2D< Type, Size > Class Template Reference

WARNING: This class is still under development and quite unstable. More...

#include <stencil2D.h>

Collaboration diagram for dlr::numeric::Stencil2D< Type, Size >:
[legend]

List of all members.

Public Member Functions

 Stencil2D ()
 The default constructor creates a blank Stencil2D instance.
 Stencil2D (size_t rows, size_t columns)
 This constructor creates a Stencil2D instance which accesses each element of a (rows x columns) pattern in raster order from top left to bottom right.
 Stencil2D (const Array2D< bool > &pattern)
 This constructor creates a Stencil2D instance which accesses a pattern of elements that has the same shape as its argument, but includes only those elements for which the corresponding element of argument pattern is true.
 Stencil2D (const std::vector< Index2D > &pattern)
 This constructor is like Stencil2D(const Array2D<bool>&), except that the elements which make up the stencil are specified explicitly by passing in a vector of their coordinates with respect to the pattern origin (top left corner).
 ~Stencil2D ()
 Destructor.
void advance ()
 This member function moves the stencil one column to the right, but does not check to see whether such a move is valid.
StencilIterator< Type, Size > begin ()
 This member functio refers an iterator pointing to the first element in the stencil sequence.
StencilIterator< Type, Size > end ()
 This member functio refers an iterator pointing one element past the final element of the stencil sequence.
Type & getReference (size_t elementNumber)
 This member function returns a reference to a single stencil element.
Type getValue (size_t elementNumber) const
 This member function returns the value of a single stencil element.
void goTo (size_t index)
 This member function moves the upper left corner of the stencil to the specified location in the target Array2D instance.
void goTo (size_t row, size_t column)
 This member function moves the upper left corner of the stencil to the specified location in the target Array2D instance.
void setPattern (const Array2D< bool > &pattern)
 This member function sets the stencil pattern as described in the documentation of Stencil2D<Type>::Stencil2D(const Array2D<bool>&).
template<class Type2 >
void setTarget (const Array2D< Type2 > &target)
 This member function sets the Array2D instance to which the stencil will be applied.
template<class Type2 >
void setTarget (Array2D< Type2 > &target)
 This member function sets the Array2D instance to which the stencil will be applied.
void checkBounds (size_t elementNumber) const

Public Attributes

Type * m_basePtr
size_t m_rows
size_t m_columns
int m_targetSize
size_t m_numberOfElements
Type * m_ptr
int m_offsetArray [Size]
int m_incrementArray [Size]
Index2D m_patternArray [Size]


Detailed Description

template<class Type, int Size>
class dlr::numeric::Stencil2D< Type, Size >

WARNING: This class is still under development and quite unstable.

Use at your own risk.

This class makes it easy to access Array2D elements in a repeating pattern which moves around the array. It is useful for implementing things like 2D convolution or Bayer filtering.

Template argument Type specifies the element type of the Array2D instance.

Template argument Size specifies a maximum number of elements in the stencil pattern. For example, you must set Size greater than or equal to the number of elements in your convolution kernel or Bayer filtering pattern. Setting Size too big simply increases memory usage. Setting Size too small will very likely cause a segfault.

For an example of how to use Stencil2D, please refer to dlrNumeric/convolve2D.h.

Definition at line 201 of file stencil2D.h.


Constructor & Destructor Documentation

template<class Type , int Size>
dlr::numeric::Stencil2D< Type, Size >::Stencil2D (  )  [inline]

The default constructor creates a blank Stencil2D instance.

Definition at line 433 of file stencil2D.h.

template<class Type , int Size>
dlr::numeric::Stencil2D< Type, Size >::Stencil2D ( size_t  rows,
size_t  columns 
) [inline]

This constructor creates a Stencil2D instance which accesses each element of a (rows x columns) pattern in raster order from top left to bottom right.

Parameters:
rows This argument specifies the height of the stencil.
columns This argument specifies the width of the stencil.

Definition at line 454 of file stencil2D.h.

template<class Type , int Size>
dlr::numeric::Stencil2D< Type, Size >::Stencil2D ( const Array2D< bool > &  pattern  )  [inline]

This constructor creates a Stencil2D instance which accesses a pattern of elements that has the same shape as its argument, but includes only those elements for which the corresponding element of argument pattern is true.

Elements wil be accessed in raster order from top left to bottom right.

Parameters:
pattern This argument is a 2D array of bools indicating which elements should be accessed as part of the stencil pattern.

Definition at line 496 of file stencil2D.h.

References dlr::numeric::Stencil2D< Type, Size >::setPattern().

template<class Type , int Size>
dlr::numeric::Stencil2D< Type, Size >::Stencil2D ( const std::vector< Index2D > &  pattern  )  [inline]

This constructor is like Stencil2D(const Array2D<bool>&), except that the elements which make up the stencil are specified explicitly by passing in a vector of their coordinates with respect to the pattern origin (top left corner).

Column numbers increase from left to right, and row numbers increase from top to bottom.

Parameters:
pattern This argument is a vector of element coordinates from which to construct the stencil.

Definition at line 513 of file stencil2D.h.

template<class Type , int Size>
dlr::numeric::Stencil2D< Type, Size >::~Stencil2D (  )  [inline]

Destructor.

Definition at line 253 of file stencil2D.h.


Member Function Documentation

template<class Type , int Size>
void dlr::numeric::Stencil2D< Type, Size >::advance (  )  [inline]

This member function moves the stencil one column to the right, but does not check to see whether such a move is valid.

You can easily advance off right edge of the array if you're not careful.

Definition at line 263 of file stencil2D.h.

template<class Type , int Size>
StencilIterator<Type, Size> dlr::numeric::Stencil2D< Type, Size >::begin (  )  [inline]

This member functio refers an iterator pointing to the first element in the stencil sequence.

In order for the result to be valid, member function setTarget() must have been called.

Returns:
The return value is a Stencil2DIterator instance pointing to the begining of the stencil sequence.

Definition at line 275 of file stencil2D.h.

template<class Type , int Size>
StencilIterator<Type, Size> dlr::numeric::Stencil2D< Type, Size >::end (  )  [inline]

This member functio refers an iterator pointing one element past the final element of the stencil sequence.

In order for the result to be valid, member function setTarget() must have been called.

Returns:
The return value is an "end" iterator to use along with member function begin() in stl-style algorithms.

Definition at line 289 of file stencil2D.h.

template<class Type , int Size>
Type & dlr::numeric::Stencil2D< Type, Size >::getReference ( size_t  elementNumber  )  [inline]

This member function returns a reference to a single stencil element.

In order for the result to be valid, member function setTarget() must have been called.

Parameters:
elementNumber This argument specifies which element is to be returned.
Returns:
The return value is a reference to the requested element.

Definition at line 543 of file stencil2D.h.

template<class Type , int Size>
Type dlr::numeric::Stencil2D< Type, Size >::getValue ( size_t  elementNumber  )  const [inline]

This member function returns the value of a single stencil element.

In order for the result to be valid, member function setTarget() must have been called.

Parameters:
elementNumber This argument specifies which element is to be returned.
Returns:
The value of the requested element is returned.

Definition at line 553 of file stencil2D.h.

template<class Type , int Size>
void dlr::numeric::Stencil2D< Type, Size >::goTo ( size_t  row,
size_t  column 
) [inline]

This member function moves the upper left corner of the stencil to the specified location in the target Array2D instance.

Parameters:
row This argument specifies row coordinate of the requested location.
column This argument specifies column coordinate of the requested location.

Definition at line 572 of file stencil2D.h.

template<class Type , int Size>
void dlr::numeric::Stencil2D< Type, Size >::goTo ( size_t  index  )  [inline]

This member function moves the upper left corner of the stencil to the specified location in the target Array2D instance.

Parameters:
index This argument specifies the requested location as described for Array2D::operator()(size_t).

Definition at line 563 of file stencil2D.h.

template<class Type , int Size>
void dlr::numeric::Stencil2D< Type, Size >::setPattern ( const Array2D< bool > &  pattern  )  [inline]

This member function sets the stencil pattern as described in the documentation of Stencil2D<Type>::Stencil2D(const Array2D<bool>&).

Parameters:
pattern This argument is a 2D array of bools indicating which elements should be accessed as part of the stencil pattern.

Definition at line 581 of file stencil2D.h.

References dlr::numeric::Array2D< Type >::columns(), and dlr::numeric::Array2D< Type >::rows().

Referenced by dlr::numeric::Stencil2D< Type, Size >::Stencil2D().

template<class Type , int Size>
template<class Type2 >
void dlr::numeric::Stencil2D< Type, Size >::setTarget ( Array2D< Type2 > &  target  )  [inline]

This member function sets the Array2D instance to which the stencil will be applied.

Parameters:
target This argument is the Array2D instance whose elements should be accessed.

Definition at line 645 of file stencil2D.h.

References dlr::numeric::Array2D< Type >::columns(), dlr::numeric::Array2D< Type >::data(), dlr::numeric::Index2D::getColumn(), dlr::numeric::Index2D::getRow(), dlr::numeric::Array2D< Type >::rows(), and dlr::numeric::Array2D< Type >::size().

template<class Type , int Size>
template<class Type2 >
void dlr::numeric::Stencil2D< Type, Size >::setTarget ( const Array2D< Type2 > &  target  )  [inline]

This member function sets the Array2D instance to which the stencil will be applied.

Parameters:
target This argument is the Array2D instance whose elements should be accessed.

Definition at line 618 of file stencil2D.h.

References dlr::numeric::Array2D< Type >::columns(), dlr::numeric::Array2D< Type >::data(), dlr::numeric::Index2D::getColumn(), dlr::numeric::Index2D::getRow(), dlr::numeric::Array2D< Type >::rows(), and dlr::numeric::Array2D< Type >::size().


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

Generated on Wed Nov 25 00:42:50 2009 for dlrUtilities Utility Library by  doxygen 1.5.8