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

itkConstrainedValueAdditionImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkConstrainedValueAdditionImageFilter.h,v $
00005   Language:  C++
00006 
00007   Copyright (c) Insight Software Consortium. All rights reserved.
00008   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even 
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00012      PURPOSE.  See the above copyright notices for more information.
00013 
00014 =========================================================================*/
00015 #ifndef __itkConstrainedValueAdditionImageFilter_h
00016 #define __itkConstrainedValueAdditionImageFilter_h
00017 
00018 #include "itkBinaryFunctorImageFilter.h"
00019 #include "itkNumericTraits.h"
00020 
00021 namespace itk
00022 {
00023   
00050 namespace Functor {  
00051   
00052 template< class TInput1, class TInput2, class TOutput>
00053 class ConstrainedValueAddition
00054 {
00055 public:
00056   ConstrainedValueAddition() {};
00057   ~ConstrainedValueAddition() {};
00058   inline TOutput operator()( const TInput1 & A, 
00059                              const TInput2 & B)
00060   {
00061     const double dA = static_cast<double>( A );
00062     const double dB = static_cast<double>( B );
00063     const double add = dA + dB;
00064     const double cadd = ( add < NumericTraits<TOutput>::max() ) ? add : NumericTraits<TOutput>::max(); 
00065     return static_cast<TOutput>( cadd );
00066   }
00067 }; 
00068 }
00069 
00070 template <class TInputImage1, class TInputImage2, class TOutputImage>
00071 class ITK_EXPORT ConstrainedValueAdditionImageFilter :
00072     public
00073 BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage, 
00074                          Functor::ConstrainedValueAddition< 
00075   typename TInputImage1::PixelType, 
00076   typename TInputImage2::PixelType,
00077   typename TOutputImage::PixelType>   >
00078 {
00079 public:
00081   typedef ConstrainedValueAdditionImageFilter  Self;
00082   typedef BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage, 
00083                                    Functor::ConstrainedValueAddition< 
00084     typename TInputImage1::PixelType, 
00085     typename TInputImage2::PixelType,
00086     typename TOutputImage::PixelType>   
00087   >  Superclass;
00088   typedef SmartPointer<Self>   Pointer;
00089   typedef SmartPointer<const Self>  ConstPointer;
00090 
00092   itkNewMacro(Self);
00093   
00094 protected:
00095   ConstrainedValueAdditionImageFilter() {}
00096   virtual ~ConstrainedValueAdditionImageFilter() {}
00097 
00098 private:
00099   ConstrainedValueAdditionImageFilter(const Self&); //purposely not implemented
00100   void operator=(const Self&); //purposely not implemented
00101 
00102 };
00103 
00104 } // end namespace itk
00105 
00106 
00107 #endif

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