13 #ifndef MITKIMAGE_H_HEADER_INCLUDED_C1C2FCD2 14 #define MITKIMAGE_H_HEADER_INCLUDED_C1C2FCD2 30 #ifndef __itkHistogram_h 31 #include <itkHistogram.h> 44 class SubImageSelector;
45 class ImageTimeSelector;
47 class ImageStatisticsHolder;
86 itkFactorylessNewMacro(
Self);
109 DontManageMemory = ReferenceMemory
126 unsigned int GetDimension()
const;
132 unsigned int GetDimension(
int i)
const;
149 unsigned int timestep = 0,
150 unsigned int component = 0));
157 double GetPixelValueByWorldCoordinate(
const mitk::Point3D &position,
158 unsigned int timestep = 0,
159 unsigned int component = 0);
163 virtual vtkImageData *GetVtkImageData(
int t = 0,
int n = 0);
164 virtual const vtkImageData *GetVtkImageData(
int t = 0,
int n = 0)
const;
175 bool IsSliceSet(
int s = 0,
int t = 0,
int n = 0)
const override;
179 bool IsVolumeSet(
int t = 0,
int n = 0)
const override;
183 bool IsChannelSet(
int n = 0)
const override;
196 virtual bool SetSlice(
const void *data,
int s = 0,
int t = 0,
int n = 0);
209 virtual bool SetVolume(
const void *data,
int t = 0,
int n = 0);
222 virtual bool SetChannel(
const void *data,
int n = 0);
232 virtual bool SetImportSlice(
243 virtual bool SetImportVolume(
void *data,
248 virtual bool SetImportVolume(
const void *const_data,
int t = 0,
int n = 0);
258 virtual bool SetImportChannel(
void *data,
266 unsigned int dimension,
267 const unsigned int *dimensions,
268 unsigned int channels = 1);
276 unsigned int channels = 1,
300 unsigned int channels = 1,
316 unsigned int channels = 1,
322 unsigned int channels = 1,
355 virtual void Initialize(vtkImageData *vtkimagedata,
int channels = 1,
int tDim = -1,
int sDim = -1,
int pDim = -1);
365 template <
typename itkImageType>
366 void InitializeByItk(
const itkImageType *itkimage,
int channels = 1,
int tDim = -1,
int sDim = -1)
368 if (itkimage ==
nullptr)
371 MITK_DEBUG <<
"Initializing MITK image from ITK image.";
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];
380 for (i = 0, p = tmpDimensions + m_Dimension; i < 4 - m_Dimension; ++i, ++p)
385 if ((m_Dimension > 2) && (sDim >= 0))
386 tmpDimensions[2] = sDim;
388 if ((m_Dimension > 3) && (tDim >= 0))
389 tmpDimensions[3] = tDim;
395 MakePixelType<itkImageType>(itkimage->GetNumberOfComponentsPerPixel()), m_Dimension, tmpDimensions, channels);
396 const typename itkImageType::SpacingType &itkspacing = itkimage->GetSpacing();
402 if (m_Dimension >= 2)
403 spacing[1] = itkspacing[1];
404 if (m_Dimension >= 3)
405 spacing[2] = itkspacing[2];
409 const typename itkImageType::PointType &itkorigin = itkimage->GetOrigin();
412 if (m_Dimension >= 2)
413 origin[1] = itkorigin[1];
414 if (m_Dimension >= 3)
415 origin[2] = itkorigin[2];
418 const typename itkImageType::DirectionType &itkdirection = itkimage->GetDirection();
419 MITK_DEBUG <<
"ITK direction " << itkdirection;
421 matrix.SetIdentity();
422 unsigned int j, itkDimMax3 = (m_Dimension >= 3 ? 3 : m_Dimension);
424 bool itkdirectionOk =
true;
426 for (j = 0; j < itkDimMax3; ++j)
429 for (i = 0; i < itkDimMax3; ++i)
431 columnSum += fabs(itkdirection[i][j]);
435 itkdirectionOk =
false;
439 (j == 2) && (m_Dimensions[2] == 1))
451 MITK_WARN <<
"Illegal value of itk::Image::GetSpacing()[" << j <<
"]=" << spacing[j]
452 <<
". Using inverted value " << -spacing[j];
453 spacing[j] = -spacing[j];
457 MITK_ERROR <<
"Illegal value of itk::Image::GetSpacing()[" << j <<
"]=" << spacing[j]
458 <<
". Using 1.0 instead.";
462 if (itkdirectionOk ==
false)
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)
469 matrix[i][j] = spacing[j];
475 for (i = 0; i < itkDimMax3; ++i)
476 for (j = 0; j < itkDimMax3; ++j)
477 matrix[i][j] = itkdirection[i][j] * spacing[j];
492 timeGeometry->Initialize(slicedGeometry, m_Dimensions[3]);
493 SetTimeGeometry(timeGeometry);
496 delete[] tmpDimensions;
504 virtual bool IsValidSlice(
int s = 0,
int t = 0,
int n = 0)
const;
509 virtual bool IsValidVolume(
int t = 0,
int n = 0)
const;
514 virtual bool IsValidChannel(
int n = 0)
const;
520 bool IsRotated()
const;
526 unsigned int *GetDimensions()
const;
537 virtual ImageDataItemPointer GetSliceData(
int s = 0,
540 void *data =
nullptr,
546 virtual ImageDataItemPointer GetVolumeData(
int t = 0,
548 void *data =
nullptr,
554 virtual ImageDataItemPointer GetChannelData(
int n = 0,
555 void *data =
nullptr,
631 DEPRECATED(
unsigned int GetCountOfMaxValuedVoxelsNoRecompute(
unsigned int t = 0)
const);
638 DEPRECATED(
unsigned int GetCountOfMinValuedVoxelsNoRecompute(
unsigned int t = 0)
const);
652 int GetSliceIndex(
int s = 0,
int t = 0,
int n = 0)
const;
654 int GetVolumeIndex(
int t = 0,
int n = 0)
const;
656 void ComputeOffsetTable();
658 virtual bool IsValidTimeStep(
int t)
const;
660 void Expand(
unsigned int timeSteps)
override;
662 virtual ImageDataItemPointer AllocateSliceData(
666 void *data =
nullptr,
669 virtual ImageDataItemPointer AllocateVolumeData(
672 virtual ImageDataItemPointer AllocateChannelData(
681 void Clear()
override;
684 void Initialize()
override;
686 void PrintSelf(std::ostream &os, itk::Indent indent)
const override;
707 ImageDataItemPointer GetSliceData_unlocked(
709 ImageDataItemPointer GetVolumeData_unlocked(
int t,
713 ImageDataItemPointer GetChannelData_unlocked(
int n,
717 ImageDataItemPointer AllocateSliceData_unlocked(
719 ImageDataItemPointer AllocateVolumeData_unlocked(
int t,
723 ImageDataItemPointer AllocateChannelData_unlocked(
int n,
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;
732 mutable std::vector<ImageAccessorBase *> m_Readers;
734 mutable std::vector<ImageAccessorBase *> m_Writers;
736 mutable std::vector<ImageAccessorBase *> m_VtkReaders;
739 itk::SimpleFastMutexLock m_ReadWriteLock;
741 itk::SimpleFastMutexLock m_VtkReadersLock;
itk::SmartPointer< ImageDataItem > ImageDataItemPointer
unsigned int * m_Dimensions
void SetSpacing(const mitk::Vector3D &aSpacing, bool enforceSetSpacing=false)
Set the spacing (m_Spacing).
Base of all data objects.
ImageDataItemPointerArray m_Slices
vcl_size_t * m_OffsetTable
DataCollection - Class to facilitate loading/accessing structured data.
ImageDataItemPointerArray m_Channels
StatisticsHolderPointer GetStatistics() const
Returns a pointer to the ImageStatisticsHolder object that holds all statistics information for the i...
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)
ImageDataItemPointerArray m_Volumes
ChannelDescriptor GetChannelDescriptor(int id=0) const
itk::Statistics::Histogram< double > HistogramType
itk::SimpleFastMutexLock m_ImageDataArraysLock
mitk::ImageStatisticsHolder * StatisticsHolderPointer
StatisticsHolderPointer m_ImageStatistics
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...
#define mitkClassMacro(className, SuperClassName)
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.
Image class for storing images.
mitk::Image::Pointer image
itk::MutexLockHolder< itk::SimpleFastMutexLock > MutexHolder
Describes the geometry of a data object consisting of slices.
#define mitkCloneMacro(classname)
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
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
ImportMemoryManagementType
BaseGeometry Describes the geometry of a data object.
void InitializeByItk(const itkImageType *itkimage, int channels=1, int tDim=-1, int sDim=-1)
Class for defining the data type of pixels.
mitk::AffineTransform3D * GetIndexToWorldTransform()
Get the transformation used to convert from index to world coordinates.
ImageDescriptor::Pointer m_ImageDescriptor