00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkChangeLabelImageFilter_h
00018 #define __itkChangeLabelImageFilter_h
00019
00020 #include "itkUnaryFunctorImageFilter.h"
00021 #include "itkConceptChecking.h"
00022 #include "itkSimpleDataObjectDecorator.h"
00023
00024 namespace itk
00025 {
00026
00048 #include <map>
00049
00050 namespace Functor {
00051
00052 template< class TInput, class TOutput>
00053 class ChangeLabel
00054 {
00055 public:
00056 ChangeLabel() {};
00057 ~ChangeLabel() {};
00058
00059 typedef std::map<TInput, TOutput> ChangeMapType;
00060
00061 TInput GetChange( const TInput & original )
00062 {
00063 return m_ChangeMap[original];
00064 }
00065
00066 void SetChange( const TInput & original, const TOutput & result )
00067 {
00068 m_ChangeMap[original] = result;
00069 }
00070
00071 void SetChangeMap( ChangeMapType & changeMap )
00072 {
00073 m_ChangeMap = changeMap;
00074 }
00075
00076 void ClearChangeMap( )
00077 {
00078 m_ChangeMap.clear();
00079 }
00080
00081 inline TOutput operator()( const TInput & A )
00082 {
00083 if ( m_ChangeMap.find(A) != m_ChangeMap.end() )
00084 {
00085 return m_ChangeMap[A];
00086 }
00087 return A;
00088 }
00089
00090 private:
00091
00092 ChangeMapType m_ChangeMap;
00093
00094 };
00095 }
00096
00097 template <class TInputImage, class TOutputImage>
00098 class ITK_EXPORT ChangeLabelImageFilter :
00099 public
00100 UnaryFunctorImageFilter<TInputImage,TOutputImage,
00101 Functor::ChangeLabel<
00102 typename TInputImage::PixelType,
00103 typename TOutputImage::PixelType> >
00104 {
00105 public:
00107 typedef ChangeLabelImageFilter Self;
00108 typedef UnaryFunctorImageFilter<TInputImage,TOutputImage,
00109 Functor::ChangeLabel<
00110 typename TInputImage::PixelType,
00111 typename TOutputImage::PixelType>
00112 > Superclass;
00113 typedef SmartPointer<Self> Pointer;
00114 typedef SmartPointer<const Self> ConstPointer;
00115
00117 itkNewMacro(Self);
00118
00120 itkTypeMacro(ChangeLabelImageFilter, UnaryFunctorImageFilter);
00121
00123 typedef typename TInputImage::PixelType InputPixelType;
00124 typedef typename TOutputImage::PixelType OutputPixelType;
00125
00127 itkConceptMacro(PixelTypeComparable, (Concept::Comparable<InputPixelType>));
00128
00130 typedef std::map<InputPixelType, OutputPixelType> ChangeMapType;
00131
00133 void SetChange( const InputPixelType & original, const OutputPixelType & result );
00134
00136 void SetChangeMap( const ChangeMapType & changeMap );
00137
00139 void ClearChangeMap( );
00140
00141 protected:
00142 ChangeLabelImageFilter();
00143 virtual ~ChangeLabelImageFilter() {}
00144 void PrintSelf(std::ostream& os, Indent indent) const;
00145
00146 private:
00147 ChangeLabelImageFilter(const Self&);
00148 void operator=(const Self&);
00149 };
00150
00151 }
00152
00153 #ifndef ITK_MANUAL_INSTANTIATION
00154 #include "itkChangeLabelImageFilter.txx"
00155 #endif
00156
00157 #endif