ITK  5.4.0
Insight Toolkit
itkMergeLabelMapFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkMergeLabelMapFilter_h
19 #define itkMergeLabelMapFilter_h
20 
22 #include "ITKLabelMapExport.h"
23 
24 namespace itk
25 {
26 // See https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2059?view=vs-2019
27 #ifdef STRICT
28 # define TEMPINPLACELABELMAPSTRICT STRICT
29 # undef STRICT
30 #endif
31 
36 {
37 public:
41  enum class ChoiceMethod : uint8_t
42  {
43  KEEP = 0,
44  AGGREGATE = 1,
45  PACK = 2,
46  STRICT = 3
47  };
48 };
49 // Define how to print enumeration
50 extern ITKLabelMap_EXPORT std::ostream &
51  operator<<(std::ostream & out, const MergeLabelMapFilterEnums::ChoiceMethod value);
52 
54 #if !defined(ITK_LEGACY_REMOVE)
55 
57 // We need to expose the enum values at the class level
58 // for backwards compatibility
59 static constexpr ChoiceMethodEnum KEEP = ChoiceMethodEnum::KEEP;
60 static constexpr ChoiceMethodEnum AGGREGATE = ChoiceMethodEnum::AGGREGATE;
61 static constexpr ChoiceMethodEnum PACK = ChoiceMethodEnum::PACK;
62 static constexpr ChoiceMethodEnum STRICT = ChoiceMethodEnum::STRICT;
63 #endif
64 
65 #ifdef TEMPINPLACELABELMAPSTRICT
66 # define STRICT TEMPINPLACELABELMAPSTRICT
67 # undef TEMPINPLACELABELMAPSTRICT
68 #endif
69 
100 template <typename TImage>
101 class ITK_TEMPLATE_EXPORT MergeLabelMapFilter : public InPlaceLabelMapFilter<TImage>
102 {
103 public:
104  ITK_DISALLOW_COPY_AND_MOVE(MergeLabelMapFilter);
105 
111 
113  using ImageType = TImage;
116  using PixelType = typename ImageType::PixelType;
117  using IndexType = typename ImageType::IndexType;
118  using LabelObjectType = typename ImageType::LabelObjectType;
120 
122  static constexpr unsigned int ImageDimension = TImage::ImageDimension;
123 
125  itkNewMacro(Self);
126 
128  itkOverrideGetNameOfClassMacro(MergeLabelMapFilter);
129 
130 #if !defined(ITK_LEGACY_REMOVE)
131 
132  using MethodChoice = ChoiceMethodEnum;
133 #endif
134 
135 #ifdef ITK_USE_CONCEPT_CHECKING
136  // Begin concept checking
137 /* itkConceptMacro(InputEqualityComparableCheck,
138  (Concept::EqualityComparable<InputImagePixelType>));
139  itkConceptMacro(IntConvertibleToInputCheck,
140  (Concept::Convertible<int, InputImagePixelType>));
141  itkConceptMacro(InputOStreamWritableCheck,
142  (Concept::OStreamWritable<InputImagePixelType>));*/
143 // End concept checking
144 #endif
145 
146 #ifdef STRICT
147 # undef STRICT
148 #endif
149 
151  itkSetMacro(Method, ChoiceMethodEnum);
152  itkGetConstReferenceMacro(Method, ChoiceMethodEnum);
155 protected:
157  ~MergeLabelMapFilter() override = default;
158 
159  void
160  GenerateData() override;
161 
162  void
163  PrintSelf(std::ostream & os, Indent indent) const override;
164 
165  ChoiceMethodEnum m_Method{};
166 
167 private:
168  void
169  MergeWithKeep();
170 
171  void
172  MergeWithAggregate();
173 
174  void
175  MergeWithPack();
176 
177  void
178  MergeWithStrict();
179 }; // end of class
180 } // end namespace itk
181 
182 #ifndef ITK_MANUAL_INSTANTIATION
183 # include "itkMergeLabelMapFilter.hxx"
184 #endif
185 
186 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::MergeLabelMapFilterEnums::ChoiceMethod::STRICT
itk::MergeLabelMapFilterEnums::ChoiceMethod::AGGREGATE
itk::operator<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:216
ChoiceMethod
itk::InPlaceLabelMapFilter
Base class for filters that takes an image as input and overwrites that image as the output.
Definition: itkInPlaceLabelMapFilter.h:83
itk::MergeLabelMapFilter::PixelType
typename ImageType::PixelType PixelType
Definition: itkMergeLabelMapFilter.h:116
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::MergeLabelMapFilterEnums::ChoiceMethod::KEEP
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::MergeLabelMapFilter::ImageType
TImage ImageType
Definition: itkMergeLabelMapFilter.h:113
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::MergeLabelMapFilterEnums::ChoiceMethod
ChoiceMethod
Definition: itkMergeLabelMapFilter.h:41
itkInPlaceLabelMapFilter.h
itk::MergeLabelMapFilterEnums
Contains all enum classes used by MergeLabelMapFilter class.
Definition: itkMergeLabelMapFilter.h:35
itk::MergeLabelMapFilterEnums::ChoiceMethod::PACK
itk::MergeLabelMapFilter::IndexType
typename ImageType::IndexType IndexType
Definition: itkMergeLabelMapFilter.h:117
itk::MergeLabelMapFilter::ImagePointer
typename ImageType::Pointer ImagePointer
Definition: itkMergeLabelMapFilter.h:114
itk::MergeLabelMapFilter::ImageConstPointer
typename ImageType::ConstPointer ImageConstPointer
Definition: itkMergeLabelMapFilter.h:115
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::MergeLabelMapFilter::LabelObjectType
typename ImageType::LabelObjectType LabelObjectType
Definition: itkMergeLabelMapFilter.h:118
itk::MergeLabelMapFilter::LabelObjectPointer
typename LabelObjectType::Pointer LabelObjectPointer
Definition: itkMergeLabelMapFilter.h:119
itk::ChoiceMethodEnum
MergeLabelMapFilterEnums::ChoiceMethod ChoiceMethodEnum
Definition: itkMergeLabelMapFilter.h:53
itk::MergeLabelMapFilter
Merges several Label Maps.
Definition: itkMergeLabelMapFilter.h:101