コード例 #1
0
    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 }};

    }
コード例 #2
0
// Helper function to get a geometry of an image for a specific time step.
static mitk::BaseGeometry::Pointer GetGeometry(mitk::Image::Pointer image, unsigned int timeStep)
{
  mitk::TimeGeometry::Pointer timeGeometry = image->GetTimeGeometry();

  if (timeGeometry.IsNull())
    mitkThrow();

  auto geometry = timeGeometry->GetGeometryForTimeStep(timeStep);

  if (geometry.IsNull())
    mitkThrow();

  return geometry;
}