template<typename T>
dip::LineIterator class

An iterator to iterate over all pixels of an image line.

This iterator is constructed from a dip::ImageIterator, but can also be constructed manually if necessary.

The iterator can be incremented until it reaches the end of the line. At this point, the iterator will become invalid. An invalid iterator will test false. The IsAtEnd method can be used instead to test for this condition. It is also possible to compare two iterators for equality (i.e. to compare against an end iterator).

Dereferencing the iterator yields the first sample of the current pixel (*it == it[ 0 ]). One can index using the [] operator to obtain each of the samples of the tensor (it[ 0 ] .. it[ image.TensorElements() - 1 ]).

Alternatively, a dip::SampleIterator can be obtained to iterate over the samples of the tensor (it.begin() .. it.end()).

Satisfies all the requirements for a mutable ForwardIterator.

Note that when an image is stripped or reforged, all its iterators are invalidated.

Constructors, destructors, assignment and conversion operators

LineIterator() defaulted
Default constructor yields an invalid iterator that cannot be dereferenced, and is equivalent to an end iterator
LineIterator(dip::Image const& image, dip::UnsignedArray const& coords, dip::uint procDim)
To construct a useful iterator, provide an image, the coordinate of the start pixel, and the processing dimension
LineIterator(dip::LineIterator::pointer ptr, dip::uint coord, dip::uint size, dip::sint stride, dip::uint nTensorElements, dip::sint tensorStride)
To construct a useful iterator, provide a pointer, the offset within the line, the length of the line, the stride, the number of tensor elements, and the tensor stride.
LineIterator(dip::LineIterator::pointer ptr, dip::uint size, dip::sint stride, dip::uint nTensorElements, dip::sint tensorStride)
To construct a useful iterator, provide a pointer, the length of the line, the stride, the number of tensor elements, and the tensor stride. The iterator starts at the beginning of the line.
LineIterator(dip::LineIterator::pointer ptr, dip::uint coord, dip::uint size, dip::sint stride)
To construct a useful iterator, provide a pointer, the offset within the line, the length of the line, and the stride. A single tensor element is assumed.
LineIterator(dip::LineIterator::pointer ptr, dip::uint size, dip::sint stride)
To construct a useful iterator, provide a pointer, the length of the line, and the stride. A single tensor element is assumed. The iterator starts at the beginning of the line.

Aliases

using iterator_category = std::forward_iterator_tag
Iterator category
using pointer = T*
The type of a pointer to a pixel
using reference = T&
The type of a reference to a pixel
using value_type = T
The data type of the pixel, obtained when dereferencing the iterator

Functions

auto begin() const -> dip::SampleIterator
Get an iterator over the tensor for the current pixel
auto cbegin() const -> dip::ConstSampleIterator
Get a const iterator over the tensor for the current pixel
auto cend() const -> dip::ConstSampleIterator
Get an end const iterator over the tensor for the current pixel
auto Coordinate() const -> dip::uint const&
Return the current coordinate along the line
auto end() const -> dip::SampleIterator
Get an end iterator over the tensor for the current pixel
auto IsAtEnd() const -> bool
Test to see if the iterator reached past the last pixel
auto Length() const -> dip::uint const&
Return the number of pixels along the line
auto Pointer() const -> dip::LineIterator::pointer
Return the current pointer
void swap(dip::LineIterator& other) noexcept
Swap

Operators

auto operator bool() const -> bool explicit
Test to see if the iterator is still pointing at a pixel
auto operator LineIterator() const -> dip::LineIterator
Convert from non-const iterator to const iterator
auto operator!=(dip::LineIterator const& other) const -> bool
Inequality comparison
auto operator*() const -> dip::LineIterator::reference
Dereference
auto operator++() -> dip::LineIterator&
Pre-increment
auto operator++(int ) -> dip::LineIterator
Post-increment
auto operator->() const -> dip::LineIterator::pointer
Dereference
auto operator==(dip::LineIterator const& other) const -> bool
Equality comparison
auto operator[](dip::uint index) const -> dip::LineIterator::reference
Index into tensor, it[0] is equal to *it, but it[1] is not equal to *(++it).

Alias documentation

template<typename T>
using iterator_category = std::forward_iterator_tag

Iterator category

template<typename T>
using value_type = T

The data type of the pixel, obtained when dereferencing the iterator

template<typename T>
using reference = T&

The type of a reference to a pixel

template<typename T>
using pointer = T*

The type of a pointer to a pixel

template<typename T>
template<typename T>
using dip::ConstLineIterator = dip::LineIterator

A const iterator to iterate over all pixels of an image line.

This iterator is identical to dip::LineIterator, but with a const value type.

Satisfies all the requirements for a non-mutable ForwardIterator.

Function documentation

template<typename T>
LineIterator( ) defaulted

Default constructor yields an invalid iterator that cannot be dereferenced, and is equivalent to an end iterator

template<typename T>
LineIterator( dip::Image const& image, dip::UnsignedArray const& coords, dip::uint procDim)

To construct a useful iterator, provide an image, the coordinate of the start pixel, and the processing dimension

template<typename T>
LineIterator( dip::LineIterator::pointer ptr, dip::uint coord, dip::uint size, dip::sint stride, dip::uint nTensorElements, dip::sint tensorStride)

To construct a useful iterator, provide a pointer, the offset within the line, the length of the line, the stride, the number of tensor elements, and the tensor stride.

template<typename T>
LineIterator( dip::LineIterator::pointer ptr, dip::uint size, dip::sint stride, dip::uint nTensorElements, dip::sint tensorStride)

To construct a useful iterator, provide a pointer, the length of the line, the stride, the number of tensor elements, and the tensor stride. The iterator starts at the beginning of the line.

template<typename T>
LineIterator( dip::LineIterator::pointer ptr, dip::uint coord, dip::uint size, dip::sint stride)

To construct a useful iterator, provide a pointer, the offset within the line, the length of the line, and the stride. A single tensor element is assumed.

template<typename T>
LineIterator( dip::LineIterator::pointer ptr, dip::uint size, dip::sint stride)

To construct a useful iterator, provide a pointer, the length of the line, and the stride. A single tensor element is assumed. The iterator starts at the beginning of the line.

template<typename T>
void swap( dip::LineIterator& other) noexcept

Swap

template<typename T>
dip::SampleIterator begin( ) const

Get an iterator over the tensor for the current pixel

template<typename T>
dip::SampleIterator end( ) const

Get an end iterator over the tensor for the current pixel

template<typename T>
dip::ConstSampleIterator cbegin( ) const

Get a const iterator over the tensor for the current pixel

template<typename T>
dip::ConstSampleIterator cend( ) const

Get an end const iterator over the tensor for the current pixel

template<typename T>
bool IsAtEnd( ) const

Test to see if the iterator reached past the last pixel

template<typename T>
dip::uint const& Coordinate( ) const

Return the current coordinate along the line

template<typename T>
dip::uint const& Length( ) const

Return the number of pixels along the line

template<typename T>
dip::LineIterator::pointer Pointer( ) const

Return the current pointer

template<typename T>
dip::LineIterator operator LineIterator( ) const

Convert from non-const iterator to const iterator

template<typename T>
dip::LineIterator::reference operator*( ) const

Dereference

template<typename T>
dip::LineIterator::pointer operator->( ) const

Dereference

template<typename T>
dip::LineIterator::reference operator[]( dip::uint index) const

Index into tensor, it[0] is equal to *it, but it[1] is not equal to *(++it).

template<typename T>
dip::LineIterator& operator++( )

Pre-increment

template<typename T>
dip::LineIterator operator++( int )

Post-increment

template<typename T>
bool operator==( dip::LineIterator const& other) const

Equality comparison

template<typename T>
bool operator!=( dip::LineIterator const& other) const

Inequality comparison

template<typename T>
bool operator bool( ) const explicit

Test to see if the iterator is still pointing at a pixel