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: 2008/02/13 20:52:34 $
00007   Version:   $Revision: 1.6 $
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   bool operator!=( const ChangeLabel & other ) const
00062     {
00063     if (m_ChangeMap != other.m_ChangeMap)
00064       {
00065       return true;
00066       }
00067     return false;
00068     }
00069   bool operator==( const ChangeLabel & other ) const
00070     {
00071     return !(*this != other);
00072     }
00073   TOutput GetChange( const TInput & original )
00074     {  
00075     return m_ChangeMap[original]; 
00076     }
00077 
00078   void SetChange( const TInput & original, const TOutput & result )
00079     { 
00080     m_ChangeMap[original] = result; 
00081     }
00082   
00083   void SetChangeMap( const ChangeMapType & changeMap )
00084     { 
00085     m_ChangeMap = changeMap; 
00086     }
00087 
00088   void ClearChangeMap( )
00089     { 
00090     m_ChangeMap.clear(); 
00091     }
00092 
00093   inline TOutput operator()( const TInput & A )
00094     {
00095     if ( m_ChangeMap.find(A) != m_ChangeMap.end() )
00096       {
00097       return m_ChangeMap[A];
00098       }
00099     return A;
00100     }
00101 
00102 private:
00103   ChangeMapType m_ChangeMap;
00104 
00105 };
00106 }
00107 
00108 template <class TInputImage, class TOutputImage>
00109 class ITK_EXPORT ChangeLabelImageFilter :
00110     public
00111 UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00112                         Functor::ChangeLabel< 
00113   typename TInputImage::PixelType, 
00114   typename TOutputImage::PixelType> >
00115 {
00116 public:
00118   typedef ChangeLabelImageFilter   Self;
00119   typedef UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00120     Functor::ChangeLabel< 
00121     typename TInputImage::PixelType, 
00122     typename TOutputImage::PixelType>   
00123   >                                Superclass;
00124   typedef SmartPointer<Self>       Pointer;
00125   typedef SmartPointer<const Self> ConstPointer;
00126 
00128   itkNewMacro(Self);
00129 
00131   itkTypeMacro(ChangeLabelImageFilter, UnaryFunctorImageFilter);
00132 
00134   typedef typename TInputImage::PixelType  InputPixelType;
00135   typedef typename TOutputImage::PixelType OutputPixelType;
00136 
00138   typedef std::map<InputPixelType, OutputPixelType> ChangeMapType;
00139 
00141   void SetChange( const InputPixelType & original, const OutputPixelType & result );
00142 
00144   void SetChangeMap( const ChangeMapType & changeMap );
00145 
00147   void ClearChangeMap( );
00148 
00149 #ifdef ITK_USE_CONCEPT_CHECKING
00150 
00151   itkConceptMacro(InputConvertibleToOutputCheck,
00152                   (Concept::Convertible<InputPixelType, OutputPixelType>));
00153   itkConceptMacro(PixelTypeComparable,
00154                   (Concept::Comparable<InputPixelType>));
00155 
00157 #endif
00158 
00159 protected:
00160   ChangeLabelImageFilter();
00161   virtual ~ChangeLabelImageFilter() {}
00162   void PrintSelf(std::ostream& os, Indent indent) const;
00163 
00164 private:
00165   ChangeLabelImageFilter(const Self&); //purposely not implemented
00166   void operator=(const Self&); //purposely not implemented
00167 };
00168 
00169 } // end namespace itk
00170 
00171 #ifndef ITK_MANUAL_INSTANTIATION
00172 #include "itkChangeLabelImageFilter.txx"
00173 #endif
00174 
00175 #endif
00176 

Generated at Tue Jul 29 19:30:19 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000