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