Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mirtk::ConstImageIterator Class Reference

#include <ConstImageIterator.h>

Inheritance diagram for mirtk::ConstImageIterator:
Inheritance graph
Collaboration diagram for mirtk::ConstImageIterator:
Collaboration graph

Public Member Functions

int ColumnStride () const
 Get stride between columns in number of voxels.
 
 ConstImageIterator (const ImageAttributes &, int)
 Constructor.
 
 ConstImageIterator (const ImageAttributes &, const void *=NULL, int=MIRTK_VOXEL_UNKNOWN)
 Constructor.
 
 ConstImageIterator (const BaseImage &)
 Constructor.
 
 ConstImageIterator (const BaseImage *)
 Constructor.
 
 ConstImageIterator (const ConstImageIterator &)
 Copy constructor.
 
template<class VoxelType >
const VoxelType * Current () const
 
template<class VoxelType >
const VoxelType * Current (int) const
 
int FrameStride () const
 Get stride between frames in number of voxels.
 
void GoToBegin ()
 Go to begin of region.
 
void GoToCenter ()
 Go to center of region.
 
void GoToEnd ()
 Go to end of region.
 
void GoToIndex (int)
 Go to voxel with specified index relative to entire image.
 
void GoToPos (int)
 Go to specified position within image region.
 
void GoToVoxel (int, int, int=-1, int=-1)
 Go to voxel with specified coordinates relative to entire image.
 
void GoToVoxel (const Vector4D< int > &)
 Go to voxel with specified coordinates relative to entire image.
 
int Index () const
 Index of voxel at current iterator position.
 
int IndexToPos (int) const
 Convert voxel index to iterator position.
 
void IndexToVoxel (int, int &, int &) const
 Convert iterator position to voxel coordinates.
 
void IndexToVoxel (int, int &, int &, int &) const
 Convert iterator position to voxel coordinates.
 
void IndexToVoxel (int, int &, int &, int &, int &) const
 Convert iterator position to voxel coordinates.
 
void IndexToVoxel (int, Vector4D< int > &) const
 Convert iterator position to voxel coordinates.
 
bool IsAtBegin () const
 Whether iterator reached the start of the region and is invalid now.
 
bool IsAtEnd () const
 Whether iterator reached the end of the region and is invalid now.
 
bool IsImageSequence () const
 
bool IsScalar () const
 
bool IsScalarImage () const
 
bool IsSequence () const
 
int LineStride () const
 Get stride between rows/lines in number of voxels.
 
template<class VoxelType >
void Move (const VoxelType *&) const
 
template<class VoxelType >
void Move (VoxelType *&) const
 
template<class VoxelType >
const VoxelType * Next ()
 
template<class VoxelType >
const VoxelType * Next (int)
 
int NumberOfChannels () const
 Get number of channels in image region.
 
int NumberOfComponents () const
 Get number of vector components considered.
 
int NumberOfFrames () const
 Get number of frames in image region.
 
int NumberOfImageChannels () const
 
int NumberOfImageVoxels () const
 Number of voxels in the entire image.
 
int NumberOfSequenceFrames () const
 
int NumberOfVectorComponents () const
 
int NumberOfVoxels () const
 Number of voxels in image region.
 
 operator bool () const
 Whether iterator is valid and not yet at end of region.
 
void operator++ ()
 Pre-increment operator.
 
void operator-- ()
 Pre-decrement operator.
 
ConstImageIteratoroperator= (const ConstImageIterator &)
 Assignment operator.
 
int Pos () const
 Current iterator position within image region.
 
int PosToIndex (int) const
 Convert iterator position to voxel index.
 
void PosToVoxel (int, int &, int &) const
 Convert iterator position to voxel coordinates.
 
void PosToVoxel (int, int &, int &, int &) const
 Convert iterator position to voxel coordinates.
 
void PosToVoxel (int, int &, int &, int &, int &) const
 Convert iterator position to voxel coordinates.
 
void PosToVoxel (int, Vector4D< int > &) const
 Convert iterator position to voxel coordinates.
 
void SetChannel (int, int=1)
 Set temporal region (start and size)
 
void SetChannel (const blocked_range< int > &)
 Set temporal region (start and end)
 
void SetComponent (int, int=1)
 Set temporal region (start and size)
 
void SetComponent (const blocked_range< int > &)
 Set temporal region (start and end)
 
void SetData (const void *, int=MIRTK_VOXEL_UNKNOWN)
 Set raw data pointer to start of entire image.
 
void SetDataType (int)
 Set data type - defines number of bytes per voxel.
 
void SetFrame (int, int=1)
 Set temporal region (start and size)
 
void SetFrame (const blocked_range< int > &)
 Set temporal region (start and end)
 
void SetNeighborhood (int, int, int, int)
 Set 2D neighborhood (center and radius)
 
void SetNeighborhood (int, int, int, int, int, int)
 Set 3D neighborhood (center and radius)
 
void SetNeighborhood (int, int, int, int, int, int, int, int)
 Set 4D neighborhood (center and radius)
 
void SetRegion (int, int, int, int)
 Set 2D image region (start and size)
 
void SetRegion (const blocked_range2d< int > &)
 Set 2D image region (start and end)
 
void SetRegion (int, int, int, int, int, int)
 Set 3D image region (start and size)
 
void SetRegion (const blocked_range3d< int > &)
 Set 3D image region (start and end)
 
void SetRegion (int, int, int, int, int, int, int, int)
 Set 4D image region (start and size)
 
int SliceStride () const
 Get stride between slices in number of voxels.
 
template<class VoxelType >
const VoxelType & Value () const
 
template<class VoxelType >
const VoxelType & Value (int t) const
 
virtual double ValueAsDouble () const
 Get current voxel value casted to double.
 
virtual double ValueAsDouble (int) const
 
void Voxel (int &, int &) const
 Coordinates of voxel at current iterator position.
 
void Voxel (int &, int &, int &) const
 Coordinates of voxel at current iterator position.
 
void Voxel (int &, int &, int &, int &) const
 Coordinates of voxel at current iterator position.
 
int VoxelToIndex (int, int, int=0, int=0) const
 Convert voxel coordinates to index.
 
int VoxelToIndex (const Vector4D< int > &) const
 Convert voxel coordinates to index.
 
int VoxelToPos (int, int, int=0, int=0) const
 Convert voxel cooridnates to iterator position.
 
int VoxelToPos (const Vector4D< int > &) const
 Convert voxel cooridnates to iterator position.
 
virtual ~ConstImageIterator ()
 Destructor.
 

Protected Member Functions

void CalculateStride ()
 Calculate pointer increments.
 
void Initialize ()
 Initialize iterator, called by first GoTo command.
 

Protected Attributes

Vector4D< int > _Begin
 First index of the image region.
 
int _ColumnStride
 Increment in number of bytes (size of voxel type)
 
const char * _Data
 Pointer to begin of entire image.
 
Vector4D< int > _DataSize
 Size of the entire image.
 
Vector4D< int > _End
 Last index of the image region.
 
int _FrameStride
 Increment at end of frame in number of bytes.
 
int _Inc
 Previous pointer increment in number of bytes.
 
Vector4D< int > _Index
 Start index of the image region.
 
bool _IsImageSequence
 Whether the image is a sequence.
 
int _LineStride
 Increment at end of line in number of bytes.
 
const char * _Next
 Pointer to next image voxel.
 
Vector4D< int > _Size
 Size of image region.
 
int _SliceStride
 Increment at end of slice in number of bytes.
 
int _XYZ
 Number of voxels per frame of the image.
 

Detailed Description

Base class of const image iterator

Definition at line 35 of file ConstImageIterator.h.

Member Function Documentation

§ Current() [1/2]

template<class VoxelType >
const VoxelType * mirtk::ConstImageIterator::Current ( ) const
inline

Get pointer to current iterator position

The VoxelType template argument must match the actual scalar type of the image.

Definition at line 1180 of file ConstImageIterator.h.

§ Current() [2/2]

template<class VoxelType >
const VoxelType * mirtk::ConstImageIterator::Current ( int  t) const
inline

Get pointer to current iterator position

The VoxelType template argument must match the actual scalar type of the image.

Parameters
[in]tChannel/Component/Frame stride relative to current iterator position. For example, set iterator region to only the first channel/frame and then access other channels/vector components/frames using this method.

Definition at line 1187 of file ConstImageIterator.h.

§ IsImageSequence()

bool mirtk::ConstImageIterator::IsImageSequence ( ) const
inline

Whether the image is a 3D+t image sequence (i.e., number of voxels in t dimension is greater 1 and dt is not 0)

Definition at line 606 of file ConstImageIterator.h.

§ IsScalar()

bool mirtk::ConstImageIterator::IsScalar ( ) const
inline

Whether the image region is scalar (i.e., number of voxels in t dimension is 1)

Definition at line 652 of file ConstImageIterator.h.

§ IsScalarImage()

bool mirtk::ConstImageIterator::IsScalarImage ( ) const
inline

Whether the image is a scalar image (i.e., number of voxels in t dimension is 1 or dt equal 0)

Definition at line 612 of file ConstImageIterator.h.

§ IsSequence()

bool mirtk::ConstImageIterator::IsSequence ( ) const
inline

Whether the image region is a 3D+t image sequence (i.e., number of voxels in t dimension > 1 and dt > 0)

Definition at line 646 of file ConstImageIterator.h.

§ Move() [1/2]

template<class VoxelType >
void mirtk::ConstImageIterator::Move ( const VoxelType *&  p) const
inline

Move given raw image data pointer to the current iterator position assuming it is at the voxel position at which the iterator has been before

This method is useful when iterating over multiple images with common image attributes simultaneously. An iterator instance associated with one of the images or initialized with the image attributes corresponding to all images is then sufficient to reduce the associated overhead. Raw pointers to the voxel data of the other images can then be moved to the next position using this method after the iterator itself has been incremented or decremented.

Note that after a GoTo method of the iterator has been called, this method moves the raw image data pointer returned by BaseImage::GetScalarPointer to the same position as the iterator was moved to by the GoTo method.

ConstImageIterator it(gradient.GetImageAttributes(), gradient.GetScalarType());
double *gx = gradient.GetPointerToVoxels(0, 0, 0, 0);
double *gy = gradient.GetPointerToVoxels(0, 0, 0, 1);
double *gz = gradient.GetPointerToVoxels(0, 0, 0, 2);
it.GoToBegin();
while (!it.IsAtEnd()) {
// do something with the data
++it; // must be done before moving the other data pointers
it.Move(gx), it.Move(gy), it.Move(gz);
}
it.GoToEnd();
while (!it.IsAtBegin()) {
// do something with the data
--it; // must be done before moving the other data pointers
it.Move(gx), it.Move(gy), it.Move(gz);
}

Definition at line 1238 of file ConstImageIterator.h.

§ Move() [2/2]

template<class VoxelType >
void mirtk::ConstImageIterator::Move ( VoxelType *&  p) const
inline

Move given raw image data pointer to the current iterator position assuming it is at the voxel position at which the iterator has been before

Definition at line 1245 of file ConstImageIterator.h.

§ Next() [1/2]

template<class VoxelType >
const VoxelType * mirtk::ConstImageIterator::Next ( )
inline

Get pointer to current iterator position and post-increment iterator

The VoxelType template argument must match the actual scalar type of the image.

Definition at line 1194 of file ConstImageIterator.h.

§ Next() [2/2]

template<class VoxelType >
const VoxelType * mirtk::ConstImageIterator::Next ( int  t)
inline

Get pointer to current iterator position and post-increment iterator

The VoxelType template argument must match the actual scalar type of the image.

Parameters
[in]tChannel/Component/Frame stride relative to current iterator position. For example, set iterator region to only the first channel/frame and then access other channels/vector components/frames using this method.

Definition at line 1203 of file ConstImageIterator.h.

§ NumberOfImageChannels()

int mirtk::ConstImageIterator::NumberOfImageChannels ( ) const
inline

Get number of image channels (i.e., number of voxels in t dimension if dt <= 0 or 1 otherwise)

Definition at line 624 of file ConstImageIterator.h.

§ NumberOfSequenceFrames()

int mirtk::ConstImageIterator::NumberOfSequenceFrames ( ) const
inline

Get number of iterated frames (i.e., number of voxels in t dimension if dt > 0 or 1 otherwise)

Definition at line 636 of file ConstImageIterator.h.

§ NumberOfVectorComponents()

int mirtk::ConstImageIterator::NumberOfVectorComponents ( ) const
inline

Get number of vector components (i.e., number of voxels in t dimension if dt <= 0 or 1 otherwise)

Definition at line 630 of file ConstImageIterator.h.

§ Value() [1/2]

template<class VoxelType >
const VoxelType & mirtk::ConstImageIterator::Value ( ) const
inline

Get reference to voxel value at current iterator position

The VoxelType template argument must match the actual scalar type of the image.

Definition at line 1212 of file ConstImageIterator.h.

§ Value() [2/2]

template<class VoxelType >
const VoxelType & mirtk::ConstImageIterator::Value ( int  t) const
inline

Get reference to voxel value at current iterator position

The VoxelType template argument must match the actual scalar type of the image.

Parameters
[in]tChannel/Component/Frame stride relative to current iterator position. For example, set iterator region to only the first channel/frame and then access other channels/vector components/frames using this method.

Definition at line 1219 of file ConstImageIterator.h.

§ ValueAsDouble()

double mirtk::ConstImageIterator::ValueAsDouble ( int  t) const
inlinevirtual

Get current voxel value casted to double

Parameters
[in]tChannel/Component/Frame stride relative to current iterator position. For example, set iterator region to only the first channel/frame and then access other channels/vector components/frames using this method.

Reimplemented in mirtk::ConstGenericImageIterator< VoxelType >, and mirtk::GenericImageIterator< VoxelType >.

Definition at line 1231 of file ConstImageIterator.h.


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