ITK  6.0.0
Insight Toolkit
Classes | Public Types | Public Member Functions | Private Types | Private Attributes | Static Private Attributes | List of all members
itk::ImageBufferRange< TImage > Class Template Referencefinal

#include <itkImageBufferRange.h>

Detailed Description

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

Modern C++11 range to iterate over the pixels of an image. Designed to conform to Standard C++ Iterator requirements, so that it can be used in range-based for loop, and passed to Standard C++ algorithms.

The following example adds 42 to each pixel, using a range-based for loop:

ImageBufferRange range{ *image };
for (auto&& pixel : range)
{
pixel = pixel + 42;
}

The following example prints the values of the pixels:

for (const auto pixel : range)
{
std::cout << pixel << std::endl;
}
Author
Niels Dekker, LKEB, Leiden University Medical Center
See also
ImageIterator
ImageConstIterator
IndexRange
ShapedImageNeighborhoodRange
Examples
SphinxExamples/src/Core/Common/GenerateOffsetsShapedImageNeighborhood/Code.cxx, and SphinxExamples/src/Core/Common/ImageBufferAndIndexRange/Code.cxx.

Definition at line 73 of file itkImageBufferRange.h.

Classes

class  AccessorFunctorInitializer
 
struct  EmptyAccessorFunctor
 
class  IteratorInitializer
 
class  PixelProxy
 
class  PixelProxy< false, TDummy >
 
class  PixelProxy< true, TDummy >
 
class  QualifiedIterator
 

Public Types

using const_iterator = std::conditional_t< UsingPointerAsIterator, const InternalPixelType *, QualifiedIterator< true > >
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 
using iterator = std::conditional_t< UsingPointerAsIterator, QualifiedInternalPixelType *, QualifiedIterator< IsImageTypeConst > >
 
using reverse_iterator = std::reverse_iterator< iterator >
 

Public Member Functions

iterator begin () const noexcept
 
const_iterator cbegin () const noexcept
 
const_iterator cend () const noexcept
 
const_reverse_iterator crbegin () const noexcept
 
const_reverse_iterator crend () const noexcept
 
bool empty () const noexcept
 
iterator end () const noexcept
 
 ImageBufferRange ()=default
 
reverse_iterator rbegin () const noexcept
 
reverse_iterator rend () const noexcept
 
vcl_size_t size () const noexcept
 
 ImageBufferRange (TImage &image)
 
QualifiedIterator< false >::reference operator[] (const vcl_size_t n) const noexcept
 

Private Types

using AccessorFunctorType = typename TImage::AccessorFunctorType
 
using InternalPixelType = typename TImage::InternalPixelType
 
using OptionalAccessorFunctorType = std::conditional_t< SupportsDirectPixelAccess, EmptyAccessorFunctor, AccessorFunctorType >
 
using PixelType = typename TImage::PixelType
 
using QualifiedInternalPixelType = std::conditional_t< IsImageTypeConst, const InternalPixelType, InternalPixelType >
 

Private Attributes

QualifiedInternalPixelTypem_ImageBufferPointer = nullptr
 
SizeValueType m_NumberOfPixels = 0
 
OptionalAccessorFunctorType m_OptionalAccessorFunctor
 

Static Private Attributes

static constexpr bool IsImageTypeConst = std::is_const_v<TImage>
 
static constexpr bool SupportsDirectPixelAccess
 
static constexpr bool UsingPointerAsIterator = SupportsDirectPixelAccess
 

Member Typedef Documentation

◆ AccessorFunctorType

template<typename TImage>
using itk::ImageBufferRange< TImage >::AccessorFunctorType = typename TImage::AccessorFunctorType
private

Definition at line 78 of file itkImageBufferRange.h.

◆ const_iterator

template<typename TImage>
using itk::ImageBufferRange< TImage >::const_iterator = std::conditional_t<UsingPointerAsIterator, const InternalPixelType *, QualifiedIterator<true> >

Definition at line 550 of file itkImageBufferRange.h.

◆ const_reverse_iterator

template<typename TImage>
using itk::ImageBufferRange< TImage >::const_reverse_iterator = std::reverse_iterator<const_iterator>

Definition at line 554 of file itkImageBufferRange.h.

◆ InternalPixelType

template<typename TImage>
using itk::ImageBufferRange< TImage >::InternalPixelType = typename TImage::InternalPixelType
private

Definition at line 77 of file itkImageBufferRange.h.

◆ iterator

template<typename TImage>
using itk::ImageBufferRange< TImage >::iterator = std::conditional_t<UsingPointerAsIterator, QualifiedInternalPixelType *, QualifiedIterator<IsImageTypeConst> >

Definition at line 552 of file itkImageBufferRange.h.

◆ OptionalAccessorFunctorType

template<typename TImage>
using itk::ImageBufferRange< TImage >::OptionalAccessorFunctorType = std::conditional_t<SupportsDirectPixelAccess, EmptyAccessorFunctor, AccessorFunctorType>
private

Definition at line 96 of file itkImageBufferRange.h.

◆ PixelType

template<typename TImage>
using itk::ImageBufferRange< TImage >::PixelType = typename TImage::PixelType
private

Definition at line 76 of file itkImageBufferRange.h.

◆ QualifiedInternalPixelType

template<typename TImage>
using itk::ImageBufferRange< TImage >::QualifiedInternalPixelType = std::conditional_t<IsImageTypeConst, const InternalPixelType, InternalPixelType>
private

Definition at line 487 of file itkImageBufferRange.h.

◆ reverse_iterator

template<typename TImage>
using itk::ImageBufferRange< TImage >::reverse_iterator = std::reverse_iterator<iterator>

Definition at line 553 of file itkImageBufferRange.h.

Constructor & Destructor Documentation

◆ ImageBufferRange() [1/2]

template<typename TImage>
itk::ImageBufferRange< TImage >::ImageBufferRange ( )
default

Explicitly-defaulted default-constructor. Constructs an empty range.

Note
The other five "special member functions" (copy-constructor, copy-assignment operator, move-constructor, move-assignment operator, and destructor) are defaulted implicitly, following the C++ "Rule of Zero".

◆ ImageBufferRange() [2/2]

template<typename TImage>
itk::ImageBufferRange< TImage >::ImageBufferRange ( TImage &  image)
inlineexplicit

Specifies a range of the pixels of an image.

Note
This constructor supports class template argument deduction (CTAD).

Definition at line 568 of file itkImageBufferRange.h.

Member Function Documentation

◆ begin()

template<typename TImage>
iterator itk::ImageBufferRange< TImage >::begin ( ) const
inlinenoexcept

◆ cbegin()

template<typename TImage>
const_iterator itk::ImageBufferRange< TImage >::cbegin ( ) const
inlinenoexcept

Returns a const iterator to the first pixel. Provides only read-only access to the pixel data.

Definition at line 598 of file itkImageBufferRange.h.

References itk::ImageBufferRange< TImage >::begin().

◆ cend()

template<typename TImage>
const_iterator itk::ImageBufferRange< TImage >::cend ( ) const
inlinenoexcept

Returns a const 'end iterator' for this range.

Definition at line 605 of file itkImageBufferRange.h.

References itk::ImageBufferRange< TImage >::end().

◆ crbegin()

template<typename TImage>
const_reverse_iterator itk::ImageBufferRange< TImage >::crbegin ( ) const
inlinenoexcept

Returns a const reverse 'begin iterator' for this range.

Definition at line 626 of file itkImageBufferRange.h.

References itk::ImageBufferRange< TImage >::rbegin().

◆ crend()

template<typename TImage>
const_reverse_iterator itk::ImageBufferRange< TImage >::crend ( ) const
inlinenoexcept

Returns a const reverse 'end iterator' for this range.

Definition at line 633 of file itkImageBufferRange.h.

References itk::ImageBufferRange< TImage >::rend().

◆ empty()

template<typename TImage>
bool itk::ImageBufferRange< TImage >::empty ( ) const
inlinenoexcept

Tells whether the range is empty.

Definition at line 649 of file itkImageBufferRange.h.

References itk::ImageBufferRange< TImage >::m_NumberOfPixels.

◆ end()

template<typename TImage>
iterator itk::ImageBufferRange< TImage >::end ( ) const
inlinenoexcept

◆ operator[]()

template<typename TImage>
QualifiedIterator<false>::reference itk::ImageBufferRange< TImage >::operator[] ( const vcl_size_t  n) const
inlinenoexcept

Subscript operator. Allows random access, to the nth pixel.

Note
The return type QualifiedIterator<false>::reference is equivalent to iterator::reference.

Definition at line 659 of file itkImageBufferRange.h.

References itk::ImageBufferRange< TImage >::begin(), and itk::ImageBufferRange< TImage >::size().

◆ rbegin()

template<typename TImage>
reverse_iterator itk::ImageBufferRange< TImage >::rbegin ( ) const
inlinenoexcept

Returns a reverse 'begin iterator' for this range.

Definition at line 612 of file itkImageBufferRange.h.

References itk::ImageBufferRange< TImage >::end().

Referenced by itk::ImageBufferRange< TImage >::crbegin().

◆ rend()

template<typename TImage>
reverse_iterator itk::ImageBufferRange< TImage >::rend ( ) const
inlinenoexcept

Returns a reverse 'end iterator' for this range.

Definition at line 619 of file itkImageBufferRange.h.

References itk::ImageBufferRange< TImage >::begin().

Referenced by itk::ImageBufferRange< TImage >::crend().

◆ size()

template<typename TImage>
vcl_size_t itk::ImageBufferRange< TImage >::size ( ) const
inlinenoexcept

Returns the size of the range, that is the number of pixels.

Definition at line 641 of file itkImageBufferRange.h.

References itk::ImageBufferRange< TImage >::m_NumberOfPixels.

Referenced by itk::ImageBufferRange< TImage >::operator[]().

Member Data Documentation

◆ IsImageTypeConst

template<typename TImage>
constexpr bool itk::ImageBufferRange< TImage >::IsImageTypeConst = std::is_const_v<TImage>
staticconstexprprivate

Definition at line 485 of file itkImageBufferRange.h.

◆ m_ImageBufferPointer

template<typename TImage>
QualifiedInternalPixelType* itk::ImageBufferRange< TImage >::m_ImageBufferPointer = nullptr
private

◆ m_NumberOfPixels

template<typename TImage>
SizeValueType itk::ImageBufferRange< TImage >::m_NumberOfPixels = 0
private

◆ m_OptionalAccessorFunctor

template<typename TImage>
OptionalAccessorFunctorType itk::ImageBufferRange< TImage >::m_OptionalAccessorFunctor
private

◆ SupportsDirectPixelAccess

template<typename TImage>
constexpr bool itk::ImageBufferRange< TImage >::SupportsDirectPixelAccess
staticconstexprprivate
Initial value:
=
std::is_same_v<PixelType, InternalPixelType> &&
std::is_same_v<typename TImage::AccessorType, DefaultPixelAccessor<PixelType>> &&
std::is_same_v<AccessorFunctorType, DefaultPixelAccessorFunctor<std::remove_const_t<TImage>>>

Definition at line 84 of file itkImageBufferRange.h.

◆ UsingPointerAsIterator

template<typename TImage>
constexpr bool itk::ImageBufferRange< TImage >::UsingPointerAsIterator = SupportsDirectPixelAccess
staticconstexprprivate

Definition at line 90 of file itkImageBufferRange.h.


The documentation for this class was generated from the following file:
itk::ImageBufferRange::ImageBufferRange
ImageBufferRange()=default