00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkAddImageFilter_h
00018 #define __itkAddImageFilter_h
00019
00020 #include "itkBinaryFunctorImageFilter.h"
00021 #include "itkNumericTraits.h"
00022
00023
00024 namespace itk
00025 {
00026
00055 namespace Functor {
00056
00057 template< class TInput1, class TInput2=TInput1, class TOutput=TInput1>
00058 class Add2
00059 {
00060 public:
00061 typedef typename NumericTraits< TInput1 >::AccumulateType AccumulatorType;
00062 Add2() {};
00063 ~Add2() {};
00064 bool operator!=( const Add2 & ) const
00065 {
00066 return false;
00067 }
00068 bool operator==( const Add2 & other ) const
00069 {
00070 return !(*this != other);
00071 }
00072 inline TOutput operator()( const TInput1 & A, const TInput2 & B)
00073 {
00074 const AccumulatorType sum = A;
00075 return static_cast<TOutput>( sum + B );
00076 }
00077 };
00078
00079 }
00080 template <class TInputImage1, class TInputImage2=TInputImage1, class TOutputImage=TInputImage1>
00081 class ITK_EXPORT AddImageFilter :
00082 public
00083 BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
00084 Functor::Add2<
00085 typename TInputImage1::PixelType,
00086 typename TInputImage2::PixelType,
00087 typename TOutputImage::PixelType> >
00088
00089
00090 {
00091 public:
00093 typedef AddImageFilter Self;
00094 typedef BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
00095 Functor::Add2<
00096 typename TInputImage1::PixelType,
00097 typename TInputImage2::PixelType,
00098 typename TOutputImage::PixelType>
00099 > Superclass;
00100 typedef SmartPointer<Self> Pointer;
00101 typedef SmartPointer<const Self> ConstPointer;
00102
00104 itkNewMacro(Self);
00105
00107 itkTypeMacro(AddImageFilter,
00108 BinaryFunctorImageFilter);
00109
00110 #ifdef ITK_USE_CONCEPT_CHECKING
00111
00112 itkConceptMacro(Input1Input2OutputAdditiveOperatorsCheck,
00113 (Concept::AdditiveOperators<typename TInputImage1::PixelType,
00114 typename TInputImage2::PixelType,
00115 typename TOutputImage::PixelType>));
00116
00118 #endif
00119
00120 protected:
00121 AddImageFilter() {}
00122 virtual ~AddImageFilter() {}
00123
00124 private:
00125 AddImageFilter(const Self&);
00126 void operator=(const Self&);
00127
00128 };
00129
00130 }
00131
00132
00133 #endif
00134