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: 2007/08/30 15:01:09 $
00007   Version:   $Revision: 1.13 $
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 >::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=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   void SetOutsideValue( const typename TOutputImage::PixelType & outsideValue ) 
00129     {
00130     if( this->GetOutsideValue() != outsideValue )
00131       {
00132       this->Modified();
00133       this->GetFunctor().SetOutsideValue( outsideValue );
00134       }
00135     }
00137 
00138   const typename TOutputImage::PixelType & GetOutsideValue() const
00139     {
00140     return this->GetFunctor().GetOutsideValue();
00141     }
00142 
00143 #ifdef ITK_USE_CONCEPT_CHECKING
00144 
00145   itkConceptMacro(MaskEqualityComparableCheck,
00146     (Concept::EqualityComparable<typename TMaskImage::PixelType>));
00147   itkConceptMacro(InputConvertibleToOutputCheck,
00148     (Concept::Convertible<typename TInputImage::PixelType,
00149                           typename TOutputImage::PixelType>));
00150 
00152 #endif
00153 
00154 protected:
00155   MaskImageFilter() {}
00156   virtual ~MaskImageFilter() {}
00157 
00158   void PrintSelf(std::ostream &os, Indent indent) const
00159     {
00160     Superclass::PrintSelf(os, indent);
00161     os << indent << "OutsideValue: "  << this->GetOutsideValue() << std::endl;
00162     }
00163 
00164 private:
00165   MaskImageFilter(const Self&); //purposely not implemented
00166   void operator=(const Self&); //purposely not implemented
00167 
00168 };
00169 
00170 } // end namespace itk
00171 
00172 
00173 #endif
00174 

Generated at Sun Sep 23 13:27:00 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000