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   Date:      $Date: 2007/02/22 04:33:00 $
00007   Version:   $Revision: 1.6 $
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 __itkConstrainedValueAdditionImageFilter_h
00018 #define __itkConstrainedValueAdditionImageFilter_h
00019 
00020 #include "itkBinaryFunctorImageFilter.h"
00021 #include "itkNumericTraits.h"
00022 
00023 namespace itk
00024 {
00025   
00054 namespace Functor {  
00055   
00056 template< class TInput1, class TInput2, class TOutput>
00057 class ConstrainedValueAddition
00058 {
00059 public:
00060   ConstrainedValueAddition() {};
00061   ~ConstrainedValueAddition() {};
00062   bool operator!=( const ConstrainedValueAddition & ) const
00063     {
00064     return false;
00065     }
00066   bool operator==( const ConstrainedValueAddition & other ) const
00067     {
00068     return !(*this != other);
00069     }
00070   inline TOutput operator()( const TInput1 & A, 
00071                              const TInput2 & B)
00072     {
00073     const double dA = static_cast<double>( A );
00074     const double dB = static_cast<double>( B );
00075     const double add = dA + dB;
00076     const double cadd1 = ( add < NumericTraits<TOutput>::max() ) ?
00077       add : NumericTraits<TOutput>::max(); 
00078     const double cadd2 = ( cadd1 > NumericTraits<TOutput>::NonpositiveMin() ) ?
00079       cadd1 : NumericTraits<TOutput>::NonpositiveMin(); 
00080     return static_cast<TOutput>( cadd2 );
00081     }
00082 }; 
00083 }
00084 
00085 template <class TInputImage1, class TInputImage2, class TOutputImage>
00086 class ITK_EXPORT ConstrainedValueAdditionImageFilter :
00087     public
00088 BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage, 
00089                          Functor::ConstrainedValueAddition< 
00090   typename TInputImage1::PixelType, 
00091   typename TInputImage2::PixelType,
00092   typename TOutputImage::PixelType>   >
00093 {
00094 public:
00096   typedef ConstrainedValueAdditionImageFilter  Self;
00097   typedef BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage, 
00098                                    Functor::ConstrainedValueAddition< 
00099     typename TInputImage1::PixelType, 
00100     typename TInputImage2::PixelType,
00101     typename TOutputImage::PixelType> >
00102                                     Superclass;
00103   typedef SmartPointer<Self>        Pointer;
00104   typedef SmartPointer<const Self>  ConstPointer;
00105 
00107   itkNewMacro(Self);
00108 
00109 #ifdef ITK_USE_CONCEPT_CHECKING
00110 
00111   itkConceptMacro(Input1ConvertibleToDoubleCheck,
00112     (Concept::Convertible<typename TInputImage1::PixelType, double>));
00113   itkConceptMacro(Input2ConvertibleToDoubleCheck,
00114     (Concept::Convertible<typename TInputImage2::PixelType, double>));
00115   itkConceptMacro(DoubleConvertibleToOutputCastCheck,
00116     (Concept::Convertible<double, typename TOutputImage::PixelType>));
00117   itkConceptMacro(DoubleLessThanOutputCheck,
00118     (Concept::LessThanComparable<double, typename TOutputImage::PixelType>));
00119 
00121 #endif
00122 
00123 protected:
00124   ConstrainedValueAdditionImageFilter() {}
00125   virtual ~ConstrainedValueAdditionImageFilter() {}
00126 
00127 private:
00128   ConstrainedValueAdditionImageFilter(const Self&); //purposely not implemented
00129   void operator=(const Self&); //purposely not implemented
00130 
00131 };
00132 
00133 } // end namespace itk
00134 
00135 
00136 #endif
00137 

Generated at Sun Sep 23 12:16:57 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000