本文整理汇总了C++中mitk::labelsetimage::Pointer::GetActiveLabelSet方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::GetActiveLabelSet方法的具体用法?C++ Pointer::GetActiveLabelSet怎么用?C++ Pointer::GetActiveLabelSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mitk::labelsetimage::Pointer
的用法示例。
在下文中一共展示了Pointer::GetActiveLabelSet方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestSetActiveLayer
void TestSetActiveLayer()
{
// Cache active layer
mitk::LabelSet::ConstPointer activeLayer = m_LabelSetImage->GetActiveLabelSet();
// Add new layer
mitk::LabelSet::Pointer newlayer = mitk::LabelSet::New();
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(label1);
newlayer->AddLabel(label2);
newlayer->SetActiveLabel(200);
unsigned int layerID = m_LabelSetImage->AddLayer(newlayer);
// Set initial layer as active layer
m_LabelSetImage->SetActiveLayer(0);
CPPUNIT_ASSERT_MESSAGE("Wrong active labelset returned", mitk::Equal(*activeLayer, *m_LabelSetImage->GetActiveLabelSet(), 0.00001, true));
// Set previously added layer as active layer
m_LabelSetImage->SetActiveLayer(layerID);
CPPUNIT_ASSERT_MESSAGE("Wrong active labelset returned", mitk::Equal(*newlayer, *m_LabelSetImage->GetActiveLabelSet(), 0.00001, true));
// Set a non existing layer as active layer - nothing should change
m_LabelSetImage->SetActiveLayer(10000);
CPPUNIT_ASSERT_MESSAGE("Wrong active labelset returned", mitk::Equal(*newlayer, *m_LabelSetImage->GetActiveLabelSet(), 0.00001, true));
}
示例2: TestRemoveLayer
void TestRemoveLayer()
{
// Cache active layer
mitk::LabelSet::ConstPointer activeLayer = m_LabelSetImage->GetActiveLabelSet();
// Add new layers
m_LabelSetImage->AddLayer();
mitk::LabelSet::Pointer newlayer = mitk::LabelSet::New();
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(label1);
newlayer->AddLabel(label2);
newlayer->SetActiveLabel(200);
m_LabelSetImage->AddLayer(newlayer);
CPPUNIT_ASSERT_MESSAGE("Wrong active labelset returned",
mitk::Equal(*newlayer, *m_LabelSetImage->GetActiveLabelSet(), 0.00001, true));
m_LabelSetImage->RemoveLayer();
CPPUNIT_ASSERT_MESSAGE("Wrong number of layers, after a layer was removed",
m_LabelSetImage->GetNumberOfLayers() == 2);
CPPUNIT_ASSERT_MESSAGE("Check for existing layer failed", m_LabelSetImage->ExistLabelSet(2) == false);
CPPUNIT_ASSERT_MESSAGE("Check for existing layer failed", m_LabelSetImage->ExistLabelSet(1) == true);
CPPUNIT_ASSERT_MESSAGE("Check for existing layer failed", m_LabelSetImage->ExistLabelSet(0) == true);
m_LabelSetImage->RemoveLayer();
CPPUNIT_ASSERT_MESSAGE("Wrong number of layers, after a layer was removed",
m_LabelSetImage->GetNumberOfLayers() == 1);
CPPUNIT_ASSERT_MESSAGE("Check for existing layer failed", m_LabelSetImage->ExistLabelSet(1) == false);
CPPUNIT_ASSERT_MESSAGE("Check for existing layer failed", m_LabelSetImage->ExistLabelSet(0) == true);
CPPUNIT_ASSERT_MESSAGE("Wrong active layer",
mitk::Equal(*activeLayer, *m_LabelSetImage->GetActiveLabelSet(), 0.00001, true));
m_LabelSetImage->RemoveLayer();
CPPUNIT_ASSERT_MESSAGE("Wrong number of layers, after a layer was removed",
m_LabelSetImage->GetNumberOfLayers() == 0);
CPPUNIT_ASSERT_MESSAGE("Check for existing layer failed", m_LabelSetImage->ExistLabelSet(0) == false);
CPPUNIT_ASSERT_MESSAGE("Active layers is not nullptr although all layer have been removed",
m_LabelSetImage->GetActiveLabelSet() == 0);
}
示例3: TestExistsLabelSet
void TestExistsLabelSet()
{
// Cache active layer
mitk::LabelSet::ConstPointer activeLayer = m_LabelSetImage->GetActiveLabelSet();
// Add new layer
mitk::LabelSet::Pointer newlayer = mitk::LabelSet::New();
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(label1);
newlayer->AddLabel(label2);
newlayer->SetActiveLabel(200);
m_LabelSetImage->AddLayer(newlayer);
CPPUNIT_ASSERT_MESSAGE("Check for existing layer failed", m_LabelSetImage->ExistLabelSet(0) == true);
CPPUNIT_ASSERT_MESSAGE("Check for existing layer failed", m_LabelSetImage->ExistLabelSet(1) == true);
CPPUNIT_ASSERT_MESSAGE("Check for existing layer failed", m_LabelSetImage->ExistLabelSet(20) == false);
}
示例4: TestGetLabel
void TestGetLabel()
{
mitk::Label::Pointer label1 = mitk::Label::New();
label1->SetName("Label1");
mitk::Label::PixelType value1 = 1;
label1->SetValue(value1);
mitk::Label::Pointer label2 = mitk::Label::New();
label2->SetName("Label2");
mitk::Label::PixelType value2 = 200;
label2->SetValue(value2);
m_LabelSetImage->GetActiveLabelSet()->AddLabel(label1);
m_LabelSetImage->AddLayer();
m_LabelSetImage->GetLabelSet(1)->AddLabel(label2);
CPPUNIT_ASSERT_MESSAGE("Wrong label retrieved for active layer",
mitk::Equal(*m_LabelSetImage->GetLabel(1), *label1, 0.0001, true));
CPPUNIT_ASSERT_MESSAGE("Wrong label retrieved for layer 1",
mitk::Equal(*m_LabelSetImage->GetLabel(200, 1), *label2, 0.0001, true));
// Try to get a non existing label
mitk::Label *label3 = m_LabelSetImage->GetLabel(1000);
CPPUNIT_ASSERT_MESSAGE("Non existing label should be nullptr", label3 == nullptr);
// Try to get a label from a non existing layer
label3 = m_LabelSetImage->GetLabel(200, 1000);
CPPUNIT_ASSERT_MESSAGE("Label from non existing layer should be nullptr", label3 == nullptr);
}
示例5: TestGetActiveLabel
void TestGetActiveLabel()
{
mitk::Label::Pointer label1 = mitk::Label::New();
label1->SetName("Label1");
mitk::Label::PixelType value1 = 1;
label1->SetValue(value1);
mitk::Label::Pointer label2 = mitk::Label::New();
label2->SetName("Label2");
mitk::Label::PixelType value2 = 200;
label2->SetValue(value2);
m_LabelSetImage->GetActiveLabelSet()->AddLabel(label1);
m_LabelSetImage->GetActiveLabelSet()->AddLabel(label2);
m_LabelSetImage->GetActiveLabelSet()->SetActiveLabel(1);
CPPUNIT_ASSERT_MESSAGE("Layer was not added correctly to image - active label is wrong",m_LabelSetImage->GetActiveLabel()->GetValue() == value1);
m_LabelSetImage->GetActiveLabelSet()->SetActiveLabel(value2);
CPPUNIT_ASSERT_MESSAGE("Layer was not added correctly to image - active label is wrong",m_LabelSetImage->GetActiveLabel()->GetValue() == value2);
}
示例6: TestGetTotalNumberOfLabels
void TestGetTotalNumberOfLabels()
{
mitk::Label::Pointer label1 = mitk::Label::New();
label1->SetName("Label1");
mitk::Label::PixelType value1 = 1;
label1->SetValue(value1);
mitk::Label::Pointer label2 = mitk::Label::New();
label2->SetName("Label2");
mitk::Label::PixelType value2 = 200;
label2->SetValue(value2);
m_LabelSetImage->GetActiveLabelSet()->AddLabel(label1);
m_LabelSetImage->AddLayer();
m_LabelSetImage->GetLabelSet(1)->AddLabel(label2);
CPPUNIT_ASSERT_MESSAGE("Wrong total number of labels", m_LabelSetImage->GetTotalNumberOfLabels() == 4); // added 2 labels + 2 exterior default labels
}
示例7: TestGetActiveLabelSet
void TestGetActiveLabelSet()
{
mitk::LabelSet::Pointer newlayer = mitk::LabelSet::New();
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(label1);
newlayer->AddLabel(label2);
newlayer->SetActiveLabel(200);
unsigned int layerID = m_LabelSetImage->AddLayer(newlayer);
mitk::LabelSet::Pointer activeLayer = m_LabelSetImage->GetActiveLabelSet();
CPPUNIT_ASSERT_MESSAGE("Wrong layer ID was returned", layerID == 1);
CPPUNIT_ASSERT_MESSAGE("Wrong active labelset returned", mitk::Equal(*newlayer, *activeLayer, 0.00001, true));
}
示例8: 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);
}