本文整理汇总了C++中mitk::labelsetimage::Pointer::GetLabelSet方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::GetLabelSet方法的具体用法?C++ Pointer::GetLabelSet怎么用?C++ Pointer::GetLabelSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mitk::labelsetimage::Pointer
的用法示例。
在下文中一共展示了Pointer::GetLabelSet方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestGetLabelSet
void TestGetLabelSet()
{
// Test get non existing lset
mitk::LabelSet::ConstPointer lset = m_LabelSetImage->GetLabelSet(10000);
CPPUNIT_ASSERT_MESSAGE("Non existing labelset is not nullptr", lset.IsNull());
lset = m_LabelSetImage->GetLabelSet(0);
CPPUNIT_ASSERT_MESSAGE("Existing labelset is nullptr", lset.IsNotNull());
}
示例2: 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);
}
示例3: LoadLabelSetImagePreset
void LabelSetImageIO::LoadLabelSetImagePreset(const std::string & presetFilename, mitk::LabelSetImage::Pointer& inputImage )
{
std::unique_ptr<TiXmlDocument> presetXmlDoc(new TiXmlDocument());
bool ok = presetXmlDoc->LoadFile(presetFilename);
if ( !ok )
return;
TiXmlElement * presetElem = presetXmlDoc->FirstChildElement("LabelSetImagePreset");
if(!presetElem)
{
MITK_INFO << "No valid preset XML";
return;
}
int numberOfLayers;
presetElem->QueryIntAttribute("layers", &numberOfLayers);
for(int i = 0 ; i < numberOfLayers; i++)
{
TiXmlElement * layerElem = presetElem->FirstChildElement("Layer");
int numberOfLabels;
layerElem->QueryIntAttribute("labels", &numberOfLabels);
if(inputImage->GetLabelSet(i) == NULL) inputImage->AddLayer();
TiXmlElement * labelElement = layerElem->FirstChildElement("Label");
if(labelElement == NULL) break;
for(int j = 0 ; j < numberOfLabels; j++)
{
mitk::Label::Pointer label = mitk::LabelSetImageIO::LoadLabelFromTiXmlDocument(labelElement);
inputImage->GetLabelSet()->AddLabel(label);
labelElement = labelElement->NextSiblingElement("Label");
if(labelElement == NULL) break;
}
}
}
示例4: TestExistsLabel
void TestExistsLabel()
{
mitk::Label::Pointer label = mitk::Label::New();
label->SetName("Label2");
mitk::Label::PixelType value = 200;
label->SetValue(value);
m_LabelSetImage->AddLayer();
m_LabelSetImage->GetLabelSet(1)->AddLabel(label);
m_LabelSetImage->SetActiveLayer(0);
CPPUNIT_ASSERT_MESSAGE("Existing label was not found", m_LabelSetImage->ExistLabel(value) == true);
CPPUNIT_ASSERT_MESSAGE("Non existing label was found", m_LabelSetImage->ExistLabel(10000) == false);
}
示例5: 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
}