Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkImage.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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef MITKIMAGE_H_HEADER_INCLUDED_C1C2FCD2
18 #define MITKIMAGE_H_HEADER_INCLUDED_C1C2FCD2
19 
20 #include "mitkBaseData.h"
21 #include "mitkImageAccessorBase.h"
22 #include "mitkImageDataItem.h"
23 #include "mitkImageDescriptor.h"
24 #include "mitkImageVtkAccessor.h"
25 #include "mitkLevelWindow.h"
26 #include "mitkPlaneGeometry.h"
27 #include "mitkSlicedData.h"
28 #include <MitkCoreExports.h>
30 
31 // DEPRECATED
32 #include <mitkTimeSlicedGeometry.h>
33 
34 #ifndef __itkHistogram_h
35 #include <itkHistogram.h>
36 #endif
37 
38 class vtkImageData;
39 
40 namespace itk
41 {
42  template <class T>
44 }
45 
46 namespace mitk
47 {
48  class SubImageSelector;
49  class ImageTimeSelector;
50 
51  class ImageStatisticsHolder;
52 
53  //##Documentation
54  //## @brief Image class for storing images
55  //##
56  //## Can be asked for header information, the data vector,
57  //## the mitkIpPicDescriptor struct or vtkImageData objects. If not the complete
58  //## data is required, the appropriate SubImageSelector class should be used
59  //## for access.
60  //## Image organizes sets of slices (s x 2D), volumes (t x 3D) and channels (n
61  //## x ND). Channels are for different kind of data, e.g., morphology in
62  //## channel 0, velocities in channel 1. All channels must have the same Geometry! In
63  //## particular, the dimensions of all channels are the same, only the pixel-type
64  //## may differ between channels.
65  //##
66  //## For importing ITK images use of mitk::ITKImageImport is recommended, see
67  //## \ref Adaptor.
68  //##
69  //## For ITK v3.8 and older: Converting coordinates from the ITK physical
70  //## coordinate system (which does not support rotated images) to the MITK world
71  //## coordinate system should be performed via the BaseGeometry of the Image, see
72  //## BaseGeometry::WorldToItkPhysicalPoint.
73  //##
74  //## For more information, see \ref MitkImagePage .
75  //## @ingroup Data
77  {
78  friend class SubImageSelector;
79 
80  friend class ImageAccessorBase;
81  friend class ImageVtkAccessor;
82  friend class ImageVtkReadAccessor;
83  friend class ImageVtkWriteAccessor;
84  friend class ImageReadAccessor;
85  friend class ImageWriteAccessor;
86 
87  public:
89 
90  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
91 
93  typedef itk::SmartPointer<ImageDataItem> ImageDataItemPointer;
94  typedef itk::Statistics::Histogram<double> HistogramType;
96 
97  //## @param ImportMemoryManagementType This parameter is evaluated when setting new data to an image.
98  //## The different options are:
99  //## CopyMemory: Data to be set is copied and assigned to a new memory block. Data memory block will be freed on
100  // deletion of mitk::Image.
101  //## MamageMemory: Data to be set will be referenced, and Data memory block will be freed on deletion of
102  //mitk::Image.
103  //## Reference Memory: Data to be set will be referenced, but Data memory block will not be freed on deletion of
104  // mitk::Image.
105  //## DontManageMemory = ReferenceMemory.
107  {
111  DontManageMemory = ReferenceMemory
112  };
113 
114  //##Documentation
115  //## @brief Vector container of SmartPointers to ImageDataItems;
116  //## Class is only for internal usage to allow convenient access to all slices over iterators;
117  //## See documentation of ImageDataItem for details.
118  typedef std::vector<ImageDataItemPointer> ImageDataItemPointerArray;
119 
120  public:
121  //##Documentation
122  //## @brief Returns the PixelType of channel @a n.
123  const mitk::PixelType GetPixelType(int n = 0) const;
124 
125  //##Documentation
126  //## @brief Get dimension of the image
127  //##
128  unsigned int GetDimension() const;
129 
130  //##Documentation
131  //## @brief Get the size of dimension @a i (e.g., i=0 results in the number of pixels in x-direction).
132  //##
133  //## @sa GetDimensions()
134  unsigned int GetDimension(int i) const;
135 
142  DEPRECATED(virtual void *GetData());
143 
144  public:
150  DEPRECATED(double GetPixelValueByIndex(const itk::Index<3> &position,
151  unsigned int timestep = 0,
152  unsigned int component = 0));
153 
159  DEPRECATED(double GetPixelValueByWorldCoordinate(const mitk::Point3D &position,
160  unsigned int timestep = 0,
161  unsigned int component = 0));
162 
163  //##Documentation
164  //## @brief Get a volume at a specific time @a t of channel @a n as a vtkImageData.
165  virtual vtkImageData *GetVtkImageData(int t = 0, int n = 0);
166  virtual const vtkImageData *GetVtkImageData(int t = 0, int n = 0) const;
167 
168  //##Documentation
169  //## @brief Get the complete image, i.e., all channels linked together, as a @a mitkIpPicDescriptor.
170  //##
171  //## If you only want to access a slice, volume at a specific time or single channel
172  //## use one of the SubImageSelector classes.
173  // virtual mitkIpPicDescriptor* GetPic();
174 
175  //##Documentation
176  //## @brief Check whether slice @a s at time @a t in channel @a n is set
177  virtual bool IsSliceSet(int s = 0, int t = 0, int n = 0) const override;
178 
179  //##Documentation
180  //## @brief Check whether volume at time @a t in channel @a n is set
181  virtual bool IsVolumeSet(int t = 0, int n = 0) const override;
182 
183  //##Documentation
184  //## @brief Check whether the channel @a n is set
185  virtual bool IsChannelSet(int n = 0) const override;
186 
187  //##Documentation
188  //## @brief Set @a data as slice @a s at time @a t in channel @a n. It is in
189  //## the responsibility of the caller to ensure that the data vector @a data
190  //## is really a slice (at least is not smaller than a slice), since there is
191  //## no chance to check this.
192  //##
193  //## The data is copied to an array managed by the image. If the image shall
194  //## reference the data, use SetImportSlice with ImportMemoryManagementType
195  //## set to ReferenceMemory. For importing ITK images use of mitk::
196  //## ITKImageImport is recommended.
197  //## @sa SetPicSlice, SetImportSlice, SetImportVolume
198  virtual bool SetSlice(const void *data, int s = 0, int t = 0, int n = 0);
199 
200  //##Documentation
201  //## @brief Set @a data as volume at time @a t in channel @a n. It is in
202  //## the responsibility of the caller to ensure that the data vector @a data
203  //## is really a volume (at least is not smaller than a volume), since there is
204  //## no chance to check this.
205  //##
206  //## The data is copied to an array managed by the image. If the image shall
207  //## reference the data, use SetImportVolume with ImportMemoryManagementType
208  //## set to ReferenceMemory. For importing ITK images use of mitk::
209  //## ITKImageImport is recommended.
210  //## @sa SetPicVolume, SetImportVolume
211  virtual bool SetVolume(const void *data, int t = 0, int n = 0);
212 
213  //##Documentation
214  //## @brief Set @a data in channel @a n. It is in
215  //## the responsibility of the caller to ensure that the data vector @a data
216  //## is really a channel (at least is not smaller than a channel), since there is
217  //## no chance to check this.
218  //##
219  //## The data is copied to an array managed by the image. If the image shall
220  //## reference the data, use SetImportChannel with ImportMemoryManagementType
221  //## set to ReferenceMemory. For importing ITK images use of mitk::
222  //## ITKImageImport is recommended.
223  //## @sa SetPicChannel, SetImportChannel
224  virtual bool SetChannel(const void *data, int n = 0);
225 
226  //##Documentation
227  //## @brief Set @a data as slice @a s at time @a t in channel @a n. It is in
228  //## the responsibility of the caller to ensure that the data vector @a data
229  //## is really a slice (at least is not smaller than a slice), since there is
230  //## no chance to check this.
231  //##
232  //## The data is managed according to the parameter \a importMemoryManagement.
233  //## @sa SetPicSlice
234  virtual bool SetImportSlice(
235  void *data, int s = 0, int t = 0, int n = 0, ImportMemoryManagementType importMemoryManagement = CopyMemory);
236 
237  //##Documentation
238  //## @brief Set @a data as volume at time @a t in channel @a n. It is in
239  //## the responsibility of the caller to ensure that the data vector @a data
240  //## is really a volume (at least is not smaller than a volume), since there is
241  //## no chance to check this.
242  //##
243  //## The data is managed according to the parameter \a importMemoryManagement.
244  //## @sa SetPicVolume
245  virtual bool SetImportVolume(void *data,
246  int t = 0,
247  int n = 0,
248  ImportMemoryManagementType importMemoryManagement = CopyMemory);
249 
250  //##Documentation
251  //## @brief Set @a data in channel @a n. It is in
252  //## the responsibility of the caller to ensure that the data vector @a data
253  //## is really a channel (at least is not smaller than a channel), since there is
254  //## no chance to check this.
255  //##
256  //## The data is managed according to the parameter \a importMemoryManagement.
257  //## @sa SetPicChannel
258  virtual bool SetImportChannel(void *data,
259  int n = 0,
260  ImportMemoryManagementType importMemoryManagement = CopyMemory);
261 
262  //##Documentation
263  //## initialize new (or re-initialize) image information
264  //## @warning Initialize() by pic assumes a plane, evenly spaced geometry starting at (0,0,0).
265  virtual void Initialize(const mitk::PixelType &type,
266  unsigned int dimension,
267  const unsigned int *dimensions,
268  unsigned int channels = 1);
269 
270  //##Documentation
271  //## initialize new (or re-initialize) image information by a BaseGeometry
272  //##
273  //## @param tDim defines the number of time steps for which the Image should be initialized
274  virtual void Initialize(const mitk::PixelType &type,
275  const mitk::BaseGeometry &geometry,
276  unsigned int channels = 1,
277  int tDim = 1);
278 
286  DEPRECATED(virtual void Initialize(const mitk::PixelType & /*type*/,
287  const mitk::TimeSlicedGeometry * /*geometry*/,
288  unsigned int /*channels = 1*/,
289  int /*tDim=1*/))
290  {
291  }
292 
298  virtual void Initialize(const mitk::PixelType &type,
299  const mitk::TimeGeometry &geometry,
300  unsigned int channels = 1,
301  int tDim = -1);
302 
303  //##Documentation
304  //## initialize new (or re-initialize) image information by a PlaneGeometry and number of slices
305  //##
306  //## Initializes the bounding box according to the width/height of the
307  //## PlaneGeometry and @a sDim via SlicedGeometry3D::InitializeEvenlySpaced.
308  //## The spacing is calculated from the PlaneGeometry.
309  //## \sa SlicedGeometry3D::InitializeEvenlySpaced
310  //## \deprecatedSince{2016_11} Use a left-handed or right-handed PlaneGeometry to define the
311  //## direction of the image stack instead of the flipped parameter
312  DEPRECATED(virtual void Initialize(const mitk::PixelType &type,
313  int sDim,
314  const mitk::PlaneGeometry &geometry2d,
315  bool flipped,
316  unsigned int channels = 1,
317  int tDim = 1));
318 
319  virtual void Initialize(const mitk::PixelType &type,
320  int sDim,
321  const mitk::PlaneGeometry &geometry2d,
322  unsigned int channels = 1,
323  int tDim = 1);
324 
325  //##Documentation
326  //## initialize new (or re-initialize) image information by another
327  //## mitk-image.
328  //## Only the header is used, not the data vector!
329  //##
330  virtual void Initialize(const mitk::Image *image);
331 
332  virtual void Initialize(const mitk::ImageDescriptor::Pointer inDesc);
333 
334  //##Documentation
335  //## initialize new (or re-initialize) image information by @a pic.
336  //## Dimensions and @a Geometry3D /@a PlaneGeometry are set according
337  //## to the tags in @a pic.
338  //## Only the header is used, not the data vector! Use SetPicVolume(pic)
339  //## to set the data vector.
340  //##
341  //## @param tDim override time dimension (@a n[3]) in @a pic (if >0)
342  //## @param sDim override z-space dimension (@a n[2]) in @a pic (if >0)
343  //## @warning Initialize() by pic assumes a plane, evenly spaced geometry starting at (0,0,0).
344  // virtual void Initialize(const mitkIpPicDescriptor* pic, int channels = 1, int tDim = -1, int sDim = -1);
345 
346  //##Documentation
347  //## initialize new (or re-initialize) image information by @a vtkimagedata,
348  //## a vtk-image.
349  //## Only the header is used, not the data vector! Use
350  //## SetVolume(vtkimage->GetScalarPointer()) to set the data vector.
351  //##
352  //## @param tDim override time dimension in @a vtkimagedata (if >0 and <)
353  //## @param sDim override z-space dimension in @a vtkimagedata (if >0 and <)
354  //## @param pDim override y-space dimension in @a vtkimagedata (if >0 and <)
355  virtual void Initialize(vtkImageData *vtkimagedata, int channels = 1, int tDim = -1, int sDim = -1, int pDim = -1);
356 
357  //##Documentation
358  //## initialize new (or re-initialize) image information by @a itkimage,
359  //## a templated itk-image.
360  //## Only the header is used, not the data vector! Use
361  //## SetVolume(itkimage->GetBufferPointer()) to set the data vector.
362  //##
363  //## @param tDim override time dimension in @a itkimage (if >0 and <)
364  //## @param sDim override z-space dimension in @a itkimage (if >0 and <)
365  template <typename itkImageType>
366  void InitializeByItk(const itkImageType *itkimage, int channels = 1, int tDim = -1, int sDim = -1)
367  {
368  if (itkimage == nullptr)
369  return;
370 
371  MITK_DEBUG << "Initializing MITK image from ITK image.";
372  // build array with dimensions in each direction with at least 4 entries
373  m_Dimension = itkimage->GetImageDimension();
374  unsigned int i, *tmpDimensions = new unsigned int[m_Dimension > 4 ? m_Dimension : 4];
375  for (i = 0; i < m_Dimension; ++i)
376  tmpDimensions[i] = itkimage->GetLargestPossibleRegion().GetSize().GetSize()[i];
377  if (m_Dimension < 4)
378  {
379  unsigned int *p;
380  for (i = 0, p = tmpDimensions + m_Dimension; i < 4 - m_Dimension; ++i, ++p)
381  *p = 1;
382  }
383 
384  // overwrite number of slices if sDim is set
385  if ((m_Dimension > 2) && (sDim >= 0))
386  tmpDimensions[2] = sDim;
387  // overwrite number of time points if tDim is set
388  if ((m_Dimension > 3) && (tDim >= 0))
389  tmpDimensions[3] = tDim;
390 
391  // rough initialization of Image
392  // mitk::PixelType importType = ImportItkPixelType( itkimage::PixelType );
393 
394  Initialize(
395  MakePixelType<itkImageType>(itkimage->GetNumberOfComponentsPerPixel()), m_Dimension, tmpDimensions, channels);
396  const typename itkImageType::SpacingType &itkspacing = itkimage->GetSpacing();
397 
398  MITK_DEBUG << "ITK spacing " << itkspacing;
399  // access spacing of itk::Image
400  Vector3D spacing;
401  FillVector3D(spacing, itkspacing[0], 1.0, 1.0);
402  if (m_Dimension >= 2)
403  spacing[1] = itkspacing[1];
404  if (m_Dimension >= 3)
405  spacing[2] = itkspacing[2];
406 
407  // access origin of itk::Image
408  Point3D origin;
409  const typename itkImageType::PointType &itkorigin = itkimage->GetOrigin();
410  MITK_DEBUG << "ITK origin " << itkorigin;
411  FillVector3D(origin, itkorigin[0], 0.0, 0.0);
412  if (m_Dimension >= 2)
413  origin[1] = itkorigin[1];
414  if (m_Dimension >= 3)
415  origin[2] = itkorigin[2];
416 
417  // access direction of itk::Imagm_PixelType = new mitk::PixelType(type);e and include spacing
418  const typename itkImageType::DirectionType &itkdirection = itkimage->GetDirection();
419  MITK_DEBUG << "ITK direction " << itkdirection;
420  mitk::Matrix3D matrix;
421  matrix.SetIdentity();
422  unsigned int j, itkDimMax3 = (m_Dimension >= 3 ? 3 : m_Dimension);
423  // check if spacing has no zero entry and itkdirection has no zero columns
424  bool itkdirectionOk = true;
425  mitk::ScalarType columnSum;
426  for (j = 0; j < itkDimMax3; ++j)
427  {
428  columnSum = 0.0;
429  for (i = 0; i < itkDimMax3; ++i)
430  {
431  columnSum += fabs(itkdirection[i][j]);
432  }
433  if (columnSum < mitk::eps)
434  {
435  itkdirectionOk = false;
436  }
437  if ((spacing[j] < -mitk::eps) // (normally sized) negative value
438  &&
439  (j == 2) && (m_Dimensions[2] == 1))
440  {
441  // Negative spacings can occur when reading single DICOM slices with ITK via GDCMIO
442  // In these cases spacing is not determind by ITK correctly (because it distinguishes correctly
443  // between slice thickness and inter slice distance -- slice distance is meaningless for
444  // single slices).
445  // I experienced that ITK produced something meaningful nonetheless because is is
446  // evaluating the tag "(0018,0088) Spacing between slices" as a fallback. This tag is not
447  // reliable (http://www.itk.org/pipermail/insight-users/2005-September/014711.html)
448  // but gives at least a hint.
449  // In real world cases I experienced that this tag contained the correct inter slice distance
450  // with a negative sign, so we just invert such negative spacings.
451  MITK_WARN << "Illegal value of itk::Image::GetSpacing()[" << j << "]=" << spacing[j]
452  << ". Using inverted value " << -spacing[j];
453  spacing[j] = -spacing[j];
454  }
455  else if (spacing[j] < mitk::eps) // value near zero
456  {
457  MITK_ERROR << "Illegal value of itk::Image::GetSpacing()[" << j << "]=" << spacing[j]
458  << ". Using 1.0 instead.";
459  spacing[j] = 1.0;
460  }
461  }
462  if (itkdirectionOk == false)
463  {
464  MITK_ERROR << "Illegal matrix returned by itk::Image::GetDirection():" << itkdirection
465  << " Using identity instead.";
466  for (i = 0; i < itkDimMax3; ++i)
467  for (j = 0; j < itkDimMax3; ++j)
468  if (i == j)
469  matrix[i][j] = spacing[j];
470  else
471  matrix[i][j] = 0.0;
472  }
473  else
474  {
475  for (i = 0; i < itkDimMax3; ++i)
476  for (j = 0; j < itkDimMax3; ++j)
477  matrix[i][j] = itkdirection[i][j] * spacing[j];
478  }
479 
480  // re-initialize PlaneGeometry with origin and direction
481  PlaneGeometry *planeGeometry = static_cast<PlaneGeometry *>(GetSlicedGeometry(0)->GetPlaneGeometry(0));
482  planeGeometry->SetOrigin(origin);
483  planeGeometry->GetIndexToWorldTransform()->SetMatrix(matrix);
484 
485  // re-initialize SlicedGeometry3D
486  SlicedGeometry3D *slicedGeometry = GetSlicedGeometry(0);
487  slicedGeometry->InitializeEvenlySpaced(planeGeometry, m_Dimensions[2]);
488  slicedGeometry->SetSpacing(spacing);
489 
490  // re-initialize TimeGeometry
492  timeGeometry->Initialize(slicedGeometry, m_Dimensions[3]);
493  SetTimeGeometry(timeGeometry);
494 
495  // clean-up
496  delete[] tmpDimensions;
497 
498  this->Initialize();
499  }
500 
501  //##Documentation
502  //## @brief Check whether slice @a s at time @a t in channel @a n is valid, i.e.,
503  //## is (or can be) inside of the image
504  virtual bool IsValidSlice(int s = 0, int t = 0, int n = 0) const;
505 
506  //##Documentation
507  //## @brief Check whether volume at time @a t in channel @a n is valid, i.e.,
508  //## is (or can be) inside of the image
509  virtual bool IsValidVolume(int t = 0, int n = 0) const;
510 
511  //##Documentation
512  //## @brief Check whether the channel @a n is valid, i.e.,
513  //## is (or can be) inside of the image
514  virtual bool IsValidChannel(int n = 0) const;
515 
516  //##Documentation
517  //## @brief Returns true if an image is rotated, i.e. its geometry's
518  //## transformation matrix has nonzero elements besides the diagonal.
519  //## Non-diagonal elements are checked if larger then 1/1000 of the matrix' trace.
520  bool IsRotated() const;
521 
522  //##Documentation
523  //## @brief Get the sizes of all dimensions as an integer-array.
524  //##
525  //## @sa GetDimension(int i);
526  unsigned int *GetDimensions() const;
527 
528  ImageDescriptor::Pointer GetImageDescriptor() const { return m_ImageDescriptor; }
529  ChannelDescriptor GetChannelDescriptor(int id = 0) const { return m_ImageDescriptor->GetChannelDescriptor(id); }
532  virtual void SetGeometry(BaseGeometry *aGeometry3D) override;
533 
537  virtual ImageDataItemPointer GetSliceData(int s = 0,
538  int t = 0,
539  int n = 0,
540  void *data = nullptr,
541  ImportMemoryManagementType importMemoryManagement = CopyMemory) const;
542 
546  virtual ImageDataItemPointer GetVolumeData(int t = 0,
547  int n = 0,
548  void *data = nullptr,
549  ImportMemoryManagementType importMemoryManagement = CopyMemory) const;
550 
554  virtual ImageDataItemPointer GetChannelData(int n = 0,
555  void *data = nullptr,
556  ImportMemoryManagementType importMemoryManagement = CopyMemory) const;
557 
561  DEPRECATED(ScalarType GetScalarValueMin(int t = 0) const);
562 
568  DEPRECATED(ScalarType GetScalarValueMax(int t = 0) const);
569 
575  DEPRECATED(ScalarType GetScalarValue2ndMin(int t = 0) const);
576 
582  DEPRECATED(ScalarType GetScalarValueMinNoRecompute(unsigned int t = 0) const);
583 
589  DEPRECATED(ScalarType GetScalarValue2ndMinNoRecompute(unsigned int t = 0) const);
590 
596  DEPRECATED(ScalarType GetScalarValue2ndMax(int t = 0) const);
597 
603  DEPRECATED(ScalarType GetScalarValueMaxNoRecompute(unsigned int t = 0) const);
604 
610  DEPRECATED(ScalarType GetScalarValue2ndMaxNoRecompute(unsigned int t = 0) const);
611 
617  DEPRECATED(ScalarType GetCountOfMinValuedVoxels(int t = 0) const);
618 
624  DEPRECATED(ScalarType GetCountOfMaxValuedVoxels(int t = 0) const);
625 
631  DEPRECATED(unsigned int GetCountOfMaxValuedVoxelsNoRecompute(unsigned int t = 0) const);
632 
638  DEPRECATED(unsigned int GetCountOfMinValuedVoxelsNoRecompute(unsigned int t = 0) const);
639 
646  StatisticsHolderPointer GetStatistics() const { return m_ImageStatistics; }
647  protected:
649 
651 
652  int GetSliceIndex(int s = 0, int t = 0, int n = 0) const;
653 
654  int GetVolumeIndex(int t = 0, int n = 0) const;
655 
656  void ComputeOffsetTable();
657 
658  virtual bool IsValidTimeStep(int t) const;
659 
660  virtual void Expand(unsigned int timeSteps) override;
661 
662  virtual ImageDataItemPointer AllocateSliceData(
663  int s = 0,
664  int t = 0,
665  int n = 0,
666  void *data = nullptr,
667  ImportMemoryManagementType importMemoryManagement = CopyMemory) const;
668 
669  virtual ImageDataItemPointer AllocateVolumeData(
670  int t = 0, int n = 0, void *data = nullptr, ImportMemoryManagementType importMemoryManagement = CopyMemory) const;
671 
672  virtual ImageDataItemPointer AllocateChannelData(
673  int n = 0, void *data = nullptr, ImportMemoryManagementType importMemoryManagement = CopyMemory) const;
674 
675  Image();
676 
677  Image(const Image &other);
678 
679  virtual ~Image();
680 
681  virtual void Clear() override;
682 
683  //## @warning Has to be called by every Initialize method!
684  virtual void Initialize() override;
685 
686  virtual void PrintSelf(std::ostream &os, itk::Indent indent) const override;
687 
688  mutable ImageDataItemPointerArray m_Channels;
689  mutable ImageDataItemPointerArray m_Volumes;
690  mutable ImageDataItemPointerArray m_Slices;
691  mutable itk::SimpleFastMutexLock m_ImageDataArraysLock;
692 
693  unsigned int m_Dimension;
694 
695  unsigned int *m_Dimensions;
696 
698 
699  size_t *m_OffsetTable;
701 
702  // Image statistics Holder replaces the former implementation directly inside this class
703  friend class ImageStatisticsHolder;
705 
706  private:
707  ImageDataItemPointer GetSliceData_unlocked(
708  int s, int t, int n, void *data, ImportMemoryManagementType importMemoryManagement) const;
709  ImageDataItemPointer GetVolumeData_unlocked(int t,
710  int n,
711  void *data,
712  ImportMemoryManagementType importMemoryManagement) const;
713  ImageDataItemPointer GetChannelData_unlocked(int n,
714  void *data,
715  ImportMemoryManagementType importMemoryManagement) const;
716 
717  ImageDataItemPointer AllocateSliceData_unlocked(
718  int s, int t, int n, void *data, ImportMemoryManagementType importMemoryManagement) const;
719  ImageDataItemPointer AllocateVolumeData_unlocked(int t,
720  int n,
721  void *data,
722  ImportMemoryManagementType importMemoryManagement) const;
723  ImageDataItemPointer AllocateChannelData_unlocked(int n,
724  void *data,
725  ImportMemoryManagementType importMemoryManagement) const;
726 
727  bool IsSliceSet_unlocked(int s, int t, int n) const;
728  bool IsVolumeSet_unlocked(int t, int n) const;
729  bool IsChannelSet_unlocked(int n) const;
730 
732  mutable std::vector<ImageAccessorBase *> m_Readers;
734  mutable std::vector<ImageAccessorBase *> m_Writers;
736  mutable std::vector<ImageAccessorBase *> m_VtkReaders;
737 
739  itk::SimpleFastMutexLock m_ReadWriteLock;
741  itk::SimpleFastMutexLock m_VtkReadersLock;
742  };
743 
765  const mitk::Image *leftHandSide, const mitk::Image *rightHandSide, ScalarType eps, bool verbose));
766 
785  MITKCORE_EXPORT bool Equal(const mitk::Image &leftHandSide,
786  const mitk::Image &rightHandSide,
787  ScalarType eps,
788  bool verbose);
789 
790 } // namespace mitk
791 
792 #endif /* MITKIMAGE_H_HEADER_INCLUDED_C1C2FCD2 */
mitk::Point3D PointType
unsigned int * m_Dimensions
Definition: mitkImage.h:695
void SetSpacing(const mitk::Vector3D &aSpacing, bool enforceSetSpacing=false)
Set the spacing (m_Spacing).
#define MITKCORE_EXPORT
Base of all data objects.
Definition: mitkBaseData.h:39
#define MITK_ERROR
Definition: mitkLogMacros.h:24
double ScalarType
ImageDataItemPointerArray m_Slices
Definition: mitkImage.h:690
StatisticsHolderPointer GetStatistics() const
Returns a pointer to the ImageStatisticsHolder object that holds all statistics information for the i...
Definition: mitkImage.h:646
vcl_size_t * m_OffsetTable
Definition: mitkImage.h:699
#define MITK_DEBUG
Definition: mitkLogMacros.h:26
DataCollection - Class to facilitate loading/accessing structured data.
ImageDataItemPointerArray m_Channels
Definition: mitkImage.h:688
ImportMemoryManagementType
Definition: mitkImage.h:106
ChannelDescriptor GetChannelDescriptor(int id=0) const
Definition: mitkImage.h:529
An object which holds all essential information about a single channel of an Image.
ImageVtkAccessor class provides any image read access which is required by Vtk methods.
virtual void InitializeEvenlySpaced(mitk::PlaneGeometry *geometry2D, unsigned int slices)
Completely initialize this instance as evenly-spaced with slices parallel to the provided PlaneGeomet...
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
Definition: mitkArray.h:110
ImageDataItemPointerArray m_Volumes
Definition: mitkImage.h:689
itk::Statistics::Histogram< double > HistogramType
Definition: mitkImage.h:94
#define DEPRECATED(func)
Definition: mitkCommon.h:183
T::Pointer GetData(const std::string &name)
itk::SimpleFastMutexLock m_ImageDataArraysLock
Definition: mitkImage.h:691
StatisticsHolderPointer m_ImageStatistics
Definition: mitkImage.h:704
class ITK_EXPORT Image
#define MITK_WARN
Definition: mitkLogMacros.h:23
Super class of data objects consisting of slices.
std::vector< ImageDataItemPointer > ImageDataItemPointerArray
Vector container of SmartPointers to ImageDataItems; Class is only for internal usage to allow conven...
Definition: mitkImage.h:118
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44
void SetOrigin(const Point3D &origin)
Set the origin, i.e. the upper-left corner of the plane.
Image class for storing images.
Definition: mitkImage.h:76
unsigned int m_Dimension
Definition: mitkImage.h:693
itk::MutexLockHolder< itk::SimpleFastMutexLock > MutexHolder
Definition: mitkImage.h:648
Describes the geometry of a data object consisting of slices.
#define mitkCloneMacro(classname)
Definition: mitkCommon.h:162
Class holding the statistics informations about a single mitk::Image.
ImageVtkReadAccessor class provides any image read access which is required by Vtk methods...
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
MITKCORE_EXPORT const ScalarType eps
Base class of all classes providing access to parts of an image.
ImageWriteAccessor class to get locked write-access for a particular image part.
Describes a two-dimensional, rectangular plane.
Internal class for managing references on sub-images.
ImageReadAccessor class to get locked read access for a particular image part.
ImageVtkWriteAccessor class provides any image write access which is required by Vtk methods...
ImageDescriptor::Pointer GetImageDescriptor() const
Definition: mitkImage.h:528
ImageDataItemPointer m_CompleteData
Definition: mitkImage.h:700
BaseGeometry Describes the geometry of a data object.
void InitializeByItk(const itkImageType *itkimage, int channels=1, int tDim=-1, int sDim=-1)
Definition: mitkImage.h:366
Class for defining the data type of pixels.
Definition: mitkPixelType.h:55
mitk::AffineTransform3D * GetIndexToWorldTransform()
Get the transformation used to convert from index to world coordinates.
ImageDescriptor::Pointer m_ImageDescriptor
Definition: mitkImage.h:697