Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends

mitk::Image Class Reference
[Data Classes]

Image class for storing images. More...

#include <mitkImage.h>

Inheritance diagram for mitk::Image:
Inheritance graph
[legend]
Collaboration diagram for mitk::Image:
Collaboration graph
[legend]

List of all members.

Public Types

enum  ImportMemoryManagementType { CopyMemory, ManageMemory, ReferenceMemory, DontManageMemory = ReferenceMemory }
typedef Image Self
typedef SlicedData Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer
typedef
itk::SmartPointerForwardReference
< ImageDataItem
ImageDataItemPointer
typedef std::vector
< ImageDataItemPointer
ImageDataItemPointerArray
 Vector container of SmartPointers to ImageDataItems; Class is only for internal usage to allow convenient access to all slices over iterators; See documentation of ImageDataItem for details.
typedef
itk::Statistics::Histogram
< double > 
HistogramType

Public Member Functions

virtual const char * GetClassName () const
const mitk::PixelTypeGetPixelType (int n=0) const
 Returns the PixelType of channel n.
unsigned int GetDimension () const
 Get dimension of the image.
unsigned int GetDimension (int i) const
 Get the size of dimension i (e.g., i=0 results in the number of pixels in x-direction).
virtual void * GetData ()
double GetPixelValueByIndex (const mitk::Index3D &position, unsigned int timestep=0)
double GetPixelValueByWorldCoordinate (const mitk::Point3D &position, unsigned int timestep=0)
virtual vtkImageData * GetVtkImageData (int t=0, int n=0)
 Get a volume at a specific time t of channel n as a vtkImageData.
virtual mitkIpPicDescriptor * GetPic ()
 Get the complete image, i.e., all channels linked together, as a mitkIpPicDescriptor.
virtual bool IsSliceSet (int s=0, int t=0, int n=0) const
 Check whether slice s at time t in channel n is set.
virtual bool IsVolumeSet (int t=0, int n=0) const
 Check whether volume at time t in channel n is set.
virtual bool IsChannelSet (int n=0) const
 Check whether the channel n is set.
virtual bool SetSlice (const void *data, int s=0, int t=0, int n=0)
 Set data as slice s at time t in channel n. It is in the responsibility of the caller to ensure that the data vector data is really a slice (at least is not smaller than a slice), since there is no chance to check this.
virtual bool SetVolume (const void *data, int t=0, int n=0)
 Set data as volume at time t in channel n. It is in the responsibility of the caller to ensure that the data vector data is really a volume (at least is not smaller than a volume), since there is no chance to check this.
virtual bool SetChannel (const void *data, int n=0)
 Set data in channel n. It is in the responsibility of the caller to ensure that the data vector data is really a channel (at least is not smaller than a channel), since there is no chance to check this.
virtual bool SetImportSlice (void *data, int s=0, int t=0, int n=0, ImportMemoryManagementType importMemoryManagement=CopyMemory)
 Set data as slice s at time t in channel n. It is in the responsibility of the caller to ensure that the data vector data is really a slice (at least is not smaller than a slice), since there is no chance to check this.
virtual bool SetImportVolume (void *data, int t=0, int n=0, ImportMemoryManagementType importMemoryManagement=CopyMemory)
 Set data as volume at time t in channel n. It is in the responsibility of the caller to ensure that the data vector data is really a volume (at least is not smaller than a volume), since there is no chance to check this.
virtual bool SetImportChannel (void *data, int n=0, ImportMemoryManagementType importMemoryManagement=CopyMemory)
 Set data in channel n. It is in the responsibility of the caller to ensure that the data vector data is really a channel (at least is not smaller than a channel), since there is no chance to check this.
virtual bool SetPicSlice (const mitkIpPicDescriptor *pic, int s=0, int t=0, int n=0, ImportMemoryManagementType importMemoryManagement=CopyMemory)
 Set pic as slice s at time t in channel n.
virtual bool SetPicVolume (const mitkIpPicDescriptor *pic, int t=0, int n=0, ImportMemoryManagementType importMemoryManagement=CopyMemory)
 Set pic as volume at time t in channel n.
virtual bool SetPicChannel (const mitkIpPicDescriptor *pic, int n=0, ImportMemoryManagementType importMemoryManagement=CopyMemory)
 Set pic in channel n.
virtual void Initialize (const mitk::PixelType &type, unsigned int dimension, unsigned int *dimensions, unsigned int channels=1)
virtual void Initialize (const mitk::PixelType &type, const mitk::Geometry3D &geometry, unsigned int channels=1, int tDim=-1)
virtual void Initialize (const mitk::PixelType &type, int sDim, const mitk::Geometry2D &geometry2d, bool flipped=false, unsigned int channels=1, int tDim=-1)
virtual void Initialize (const mitk::Image *image)
virtual void Initialize (const mitkIpPicDescriptor *pic, int channels=1, int tDim=-1, int sDim=-1)
virtual void Initialize (vtkImageData *vtkimagedata, int channels=1, int tDim=-1, int sDim=-1)
template<typename itkImageType >
void InitializeByItk (const itkImageType *itkimage, int channels=1, int tDim=-1, int sDim=-1)
virtual bool IsValidSlice (int s=0, int t=0, int n=0) const
 Check whether slice s at time t in channel n is valid, i.e., is (or can be) inside of the image.
virtual bool IsValidVolume (int t=0, int n=0) const
 Check whether volume at time t in channel n is valid, i.e., is (or can be) inside of the image.
virtual bool IsValidChannel (int n=0) const
 Check whether the channel n is valid, i.e., is (or can be) inside of the image.
bool IsRotated () const
 Returns true if an image is rotated, i.e. its geometry's transformation matrix has nonzero elements besides the diagonal. Non-diagonal elements are checked if larger then 1/1000 of the matrix' trace.
unsigned int * GetDimensions () const
 Get the sizes of all dimensions as an integer-array.
virtual void SetGeometry (Geometry3D *aGeometry3D)
 Set the Geometry3D of the data, which will be referenced (not copied!). It has to be a sub-class of SlicedGeometry3D.
virtual const HistogramTypeGetScalarHistogram (int t=0) const
virtual ScalarType GetScalarValueMin (int t=0) const
 Get the minimum for scalar images.
virtual ScalarType GetScalarValueMax (int t=0) const
 Get the maximum for scalar images.
virtual ScalarType GetScalarValue2ndMin (int t=0) const
 Get the second smallest value for scalar images.
virtual mitk::ScalarType GetScalarValueMinNoRecompute (unsigned int t=0) const
 Get the smallest value for scalar images, but do not recompute it first.
virtual mitk::ScalarType GetScalarValue2ndMinNoRecompute (unsigned int t=0) const
 Get the second smallest value for scalar images, but do not recompute it first.
virtual ScalarType GetScalarValue2ndMax (int t=0) const
 Get the second largest value for scalar images.
virtual mitk::ScalarType GetScalarValueMaxNoRecompute (unsigned int t=0) const
 Get the largest value for scalar images, but do not recompute it first.
virtual mitk::ScalarType GetScalarValue2ndMaxNoRecompute (unsigned int t=0) const
 Get the second largest value for scalar images, but do not recompute it first.
mitk::ScalarType GetCountOfMinValuedVoxels (int t=0) const
 Get the count of voxels with the smallest scalar value in the dataset.
mitk::ScalarType GetCountOfMaxValuedVoxels (int t=0) const
 Get the count of voxels with the largest scalar value in the dataset.
virtual unsigned int GetCountOfMaxValuedVoxelsNoRecompute (unsigned int t=0) const
 Get the count of voxels with the largest scalar value in the dataset.
virtual unsigned int GetCountOfMinValuedVoxelsNoRecompute (unsigned int t=0) const
 Get the count of voxels with the smallest scalar value in the dataset.
virtual ImageDataItemPointer GetSliceData (int s=0, int t=0, int n=0, void *data=NULL, ImportMemoryManagementType importMemoryManagement=CopyMemory)
virtual ImageDataItemPointer GetVolumeData (int t=0, int n=0, void *data=NULL, ImportMemoryManagementType importMemoryManagement=CopyMemory)
virtual ImageDataItemPointer GetChannelData (int n=0, void *data=NULL, ImportMemoryManagementType importMemoryManagement=CopyMemory)

Static Public Member Functions

static Pointer New ()

Protected Member Functions

int GetSliceIndex (int s=0, int t=0, int n=0) const
int GetVolumeIndex (int t=0, int n=0) const
void ComputeOffsetTable ()
virtual void Expand (int timeSteps) const
virtual bool IsValidTimeStep (int t) const
virtual void ResetImageStatistics () const
virtual void ComputeImageStatistics (int t=0) const
virtual ImageDataItemPointer AllocateSliceData (int s=0, int t=0, int n=0, void *data=NULL, ImportMemoryManagementType importMemoryManagement=CopyMemory)
virtual ImageDataItemPointer AllocateVolumeData (int t=0, int n=0, void *data=NULL, ImportMemoryManagementType importMemoryManagement=CopyMemory)
virtual ImageDataItemPointer AllocateChannelData (int n=0, void *data=NULL, ImportMemoryManagementType importMemoryManagement=CopyMemory)
 Image ()
virtual ~Image ()
virtual void Clear ()
 Calls ClearData() and InitializeEmpty();.
virtual void Initialize ()
ImageTimeSelectorGetTimeSelector () const
virtual void PrintSelf (std::ostream &os, itk::Indent indent) const

Protected Attributes

ImageDataItemPointerArray m_Channels
ImageDataItemPointerArray m_Volumes
ImageDataItemPointerArray m_Slices
unsigned int m_Dimension
unsigned int * m_Dimensions
vcl_size_t * m_OffsetTable
ImageDataItemPointer m_CompleteData
PixelType m_PixelType
itk::Object::Pointer m_HistogramGeneratorObject
itk::Object::Pointer m_TimeSelectorForExtremaObject
std::vector< unsigned int > m_CountOfMinValuedVoxels
std::vector< unsigned int > m_CountOfMaxValuedVoxels
std::vector< ScalarType > m_ScalarMin
std::vector< ScalarType > m_ScalarMax
std::vector< ScalarType > m_Scalar2ndMin
std::vector< ScalarType > m_Scalar2ndMax
itk::TimeStamp m_LastRecomputeTimeStamp

Friends

class SubImageSelector
template<typename ItkImageType >
void _ComputeExtremaInItkImage (ItkImageType *itkImage, mitk::Image *mitkImage, int t)

Detailed Description

Image class for storing images.

Can be asked for header information, the data vector, the mitkIpPicDescriptor struct or vtkImageData objects. If not the complete data is required, the appropriate SubImageSelector class should be used for access. Image organizes sets of slices (s x 2D), volumes (t x 3D) and channels (n x ND). Channels are for different kind of data, e.g., morphology in channel 0, velocities in channel 1. All channels must have the same Geometry! In particular, the dimensions of all channels are the same, only the pixel-type may differ between channels.

For importing ITK images use of mitk::ITKImageImport is recommended, see Adaptor Classes.

For ITK v3.8 and older: Converting coordinates from the ITK physical coordinate system (which does not support rotated images) to the MITK world coordinate system should be performed via the Geometry3D of the Image, see Geometry3D::WorldToItkPhysicalPoint.

Examples:

QtFreeRender.cpp, Step3.cpp, Step6.cpp, and Step6RegionGrowing.txx.

Definition at line 62 of file mitkImage.h.


Member Typedef Documentation

typedef itk::SmartPointer<const Self> mitk::Image::ConstPointer
typedef itk::Statistics::Histogram<double> mitk::Image::HistogramType

Definition at line 88 of file mitkImage.h.

typedef itk::SmartPointerForwardReference<ImageDataItem> mitk::Image::ImageDataItemPointer

Smart Pointer type to a ImageDataItem.

Definition at line 69 of file mitkImage.h.

Vector container of SmartPointers to ImageDataItems; Class is only for internal usage to allow convenient access to all slices over iterators; See documentation of ImageDataItem for details.

Definition at line 86 of file mitkImage.h.

typedef itk::SmartPointer<Self> mitk::Image::Pointer

Member Enumeration Documentation

Enumerator:
CopyMemory 
ManageMemory 
ReferenceMemory 
DontManageMemory 

Definition at line 80 of file mitkImage.h.


Constructor & Destructor Documentation

mitk::Image::Image (  ) [protected]

Definition at line 35 of file mitkImage.cpp.

References m_CountOfMaxValuedVoxels, m_CountOfMinValuedVoxels, m_HistogramGeneratorObject, mitk::BaseData::m_Initialized, m_Scalar2ndMax, m_Scalar2ndMin, m_ScalarMax, m_ScalarMin, QuadProgPP::max(), and New().

                 : 
  m_Dimension(0), m_Dimensions(NULL), m_OffsetTable(NULL),
  m_CompleteData(NULL), m_PixelType(NULL),
  m_TimeSelectorForExtremaObject(NULL)
{
  m_CountOfMinValuedVoxels.resize(1, 0);
  m_CountOfMaxValuedVoxels.resize(1, 0);
  m_ScalarMin.resize(1, itk::NumericTraits<ScalarType>::max());
  m_ScalarMax.resize(1, itk::NumericTraits<ScalarType>::NonpositiveMin());
  m_Scalar2ndMin.resize(1, itk::NumericTraits<ScalarType>::max());
  m_Scalar2ndMax.resize(1, itk::NumericTraits<ScalarType>::NonpositiveMin());

  m_Initialized = false;
  mitk::HistogramGenerator::Pointer generator = mitk::HistogramGenerator::New();
  m_HistogramGeneratorObject = generator;
}
mitk::Image::~Image (  ) [protected, virtual]

Definition at line 52 of file mitkImage.cpp.

{
  Clear();
  m_ReferenceCountLock.Lock();
  m_ReferenceCount = 3;
  m_ReferenceCountLock.Unlock();
  m_HistogramGeneratorObject = NULL;
  m_TimeSelectorForExtremaObject = NULL;
  m_ReferenceCountLock.Lock();
  m_ReferenceCount = 0;
  m_ReferenceCountLock.Unlock();
  delete [] m_OffsetTable;
}

Member Function Documentation

mitk::Image::ImageDataItemPointer mitk::Image::AllocateChannelData ( int  n = 0,
void *  data = NULL,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) [protected, virtual]

Definition at line 1139 of file mitkImage.cpp.

{
  ImageDataItemPointer ch;
  // allocate new channel
  if(importMemoryManagement == CopyMemory)
  {
    ch=new ImageDataItem(m_PixelType, m_Dimension, m_Dimensions, NULL, true);
    if(data != NULL)
      std::memcpy(ch->GetData(), data, m_OffsetTable[4]*(m_PixelType.GetBpe()/8));
  }
  else
  {
    ch=new ImageDataItem(m_PixelType, m_Dimension, m_Dimensions, data, importMemoryManagement == ManageMemory);
  }
  m_Channels[n]=ch;
  return ch;
}
mitk::Image::ImageDataItemPointer mitk::Image::AllocateSliceData ( int  s = 0,
int  t = 0,
int  n = 0,
void *  data = NULL,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) [protected, virtual]

Definition at line 1073 of file mitkImage.cpp.

{
  int pos;
  pos=GetSliceIndex(s,t,n);

  // is slice available as part of a volume that is available?
  ImageDataItemPointer sl, ch, vol;
  vol=m_Volumes[GetVolumeIndex(t,n)];
  if(vol.GetPointer()!=NULL)
  {
    sl=new ImageDataItem(*vol, 2, data, importMemoryManagement == ManageMemory, ((size_t) s)*m_OffsetTable[2]*(m_PixelType.GetBpe()/8));
    sl->SetComplete(true);
    return m_Slices[pos]=sl;
  }

  // is slice available as part of a channel that is available?
  ch=m_Channels[n];
  if(ch.GetPointer()!=NULL)
  {
    sl=new ImageDataItem(*ch, 2, data, importMemoryManagement == ManageMemory, (((size_t) s)*m_OffsetTable[2]+((size_t) t)*m_OffsetTable[3])*(m_PixelType.GetBpe()/8));
    sl->SetComplete(true);
    return m_Slices[pos]=sl;
  }

  // allocate new volume (instead of a single slice to keep data together!)
  m_Volumes[GetVolumeIndex(t,n)]=vol=AllocateVolumeData(t,n,NULL,importMemoryManagement);
  sl=new ImageDataItem(*vol, 2, data, importMemoryManagement == ManageMemory, ((size_t) s)*m_OffsetTable[2]*(m_PixelType.GetBpe()/8));
  sl->SetComplete(true);
  return m_Slices[pos]=sl;

  //sl=new ImageDataItem(m_PixelType, 2, m_Dimensions);
  //m_Slices[pos]=sl;
  //return vol;
}
mitk::Image::ImageDataItemPointer mitk::Image::AllocateVolumeData ( int  t = 0,
int  n = 0,
void *  data = NULL,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) [protected, virtual]

Definition at line 1110 of file mitkImage.cpp.

{
  int pos;
  pos=GetVolumeIndex(t,n);

  // is volume available as part of a channel that is available?
  ImageDataItemPointer ch, vol;
  ch=m_Channels[n];
  if(ch.GetPointer()!=NULL)
  {
    vol=new ImageDataItem(*ch, 3, data, importMemoryManagement == ManageMemory, (((size_t) t)*m_OffsetTable[3])*(m_PixelType.GetBpe()/8));
    return m_Volumes[pos]=vol;
  }

  // allocate new volume
  if(importMemoryManagement == CopyMemory)
  {
    vol=new ImageDataItem(m_PixelType, 3, m_Dimensions, NULL, true);
    if(data != NULL)
      std::memcpy(vol->GetData(), data, m_OffsetTable[3]*(m_PixelType.GetBpe()/8));
  }
  else
  {
    vol=new ImageDataItem(m_PixelType, 3, m_Dimensions, data, importMemoryManagement == ManageMemory);
  }
  m_Volumes[pos]=vol;
  return vol;
}
void mitk::Image::Clear (  ) [protected, virtual]

Calls ClearData() and InitializeEmpty();.

Warning:
Only use in subclasses that reimplemented these methods. Just calling Clear from BaseData will reset an object to a not initialized, invalid state.

Reimplemented from mitk::BaseData.

Definition at line 1162 of file mitkImage.cpp.

{
  Superclass::Clear();
  delete [] m_Dimensions;
  m_Dimensions = NULL;
}
void mitk::Image::ComputeImageStatistics ( int  t = 0 ) const [protected, virtual]

Definition at line 1305 of file mitkImage.cpp.

References AccessByItk_2, mitk::ImageSource::GetOutput(), QuadProgPP::max(), mitk::ImageTimeSelector::SetTimeNr(), and QuadProgPP::t().

{
  // timestep valid?
  if (!IsValidTimeStep(t)) return;

  // image modified?
  if (this->GetMTime() > m_LastRecomputeTimeStamp.GetMTime())
    this->ResetImageStatistics();

  // adapt vector length
  this->Expand(t+1);

  // do we have valid information already?
  if( m_ScalarMin[t] != itk::NumericTraits<ScalarType>::max() || 
    m_Scalar2ndMin[t] != itk::NumericTraits<ScalarType>::max() ) return; // Values already calculated before...

  if(this->m_PixelType.GetNumberOfComponents() == 1)
  {
    // recompute
    mitk::ImageTimeSelector* timeSelector = this->GetTimeSelector();
    if(timeSelector!=NULL)
    {
      timeSelector->SetTimeNr(t);
      timeSelector->UpdateLargestPossibleRegion();
      mitk::Image* image = timeSelector->GetOutput();
      mitk::Image* thisImage = const_cast<Image*>(this);
      AccessByItk_2( image, _ComputeExtremaInItkImage, thisImage, t );
    }
  }
  else if(this->m_PixelType.GetNumberOfComponents() > 1)
  {
    m_ScalarMin[t] = 0;
    m_ScalarMax[t] = 255;
  }
}
void mitk::Image::ComputeOffsetTable (  ) [protected]

Definition at line 1042 of file mitkImage.cpp.

{
  if(m_OffsetTable!=NULL)
    delete [] m_OffsetTable;

  m_OffsetTable=new size_t[m_Dimension>4 ? m_Dimension+1 : 4+1];

  unsigned int i;
  size_t num=1;
  m_OffsetTable[0] = 1;
  for (i=0; i < m_Dimension; ++i)
  {
    num *= m_Dimensions[i];
    m_OffsetTable[i+1] = num;
  }
  for (;i < 4; ++i)
    m_OffsetTable[i+1] = num;
}
void mitk::Image::Expand ( int  timeSteps ) const [protected, virtual]

Definition at line 1280 of file mitkImage.cpp.

References QuadProgPP::max().

{
  if(timeSteps < 1) itkExceptionMacro(<< "Invalid timestep in Image!");
  if(! IsValidTimeStep( timeSteps-1 ) ) return;
  if(timeSteps > (int)m_ScalarMin.size() )
  {
    m_ScalarMin.resize(timeSteps, itk::NumericTraits<ScalarType>::max());
    m_ScalarMax.resize(timeSteps, itk::NumericTraits<ScalarType>::NonpositiveMin());
    m_Scalar2ndMin.resize(timeSteps, itk::NumericTraits<ScalarType>::max());
    m_Scalar2ndMax.resize(timeSteps, itk::NumericTraits<ScalarType>::NonpositiveMin());
    m_CountOfMinValuedVoxels.resize(timeSteps, 0);
    m_CountOfMaxValuedVoxels.resize(timeSteps, 0);
  }
}
mitk::Image::ImageDataItemPointer mitk::Image::GetChannelData ( int  n = 0,
void *  data = NULL,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) [virtual]
Warning:
for internal use only

Definition at line 351 of file mitkImage.cpp.

References mitkIpPicDescriptor, mitk::ImageDataItem::SetComplete(), and QuadProgPP::t().

Referenced by mitk::SubImageSelector::GetChannelData().

{
  if(IsValidChannel(n)==false) return NULL;
  ImageDataItemPointer ch, vol;
  ch=m_Channels[n];
  if((ch.GetPointer()!=NULL) && (ch->IsComplete()))
    return ch;

  // let's see if all volumes are set, so that we can (could) combine them to a channel
  if(IsChannelSet(n))
  {
    // if there is only one time frame we do not need to combine anything
    if(m_Dimensions[3]<=1)
    {
      vol=GetVolumeData(0,n,data,importMemoryManagement);
      ch=new ImageDataItem(*vol, 3, data, importMemoryManagement == ManageMemory);
      ch->SetComplete(true);
    }
    else
    {
      ch=m_Channels[n];
      // ok, let's combine the volumes!
      if(ch.GetPointer()==NULL)
        ch=new ImageDataItem(m_PixelType, m_Dimension, m_Dimensions, NULL, true);
      ch->SetComplete(true);
      size_t size=m_OffsetTable[m_Dimension-1]*(m_PixelType.GetBpe()/8);
      unsigned int t;
      ImageDataItemPointerArray::iterator slicesIt = m_Slices.begin()+n*m_Dimensions[2]*m_Dimensions[3];
      for(t=0;t<m_Dimensions[3];++t)
      {
        int posVol;
        ImageDataItemPointer vol;

        posVol=GetVolumeIndex(t,n);
        vol=GetVolumeData(t,n,data,importMemoryManagement);

        if(vol->GetParent()!=ch)
        {
          // copy data of volume in channel
          size_t offset = ((size_t) t)*m_OffsetTable[3]*(m_PixelType.GetBpe()/8);
          std::memcpy(static_cast<char*>(ch->GetData())+offset, vol->GetData(), size);

          mitkIpPicDescriptor * pic = vol->GetPicDescriptor();

          // replace old volume with reference to channel
          vol=new ImageDataItem(*ch, 3, data, importMemoryManagement == ManageMemory, offset);
          vol->SetComplete(true);
          mitkIpFuncCopyTags(vol->GetPicDescriptor(), pic);

          m_Volumes[posVol]=vol;

          // get rid of slices - they may point to old volume
          ImageDataItemPointer dnull=NULL;
          for(unsigned int i = 0; i < m_Dimensions[2]; ++i, ++slicesIt)
          {
            assert(slicesIt != m_Slices.end());
            *slicesIt = dnull;
          }
        }
      }
      if(ch->GetPicDescriptor()->info->tags_head==NULL)
        mitkIpFuncCopyTags(ch->GetPicDescriptor(), m_Volumes[GetVolumeIndex(0,n)]->GetPicDescriptor());
    }
    return m_Channels[n]=ch;
  }

  // channel is unavailable. Can we calculate it?
  if((GetSource()!=NULL) && (GetSource()->Updating()==false))
  {
    // ... wir muessen rechnen!!! ....
    m_RequestedRegion.SetIndex(0, 0);
    m_RequestedRegion.SetIndex(1, 0);
    m_RequestedRegion.SetIndex(2, 0);
    m_RequestedRegion.SetIndex(3, 0);
    m_RequestedRegion.SetIndex(4, n);
    m_RequestedRegion.SetSize(0, m_Dimensions[0]);
    m_RequestedRegion.SetSize(1, m_Dimensions[1]);
    m_RequestedRegion.SetSize(2, m_Dimensions[2]);
    m_RequestedRegion.SetSize(3, m_Dimensions[3]);
    m_RequestedRegion.SetSize(4, 1);
    m_RequestedRegionInitialized=true;
    GetSource()->Update();
    // did it work?
    if(IsChannelSet(n))
      //yes: now we can call ourselves without the risk of a endless loop (see "if" above)
      return GetChannelData(n,data,importMemoryManagement);
    else
      return NULL;
  }
  else
  {
    ImageDataItemPointer item = AllocateChannelData(n,data,importMemoryManagement);
    item->SetComplete(true);
    return item;
  }
}
virtual const char* mitk::Image::GetClassName (  ) const [virtual]
mitk::ScalarType mitk::Image::GetCountOfMaxValuedVoxels ( int  t = 0 ) const

Get the count of voxels with the largest scalar value in the dataset.

Definition at line 1372 of file mitkImage.cpp.

References QuadProgPP::t().

virtual unsigned int mitk::Image::GetCountOfMaxValuedVoxelsNoRecompute ( unsigned int  t = 0 ) const [inline, virtual]

Get the count of voxels with the largest scalar value in the dataset.

Definition at line 527 of file mitkImage.h.

References QuadProgPP::t().

Referenced by mitk::ImageMapperGL2D::Paint(), and mitk::LevelWindow::SetAuto().

  {
    if ( t < m_CountOfMaxValuedVoxels.size() )
      return m_CountOfMaxValuedVoxels[t];
    else return 0;
  }
mitk::ScalarType mitk::Image::GetCountOfMinValuedVoxels ( int  t = 0 ) const

Get the count of voxels with the smallest scalar value in the dataset.

Definition at line 1366 of file mitkImage.cpp.

References QuadProgPP::t().

virtual unsigned int mitk::Image::GetCountOfMinValuedVoxelsNoRecompute ( unsigned int  t = 0 ) const [inline, virtual]

Get the count of voxels with the smallest scalar value in the dataset.

Definition at line 536 of file mitkImage.h.

References QuadProgPP::t().

Referenced by mitk::LevelWindow::SetAuto().

  {
    if ( t < m_CountOfMinValuedVoxels.size() )
      return m_CountOfMinValuedVoxels[t];
    else return 0;
  }
void * mitk::Image::GetData (  ) [virtual]

Definition at line 83 of file mitkImage.cpp.

Referenced by mitk::PlaneCutFilter::GenerateData(), mitk::SegmentationInterpolationController::ScanWholeVolume(), testImageToItkAndBack(), and mitk::ImageWriter::WriteByITK().

{
  if(m_Initialized==false)
  {
    if(GetSource()==NULL)
      return NULL;
    if(GetSource()->Updating()==false)
      GetSource()->UpdateOutputInformation();
  }
  m_CompleteData=GetChannelData();
  return m_CompleteData->GetData();
}
unsigned int mitk::Image::GetDimension (  ) const
unsigned int mitk::Image::GetDimension ( int  i ) const

Get the size of dimension i (e.g., i=0 results in the number of pixels in x-direction).

See also:
GetDimensions()

Definition at line 76 of file mitkImage.cpp.

{
  if((i>=0) && (i<(int)m_Dimension))
    return m_Dimensions[i];
  return 1;
}
unsigned int * mitk::Image::GetDimensions (  ) const
mitkIpPicDescriptor * mitk::Image::GetPic (  ) [virtual]

Get the complete image, i.e., all channels linked together, as a mitkIpPicDescriptor.

If you only want to access a slice, volume at a specific time or single channel use one of the SubImageSelector classes.

Definition at line 170 of file mitkImage.cpp.

{
  if(m_Initialized==false)
  {
    if(GetSource()==NULL)
      return NULL;
    if(GetSource()->Updating()==false)
      GetSource()->UpdateOutputInformation();
  }
  m_CompleteData=GetChannelData();
  if(m_CompleteData.GetPointer()==NULL) 
    return NULL;
  return m_CompleteData->GetPicDescriptor();
}
const mitk::PixelType & mitk::Image::GetPixelType ( int  n = 0 ) const
double mitk::Image::GetPixelValueByIndex ( const mitk::Index3D &  position,
unsigned int  timestep = 0 
)

Definition at line 119 of file mitkImage.cpp.

References AccessPixel(), and mitkIpPicDescriptor.

{
  mitkIpPicDescriptor* pic = this->GetPic();
  double value = 0;
  if (this->GetTimeSteps() < timestep)
  {
    timestep = this->GetTimeSteps();
  }
  mitkIpPicTypeMultiplex3(AccessPixel, pic, position, value, timestep);
  return value;
}
double mitk::Image::GetPixelValueByWorldCoordinate ( const mitk::Point3D &  position,
unsigned int  timestep = 0 
)

Definition at line 131 of file mitkImage.cpp.

References AccessPixel(), and mitkIpPicDescriptor.

Referenced by QmitkImageStatistics::ComputeIntensityProfile().

{
  mitkIpPicDescriptor* pic = this->GetPic();
  double value = 0;
  if (this->GetTimeSteps() < timestep)
  {
    timestep = this->GetTimeSteps();
  }

  Index3D itkIndex;
  this->GetGeometry()->WorldToIndex(position,itkIndex);
  mitkIpPicTypeMultiplex3(AccessPixel, pic, itkIndex, value, timestep);

  return value;
}
const mitk::Image::HistogramType * mitk::Image::GetScalarHistogram ( int  t = 0 ) const [virtual]

Definition at line 1175 of file mitkImage.cpp.

References mitk::HistogramGenerator::ComputeHistogram(), mitk::HistogramGenerator::GetHistogram(), mitk::ImageSource::GetOutput(), mitk::HistogramGenerator::SetImage(), and mitk::ImageTimeSelector::SetTimeNr().

Referenced by QmitkHistogramWidget::SetHistogram().

{
  mitk::ImageTimeSelector* timeSelector = this->GetTimeSelector();
  if(timeSelector!=NULL)
  {
    timeSelector->SetTimeNr(t);
    timeSelector->UpdateLargestPossibleRegion();

    mitk::HistogramGenerator* generator = static_cast<mitk::HistogramGenerator*>(m_HistogramGeneratorObject.GetPointer());
    generator->SetImage(timeSelector->GetOutput());
    generator->ComputeHistogram();
    return static_cast<const mitk::Image::HistogramType*>(generator->GetHistogram());
  }
  return NULL;
}
mitk::ScalarType mitk::Image::GetScalarValue2ndMax ( int  t = 0 ) const [virtual]

Get the second largest value for scalar images.

Definition at line 1360 of file mitkImage.cpp.

References QuadProgPP::t().

virtual mitk::ScalarType mitk::Image::GetScalarValue2ndMaxNoRecompute ( unsigned int  t = 0 ) const [inline, virtual]

Get the second largest value for scalar images, but do not recompute it first.

Definition at line 510 of file mitkImage.h.

References QuadProgPP::t().

Referenced by mitk::LevelWindow::SetAuto().

  {
    if ( t < m_Scalar2ndMax.size() )
      return m_Scalar2ndMax[t];
    else return itk::NumericTraits<ScalarType>::NonpositiveMin();
  }
mitk::ScalarType mitk::Image::GetScalarValue2ndMin ( int  t = 0 ) const [virtual]

Get the second smallest value for scalar images.

Definition at line 1354 of file mitkImage.cpp.

References QuadProgPP::t().

Referenced by QmitkVolumetryView::OnImageSelected().

virtual mitk::ScalarType mitk::Image::GetScalarValue2ndMinNoRecompute ( unsigned int  t = 0 ) const [inline, virtual]

Get the second smallest value for scalar images, but do not recompute it first.

Definition at line 488 of file mitkImage.h.

References QuadProgPP::max(), and QuadProgPP::t().

Referenced by mitk::LevelWindow::SetAuto().

  {
    if ( t < m_Scalar2ndMin.size() )
      return m_Scalar2ndMin[t];
    else return itk::NumericTraits<ScalarType>::max();
  }
mitk::ScalarType mitk::Image::GetScalarValueMax ( int  t = 0 ) const [virtual]

Get the maximum for scalar images.

Definition at line 1348 of file mitkImage.cpp.

References QuadProgPP::t().

Referenced by mitk::ImageMapperGL2D::Paint(), and QmitkImageCropper::SurroundingCheck().

virtual mitk::ScalarType mitk::Image::GetScalarValueMaxNoRecompute ( unsigned int  t = 0 ) const [inline, virtual]

Get the largest value for scalar images, but do not recompute it first.

Definition at line 501 of file mitkImage.h.

References QuadProgPP::t().

Referenced by QmitkVolumetryView::OnImageSelected(), and mitk::LevelWindow::SetAuto().

  {
    if ( t < m_ScalarMax.size() )
      return m_ScalarMax[t];
    else return itk::NumericTraits<ScalarType>::NonpositiveMin();
  }
mitk::ScalarType mitk::Image::GetScalarValueMin ( int  t = 0 ) const [virtual]

Get the minimum for scalar images.

Definition at line 1342 of file mitkImage.cpp.

References QuadProgPP::t().

Referenced by mitk::LevelWindow::SetAuto(), and QmitkImageCropper::SurroundingCheck().

virtual mitk::ScalarType mitk::Image::GetScalarValueMinNoRecompute ( unsigned int  t = 0 ) const [inline, virtual]

Get the smallest value for scalar images, but do not recompute it first.

Definition at line 479 of file mitkImage.h.

References QuadProgPP::max(), and QuadProgPP::t().

  {
    if ( t < m_ScalarMin.size() )
      return m_ScalarMin[t];
    else return itk::NumericTraits<ScalarType>::max();
  }
mitk::Image::ImageDataItemPointer mitk::Image::GetSliceData ( int  s = 0,
int  t = 0,
int  n = 0,
void *  data = NULL,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) [virtual]
Warning:
for internal use only

Definition at line 185 of file mitkImage.cpp.

Referenced by mitk::ContourUtils::FillContourInSlice(), and mitk::SubImageSelector::GetSliceData().

{
  if(IsValidSlice(s,t,n)==false) return NULL;

  // slice directly available?
  int pos=GetSliceIndex(s,t,n);
  if(m_Slices[pos].GetPointer()!=NULL)
    return m_Slices[pos];

  // is slice available as part of a volume that is available?
  ImageDataItemPointer sl, ch, vol;
  vol=m_Volumes[GetVolumeIndex(t,n)];
  if((vol.GetPointer()!=NULL) && (vol->IsComplete()))
  {
    sl=new ImageDataItem(*vol, 2, data, importMemoryManagement == ManageMemory, ((size_t) s)*m_OffsetTable[2]*(m_PixelType.GetBpe()/8));
    sl->SetComplete(true);
    return m_Slices[pos]=sl;
  }

  // is slice available as part of a channel that is available?
  ch=m_Channels[n];
  if((ch.GetPointer()!=NULL) && (ch->IsComplete()))
  {
    sl=new ImageDataItem(*ch, 2, data, importMemoryManagement == ManageMemory, (((size_t) s)*m_OffsetTable[2]+((size_t) t)*m_OffsetTable[3])*(m_PixelType.GetBpe()/8));
    sl->SetComplete(true);
    return m_Slices[pos]=sl;
  }

  // slice is unavailable. Can we calculate it?
  if((GetSource()!=NULL) && (GetSource()->Updating()==false))
  {
    // ... wir mussen rechnen!!! ....
    m_RequestedRegion.SetIndex(0, 0);
    m_RequestedRegion.SetIndex(1, 0);
    m_RequestedRegion.SetIndex(2, s);
    m_RequestedRegion.SetIndex(3, t);
    m_RequestedRegion.SetIndex(4, n);
    m_RequestedRegion.SetSize(0, m_Dimensions[0]);
    m_RequestedRegion.SetSize(1, m_Dimensions[1]);
    m_RequestedRegion.SetSize(2, 1);
    m_RequestedRegion.SetSize(3, 1);
    m_RequestedRegion.SetSize(4, 1);
    m_RequestedRegionInitialized=true;
    GetSource()->Update();
    if(IsSliceSet(s,t,n))
      //yes: now we can call ourselves without the risk of a endless loop (see "if" above)
      return GetSliceData(s,t,n,data,importMemoryManagement);
    else
      return NULL;
  }
  else
  {
    ImageDataItemPointer item = AllocateSliceData(s,t,n,data,importMemoryManagement);
    item->SetComplete(true);
    return item;
  }
}
int mitk::Image::GetSliceIndex ( int  s = 0,
int  t = 0,
int  n = 0 
) const [protected]

Definition at line 1061 of file mitkImage.cpp.

{
  if(IsValidSlice(s,t,n)==false) return false;
  return ((size_t)s)+((size_t) t)*m_Dimensions[2]+((size_t) n)*m_Dimensions[3]*m_Dimensions[2]; //??
}
mitk::ImageTimeSelector * mitk::Image::GetTimeSelector (  ) const [protected]

Definition at line 696 of file mitkImage.cpp.

References mitk::ImageTimeSelector::New(), and mitk::ImageToImageFilter::SetInput().

{
  if(m_TimeSelectorForExtremaObject.IsNull())
  {
    m_TimeSelectorForExtremaObject = ImageTimeSelector::New();

    ImageTimeSelector* timeSelector = static_cast<mitk::ImageTimeSelector*>( m_TimeSelectorForExtremaObject.GetPointer() );
    timeSelector->SetInput(this);
    this->UnRegister();
  }

  return static_cast<ImageTimeSelector*>( m_TimeSelectorForExtremaObject.GetPointer() );
}
mitk::Image::ImageDataItemPointer mitk::Image::GetVolumeData ( int  t = 0,
int  n = 0,
void *  data = NULL,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) [virtual]
Warning:
for internal use only

Definition at line 243 of file mitkImage.cpp.

References mitkIpPicDescriptor, and mitk::ImageDataItem::SetComplete().

Referenced by mitk::SubImageSelector::GetVolumeData(), mitk::CompressedImageContainer::SetImage(), and mitkCompressedImageContainerTestClass::Test().

{
  if(IsValidVolume(t,n)==false) return NULL;

  ImageDataItemPointer ch, vol;

  // volume directly available?
  int pos=GetVolumeIndex(t,n);
  vol=m_Volumes[pos];
  if((vol.GetPointer()!=NULL) && (vol->IsComplete()))
    return vol;

  // is volume available as part of a channel that is available?
  ch=m_Channels[n];
  if((ch.GetPointer()!=NULL) && (ch->IsComplete()))
  {
    vol=new ImageDataItem(*ch, 3, data, importMemoryManagement == ManageMemory, (((size_t) t)*m_OffsetTable[3])*(m_PixelType.GetBpe()/8));
    vol->SetComplete(true);
    return m_Volumes[pos]=vol;
  }

  // let's see if all slices of the volume are set, so that we can (could) combine them to a volume
  bool complete=true;
  unsigned int s;
  for(s=0;s<m_Dimensions[2];++s)
  {
    if(m_Slices[GetSliceIndex(s,t,n)].GetPointer()==NULL)
    {
      complete=false;
      break;
    }
  }
  if(complete)
  {
    // if there is only single slice we do not need to combine anything
    if(m_Dimensions[2]<=1)
    {
      ImageDataItemPointer sl;
      sl=GetSliceData(0,t,n,data,importMemoryManagement);
      vol=new ImageDataItem(*sl, 3, data, importMemoryManagement == ManageMemory);
      vol->SetComplete(true);
    }
    else
    {
      vol=m_Volumes[pos];
      // ok, let's combine the slices!
      if(vol.GetPointer()==NULL)
        vol=new ImageDataItem(m_PixelType, 3, m_Dimensions, NULL, true);
      vol->SetComplete(true);
      size_t size=m_OffsetTable[2]*(m_PixelType.GetBpe()/8);
      for(s=0;s<m_Dimensions[2];++s)
      {
        int posSl;
        ImageDataItemPointer sl;
        posSl=GetSliceIndex(s,t,n);

        sl=m_Slices[posSl];
        if(sl->GetParent()!=vol)
        {
          // copy data of slices in volume
          size_t offset = ((size_t) s)*size;
          std::memcpy(static_cast<char*>(vol->GetData())+offset, sl->GetData(), size);

          mitkIpPicDescriptor * pic = sl->GetPicDescriptor();

          // replace old slice with reference to volume
          sl=new ImageDataItem(*vol, 2, data, importMemoryManagement == ManageMemory, ((size_t) s)*size);
          sl->SetComplete(true);
          mitkIpFuncCopyTags(sl->GetPicDescriptor(), pic);
          m_Slices[posSl]=sl;
        }
      }
      if(vol->GetPicDescriptor()->info->tags_head==NULL)
        mitkIpFuncCopyTags(vol->GetPicDescriptor(), m_Slices[GetSliceIndex(0,t,n)]->GetPicDescriptor());
    }
    return m_Volumes[pos]=vol;
  }

  // volume is unavailable. Can we calculate it?
  if((GetSource()!=NULL) && (GetSource()->Updating()==false))
  {
    // ... wir muessen rechnen!!! ....
    m_RequestedRegion.SetIndex(0, 0);
    m_RequestedRegion.SetIndex(1, 0);
    m_RequestedRegion.SetIndex(2, 0);
    m_RequestedRegion.SetIndex(3, t);
    m_RequestedRegion.SetIndex(4, n);
    m_RequestedRegion.SetSize(0, m_Dimensions[0]);
    m_RequestedRegion.SetSize(1, m_Dimensions[1]);
    m_RequestedRegion.SetSize(2, m_Dimensions[2]);
    m_RequestedRegion.SetSize(3, 1);
    m_RequestedRegion.SetSize(4, 1);
    m_RequestedRegionInitialized=true;
    GetSource()->Update();
    if(IsVolumeSet(t,n))
      //yes: now we can call ourselves without the risk of a endless loop (see "if" above)
      return GetVolumeData(t,n,data,importMemoryManagement);
    else
      return NULL;
  }
  else
  {
    ImageDataItemPointer item = AllocateVolumeData(t,n,data,importMemoryManagement);
    item->SetComplete(true);
    return item;
  }
}
int mitk::Image::GetVolumeIndex ( int  t = 0,
int  n = 0 
) const [protected]

Definition at line 1067 of file mitkImage.cpp.

{
  if(IsValidVolume(t,n)==false) return false;
  return ((size_t)t)+((size_t) n)*m_Dimensions[3]; //??
}
vtkImageData * mitk::Image::GetVtkImageData ( int  t = 0,
int  n = 0 
) [virtual]

Get a volume at a specific time t of channel n as a vtkImageData.

Reimplemented in mitk::QBallImage, and mitk::TensorImage.

Definition at line 147 of file mitkImage.cpp.

Referenced by mitk::VolumeDataVtkMapper3D::GenerateData(), mitk::ProbeFilter::GenerateData(), mitk::ManualSegmentationToSurfaceFilter::GenerateData(), mitk::LabeledImageToSurfaceFilter::GenerateData(), mitk::ImageToSurfaceFilter::GenerateData(), mitk::ImageMapperGL2D::GenerateData(), mitk::GPUVolumeMapper3D::GenerateData(), mitk::ExtractDirectedPlaneImageFilter::GenerateData(), mitk::GPUVolumeMapper3D::IsRenderable(), mitk::VolumeDataVtkMapper3D::SetClippingPlane(), and mitk::VolumeDataVtkMapper3D::SetMask().

{
  if(m_Initialized==false)
  {
    if(GetSource()==NULL)
      return NULL;
    if(GetSource()->Updating()==false)
      GetSource()->UpdateOutputInformation();
  }
  ImageDataItemPointer volume=GetVolumeData(t, n);
  if(volume.GetPointer()==NULL || volume->GetVtkImageData() == NULL)
    return NULL;

#if ((VTK_MAJOR_VERSION > 4) || ((VTK_MAJOR_VERSION==4) && (VTK_MINOR_VERSION>=4) ))
  float *fspacing = const_cast<float *>(GetSlicedGeometry(t)->GetFloatSpacing());
  double dspacing[3] = {fspacing[0],fspacing[1],fspacing[2]};
  volume->GetVtkImageData()->SetSpacing( dspacing );
#else
  volume->GetVtkImageData()->SetSpacing(const_cast<float*>(GetSlicedGeometry(t)->GetFloatSpacing()));
#endif
  return volume->GetVtkImageData();
}
void mitk::Image::Initialize ( const mitk::PixelType type,
int  sDim,
const mitk::Geometry2D geometry2d,
bool  flipped = false,
unsigned int  channels = 1,
int  tDim = -1 
) [virtual]

initialize new (or re-initialize) image information by a Geometry2D and number of slices

Initializes the bounding box according to the width/height of the Geometry2D and sDim via SlicedGeometry3D::InitializeEvenlySpaced. The spacing is calculated from the Geometry2D.

Parameters:
tDimoverride time dimension (n[3]) if geometry is a TimeSlicedGeometry (if >0)
See also:
SlicedGeometry3D::InitializeEvenlySpaced

Definition at line 837 of file mitkImage.cpp.

References mitk::Geometry2D::Clone(), and mitk::SlicedGeometry3D::New().

{
  SlicedGeometry3D::Pointer slicedGeometry = SlicedGeometry3D::New();
  slicedGeometry->InitializeEvenlySpaced(static_cast<Geometry2D*>(geometry2d.Clone().GetPointer()), sDim, flipped);
  Initialize(type, *slicedGeometry, channels, tDim);
}
void mitk::Image::Initialize ( const mitk::PixelType type,
unsigned int  dimension,
unsigned int *  dimensions,
unsigned int  channels = 1 
) [virtual]

initialize new (or re-initialize) image information

Warning:
Initialize() by pic assumes a plane, evenly spaced geometry starting at (0,0,0).

Definition at line 710 of file mitkImage.cpp.

References mitk::TimeSlicedGeometry::New(), mitk::SlicedGeometry3D::New(), and mitk::PlaneGeometry::New().

Referenced by mitk::PlaneCutFilter::GenerateData(), and mitk::BoundingObjectToSegmentationFilter::GenerateData().

{
  Clear();

  m_Dimension=dimension;

  if(!dimensions)
    itkExceptionMacro(<< "invalid zero dimension image");

  unsigned int i;
  for(i=0;i<dimension;++i)
  {
    if(dimensions[i]<1)
      itkExceptionMacro(<< "invalid dimension[" << i << "]: " << dimensions[i]);
  }

  m_Dimensions=new unsigned int[m_Dimension>4?m_Dimension:4];
  std::memcpy(m_Dimensions, dimensions, sizeof(unsigned int)*m_Dimension);
  if(m_Dimension<4)
  {
    unsigned int *p;
    for(i=0,p=m_Dimensions+m_Dimension;i<4-m_Dimension;++i, ++p)
      *p=1;
  }

  for(i=0;i<4;++i)
  {
    m_LargestPossibleRegion.SetIndex(i, 0);
    m_LargestPossibleRegion.SetSize (i, m_Dimensions[i]);
  }
  m_LargestPossibleRegion.SetIndex(i, 0);
  m_LargestPossibleRegion.SetSize(i, channels);

  if(m_LargestPossibleRegion.GetNumberOfPixels()==0)
  {
    delete [] m_Dimensions;
    m_Dimensions = NULL;
    return;
  }

  m_PixelType=type;

  PlaneGeometry::Pointer planegeometry = PlaneGeometry::New();
  planegeometry->InitializeStandardPlane(m_Dimensions[0], m_Dimensions[1]);

  SlicedGeometry3D::Pointer slicedGeometry = SlicedGeometry3D::New();
  slicedGeometry->InitializeEvenlySpaced(planegeometry, m_Dimensions[2]);

  if(dimension>=4)
  {
    TimeBounds timebounds;
    timebounds[0] = 0.0;
    timebounds[1] = 1.0;
    slicedGeometry->SetTimeBounds(timebounds);
  }

  TimeSlicedGeometry::Pointer timeSliceGeometry = TimeSlicedGeometry::New();
  timeSliceGeometry->InitializeEvenlyTimed(slicedGeometry, m_Dimensions[3]);

  SetGeometry(timeSliceGeometry);

  ImageDataItemPointer dnull=NULL;

  m_Channels.assign(GetNumberOfChannels(), dnull);

  m_Volumes.assign(GetNumberOfChannels()*m_Dimensions[3], dnull);

  m_Slices.assign(GetNumberOfChannels()*m_Dimensions[3]*m_Dimensions[2], dnull);

  ComputeOffsetTable();

  Initialize();

  m_Initialized = true;
}
void mitk::Image::Initialize ( const mitk::PixelType type,
const mitk::Geometry3D geometry,
unsigned int  channels = 1,
int  tDim = -1 
) [virtual]

initialize new (or re-initialize) image information by a Geometry3D

Parameters:
tDimoverride time dimension (n[3]) if geometry is a TimeSlicedGeometry (if >0)

Definition at line 786 of file mitkImage.cpp.

References mitk::Geometry3D::Clone(), mitk::Geometry3D::GetBoundingBox(), mitk::Geometry3D::GetExtent(), mitk::Geometry3D::GetIndexToWorldTransform(), mitk::TimeSlicedGeometry::GetTimeSteps(), mitk::Geometry3D::IndexToWorld(), int(), and mitk::Geometry3D::SetBounds().

{
  unsigned int dimensions[5];
  dimensions[0] = (unsigned int)(geometry.GetExtent(0)+0.5);
  dimensions[1] = (unsigned int)(geometry.GetExtent(1)+0.5);
  dimensions[2] = (unsigned int)(geometry.GetExtent(2)+0.5);
  dimensions[3] = 0;
  dimensions[4] = 0;

  unsigned int dimension = 2;
  if ( dimensions[2] > 1 )
    dimension = 3;

  if ( tDim > 0)
  {
    dimensions[3] = tDim;
  }
  else
  {
    const mitk::TimeSlicedGeometry* timeGeometry = dynamic_cast<const mitk::TimeSlicedGeometry*>(&geometry);
    if ( timeGeometry != NULL ) 
    {
      dimensions[3] = timeGeometry->GetTimeSteps();
    }
  }

  if ( dimensions[3] > 1 )
    dimension = 4;

  Initialize( type, dimension, dimensions, channels );

  SetGeometry(static_cast<Geometry3D*>(geometry.Clone().GetPointer()));
  
  mitk::BoundingBox::BoundsArrayType bounds = geometry.GetBoundingBox()->GetBounds();
  if( (bounds[0] != 0.0) || (bounds[2] != 0.0) || (bounds[4] != 0.0) )
  {
    SlicedGeometry3D* slicedGeometry = GetSlicedGeometry(0);
  
    mitk::Point3D origin; origin.Fill(0.0);
    slicedGeometry->IndexToWorld(origin, origin);

    bounds[1]-=bounds[0]; bounds[3]-=bounds[2]; bounds[5]-=bounds[4];
    bounds[0] = 0.0;      bounds[2] = 0.0;      bounds[4] = 0.0;

    slicedGeometry->SetBounds(bounds);
    slicedGeometry->GetIndexToWorldTransform()->SetOffset(origin.Get_vnl_vector().data_block());  
  
    GetTimeSlicedGeometry()->InitializeEvenlyTimed(slicedGeometry, m_Dimensions[3]);
  }
}
void mitk::Image::Initialize ( const mitk::Image image ) [virtual]

initialize new (or re-initialize) image information by another mitk-image. Only the header is used, not the data vector!

Definition at line 844 of file mitkImage.cpp.

References GetPixelType(), mitk::BaseData::GetTimeSlicedGeometry(), and mitk::PixelType::GetTypeId().

void mitk::Image::Initialize ( const mitkIpPicDescriptor *  pic,
int  channels = 1,
int  tDim = -1,
int  sDim = -1 
) [virtual]

initialize new (or re-initialize) image information by pic. Dimensions and Geometry3D /Geometry2D are set according to the tags in pic. Only the header is used, not the data vector! Use SetPicVolume(pic) to set the data vector.

Parameters:
tDimoverride time dimension (n[3]) in pic (if >0)
sDimoverride z-space dimension (n[2]) in pic (if >0)
Warning:
Initialize() by pic assumes a plane, evenly spaced geometry starting at (0,0,0).

Definition at line 955 of file mitkImage.cpp.

References mitk::PicHelper::InitializeEvenlySpaced(), mitk::TimeSlicedGeometry::New(), and mitk::SlicedGeometry3D::New().

{
  if(pic==NULL) return;

  Clear();

  m_Dimension=pic->dim;

  m_Dimensions=new unsigned int[m_Dimension>4?m_Dimension:4];
  std::memcpy(m_Dimensions, pic->n, sizeof(unsigned int)*m_Dimension);
  if(m_Dimension<4)
  {
    unsigned int i, *p;
    for(i=0,p=m_Dimensions+m_Dimension;i<4-m_Dimension;++i, ++p)
      *p=1;
  }

  if(sDim>=0)
  {
    m_Dimensions[2]=sDim;
    if(m_Dimension < 3)
      m_Dimension = 3;
  }
  if(tDim>=0)
  {
    m_Dimensions[3]=tDim;
    if(m_Dimension < 4)
      m_Dimension = 4;
  }

  unsigned int i;
  for(i=0;i<4;++i)
  {
    m_LargestPossibleRegion.SetIndex(i, 0);
    m_LargestPossibleRegion.SetSize (i, m_Dimensions[i]);
  }
  m_LargestPossibleRegion.SetIndex(i, 0);
  m_LargestPossibleRegion.SetSize(i, channels);

  m_PixelType=PixelType(pic);
  SlicedGeometry3D::Pointer slicedGeometry = SlicedGeometry3D::New(); 
  PicHelper::InitializeEvenlySpaced(pic, m_Dimensions[2], slicedGeometry);

  TimeSlicedGeometry::Pointer timeSliceGeometry = TimeSlicedGeometry::New();
  timeSliceGeometry->InitializeEvenlyTimed(slicedGeometry, m_Dimensions[3]);

  SetGeometry(timeSliceGeometry);  

  ImageDataItemPointer dnull=NULL;

  m_Channels.assign(GetNumberOfChannels(), dnull);

  m_Volumes.assign(GetNumberOfChannels()*m_Dimensions[3], dnull);

  m_Slices.assign(GetNumberOfChannels()*m_Dimensions[3]*m_Dimensions[2], dnull);

  ComputeOffsetTable();

  Initialize();

  m_Initialized = true;
}
void mitk::Image::Initialize ( vtkImageData *  vtkimagedata,
int  channels = 1,
int  tDim = -1,
int  sDim = -1 
) [virtual]

initialize new (or re-initialize) image information by vtkimagedata, a vtk-image. Only the header is used, not the data vector! Use SetVolume(vtkimage->GetScalarPointer()) to set the data vector.

Parameters:
tDimoverride time dimension in vtkimagedata (if >0 and <)
sDimoverride z-space dimension in vtkimagedata (if >0 and <)

Definition at line 849 of file mitkImage.cpp.

References mitk::SlicedGeometry3D::GetGeometry2D(), mitk::PixelType::Initialize(), mitk::Geometry3D::SetOrigin(), and mitk::SlicedGeometry3D::SetSpacing().

{
  if(vtkimagedata==NULL) return;

  m_Dimension=vtkimagedata->GetDataDimension();
  unsigned int i, *tmpDimensions=new unsigned int[m_Dimension>4?m_Dimension:4];
  for(i=0;i<m_Dimension;++i) tmpDimensions[i]=vtkimagedata->GetDimensions()[i];
  if(m_Dimension<4)
  {
    unsigned int *p;
    for(i=0,p=tmpDimensions+m_Dimension;i<4-m_Dimension;++i, ++p)
      *p=1;
  }

  if(sDim>=0)
  {
    tmpDimensions[2]=sDim;
    if(m_Dimension < 3)
      m_Dimension = 3;
  }
  if(tDim>=0)
  {
    tmpDimensions[3]=tDim;
    if(m_Dimension < 4)
      m_Dimension = 4;
  }

  mitk::PixelType pixelType;

  switch ( vtkimagedata->GetScalarType() ) 
  {
  case VTK_BIT: 
  case VTK_CHAR: 
    pixelType.Initialize(typeid(char), vtkimagedata->GetNumberOfScalarComponents());
    break;
  case VTK_UNSIGNED_CHAR: 
    pixelType.Initialize(typeid(unsigned char), vtkimagedata->GetNumberOfScalarComponents());
    break;
  case VTK_SHORT: 
    pixelType.Initialize(typeid(short), vtkimagedata->GetNumberOfScalarComponents());
    break;
  case VTK_UNSIGNED_SHORT: 
    pixelType.Initialize(typeid(unsigned short), vtkimagedata->GetNumberOfScalarComponents());
    break;
  case VTK_INT: 
    pixelType.Initialize(typeid(int), vtkimagedata->GetNumberOfScalarComponents());
    break;
  case VTK_UNSIGNED_INT: 
    pixelType.Initialize(typeid(unsigned int), vtkimagedata->GetNumberOfScalarComponents());
    break;
  case VTK_LONG: 
    pixelType.Initialize(typeid(long), vtkimagedata->GetNumberOfScalarComponents());
    break;
  case VTK_UNSIGNED_LONG: 
    pixelType.Initialize(typeid(unsigned long), vtkimagedata->GetNumberOfScalarComponents());
    break;
  case VTK_FLOAT:
    pixelType.Initialize(typeid(float), vtkimagedata->GetNumberOfScalarComponents());
    break;
  case VTK_DOUBLE: 
    pixelType.Initialize(typeid(double), vtkimagedata->GetNumberOfScalarComponents());
    break;
  default:
    break;
  }
  Initialize(pixelType, 
    m_Dimension, 
    tmpDimensions,
    channels);

#if ((VTK_MAJOR_VERSION > 4) || ((VTK_MAJOR_VERSION==4) && (VTK_MINOR_VERSION>=4) ))
  const double *spacinglist = vtkimagedata->GetSpacing();
#else
  const float *spacinglist = vtkimagedata->GetSpacing();
#endif
  Vector3D spacing;
  FillVector3D(spacing, spacinglist[0], 1.0, 1.0);
  if(m_Dimension>=2)
    spacing[1]=spacinglist[1];
  if(m_Dimension>=3)
    spacing[2]=spacinglist[2];

  // access origin of vtkImage
    Point3D origin;
  vtkFloatingPointType vtkorigin[3];
  vtkimagedata->GetOrigin(vtkorigin);
  FillVector3D(origin, vtkorigin[0], 0.0, 0.0);
  if(m_Dimension>=2)
    origin[1]=vtkorigin[1];
  if(m_Dimension>=3)
    origin[2]=vtkorigin[2];

  SlicedGeometry3D* slicedGeometry = GetSlicedGeometry(0);

  // re-initialize PlaneGeometry with origin and direction
  PlaneGeometry* planeGeometry = static_cast<PlaneGeometry*>(slicedGeometry->GetGeometry2D(0));
  planeGeometry->SetOrigin(origin);

  // re-initialize SlicedGeometry3D
  slicedGeometry->SetOrigin(origin);
  slicedGeometry->SetSpacing(spacing);
  GetTimeSlicedGeometry()->InitializeEvenlyTimed(slicedGeometry, m_Dimensions[3]);

  delete [] tmpDimensions;
}
void mitk::Image::Initialize (  ) [protected, virtual]

Reimplemented in mitk::SeedsImage.

Definition at line 674 of file mitkImage.cpp.

{
  ImageDataItemPointerArray::iterator it, end;
  for( it=m_Slices.begin(), end=m_Slices.end(); it!=end; ++it )
  {
    (*it)=NULL;
  }
  for( it=m_Volumes.begin(), end=m_Volumes.end(); it!=end; ++it )
  {
    (*it)=NULL;
  }
  for( it=m_Channels.begin(), end=m_Channels.end(); it!=end; ++it )
  {
    (*it)=NULL;
  }
  m_CompleteData = NULL;
 
  this->GetTimeSelector(); // just to create m_TimeSelectorForExtremaObject 

  SetRequestedRegionToLargestPossibleRegion();
}
template<typename itkImageType >
void mitk::Image::InitializeByItk ( const itkImageType *  itkimage,
int  channels = 1,
int  tDim = -1,
int  sDim = -1 
) [inline]

initialize new (or re-initialize) image information by itkimage, a templated itk-image. Only the header is used, not the data vector! Use SetVolume(itkimage->GetBufferPointer()) to set the data vector.

Parameters:
tDimoverride time dimension in itkimage (if >0 and <)
sDimoverride z-space dimension in itkimage (if >0 and <)

Definition at line 306 of file mitkImage.h.

References mitk::Geometry3D::GetIndexToWorldTransform(), mitk::SlicedGeometry3D::InitializeEvenlySpaced(), matrix(), MITK_DEBUG, MITK_ERROR, MITK_WARN, mitk::Geometry3D::SetOrigin(), and mitk::SlicedGeometry3D::SetSpacing().

  {
    if(itkimage==NULL) return;

    MITK_DEBUG << "Initializing MITK image from ITK image.";
    // build array with dimensions in each direction with at least 4 entries
    m_Dimension=itkimage->GetImageDimension();
    unsigned int i, *tmpDimensions=new unsigned int[m_Dimension>4?m_Dimension:4];
    for(i=0;i<m_Dimension;++i) 
      tmpDimensions[i]=itkimage->GetLargestPossibleRegion().GetSize().GetSize()[i];
    if(m_Dimension<4)
    {
      unsigned int *p;
      for(i=0,p=tmpDimensions+m_Dimension;i<4-m_Dimension;++i, ++p)
        *p=1;
    }

    // overwrite number of slices if sDim is set
    if((m_Dimension>2) && (sDim>=0))
      tmpDimensions[2]=sDim;
    // overwrite number of time points if tDim is set
    if((m_Dimension>3) && (tDim>=0))
      tmpDimensions[3]=tDim;

    // rough initialization of Image
    Initialize(mitk::PixelType(typeid(typename itkImageType::PixelType)), 
      m_Dimension, 
      tmpDimensions,
      channels);
    const typename itkImageType::SpacingType & itkspacing = itkimage->GetSpacing();  

    MITK_DEBUG << "ITK spacing " << itkspacing;
    // access spacing of itk::Image
    Vector3D spacing;
    FillVector3D(spacing, itkspacing[0], 1.0, 1.0);
    if(m_Dimension >= 2)
      spacing[1]=itkspacing[1];
    if(m_Dimension >= 3)
      spacing[2]=itkspacing[2];

    // access origin of itk::Image
    Point3D origin;
    const typename itkImageType::PointType & itkorigin = itkimage->GetOrigin();  
    MITK_DEBUG << "ITK origin " << itkorigin;
    FillVector3D(origin, itkorigin[0], 0.0, 0.0);
    if(m_Dimension>=2)
      origin[1]=itkorigin[1];
    if(m_Dimension>=3)
      origin[2]=itkorigin[2];

    // access direction of itk::Image and include spacing
    const typename itkImageType::DirectionType & itkdirection = itkimage->GetDirection();  
    MITK_DEBUG << "ITK direction " << itkdirection;
    mitk::Matrix3D matrix;
    matrix.SetIdentity();
    unsigned int j, itkDimMax3 = (m_Dimension >= 3? 3 : m_Dimension);
    // check if spacing has no zero entry and itkdirection has no zero columns
    bool itkdirectionOk = true;
    mitk::ScalarType columnSum;
    for( j=0; j < itkDimMax3; ++j )
    {
      columnSum = 0.0;
      for ( i=0; i < itkDimMax3; ++i)
      {
        columnSum += fabs(itkdirection[i][j]);
      }
      if(columnSum < mitk::eps)
      {
        itkdirectionOk = false;
      }
      if (    (spacing[j] < - mitk::eps) // (normally sized) negative value
          &&  (j==2) && (m_Dimensions[2] == 1) )
      {
        // Negative spacings can occur when reading single DICOM slices with ITK via GDCMIO
        // In these cases spacing is not determind by ITK correctly (because it distinguishes correctly
        // between slice thickness and inter slice distance -- slice distance is meaningless for
        // single slices).
        // I experienced that ITK produced something meaningful nonetheless because is is 
        // evaluating the tag "(0018,0088) Spacing between slices" as a fallback. This tag is not
        // reliable (http://www.itk.org/pipermail/insight-users/2005-September/014711.html)
        // but gives at least a hint.
        // In real world cases I experienced that this tag contained the correct inter slice distance
        // with a negative sign, so we just invert such negative spacings.
        MITK_WARN << "Illegal value of itk::Image::GetSpacing()[" << j <<"]=" << spacing[j] << ". Using inverted value " << -spacing[j];
        spacing[j] = -spacing[j];
      }
      else if (spacing[j] < mitk::eps) // value near zero
      {
        MITK_ERROR << "Illegal value of itk::Image::GetSpacing()[" << j <<"]=" << spacing[j] << ". Using 1.0 instead.";
        spacing[j] = 1.0;
      }
    }
    if(itkdirectionOk == false)
    {
      MITK_ERROR << "Illegal matrix returned by itk::Image::GetDirection():" << itkdirection << " Using identity instead.";
      for ( i=0; i < itkDimMax3; ++i)
        for( j=0; j < itkDimMax3; ++j )
          if ( i == j )
            matrix[i][j] = spacing[j];
          else
            matrix[i][j] = 0.0;
    }
    else
    {
      for ( i=0; i < itkDimMax3; ++i)
        for( j=0; j < itkDimMax3; ++j )
          matrix[i][j] = itkdirection[i][j]*spacing[j];
    }

    // re-initialize PlaneGeometry with origin and direction
    PlaneGeometry* planeGeometry = static_cast<PlaneGeometry*>(GetSlicedGeometry(0)->GetGeometry2D(0));
    planeGeometry->SetOrigin(origin);
    planeGeometry->GetIndexToWorldTransform()->SetMatrix(matrix);

    // re-initialize SlicedGeometry3D
    SlicedGeometry3D* slicedGeometry = GetSlicedGeometry(0);
    slicedGeometry->InitializeEvenlySpaced(planeGeometry, m_Dimensions[2]);
    slicedGeometry->SetSpacing(spacing);

    // re-initialize TimeSlicedGeometry
    GetTimeSlicedGeometry()->InitializeEvenlyTimed(slicedGeometry, m_Dimensions[3]);
    
    // clean-up
    delete [] tmpDimensions;

    this->Initialize();
  };
bool mitk::Image::IsChannelSet ( int  n = 0 ) const [virtual]

Check whether the channel n is set.

Implements mitk::SlicedData.

Definition at line 488 of file mitkImage.cpp.

References QuadProgPP::t().

{
  if(IsValidChannel(n)==false) return false;
  ImageDataItemPointer ch, vol;
  ch=m_Channels[n];
  if((ch.GetPointer()!=NULL) && (ch->IsComplete()))

    return true;
  // let's see if all volumes are set, so that we can (could) combine them to a channel
  unsigned int t;
  for(t=0;t<m_Dimensions[3];++t)
    if(IsVolumeSet(t,n)==false)
      return false;
  return true;
}
bool mitk::Image::IsRotated (  ) const

Returns true if an image is rotated, i.e. its geometry's transformation matrix has nonzero elements besides the diagonal. Non-diagonal elements are checked if larger then 1/1000 of the matrix' trace.

Definition at line 1401 of file mitkImage.cpp.

References QuadProgPP::abs(), and mitk::Geometry3D::GetIndexToWorldTransform().

{
  const mitk::Geometry3D* geo = this->GetGeometry();
  bool ret = false;

  if(geo)
  {
    const vnl_matrix_fixed<float, 3, 3> & mx = geo->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix();
    float ref = 0;
    for(short k = 0; k < 3; ++k)
      ref += mx[k][k];
    ref/=1000;  // Arbitrary value; if a non-diagonal (nd) element is bigger then this, matrix is considered nd.

    for(short i = 0; i < 3; ++i)
    {
      for(short j = 0; j < 3; ++j)
      {
        if(i != j)
        {
          if(abs(mx[i][j]) > ref) // matrix is nd
            ret = true;
        }
      }
    }
  }
  return ret;
}
bool mitk::Image::IsSliceSet ( int  s = 0,
int  t = 0,
int  n = 0 
) const [virtual]

Check whether slice s at time t in channel n is set.

Implements mitk::SlicedData.

Definition at line 448 of file mitkImage.cpp.

{
  if(IsValidSlice(s,t,n)==false) return false;

  if(m_Slices[GetSliceIndex(s,t,n)].GetPointer()!=NULL)
    return true;

  ImageDataItemPointer ch, vol;
  vol=m_Volumes[GetVolumeIndex(t,n)];
  if((vol.GetPointer()!=NULL) && (vol->IsComplete()))
    return true;
  ch=m_Channels[n];
  if((ch.GetPointer()!=NULL) && (ch->IsComplete()))
    return true;
  return false;
}
bool mitk::Image::IsValidChannel ( int  n = 0 ) const [virtual]

Check whether the channel n is valid, i.e., is (or can be) inside of the image.

Definition at line 1034 of file mitkImage.cpp.

{
  if(m_Initialized)
    return IsValidSlice(0, 0, n);
  else
    return false;
}
bool mitk::Image::IsValidSlice ( int  s = 0,
int  t = 0,
int  n = 0 
) const [virtual]

Check whether slice s at time t in channel n is valid, i.e., is (or can be) inside of the image.

Definition at line 1018 of file mitkImage.cpp.

{
  if(m_Initialized)
    return ((s>=0) && (s<(int)m_Dimensions[2]) && (t>=0) && (t< (int) m_Dimensions[3]) && (n>=0) && (n< (int)GetNumberOfChannels()));
  else
    return false;
}
bool mitk::Image::IsValidTimeStep ( int  t ) const [protected, virtual]

Definition at line 1275 of file mitkImage.cpp.

{
  return ( ( m_Dimension >= 4 && t <= (int)m_Dimensions[3] && t > 0 ) || (t == 0) ); 
}
bool mitk::Image::IsValidVolume ( int  t = 0,
int  n = 0 
) const [virtual]

Check whether volume at time t in channel n is valid, i.e., is (or can be) inside of the image.

Definition at line 1026 of file mitkImage.cpp.

{
  if(m_Initialized)
    return IsValidSlice(0, t, n);
  else
    return false;
}
bool mitk::Image::IsVolumeSet ( int  t = 0,
int  n = 0 
) const [virtual]

Check whether volume at time t in channel n is set.

Implements mitk::SlicedData.

Definition at line 465 of file mitkImage.cpp.

Referenced by mitk::ImageMapperGL2D::GenerateData(), and mitk::ExtractDirectedPlaneImageFilter::GenerateData().

{
  if(IsValidVolume(t,n)==false) return false;
  ImageDataItemPointer ch, vol;

  // volume directly available?
  vol=m_Volumes[GetVolumeIndex(t,n)];
  if((vol.GetPointer()!=NULL) && (vol->IsComplete()))
    return true;

  // is volume available as part of a channel that is available?
  ch=m_Channels[n];
  if((ch.GetPointer()!=NULL) && (ch->IsComplete()))
    return true;

  // let's see if all slices of the volume are set, so that we can (could) combine them to a volume
  unsigned int s;
  for(s=0;s<m_Dimensions[2];++s)
    if(m_Slices[GetSliceIndex(s,t,n)].GetPointer()==NULL)
      return false;
  return true;
}
static Pointer mitk::Image::New (  ) [static]

Reimplemented in mitk::DiffusionImage< TPixelType >, mitk::QBallImage, mitk::TensorImage, mitk::SeedsImage, and mitk::DiffusionImage< DiffusionImagePixelType >.

Examples:
Step6RegionGrowing.txx.

Referenced by QmitkSlicesInterpolator::AcceptAllInterpolations(), QmitkImageCropper::AddSurrounding(), QmitkDeformableRegistrationView::ApplyDeformationField(), mitk::OpeningTool::ApplyFilter(), mitk::ErodeTool::ApplyFilter(), mitk::DilateTool::ApplyFilter(), mitk::ClosingTool::ApplyFilter(), QmitkPointBasedRegistrationView::calculateLandmarkWarping(), mitk::CastToMitkImage(), mitk::TensorImage::ConstructRgbImage(), mitk::QBallImage::ConstructRgbImage(), mitk::Tool::CreateEmptySegmentationNode(), mitkSegmentationInterpolationTestClass::CreateSegmentation(), CreateTestImage(), QmitkThresholdComponent::CreateThresholdSegmentation(), QmitkDiffusionTensorEstimation::DirectionVolumesAngularErrorButton(), QmitkDiffusionTensorEstimation::DirectionVolumesLoadButton(), QmitkPreprocessingView::DoBrainMask(), QmitkPreprocessingView::DoExtractB0(), mitk::ContourUtils::FillContourInSlice(), mitk::OverwriteSliceImageFilter::GenerateData(), mitk::CorrectorAlgorithm::GenerateData(), mitk::CompressedImageContainer::GetImage(), mitk::VolumeDataVtkMapper3D::GetMask(), mitk::GrabItkImageMemory(), Image(), mitk::ImageRegistrationMethod::ImageRegistrationMethod(), QmitkSegmentationPostProcessing::IncreaseCroppedImageSize(), QmitkAutocropAction::IncreaseCroppedImageSize(), mitk::CorrectorAlgorithm::ItkCalculateDifferenceImage(), mitk::AutoCropImageFilter::ITKCrop3DImage(), mitk::DicomSeriesReader::LoadDicom(), mitkBoundingObjectCutterTest(), mitkDemonsRegistrationTest(), mitkHistogramMatchingTest(), mitkImageMapper2DTest(), mitkImageTest(), mitkImageToItkTest(), mitkLevelWindowTest(), mitkPipelineSmartPointerCorrectnessTest(), mitkPropertySerializationTest(), mitkRegistrationBaseTest(), mitkSurfaceToImageFilterTest(), mitkSymmetricForcesDemonsRegistrationTest(), QmitkQBallReconstructionView::NumericalQBallReconstruction(), mitk::SetRegionTool::OnMousePressed(), mitk::RegionGrowingTool::OnMousePressed(), mitk::MorphologicTool::OnRoiDataChanged(), mitk::BinaryThresholdULTool::OnRoiDataChanged(), mitk::BinaryThresholdTool::OnRoiDataChanged(), mitk::PyramidalRegistrationMethod::PyramidalRegistrationMethod(), QmitkDiffusionTensorEstimation::QBallReconstructionButton(), QmitkDiffusionTensorEstimation::QBallStandardAlgorithmsDeconvolutionButton(), QmitkDiffusionTensorEstimation::QBallStandardAlgorithmsDirectionButton(), QmitkDiffusionTensorEstimation::QBallStandardAlgorithmsGFAButton(), QmitkDiffusionTensorEstimation::QBallVolumesLoadButton(), QmitkDiffusionTensorEstimation::QBallVolumesVisualizeSelectedButton(), QmitkDiffusionQuantificationView::QBIQuantification(), mitk::DataNodeFactory::ReadFileSeriesTypeITKImageSeriesReader(), QmitkDiffusionTensorEstimation::ReconstructAnalytically(), RegionGrowing(), mitk::NonBlockingAlgorithm::SetItkImageAsMITKImagePointerParameter(), QmitkDiffusionTensorEstimation::StandardAlgorithmsDirectionButton(), QmitkDiffusionTensorEstimation::StandardAlgorithmsFAButton(), QmitkDiffusionTensorEstimation::StandardAlgorithmsRAButton(), QmitkQBallReconstructionView::TemplatedAnalyticalQBallReconstruction(), QmitkDiffusionTensorEstimation::TensorEstimationButton(), QmitkDiffusionQuantificationView::TensorQuantification(), QmitkDiffusionTensorEstimation::TensorVolumesLoadButton(), mitkOverwriteSliceImageFilterTestClass::Test3D(), testBackCasting(), mitkDataNodeTestClass::TestDataSetting(), mitk::RawImageFileReader::TypedGenerateData(), mitk::PaintbrushTool::UpdateContour(), and mitk::BinaryThresholdULTool::UpdatePreview().

void mitk::Image::PrintSelf ( std::ostream &  os,
itk::Indent  indent 
) const [protected, virtual]

Reimplemented from mitk::BaseData.

Definition at line 1378 of file mitkImage.cpp.

{
  unsigned char i;
  if(m_Initialized)
  {
    os << indent << " PixelType: " << m_PixelType.GetTypeId()->name() << std::endl;
    os << indent << " BitsPerElement: " << m_PixelType.GetBpe() << std::endl;
    os << indent << " NumberOfComponents: " << m_PixelType.GetNumberOfComponents() << std::endl;
    os << indent << " BitsPerComponent: " << m_PixelType.GetBitsPerComponent() << std::endl;
    os << indent << " Dimension: " << m_Dimension << std::endl;
    os << indent << " Dimensions: ";
    for(i=0; i < m_Dimension; ++i)
      os << GetDimension(i) << " ";
    os << std::endl;
  }
  else
  {
    os << indent << " Image not initialized: m_Initialized: false" << std::endl;
  }

  Superclass::PrintSelf(os,indent);
}
void mitk::Image::ResetImageStatistics (  ) const [protected, virtual]

Definition at line 1295 of file mitkImage.cpp.

References QuadProgPP::max().

{
  m_ScalarMin.assign(1, itk::NumericTraits<ScalarType>::max());
  m_ScalarMax.assign(1, itk::NumericTraits<ScalarType>::NonpositiveMin());
  m_Scalar2ndMin.assign(1, itk::NumericTraits<ScalarType>::max());
  m_Scalar2ndMax.assign(1, itk::NumericTraits<ScalarType>::NonpositiveMin());
  m_CountOfMinValuedVoxels.assign(1, 0);
  m_CountOfMaxValuedVoxels.assign(1, 0);
}
bool mitk::Image::SetChannel ( const void *  data,
int  n = 0 
) [virtual]

Set data in channel n. It is in the responsibility of the caller to ensure that the data vector data is really a channel (at least is not smaller than a channel), since there is no chance to check this.

The data is copied to an array managed by the image. If the image shall reference the data, use SetImportChannel with ImportMemoryManagementType set to ReferenceMemory. For importing ITK images use of mitk:: ITKImageImport is recommended.

See also:
SetPicChannel, SetImportChannel

Definition at line 516 of file mitkImage.cpp.

{
  // const_cast is no risk for ImportMemoryManagementType == CopyMemory
  return SetImportChannel(const_cast<void*>(data), n, CopyMemory);
}
void mitk::Image::SetGeometry ( Geometry3D aGeometry3D ) [virtual]

Set the Geometry3D of the data, which will be referenced (not copied!). It has to be a sub-class of SlicedGeometry3D.

Warning:
This method will normally be called internally by the sub-class of SlicedData during initialization.

Reimplemented from mitk::SlicedData.

Definition at line 1169 of file mitkImage.cpp.

bool mitk::Image::SetImportChannel ( void *  data,
int  n = 0,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) [virtual]

Set data in channel n. It is in the responsibility of the caller to ensure that the data vector data is really a channel (at least is not smaller than a channel), since there is no chance to check this.

The data is managed according to the parameter importMemoryManagement.

See also:
SetPicChannel

Definition at line 586 of file mitkImage.cpp.

{
  if(IsValidChannel(n)==false) return false;
  ImageDataItemPointer ch;
  if(IsChannelSet(n))
  {
    ch=GetChannelData(n,data,importMemoryManagement);
    if(ch->GetManageMemory()==false)
    {
      ch=AllocateChannelData(n,data,importMemoryManagement);
      if(ch.GetPointer()==NULL) return false;
    }
    if ( ch->GetData() != data )
      std::memcpy(ch->GetData(), data, m_OffsetTable[4]*(m_PixelType.GetBpe()/8));
    ch->Modified();
    ch->SetComplete(true);
    //we have changed the data: call Modified()! 
    Modified();
  }
  else
  {
    ch=AllocateChannelData(n,data,importMemoryManagement);
    if(ch.GetPointer()==NULL) return false;
    if ( ch->GetData() != data )
      std::memcpy(ch->GetData(), data, m_OffsetTable[4]*(m_PixelType.GetBpe()/8));
    ch->SetComplete(true);
    //we just added a missing Channel, which is not regarded as modification.
    //Therefore, we do not call Modified()!
  }
  return true;
}
bool mitk::Image::SetImportSlice ( void *  data,
int  s = 0,
int  t = 0,
int  n = 0,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) [virtual]

Set data as slice s at time t in channel n. It is in the responsibility of the caller to ensure that the data vector data is really a slice (at least is not smaller than a slice), since there is no chance to check this.

The data is managed according to the parameter importMemoryManagement.

See also:
SetPicSlice

Definition at line 522 of file mitkImage.cpp.

{
  if(IsValidSlice(s,t,n)==false) return false;
  ImageDataItemPointer sl;
  if(IsSliceSet(s,t,n))
  {
    sl=GetSliceData(s,t,n,data,importMemoryManagement);
    if(sl->GetManageMemory()==false)
    {
      sl=AllocateSliceData(s,t,n,data,importMemoryManagement);
      if(sl.GetPointer()==NULL) return false;
    }
    if ( sl->GetData() != data )
      std::memcpy(sl->GetData(), data, m_OffsetTable[2]*(m_PixelType.GetBpe()/8));
    sl->Modified();
    //we have changed the data: call Modified()! 
    Modified();
  }
  else
  {
    sl=AllocateSliceData(s,t,n,data,importMemoryManagement);
    if(sl.GetPointer()==NULL) return false;
    if ( sl->GetData() != data )
      std::memcpy(sl->GetData(), data, m_OffsetTable[2]*(m_PixelType.GetBpe()/8));
    //we just added a missing slice, which is not regarded as modification.
    //Therefore, we do not call Modified()!
  }
  return true;
}
bool mitk::Image::SetImportVolume ( void *  data,
int  t = 0,
int  n = 0,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) [virtual]

Set data as volume at time t in channel n. It is in the responsibility of the caller to ensure that the data vector data is really a volume (at least is not smaller than a volume), since there is no chance to check this.

The data is managed according to the parameter importMemoryManagement.

See also:
SetPicVolume

Definition at line 552 of file mitkImage.cpp.

Referenced by mitk::PlaneCutFilter::GenerateData().

{
  if(IsValidVolume(t,n)==false) return false;
  ImageDataItemPointer vol;
  if(IsVolumeSet(t,n))
  {
    vol=GetVolumeData(t,n,data,importMemoryManagement);
    if(vol->GetManageMemory()==false)
    {
      vol=AllocateVolumeData(t,n,data,importMemoryManagement);
      if(vol.GetPointer()==NULL) return false;
    }
    if ( vol->GetData() != data )
      std::memcpy(vol->GetData(), data, m_OffsetTable[3]*(m_PixelType.GetBpe()/8));
    vol->Modified();
    vol->SetComplete(true);
    //we have changed the data: call Modified()! 
    Modified();
  }
  else
  {
    vol=AllocateVolumeData(t,n,data,importMemoryManagement);
    if(vol.GetPointer()==NULL) return false;
    if ( vol->GetData() != data )
    { 
      std::memcpy(vol->GetData(), data, m_OffsetTable[3]*(m_PixelType.GetBpe()/8));
    }
    vol->SetComplete(true);
    //we just added a missing Volume, which is not regarded as modification.
    //Therefore, we do not call Modified()!
  }
  return true;
}
bool mitk::Image::SetPicChannel ( const mitkIpPicDescriptor *  pic,
int  n = 0,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) [virtual]

Set pic in channel n.

The data is copied to an array managed by the image.

Returns:
false : dimensions and/or data-type of pic does not comply with image true success

Definition at line 651 of file mitkImage.cpp.

{
  if(pic==NULL) return false;
  if(pic->dim<=3) return SetPicVolume(pic, 0, n);
  if(pic->dim!=m_Dimension) return false;
  unsigned int i;
  for(i=0;i<m_Dimension; ++i)
  {
    if(pic->n[i]!=m_Dimensions[i]) return false;
  }
  if(SetChannel(pic->data,n)) //@todo: add geometry!
  {
    ImageDataItemPointer ch;
    ch=GetChannelData(n,NULL,CopyMemory);
    // commented the next line, because 
    // it crashes when called from mitkDICOMFileReader for the Live3D data
    // mitkIpFuncCopyTags(ch->GetPicDescriptor(), pic);
    return true;
  }
  else
    return false;
}
bool mitk::Image::SetPicSlice ( const mitkIpPicDescriptor *  pic,
int  s = 0,
int  t = 0,
int  n = 0,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) [virtual]

Set pic as slice s at time t in channel n.

The data is copied to an array managed by the image.

Returns:
false : dimensions and/or data-type of pic does not comply with image true success

Definition at line 618 of file mitkImage.cpp.

References mitkIpPicDescriptor.

{
  if(pic==NULL) return false;
  if(pic->dim!=2) return false;
  if((pic->n[0]!=m_Dimensions[0]) || (pic->n[1]!=m_Dimensions[1])) return false;
  if(SetSlice(pic->data,s,t,n)) //@todo: add geometry!
  {
    ImageDataItemPointer sl;
    sl=GetSliceData(s,t,n,NULL,CopyMemory);
    mitkIpFuncCopyTags(sl->GetPicDescriptor(), const_cast<mitkIpPicDescriptor *>(pic));
    return true;
  }
  else
    return false;
}
bool mitk::Image::SetPicVolume ( const mitkIpPicDescriptor *  pic,
int  t = 0,
int  n = 0,
ImportMemoryManagementType  importMemoryManagement = CopyMemory 
) [virtual]

Set pic as volume at time t in channel n.

The data is copied to an array managed by the image.

Returns:
false : dimensions and/or data-type of pic does not comply with image true success

Definition at line 634 of file mitkImage.cpp.

References mitkIpPicDescriptor.

{
  if(pic==NULL) return false;
  if((pic->dim==2) && ((m_Dimension==2) || ((m_Dimension>2) && (m_Dimensions[2]==1)))) return SetPicSlice(pic, 0, t, n);
  if(pic->dim!=3) return false;
  if((pic->n[0]!=m_Dimensions[0]) || (pic->n[1]!=m_Dimensions[1]) || (pic->n[2]!=m_Dimensions[2])) return false;
  if(SetVolume(pic->data,t,n)) //@todo: add geometry!
  {
    ImageDataItemPointer vol;
    vol=GetVolumeData(t,n,NULL,CopyMemory);
    mitkIpFuncCopyTags(vol->GetPicDescriptor(), const_cast<mitkIpPicDescriptor *>(pic));
    return true;
  }
  else
    return false;
}
bool mitk::Image::SetSlice ( const void *  data,
int  s = 0,
int  t = 0,
int  n = 0 
) [virtual]

Set data as slice s at time t in channel n. It is in the responsibility of the caller to ensure that the data vector data is really a slice (at least is not smaller than a slice), since there is no chance to check this.

The data is copied to an array managed by the image. If the image shall reference the data, use SetImportSlice with ImportMemoryManagementType set to ReferenceMemory. For importing ITK images use of mitk:: ITKImageImport is recommended.

See also:
SetPicSlice, SetImportSlice, SetImportVolume

Definition at line 504 of file mitkImage.cpp.

{
  // const_cast is no risk for ImportMemoryManagementType == CopyMemory
  return SetImportSlice(const_cast<void*>(data), s, t, n, CopyMemory);
}
bool mitk::Image::SetVolume ( const void *  data,
int  t = 0,
int  n = 0 
) [virtual]

Set data as volume at time t in channel n. It is in the responsibility of the caller to ensure that the data vector data is really a volume (at least is not smaller than a volume), since there is no chance to check this.

The data is copied to an array managed by the image. If the image shall reference the data, use SetImportVolume with ImportMemoryManagementType set to ReferenceMemory. For importing ITK images use of mitk:: ITKImageImport is recommended.

See also:
SetPicVolume, SetImportVolume

Definition at line 510 of file mitkImage.cpp.

{
  // const_cast is no risk for ImportMemoryManagementType == CopyMemory
  return SetImportVolume(const_cast<void*>(data), t, n, CopyMemory);
}

Friends And Related Function Documentation

template<typename ItkImageType >
void _ComputeExtremaInItkImage ( ItkImageType *  itkImage,
mitk::Image mitkImage,
int  t 
) [friend]
friend class SubImageSelector [friend]

Definition at line 64 of file mitkImage.h.


Member Data Documentation

Definition at line 593 of file mitkImage.h.

Definition at line 600 of file mitkImage.h.

std::vector<unsigned int> mitk::Image::m_CountOfMaxValuedVoxels [mutable, protected]

Definition at line 607 of file mitkImage.h.

Referenced by Image().

std::vector<unsigned int> mitk::Image::m_CountOfMinValuedVoxels [mutable, protected]

Definition at line 606 of file mitkImage.h.

Referenced by Image().

unsigned int mitk::Image::m_Dimension [protected]

Definition at line 597 of file mitkImage.h.

unsigned int* mitk::Image::m_Dimensions [protected]

Definition at line 598 of file mitkImage.h.

itk::Object::Pointer mitk::Image::m_HistogramGeneratorObject [mutable, protected]

Definition at line 603 of file mitkImage.h.

Referenced by Image().

itk::TimeStamp mitk::Image::m_LastRecomputeTimeStamp [protected]

Definition at line 613 of file mitkImage.h.

vcl_size_t* mitk::Image::m_OffsetTable [protected]

Definition at line 599 of file mitkImage.h.

Definition at line 601 of file mitkImage.h.

std::vector<ScalarType> mitk::Image::m_Scalar2ndMax [mutable, protected]

Definition at line 611 of file mitkImage.h.

Referenced by Image().

std::vector<ScalarType> mitk::Image::m_Scalar2ndMin [mutable, protected]

Definition at line 610 of file mitkImage.h.

Referenced by Image().

std::vector<ScalarType> mitk::Image::m_ScalarMax [mutable, protected]

Definition at line 609 of file mitkImage.h.

Referenced by Image().

std::vector<ScalarType> mitk::Image::m_ScalarMin [mutable, protected]

Definition at line 608 of file mitkImage.h.

Referenced by Image().

Definition at line 595 of file mitkImage.h.

itk::Object::Pointer mitk::Image::m_TimeSelectorForExtremaObject [mutable, protected]

Definition at line 605 of file mitkImage.h.

Definition at line 594 of file mitkImage.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines