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: 2009-04-01 14:36:27 $
00007   Version:   $Revision: 1.18 $
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=TInput >
00056 class MaskInput
00057 {
00058 public:
00059   typedef typename NumericTraits< TInput >::AccumulateType AccumulatorType;
00060 
00061   MaskInput(): m_OutsideValue(NumericTraits< TOutput >::Zero) {};
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) const
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=TInputImage>
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   itkTypeMacro(MaskImageFilter, 
00129                BinaryFunctorImageFilter);
00130 
00132   void SetOutsideValue( const typename TOutputImage::PixelType & outsideValue ) 
00133     {
00134     if( this->GetOutsideValue() != outsideValue )
00135       {
00136       this->Modified();
00137       this->GetFunctor().SetOutsideValue( outsideValue );
00138       }
00139     }
00141 
00142   const typename TOutputImage::PixelType & GetOutsideValue() const
00143     {
00144     return this->GetFunctor().GetOutsideValue();
00145     }
00146 
00147 #ifdef ITK_USE_CONCEPT_CHECKING
00148 
00149   itkConceptMacro(MaskEqualityComparableCheck,
00150     (Concept::EqualityComparable<typename TMaskImage::PixelType>));
00151   itkConceptMacro(InputConvertibleToOutputCheck,
00152     (Concept::Convertible<typename TInputImage::PixelType,
00153                           typename TOutputImage::PixelType>));
00154 
00156 #endif
00157 
00158 protected:
00159   MaskImageFilter() {}
00160   virtual ~MaskImageFilter() {}
00161 
00162   void PrintSelf(std::ostream &os, Indent indent) const
00163     {
00164     Superclass::PrintSelf(os, indent);
00165     os << indent << "OutsideValue: "  << this->GetOutsideValue() << std::endl;
00166     }
00167 
00168 private:
00169   MaskImageFilter(const Self&); //purposely not implemented
00170   void operator=(const Self&); //purposely not implemented
00171 
00172 };
00173 
00174 } // end namespace itk
00175 
00176 
00177 #endif
00178 

Generated at Tue Sep 15 03:54:02 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000