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

Provides locked write access to a particular region of image data. More...

#include <mitkImageWriteAccessor.h>

Inheritance diagram for mitk::ImageWriteAccessor:
Collaboration diagram for mitk::ImageWriteAccessor:

Public Types

typedef Image::Pointer ImagePointer
 Smart pointer type for the associated 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

 ImageWriteAccessor (ImagePointer image, const ImageDataItem *iDI=nullptr, int OptionFlags=ImageAccessorBase::DefaultBehavior)
 Construct a write accessor for a slice, volume, or entire image. More...
 
void * GetData ()
 Get a non-const pointer to the raw image data for writing. More...
 
 ~ImageWriteAccessor () override
 Destructor releases the write 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 write access to a particular region of image data.

ImageWriteAccessor acquires an exclusive write lock on the specified image data region upon construction and releases it upon destruction (RAII pattern). While a write accessor exists, no other read or write accessor can access an overlapping region (they will either block or throw, depending on option flags).

Use GetData() to obtain a non-const pointer to the raw data for writing.

mitk::ImageWriteAccessor accessor(image);
void* data = accessor.GetData();
// ... modify data ...
Provides locked write access to a particular region of image data.
Note
After writing, you should call image->Modified() to notify the pipeline that the data has changed.
See also
mitk::ImageReadAccessor, mitk::ImagePixelWriteAccessor
mitk::ImageAccessorBase

Definition at line 44 of file mitkImageWriteAccessor.h.

Member Typedef Documentation

◆ ImagePointer

Smart pointer type for the associated Image.

Definition at line 51 of file mitkImageWriteAccessor.h.

Constructor & Destructor Documentation

◆ ImageWriteAccessor()

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

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

Parameters
[in]imageThe image to access (must be non-const).
[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.

◆ ~ImageWriteAccessor()

mitk::ImageWriteAccessor::~ImageWriteAccessor ( )
override

Destructor releases the write lock on the image data.

Member Function Documentation

◆ GetData()

void* mitk::ImageWriteAccessor::GetData ( )
inline

Get a non-const pointer to the raw image data for writing.

Returns
Pointer to the beginning of the writable memory region.

Definition at line 73 of file mitkImageWriteAccessor.h.

Referenced by mitk::ImageGenerator::GenerateImageFromReference(), and mitk::ImageGenerator::GenerateRandomImage().

◆ GetImage()

const Image* mitk::ImageWriteAccessor::GetImage ( ) const
overrideprotectedvirtual

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