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

Image class for storing multi-dimensional medical image data. More...

#include <mitkImage.h>

Inheritance diagram for mitk::Image:
Collaboration diagram for mitk::Image:

Public Types

enum  ImportMemoryManagementType { CopyMemory , ManageMemory , ReferenceMemory , DontManageMemory }
 Defines how imported memory is managed when setting data on an Image. More...
 
typedef itk::SmartPointer< ImageDataItem > ImageDataItemPointer
 Smart Pointer type to an ImageDataItem. More...
 
typedef itk::Statistics::Histogram< double > HistogramType
 Histogram type used for image statistics (double-precision). More...
 
typedef mitk::ImageStatisticsHolder * StatisticsHolderPointer
 Pointer type to the ImageStatisticsHolder. More...
 
typedef std::vector< ImageDataItemPointer > ImageDataItemPointerArray
 Vector container of SmartPointers to ImageDataItems. More...
 
- Public Types inherited from mitk::SlicedData
typedef itk::ImageRegion< RegionDimension > RegionType
 
typedef itk::Index< RegionDimension > IndexType
 
typedef IndexType::IndexValueType IndexValueType
 
typedef itk::Offset< RegionDimension > OffsetType
 
typedef OffsetType::OffsetValueType OffsetValueType
 
typedef itk::Size< RegionDimension > SizeType
 
typedef SizeType::SizeValueType SizeValueType
 
- Public Types inherited from mitk::Identifiable
using UIDType = std::string
 Type alias for unique identifiers. More...
 

Public Member Functions

 mitkClassMacro (Image, SlicedData)
 
Pointer Clone () const
 
const mitk::PixelType GetPixelType (int n=0) const
 Returns the PixelType of channel n. More...
 
unsigned int GetDimension () const
 Get the number of dimensions of the image. More...
 
unsigned int GetDimension (int i) const
 Get the size of dimension i. More...
 
virtual vtkImageData * GetVtkImageData (int t=0, int n=0)
 Get a volume at a specific time step t of channel n as a vtkImageData. More...
 
virtual const vtkImageData * GetVtkImageData (int t=0, int n=0) const
 Get a volume at a specific time step t of channel n as a vtkImageData. More...
 
bool IsSliceSet (int s=0, int t=0, int n=0) const override
 Check whether slice s at time t in channel n is set. More...
 
bool IsVolumeSet (int t=0, int n=0) const override
 Check whether the volume at time t in channel n is set. More...
 
bool IsChannelSet (int n=0) const override
 Check whether channel n is set. More...
 
virtual bool SetSlice (const void *data, int s=0, int t=0, int n=0)
 Set data as slice s at time t in channel n. More...
 
virtual bool SetVolume (const void *data, int t=0, int n=0)
 Set data as volume at time t in channel n. More...
 
virtual bool SetChannel (const void *data, int n=0)
 Set data as the data for channel n. More...
 
virtual bool SetImportSlice (void *data, int s=0, int t=0, int n=0, ImportMemoryManagementType importMemoryManagement=CopyMemory)
 Set data as slice s at time t in channel n with configurable memory management. More...
 
virtual bool SetImportVolume (void *data, int t=0, int n=0, ImportMemoryManagementType importMemoryManagement=CopyMemory)
 Set data as volume at time t in channel n with configurable memory management. More...
 
virtual bool SetImportVolume (const void *const_data, int t=0, int n=0)
 Set const_data as volume at time t in channel n (copy-only). More...
 
virtual void AllocateZeroedVolume (int t=0, int n=0)
 Allocate a zero-initialized volume at time t in channel n. More...
 
virtual bool SetImportChannel (void *data, int n=0, ImportMemoryManagementType importMemoryManagement=CopyMemory)
 Set data as the data for channel n with configurable memory management. More...
 
virtual void Initialize (const mitk::PixelType &type, unsigned int dimension, const unsigned int *dimensions, unsigned int channels=1)
 Initialize (or re-initialize) image with pixel type and dimensions. More...
 
virtual void Initialize (const mitk::PixelType &type, const mitk::BaseGeometry &geometry, unsigned int channels=1, int tDim=1)
 Initialize (or re-initialize) image from a BaseGeometry. More...
 
virtual void Initialize (const mitk::PixelType &type, const mitk::TimeGeometry &geometry, unsigned int channels=1, int tDim=-1)
 Initialize (or re-initialize) image from a TimeGeometry. More...
 
virtual void Initialize (const mitk::PixelType &type, int sDim, const mitk::PlaneGeometry &geometry2d, unsigned int channels=1, int tDim=1)
 Initialize (or re-initialize) image from a PlaneGeometry and number of slices. More...
 
virtual void Initialize (const mitk::Image *image)
 Initialize (or re-initialize) image from another mitk::Image. More...
 
virtual void Initialize (const mitk::ImageDescriptor::Pointer inDesc)
 Initialize (or re-initialize) image from an ImageDescriptor. More...
 
virtual void Initialize (vtkImageData *vtkimagedata, int channels=1, int tDim=-1, int sDim=-1, int pDim=-1)
 Initialize (or re-initialize) image from a vtkImageData. More...
 
template<typename itkImageType >
void InitializeByItk (const itkImageType *itkimage, int channels=1, int tDim=-1, int sDim=-1)
 Initialize (or re-initialize) image from a templated ITK image. More...
 
virtual bool IsValidSlice (int s=0, int t=0, int n=0) const
 Check whether slice s at time t in channel n is valid. More...
 
virtual bool IsValidVolume (int t=0, int n=0) const
 Check whether the volume at time t in channel n is valid. More...
 
virtual bool IsValidChannel (int n=0) const
 Check whether channel n is valid. More...
 
bool IsRotated () const
 Check whether the image has a rotated geometry. More...
 
unsigned int * GetDimensions () const
 Get the sizes of all dimensions as an integer array. More...
 
ImageDescriptor::Pointer GetImageDescriptor () const
 Get the image descriptor containing type and dimension information. More...
 
ChannelDescriptor GetChannelDescriptor (int id=0) const
 Get the channel descriptor for channel id. More...
 
void SetGeometry (BaseGeometry *aGeometry3D) override
 Set the geometry of the image. More...
 
virtual ImageDataItemPointer GetSliceData (int s=0, int t=0, int n=0, void *data=nullptr, ImportMemoryManagementType importMemoryManagement=CopyMemory) const
 Get the ImageDataItem for slice s at time t in channel n. More...
 
virtual ImageDataItemPointer GetVolumeData (int t=0, int n=0, void *data=nullptr, ImportMemoryManagementType importMemoryManagement=CopyMemory) const
 Get the ImageDataItem for the volume at time t in channel n. More...
 
virtual ImageDataItemPointer GetChannelData (int n=0, void *data=nullptr, ImportMemoryManagementType importMemoryManagement=CopyMemory) const
 Get the ImageDataItem for channel n. More...
 
void * GetData (int t=0, int n=0)
 Get a raw pointer to the volume data at t in channel n without locking. More...
 
const void * GetData (int t=0, int n=0) const
 Get a raw pointer to the volume data at t in channel n without locking. More...
 
StatisticsHolderPointer GetStatistics () const
 Get the ImageStatisticsHolder that provides statistics for this image. More...
 
- Public Member Functions inherited from mitk::SlicedData
 mitkClassMacro (SlicedData, BaseData)
 
 itkStaticConstMacro (RegionDimension, unsigned int, 5)
 
void UpdateOutputInformation () override
 Update the information for this DataObject so it can be used as an output of a ProcessObject. More...
 
void PrepareForNewData () override
 Prepare the data object to receive new data. More...
 
void SetRequestedRegionToLargestPossibleRegion () override
 Set the RequestedRegion to the LargestPossibleRegion. More...
 
bool RequestedRegionIsOutsideOfTheBufferedRegion () override
 Determine whether the RequestedRegion is outside of the BufferedRegion. More...
 
bool VerifyRequestedRegion () override
 Verify that the RequestedRegion is within the LargestPossibleRegion. More...
 
void SetRequestedRegion (const itk::DataObject *data) override
 Set the requested region from another data object. More...
 
virtual void SetRequestedRegion (SlicedData::RegionType *region)
 Set the requested region from a RegionType pointer. More...
 
void SetLargestPossibleRegion (SlicedData::RegionType *region)
 Set the largest possible region. More...
 
const RegionType & GetLargestPossibleRegion () const
 Get the largest possible region. More...
 
virtual const RegionType & GetRequestedRegion () const
 Get the region object that defines the size and starting index for the requested region (i.e., the part of the data to be operated on). More...
 
void CopyInformation (const itk::DataObject *data) override
 Copy information from the specified data set. More...
 
unsigned int GetNumberOfChannels () const
 Get the number of channels. More...
 
SlicedGeometry3D * GetSlicedGeometry (unsigned int t=0) const
 Convenience access method for the geometry, which is of type SlicedGeometry3D (or a sub-class of it). More...
 
const SlicedGeometry3D * GetUpdatedSlicedGeometry (unsigned int t=0)
 Convenience access method that returns an up-to-date SlicedGeometry3D. More...
 
void SetGeometry (BaseGeometry *aGeometry3D) override
 Set the BaseGeometry of the data, which will be referenced (not copied!). More...
 
void SetOrigin (const Point3D &origin) override
 Convenience method for setting the origin of the SlicedGeometry3D instances of all time steps. More...
 
virtual void SetSpacing (const ScalarType aSpacing[])
 Convenience method for setting the spacing of the SlicedGeometry3D instances of all time steps. More...
 
virtual void SetSpacing (mitk::Vector3D aSpacing)
 Convenience method for setting the spacing of the SlicedGeometry3D instances of all time steps. More...
 
- Public Member Functions inherited from mitk::BaseData
 mitkClassMacroItkParent (BaseData, itk::DataObject)
 
BaseProperty::ConstPointer GetConstProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) const override
 Get a const property by its key. More...
 
std::vector< std::string > GetPropertyKeys (const std::string &contextName="", bool includeDefaultContext=false) const override
 Get all property keys stored in the property list. More...
 
std::vector< std::string > GetPropertyContextNames () const override
 Get the names of all property contexts. More...
 
BaseProperty * GetNonConstProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) override
 Get a non-const property by its key. More...
 
void SetProperty (const std::string &propertyKey, BaseProperty *property, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
 Set a property in the property list. More...
 
void RemoveProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
 Remove a property from the property list. More...
 
const mitk::TimeGeometry * GetTimeGeometry () const
 Return the TimeGeometry of the data as const pointer. More...
 
mitk::TimeGeometry * GetTimeGeometry ()
 Return the TimeGeometry of the data as non-const pointer. More...
 
const mitk::TimeGeometry * GetUpdatedTimeGeometry ()
 Return the TimeGeometry of the data after ensuring it is up-to-date. More...
 
const mitk::BaseGeometry * GetUpdatedGeometry (int t=0)
 Return the BaseGeometry of the data at time step t after ensuring it is up-to-date. More...
 
mitk::BaseGeometry * GetGeometry (int t=0) const
 Return the BaseGeometry of the data at time step t as a non-const pointer. More...
 
void UpdateOutputInformation () override
 Update the information for this BaseData so that it can be used as an output of a BaseProcess. More...
 
void CopyInformation (const itk::DataObject *data) override
 Copy information from the specified data set. More...
 
virtual bool IsInitialized () const
 Check whether the data has been initialized. More...
 
virtual bool IsEmptyTimeStep (unsigned int t) const
 Check whether the object contains data at the specified time step. More...
 
virtual bool IsEmpty () const
 Check whether the object contains data at any time step. More...
 
void ExecuteOperation (Operation *operation) override
 Execute an operation on this data object. More...
 
virtual void SetTimeGeometry (TimeGeometry *geometry)
 Set the TimeGeometry of the data, which will be referenced (not copied!). More...
 
virtual void SetClonedGeometry (const BaseGeometry *aGeometry3D)
 Set a clone of the provided geometry as the BaseGeometry of the data. More...
 
virtual void SetClonedTimeGeometry (const TimeGeometry *geometry)
 Set a clone of the provided TimeGeometry as the TimeGeometry of the data. More...
 
virtual void SetClonedGeometry (const BaseGeometry *aGeometry3D, unsigned int time)
 Set a clone of the provided geometry as the BaseGeometry of a given time step. More...
 
mitk::PropertyList::Pointer GetPropertyList () const
 Get the data's property list. More...
 
void SetPropertyList (PropertyList *propertyList)
 Set the data's property list, replacing the existing one. More...
 
mitk::BaseProperty::Pointer GetProperty (const char *propertyKey) const
 Get a property by its key from the PropertyList. More...
 
void SetProperty (const char *propertyKey, BaseProperty *property)
 Set a property in the PropertyList. More...
 
itk::SmartPointer< mitk::BaseDataSource > GetSource () const
 Get the process object that generated this data object. More...
 
unsigned int GetTimeSteps () const
 Get the number of time steps from the TimeGeometry. More...
 
itk::ModifiedTimeType GetMTime () const override
 Get the modification time of this data object or its geometry, whichever was modified most recently. More...
 
void Graft (const DataObject *) override
 Graft data and information from another data object. More...
 
- Public Member Functions inherited from mitk::OperationActor
 itkTypeMacroNoParent (OperationActor) virtual ~OperationActor()
 
- Public Member Functions inherited from mitk::Identifiable
 Identifiable ()
 Default constructor. Generates a new random UID. More...
 
 Identifiable (const UIDType &uid)
 Construct with a pre-existing UID. More...
 
 Identifiable (const Identifiable &)=delete
 Copy construction is deleted to prevent UID duplication. More...
 
 Identifiable (Identifiable &&) noexcept
 Move constructor. Transfers ownership of the UID. More...
 
virtual ~Identifiable ()
 Virtual destructor. More...
 
Identifiable & operator= (const Identifiable &)=delete
 Copy assignment is deleted to prevent UID duplication. More...
 
Identifiable & operator= (Identifiable &&other) noexcept
 Move assignment operator. Transfers ownership of the UID. More...
 
virtual UIDType GetUID () const
 Get the unique identifier of this object. More...
 
UIDType GetRuntimeUID () const noexcept
 Get a runtime-unique ID for this object instance. More...
 
- Public Member Functions inherited from mitk::IPropertyOwner
 ~IPropertyOwner () override
 
virtual bool PropertyIsOwned (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) const
 Checks if a certain property exists. More...
 
- Public Member Functions inherited from mitk::IPropertyProvider
virtual ~IPropertyProvider ()
 Virtual destructor. More...
 

Static Public Member Functions

static Pointer New ()
 

Protected Types

typedef std::lock_guard< std::mutex > MutexHolder
 

Protected Member Functions

 mitkCloneMacro (Self)
 
int GetSliceIndex (int s=0, int t=0, int n=0) const
 
int GetVolumeIndex (int t=0, int n=0) const
 
void ComputeOffsetTable ()
 
virtual bool IsValidTimeStep (int t) const
 
void Expand (unsigned int timeSteps) override
 Expand the TimeGeometry to a number of time steps. More...
 
virtual ImageDataItemPointer AllocateSliceData (int s=0, int t=0, int n=0, void *data=nullptr, ImportMemoryManagementType importMemoryManagement=CopyMemory) const
 
virtual ImageDataItemPointer AllocateVolumeData (int t=0, int n=0, void *data=nullptr, ImportMemoryManagementType importMemoryManagement=CopyMemory) const
 
virtual ImageDataItemPointer AllocateChannelData (int n=0, void *data=nullptr, ImportMemoryManagementType importMemoryManagement=CopyMemory) const
 
 Image ()
 
 Image (const Image &other)
 
 ~Image () override
 
void Clear () override
 Reset the data object by calling ClearData() and InitializeEmpty(). More...
 
void Initialize () override
 
void PrintSelf (std::ostream &os, itk::Indent indent) const override
 
- Protected Member Functions inherited from mitk::SlicedData
 SlicedData ()
 
 SlicedData (const SlicedData &other)
 
 ~SlicedData () override
 
- Protected Member Functions inherited from mitk::BaseData
 BaseData ()
 
 BaseData (const BaseData &other)
 
 ~BaseData () override
 
virtual void InitializeTimeGeometry (unsigned int timeSteps=1)
 Initialize the TimeGeometry for a number of time steps. The TimeGeometry is initialized empty and evenly timed. In many cases it will be necessary to overwrite this in sub-classes. More...
 
virtual void ClearData ()
 reset to non-initialized state, release memory More...
 
virtual void InitializeEmpty ()
 Pure virtual; Must be used in subclasses to get a data object to a valid state. Should at least create one empty object and call Superclass::InitializeTimeGeometry() to ensure an existing valid geometry. More...
 
void PrintSelf (std::ostream &os, itk::Indent indent) const override
 
- Protected Member Functions inherited from mitk::Identifiable
virtual void SetUID (const UIDType &uid)
 

Protected Attributes

ImageDataItemPointerArray m_Channels
 
ImageDataItemPointerArray m_Volumes
 
ImageDataItemPointerArray m_Slices
 
std::mutex m_ImageDataArraysLock
 
unsigned int m_Dimension
 
unsigned int * m_Dimensions
 
ImageDescriptor::Pointer m_ImageDescriptor
 
size_t * m_OffsetTable
 
ImageDataItemPointer m_CompleteData
 
StatisticsHolderPointer m_ImageStatistics
 
- Protected Attributes inherited from mitk::SlicedData
RegionType m_LargestPossibleRegion
 
RegionType m_RequestedRegion
 
bool m_RequestedRegionInitialized
 
RegionType m_BufferedRegion
 
bool m_UseLargestPossibleRegion
 
- Protected Attributes inherited from mitk::BaseData
bool m_LastRequestedRegionWasOutsideOfTheBufferedRegion
 
unsigned int m_SourceOutputIndexDuplicate
 
bool m_Initialized
 

Detailed Description

Image class for storing multi-dimensional medical image data.

Image is the primary data class for pixel-based image data in MITK. It can be queried for header information, raw data vectors, or vtkImageData objects. If access to only part of the data is required, use the appropriate accessor classes (ImageReadAccessor, ImageWriteAccessor, ImagePixelReadAccessor, ImagePixelWriteAccessor) rather than direct data access.

Image organizes data hierarchically as:

  • Slices (s x 2D): individual 2D planes
  • Volumes (t x 3D): stacks of slices for each time step
  • Channels (n x ND): separate data arrays per channel (e.g., morphology in channel 0, velocity in channel 1)

All channels must share the same geometry (including dimensions). Only the pixel type may differ between channels.

For importing ITK images, use of mitk::ITKImageImport is recommended. See Adaptor Classes for details.

For more information, see MITK Image.

See also
mitk::SlicedData, mitk::BaseData
mitk::ImageReadAccessor, mitk::ImageWriteAccessor
mitk::ImagePixelReadAccessor, mitk::ImagePixelWriteAccessor
mitk::ImageVtkReadAccessor, mitk::ImageVtkWriteAccessor

Definition at line 75 of file mitkImage.h.

Member Typedef Documentation

◆ HistogramType

typedef itk::Statistics::Histogram<double> mitk::Image::HistogramType

Histogram type used for image statistics (double-precision).

Definition at line 96 of file mitkImage.h.

◆ ImageDataItemPointer

Smart Pointer type to an ImageDataItem.

Definition at line 93 of file mitkImage.h.

◆ ImageDataItemPointerArray

Vector container of SmartPointers to ImageDataItems.

For internal usage to allow convenient access to all slices via iterators.

See also
ImageDataItem

Definition at line 121 of file mitkImage.h.

◆ MutexHolder

typedef std::lock_guard<std::mutex> mitk::Image::MutexHolder
protected

Definition at line 742 of file mitkImage.h.

◆ StatisticsHolderPointer

Member Enumeration Documentation

◆ ImportMemoryManagementType

Defines how imported memory is managed when setting data on an Image.

This enum is evaluated by SetImportSlice, SetImportVolume, and SetImportChannel to decide ownership of the provided data buffer.

Enumerator
CopyMemory 

Data is copied to a new memory block owned by the Image. The original buffer is not freed by Image.

ManageMemory 

Data is referenced by the Image. The Image takes ownership and will free the buffer on deletion.

ReferenceMemory 

Data is referenced by the Image. The Image does not free the buffer on deletion; the caller retains ownership.

DontManageMemory 

Alias for ReferenceMemory.

Definition at line 107 of file mitkImage.h.

Constructor & Destructor Documentation

◆ Image() [1/2]

mitk::Image::Image ( )
protected

◆ Image() [2/2]

mitk::Image::Image ( const Image &  other)
protected

◆ ~Image()

mitk::Image::~Image ( )
overrideprotected

Member Function Documentation

◆ AllocateChannelData()

virtual ImageDataItemPointer mitk::Image::AllocateChannelData ( int  n = 0,
void *  data = nullptr,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) const
protectedvirtual

◆ AllocateSliceData()

virtual ImageDataItemPointer mitk::Image::AllocateSliceData ( int  s = 0,
int  t = 0,
int  n = 0,
void *  data = nullptr,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) const
protectedvirtual

◆ AllocateVolumeData()

virtual ImageDataItemPointer mitk::Image::AllocateVolumeData ( int  t = 0,
int  n = 0,
void *  data = nullptr,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) const
protectedvirtual

◆ AllocateZeroedVolume()

virtual void mitk::Image::AllocateZeroedVolume ( int  t = 0,
int  n = 0 
)
virtual

Allocate a zero-initialized volume at time t in channel n.

The image must already be initialized with a pixel type and dimensions (via any Initialize() overload) but must not yet have volume data set for the given time step and channel.

Parameters
[in]tTime step (default: 0).
[in]nChannel number (default: 0).
Precondition
Image must be initialized (IsInitialized() == true).
Image dimension must be between 1 and 3.
No volume data may already exist at (t, n).
Exceptions
mitk::Exceptionif any precondition is violated.

◆ Clear()

void mitk::Image::Clear ( )
overrideprotectedvirtual

Reset the data object by calling ClearData() and InitializeEmpty().

Warning
Only use in subclasses that have reimplemented ClearData() and InitializeEmpty(). Calling Clear() directly on BaseData will reset the object to a non-initialized, invalid state.
See also
ClearData, InitializeEmpty

Reimplemented from mitk::BaseData.

◆ Clone()

Pointer mitk::Image::Clone ( ) const

◆ ComputeOffsetTable()

void mitk::Image::ComputeOffsetTable ( )
protected

◆ Expand()

void mitk::Image::Expand ( unsigned int  timeSteps)
overrideprotectedvirtual

Expand the TimeGeometry to a number of time steps.

The method expands the TimeGeometry to the given number of time steps, filling newly created elements with empty geometries. Sub-classes should override this method to handle the elongation of their data vectors, too.

Note
Shrinking is neither possible nor intended. If timeSteps is less than or equal to the current number of time steps, no action is taken.
Parameters
[in]timeStepsThe desired number of time steps.
See also
TimeGeometry::Expand

Reimplemented from mitk::BaseData.

◆ GetChannelData()

virtual ImageDataItemPointer mitk::Image::GetChannelData ( int  n = 0,
void *  data = nullptr,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) const
virtual

Get the ImageDataItem for channel n.

Warning
For internal use only. Use ImageReadAccessor or ImageWriteAccessor for safe data access.
Parameters
[in]nChannel number (default: 0).
[in]dataOptional pre-allocated data buffer (default: nullptr).
[in]importMemoryManagementMemory management policy (default: CopyMemory).
Returns
Smart pointer to the ImageDataItem, or nullptr if invalid.

◆ GetChannelDescriptor()

ChannelDescriptor mitk::Image::GetChannelDescriptor ( int  id = 0) const
inline

Get the channel descriptor for channel id.

Parameters
[in]idThe channel index (default: 0).
Returns
The ChannelDescriptor for the specified channel.

Definition at line 642 of file mitkImage.h.

◆ GetData() [1/2]

void* mitk::Image::GetData ( int  t = 0,
int  n = 0 
)

Get a raw pointer to the volume data at t in channel n without locking.

Returns the underlying voxel buffer for direct, unlocked access. No ImageReadAccessor or ImageWriteAccessor is created and the accessor lock list is left untouched. The caller is responsible for ensuring no concurrent SetVolume(), SetSlice(), or Initialize() call runs while the returned pointer is in use.

Use the accessor classes (ImageReadAccessor, ImageWriteAccessor) when lock-based concurrency control is required instead.

Parameters
[in]tTime step (default: 0).
[in]nChannel number (default: 0).
Returns
Pointer to the start of the volume buffer, or nullptr if no volume data is available at (t, n).
See also
GetVolumeData, ImageReadAccessor, ImageWriteAccessor

◆ GetData() [2/2]

const void* mitk::Image::GetData ( int  t = 0,
int  n = 0 
) const

Get a raw pointer to the volume data at t in channel n without locking.

Returns the underlying voxel buffer for direct, unlocked access. No ImageReadAccessor or ImageWriteAccessor is created and the accessor lock list is left untouched. The caller is responsible for ensuring no concurrent SetVolume(), SetSlice(), or Initialize() call runs while the returned pointer is in use.

Use the accessor classes (ImageReadAccessor, ImageWriteAccessor) when lock-based concurrency control is required instead.

Parameters
[in]tTime step (default: 0).
[in]nChannel number (default: 0).
Returns
Pointer to the start of the volume buffer, or nullptr if no volume data is available at (t, n).
See also
GetVolumeData, ImageReadAccessor, ImageWriteAccessor

◆ GetDimension() [1/2]

unsigned int mitk::Image::GetDimension ( ) const

Get the number of dimensions of the image.

Returns
The image dimensionality (e.g., 2, 3, or 4).

Referenced by mitk::ImagePixelAccessor< TPixel, VDimension >::CheckData(), and mitk::AccessItkImageFunctor< X, VDimension, T1, T2, T3 >::operator()().

◆ GetDimension() [2/2]

unsigned int mitk::Image::GetDimension ( int  i) const

Get the size of dimension i.

For example, i=0 gives the number of pixels in x-direction, i=1 in y-direction, i=2 in z-direction (number of slices), and i=3 the number of time steps.

Parameters
[in]iThe dimension index.
Returns
The size of the requested dimension, or 1 if i is out of range.
See also
GetDimensions

◆ GetDimensions()

unsigned int* mitk::Image::GetDimensions ( ) const

Get the sizes of all dimensions as an integer array.

Returns
Pointer to the internal array of dimension sizes.
See also
GetDimension(int)

◆ GetImageDescriptor()

ImageDescriptor::Pointer mitk::Image::GetImageDescriptor ( ) const
inline

Get the image descriptor containing type and dimension information.

Returns
Smart pointer to the ImageDescriptor.

Definition at line 634 of file mitkImage.h.

◆ GetPixelType()

const mitk::PixelType mitk::Image::GetPixelType ( int  n = 0) const

Returns the PixelType of channel n.

Parameters
[in]nThe channel index (default: 0).
Returns
The PixelType describing the voxel data type and number of components.
See also
PixelType

Referenced by mitk::ImagePixelAccessor< TPixel, VDimension >::CheckData(), and mitk::ImagePixelReadAccessor< TPixel, VDimension >::GetConsecutivePixelsAsVector().

◆ GetSliceData()

virtual ImageDataItemPointer mitk::Image::GetSliceData ( int  s = 0,
int  t = 0,
int  n = 0,
void *  data = nullptr,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) const
virtual

Get the ImageDataItem for slice s at time t in channel n.

Warning
For internal use only. Use ImageReadAccessor or ImageWriteAccessor for safe data access.
Parameters
[in]sSlice index (default: 0).
[in]tTime step (default: 0).
[in]nChannel number (default: 0).
[in]dataOptional pre-allocated data buffer (default: nullptr).
[in]importMemoryManagementMemory management policy (default: CopyMemory).
Returns
Smart pointer to the ImageDataItem, or nullptr if invalid.

◆ GetSliceIndex()

int mitk::Image::GetSliceIndex ( int  s = 0,
int  t = 0,
int  n = 0 
) const
protected

◆ GetStatistics()

StatisticsHolderPointer mitk::Image::GetStatistics ( ) const
inline

Get the ImageStatisticsHolder that provides statistics for this image.

All statistics query methods (min, max, scalar 2nd, etc.) are available through the returned ImageStatisticsHolder object.

Returns
Pointer to the ImageStatisticsHolder.
See also
ImageStatisticsHolder

Definition at line 737 of file mitkImage.h.

◆ GetVolumeData()

virtual ImageDataItemPointer mitk::Image::GetVolumeData ( int  t = 0,
int  n = 0,
void *  data = nullptr,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) const
virtual

Get the ImageDataItem for the volume at time t in channel n.

Warning
For internal use only. Use ImageReadAccessor or ImageWriteAccessor for safe data access.
Parameters
[in]tTime step (default: 0).
[in]nChannel number (default: 0).
[in]dataOptional pre-allocated data buffer (default: nullptr).
[in]importMemoryManagementMemory management policy (default: CopyMemory).
Returns
Smart pointer to the ImageDataItem, or nullptr if invalid.

◆ GetVolumeIndex()

int mitk::Image::GetVolumeIndex ( int  t = 0,
int  n = 0 
) const
protected

◆ GetVtkImageData() [1/2]

virtual vtkImageData* mitk::Image::GetVtkImageData ( int  t = 0,
int  n = 0 
)
virtual

Get a volume at a specific time step t of channel n as a vtkImageData.

If the image is not initialized, the method will attempt to trigger an update from the pipeline source.

Parameters
[in]tTime step (default: 0).
[in]nChannel number (default: 0).
Returns
Pointer to the vtkImageData, or nullptr if the data is unavailable.
See also
ImageVtkReadAccessor, ImageVtkWriteAccessor

◆ GetVtkImageData() [2/2]

virtual const vtkImageData* mitk::Image::GetVtkImageData ( int  t = 0,
int  n = 0 
) const
virtual

Get a volume at a specific time step t of channel n as a vtkImageData.

If the image is not initialized, the method will attempt to trigger an update from the pipeline source.

Parameters
[in]tTime step (default: 0).
[in]nChannel number (default: 0).
Returns
Pointer to the vtkImageData, or nullptr if the data is unavailable.
See also
ImageVtkReadAccessor, ImageVtkWriteAccessor

◆ Initialize() [1/8]

void mitk::Image::Initialize ( )
overrideprotected
Warning
Has to be called by every Initialize method!

◆ Initialize() [2/8]

virtual void mitk::Image::Initialize ( const mitk::Image *  image)
virtual

Initialize (or re-initialize) image from another mitk::Image.

Only the header information is copied, not the data vector.

Parameters
[in]imageThe source image whose header to copy.

◆ Initialize() [3/8]

virtual void mitk::Image::Initialize ( const mitk::ImageDescriptor::Pointer  inDesc)
virtual

Initialize (or re-initialize) image from an ImageDescriptor.

Parameters
[in]inDescThe image descriptor providing type and dimension information.

◆ Initialize() [4/8]

virtual void mitk::Image::Initialize ( const mitk::PixelType &  type,
const mitk::BaseGeometry &  geometry,
unsigned int  channels = 1,
int  tDim = 1 
)
virtual

Initialize (or re-initialize) image from a BaseGeometry.

Parameters
[in]typeThe pixel type for the image.
[in]geometryThe spatial geometry to use.
[in]channelsNumber of channels (default: 1).
[in]tDimNumber of time steps (default: 1).

◆ Initialize() [5/8]

virtual void mitk::Image::Initialize ( const mitk::PixelType &  type,
const mitk::TimeGeometry &  geometry,
unsigned int  channels = 1,
int  tDim = -1 
)
virtual

Initialize (or re-initialize) image from a TimeGeometry.

Parameters
[in]typeThe pixel type for the image.
[in]geometryThe time geometry providing spatial and temporal information.
[in]channelsNumber of channels (default: 1).
[in]tDimOverride the time dimension if the value is > 0 (default: -1, meaning use the number of time steps from the TimeGeometry).

◆ Initialize() [6/8]

virtual void mitk::Image::Initialize ( const mitk::PixelType &  type,
int  sDim,
const mitk::PlaneGeometry &  geometry2d,
unsigned int  channels = 1,
int  tDim = 1 
)
virtual

Initialize (or re-initialize) image from a PlaneGeometry and number of slices.

The bounding box is initialized according to the width/height of the PlaneGeometry and sDim via SlicedGeometry3D::InitializeEvenlySpaced. The spacing is calculated from the PlaneGeometry.

Parameters
[in]typeThe pixel type for the image.
[in]sDimNumber of slices.
[in]geometry2dThe 2D plane geometry.
[in]channelsNumber of channels (default: 1).
[in]tDimNumber of time steps (default: 1).
See also
SlicedGeometry3D::InitializeEvenlySpaced

◆ Initialize() [7/8]

virtual void mitk::Image::Initialize ( const mitk::PixelType &  type,
unsigned int  dimension,
const unsigned int *  dimensions,
unsigned int  channels = 1 
)
virtual

Initialize (or re-initialize) image with pixel type and dimensions.

Creates a plane, evenly spaced geometry starting at origin (0,0,0).

Parameters
[in]typeThe pixel type for the image.
[in]dimensionThe number of dimensions (2, 3, or 4).
[in]dimensionsArray of sizes for each dimension.
[in]channelsNumber of channels (default: 1).
Warning
Assumes a plane, evenly spaced geometry starting at (0,0,0).

◆ Initialize() [8/8]

virtual void mitk::Image::Initialize ( vtkImageData *  vtkimagedata,
int  channels = 1,
int  tDim = -1,
int  sDim = -1,
int  pDim = -1 
)
virtual

Initialize (or re-initialize) image from a vtkImageData.

Only the header is used, not the data vector. Use SetVolume(vtkimage->GetScalarPointer()) to transfer the pixel data.

Parameters
[in]vtkimagedataThe VTK image providing header information.
[in]channelsNumber of channels (default: 1).
[in]tDimOverride time dimension (default: -1, use VTK value).
[in]sDimOverride z-space dimension (default: -1, use VTK value).
[in]pDimOverride y-space dimension (default: -1, use VTK value).

◆ InitializeByItk()

template<typename itkImageType >
void mitk::Image::InitializeByItk ( const itkImageType *  itkimage,
int  channels = 1,
int  tDim = -1,
int  sDim = -1 
)
inline

Initialize (or re-initialize) image from a templated ITK image.

Only the header (spacing, origin, direction, dimensions) is used, not the data vector. Use SetVolume(itkimage->GetBufferPointer()) to transfer data.

Template Parameters
itkImageTypeThe ITK image type.
Parameters
[in]itkimageThe ITK image providing header information.
[in]channelsNumber of channels (default: 1).
[in]tDimOverride time dimension (default: -1, use ITK value).
[in]sDimOverride z-space dimension (default: -1, use ITK value).

Definition at line 443 of file mitkImage.h.

References mitk::eps, mitk::FillVector3D(), mitk::BaseGeometry::GetIndexToWorldTransform(), mitk::SlicedGeometry3D::InitializeEvenlySpaced(), MITK_DEBUG, MITK_ERROR, MITK_WARN, mitk::ProportionalTimeGeometry::New(), mitk::BaseGeometry::SetOrigin(), and mitk::BaseGeometry::SetSpacing().

◆ IsChannelSet()

bool mitk::Image::IsChannelSet ( int  n = 0) const
overridevirtual

Check whether channel n is set.

Parameters
[in]nChannel number (default: 0).
Returns
True if the channel data is available.

Implements mitk::SlicedData.

◆ IsRotated()

bool mitk::Image::IsRotated ( ) const

Check whether the image has a rotated geometry.

Returns true if the geometry's transformation matrix has non-zero off-diagonal elements larger than 1/1000 of the matrix trace.

Returns
True if the image geometry is rotated.

◆ IsSliceSet()

bool mitk::Image::IsSliceSet ( int  s = 0,
int  t = 0,
int  n = 0 
) const
overridevirtual

Check whether slice s at time t in channel n is set.

Parameters
[in]sSlice index (default: 0).
[in]tTime step (default: 0).
[in]nChannel number (default: 0).
Returns
True if the slice data is available.

Implements mitk::SlicedData.

◆ IsValidChannel()

virtual bool mitk::Image::IsValidChannel ( int  n = 0) const
virtual

Check whether channel n is valid.

A valid channel has an index within the image bounds.

Parameters
[in]nChannel number (default: 0).
Returns
True if the specified channel is within the image bounds.

◆ IsValidSlice()

virtual bool mitk::Image::IsValidSlice ( int  s = 0,
int  t = 0,
int  n = 0 
) const
virtual

Check whether slice s at time t in channel n is valid.

A valid slice is one whose indices are within the image bounds.

Parameters
[in]sSlice index (default: 0).
[in]tTime step (default: 0).
[in]nChannel number (default: 0).
Returns
True if the specified slice is within the image bounds.

◆ IsValidTimeStep()

virtual bool mitk::Image::IsValidTimeStep ( int  t) const
protectedvirtual

◆ IsValidVolume()

virtual bool mitk::Image::IsValidVolume ( int  t = 0,
int  n = 0 
) const
virtual

Check whether the volume at time t in channel n is valid.

A valid volume has indices within the image bounds.

Parameters
[in]tTime step (default: 0).
[in]nChannel number (default: 0).
Returns
True if the specified volume is within the image bounds.

◆ IsVolumeSet()

bool mitk::Image::IsVolumeSet ( int  t = 0,
int  n = 0 
) const
overridevirtual

Check whether the volume at time t in channel n is set.

Parameters
[in]tTime step (default: 0).
[in]nChannel number (default: 0).
Returns
True if the volume data is available.

Implements mitk::SlicedData.

◆ mitkClassMacro()

mitk::Image::mitkClassMacro ( Image  ,
SlicedData   
)

◆ mitkCloneMacro()

mitk::Image::mitkCloneMacro ( Self  )
protected

◆ New()

◆ PrintSelf()

void mitk::Image::PrintSelf ( std::ostream &  os,
itk::Indent  indent 
) const
overrideprotected

◆ SetChannel()

virtual bool mitk::Image::SetChannel ( const void *  data,
int  n = 0 
)
virtual

Set data as the data for channel n.

The data is copied into an array managed by the Image. If the image should reference external data instead, use SetImportChannel with ImportMemoryManagementType set to ReferenceMemory.

Precondition
The caller must ensure data points to a buffer at least as large as one channel.
Parameters
[in]dataPointer to the channel data.
[in]nChannel number (default: 0).
Returns
True on success.
See also
SetImportChannel

◆ SetGeometry()

void mitk::Image::SetGeometry ( BaseGeometry *  aGeometry3D)
overridevirtual

Set the geometry of the image.

Overrides BaseData::SetGeometry to handle SlicedGeometry3D and PlaneGeometry conversion.

Parameters
[in]aGeometry3DThe geometry to set.

Reimplemented from mitk::BaseData.

◆ SetImportChannel()

virtual bool mitk::Image::SetImportChannel ( void *  data,
int  n = 0,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
)
virtual

Set data as the data for channel n with configurable memory management.

Precondition
The caller must ensure data points to a buffer at least as large as one channel.
Parameters
[in]dataPointer to the channel data.
[in]nChannel number (default: 0).
[in]importMemoryManagementSpecifies how the data buffer is managed (default: CopyMemory).
Returns
True on success.
See also
SetChannel, ImportMemoryManagementType

◆ SetImportSlice()

virtual bool mitk::Image::SetImportSlice ( void *  data,
int  s = 0,
int  t = 0,
int  n = 0,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
)
virtual

Set data as slice s at time t in channel n with configurable memory management.

Precondition
The caller must ensure data points to a buffer at least as large as one slice.
Parameters
[in]dataPointer to the slice data.
[in]sSlice index (default: 0).
[in]tTime step (default: 0).
[in]nChannel number (default: 0).
[in]importMemoryManagementSpecifies how the data buffer is managed (default: CopyMemory).
Returns
True on success.
See also
SetSlice, ImportMemoryManagementType

◆ SetImportVolume() [1/2]

virtual bool mitk::Image::SetImportVolume ( const void *  const_data,
int  t = 0,
int  n = 0 
)
virtual

Set const_data as volume at time t in channel n (copy-only).

This overload always copies the data (equivalent to CopyMemory).

Parameters
[in]const_dataPointer to the const volume data to copy.
[in]tTime step (default: 0).
[in]nChannel number (default: 0).
Returns
True on success.

◆ SetImportVolume() [2/2]

virtual bool mitk::Image::SetImportVolume ( void *  data,
int  t = 0,
int  n = 0,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
)
virtual

Set data as volume at time t in channel n with configurable memory management.

Precondition
The caller must ensure data points to a buffer at least as large as one volume.
Parameters
[in]dataPointer to the volume data.
[in]tTime step (default: 0).
[in]nChannel number (default: 0).
[in]importMemoryManagementSpecifies how the data buffer is managed (default: CopyMemory).
Returns
True on success.
See also
SetVolume, ImportMemoryManagementType

◆ SetSlice()

virtual bool mitk::Image::SetSlice ( const void *  data,
int  s = 0,
int  t = 0,
int  n = 0 
)
virtual

Set data as slice s at time t in channel n.

The data is copied into an array managed by the Image. If the image should reference external data instead, use SetImportSlice with ImportMemoryManagementType set to ReferenceMemory.

Precondition
The caller must ensure data points to a buffer at least as large as one slice.
Parameters
[in]dataPointer to the slice data.
[in]sSlice index (default: 0).
[in]tTime step (default: 0).
[in]nChannel number (default: 0).
Returns
True on success.
See also
SetImportSlice, SetVolume

◆ SetVolume()

virtual bool mitk::Image::SetVolume ( const void *  data,
int  t = 0,
int  n = 0 
)
virtual

Set data as volume at time t in channel n.

The data is copied into an array managed by the Image. If the image should reference external data instead, use SetImportVolume with ImportMemoryManagementType set to ReferenceMemory.

Precondition
The caller must ensure data points to a buffer at least as large as one volume.
Parameters
[in]dataPointer to the volume data.
[in]tTime step (default: 0).
[in]nChannel number (default: 0).
Returns
True on success.
See also
SetImportVolume, SetSlice

Member Data Documentation

◆ m_Channels

ImageDataItemPointerArray mitk::Image::m_Channels
mutableprotected

Definition at line 780 of file mitkImage.h.

◆ m_CompleteData

ImageDataItemPointer mitk::Image::m_CompleteData
protected

Definition at line 792 of file mitkImage.h.

◆ m_Dimension

unsigned int mitk::Image::m_Dimension
protected

Definition at line 785 of file mitkImage.h.

◆ m_Dimensions

unsigned int* mitk::Image::m_Dimensions
protected

Definition at line 787 of file mitkImage.h.

◆ m_ImageDataArraysLock

std::mutex mitk::Image::m_ImageDataArraysLock
mutableprotected

Definition at line 783 of file mitkImage.h.

◆ m_ImageDescriptor

ImageDescriptor::Pointer mitk::Image::m_ImageDescriptor
protected

Definition at line 789 of file mitkImage.h.

◆ m_ImageStatistics

StatisticsHolderPointer mitk::Image::m_ImageStatistics
protected

Definition at line 796 of file mitkImage.h.

◆ m_OffsetTable

size_t* mitk::Image::m_OffsetTable
protected

Definition at line 791 of file mitkImage.h.

◆ m_Slices

ImageDataItemPointerArray mitk::Image::m_Slices
mutableprotected

Definition at line 782 of file mitkImage.h.

◆ m_Volumes

ImageDataItemPointerArray mitk::Image::m_Volumes
mutableprotected

Definition at line 781 of file mitkImage.h.


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