[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

ImageIteratorBase< IMAGEITERATOR, PIXELTYPE, REFERENCE, POINTER, StridedOrUnstrided > Class Template Reference

Base class for 2D random access iterators. More...

`#include <vigra/imageiterator.hxx>`

## Public Types

typedef ColumnIteratorSelector::res | column_iterator
typedef Diff2D | difference_type
typedef REFERENCE | index_reference
typedef image_traverser_tag | iterator_category
typedef vigra::detail::DirectionSelector< StridedOrUnstrided >::template type< pointer > | MoveX
typedef vigra::detail::DirectionSelector< StridedArrayTag >::template type< std::ptrdiff_t > | MoveY
typedef PIXELTYPE | PixelType
typedef POINTER | pointer
typedef REFERENCE | reference
typedef RowIteratorSelector::res | row_iterator
typedef PIXELTYPE | value_type

## Public Member Functions

Comparison of Iterators
bool | operator== (ImageIteratorBase const &rhs) const
bool | operator!= (ImageIteratorBase const &rhs) const
difference_type | operator- (ImageIteratorBase const &rhs) const
Random navigation
IMAGEITERATOR & | operator+= (difference_type const &s)
IMAGEITERATOR & | operator-= (difference_type const &s)
IMAGEITERATOR | operator+ (difference_type const &s) const
IMAGEITERATOR | operator- (difference_type const &s) const

## Specify coordinate to operate on

MoveX | x
MoveY | y
| ImageIteratorBase (pointer base, std::ptrdiff_t ystride)
| ImageIteratorBase (pointer base, std::ptrdiff_t xstride, std::ptrdiff_t ystride)
| ImageIteratorBase (ImageIteratorBase const &rhs)
| ImageIteratorBase ()
ImageIteratorBase & | operator= (ImageIteratorBase const &rhs)

## Access the Pixels

reference | operator* () const
pointer | operator-> () const
index_reference | operator[] (Diff2D const &d) const
index_reference | operator() (std::ptrdiff_t dx, std::ptrdiff_t dy) const
pointer | operator[] (std::ptrdiff_t dy) const

## Detailed Description

template<class IMAGEITERATOR, class PIXELTYPE, class REFERENCE, class POINTER, class StridedOrUnstrided = UnstridedArrayTag>
class vigra::ImageIteratorBase< IMAGEITERATOR, PIXELTYPE, REFERENCE, POINTER, StridedOrUnstrided >

Base class for 2D random access iterators.

This class contains the navigational part of the iterator. It is usually not constructed directly, but via some derived class such as ImageIterator or StridedImageIterator.

#include <vigra/imageiterator.hxx>
Namespace: vigra

The usage examples assume that you constructed two iterators like this:

vigra::ImageIterator<SomePixelType> iterator(base, width);
vigra::ImageIterator<SomePixelType> iterator1(base, width);
vigra::RGBValue
Class for a single RGB value.
Definition rgbvalue.hxx:128

See the paper: U. Koethe: Reusable Algorithms in Image Processing for a discussion of the concepts behind ImageIterators.

## Member Typedef Documentation

## ◆ value_type

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

typedef PIXELTYPE value_type

The underlying image's pixel type.

## ◆ PixelType

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

typedef PIXELTYPE PixelType

deprecated, use `value_type` instead.

## ◆ reference

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

typedef REFERENCE reference

the iterator's reference type (return type of `*iter`)

## ◆ index_reference

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

typedef REFERENCE index_reference

the iterator's index reference type (return type of `iter[diff]`)

## ◆ pointer

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

typedef POINTER pointer

the iterator's pointer type (return type of `iter.operator->()`)

## ◆ difference_type

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

typedef Diff2D difference_type

the iterator's difference type (argument type of `iter[diff]`)

## ◆ iterator_category

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

typedef image_traverser_tag iterator_category

the iterator tag (image traverser)

## ◆ row_iterator

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

typedef RowIteratorSelector::res row_iterator

The associated row iterator.

## ◆ column_iterator

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

typedef ColumnIteratorSelector::res column_iterator

The associated column iterator.

## ◆ MoveX

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

typedef vigra::detail::DirectionSelector<StridedOrUnstrided>::template type<pointer> MoveX

Let operations act in X direction

## ◆ MoveY

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

typedef vigra::detail::DirectionSelector<StridedArrayTag>::template type<std::ptrdiff_t> MoveY

Let operations act in Y direction

## Constructor & Destructor Documentation

## ◆ ImageIteratorBase() [1/4]

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

ImageIteratorBase | ( | pointer | base,
|  | std::ptrdiff_t | ystride
| ) |  |

protected

Construct from raw memory with a vertical stride of `ystride`. `ystride` must equal the physical image width (row length), even if the iterator will only be used for a sub image. This constructor must only be called for unstrided iterators (`StridedOrUnstrided == UnstridedArrayTag`)

## ◆ ImageIteratorBase() [2/4]

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

ImageIteratorBase | ( | pointer | base,
|  | std::ptrdiff_t | xstride,
|  | std::ptrdiff_t | ystride
| ) |  |

protected

Construct from raw memory with a horizontal stride of `xstride` and a vertical stride of `ystride`. This constructor may be used for iterators that shall skip pixels. Thus, it must only be called for strided iterators (`StridedOrUnstrided == StridedArrayTag`)

## ◆ ImageIteratorBase() [3/4]

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

ImageIteratorBase | ( | ImageIteratorBase< IMAGEITERATOR, PIXELTYPE, REFERENCE, POINTER, StridedOrUnstrided > const & | rhs | ) |

protected

Copy constructor

## ◆ ImageIteratorBase() [4/4]

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

ImageIteratorBase | ( |  | ) |

protected

Default constructor

## Member Function Documentation

## ◆ operator==()

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

bool operator== | ( | ImageIteratorBase< IMAGEITERATOR, PIXELTYPE, REFERENCE, POINTER, StridedOrUnstrided > const & | rhs | ) | const

usage: `iterator == iterator1`

## ◆ operator!=()

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

bool operator!= | ( | ImageIteratorBase< IMAGEITERATOR, PIXELTYPE, REFERENCE, POINTER, StridedOrUnstrided > const & | rhs | ) | const

usage: `iterator != iterator1`

## ◆ operator-() [1/2]

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

difference_type operator- | ( | ImageIteratorBase< IMAGEITERATOR, PIXELTYPE, REFERENCE, POINTER, StridedOrUnstrided > const & | rhs | ) | const

usage: `Diff2D dist = iterator - iterator1`

## ◆ operator=()

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

ImageIteratorBase & operator= | ( | ImageIteratorBase< IMAGEITERATOR, PIXELTYPE, REFERENCE, POINTER, StridedOrUnstrided > const & | rhs | ) |

protected

Copy assignment

## ◆ operator+=()

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

IMAGEITERATOR & operator+= | ( | difference_type const & | s | ) |

Add offset via Diff2D

## ◆ operator-=()

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

IMAGEITERATOR & operator-= | ( | difference_type const & | s | ) |

Subtract offset via Diff2D

## ◆ operator+()

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

IMAGEITERATOR operator+ | ( | difference_type const & | s | ) | const

Add a distance

## ◆ operator-() [2/2]

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

IMAGEITERATOR operator- | ( | difference_type const & | s | ) | const

Subtract a distance

## ◆ operator*()

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

reference operator* | ( |  | ) | const

Access current pixel.
usage: `SomePixelType value = *iterator`

## ◆ operator->()

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

pointer operator-> | ( |  | ) | const

Call member of current pixel.
usage: `iterator->pixelMemberFunction()`

## ◆ operator[]() [1/2]

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

index_reference operator[] | ( | Diff2D const & | d | ) | const

Access pixel at offset from current location.
usage: `SomePixelType value = iterator[Diff2D(1,1)]`

## ◆ operator()()

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

index_reference operator() | ( | std::ptrdiff_t | dx,
|  | std::ptrdiff_t | dy
| ) |  | const

Access pixel at offset (dx, dy) from current location.
usage: `SomePixelType value = iterator(dx, dy)`

## ◆ operator[]() [2/2]

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

pointer operator[] | ( | std::ptrdiff_t | dy | ) | const

Read pixel with offset [dy][dx] from current pixel. Note that the 'x' index is the trailing index.
usage: `SomePixelType value = iterator[dy][dx]`

## Member Data Documentation

## ◆ x

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

MoveX x

Refer to iterator's x coordinate. Usage examples:

++iterator.x; // move one step to the right
--iterator.x; // move one step to the left
iterator.x += dx; // move dx steps to the right
iterator.x -= dx; // move dx steps to the left
bool notAtEndOfRow = iterator.x < lowerRight.x; // compare x coordinates of two iterators
int width = lowerRight.x - upperLeft.x; // calculate difference of x coordinates
// between two iterators

## ◆ y

template<class IMAGEITERATOR , class PIXELTYPE , class REFERENCE , class POINTER , class StridedOrUnstrided = UnstridedArrayTag>

MoveY y

Refer to iterator's y coordinate. Usage examples:

++iterator.y; // move one step down
--iterator.y; // move one step up
iterator.y += dy; // move dy steps down
iterator.y -= dy; // move dy steps up
bool notAtEndOfColumn = iterator.y < lowerRight.y; // compare y coordinates of two iterators
int height = lowerRight.y - upperLeft.y; // calculate difference of y coordinates
// between two iterators

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

- vigra/imageiterator.hxx

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python vigra 1.12.1