Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::ImageReadAccessor Class Reference

Provides locked read-only access to a particular region of image data. More...

#include <mitkImageReadAccessor.h>

Inheritance diagram for mitk::ImageReadAccessor:
Collaboration diagram for mitk::ImageReadAccessor:

Public Types

typedef itk::SmartPointer< Image > ImagePointer
 Smart pointer type for a non-const Image. More...
 
- Public Types inherited from mitk::ImageAccessorBase
enum  Options { DefaultBehavior , ExceptionIfLocked , ForceCoherentMemory , IgnoreLock }
 Option flags that control ImageAccessor behavior. More...
 
typedef itk::SmartPointer< const mitk::Image > ImageConstPointer
 Const smart pointer type for the associated Image. More...
 

Public Member Functions

 ImageReadAccessor (ImageConstPointer image, const ImageDataItem *iDI=nullptr, int OptionFlags=ImageAccessorBase::DefaultBehavior)
 Construct a read accessor for a slice, volume, or entire image. More...
 
 ImageReadAccessor (ImagePointer image, const ImageDataItem *iDI=nullptr, int OptionFlags=ImageAccessorBase::DefaultBehavior)
 Construct a read accessor from a non-const image smart pointer. More...
 
 ImageReadAccessor (const Image *image, const ImageDataItem *iDI=nullptr)
 Construct a read accessor from a raw image pointer (default options). More...
 
 ~ImageReadAccessor () override
 Destructor releases the read lock on the image data. More...
 
- Public Member Functions inherited from mitk::ImageAccessorBase
virtual ~ImageAccessorBase ()
 Virtual destructor. Releases the wait lock if no other accessors are waiting. More...
 
const void * GetData () const
 Get const access to the raw image data. More...
 

Protected Member Functions

const Image * GetImage () const override
 
- Protected Member Functions inherited from mitk::ImageAccessorBase
 ImageAccessorBase (ImageConstPointer iP, const ImageDataItem *iDI=nullptr, int OptionFlags=DefaultBehavior)
 Checks validity of given parameters from inheriting classes and stores those parameters in member variables. More...
 
void Increment ()
 Increments m_WaiterCount. A call of this method is prohibited unless the Mutex m_ReadWriteLock in the mitk::Image class is Locked. More...
 
bool Overlap (const ImageAccessorBase *iAB)
 Computes if there is an Overlap of the image part between this instantiation and another ImageAccessor object. More...
 
void WaitForReleaseOf (ImageAccessorWaitLock *wL)
 Uses the WaitLock to wait for another ImageAccessor. More...
 
void PreventRecursiveMutexLock (ImageAccessorBase *iAB)
 Prevents a recursive mutex lock by comparing thread ids of competing image accessors. More...
 

Additional Inherited Members

- Protected Attributes inherited from mitk::ImageAccessorBase
itk::ImageRegion< 4 > * m_SubRegion
 
void * m_AddressBegin
 
void * m_AddressEnd
 
int m_Options
 Stores all extended properties of an ImageAccessor. The different flags in mitk::ImageAccessorBase::Options can be unified by bitwise operations. More...
 
bool m_CoherentMemory
 
ImageAccessorWaitLock * m_WaitLock
 Pointer to a WaitLock struct, that allows other ImageAccessors to wait for this ImageAccessor. More...
 
ThreadIDType m_Thread
 

Detailed Description

Provides locked read-only access to a particular region of image data.

ImageReadAccessor acquires a read lock on the specified image data region upon construction and releases it upon destruction (RAII pattern). Multiple read accessors can co-exist for the same region, but a write accessor for an overlapping region will either block or throw, depending on the option flags.

Use GetData() to obtain a const pointer to the raw data.

mitk::ImageReadAccessor accessor(image, image->GetSliceData(0));
const void* data = accessor.GetData();
Provides locked read-only access to a particular region of image data.
See also
mitk::ImageWriteAccessor, mitk::ImagePixelReadAccessor
mitk::ImageAccessorBase

Definition at line 43 of file mitkImageReadAccessor.h.

Member Typedef Documentation

◆ ImagePointer

Smart pointer type for a non-const Image.

Definition at line 52 of file mitkImageReadAccessor.h.

Constructor & Destructor Documentation

◆ ImageReadAccessor() [1/3]

mitk::ImageReadAccessor::ImageReadAccessor ( ImageConstPointer  image,
const ImageDataItem *  iDI = nullptr,
int  OptionFlags = ImageAccessorBase::DefaultBehavior 
)

Construct a read accessor for a slice, volume, or entire image.

Parameters
[in]imageThe image to access (const smart pointer).
[in]iDIOptional ImageDataItem specifying the data region. If nullptr, the entire first channel is accessed.
[in]OptionFlagsCombination of mitk::ImageAccessorBase::Options flags.
Exceptions
mitk::Exceptionif construction parameters are invalid.
mitk::MemoryIsLockedExceptionif the region is exclusively locked and ExceptionIfLocked is set.

◆ ImageReadAccessor() [2/3]

mitk::ImageReadAccessor::ImageReadAccessor ( ImagePointer  image,
const ImageDataItem *  iDI = nullptr,
int  OptionFlags = ImageAccessorBase::DefaultBehavior 
)

Construct a read accessor from a non-const image smart pointer.

Parameters
[in]imageThe image to access.
[in]iDIOptional ImageDataItem specifying the data region.
[in]OptionFlagsCombination of mitk::ImageAccessorBase::Options flags.

◆ ImageReadAccessor() [3/3]

mitk::ImageReadAccessor::ImageReadAccessor ( const Image *  image,
const ImageDataItem *  iDI = nullptr 
)

Construct a read accessor from a raw image pointer (default options).

Parameters
[in]imageThe image to access.
[in]iDIOptional ImageDataItem specifying the data region.

◆ ~ImageReadAccessor()

mitk::ImageReadAccessor::~ImageReadAccessor ( )
override

Destructor releases the read lock on the image data.

Member Function Documentation

◆ GetImage()


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