The library infrastructure » Iterators module

Objects to iterate over images and image lines in different ways.

Contents

See Using iterators to implement filters for a mini-tutorial on how to use each of the different iterator types. Next, read the documentation for the iterator you plan to use, to learn about additional options and possibilities.

Classes

template<typename T>
class dip::SampleIterator
An iterator to iterate over samples in a tensor, or pixels on an image line.
class dip::BresenhamLineIterator
An iterator to iterate over pixels along a straight line.
template<typename T = dip::dfloat>
class dip::GenericImageIterator
A data-type–agnostic version of dip::ImageIterator. Use this iterator only to write code that does not know at compile-time what the data type of the image is.
template<dip::uint N, typename T = dip::dfloat>
class dip::GenericJointImageIterator
A data-type–agnostic version of dip::JointImageIterator. Use this iterator only to write code that does not know at compile-time what the data type of the image is.
class dip::ImageSliceIterator
An iterator for slice-by-slice processing of an image. Use it to process a multi-dimensional image as a series of lower-dimensional images.
template<typename T>
class dip::LineIterator
An iterator to iterate over all pixels of an image line.
template<typename T>
class dip::ImageIterator
An iterator to iterate over all pixels of an image, or all lines of an image.
template<typename Types>
class dip::JointImageIterator
An iterator to iterate over all pixels of multiple images.

Aliases

template<typename T>
using dip::ConstSampleIterator = SampleIterator<const T>
A const iterator to iterate over samples in a tensor, or pixels on an image line.
template<typename T>
using dip::ConstLineIterator = LineIterator<const T>
A const iterator to iterate over all pixels of an image line.
template<typename T>
using dip::ConstImageIterator = ImageIterator<const T>
A const iterator to iterate over all pixels of an image, or all lines of an image.

Functions

auto dip::ImageSliceEndIterator(dip::Image const& image, dip::uint procDim) -> dip::ImageSliceIterator
Constructs an end iterator corresponding to a dip::ImageSliceIterator
auto dip::ImageTensorIterator(dip::Image const& image) -> dip::ImageSliceIterator
An iterator for element-by-element processing of a tensor image. Use it to process a tensor image as a series of scalar images.

Operators

template<typename T, typename I, typename <SFINAE>>
auto dip::operator+(SampleIterator<T> it, I n) -> SampleIterator<T>
Add integer to a sample iterator
template<typename T, typename I, typename <SFINAE>>
auto dip::operator-(SampleIterator<T> it, I n) -> SampleIterator<T>
Subtract integer from a sample iterator
auto dip::operator+(dip::ImageSliceIterator it, dip::sint n) -> dip::ImageSliceIterator
Increment an image slice iterator by n
auto dip::operator+(dip::ImageSliceIterator it, dip::uint n) -> dip::ImageSliceIterator
Increment an image slice iterator by n
auto dip::operator-(dip::ImageSliceIterator it, dip::sint n) -> dip::ImageSliceIterator
Decrement an image slice iterator by n, but never moves the iterator to before the first slide
auto dip::operator-(dip::ImageSliceIterator it, dip::uint n) -> dip::ImageSliceIterator
Decrement an image slice iterator by n, but never moves the iterator to before the first slide

Function documentation

dip::ImageSliceIterator dip::ImageSliceEndIterator(dip::Image const& image, dip::uint procDim)

Constructs an end iterator corresponding to a dip::ImageSliceIterator

dip::ImageSliceIterator dip::ImageTensorIterator(dip::Image const& image)

An iterator for element-by-element processing of a tensor image. Use it to process a tensor image as a series of scalar images.

This iterator is implemented as a dip::ImageSliceIterator, see that iterator’s documentation for further information. When the iterator is dereferenced it yields a scalar image of the same size as the input image. Each of the tensor elements is visited in the order in which it is stored. For the case of symmetric and triangular tensors, this means that fewer tensor elements will be visited. See dip::Tensor for information on storage order.

auto it = dip::ImageTensorIterator( img );
do {
   // do something with the image *it here.
} while( ++it );

Note that when the original image is stripped or reforged, the iterator is still valid and holds on to the original data segment.