template<typename T>
LineIterator class
An iterator to iterate over all pixels of an image line.
Contents
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 value_type = T
- The data type of the pixel, obtained when dereferencing the iterator
- using reference = T&
- The type of a reference to a pixel
- using pointer = T*
- The type of a pointer to a pixel
Functions
- void swap(dip::LineIterator& other) noexcept
- Swap
- auto begin() const -> dip::SampleIterator
- Get an iterator over the tensor for the current pixel
- auto end() const -> dip::SampleIterator
- Get an end 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 IsAtEnd() const -> bool
- Test to see if the iterator reached past the last pixel
- auto Coordinate() const -> dip::uint const&
- Return the current coordinate along the line
- auto Length() const -> dip::uint const&
- Return the number of pixels along the line
- auto Pointer() const -> dip::LineIterator::pointer
- Return the current pointer
Operators
-
auto operator LineIterator
() const -> dip::LineIterator - Convert from non-const iterator to const iterator
- auto operator*() const -> dip::LineIterator::reference
- Dereference
- auto operator->() const -> dip::LineIterator::pointer
- Dereference
- auto operator[](dip::uint index) const -> dip::LineIterator::reference
- Index into tensor,
it[0]
is equal to*it
, butit[1]
is not equal to*(++it)
. - auto operator++() -> dip::LineIterator&
- Pre-increment
- auto operator++(int ) -> dip::LineIterator
- Post-increment
- auto operator==(dip::LineIterator const& other) const -> bool
- Equality comparison
- auto operator!=(dip::LineIterator const& other) const -> bool
- Inequality comparison
- auto operator bool() const -> bool explicit
- Test to see if the iterator is still pointing at a pixel
Alias documentation
template<typename T>
template<typename T>
using dip:: ConstLineIterator = dip::LineIterator
template<typename T>
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.