ITK  4.9.0
Insight Segmentation and Registration Toolkit
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
itk::Index< VIndexDimension > Class Template Reference

#include <itkIndex.h>

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

Detailed Description

template<unsigned int VIndexDimension = 2>
class itk::Index< VIndexDimension >

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_Index) allowing for fast and convenient instantiations/assignments.

The following syntax for assigning an index is allowed/suggested:

Index<3> index = {{5, 2, 7}};

The double braces {{ and }} are needed to prevent a compiler warning about a partly bracketed initializer.

Remarks
Should there be an itkBoundedIndex to handle bounds checking? Or should there be an API to perform bounded increments in the iterator.
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/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/HistogramToImageFilterGrayscale.cxx, WikiExamples/Statistics/HistogramToImageFilterRGB.cxx, WikiExamples/Statistics/HistogramToImageFilterVectorImage.cxx, WikiExamples/VectorImages/JoinImageFilter.cxx, WikiExamples/VectorImages/VectorImageToImageAdaptor.cxx, WikiExamples/VectorImages/VectorNeighborhoodIterator.cxx, and WikiExamples/VectorImages/VectorResampleImageFilter.cxx.

Definition at line 71 of file itkIndex.h.

Public Types

typedef Index< VIndexDimension > IndexType
 
typedef ::itk::IndexValueType IndexValueType
 
typedef
Functor::IndexLexicographicCompare
< VIndexDimension > 
LexicographicCompare
 
typedef Offset< VIndexDimension > OffsetType
 
typedef ::itk::OffsetValueType OffsetValueType
 
typedef Index Self
 
typedef Size< VIndexDimension > SizeType
 

Public Member Functions

void Fill (IndexValueType value)
 
IndexValueType GetElement (unsigned long element) const
 
const IndexValueTypeGetIndex () const
 
bool operator!= (const Self &vec) const
 
const Self operator* (const SizeType &vec) const
 
const Self operator+ (const SizeType &size) const
 
const Self operator+ (const OffsetType &offset) const
 
const Self operator- (const SizeType &size) const
 
const Self operator- (const OffsetType &off) const
 
const OffsetType operator- (const Self &vec) const
 
bool operator== (const Self &vec) const
 
IndexValueTypeoperator[] (unsigned int dim)
 
IndexValueType operator[] (unsigned int dim) const
 
void SetElement (unsigned long element, IndexValueType val)
 
void SetIndex (const IndexValueType val[VIndexDimension])
 
const Selfoperator+= (const SizeType &size)
 
const Selfoperator-= (const SizeType &size)
 
const Selfoperator+= (const OffsetType &offset)
 
const Selfoperator-= (const OffsetType &offset)
 
template<typename TCoordRep >
void CopyWithRound (const FixedArray< TCoordRep, VIndexDimension > &point)
 
template<typename TCoordRep >
void CopyWithCast (const FixedArray< TCoordRep, VIndexDimension > &point)
 

Static Public Member Functions

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

Public Attributes

IndexValueType m_Index [VIndexDimension]
 

Static Public Attributes

static const unsigned int Dimension = VIndexDimension
 

Member Typedef Documentation

template<unsigned int VIndexDimension = 2>
typedef Index< VIndexDimension > itk::Index< VIndexDimension >::IndexType

Compatible Index and value typedef

Definition at line 78 of file itkIndex.h.

template<unsigned int VIndexDimension = 2>
typedef ::itk::IndexValueType itk::Index< VIndexDimension >::IndexValueType

Definition at line 79 of file itkIndex.h.

template<unsigned int VIndexDimension = 2>
typedef Functor::IndexLexicographicCompare< VIndexDimension > itk::Index< VIndexDimension >::LexicographicCompare

Lexicographic ordering functor type.

Definition at line 95 of file itkIndex.h.

template<unsigned int VIndexDimension = 2>
typedef Offset< VIndexDimension > itk::Index< VIndexDimension >::OffsetType

Compatible Offset and Offset value typedef.

Definition at line 91 of file itkIndex.h.

template<unsigned int VIndexDimension = 2>
typedef ::itk::OffsetValueType itk::Index< VIndexDimension >::OffsetValueType

Definition at line 92 of file itkIndex.h.

template<unsigned int VIndexDimension = 2>
typedef Index itk::Index< VIndexDimension >::Self

Standard class typedefs.

Definition at line 75 of file itkIndex.h.

template<unsigned int VIndexDimension = 2>
typedef Size< VIndexDimension > itk::Index< VIndexDimension >::SizeType

Compatible Size typedef.

Definition at line 88 of file itkIndex.h.

Member Function Documentation

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

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

Definition at line 324 of file itkIndex.h.

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

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

Definition at line 304 of file itkIndex.h.

template<unsigned int VIndexDimension = 2>
void itk::Index< VIndexDimension >::Fill ( IndexValueType  value)
inline
template<unsigned int VIndexDimension>
Index< VIndexDimension > itk::Index< VIndexDimension >::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, ..., VIndexDimension-1.

Definition at line 379 of file itkIndex.h.

References itk::Index< VIndexDimension >::m_Index.

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

Gets the value of one of the elements in the index. 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 282 of file itkIndex.h.

template<unsigned int VIndexDimension = 2>
const IndexValueType* itk::Index< VIndexDimension >::GetIndex ( void  ) const
inline

Get the index. This provides a read only reference to the index.

See Also
SetIndex()
Examples:
WikiExamples/Developer/ImageFilter.cxx, and WikiExamples/Developer/InplaceImageFilter.cxx.

Definition at line 254 of file itkIndex.h.

template<unsigned int VIndexDimension = 2>
static unsigned int itk::Index< VIndexDimension >::GetIndexDimension ( )
inlinestatic

Get the dimension (size) of the index.

Definition at line 85 of file itkIndex.h.

template<unsigned int VIndexDimension = 2>
bool itk::Index< VIndexDimension >::operator!= ( const Self vec) const
inline

Compare two indices.

Definition at line 218 of file itkIndex.h.

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

Multiply an index by a size (elementwise product). This method models a random access Index.

Definition at line 196 of file itkIndex.h.

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

Add a size to an index. This method models a random access Index.

Definition at line 99 of file itkIndex.h.

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

Add an offset to an index.

Definition at line 142 of file itkIndex.h.

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

Increment index by a size. This method models a random access Index.

Definition at line 110 of file itkIndex.h.

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

Increment index by an offset. This method models a random access Index.

Definition at line 153 of file itkIndex.h.

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

Subtract a size from an index. This method models a random access Index.

Definition at line 121 of file itkIndex.h.

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

Subtract an offset from an index.

Definition at line 173 of file itkIndex.h.

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

Subtract two indices. This method models a random access Index.

Definition at line 184 of file itkIndex.h.

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

Decrement index by a size. This method models a random access Index.

Definition at line 132 of file itkIndex.h.

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

Decrement index by an offset. This method models a random access Index.

Definition at line 163 of file itkIndex.h.

template<unsigned int VIndexDimension = 2>
bool itk::Index< VIndexDimension >::operator== ( const Self vec) const
inline

Compare two indices.

Definition at line 207 of file itkIndex.h.

template<unsigned int VIndexDimension = 2>
IndexValueType& itk::Index< VIndexDimension >::operator[] ( unsigned int  dim)
inline

Access an element of the index. Elements are numbered 0, ..., VIndexDimension-1. No bounds checking is performed.

Definition at line 236 of file itkIndex.h.

template<unsigned int VIndexDimension = 2>
IndexValueType itk::Index< VIndexDimension >::operator[] ( unsigned int  dim) const
inline

Access an element of the index. Elements are numbered 0, ..., VIndexDimension-1. This version can only be an rvalue. No bounds checking is performed.

Definition at line 249 of file itkIndex.h.

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

Sets the value of one of the elements in the index. 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 273 of file itkIndex.h.

template<unsigned int VIndexDimension = 2>
void itk::Index< VIndexDimension >::SetIndex ( const IndexValueType  val[VIndexDimension])
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 260 of file itkIndex.h.

Referenced by itk::ImageRegionSplitter< VImageDimension >::GetNumberOfSplitsInternal(), and itk::ImageRegionSplitter< VImageDimension >::GetSplitInternal().

Member Data Documentation

template<unsigned int VIndexDimension = 2>
const unsigned int itk::Index< VIndexDimension >::Dimension = VIndexDimension
static

Dimension constant

Definition at line 82 of file itkIndex.h.

template<unsigned int VIndexDimension = 2>
IndexValueType itk::Index< VIndexDimension >::m_Index[VIndexDimension]

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