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

itkMaskImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkMaskImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2006/03/16 13:35:01 $
00007   Version:   $Revision: 1.11 $
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 __itkMaskImageFilter_h
00018 #define __itkMaskImageFilter_h
00019 
00020 #include "itkBinaryFunctorImageFilter.h"
00021 #include "itkNumericTraits.h"
00022 
00023 
00024 namespace itk
00025 {
00026   
00053 namespace Functor {  
00054   
00055 template< class TInput, class TMask, class TOutput >
00056 class MaskInput
00057 {
00058 public:
00059   typedef typename NumericTraits< TInput >::AccumulateType AccumulatorType;
00060 
00061   MaskInput(): m_OutsideValue(NumericTraits< TOutput >::ZeroValue()) {};
00062   ~MaskInput() {};
00063   bool operator!=( const MaskInput & ) const
00064   {
00065     return false;
00066   }
00067   bool operator==( const MaskInput & other ) const
00068   {
00069     return !(*this != other);
00070   }
00071 
00072   inline TOutput operator()( const TInput & A, const TMask & B)
00073   {
00074     if (B != NumericTraits< TMask >::ZeroValue() ) 
00075       {
00076       return static_cast<TOutput>( A );
00077       }
00078     else
00079       {
00080       return m_OutsideValue;
00081       }
00082   }
00083 
00085   void SetOutsideValue( const TOutput &outsideValue )
00086     {
00087     m_OutsideValue = outsideValue;
00088     }
00089 
00091   const TOutput &GetOutsideValue() const
00092     {
00093     return m_OutsideValue;
00094     }
00095 
00096 private:
00097   TOutput m_OutsideValue;
00098 }; 
00099 
00100 }
00101 template <class TInputImage, class TMaskImage, class TOutputImage>
00102 class ITK_EXPORT MaskImageFilter :
00103     public
00104 BinaryFunctorImageFilter<TInputImage,TMaskImage,TOutputImage, 
00105                          Functor::MaskInput< 
00106   typename TInputImage::PixelType, 
00107   typename TMaskImage::PixelType,
00108   typename TOutputImage::PixelType>   >
00109 
00110 
00111 {
00112 public:
00114   typedef MaskImageFilter  Self;
00115   typedef BinaryFunctorImageFilter<TInputImage,TMaskImage,TOutputImage, 
00116                                    Functor::MaskInput< 
00117     typename TInputImage::PixelType, 
00118     typename TMaskImage::PixelType,
00119     typename TOutputImage::PixelType>   
00120   >  Superclass;
00121   typedef SmartPointer<Self>   Pointer;
00122   typedef SmartPointer<const Self>  ConstPointer;
00123 
00125   itkNewMacro(Self);
00126 
00128   void SetOutsideValue( const typename TOutputImage::PixelType & outsudeValue ) 
00129     {
00130     this->GetFunctor().SetOutsideValue( outsudeValue );
00131     }
00132 
00133 #ifdef ITK_USE_CONCEPT_CHECKING
00134 
00135   itkConceptMacro(MaskEqualityComparableCheck,
00136     (Concept::EqualityComparable<typename TMaskImage::PixelType>));
00137   itkConceptMacro(InputConvertibleToOutputCheck,
00138     (Concept::Convertible<typename TInputImage::PixelType,
00139                           typename TOutputImage::PixelType>));
00140 
00142 #endif
00143 
00144 protected:
00145   MaskImageFilter() {}
00146   virtual ~MaskImageFilter() {}
00147 
00148 private:
00149   MaskImageFilter(const Self&); //purposely not implemented
00150   void operator=(const Self&); //purposely not implemented
00151 
00152 };
00153 
00154 } // end namespace itk
00155 
00156 
00157 #endif
00158 

Generated at Sat Sep 2 20:49:22 2006 for ITK by doxygen 1.4.7 written by Dimitri van Heesch, © 1997-2000