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: 2009-03-30 11:32:14 $
00007   Version:   $Revision: 1.7 $
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 ) const
00094     {
00095     const typename ChangeMapType::const_iterator it = m_ChangeMap.find(A);
00096     if ( it != m_ChangeMap.end() )
00097       {
00098       return it->second;
00099       }
00100     return A;
00101     }
00102 
00103 private:
00104   ChangeMapType m_ChangeMap;
00105 
00106 };
00107 }
00108 
00109 template <class TInputImage, class TOutputImage>
00110 class ITK_EXPORT ChangeLabelImageFilter :
00111     public
00112 UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00113                         Functor::ChangeLabel< 
00114   typename TInputImage::PixelType, 
00115   typename TOutputImage::PixelType> >
00116 {
00117 public:
00119   typedef ChangeLabelImageFilter   Self;
00120   typedef UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00121     Functor::ChangeLabel< 
00122     typename TInputImage::PixelType, 
00123     typename TOutputImage::PixelType>   
00124   >                                Superclass;
00125   typedef SmartPointer<Self>       Pointer;
00126   typedef SmartPointer<const Self> ConstPointer;
00127 
00129   itkNewMacro(Self);
00130 
00132   itkTypeMacro(ChangeLabelImageFilter, UnaryFunctorImageFilter);
00133 
00135   typedef typename TInputImage::PixelType  InputPixelType;
00136   typedef typename TOutputImage::PixelType OutputPixelType;
00137 
00139   typedef std::map<InputPixelType, OutputPixelType> ChangeMapType;
00140 
00142   void SetChange( const InputPixelType & original, const OutputPixelType & result );
00143 
00145   void SetChangeMap( const ChangeMapType & changeMap );
00146 
00148   void ClearChangeMap( );
00149 
00150 #ifdef ITK_USE_CONCEPT_CHECKING
00151 
00152   itkConceptMacro(InputConvertibleToOutputCheck,
00153                   (Concept::Convertible<InputPixelType, OutputPixelType>));
00154   itkConceptMacro(PixelTypeComparable,
00155                   (Concept::Comparable<InputPixelType>));
00156 
00158 #endif
00159 
00160 protected:
00161   ChangeLabelImageFilter();
00162   virtual ~ChangeLabelImageFilter() {}
00163   void PrintSelf(std::ostream& os, Indent indent) const;
00164 
00165 private:
00166   ChangeLabelImageFilter(const Self&); //purposely not implemented
00167   void operator=(const Self&); //purposely not implemented
00168 };
00169 
00170 } // end namespace itk
00171 
00172 #ifndef ITK_MANUAL_INSTANTIATION
00173 #include "itkChangeLabelImageFilter.txx"
00174 #endif
00175 
00176 #endif
00177 

Generated at Fri Apr 16 18:03:45 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000