Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkChangeLabelImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkChangeLabelImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/11/22 18:57:54 $
00007   Version:   $Revision: 1.2 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
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&); //purposely not implemented
00148   void operator=(const Self&); //purposely not implemented
00149 };
00150 
00151 } // end namespace itk
00152 
00153 #ifndef ITK_MANUAL_INSTANTIATION
00154 #include "itkChangeLabelImageFilter.txx"
00155 #endif
00156 
00157 #endif

Generated at Wed May 24 22:55:54 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000