ITK  4.6.0
Insight Segmentation and Registration Toolkit
itkChangeLabelImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 __itkChangeLabelImageFilter_h
19 #define __itkChangeLabelImageFilter_h
20 
22 #include "itkConceptChecking.h"
24 
25 #include <map>
26 
27 namespace itk
28 {
50 namespace Functor
51 {
52 template< typename TInput, typename TOutput >
54 {
55 public:
58 
59  typedef std::map< TInput, TOutput > ChangeMapType;
60 
61  bool operator!=(const ChangeLabel & other) const
62  {
63  if ( m_ChangeMap != other.m_ChangeMap )
64  {
65  return true;
66  }
67  return false;
68  }
69 
70  bool operator==(const ChangeLabel & other) const
71  {
72  return !( *this != other );
73  }
74 
75  TOutput GetChange(const TInput & original)
76  {
77  return m_ChangeMap[original];
78  }
79 
80  void SetChange(const TInput & original, const TOutput & result)
81  {
82  m_ChangeMap[original] = result;
83  }
84 
85  void SetChangeMap(const ChangeMapType & changeMap)
86  {
87  m_ChangeMap = changeMap;
88  }
89 
91  {
92  m_ChangeMap.clear();
93  }
94 
95  inline TOutput operator()(const TInput & A) const
96  {
97  const typename ChangeMapType::const_iterator it = m_ChangeMap.find(A);
98  if ( it != m_ChangeMap.end() )
99  {
100  return it->second;
101  }
102  return A;
103  }
104 
105 private:
107 };
108 }
109 
110 template< typename TInputImage, typename TOutputImage >
112  public
113  UnaryFunctorImageFilter< TInputImage, TOutputImage,
114  Functor::ChangeLabel<
115  typename TInputImage::PixelType,
116  typename TOutputImage::PixelType > >
117 {
118 public:
121  typedef UnaryFunctorImageFilter< TInputImage, TOutputImage,
123  typename TInputImage::PixelType,
124  typename TOutputImage::PixelType >
126 
129 
131  itkNewMacro(Self);
132 
135 
137  typedef typename TInputImage::PixelType InputPixelType;
138  typedef typename TOutputImage::PixelType OutputPixelType;
139 
141  typedef std::map< InputPixelType, OutputPixelType > ChangeMapType;
142 
144  void SetChange(const InputPixelType & original, const OutputPixelType & result);
145 
147  void SetChangeMap(const ChangeMapType & changeMap);
148 
150  void ClearChangeMap();
151 
152 #ifdef ITK_USE_CONCEPT_CHECKING
153  // Begin concept checking
154  itkConceptMacro( InputConvertibleToOutputCheck,
156  itkConceptMacro( PixelTypeComparable,
158  // End concept checking
159 #endif
160 
161 protected:
164  void PrintSelf(std::ostream & os, Indent indent) const;
165 
166 private:
167  ChangeLabelImageFilter(const Self &); //purposely not implemented
168  void operator=(const Self &); //purposely not implemented
169 };
170 } // end namespace itk
171 
172 #ifndef ITK_MANUAL_INSTANTIATION
173 #include "itkChangeLabelImageFilter.hxx"
174 #endif
175 
176 #endif
TOutputImage::PixelType OutputPixelType
std::map< TInput, TOutput > ChangeMapType
SmartPointer< const Self > ConstPointer
void operator=(const Self &)
void SetChangeMap(const ChangeMapType &changeMap)
Base class for all process objects that output image data.
void SetChange(const TInput &original, const TOutput &result)
void PrintSelf(std::ostream &os, Indent indent) const
TOutput operator()(const TInput &A) const
void SetChangeMap(const ChangeMapType &changeMap)
TOutput GetChange(const TInput &original)
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::ChangeLabel< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
Implements pixel-wise generic operation on one image.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
void SetChange(const InputPixelType &original, const OutputPixelType &result)
#define itkConceptMacro(name, concept)
bool operator==(const ChangeLabel &other) const
bool operator!=(const ChangeLabel &other) const
std::map< InputPixelType, OutputPixelType > ChangeMapType