00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkNaryAddImageFilter_h
00018 #define __itkNaryAddImageFilter_h
00019
00020 #include "itkNaryFunctorImageFilter.h"
00021 #include "itkNumericTraits.h"
00022
00023
00024 namespace itk
00025 {
00026
00056 namespace Functor {
00057
00058 template< class TInput, class TOutput >
00059 class Add1
00060 {
00061 public:
00062 typedef typename NumericTraits< TInput >::AccumulateType AccumulatorType;
00063 Add1() {}
00064 ~Add1() {}
00065 inline TOutput operator()( const Array< TInput > & B)
00066 {
00067 AccumulatorType sum = NumericTraits< TOutput >::Zero;
00068 for( unsigned int i=0; i< B.size(); i++ )
00069 {
00070 sum += static_cast< TOutput >(B[i]);
00071 }
00072 return static_cast<TOutput>( sum );
00073 }
00074 bool operator != (const Add1&) const
00075 {
00076 return false;
00077 }
00078 };
00079 }
00080 template <class TInputImage, class TOutputImage>
00081 class ITK_EXPORT NaryAddImageFilter :
00082 public
00083 NaryFunctorImageFilter<TInputImage,TOutputImage,
00084 Functor::Add1<typename TInputImage::PixelType, typename TInputImage::PixelType > >
00085 {
00086 public:
00088 typedef NaryAddImageFilter Self;
00089 typedef NaryFunctorImageFilter<TInputImage,TOutputImage,
00090 Functor::Add1<typename TInputImage::PixelType,
00091 typename TInputImage::PixelType > > Superclass;
00092 typedef SmartPointer<Self> Pointer;
00093 typedef SmartPointer<const Self> ConstPointer;
00094
00096 itkNewMacro(Self);
00097
00098 protected:
00099 NaryAddImageFilter() {}
00100 virtual ~NaryAddImageFilter() {}
00101
00102 private:
00103 NaryAddImageFilter(const Self&);
00104 void operator=(const Self&);
00105
00106 };
00107
00108 }
00109
00110
00111 #endif