ITK  6.0.0
Insight Toolkit
itkChangeLabelImageFilter.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 itkChangeLabelImageFilter_h
19#define itkChangeLabelImageFilter_h
20
22#include "itkConceptChecking.h"
24
25#include <map>
26
27namespace itk
28{
51namespace Functor
52{
53template <typename TInput, typename TOutput>
54class ITK_TEMPLATE_EXPORT ChangeLabel
55{
56public:
57 using ChangeMapType = std::map<TInput, TOutput>;
58
59
60 bool
61 operator==(const ChangeLabel & other) const
62 {
63 return m_ChangeMap == other.m_ChangeMap;
64 }
65
67
68 TOutput
69 GetChange(const TInput & original)
70 {
71 return m_ChangeMap[original];
72 }
73
74 void
75 SetChange(const TInput & original, const TOutput & result)
76 {
77 m_ChangeMap[original] = result;
78 }
79
80 void
81 SetChangeMap(const ChangeMapType & changeMap)
82 {
83 m_ChangeMap = changeMap;
84 }
85
86 void
88 {
89 m_ChangeMap.clear();
90 }
91
92 inline TOutput
93 operator()(const TInput & A) const
94 {
95 const typename ChangeMapType::const_iterator it = m_ChangeMap.find(A);
96 if (it != m_ChangeMap.end())
97 {
98 return it->second;
99 }
100 return A;
101 }
102
103private:
105};
106} // namespace Functor
107
108template <typename TInputImage, typename TOutputImage>
109class ITK_TEMPLATE_EXPORT ChangeLabelImageFilter
111 TInputImage,
112 TOutputImage,
113 Functor::ChangeLabel<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
114{
115public:
116 ITK_DISALLOW_COPY_AND_MOVE(ChangeLabelImageFilter);
117
121 UnaryFunctorImageFilter<TInputImage,
122 TOutputImage,
124
127
129 itkNewMacro(Self);
130
132 itkOverrideGetNameOfClassMacro(ChangeLabelImageFilter);
133
135 using InputPixelType = typename TInputImage::PixelType;
136 using OutputPixelType = typename TOutputImage::PixelType;
137
139 using ChangeMapType = std::map<InputPixelType, OutputPixelType>;
140
142 void
143 SetChange(const InputPixelType & original, const OutputPixelType & result);
144
146 void
147 SetChangeMap(const ChangeMapType & changeMap);
148
150 void
152
153#ifdef ITK_USE_CONCEPT_CHECKING
154 // Begin concept checking
157 // End concept checking
158#endif
159
160protected:
162 ~ChangeLabelImageFilter() override = default;
163 void
164 PrintSelf(std::ostream & os, Indent indent) const override;
165};
166} // end namespace itk
167
168#ifndef ITK_MANUAL_INSTANTIATION
169# include "itkChangeLabelImageFilter.hxx"
170#endif
171
172#endif
typename TOutputImage::PixelType OutputPixelType
void SetChangeMap(const ChangeMapType &changeMap)
~ChangeLabelImageFilter() override=default
void PrintSelf(std::ostream &os, Indent indent) const override
void SetChange(const InputPixelType &original, const OutputPixelType &result)
typename TInputImage::PixelType InputPixelType
std::map< InputPixelType, OutputPixelType > ChangeMapType
void SetChange(const TInput &original, const TOutput &result)
TOutput operator()(const TInput &A) const
std::map< TInput, TOutput > ChangeMapType
void SetChangeMap(const ChangeMapType &changeMap)
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(ChangeLabel)
TOutput GetChange(const TInput &original)
bool operator==(const ChangeLabel &other) const
Base class for all process objects that output image data.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Implements pixel-wise generic operation on one image.
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....