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

itkAddImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkAddImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007/09/27 11:36:39 $
00007   Version:   $Revision: 1.13 $
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 __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&); //purposely not implemented
00126   void operator=(const Self&); //purposely not implemented
00127 
00128 };
00129 
00130 } // end namespace itk
00131 
00132 
00133 #endif
00134 

Generated at Tue Jul 29 19:04:11 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000