ITK  5.1.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  * http://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 
101 template <typename TImage>
102 class ITK_TEMPLATE_EXPORT MergeLabelMapFilter : public InPlaceLabelMapFilter<TImage>
103 {
104 public:
105  ITK_DISALLOW_COPY_AND_ASSIGN(MergeLabelMapFilter);
106 
112 
114  using ImageType = TImage;
115  using ImagePointer = typename ImageType::Pointer;
116  using ImageConstPointer = typename ImageType::ConstPointer;
117  using PixelType = typename ImageType::PixelType;
118  using IndexType = typename ImageType::IndexType;
119  using LabelObjectType = typename ImageType::LabelObjectType;
120  using LabelObjectPointer = typename LabelObjectType::Pointer;
121 
123  static constexpr unsigned int ImageDimension = TImage::ImageDimension;
124 
126  itkNewMacro(Self);
127 
130 
131 #if !defined(ITK_LEGACY_REMOVE)
132 
133  using MethodChoice = ChoiceMethodEnum;
134 #endif
135 
136 #ifdef ITK_USE_CONCEPT_CHECKING
137  // Begin concept checking
138 /* itkConceptMacro(InputEqualityComparableCheck,
139  (Concept::EqualityComparable<InputImagePixelType>));
140  itkConceptMacro(IntConvertibleToInputCheck,
141  (Concept::Convertible<int, InputImagePixelType>));
142  itkConceptMacro(InputOStreamWritableCheck,
143  (Concept::OStreamWritable<InputImagePixelType>));*/
144 // End concept checking
145 #endif
146 
147 #ifdef STRICT
148 # undef STRICT
149 #endif
150 
152  itkSetMacro(Method, ChoiceMethodEnum);
153  itkGetConstReferenceMacro(Method, ChoiceMethodEnum);
155 
156 protected:
158  ~MergeLabelMapFilter() override = default;
159 
160  void
161  GenerateData() override;
162 
163  void
164  PrintSelf(std::ostream & os, Indent indent) const override;
165 
167 
168 private:
169  void
170  MergeWithKeep();
171 
172  void
173  MergeWithAggregate();
174 
175  void
176  MergeWithPack();
177 
178  void
179  MergeWithStrict();
180 }; // end of class
181 } // end namespace itk
182 
183 #ifndef ITK_MANUAL_INSTANTIATION
184 # include "itkMergeLabelMapFilter.hxx"
185 #endif
186 
187 #endif
itk::uint8_t
::uint8_t uint8_t
Definition: itkIntTypes.h:29
itk::MergeLabelMapFilterEnums::ChoiceMethod::STRICT
itk::MergeLabelMapFilterEnums::ChoiceMethod::AGGREGATE
itk::MergeLabelMapFilter::m_Method
ChoiceMethodEnum m_Method
Definition: itkMergeLabelMapFilter.h:166
itk::operator<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:213
ChoiceMethod
itk::InPlaceLabelMapFilter
Base class for filters that takes an image as input and overwrites that image as the output.
Definition: itkInPlaceLabelMapFilter.h:84
itk::MergeLabelMapFilter::PixelType
typename ImageType::PixelType PixelType
Definition: itkMergeLabelMapFilter.h:117
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:114
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
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:118
itk::MergeLabelMapFilter::ImagePointer
typename ImageType::Pointer ImagePointer
Definition: itkMergeLabelMapFilter.h:115
itk::MergeLabelMapFilter::ImageConstPointer
typename ImageType::ConstPointer ImageConstPointer
Definition: itkMergeLabelMapFilter.h:116
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::MergeLabelMapFilter::LabelObjectType
typename ImageType::LabelObjectType LabelObjectType
Definition: itkMergeLabelMapFilter.h:119
itk::MergeLabelMapFilter::LabelObjectPointer
typename LabelObjectType::Pointer LabelObjectPointer
Definition: itkMergeLabelMapFilter.h:120
itk::ChoiceMethodEnum
MergeLabelMapFilterEnums::ChoiceMethod ChoiceMethodEnum
Definition: itkMergeLabelMapFilter.h:53
itk::MergeLabelMapFilter
Merges several Label Maps.
Definition: itkMergeLabelMapFilter.h:102