13 #ifndef mitkLabelSetImage_h
14 #define mitkLabelSetImage_h
16 #include <shared_mutex>
273 std::vector<std::string> GetLabelClassNames()
const;
279 std::vector<std::string> GetLabelClassNamesByGroup(
GroupIndexType index)
const;
287 itkGetConstMacro(UnlabeledLabelLock,
bool);
288 itkSetMacro(UnlabeledLabelLock,
bool);
289 itkBooleanMacro(UnlabeledLabelLock);
293 void SetAllLabelsVisible(
bool visible);
298 void SetAllLabelsVisibleByGroup(
GroupIndexType group,
bool visible);
304 void SetAllLabelsVisibleByName(
GroupIndexType group,
const std::string_view name,
bool visible);
312 void SetAllLabelsLocked(
bool locked);
317 void SetAllLabelsLockedByGroup(
GroupIndexType group,
bool locked);
323 void SetAllLabelsLockedByName(
GroupIndexType group,
const std::string_view name,
bool locked);
356 void SetGroupName(
GroupIndexType groupID,
const std::string& name);
363 void UpdateLookupTable(
PixelType pixelValue);
367 void OnLabelModified(
const Object* sender,
const itk::EventObject&);
373 void RegisterLabel(
Label* label);
375 void ReleaseLabel(
Label* label);
388 using LabelMapType = std::map<LabelValueType, Label::Pointer>;
390 LabelMapType m_LabelMap;
392 using GroupNameVectorType = std::vector<std::string>;
394 GroupNameVectorType m_Groups;
398 using GroupToLabelMapType = std::vector<LabelValueVectorType>;
400 GroupToLabelMapType m_GroupToLabelMap;
401 using LabelToGroupMapType = std::map<LabelValueType, GroupIndexType>;
403 LabelToGroupMapType m_LabelToGroupMap;
405 using LabelEventGuardMapType = std::map<LabelValueType, ITKEventObserverGuard>;
406 LabelEventGuardMapType m_LabelModEventGuardMap;
411 bool m_UnlabeledLabelLock;
414 std::shared_mutex m_LabelNGroupMapsMutex;
433 void UpdateCenterOfMass(
PixelType pixelValue);
441 void Initialize(
const mitk::Image *image)
override;
461 void MergeLabels(
PixelType pixelValue,
const std::vector<PixelType>& vectorOfSourcePixelValues);
468 unsigned int GetActiveLayer()
const;
470 Label* GetActiveLabel();
472 const Label* GetActiveLabel()
const;
479 unsigned int GetNumberOfLabels(
unsigned int layer)
const;
485 unsigned int GetTotalNumberOfLabels()
const;
495 void MaskStamp(
mitk::Image *mask,
bool forceOverwrite);
497 void SetActiveLayer(
unsigned int layer);
500 unsigned int GetNumberOfLayers()
const;
524 LabelSetImage(
const LabelSetImage &other);
525 ~LabelSetImage()
override;
527 template <
typename TPixel,
unsigned int VImageDimension>
528 void LayerContainerToImageProcessing(itk::Image<TPixel, VImageDimension> *source,
unsigned int layer);
530 template <
typename TPixel,
unsigned int VImageDimension>
531 void ImageToLayerContainerProcessing(
const itk::Image<TPixel, VImageDimension> *source,
unsigned int layer)
const;
533 template <
typename ImageType>
534 void CalculateCenterOfMassProcessing(ImageType *input, LabelValueType index);
536 template <
typename ImageType>
537 void EraseLabelProcessing(ImageType *input, PixelType index);
539 template <
typename ImageType>
540 void MergeLabelProcessing(ImageType *input, PixelType pixelValue, PixelType index);
542 template <
typename ImageType>
543 void MaskStampProcessing(ImageType *input,
mitk::Image *mask,
bool forceOverwrite);
545 template <
typename LabelSetImageType,
typename ImageType>
546 void InitializeByLabeledImageProcessing(LabelSetImageType *input, ImageType *other);
550 LabelValueVectorType GetUsedLabelValues()
const;
603 namespace MultiLabelSegmentation
692 bool destinationBackgroundLocked =
false,
704 bool destinationBackgroundLocked =
false,