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, class TOutput >
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, class TOutputImage>
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
00106 #ifdef ITK_USE_CONCEPT_CHECKING
00107
00108 itkConceptMacro(Input1Input2OutputAdditiveOperatorsCheck,
00109 (Concept::AdditiveOperators<typename TInputImage1::PixelType,
00110 typename TInputImage2::PixelType,
00111 typename TOutputImage::PixelType>));
00112
00114 #endif
00115
00116 protected:
00117 AddImageFilter() {}
00118 virtual ~AddImageFilter() {}
00119
00120 private:
00121 AddImageFilter(const Self&);
00122 void operator=(const Self&);
00123
00124 };
00125
00126 }
00127
00128
00129 #endif
00130