Exemplo n.º 1
0
void mitk::ProbeFilter::GenerateOutputInformation()
{
  mitk::Surface::ConstPointer input  = this->GetInput();
  mitk::Image::ConstPointer source = this->GetSource();
  mitk::Surface::Pointer output = this->GetOutput();

  if(input.IsNull()) return;
  if(source.IsNull()) return;

  if(input->GetGeometry()==NULL) return;
  if(source->GetGeometry()==NULL) return;

  if( (input->GetTimeGeometry()->CountTimeSteps()==1) && (source->GetTimeGeometry()->CountTimeSteps()>1) )
  {
    Geometry3D::Pointer geo3D = Geometry3D::New();
    BaseGeometry::Pointer geometry3D = dynamic_cast<BaseGeometry*>(geo3D.GetPointer());
    geometry3D->Initialize();
    geometry3D->SetBounds(source->GetTimeGeometry()->GetBoundsInWorld());

    ProportionalTimeGeometry::Pointer outputTimeGeometry = ProportionalTimeGeometry::New();
    outputTimeGeometry->Initialize(geometry3D, source->GetTimeGeometry()->CountTimeSteps());
    outputTimeGeometry->SetFirstTimePoint(source->GetTimeGeometry()->GetMinimumTimePoint());
    TimePointType stepDuration = source->GetTimeGeometry()->GetMaximumTimePoint(0) - source->GetTimeGeometry()->GetMinimumTimePoint(0);
    outputTimeGeometry->SetStepDuration(stepDuration);

    output->Expand(outputTimeGeometry->CountTimeSteps());
    output->SetTimeGeometry( outputTimeGeometry );
  }
  else
    output->SetGeometry( static_cast<BaseGeometry*>(input->GetGeometry()->Clone().GetPointer()) );

  itkDebugMacro(<<"GenerateOutputInformation()");
}
Exemplo n.º 2
0
void mitk::Image::Initialize(const mitk::PixelType& type, unsigned int dimension, const unsigned int *dimensions, unsigned int channels)
{
  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]);
  }

  // create new array since the old was deleted
  m_Dimensions = new unsigned int[MAX_IMAGE_DIMENSIONS];

  // initialize the first four dimensions to 1, the remaining 4 to 0
  FILL_C_ARRAY(m_Dimensions, 4, 1u);
  FILL_C_ARRAY((m_Dimensions+4), 4, 0u);

  // copy in the passed dimension information
  std::memcpy(m_Dimensions, dimensions, sizeof(unsigned int)*m_Dimension);

  this->m_ImageDescriptor = mitk::ImageDescriptor::New();
  this->m_ImageDescriptor->Initialize( this->m_Dimensions, this->m_Dimension );

  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;
  }

  for( unsigned int i=0u; i<channels; i++)
  {
    this->m_ImageDescriptor->AddNewChannel( 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);
  }

  ProportionalTimeGeometry::Pointer timeGeometry = ProportionalTimeGeometry::New();
  timeGeometry->Initialize(slicedGeometry, m_Dimensions[3]);
  for (TimeStepType step = 0; step < timeGeometry->CountTimeSteps(); ++step)
  {
    timeGeometry->GetGeometryForTimeStep(step)->ImageGeometryOn();
  }
  SetTimeGeometry(timeGeometry);

  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;
}