Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::ImagePixelReadAccessor< TPixel, VDimension > Class Template Reference

Gives locked and index-based read access for a particular image part. More...

#include <mitkImagePixelReadAccessor.h>

Inheritance diagram for mitk::ImagePixelReadAccessor< TPixel, VDimension >:
Collaboration diagram for mitk::ImagePixelReadAccessor< TPixel, VDimension >:

Public Types

typedef ImagePixelAccessor< TPixel, VDimension > ImagePixelAccessorType
 
typedef itk::SmartPointer< mitk::Image > ImagePointer
 
typedef itk::SmartPointer< const mitk::Image > ImageConstPointer
 
- Public Types inherited from mitk::ImagePixelAccessor< TPixel, 3 >
typedef itk::Index< VDimension > IndexType
 
typedef ImagePixelAccessor< TPixel, VDimension > ImagePixelAccessorType
 
typedef Image::ConstPointer ImageConstPointer
 

Public Member Functions

 ImagePixelReadAccessor (ImageConstPointer iP, const ImageDataItem *iDI=nullptr, int OptionFlags=ImageAccessorBase::DefaultBehavior)
 Instantiates a mitk::ImageReadAccessor (see its doxygen page for more details) More...
 
 ImagePixelReadAccessor (ImagePointer iP, const ImageDataItem *iDI=nullptr, int OptionFlags=ImageAccessorBase::DefaultBehavior)
 Instantiates a mitk::ImageReadAccessor from an Image smart pointer. More...
 
 ImagePixelReadAccessor (Image *iP, const ImageDataItem *iDI=nullptr, int OptionFlags=ImageAccessorBase::DefaultBehavior)
 Instantiates a mitk::ImageReadAccessor from a non-const Image raw pointer. More...
 
 ImagePixelReadAccessor (const Image *iP, const ImageDataItem *iDI=nullptr, int OptionFlags=ImageAccessorBase::DefaultBehavior)
 Instantiates a mitk::ImageReadAccessor from a const Image raw pointer. More...
 
 ~ImagePixelReadAccessor () override
 
const TPixel & GetPixelByIndex (const itk::Index< VDimension > &idx) const
 
itk::VariableLengthVector< TPixel > GetConsecutivePixelsAsVector (const itk::Index< VDimension > &idx, int nrComponents) const
 Returns consecutive pixel values starting at a given index as a variable length vector. More...
 
const TPixel & GetPixelByIndexSafe (const itk::Index< VDimension > &idx) const
 
const TPixel & GetPixelByWorldCoordinates (mitk::Point3D position)
 
const TPixel & GetPixelByWorldCoordinates (mitk::Point3D position, unsigned int timestep)
 
const TPixel * GetData () const
 Gives const access to the data. More...
 
- Public Member Functions inherited from mitk::ImagePixelAccessor< TPixel, 3 >
int GetDimension (int i) const
 Get the size of the specified dimension from the underlying ImageDataItem. More...
 

Additional Inherited Members

- Protected Member Functions inherited from mitk::ImagePixelAccessor< TPixel, 3 >
 ImagePixelAccessor (ImageConstPointer iP, const mitk::ImageDataItem *iDI)
 Construct the accessor from an image and an optional ImageDataItem. More...
 
virtual ~ImagePixelAccessor ()
 Destructor. More...
 
void CheckData (const Image *image)
 Validate that the accessor dimensions and pixel type match the image. More...
 
unsigned int GetOffset (const IndexType &idx) const
 Compute the linear memory offset for a given multi-dimensional image index. More...
 
- Protected Attributes inherited from mitk::ImagePixelAccessor< TPixel, 3 >
const ImageDataItem * m_ImageDataItem
 Holds the specified ImageDataItem for pixel data access. More...
 
BaseGeometry::Pointer m_Geometry
 Pointer to the used Geometry. Since Geometry can be different to the Image (if memory was forced to be coherent) it is necessary to store Geometry separately. More...
 
itk::ImageRegion< VDimension > * m_SubRegion
 A Subregion defines an arbitrary area within the image. If no SubRegion is defined, the whole ImageDataItem or Image is regarded. A subregion (e.g. subvolume) can lead to non-coherent memory access where every dimension has a start- and end-offset. More...
 
int m_Options
 Stores all extended properties of an ImageAccessor. The different flags in mitk::ImageAccessorBase::Options can be unified by bitwise operations. More...
 

Detailed Description

template<class TPixel, unsigned int VDimension = 3>
class mitk::ImagePixelReadAccessor< TPixel, VDimension >

Gives locked and index-based read access for a particular image part.

The class provides several get-methods, which allow easy pixel access. It needs to know about pixel type and dimension of its image at compile time.

Template Parameters
TPixelDefines the pixel type.
VDimensionDefines the dimension for accessing data.

Definition at line 35 of file mitkImagePixelReadAccessor.h.

Member Typedef Documentation

◆ ImageConstPointer

template<class TPixel , unsigned int VDimension = 3>
typedef itk::SmartPointer<const mitk::Image> mitk::ImagePixelReadAccessor< TPixel, VDimension >::ImageConstPointer

Definition at line 42 of file mitkImagePixelReadAccessor.h.

◆ ImagePixelAccessorType

template<class TPixel , unsigned int VDimension = 3>
typedef ImagePixelAccessor<TPixel, VDimension> mitk::ImagePixelReadAccessor< TPixel, VDimension >::ImagePixelAccessorType

Definition at line 40 of file mitkImagePixelReadAccessor.h.

◆ ImagePointer

template<class TPixel , unsigned int VDimension = 3>
typedef itk::SmartPointer<mitk::Image> mitk::ImagePixelReadAccessor< TPixel, VDimension >::ImagePointer

Definition at line 41 of file mitkImagePixelReadAccessor.h.

Constructor & Destructor Documentation

◆ ImagePixelReadAccessor() [1/4]

template<class TPixel , unsigned int VDimension = 3>
mitk::ImagePixelReadAccessor< TPixel, VDimension >::ImagePixelReadAccessor ( ImageConstPointer  iP,
const ImageDataItem *  iDI = nullptr,
int  OptionFlags = ImageAccessorBase::DefaultBehavior 
)
inline

Instantiates a mitk::ImageReadAccessor (see its doxygen page for more details)

Parameters
iPspecifies the associated Image
iDIspecifies the allocated image part
OptionFlagsproperties from mitk::ImageAccessorBase::Options can be chosen and assembled with bitwise unification.
Exceptions
mitk::Exceptionif the Constructor was created inappropriately
mitk::MemoryIsLockedExceptionif requested image area is exclusively locked and mitk::ImageAccessorBase::ExceptionIfLocked is set in OptionFlags

Includes a check if typeid of PixelType coincides with templated TPixel and a check if VDimension equals to the Dimension of the Image.

Definition at line 56 of file mitkImagePixelReadAccessor.h.

◆ ImagePixelReadAccessor() [2/4]

template<class TPixel , unsigned int VDimension = 3>
mitk::ImagePixelReadAccessor< TPixel, VDimension >::ImagePixelReadAccessor ( ImagePointer  iP,
const ImageDataItem *  iDI = nullptr,
int  OptionFlags = ImageAccessorBase::DefaultBehavior 
)
inline

Instantiates a mitk::ImageReadAccessor from an Image smart pointer.

Definition at line 64 of file mitkImagePixelReadAccessor.h.

◆ ImagePixelReadAccessor() [3/4]

template<class TPixel , unsigned int VDimension = 3>
mitk::ImagePixelReadAccessor< TPixel, VDimension >::ImagePixelReadAccessor ( Image *  iP,
const ImageDataItem *  iDI = nullptr,
int  OptionFlags = ImageAccessorBase::DefaultBehavior 
)
inline

Instantiates a mitk::ImageReadAccessor from a non-const Image raw pointer.

Definition at line 72 of file mitkImagePixelReadAccessor.h.

◆ ImagePixelReadAccessor() [4/4]

template<class TPixel , unsigned int VDimension = 3>
mitk::ImagePixelReadAccessor< TPixel, VDimension >::ImagePixelReadAccessor ( const Image *  iP,
const ImageDataItem *  iDI = nullptr,
int  OptionFlags = ImageAccessorBase::DefaultBehavior 
)
inline

Instantiates a mitk::ImageReadAccessor from a const Image raw pointer.

Definition at line 80 of file mitkImagePixelReadAccessor.h.

◆ ~ImagePixelReadAccessor()

template<class TPixel , unsigned int VDimension = 3>
mitk::ImagePixelReadAccessor< TPixel, VDimension >::~ImagePixelReadAccessor ( )
inlineoverride

Destructor informs Image to unlock memory.

Definition at line 88 of file mitkImagePixelReadAccessor.h.

Member Function Documentation

◆ GetConsecutivePixelsAsVector()

template<class TPixel , unsigned int VDimension = 3>
itk::VariableLengthVector<TPixel> mitk::ImagePixelReadAccessor< TPixel, VDimension >::GetConsecutivePixelsAsVector ( const itk::Index< VDimension > &  idx,
int  nrComponents 
) const
inline

Returns consecutive pixel values starting at a given index as a variable length vector.

Parameters
idxThe starting index in the image.
nrComponentsThe number of consecutive components to read.
Returns
A variable length vector containing the requested pixel components.

Definition at line 102 of file mitkImagePixelReadAccessor.h.

References mitk::ImageReadAccessor::GetImage(), mitk::PixelType::GetNumberOfComponents(), mitk::ImagePixelAccessor< TPixel, VDimension >::GetOffset(), mitk::Image::GetPixelType(), and mitk::ImageAccessorBase::m_AddressBegin.

Referenced by mitk::FastSinglePixelAccess().

◆ GetData()

template<class TPixel , unsigned int VDimension = 3>
const TPixel* mitk::ImagePixelReadAccessor< TPixel, VDimension >::GetData ( ) const
inline

Gives const access to the data.

Definition at line 159 of file mitkImagePixelReadAccessor.h.

References mitk::ImageAccessorBase::m_AddressBegin.

◆ GetPixelByIndex()

template<class TPixel , unsigned int VDimension = 3>
const TPixel& mitk::ImagePixelReadAccessor< TPixel, VDimension >::GetPixelByIndex ( const itk::Index< VDimension > &  idx) const
inline

◆ GetPixelByIndexSafe()

template<class TPixel , unsigned int VDimension = 3>
const TPixel& mitk::ImagePixelReadAccessor< TPixel, VDimension >::GetPixelByIndexSafe ( const itk::Index< VDimension > &  idx) const
inline

Extends GetPixel by integrating index validation to prevent overflow.

Exceptions
mitk::Exceptionin case of overflow

Definition at line 114 of file mitkImagePixelReadAccessor.h.

References mitk::ImagePixelAccessor< TPixel, VDimension >::GetOffset(), mitk::ImageAccessorBase::m_AddressBegin, mitk::ImageAccessorBase::m_AddressEnd, and mitkThrow.

◆ GetPixelByWorldCoordinates() [1/2]

template<class TPixel , unsigned int VDimension = 3>
const TPixel& mitk::ImagePixelReadAccessor< TPixel, VDimension >::GetPixelByWorldCoordinates ( mitk::Point3D  position)
inline

Returns a const reference to the pixel at given world coordinate - works only with three-dimensional ImageAccessor

Definition at line 131 of file mitkImagePixelReadAccessor.h.

References mitk::BaseData::GetGeometry(), mitk::ImageReadAccessor::GetImage(), mitk::ImagePixelReadAccessor< TPixel, VDimension >::GetPixelByIndex(), and mitk::BaseGeometry::WorldToIndex().

◆ GetPixelByWorldCoordinates() [2/2]

template<class TPixel , unsigned int VDimension = 3>
const TPixel& mitk::ImagePixelReadAccessor< TPixel, VDimension >::GetPixelByWorldCoordinates ( mitk::Point3D  position,
unsigned int  timestep 
)
inline

Returns a const reference to the pixel at given world coordinate - works only with four-dimensional ImageAccessor

Definition at line 142 of file mitkImagePixelReadAccessor.h.

References mitk::BaseData::GetGeometry(), mitk::ImageReadAccessor::GetImage(), mitk::ImagePixelReadAccessor< TPixel, VDimension >::GetPixelByIndex(), mitk::BaseData::GetTimeSteps(), and mitk::BaseGeometry::WorldToIndex().


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