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 namespace itk
00024 {
00025
00055 namespace Functor {
00056
00057 template< class TInput, class TOutput >
00058 class Add1
00059 {
00060 public:
00061 typedef typename NumericTraits< TInput >::AccumulateType AccumulatorType;
00062 Add1() {}
00063 ~Add1() {}
00064 inline TOutput operator()( const std::vector< TInput > & B)
00065 {
00066 AccumulatorType sum = NumericTraits< TOutput >::Zero;
00067 for( unsigned int i=0; i< B.size(); i++ )
00068 {
00069 sum += static_cast< TOutput >(B[i]);
00070 }
00071 return static_cast<TOutput>( sum );
00072 }
00073 bool operator== (const Add1&) const
00074 {
00075 return true;
00076 }
00077 bool operator!= (const Add1&) const
00078 {
00079 return false;
00080 }
00081 };
00082 }
00083 template <class TInputImage, class TOutputImage>
00084 class ITK_EXPORT NaryAddImageFilter :
00085 public
00086 NaryFunctorImageFilter<TInputImage,TOutputImage,
00087 Functor::Add1<typename TInputImage::PixelType, typename TInputImage::PixelType > >
00088 {
00089 public:
00091 typedef NaryAddImageFilter Self;
00092 typedef NaryFunctorImageFilter<TInputImage,TOutputImage,
00093 Functor::Add1<typename TInputImage::PixelType,
00094 typename TInputImage::PixelType > > Superclass;
00095 typedef SmartPointer<Self> Pointer;
00096 typedef SmartPointer<const Self> ConstPointer;
00097
00099 itkNewMacro(Self);
00100
00102 itkTypeMacro(NaryAddImageFilter,
00103 NaryFunctorImageFilter);
00104
00105 #ifdef ITK_USE_CONCEPT_CHECKING
00106
00107 itkConceptMacro(InputConvertibleToOutputCheck,
00108 (Concept::Convertible<typename TInputImage::PixelType,
00109 typename TOutputImage::PixelType>));
00110 itkConceptMacro(InputHasZeroCheck,
00111 (Concept::HasZero<typename TInputImage::PixelType>));
00112
00114 #endif
00115
00116 protected:
00117 NaryAddImageFilter() {}
00118 virtual ~NaryAddImageFilter() {}
00119
00120 private:
00121 NaryAddImageFilter(const Self&);
00122 void operator=(const Self&);
00123
00124 };
00125
00126 }
00127
00128
00129 #endif
00130