17 #ifndef MITKIMAGE_H_HEADER_INCLUDED_C1C2FCD2
18 #define MITKIMAGE_H_HEADER_INCLUDED_C1C2FCD2
34 #ifndef __itkHistogram_h
35 #include <itkHistogram.h>
48 class SubImageSelector;
49 class ImageTimeSelector;
51 class ImageStatisticsHolder;
90 itkFactorylessNewMacro(
Self) itkCloneMacro(
Self)
111 DontManageMemory = ReferenceMemory
128 unsigned int GetDimension()
const;
134 unsigned int GetDimension(
int i)
const;
151 unsigned int timestep = 0,
152 unsigned int component = 0));
160 unsigned int timestep = 0,
161 unsigned int component = 0));
165 virtual vtkImageData *GetVtkImageData(
int t = 0,
int n = 0);
166 virtual const vtkImageData *GetVtkImageData(
int t = 0,
int n = 0)
const;
177 virtual bool IsSliceSet(
int s = 0,
int t = 0,
int n = 0)
const override;
181 virtual bool IsVolumeSet(
int t = 0,
int n = 0)
const override;
185 virtual bool IsChannelSet(
int n = 0)
const override;
198 virtual bool SetSlice(
const void *data,
int s = 0,
int t = 0,
int n = 0);
211 virtual bool SetVolume(
const void *data,
int t = 0,
int n = 0);
224 virtual bool SetChannel(
const void *data,
int n = 0);
234 virtual bool SetImportSlice(
245 virtual bool SetImportVolume(
void *data,
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];
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;
532 virtual void SetGeometry(
BaseGeometry *aGeometry3D)
override;
537 virtual ImageDataItemPointer GetSliceData(
int s = 0,
540 void *data =
nullptr,
541 ImportMemoryManagementType importMemoryManagement = CopyMemory)
const;
546 virtual ImageDataItemPointer GetVolumeData(
int t = 0,
548 void *data =
nullptr,
549 ImportMemoryManagementType importMemoryManagement = CopyMemory)
const;
554 virtual ImageDataItemPointer GetChannelData(
int n = 0,
555 void *data =
nullptr,
556 ImportMemoryManagementType importMemoryManagement = CopyMemory)
const;
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 virtual void Expand(
unsigned int timeSteps)
override;
666 void *data =
nullptr,
681 virtual void Clear()
override;
684 virtual void Initialize()
override;
686 virtual void PrintSelf(std::ostream &os, itk::Indent indent)
const override;
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;
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
StatisticsHolderPointer GetStatistics() const
Returns a pointer to the ImageStatisticsHolder object that holds all statistics information for the i...
vcl_size_t * m_OffsetTable
DataCollection - Class to facilitate loading/accessing structured data.
ImageDataItemPointerArray m_Channels
ImportMemoryManagementType
ChannelDescriptor GetChannelDescriptor(int id=0) const
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
itk::Statistics::Histogram< double > HistogramType
T::Pointer GetData(const std::string &name)
itk::SimpleFastMutexLock m_ImageDataArraysLock
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.
Image class for storing images.
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...
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
ImageDataItemPointer m_CompleteData
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