Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
mitkLabelSet.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkLabelSet_h
14 #define mitkLabelSet_h
15 
16 #include "MitkMultilabelExports.h"
17 #include <mitkLookupTable.h>
18 #include <mitkMessage.h>
19 
20 #include <itkObject.h>
21 #include <itkObjectFactory.h>
22 #include <itkEventObject.h>
23 
24 #include <mitkLabel.h>
25 
26 namespace mitk
27 {
28  //
29  // Documentation
30  // @brief LabelSet containing the labels corresponding to a segmentation session.
31  // @ingroup Data
32  //
33 
34  class MITKMULTILABEL_EXPORT LabelSet : public itk::Object
35  {
36  public:
37  mitkClassMacroItkParent(LabelSet, itk::Object);
38  itkNewMacro(Self);
39 
41 
43  typedef std::map<LabelValueType, Label::Pointer> LabelContainerType;
44  typedef LabelContainerType::const_iterator LabelContainerConstIteratorType;
45  typedef LabelContainerType::iterator LabelContainerIteratorType;
46 
60 
74 
88 
93 
107 
110  LabelContainerConstIteratorType IteratorConstBegin() const;
111 
114  LabelContainerConstIteratorType IteratorConstEnd() const;
115 
118  LabelContainerIteratorType IteratorBegin();
119 
122  LabelContainerIteratorType IteratorEnd();
123 
127  void OnLabelModified(const Object*, const itk::EventObject&);
128 
131  void SetLayer(unsigned int);
132 
135  void SetActiveLabel(PixelType);
136 
139  void RemoveLabel(PixelType);
140 
143  bool ExistLabel(PixelType);
144 
153  mitk::Label* AddLabel(mitk::Label *label, bool addAsClone = true);
154 
157  mitk::Label* AddLabel(const std::string &name, const Color &color);
158 
161  void RenameLabel(PixelType, const std::string &, const Color &);
162 
165  unsigned int GetNumberOfLabels() const;
166 
169  void SetAllLabelsVisible(bool);
170 
173  void SetAllLabelsLocked(bool);
174 
177  void RemoveAllLabels();
178 
179  void SetNextActiveLabel();
180 
183  Label *GetActiveLabel() { return GetLabel(m_ActiveLabelValue); }
186  const Label *GetActiveLabel() const { return GetLabel(m_ActiveLabelValue); }
189  Label *GetLabel(PixelType pixelValue);
190 
193  const Label *GetLabel(PixelType pixelValue) const;
194 
195  itkGetMacro(Layer, int);
196 
197  itkGetConstMacro(Layer, int);
198 
199  itkGetModifiableObjectMacro(LookupTable, mitk::LookupTable);
200 
203  void SetLookupTable(LookupTable *lut);
204 
207  void UpdateLookupTable(PixelType pixelValue);
208 
209  using ReservedLabelValuesFunctor = std::function<std::vector<LabelValueType>()>;
211 
212  std::vector<LabelValueType> GetUsedLabelValues() const;
213 
214  protected:
215  LabelSet();
216  LabelSet(const LabelSet &);
217 
218  mitkCloneMacro(Self);
219 
220  ~LabelSet() override;
221 
222  void PrintSelf(std::ostream &os, itk::Indent indent) const override;
223 
225 
227 
229 
230  unsigned int m_Layer;
231  };
232 
248  MITKMULTILABEL_EXPORT bool Equal(const mitk::LabelSet &leftHandSide,
249  const mitk::LabelSet &rightHandSide,
250  ScalarType eps,
251  bool verbose);
252 
258  MITKMULTILABEL_EXPORT LabelSet::Pointer GenerateLabelSetWithMappedValues(const LabelSet* sourceLabelSet,
259  std::vector<std::pair<Label::PixelType, Label::PixelType> > labelMapping = { {1,1} });
260 
261 } // namespace mitk
262 
263 #endif
mitk::eps
const MITKCORE_EXPORT ScalarType eps
MITKMULTILABEL_EXPORT
#define MITKMULTILABEL_EXPORT
Definition: MitkMultilabelExports.h:15
mitk::LabelSet::AllLabelsModifiedEvent
Message AllLabelsModifiedEvent
AllLabelsModifiedEvent is emitted whenever a new label has been removed from the LabelSet.
Definition: mitkLabelSet.h:106
mitk::LabelSet::m_LookupTable
LookupTable::Pointer m_LookupTable
Definition: mitkLabelSet.h:226
mitkLabel.h
mitk::LabelSet::GetActiveLabel
const Label * GetActiveLabel() const
Definition: mitkLabelSet.h:186
mitk::LabelSet::AddLabelEvent
Message1< LabelValueType > AddLabelEvent
AddLabelEvent is emitted whenever a new label has been added to the LabelSet.
Definition: mitkLabelSet.h:59
mitk::LabelSet::ModifyLabelEvent
Message1< LabelValueType > ModifyLabelEvent
ModifyLabelEvent is emitted whenever a label has been modified from the LabelSet.
Definition: mitkLabelSet.h:87
mitk::Message1< LabelValueType >
mitk::LabelSet::PixelType
mitk::Label::PixelType PixelType
Definition: mitkLabelSet.h:38
mitk::LabelSet::LabelContainerType
std::map< LabelValueType, Label::Pointer > LabelContainerType
Definition: mitkLabelSet.h:43
mitk::LabelSet
Definition: mitkLabelSet.h:34
mitk::LabelSet::LabelContainerIteratorType
LabelContainerType::iterator LabelContainerIteratorType
Definition: mitkLabelSet.h:45
mitk::LabelSet::m_LabelContainer
LabelContainerType m_LabelContainer
Definition: mitkLabelSet.h:224
mitk::Color
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
Definition: mitkColorProperty.h:35
mitk::LabelSet::m_ActiveLabelValue
PixelType m_ActiveLabelValue
Definition: mitkLabelSet.h:228
mitk::Equal
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
itk::SmartPointer< Self >
mitk::LookupTable
The LookupTable class mitk wrapper for a vtkLookupTable.
Definition: mitkLookupTable.h:42
mitk::Label::PixelType
unsigned short PixelType
Definition: mitkLabel.h:33
mitk::LabelSet::GetActiveLabel
Label * GetActiveLabel()
Definition: mitkLabelSet.h:183
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk::LabelSet::LabelValueType
mitk::Label::PixelType LabelValueType
Definition: mitkLabelSet.h:42
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitkLookupTable.h
mitk::Label
A data structure describing a label.
Definition: mitkLabel.h:28
mitk::LabelSet::m_Layer
unsigned int m_Layer
Definition: mitkLabelSet.h:230
mitkMessage.h
mitk::PixelType
Class for defining the data type of pixels.
Definition: mitkPixelType.h:51
mitk::LabelSet::RemoveLabelEvent
Message1< LabelValueType > RemoveLabelEvent
RemoveLabelEvent is emitted whenever a new label has been removed from the LabelSet.
Definition: mitkLabelSet.h:73
mitk::LabelSet::ReservedLabelValuesFunctor
std::function< std::vector< LabelValueType >()> ReservedLabelValuesFunctor
Definition: mitkLabelSet.h:209
mitk::LabelSet::LabelContainerConstIteratorType
LabelContainerType::const_iterator LabelContainerConstIteratorType
Definition: mitkLabelSet.h:44
mitkCloneMacro
#define mitkCloneMacro(classname)
Definition: mitkCommon.h:154
mitk::GenerateLabelSetWithMappedValues
MITKMULTILABEL_EXPORT LabelSet::Pointer GenerateLabelSetWithMappedValues(const LabelSet *sourceLabelSet, std::vector< std::pair< Label::PixelType, Label::PixelType > > labelMapping={ {1, 1} })
mitk::LabelSet::ActiveLabelEvent
Message1< PixelType > ActiveLabelEvent
ActiveLabelEvent is emitted whenever a label has been set as active in the LabelSet.
Definition: mitkLabelSet.h:92
mitk::LabelSet::m_ReservedLabelValuesFunctor
ReservedLabelValuesFunctor m_ReservedLabelValuesFunctor
Definition: mitkLabelSet.h:210
mitk::Message
Event/message/notification class.
Definition: mitkMessage.h:452
mitk::ScalarType
double ScalarType
Definition: mitkNumericConstants.h:20
MitkMultilabelExports.h