00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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 inline TOutput operator()( const TInput & A, const TMask & B)
00064 {
00065 if (B != NumericTraits< TMask >::ZeroValue() )
00066 {
00067 return static_cast<TOutput>( A );
00068 }
00069 else
00070 {
00071 return m_OutsideValue;
00072 }
00073 }
00074
00076 void SetOutsideValue( const TOutput &outsideValue )
00077 {
00078 m_OutsideValue = outsideValue;
00079 }
00080
00082 const TOutput &GetOutsideValue() const
00083 {
00084 return m_OutsideValue;
00085 }
00086
00087 private:
00088 TOutput m_OutsideValue;
00089 };
00090
00091 }
00092 template <class TInputImage, class TMaskImage, class TOutputImage>
00093 class ITK_EXPORT MaskImageFilter :
00094 public
00095 BinaryFunctorImageFilter<TInputImage,TMaskImage,TOutputImage,
00096 Functor::MaskInput<
00097 typename TInputImage::PixelType,
00098 typename TMaskImage::PixelType,
00099 typename TOutputImage::PixelType> >
00100
00101
00102 {
00103 public:
00105 typedef MaskImageFilter Self;
00106 typedef BinaryFunctorImageFilter<TInputImage,TMaskImage,TOutputImage,
00107 Functor::MaskInput<
00108 typename TInputImage::PixelType,
00109 typename TMaskImage::PixelType,
00110 typename TOutputImage::PixelType>
00111 > Superclass;
00112 typedef SmartPointer<Self> Pointer;
00113 typedef SmartPointer<const Self> ConstPointer;
00114
00116 itkNewMacro(Self);
00117
00119 void SetOutsideValue( const typename TOutputImage::PixelType & outsudeValue )
00120 {
00121 this->GetFunctor().SetOutsideValue( outsudeValue );
00122 }
00123
00124 protected:
00125 MaskImageFilter() {}
00126 virtual ~MaskImageFilter() {}
00127
00128 private:
00129 MaskImageFilter(const Self&);
00130 void operator=(const Self&);
00131
00132 };
00133
00134 }
00135
00136
00137 #endif