本文整理汇总了C++中mitk::labelsetimage::Pointer::InitializeByLabeledImage方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::InitializeByLabeledImage方法的具体用法?C++ Pointer::InitializeByLabeledImage怎么用?C++ Pointer::InitializeByLabeledImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mitk::labelsetimage::Pointer
的用法示例。
在下文中一共展示了Pointer::InitializeByLabeledImage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestInitializeByLabeledImage
void TestInitializeByLabeledImage()
{
mitk::Image::Pointer image =
dynamic_cast<mitk::Image*>(mitk::IOUtil::Load(GetTestDataFilePath("Multilabel/LabelSetTestInitializeImage.nrrd"))[0].GetPointer());
m_LabelSetImage->InitializeByLabeledImage(image);
CPPUNIT_ASSERT_MESSAGE("Image - number of labels is not 6", m_LabelSetImage->GetNumberOfLabels() == 6);
}
示例2: TestRemoveLabels
void TestRemoveLabels()
{
mitk::Image::Pointer image =
dynamic_cast<mitk::Image*>(mitk::IOUtil::Load(GetTestDataFilePath("Multilabel/LabelSetTestInitializeImage.nrrd"))[0].GetPointer());
m_LabelSetImage->InitializeByLabeledImage(image);
CPPUNIT_ASSERT_MESSAGE("Image - number of labels is not 6", m_LabelSetImage->GetNumberOfLabels() == 6);
// 2ndMin because of the exterior label = 0
CPPUNIT_ASSERT_MESSAGE("Labels with value 1 and 3 was not remove from the image",
m_LabelSetImage->GetStatistics()->GetScalarValue2ndMin() == 1);
CPPUNIT_ASSERT_MESSAGE("Label with value 7 was not remove from the image",
m_LabelSetImage->GetStatistics()->GetScalarValueMax() == 7);
CPPUNIT_ASSERT_MESSAGE("Label with ID 3 does not exists after initialization",
m_LabelSetImage->ExistLabel(3) == true);
CPPUNIT_ASSERT_MESSAGE("Label with ID 7 does not exists after initialization",
m_LabelSetImage->ExistLabel(7) == true);
std::vector<mitk::Label::PixelType> labelsToBeRemoved;
labelsToBeRemoved.push_back(1);
labelsToBeRemoved.push_back(3);
labelsToBeRemoved.push_back(7);
m_LabelSetImage->RemoveLabels(labelsToBeRemoved);
CPPUNIT_ASSERT_MESSAGE("Wrong number of labels after some have been removed",
m_LabelSetImage->GetNumberOfLabels() == 3);
// Values within the image are 0, 1, 3, 5, 6, 7 - New Min/Max value should be 5 / 6
// 2ndMin because of the exterior label = 0
CPPUNIT_ASSERT_MESSAGE("Labels with value 1 and 3 was not remove from the image",
m_LabelSetImage->GetStatistics()->GetScalarValue2ndMin() == 5);
CPPUNIT_ASSERT_MESSAGE("Label with value 7 was not remove from the image",
m_LabelSetImage->GetStatistics()->GetScalarValueMax() == 6);
}
示例3: MitkImageToMitkLabelSetImage
void MitkImageToMitkLabelSetImage(itk::VectorImage< TPixel, VDimensions> * source, mitk::LabelSetImage::Pointer &output)
{
typedef itk::VectorImage< TPixel, VDimensions > VectorImageType;
typedef itk::Image< TPixel, VDimensions > ImageType;
typedef itk::VectorIndexSelectionCastImageFilter< VectorImageType, ImageType > VectorIndexSelectorType;
unsigned int numberOfComponents = source->GetVectorLength();
if (numberOfComponents < 1)
{
mitkThrow() << "At least one Component is required.";
}
typename VectorIndexSelectorType::Pointer vectorIndexSelector = VectorIndexSelectorType::New();
vectorIndexSelector->SetIndex(0);
vectorIndexSelector->SetInput(source);
vectorIndexSelector->Update();
mitk::Image::Pointer tempImage;
mitk::CastToMitkImage(vectorIndexSelector->GetOutput(), tempImage);
output = mitk::LabelSetImage::New();
output->InitializeByLabeledImage(tempImage);
for (unsigned int layer = 1; layer < numberOfComponents; ++layer)
{
typename VectorIndexSelectorType::Pointer vectorIndexSelectorLoop = VectorIndexSelectorType::New();
vectorIndexSelectorLoop->SetIndex(layer);
vectorIndexSelector->SetInput(source);
vectorIndexSelector->Update();
mitk::Image::Pointer loopImage;
mitk::CastToMitkImage(vectorIndexSelector->GetOutput(), loopImage);
output->AddLayer(loopImage);
}
}
示例4: TestMergeLabel
void TestMergeLabel()
{
mitk::Image::Pointer image = dynamic_cast<mitk::Image*>(mitk::IOUtil::Load(GetTestDataFilePath("Multilabel/LabelSetTestInitializeImage.nrrd"))[0].GetPointer());
m_LabelSetImage = 0;
m_LabelSetImage = mitk::LabelSetImage::New();
m_LabelSetImage->InitializeByLabeledImage(image);
CPPUNIT_ASSERT_MESSAGE("Image - number of labels is not 6", m_LabelSetImage->GetNumberOfLabels() == 6);
// 2ndMin because of the exterior label = 0
CPPUNIT_ASSERT_MESSAGE("Wrong MIN value", m_LabelSetImage->GetStatistics()->GetScalarValueMin() == 0);
CPPUNIT_ASSERT_MESSAGE("Wrong MAX value", m_LabelSetImage->GetStatistics()->GetScalarValueMax() == 7);
m_LabelSetImage->GetActiveLabelSet()->SetActiveLabel(6);
// Merge label 7 with label 0. Result should be that label 7 is not present any more
m_LabelSetImage->MergeLabel(6, 7);
CPPUNIT_ASSERT_MESSAGE("Label with value 7 was not remove from the image", m_LabelSetImage->GetStatistics()->GetScalarValueMax() == 6);
m_LabelSetImage->GetStatistics()->GetScalarValue2ndMax();
// Count all pixels with value 7 = 823
// Count all pixels with value 6 = 507
// Check if merge label has 507 + 823 = 1330 pixels
CPPUNIT_ASSERT_MESSAGE("Label with value 7 was not remove from the image", m_LabelSetImage->GetStatistics()->GetCountOfMaxValuedVoxels() == 1330);
}