MCPcopy Create free account
hub / github.com/MITK/MITK / ConvertLabelVectorToMap

Function ConvertLabelVectorToMap

Modules/Multilabel/src/mitkLabelSetImage.cpp:1774–1786  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1772 * @pre every label in the vector has a unique value.*/
1773using ConstLabelMapType = std::map<mitk::MultiLabelSegmentation::LabelValueType, mitk::Label::ConstPointer>;
1774ConstLabelMapType ConvertLabelVectorToMap(const mitk::ConstLabelVector& labelV)
1775{
1776 ConstLabelMapType result;
1777 for (auto label : labelV)
1778 {
1779 const auto value = label->GetValue();
1780 auto finding = result.find(value);
1781 if (finding != result.end()) mitkThrow() << "Operation failed. Cannot convert label vector into label map, because at least one label value is not unique. Violating label value: " << value;
1782 result.insert(std::make_pair(value, label));
1783 }
1784
1785 return result;
1786}
1787
1788
1789/** Functor class that implements the label transfer and is used in conjunction with the itk::BinaryFunctorImageFilter.

Calls 3

GetValueMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected