Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
Medical Imaging Interaction Toolkit
mitkImageDataItem.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkImageDataItem_h
14 #define mitkImageDataItem_h
15 
16 #include "mitkCommon.h"
17 #include <MitkCoreExports.h>
18 #include "mitkImageDescriptor.h"
19 
20 class vtkImageData;
21 
22 namespace mitk
23 {
24  class PixelType;
25  class ImageVtkReadAccessor;
26  class ImageVtkWriteAccessor;
27 
28  class Image;
29 
30  //##Documentation
31  //## @brief Internal class for managing references on sub-images
32  //##
33  //## ImageDataItem is a container for image data which is used internal in
34  //## mitk::Image to handle the communication between the different data types for images
35  //## used in MITK (mitk::Image, vtkImageData). Common for these image data
36  //## types is the actual image data, but they differ in representation of pixel type etc.
37  //##
38  //## The class is mainly used to extract sub-images inside of mitk::Image, like single slices etc.
39  //## It should not be used outside of this.
40  //##
41  //## @param manageMemory Determines if image data is removed while destruction of ImageDataItem or not.
42  //## @ingroup Data
43  class MITKCORE_EXPORT ImageDataItem : public itk::LightObject
44  {
45  friend class ImageAccessorBase;
46  friend class ImageWriteAccessor;
47  friend class ImageReadAccessor;
48 
49  template <class TPixel, unsigned int VDimension>
50  friend class ImagePixelAccessor;
51 
52  friend class Image;
53 
54  // template<class TOutputImage>
55  // friend class ImageToItk;
56 
57  public:
60 
62 
63  itkCloneMacro(ImageDataItem);
64  itk::LightObject::Pointer InternalClone() const override;
65 
66  ImageDataItem(const ImageDataItem &aParent,
68  int timestep,
69  unsigned int dimension,
70  void *data = nullptr,
71  bool manageMemory = false,
72  size_t offset = 0);
73 
74  ~ImageDataItem() override;
75 
76  ImageDataItem(const mitk::ImageDescriptor::Pointer desc, int timestep, void *data, bool manageMemory);
77 
78  ImageDataItem(const mitk::PixelType &type,
79  int timestep,
80  unsigned int dimension,
81  unsigned int *dimensions,
82  void *data,
83  bool manageMemory);
84 
85  ImageDataItem(const ImageDataItem &other);
86 
87  bool IsComplete() const { return m_IsComplete; }
88  void SetComplete(bool complete) { m_IsComplete = complete; }
89  int GetOffset() const { return m_Offset; }
90  PixelType GetPixelType() const { return *m_PixelType; }
91  void SetTimestep(int t) { m_Timestep = t; }
92  void SetManageMemory(bool b) { m_ManageMemory = b; }
93  int GetDimension() const { return m_Dimension; }
94  int GetDimension(int i) const
95  {
96  int returnValue = 0;
97 
98  // return the true size if dimension available
99  if (i < (int)m_Dimension)
100  returnValue = m_Dimensions[i];
101 
102  return returnValue;
103  }
104 
105  ImageDataItem::ConstPointer GetParent() const { return m_Parent; }
115  ImageVtkReadAccessor *GetVtkImageAccessor(ImageConstPointer) const;
116  ImageVtkWriteAccessor *GetVtkImageAccessor(ImagePointer);
117 
118  // Returns if image data should be deleted on destruction of ImageDataItem.
119  bool GetManageMemory() const { return m_ManageMemory; }
120  virtual void ConstructVtkImageData(ImageConstPointer) const;
121 
122  size_t GetSize() const { return m_Size; }
123  virtual void Modified() const;
124 
125  protected:
126 
131  void* GetData() const { return m_Data; }
132 
133  unsigned char *m_Data;
134 
136 
138 
139  mutable vtkImageData *m_VtkImageData;
142  int m_Offset;
143 
145 
146  size_t m_Size;
147 
148  private:
149  void ComputeItemSize(const unsigned int *dimensions, unsigned int dimension);
150 
152 
153  unsigned int m_Dimension;
154 
155  unsigned int m_Dimensions[MAX_IMAGE_DIMENSIONS];
156 
157  int m_Timestep;
158  };
159 
160 } // namespace mitk
161 
162 #endif
mitk::ImageVtkWriteAccessor
ImageVtkWriteAccessor class provides any image write access which is required by Vtk methods.
Definition: mitkImageVtkWriteAccessor.h:29
mitk::ImageDataItem::m_Size
size_t m_Size
Definition: mitkImageDataItem.h:146
mitk::ImageDataItem::GetOffset
int GetOffset() const
Definition: mitkImageDataItem.h:89
mitk::ImageDataItem::IsComplete
bool IsComplete() const
Definition: mitkImageDataItem.h:87
mitk::ImageDataItem::m_IsComplete
bool m_IsComplete
Definition: mitkImageDataItem.h:144
MAX_IMAGE_DIMENSIONS
#define MAX_IMAGE_DIMENSIONS
Defines the maximum of 8 dimensions per image channel.
Definition: mitkImageDescriptor.h:25
mitk::ImageDataItem::GetManageMemory
bool GetManageMemory() const
Definition: mitkImageDataItem.h:119
mitk::ImageWriteAccessor
ImageWriteAccessor class to get locked write-access for a particular image part.
Definition: mitkImageWriteAccessor.h:25
mitk::ImageDataItem::SetTimestep
void SetTimestep(int t)
Definition: mitkImageDataItem.h:91
mitk::ImageDataItem::ImageConstPointer
itk::SmartPointer< const mitk::Image > ImageConstPointer
Definition: mitkImageDataItem.h:59
mitk::ImageDataItem::GetDimension
int GetDimension(int i) const
Definition: mitkImageDataItem.h:94
mitk::ImageDataItem::SetComplete
void SetComplete(bool complete)
Definition: mitkImageDataItem.h:88
mitk::ImageDataItem::GetParent
ImageDataItem::ConstPointer GetParent() const
Definition: mitkImageDataItem.h:105
mitk::ImageDataItem
Internal class for managing references on sub-images.
Definition: mitkImageDataItem.h:43
mitk::ImageDataItem::m_VtkImageData
vtkImageData * m_VtkImageData
Definition: mitkImageDataItem.h:139
mitk::ImageAccessorBase
Definition: mitkImageAccessorBase.h:48
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
mitk::ImageDataItem::SetManageMemory
void SetManageMemory(bool b)
Definition: mitkImageDataItem.h:92
itk::SmartPointer
Definition: mitkIFileReader.h:30
mitk::ImageDataItem::m_ManageMemory
bool m_ManageMemory
Definition: mitkImageDataItem.h:137
mitk::ImageDataItem::GetPixelType
PixelType GetPixelType() const
Definition: mitkImageDataItem.h:90
mitk::ImageDataItem::m_VtkImageWriteAccessor
ImageVtkWriteAccessor * m_VtkImageWriteAccessor
Definition: mitkImageDataItem.h:141
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk::ImageDataItem::m_Offset
int m_Offset
Definition: mitkImageDataItem.h:142
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::ImageReadAccessor
ImageReadAccessor class to get locked read access for a particular image part.
Definition: mitkImageReadAccessor.h:27
mitk::ImageDataItem::m_VtkImageReadAccessor
ImageVtkReadAccessor * m_VtkImageReadAccessor
Definition: mitkImageDataItem.h:140
MitkCoreExports.h
mitk::ImagePixelAccessor
Provides templated image access for all inheriting classes.
Definition: mitkImagePixelAccessor.h:30
mitk::ImageDataItem::GetDimension
int GetDimension() const
Definition: mitkImageDataItem.h:93
mitk::PixelType
Class for defining the data type of pixels.
Definition: mitkPixelType.h:51
mitkCommon.h
mitkImageDescriptor.h
mitk::ImageVtkReadAccessor
ImageVtkReadAccessor class provides any image read access which is required by Vtk methods.
Definition: mitkImageVtkReadAccessor.h:29
mitk::ImageDataItem::GetSize
size_t GetSize() const
Definition: mitkImageDataItem.h:122
mitk::ImageDataItem::ImagePointer
itk::SmartPointer< mitk::Image > ImagePointer
Definition: mitkImageDataItem.h:58
itk::Image
class ITK_EXPORT Image
Definition: mitkGeometryClipImageFilter.h:25
mitk::ImageDataItem::m_Data
unsigned char * m_Data
Definition: mitkImageDataItem.h:133
mitk::ImageDataItem::m_PixelType
PixelType * m_PixelType
Definition: mitkImageDataItem.h:135
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15
mitk::ImageDataItem::GetData
void * GetData() const
Definition: mitkImageDataItem.h:131