Medical Imaging Interaction Toolkit  2018.4.99-6ca56567
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);
87 
88  itkCloneMacro(Self);
89 
92  typedef itk::Statistics::Histogram<double> HistogramType;
94 
95  //## @param ImportMemoryManagementType This parameter is evaluated when setting new data to an image.
96  //## The different options are:
97  //## CopyMemory: Data to be set is copied and assigned to a new memory block. Data memory block will be freed on
98  // deletion of mitk::Image.
99  //## MamageMemory: Data to be set will be referenced, and Data memory block will be freed on deletion of
100  //mitk::Image.
101  //## Reference Memory: Data to be set will be referenced, but Data memory block will not be freed on deletion of
102  // mitk::Image.
103  //## DontManageMemory = ReferenceMemory.
105  {
109  DontManageMemory = ReferenceMemory
110  };
111 
112  //##Documentation
113  //## @brief Vector container of SmartPointers to ImageDataItems;
114  //## Class is only for internal usage to allow convenient access to all slices over iterators;
115  //## See documentation of ImageDataItem for details.
116  typedef std::vector<ImageDataItemPointer> ImageDataItemPointerArray;
117 
118  public:
119  //##Documentation
120  //## @brief Returns the PixelType of channel @a n.
121  const mitk::PixelType GetPixelType(int n = 0) const;
122 
123  //##Documentation
124  //## @brief Get dimension of the image
125  //##
126  unsigned int GetDimension() const;
127 
128  //##Documentation
129  //## @brief Get the size of dimension @a i (e.g., i=0 results in the number of pixels in x-direction).
130  //##
131  //## @sa GetDimensions()
132  unsigned int GetDimension(int i) const;
133 
140  DEPRECATED(virtual void *GetData());
141 
142  public:
148  DEPRECATED(double GetPixelValueByIndex(const itk::Index<3> &position,
149  unsigned int timestep = 0,
150  unsigned int component = 0));
151 
157  double GetPixelValueByWorldCoordinate(const mitk::Point3D &position,
158  unsigned int timestep = 0,
159  unsigned int component = 0);
160 
161  //##Documentation
162  //## @brief Get a volume at a specific time @a t of channel @a n as a vtkImageData.
163  virtual vtkImageData *GetVtkImageData(int t = 0, int n = 0);
164  virtual const vtkImageData *GetVtkImageData(int t = 0, int n = 0) const;
165 
166  //##Documentation
167  //## @brief Get the complete image, i.e., all channels linked together, as a @a mitkIpPicDescriptor.
168  //##
169  //## If you only want to access a slice, volume at a specific time or single channel
170  //## use one of the SubImageSelector classes.
171  // virtual mitkIpPicDescriptor* GetPic();
172 
173  //##Documentation
174  //## @brief Check whether slice @a s at time @a t in channel @a n is set
175  bool IsSliceSet(int s = 0, int t = 0, int n = 0) const override;
176 
177  //##Documentation
178  //## @brief Check whether volume at time @a t in channel @a n is set
179  bool IsVolumeSet(int t = 0, int n = 0) const override;
180 
181  //##Documentation
182  //## @brief Check whether the channel @a n is set
183  bool IsChannelSet(int n = 0) const override;
184 
185  //##Documentation
186  //## @brief Set @a data as slice @a s at time @a t in channel @a n. It is in
187  //## the responsibility of the caller to ensure that the data vector @a data
188  //## is really a slice (at least is not smaller than a slice), since there is
189  //## no chance to check this.
190  //##
191  //## The data is copied to an array managed by the image. If the image shall
192  //## reference the data, use SetImportSlice with ImportMemoryManagementType
193  //## set to ReferenceMemory. For importing ITK images use of mitk::
194  //## ITKImageImport is recommended.
195  //## @sa SetPicSlice, SetImportSlice, SetImportVolume
196  virtual bool SetSlice(const void *data, int s = 0, int t = 0, int n = 0);
197 
198  //##Documentation
199  //## @brief Set @a data as volume at time @a t in channel @a n. It is in
200  //## the responsibility of the caller to ensure that the data vector @a data
201  //## is really a volume (at least is not smaller than a volume), since there is
202  //## no chance to check this.
203  //##
204  //## The data is copied to an array managed by the image. If the image shall
205  //## reference the data, use SetImportVolume with ImportMemoryManagementType
206  //## set to ReferenceMemory. For importing ITK images use of mitk::
207  //## ITKImageImport is recommended.
208  //## @sa SetPicVolume, SetImportVolume
209  virtual bool SetVolume(const void *data, int t = 0, int n = 0);
210 
211  //##Documentation
212  //## @brief Set @a data in channel @a n. It is in
213  //## the responsibility of the caller to ensure that the data vector @a data
214  //## is really a channel (at least is not smaller than a channel), since there is
215  //## no chance to check this.
216  //##
217  //## The data is copied to an array managed by the image. If the image shall
218  //## reference the data, use SetImportChannel with ImportMemoryManagementType
219  //## set to ReferenceMemory. For importing ITK images use of mitk::
220  //## ITKImageImport is recommended.
221  //## @sa SetPicChannel, SetImportChannel
222  virtual bool SetChannel(const void *data, int n = 0);
223 
224  //##Documentation
225  //## @brief Set @a data as slice @a s at time @a t in channel @a n. It is in
226  //## the responsibility of the caller to ensure that the data vector @a data
227  //## is really a slice (at least is not smaller than a slice), since there is
228  //## no chance to check this.
229  //##
230  //## The data is managed according to the parameter \a importMemoryManagement.
231  //## @sa SetPicSlice
232  virtual bool SetImportSlice(
233  void *data, int s = 0, int t = 0, int n = 0, ImportMemoryManagementType importMemoryManagement = CopyMemory);
234 
235  //##Documentation
236  //## @brief Set @a data as volume at time @a t in channel @a n. It is in
237  //## the responsibility of the caller to ensure that the data vector @a data
238  //## is really a volume (at least is not smaller than a volume), since there is
239  //## no chance to check this.
240  //##
241  //## The data is managed according to the parameter \a importMemoryManagement.
242  //## @sa SetPicVolume
243  virtual bool SetImportVolume(void *data,
244  int t = 0,
245  int n = 0,
246  ImportMemoryManagementType importMemoryManagement = CopyMemory);
247 
248  virtual bool SetImportVolume(const void *const_data, int t = 0, int n = 0);
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
491  ProportionalTimeGeometry::Pointer timeGeometry = ProportionalTimeGeometry::New();
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  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  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  ~Image() override;
680 
681  void Clear() override;
682 
683  //## @warning Has to be called by every Initialize method!
684  void Initialize() override;
685 
686  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;
700  ImageDataItemPointer m_CompleteData;
701 
702  // Image statistics Holder replaces the former implementation directly inside this class
703  friend class ImageStatisticsHolder;
704  StatisticsHolderPointer m_ImageStatistics;
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 */
itk::SmartPointer< ImageDataItem > ImageDataItemPointer
Definition: mitkImage.h:88
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:42
#define MITK_ERROR
Definition: mitkLogMacros.h:20
double ScalarType
ImageDataItemPointerArray m_Slices
Definition: mitkImage.h:690
vcl_size_t * m_OffsetTable
Definition: mitkImage.h:699
#define MITK_DEBUG
Definition: mitkLogMacros.h:22
DataCollection - Class to facilitate loading/accessing structured data.
ImageDataItemPointerArray m_Channels
Definition: mitkImage.h:688
StatisticsHolderPointer GetStatistics() const
Returns a pointer to the ImageStatisticsHolder object that holds all statistics information for the i...
Definition: mitkImage.h:646
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:689
ChannelDescriptor GetChannelDescriptor(int id=0) const
Definition: mitkImage.h:529
itk::Statistics::Histogram< double > HistogramType
Definition: mitkImage.h:92
#define DEPRECATED(func)
Definition: mitkCommon.h:179
itk::SimpleFastMutexLock m_ImageDataArraysLock
Definition: mitkImage.h:691
mitk::ImageStatisticsHolder * StatisticsHolderPointer
Definition: mitkImage.h:93
StatisticsHolderPointer m_ImageStatistics
Definition: mitkImage.h:704
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:116
#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:693
mitk::Image::Pointer image
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: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:528
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:700
ImportMemoryManagementType
Definition: mitkImage.h:104
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:51
mitk::AffineTransform3D * GetIndexToWorldTransform()
Get the transformation used to convert from index to world coordinates.
ImageDescriptor::Pointer m_ImageDescriptor
Definition: mitkImage.h:697