void setUp() override
    {
        m_ReferenceImage = mitk::IOUtil::LoadImage(GetTestDataFilePath("Pic3D.nrrd"));
        CPPUNIT_ASSERT_MESSAGE("Failed to load image for test: [Pic3D.nrrd]", m_ReferenceImage.IsNotNull());

        m_InterpolationController = mitk::SegmentationInterpolationController::GetInstance();

        // Create empty segmentation
        // Surely there must be a better way to get an image with all zeros?
        m_SegmentationImage = mitk::Image::New();
        const mitk::PixelType pixelType(mitk::MakeScalarPixelType<mitk::Tool::DefaultSegmentationDataType>());
        m_SegmentationImage->Initialize(pixelType, m_ReferenceImage->GetDimension(), m_ReferenceImage->GetDimensions());
        m_SegmentationImage->SetClonedTimeGeometry(m_ReferenceImage->GetTimeGeometry());
        unsigned int size = sizeof(mitk::Tool::DefaultSegmentationDataType);
        for (unsigned int dim = 0; dim < m_SegmentationImage->GetDimension(); ++dim)
        {
            size *= m_SegmentationImage->GetDimension(dim);
        }
        mitk::ImageWriteAccessor imageAccessor(m_SegmentationImage);
        memset(imageAccessor.GetData(), 0, size);

        // Work in the center of the image (Pic3D)
        m_CenterPoint = {{ 127, 127, 25 }};

    }
void mitk::ToFVisualizationFilter::InitImage(mitk::Image::Pointer image)
{
  unsigned int dimensions[2];
  dimensions[0] = this->m_ImageWidth;
  dimensions[1] = this->m_ImageHeight;
  image->Initialize(mitk::PixelType(mitkIpPicUInt, 24, 3), 2, dimensions); //unsigned char RGB
}
Ejemplo n.º 3
0
void mitk::USTelemedImageSource::GetNextRawImage( mitk::Image::Pointer& image)
{
  if ( image.IsNull() ) { image = mitk::Image::New(); }

  //get the actual resolution to check if it changed. We have to do this every time because the geometry takes a few frames to adapt
  Usgfw2Lib::tagImageResolution resolutionInMetersActual;
  m_ImageProperties->GetResolution(&resolutionInMetersActual, 0);
  if (m_OldnXPelsPerUnit != resolutionInMetersActual.nXPelsPerUnit || m_OldnYPelsPerUnit != resolutionInMetersActual.nYPelsPerUnit)
    {
      //we can only update if the image exists and has a geometry
      if (m_Image.IsNotNull() && m_Image->GetGeometry() != nullptr)
     {
        m_OldnXPelsPerUnit = resolutionInMetersActual.nXPelsPerUnit;
        m_OldnYPelsPerUnit = resolutionInMetersActual.nYPelsPerUnit;
        UpdateImageGeometry();
      }

    }
  //now update image
  if ( m_Image->IsInitialized() )
  {
    m_ImageMutex->Lock();

    // copy contents of the given image into the member variable
    image->Initialize(m_Image->GetPixelType(), m_Image->GetDimension(), m_Image->GetDimensions());
    mitk::ImageReadAccessor inputReadAccessor(m_Image, m_Image->GetSliceData(0,0,0));
    image->SetSlice(inputReadAccessor.GetData());
    image->SetGeometry(m_Image->GetGeometry());

    m_ImageMutex->Unlock();
  }

}
bool mitkSegmentationInterpolationTestClass::CreateSegmentation()
{
  m_Image = mitk::Image::New();
  dim[0]=15;
  dim[1]=20;
  dim[2]=25;
  pad[0]=2;
  pad[1]=3;
  pad[2]=4;

  m_Image->Initialize(mitk::PixelType(typeid(int)), 3, dim);

  return true;
}
Ejemplo n.º 5
0
  void TestReadWrite3DplusTLabelSetImage()
  {
    unsigned int dimensions[4] = {256, 256, 312, 10};
    regularImage->Initialize(mitk::MakeScalarPixelType<int>(), 4, dimensions);

    multilabelImage = mitk::LabelSetImage::New();
    multilabelImage->Initialize(regularImage);
    mitk::LabelSet::Pointer newlayer = mitk::LabelSet::New();
    newlayer->SetLayer(1);
    mitk::Label::Pointer label0 = mitk::Label::New();
    label0->SetName("Background");
    label0->SetValue(0);

    mitk::Label::Pointer label1 = mitk::Label::New();
    label1->SetName("Label1");
    label1->SetValue(1);

    mitk::Label::Pointer label2 = mitk::Label::New();
    label2->SetName("Label2");
    label2->SetValue(200);

    newlayer->AddLabel(label0);
    newlayer->AddLabel(label1);
    newlayer->AddLabel(label2);
    newlayer->SetActiveLabel(200);

    multilabelImage->AddLayer(newlayer);

    pathToImage = mitk::IOUtil::CreateTemporaryDirectory();
    pathToImage.append("/LabelSetTestImage3DplusT.nrrd");

    mitk::IOUtil::Save(multilabelImage, pathToImage);

    mitk::LabelSetImage::Pointer loadedImage =
      dynamic_cast<mitk::LabelSetImage *>(mitk::IOUtil::Load(pathToImage)[0].GetPointer());

    // This information is currently not serialized but also checked within the Equals function
    loadedImage->SetActiveLayer(multilabelImage->GetActiveLayer());

    CPPUNIT_ASSERT_MESSAGE("Error reading label set image", loadedImage.IsNotNull());
    CPPUNIT_ASSERT_MESSAGE("Error reading label set image", mitk::Equal(*multilabelImage, *loadedImage, 0.0001, true));

    itksys::SystemTools::RemoveFile(pathToImage);
  }