コード例 #1
0
  void Init()
  {

    im1 = mitk::ImageGenerator::GenerateRandomImage<double>(2,2,2,1,2,2,2,1,0);
    im2 = mitk::ImageGenerator::GenerateRandomImage<double>(3,3,3,1,3,3,3,3,2);
    im3 = mitk::ImageGenerator::GenerateRandomImage<double>(4,4,4,1,4,4,4,5,4);
    im4 = mitk::ImageGenerator::GenerateRandomImage<double>(5,5,5,1,5,5,5,7,6);

    dataCol1 = mitk::DataCollection::New();
    dataCol2 = mitk::DataCollection::New();

    dataCol1->AddData(im1.GetPointer(),"T1");

    dataCol1->AddData(im2.GetPointer(),"T2");

    dataCol2->AddData(im3.GetPointer(),"T1");
    dataCol2->AddData(im4.GetPointer(),"T2");

    col1 = mitk::DataCollection::New();

    col1->SetName("GnaBla");
    col1->AddData(dataCol1.GetPointer(), "0001");
    col1->AddData(dataCol2.GetPointer(), "0002");

    m_Collection = mitk::DataCollection::New();

    m_Collection->SetName("DummyCollection");
    m_Collection->AddData(col1.GetPointer(), "C1");


  }
コード例 #2
0
static void EnsureDataImageInCollection(mitk::DataCollection::Pointer collection, std::string origin, std::string target)
{
  typedef itk::Image<double, 3> FeatureImage;

  if (collection->HasElement(origin))
  {
    mitk::Image::Pointer originImage = dynamic_cast<mitk::Image*>(collection->GetMitkImage(origin).GetPointer());
    FeatureImage::Pointer itkOriginImage = FeatureImage::New();
    mitk::CastToItkImage(originImage,itkOriginImage);

    if (!collection->HasElement(target) && itkOriginImage.IsNotNull())
    {
      FeatureImage::Pointer image = FeatureImage::New();
      image->SetRegions(itkOriginImage->GetLargestPossibleRegion());
      image->SetSpacing(itkOriginImage->GetSpacing());
      image->SetOrigin(itkOriginImage->GetOrigin());
      image->SetDirection(itkOriginImage->GetDirection());
      image->Allocate();

      collection->AddData(dynamic_cast<itk::DataObject*>(image.GetPointer()),target,"");
    }
  }
  for (std::size_t i = 0; i < collection->Size();++i)
  {
    mitk::DataCollection* newCol = dynamic_cast<mitk::DataCollection*>(collection->GetData(i).GetPointer());
    if (newCol != 0)
    {
      EnsureDataImageInCollection(newCol, origin, target);
    }
  }
}
コード例 #3
0
void mitk::DCUtilities::EnsureUCharImageInDC(mitk::DataCollection::Pointer dc, std::string name, std::string origin)
{
  typedef itk::Image<unsigned char, 3> FeatureImage;
  typedef itk::Image<unsigned char, 3> LabelImage;

  mitk::DataCollectionImageIterator<unsigned char , 3> iter( dc, origin);
  while (!iter.IsAtEnd())
  {
    ++iter;
  }

  if (dc->HasElement(origin))
  {
    LabelImage::Pointer originImage = dynamic_cast<LabelImage*>(dc->GetData(origin).GetPointer());
    //    = dynamic_cast<LabelImage*>(dc->GetItkImage<LabelImage>(origin).GetPointer());
    if (!dc->HasElement(name) && originImage.IsNotNull())
    {
      MITK_INFO << "New unsigned char image necessary";
      FeatureImage::Pointer image = FeatureImage::New();
      image->SetRegions(originImage->GetLargestPossibleRegion());
      image->SetSpacing(originImage->GetSpacing());
      image->SetOrigin(originImage->GetOrigin());
      image->SetDirection(originImage->GetDirection());
      image->Allocate();
      image->FillBuffer(0);

      dc->AddData(dynamic_cast<itk::DataObject*>(image.GetPointer()),name,"");
    }
  }
  for (std::size_t i = 0; i < dc->Size();++i)
  {
    mitk::DataCollection* newCol = dynamic_cast<mitk::DataCollection*>(dc->GetData(i).GetPointer());
    if (newCol != 0)
    {
      EnsureUCharImageInDC(newCol, name, origin);
    }
  }
}