Example #1
0
void mitk::TbssImage::InitializeFromVectorImage()
{
  if(!m_Image)
  {
    MITK_INFO << "TBSS Image could not be initialized. Set all members first!" << std::endl;
    return;
  }


  typedef itk::Image<float,3> ImgType;
  ImgType::Pointer img = ImgType::New();
  img->SetSpacing( m_Image->GetSpacing() );   // Set the image spacing
  img->SetOrigin( m_Image->GetOrigin() );     // Set the image origin
  img->SetDirection( m_Image->GetDirection() );  // Set the image direction
  img->SetLargestPossibleRegion( m_Image->GetLargestPossibleRegion());
  img->SetBufferedRegion( m_Image->GetLargestPossibleRegion() );
  img->Allocate();

  int vecLength = m_Image->GetVectorLength();
  InitializeByItk( img.GetPointer(), 1, vecLength );

  //for(int i=0; i<vecLength; i++)
  //{TbssImage();


  itk::ImageRegionIterator<ImgType> itw (img, img->GetLargestPossibleRegion() );
  itw = itw.Begin();

  itk::ImageRegionConstIterator<ImageType> itr (m_Image, m_Image->GetLargestPossibleRegion() );
  itr = itr.Begin();

  while(!itr.IsAtEnd())
  {
    itw.Set(itr.Get().GetElement(0));
    ++itr;
    ++itw;
  }

  // init
  SetImportVolume(img->GetBufferPointer());//, 0, 0, CopyMemory);
    //SetVolume( img->GetBufferPointer(), i );
  //}::

  m_DisplayIndex = 0;
  MITK_INFO << "Tbss-Image successfully initialized.";

}
Example #2
0
void mitk::ExtractSliceFilter2::AllocateOutputs()
{
  const auto* inputImage = this->GetInput();
  const auto* outputGeometry = this->GetOutputGeometry();
  auto outputImage = this->GetOutput();
  auto pixelType = inputImage->GetPixelType();

  outputImage->Initialize(pixelType, 1, *outputGeometry);

  auto data = new char[static_cast<std::size_t>(pixelType.GetSize() * outputGeometry->GetExtent(0) * outputGeometry->GetExtent(1))];

  try
  {
    if (!outputImage->SetImportVolume(data, 0, 0, mitk::Image::ReferenceMemory))
      throw;
  }
  catch (...)
  {
    delete[] data;
  }
}
Example #3
0
bool mitk::Image::SetVolume(const void *data, int t, int n)
{
  // const_cast is no risk for ImportMemoryManagementType == CopyMemory
  return SetImportVolume(const_cast<void*>(data), t, n, CopyMemory);
}