Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkNaryAddImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkNaryAddImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/03/25 02:01:17 $
00007   Version:   $Revision: 1.28 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
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&); //purposely not implemented
00104   void operator=(const Self&); //purposely not implemented
00105 
00106 };
00107 
00108 } // end namespace itk
00109 
00110 
00111 #endif

Generated at Wed May 24 23:43:25 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000