ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itk::ImageIterator< TImage > Class Template Reference

#include <itkImageIterator.h>

Detailed Description

template<typename TImage>
class itk::ImageIterator< TImage >

A multi-dimensional image iterator templated over image type.

ImageIterator is a templated class to represent a multi-dimensional iterator. ImageIterator is templated over the type of the image to be iterated over.

The constness of the template image type determines the access semantics of the iterator: a const-qualified type provides read-only access, while a non-const type allows both reading and writing.

ImageIterator is a base class for all the image iterators. It provides the basic construction and comparison operations. However, it does not provide mechanisms for moving the iterator. A subclass of ImageIterator must be used to move the iterator.

ImageIterator is a multi-dimensional iterator, requiring more information be specified before the iterator can be used than conventional iterators. Whereas the std::vector::iterator from the STL only needs to be passed a pointer to establish the iterator, the multi-dimensional image iterator needs a pointer, the size of the buffer, the size of the region, the start index of the buffer, and the start index of the region. To gain access to this information, ImageIterator holds a reference to the image over which it is traversing.

ImageIterator assumes a particular layout of the image data. In particular, the data is arranged in a 1D array as if it were [][][][slice][row][col] with Index[0] = col, Index[1] = row, Index[2] = slice, etc.

MORE INFORMATION
For a complete description of the ITK Image Iterators and their API, please see the Iterators chapter in the ITK Software Guide. The ITK Software Guide is available in print and as a free .pdf download from https://www.itk.org.
See also
ConditionalConstIterator
ConstNeighborhoodIterator
ConstShapedNeighborhoodIterator
ConstSliceIterator
CorrespondenceDataStructureIterator
FloodFilledFunctionConditionalConstIterator
FloodFilledImageFunctionConditionalConstIterator
FloodFilledImageFunctionConditionalIterator
FloodFilledSpatialFunctionConditionalConstIterator
FloodFilledSpatialFunctionConditionalIterator
ImageConstIterator
ImageConstIteratorWithIndex
ImageIteratorWithIndex
ImageLinearConstIteratorWithIndex
ImageLinearIteratorWithIndex
ImageRandomConstIteratorWithIndex
ImageRandomIteratorWithIndex
ImageRegionConstIterator
ImageRegionConstIteratorWithIndex
ImageRegionExclusionConstIteratorWithIndex
ImageRegionExclusionIteratorWithIndex
ImageRegionIterator
ImageRegionIteratorWithIndex
ImageRegionReverseConstIterator
ImageRegionReverseIterator
ImageReverseConstIterator
ImageReverseIterator
ImageSliceConstIteratorWithIndex
ImageSliceIteratorWithIndex
NeighborhoodIterator
PathConstIterator
PathIterator
ShapedNeighborhoodIterator
SliceIterator

Definition at line 108 of file itkImageIterator.h.

+ Inheritance diagram for itk::ImageIterator< TImage >:
+ Collaboration diagram for itk::ImageIterator< TImage >:

Public Types

using AccessorFunctorType = typename TImage::AccessorFunctorType
 
using AccessorType = typename TImage::AccessorType
 
using ImageType = detail::IteratorImageType_t<TImage>
 
using IndexType = typename TImage::IndexType
 
using InternalPixelType = typename TImage::InternalPixelType
 
using OffsetType = typename TImage::OffsetType
 
using PixelContainer = typename TImage::PixelContainer
 
using PixelContainerPointer = typename PixelContainer::Pointer
 
using PixelType = typename TImage::PixelType
 
using RegionType = typename TImage::RegionType
 
using Self = ImageIterator
 
using SizeType = typename TImage::SizeType
 

Public Member Functions

IndexType ComputeIndex () const
 
PixelType Get () const
 
TImage * GetImage () const
 
virtual const char * GetNameOfClass () const
 
const RegionType & GetRegion () const
 
void GoToBegin ()
 
void GoToEnd ()
 
 ImageIterator ()
 
template<typename TOtherImage, std::enable_if_t< detail::IsImageIteratorConvertible_v< TOtherImage, TImage >, int > = 0>
 ImageIterator (const ImageIterator< TOtherImage > &it)
 
 ImageIterator (const Self &)=default
 
 ImageIterator (TImage *ptr, const RegionType &region)
 
bool IsAtBegin () const
 
bool IsAtEnd () const
 
template<typename TOtherImage, std::enable_if_t< std::is_same_v< std::remove_const_t< TOtherImage >, std::remove_const_t< TImage > >, int > = 0>
bool operator!= (const ImageIterator< TOtherImage > &it) const
 
template<typename TOtherImage, std::enable_if_t< std::is_same_v< std::remove_const_t< TOtherImage >, std::remove_const_t< TImage > >, int > = 0>
bool operator< (const ImageIterator< TOtherImage > &it) const
 
template<typename TOtherImage, std::enable_if_t< std::is_same_v< std::remove_const_t< TOtherImage >, std::remove_const_t< TImage > >, int > = 0>
bool operator<= (const ImageIterator< TOtherImage > &it) const
 
Self & operator= (const Self &)=default
 
template<typename TOtherImage, std::enable_if_t< std::is_same_v< std::remove_const_t< TOtherImage >, std::remove_const_t< TImage > >, int > = 0>
bool operator== (const ImageIterator< TOtherImage > &it) const
 
template<typename TOtherImage, std::enable_if_t< std::is_same_v< std::remove_const_t< TOtherImage >, std::remove_const_t< TImage > >, int > = 0>
bool operator> (const ImageIterator< TOtherImage > &it) const
 
template<typename TOtherImage, std::enable_if_t< std::is_same_v< std::remove_const_t< TOtherImage >, std::remove_const_t< TImage > >, int > = 0>
bool operator>= (const ImageIterator< TOtherImage > &it) const
 
template<typename T = TImage, std::enable_if_t< std::is_same_v< T, TImage > &&!std::is_const_v< T >, int > = 0>
void Set (const PixelType &value) const
 
virtual void SetIndex (const IndexType &ind)
 
virtual void SetRegion (const RegionType &region)
 
template<typename T = TImage, std::enable_if_t< std::is_same_v< T, TImage > &&!std::is_const_v< T >, int > = 0>
PixelType & Value ()
 
const PixelType & Value () const
 
virtual ~ImageIterator ()=default
 

Static Public Member Functions

static unsigned int GetImageIteratorDimension ()
 

Static Public Attributes

static constexpr unsigned int ImageIteratorDimension = TImage::ImageDimension
 

Protected Attributes

OffsetValueType m_BeginOffset {}
 
std::conditional_t< std::is_const_v< TImage >, const InternalPixelType, InternalPixelType > * m_Buffer {}
 
OffsetValueType m_EndOffset {}
 
WeakPointer< TImage > m_Image {}
 
OffsetValueType m_Offset {}
 
AccessorType m_PixelAccessor {}
 
AccessorFunctorType m_PixelAccessorFunctor {}
 
RegionType m_Region {}
 

Friends

template<typename>
class ImageIterator
 

Member Typedef Documentation

◆ AccessorFunctorType

template<typename TImage>
using itk::ImageIterator< TImage >::AccessorFunctorType = typename TImage::AccessorFunctorType

Definition at line 155 of file itkImageIterator.h.

◆ AccessorType

template<typename TImage>
using itk::ImageIterator< TImage >::AccessorType = typename TImage::AccessorType

Accessor type that convert data between internal and external representations.

Definition at line 154 of file itkImageIterator.h.

◆ ImageType

template<typename TImage>
using itk::ImageIterator< TImage >::ImageType = detail::IteratorImageType_t<TImage>

Image type alias support

Definition at line 139 of file itkImageIterator.h.

◆ IndexType

template<typename TImage>
using itk::ImageIterator< TImage >::IndexType = typename TImage::IndexType

Index type alias support

Definition at line 127 of file itkImageIterator.h.

◆ InternalPixelType

template<typename TImage>
using itk::ImageIterator< TImage >::InternalPixelType = typename TImage::InternalPixelType

Internal Pixel Type

Definition at line 147 of file itkImageIterator.h.

◆ OffsetType

template<typename TImage>
using itk::ImageIterator< TImage >::OffsetType = typename TImage::OffsetType

Offset type alias support

Definition at line 133 of file itkImageIterator.h.

◆ PixelContainer

template<typename TImage>
using itk::ImageIterator< TImage >::PixelContainer = typename TImage::PixelContainer

PixelContainer type alias support. Used to refer to the container for the pixel data.

Definition at line 143 of file itkImageIterator.h.

◆ PixelContainerPointer

template<typename TImage>
using itk::ImageIterator< TImage >::PixelContainerPointer = typename PixelContainer::Pointer

Definition at line 144 of file itkImageIterator.h.

◆ PixelType

template<typename TImage>
using itk::ImageIterator< TImage >::PixelType = typename TImage::PixelType

External Pixel Type

Definition at line 150 of file itkImageIterator.h.

◆ RegionType

template<typename TImage>
using itk::ImageIterator< TImage >::RegionType = typename TImage::RegionType

Region type alias support

Definition at line 136 of file itkImageIterator.h.

◆ Self

template<typename TImage>
using itk::ImageIterator< TImage >::Self = ImageIterator

Standard class type aliases.

Definition at line 115 of file itkImageIterator.h.

◆ SizeType

template<typename TImage>
using itk::ImageIterator< TImage >::SizeType = typename TImage::SizeType

Size type alias support

Definition at line 130 of file itkImageIterator.h.

Constructor & Destructor Documentation

◆ ImageIterator() [1/4]

template<typename TImage>
itk::ImageIterator< TImage >::ImageIterator ( )
inline

Default Constructor. Need to provide a default constructor since we provide a copy constructor.

Definition at line 159 of file itkImageIterator.h.

◆ ~ImageIterator()

template<typename TImage>
virtual itk::ImageIterator< TImage >::~ImageIterator ( )
virtualdefault

Default Destructor.

◆ ImageIterator() [2/4]

template<typename TImage>
itk::ImageIterator< TImage >::ImageIterator ( const Self & )
default

◆ ImageIterator() [3/4]

template<typename TImage>
template<typename TOtherImage, std::enable_if_t< detail::IsImageIteratorConvertible_v< TOtherImage, TImage >, int > = 0>
itk::ImageIterator< TImage >::ImageIterator ( const ImageIterator< TOtherImage > & it)
inline

Conversion from a writable iterator to a read-only iterator.

Definition at line 178 of file itkImageIterator.h.

◆ ImageIterator() [4/4]

template<typename TImage>
itk::ImageIterator< TImage >::ImageIterator ( TImage * ptr,
const RegionType & region )
inline

Constructor establishes an iterator to walk a particular image and a particular region of that image. Initializes the iterator at the begin of the region.

Definition at line 191 of file itkImageIterator.h.

Member Function Documentation

◆ ComputeIndex()

template<typename TImage>
IndexType itk::ImageIterator< TImage >::ComputeIndex ( ) const
inlinenodiscard

Computes the index. Internally calls ImageBase::ComputeIndex, which may be a relatively expensive operation.

See also
SetIndex

Definition at line 323 of file itkImageIterator.h.

Referenced by itk::ImageReverseIterator< std::add_const_t< TImage > >::ImageReverseIterator(), and itk::ImageScanlineIterator< std::add_const_t< TImage > >::ImageScanlineIterator().

◆ Get()

◆ GetImage()

◆ GetImageIteratorDimension()

template<typename TImage>
static unsigned int itk::ImageIterator< TImage >::GetImageIteratorDimension ( )
inlinestatic

Get the dimension (size) of the index.

Definition at line 246 of file itkImageIterator.h.

◆ GetNameOfClass()

template<typename TImage>
virtual const char * itk::ImageIterator< TImage >::GetNameOfClass ( ) const
virtual
See also
LightObject::GetNameOfClass()

Reimplemented in itk::ImageConstIterator< TImage >, itk::ImageRegionConstIterator< TImage >, itk::ImageRegionConstIterator< CoordImageType >, itk::ImageRegionConstIterator< CoordImageType >, itk::ImageRegionConstIterator< FeatureImageType >, itk::ImageRegionConstIterator< FeatureImageType >, itk::ImageRegionConstIterator< ImageType >, itk::ImageRegionConstIterator< ImageType >, itk::ImageRegionConstIterator< InputImageType >, itk::ImageRegionConstIterator< InputImageType >, itk::ImageRegionConstIterator< InternalImageType >, itk::ImageRegionConstIterator< InternalImageType >, itk::ImageRegionConstIterator< MembershipImageType >, itk::ImageRegionConstIterator< MembershipImageType >, itk::ImageRegionConstIterator< PriorsImageType >, itk::ImageRegionConstIterator< PriorsImageType >, itk::ImageRegionConstIterator< TInputImage >, itk::ImageRegionConstIterator< TInputImage >, itk::ImageRegionConstIterator< TTrainingImage >, itk::ImageRegionConstIterator< TTrainingImage >, itk::ImageRegionIterator< TImage >, itk::ImageRegionIterator< ImageType >, itk::ImageRegionIterator< ImageType >, itk::ImageRegionIterator< InputImageType >, itk::ImageRegionIterator< InputImageType >, itk::ImageRegionIterator< InternalImageType >, itk::ImageRegionIterator< InternalImageType >, itk::ImageRegionIterator< LabelImageType >, itk::ImageRegionIterator< LabelImageType >, itk::ImageRegionIterator< LabelStatusImageType >, itk::ImageRegionIterator< LabelStatusImageType >, itk::ImageRegionIterator< MembershipImageType >, itk::ImageRegionIterator< MembershipImageType >, itk::ImageRegionIterator< OutputImageType >, itk::ImageRegionIterator< OutputImageType >, itk::ImageRegionIterator< PosteriorsImageType >, itk::ImageRegionIterator< PosteriorsImageType >, itk::ImageRegionIterator< std::add_const_t< TImage > >, itk::ImageRegionIterator< std::add_const_t< TImage > >, itk::ImageRegionIterator< TClassifiedImage >, itk::ImageRegionIterator< TClassifiedImage >, itk::ImageRegionIterator< TInputImage >, itk::ImageRegionIterator< TInputImage >, itk::ImageRegionIterator< TOutputImage >, itk::ImageRegionIterator< TOutputImage >, itk::ImageRegionIterator< TTrainingImage >, itk::ImageRegionIterator< TTrainingImage >, itk::ImageScanlineConstIterator< TImage >, itk::ImageScanlineConstIterator< InputImageType >, itk::ImageScanlineConstIterator< InputImageType >, itk::ImageScanlineIterator< TImage >, itk::ImageScanlineIterator< std::add_const_t< TImage > >, and itk::ImageScanlineIterator< std::add_const_t< TImage > >.

◆ GetRegion()

template<typename TImage>
const RegionType & itk::ImageIterator< TImage >::GetRegion ( ) const
inlinenodiscard

Get the region that this iterator walks. ImageIterators know the beginning and the end of the region of the image to iterate over.

Definition at line 351 of file itkImageIterator.h.

Referenced by itk::ImageReverseIterator< std::add_const_t< TImage > >::operator=().

◆ GoToBegin()

template<typename TImage>
void itk::ImageIterator< TImage >::GoToBegin ( )
inline

Move an iterator to the beginning of the region. "Begin" is defined as the first pixel in the region.

Definition at line 400 of file itkImageIterator.h.

Referenced by itk::ImageRegionIterator< std::add_const_t< TImage > >::GoToBegin(), and itk::ImageScanlineIterator< std::add_const_t< TImage > >::GoToBegin().

◆ GoToEnd()

template<typename TImage>
void itk::ImageIterator< TImage >::GoToEnd ( )
inline

Move an iterator to the end of the region. "End" is defined as one pixel past the last pixel of the region.

Definition at line 408 of file itkImageIterator.h.

Referenced by itk::ImageRegionIterator< std::add_const_t< TImage > >::GoToEnd(), and itk::ImageScanlineIterator< std::add_const_t< TImage > >::GoToEnd().

◆ IsAtBegin()

template<typename TImage>
bool itk::ImageIterator< TImage >::IsAtBegin ( ) const
inlinenodiscard

Is the iterator at the beginning of the region? "Begin" is defined as the first pixel in the region.

Definition at line 416 of file itkImageIterator.h.

◆ IsAtEnd()

template<typename TImage>
bool itk::ImageIterator< TImage >::IsAtEnd ( ) const
inlinenodiscard

Is the iterator at the end of the region? "End" is defined as one pixel past the last pixel of the region.

Definition at line 424 of file itkImageIterator.h.

Referenced by itk::MultiphaseFiniteDifferenceImageFilter< TInputImage, TFeatureImage, TOutputImage, TFunction, TIdCell >::SetLevelSet().

◆ operator!=()

template<typename TImage>
template<typename TOtherImage, std::enable_if_t< std::is_same_v< std::remove_const_t< TOtherImage >, std::remove_const_t< TImage > >, int > = 0>
bool itk::ImageIterator< TImage >::operator!= ( const ImageIterator< TOtherImage > & it) const
inline

Definition at line 266 of file itkImageIterator.h.

◆ operator<()

template<typename TImage>
template<typename TOtherImage, std::enable_if_t< std::is_same_v< std::remove_const_t< TOtherImage >, std::remove_const_t< TImage > >, int > = 0>
bool itk::ImageIterator< TImage >::operator< ( const ImageIterator< TOtherImage > & it) const
inline

Comparison operator. An iterator is "less than" another if it "points to" a lower memory location.

Definition at line 288 of file itkImageIterator.h.

◆ operator<=()

template<typename TImage>
template<typename TOtherImage, std::enable_if_t< std::is_same_v< std::remove_const_t< TOtherImage >, std::remove_const_t< TImage > >, int > = 0>
bool itk::ImageIterator< TImage >::operator<= ( const ImageIterator< TOtherImage > & it) const
inline

Comparison operator. An iterator is "less than" another if it "points to" a lower memory location.

Definition at line 276 of file itkImageIterator.h.

◆ operator=()

template<typename TImage>
Self & itk::ImageIterator< TImage >::operator= ( const Self & )
default

◆ operator==()

template<typename TImage>
template<typename TOtherImage, std::enable_if_t< std::is_same_v< std::remove_const_t< TOtherImage >, std::remove_const_t< TImage > >, int > = 0>
bool itk::ImageIterator< TImage >::operator== ( const ImageIterator< TOtherImage > & it) const
inline

Comparison operator. Two iterators are the same if they "point to" the same memory location

Definition at line 256 of file itkImageIterator.h.

◆ operator>()

template<typename TImage>
template<typename TOtherImage, std::enable_if_t< std::is_same_v< std::remove_const_t< TOtherImage >, std::remove_const_t< TImage > >, int > = 0>
bool itk::ImageIterator< TImage >::operator> ( const ImageIterator< TOtherImage > & it) const
inline

Comparison operator. An iterator is "greater than" another if it "points to" a higher location.

Definition at line 313 of file itkImageIterator.h.

◆ operator>=()

template<typename TImage>
template<typename TOtherImage, std::enable_if_t< std::is_same_v< std::remove_const_t< TOtherImage >, std::remove_const_t< TImage > >, int > = 0>
bool itk::ImageIterator< TImage >::operator>= ( const ImageIterator< TOtherImage > & it) const
inline

Comparison operator. An iterator is "greater than" another if it "points to" a higher location.

Definition at line 301 of file itkImageIterator.h.

◆ Set()

template<typename TImage>
template<typename T = TImage, std::enable_if_t< std::is_same_v< T, TImage > &&!std::is_const_v< T >, int > = 0>
void itk::ImageIterator< TImage >::Set ( const PixelType & value) const
inline

◆ SetIndex()

◆ SetRegion()

template<typename TImage>
virtual void itk::ImageIterator< TImage >::SetRegion ( const RegionType & region)
inlinevirtual

Set the region of the image to iterate over.

Definition at line 207 of file itkImageIterator.h.

◆ Value() [1/2]

template<typename TImage>
template<typename T = TImage, std::enable_if_t< std::is_same_v< T, TImage > &&!std::is_const_v< T >, int > = 0>
PixelType & itk::ImageIterator< TImage >::Value ( )
inline

Return a reference to the pixel This method will provide the fastest access to pixel data, but it will NOT support ImageAdaptors. Available only when TImage is not const.

Definition at line 392 of file itkImageIterator.h.

◆ Value() [2/2]

template<typename TImage>
const PixelType & itk::ImageIterator< TImage >::Value ( ) const
inlinenodiscard

Return a const reference to the pixel This method will provide the fastest access to pixel data, but it will NOT support ImageAdaptors.

Definition at line 382 of file itkImageIterator.h.

Referenced by itk::GradientImageFilter< TInputImage, TOperatorValueType, TOutputValueType, TOutputImageType >::SetOutputPixel().

Friends And Related Symbol Documentation

◆ ImageIterator

Member Data Documentation

◆ ImageIteratorDimension

template<typename TImage>
unsigned int itk::ImageIterator< TImage >::ImageIteratorDimension = TImage::ImageDimension
staticconstexpr

Dimension of the image the iterator walks. This constant is needed so functions that are templated over image iterator type (as opposed to being templated over pixel type and dimension) can have compile time access to the dimension of the image that the iterator walks.

Definition at line 121 of file itkImageIterator.h.

◆ m_BeginOffset

◆ m_Buffer

◆ m_EndOffset

◆ m_Image

template<typename TImage>
WeakPointer<TImage> itk::ImageIterator< TImage >::m_Image {}
protected

Definition at line 430 of file itkImageIterator.h.

◆ m_Offset

◆ m_PixelAccessor

template<typename TImage>
AccessorType itk::ImageIterator< TImage >::m_PixelAccessor {}
protected

Definition at line 440 of file itkImageIterator.h.

◆ m_PixelAccessorFunctor

template<typename TImage>
AccessorFunctorType itk::ImageIterator< TImage >::m_PixelAccessorFunctor {}
protected

Definition at line 441 of file itkImageIterator.h.

◆ m_Region


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