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 inline TOutput operator()( const TInput & A )
00077 {
00078 if ( m_ChangeMap.find(A) != m_ChangeMap.end() )
00079 {
00080 return m_ChangeMap[A];
00081 }
00082 return A;
00083 }
00084
00085 private:
00086
00087 ChangeMapType m_ChangeMap;
00088
00089 };
00090 }
00091
00092 template <class TInputImage, class TOutputImage>
00093 class ITK_EXPORT ChangeLabelImageFilter :
00094 public
00095 UnaryFunctorImageFilter<TInputImage,TOutputImage,
00096 Functor::ChangeLabel<
00097 typename TInputImage::PixelType,
00098 typename TOutputImage::PixelType> >
00099 {
00100 public:
00102 typedef ChangeLabelImageFilter Self;
00103 typedef UnaryFunctorImageFilter<TInputImage,TOutputImage,
00104 Functor::ChangeLabel<
00105 typename TInputImage::PixelType,
00106 typename TOutputImage::PixelType>
00107 > Superclass;
00108 typedef SmartPointer<Self> Pointer;
00109 typedef SmartPointer<const Self> ConstPointer;
00110
00112 itkNewMacro(Self);
00113
00115 itkTypeMacro(ChangeLabelImageFilter, UnaryFunctorImageFilter);
00116
00118 typedef typename TInputImage::PixelType InputPixelType;
00119 typedef typename TOutputImage::PixelType OutputPixelType;
00120
00122 itkConceptMacro(PixelTypeComparable, (Concept::Comparable<InputPixelType>));
00123
00125 typedef std::map<InputPixelType, OutputPixelType> ChangeMapType;
00126
00128 void SetChange( const InputPixelType & original, const OutputPixelType & result );
00129
00131 void SetChangeMap( const ChangeMapType & changeMap );
00132
00133 protected:
00134 ChangeLabelImageFilter();
00135 virtual ~ChangeLabelImageFilter() {}
00136 void PrintSelf(std::ostream& os, Indent indent) const;
00137
00138 private:
00139 ChangeLabelImageFilter(const Self&);
00140 void operator=(const Self&);
00141 };
00142
00143 }
00144
00145 #ifndef ITK_MANUAL_INSTANTIATION
00146 #include "itkChangeLabelImageFilter.txx"
00147 #endif
00148
00149 #endif