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

Method ReplaceLabels

Modules/Multilabel/src/mitkLabelSetImage.cpp:567–595  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

565}
566
567void mitk::MultiLabelSegmentation::ReplaceLabels(const ConstLabelVectorType& newLabels)
568{
569 for (auto& label : newLabels)
570 {
571 if (!this->ExistLabel(label->GetValue()))
572 {
573 mitkThrow() << "Trying to replace unknown label. Invalid label value: " << label->GetValue();
574 }
575 }
576
577 {
578 std::lock_guard<std::shared_mutex> guard(m_LabelNGroupMapsMutex);
579
580 for (auto label : newLabels)
581 {
582 auto clonedLabel = label->Clone();
583
584 this->ReleaseLabel(m_LabelMap[label->GetValue()]);
585 m_LabelMap[label->GetValue()] = clonedLabel;
586 this->RegisterLabel(clonedLabel);
587 clonedLabel->Modified(); //indicate a modification for the label as the
588 //replacement has overwritten old values
589 //e.g. relevant for the QmitkMultiLabelTreeModel
590 }
591 }
592
593 this->InvokeEvent(LabelsChangedEvent(ExtractLabelValuesFromLabelVector(newLabels)));
594 this->Modified();
595}
596
597void mitk::MultiLabelSegmentation::ReplaceLabels(const LabelVectorType& newLabels)
598{

Callers 1

Calls 6

ExistLabelMethod · 0.95
ReleaseLabelMethod · 0.95
RegisterLabelMethod · 0.95
GetValueMethod · 0.45
CloneMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected