ITK  5.0.0
Insight Segmentation and Registration Toolkit
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | List of all members
itk::Index< VDimension > Struct Template Referencefinal

#include <itkIndex.h>

+ Inheritance diagram for itk::Index< VDimension >:

Detailed Description

template<unsigned int VDimension = 2>
struct itk::Index< VDimension >

Represent a n-dimensional index in a n-dimensional image.

Index is a templated class to represent a multi-dimensional index, i.e. (i,j,k,...). Index is templated over the dimension of the index. ITK assumes the first element of an index is the fastest moving index.

For efficiency sake, Index does not define a default constructor, a copy constructor, or an operator=. We rely on the compiler to provide efficient bitwise copies.

Index is an "aggregate" class. Its data is public (m_InternalArray) allowing for fast and convenient instantiations/assignments.

The following syntax for assigning an aggregate type like this is allowed/suggested:

Index<3> var{{ 256, 256, 20 }}; // Also prevent narrowing conversions Index<3> var = {{ 256, 256, 20 }};

The doubled braces {{ and }} are required to prevent `gcc -Wall' (and perhaps other compilers) from complaining about a partly bracketed initializer.

As an aggregate type that is intended to provide highest performance characteristics, this class is not appropriate to inherit from, so setting this struct as final.

Wiki Examples:
Examples:
SphinxExamples/src/Core/Common/AddOffsetToIndex/Code.cxx, SphinxExamples/src/Core/Common/CreateAIndex/Code.cxx, SphinxExamples/src/Core/Common/CreateAnother/Code.cxx, SphinxExamples/src/Filtering/ImageGrid/ResampleAnImage/Code.cxx, WikiExamples/Curves/ContourMeanDistanceImageFilter.cxx, WikiExamples/Developer/ImageFilter.cxx, WikiExamples/Developer/InplaceImageFilter.cxx, WikiExamples/EdgesAndGradients/SobelEdgeDetectionImageFilter.cxx, WikiExamples/Functions/MedianImageFunction.cxx, WikiExamples/Functions/NeighborhoodOperatorImageFunction.cxx, WikiExamples/ImageProcessing/ApproximateSignedDistanceMapImageFilter.cxx, WikiExamples/ImageProcessing/BinaryFunctorImageFilter.cxx, WikiExamples/ImageProcessing/BinaryFunctorImageFilterCustom.cxx, WikiExamples/ImageProcessing/BinaryThinningImageFilter.cxx, WikiExamples/ImageProcessing/Compose3DCovariantVectorImageFilter.cxx, WikiExamples/ImageProcessing/DanielssonDistanceMapImageFilter.cxx, WikiExamples/ImageProcessing/ExtractImageFilter.cxx, WikiExamples/ImageProcessing/ImageAdaptorExtractVectorComponent.cxx, WikiExamples/ImageProcessing/ImageFilterOnARegion.cxx, WikiExamples/ImageProcessing/ManuallyRemovingLabels.cxx, WikiExamples/ImageProcessing/MultiplyByConstantImageFilter.cxx, WikiExamples/ImageProcessing/NthElementImageAdaptor.cxx, WikiExamples/ImageProcessing/ObjectByObjectLabelMapFilter.cxx, WikiExamples/ImageProcessing/ResampleImageFilter.cxx, WikiExamples/ImageProcessing/RGBToLuminanceImageFilter.cxx, WikiExamples/ImageProcessing/ScaleTransform.cxx, WikiExamples/ImageProcessing/SignedDanielssonDistanceMapImageFilter.cxx, WikiExamples/ImageProcessing/SignedMaurerDistanceMapImageFilter.cxx, WikiExamples/ImageProcessing/ZeroCrossingImageFilter.cxx, WikiExamples/Images/FFTNormalizedCorrelationImageFilter.cxx, WikiExamples/Images/ImageRegion.cxx, WikiExamples/Images/Index.cxx, WikiExamples/Images/MaskedFFTNormalizedCorrelationImageFilter.cxx, WikiExamples/Images/MaskNeighborhoodOperatorImageFilter.cxx, WikiExamples/Images/NormalizedCorrelationImageFilter.cxx, WikiExamples/Morphology/BinaryMorphologicalClosingImageFilter.cxx, WikiExamples/Morphology/BinaryMorphologicalOpeningImageFilter.cxx, WikiExamples/Segmentation/ContourExtractor2DImageFilter.cxx, WikiExamples/Segmentation/SimpleContourExtractorImageFilter.cxx, WikiExamples/Segmentation/WatershedImageFilter.cxx, WikiExamples/SimpleOperations/BresenhamLine.cxx, WikiExamples/SimpleOperations/DistanceBetweenIndices.cxx, WikiExamples/SimpleOperations/Offset.cxx, WikiExamples/SimpleOperations/ParaviewColormap.cxx, WikiExamples/SimpleOperations/PixelInsideRegion.cxx, WikiExamples/SimpleOperations/RequestedRegion.cxx, WikiExamples/SimpleOperations/ScalarToRGBColormapImageFilter.cxx, WikiExamples/SimpleOperations/WidthHeight.cxx, WikiExamples/SpectralAnalysis/ForwardFFTImageFilter.cxx, WikiExamples/SpectralAnalysis/InverseFFTImageFilter.cxx, WikiExamples/SpectralAnalysis/VnlFFTRealToComplexConjugateImageFilter.cxx, WikiExamples/Statistics/ImageToHistogramFilterGrayscale.cxx, WikiExamples/Statistics/ImageToHistogramFilterRGB.cxx, WikiExamples/Statistics/ImageToHistogramFilterVectorImage.cxx, WikiExamples/VectorImages/JoinImageFilter.cxx, WikiExamples/VectorImages/VectorImageToImageAdaptor.cxx, WikiExamples/VectorImages/VectorNeighborhoodIterator.cxx, and WikiExamples/VectorImages/VectorResampleImageFilter.cxx.

Definition at line 66 of file itkIndex.h.

Public Types

using const_iterator = const value_type *
 
using const_reference = const value_type &
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 
using difference_type = std::ptrdiff_t
 
using IndexType = Index< VDimension >
 
using IndexValueType = ::itk::IndexValueType
 
using iterator = value_type *
 
using OffsetType = Offset< VDimension >
 
using OffsetValueType = ::itk::OffsetValueType
 
using reference = value_type &
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using Self = Index
 
using size_type = unsigned int
 
using SizeType = Size< VDimension >
 
using value_type = ::itk::IndexValueType
 

Public Member Functions

void assign (const value_type &newValue)
 
reference at (size_type pos)
 
const_reference at (size_type pos) const
 
reference back ()
 
const_reference back () const
 
iterator begin ()
 
const_iterator begin () const
 
IndexValueTypedata ()
 
const IndexValueTypedata () const
 
constexpr bool empty () const
 
iterator end ()
 
const_iterator end () const
 
void Fill (IndexValueType value)
 
reference front ()
 
const_reference front () const
 
IndexValueType GetElement (unsigned long element) const
 
const IndexValueTypeGetIndex () const
 
constexpr size_type max_size () const
 
const Self operator* (const SizeType &vec) const
 
const Self operator+ (const SizeType &sz) const
 
const Self operator+ (const OffsetType &offset) const
 
const Self operator- (const SizeType &sz) const
 
const Self operator- (const OffsetType &off) const
 
const OffsetType operator- (const Self &vec) const
 
reference operator[] (size_type pos)
 
const_reference operator[] (size_type pos) const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
void SetElement (unsigned long element, IndexValueType val)
 
void SetIndex (const IndexValueType val[VDimension])
 
constexpr size_type size () const
 
void swap (Index &other)
 
const Selfoperator+= (const SizeType &sz)
 
const Selfoperator-= (const SizeType &sz)
 
const Selfoperator+= (const OffsetType &offset)
 
const Selfoperator-= (const OffsetType &offset)
 
template<typename TCoordRep >
void CopyWithRound (const FixedArray< TCoordRep, VDimension > &point)
 
template<typename TCoordRep >
void CopyWithCast (const FixedArray< TCoordRep, VDimension > &point)
 

Static Public Member Functions

static Self GetBasisIndex (unsigned int dim)
 
static constexpr unsigned int GetIndexDimension ()
 

Public Attributes

IndexValueType m_InternalArray [VDimension]
 

Static Public Attributes

static constexpr unsigned int Dimension = VDimension
 

Private Member Functions

void ExceptionThrowingBoundsCheck (size_type pos) const
 

Member Typedef Documentation

template<unsigned int VDimension = 2>
using itk::Index< VDimension >::const_iterator = const value_type *

Definition at line 318 of file itkIndex.h.

template<unsigned int VDimension = 2>
using itk::Index< VDimension >::const_reference = const value_type &

Definition at line 316 of file itkIndex.h.

template<unsigned int VDimension = 2>
using itk::Index< VDimension >::const_reverse_iterator = std::reverse_iterator<const_iterator>

Definition at line 322 of file itkIndex.h.

template<unsigned int VDimension = 2>
using itk::Index< VDimension >::difference_type = std::ptrdiff_t

Definition at line 320 of file itkIndex.h.

template<unsigned int VDimension = 2>
using itk::Index< VDimension >::IndexType = Index<VDimension>

Compatible Index and value type alias

Definition at line 76 of file itkIndex.h.

template<unsigned int VDimension = 2>
using itk::Index< VDimension >::IndexValueType = ::itk::IndexValueType

Definition at line 77 of file itkIndex.h.

template<unsigned int VDimension = 2>
using itk::Index< VDimension >::iterator = value_type *

Definition at line 317 of file itkIndex.h.

template<unsigned int VDimension = 2>
using itk::Index< VDimension >::OffsetType = Offset<VDimension>

Compatible Offset and Offset value type alias.

Definition at line 83 of file itkIndex.h.

template<unsigned int VDimension = 2>
using itk::Index< VDimension >::OffsetValueType = ::itk::OffsetValueType

Definition at line 84 of file itkIndex.h.

template<unsigned int VDimension = 2>
using itk::Index< VDimension >::reference = value_type &

Definition at line 315 of file itkIndex.h.

template<unsigned int VDimension = 2>
using itk::Index< VDimension >::reverse_iterator = std::reverse_iterator<iterator>

Definition at line 321 of file itkIndex.h.

template<unsigned int VDimension = 2>
using itk::Index< VDimension >::Self = Index

Standard class type aliases.

Definition at line 73 of file itkIndex.h.

template<unsigned int VDimension = 2>
using itk::Index< VDimension >::size_type = unsigned int

Definition at line 319 of file itkIndex.h.

template<unsigned int VDimension = 2>
using itk::Index< VDimension >::SizeType = Size<VDimension>

Compatible Size type alias.

Definition at line 80 of file itkIndex.h.

template<unsigned int VDimension = 2>
using itk::Index< VDimension >::value_type = ::itk::IndexValueType

Mirror the std::array type aliases and member function so that the Index class can be treated as a container class in a way that is similar to the std::array.

Definition at line 314 of file itkIndex.h.

Member Function Documentation

template<unsigned int VDimension = 2>
void itk::Index< VDimension >::assign ( const value_type newValue)
inline

Mirror behavior of the std::array manipulations See std::array for documentation on these methods

Definition at line 328 of file itkIndex.h.

template<unsigned int VDimension = 2>
reference itk::Index< VDimension >::at ( size_type  pos)
inline

Definition at line 403 of file itkIndex.h.

template<unsigned int VDimension = 2>
const_reference itk::Index< VDimension >::at ( size_type  pos) const
inline

Definition at line 408 of file itkIndex.h.

template<unsigned int VDimension = 2>
reference itk::Index< VDimension >::back ( )
inline
template<unsigned int VDimension = 2>
const_reference itk::Index< VDimension >::back ( ) const
inline

Definition at line 428 of file itkIndex.h.

template<unsigned int VDimension = 2>
iterator itk::Index< VDimension >::begin ( )
inline
template<unsigned int VDimension = 2>
const_iterator itk::Index< VDimension >::begin ( ) const
inline

Definition at line 343 of file itkIndex.h.

template<unsigned int VDimension = 2>
template<typename TCoordRep >
void itk::Index< VDimension >::CopyWithCast ( const FixedArray< TCoordRep, VDimension > &  point)
inline

Copy values from a FixedArray by casting each one of the components

Definition at line 293 of file itkIndex.h.

template<unsigned int VDimension = 2>
template<typename TCoordRep >
void itk::Index< VDimension >::CopyWithRound ( const FixedArray< TCoordRep, VDimension > &  point)
inline

Copy values from a FixedArray by rounding each one of the components

Definition at line 282 of file itkIndex.h.

template<unsigned int VDimension = 2>
IndexValueType* itk::Index< VDimension >::data ( )
inline

Definition at line 433 of file itkIndex.h.

template<unsigned int VDimension = 2>
const IndexValueType* itk::Index< VDimension >::data ( ) const
inline

Definition at line 438 of file itkIndex.h.

template<unsigned int VDimension = 2>
constexpr bool itk::Index< VDimension >::empty ( ) const
inline

Definition at line 388 of file itkIndex.h.

template<unsigned int VDimension = 2>
iterator itk::Index< VDimension >::end ( )
inline

Definition at line 348 of file itkIndex.h.

Referenced by itk::operator==(), and itk::swap().

template<unsigned int VDimension = 2>
const_iterator itk::Index< VDimension >::end ( ) const
inline

Definition at line 353 of file itkIndex.h.

template<unsigned int VDimension = 2>
void itk::Index< VDimension >::ExceptionThrowingBoundsCheck ( size_type  pos) const
inlineprivate

Definition at line 444 of file itkIndex.h.

template<unsigned int VDimension = 2>
void itk::Index< VDimension >::Fill ( IndexValueType  value)
inline
template<unsigned int VDimension = 2>
reference itk::Index< VDimension >::front ( )
inline

Definition at line 413 of file itkIndex.h.

template<unsigned int VDimension = 2>
const_reference itk::Index< VDimension >::front ( ) const
inline

Definition at line 418 of file itkIndex.h.

template<unsigned int VDimension>
Index< VDimension > itk::Index< VDimension >::GetBasisIndex ( unsigned int  dim)
static

Return a basis vector of the form [0, ..., 0, 1, 0, ... 0] where the "1" is positioned in the location specified by the parameter "dim". Valid values of "dim" are 0, ..., VDimension-1.

Definition at line 457 of file itkIndex.h.

References itk::Index< VDimension >::m_InternalArray.

template<unsigned int VDimension = 2>
IndexValueType itk::Index< VDimension >::GetElement ( unsigned long  element) const
inline

Gets the value of one of the elements. This method is mainly intended to facilitate the access to elements from Tcl and Python where C++ notation is not very convenient.

Warning
No bound checking is performed
See Also
GetIndex()
SetElement()

Definition at line 250 of file itkIndex.h.

template<unsigned int VDimension = 2>
const IndexValueType* itk::Index< VDimension >::GetIndex ( ) const
inline
template<unsigned int VDimension = 2>
static constexpr unsigned int itk::Index< VDimension >::GetIndexDimension ( )
inlinestatic

Get the dimension.

Definition at line 90 of file itkIndex.h.

template<unsigned int VDimension = 2>
constexpr size_type itk::Index< VDimension >::max_size ( ) const
inline

Definition at line 383 of file itkIndex.h.

template<unsigned int VDimension = 2>
const Self itk::Index< VDimension >::operator* ( const SizeType vec) const
inline

Multiply an index by a size (elementwise product).

Definition at line 204 of file itkIndex.h.

template<unsigned int VDimension = 2>
const Self itk::Index< VDimension >::operator+ ( const SizeType sz) const
inline

Add a size to an index.

Definition at line 97 of file itkIndex.h.

template<unsigned int VDimension = 2>
const Self itk::Index< VDimension >::operator+ ( const OffsetType offset) const
inline

Add an offset to an index.

Definition at line 144 of file itkIndex.h.

template<unsigned int VDimension = 2>
const Self& itk::Index< VDimension >::operator+= ( const SizeType sz)
inline

Increment index by a size.

Definition at line 109 of file itkIndex.h.

template<unsigned int VDimension = 2>
const Self& itk::Index< VDimension >::operator+= ( const OffsetType offset)
inline

Increment index by an offset.

Definition at line 156 of file itkIndex.h.

template<unsigned int VDimension = 2>
const Self itk::Index< VDimension >::operator- ( const SizeType sz) const
inline

Subtract a size from an index.

Definition at line 121 of file itkIndex.h.

template<unsigned int VDimension = 2>
const Self itk::Index< VDimension >::operator- ( const OffsetType off) const
inline

Subtract an offset from an index.

Definition at line 178 of file itkIndex.h.

template<unsigned int VDimension = 2>
const OffsetType itk::Index< VDimension >::operator- ( const Self vec) const
inline

Subtract two indices.

Definition at line 190 of file itkIndex.h.

template<unsigned int VDimension = 2>
const Self& itk::Index< VDimension >::operator-= ( const SizeType sz)
inline

Decrement index by a size.

Definition at line 133 of file itkIndex.h.

template<unsigned int VDimension = 2>
const Self& itk::Index< VDimension >::operator-= ( const OffsetType offset)
inline

Decrement index by an offset.

Definition at line 167 of file itkIndex.h.

template<unsigned int VDimension = 2>
reference itk::Index< VDimension >::operator[] ( size_type  pos)
inline

Definition at line 393 of file itkIndex.h.

template<unsigned int VDimension = 2>
const_reference itk::Index< VDimension >::operator[] ( size_type  pos) const
inline

Definition at line 398 of file itkIndex.h.

template<unsigned int VDimension = 2>
reverse_iterator itk::Index< VDimension >::rbegin ( )
inline

Definition at line 358 of file itkIndex.h.

template<unsigned int VDimension = 2>
const_reverse_iterator itk::Index< VDimension >::rbegin ( ) const
inline

Definition at line 363 of file itkIndex.h.

template<unsigned int VDimension = 2>
reverse_iterator itk::Index< VDimension >::rend ( )
inline

Definition at line 368 of file itkIndex.h.

template<unsigned int VDimension = 2>
const_reverse_iterator itk::Index< VDimension >::rend ( ) const
inline

Definition at line 373 of file itkIndex.h.

template<unsigned int VDimension = 2>
void itk::Index< VDimension >::SetElement ( unsigned long  element,
IndexValueType  val 
)
inline

Sets the value of one of the elements. This method is mainly intended to facilitate the access to elements from Tcl and Python where C++ notation is not very convenient.

Warning
No bound checking is performed.
See Also
SetIndex()
GetElement()

Definition at line 239 of file itkIndex.h.

template<unsigned int VDimension = 2>
void itk::Index< VDimension >::SetIndex ( const IndexValueType  val[VDimension])
inline

Set the index. Try to prototype this function so that val has to point to a block of memory that is the appropriate size.

See Also
GetIndex()

Definition at line 226 of file itkIndex.h.

Referenced by itk::BoxMeanCalculatorFunction(), itk::BoxSigmaCalculatorFunction(), and itk::ImageConstIterator< RLEImage< TPixel, VImageDimension, CounterType > >::SetIndex().

template<unsigned int VDimension = 2>
constexpr size_type itk::Index< VDimension >::size ( ) const
inline

Definition at line 378 of file itkIndex.h.

template<unsigned int VDimension = 2>
void itk::Index< VDimension >::swap ( Index< VDimension > &  other)
inline

Definition at line 333 of file itkIndex.h.

Member Data Documentation

template<unsigned int VDimension = 2>
constexpr unsigned int itk::Index< VDimension >::Dimension = VDimension
static

Dimension constant

Definition at line 87 of file itkIndex.h.

template<unsigned int VDimension = 2>
IndexValueType itk::Index< VDimension >::m_InternalArray[VDimension]

Index is an "aggregate" class. Its data is public (m_InternalArray) allowing for fast and convenient instantiations/assignments. ( See main class documentation for an example of initialization)

Definition at line 276 of file itkIndex.h.

Referenced by itk::Index< VDimension >::GetBasisIndex(), itk::Index< Self::ImageDimension >::operator-(), and itk::MultiThreaderBase::ParallelizeImageRegion().


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