itkConstrainedValueAdditionImageFilter.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
00110 itkTypeMacro(ConstrainedValueAdditionImageFilter,
00111 BinaryFunctorImageFilter);
00112
00113 #ifdef ITK_USE_CONCEPT_CHECKING
00114
00115 itkConceptMacro(Input1ConvertibleToDoubleCheck,
00116 (Concept::Convertible<typename TInputImage1::PixelType, double>));
00117 itkConceptMacro(Input2ConvertibleToDoubleCheck,
00118 (Concept::Convertible<typename TInputImage2::PixelType, double>));
00119 itkConceptMacro(DoubleConvertibleToOutputCastCheck,
00120 (Concept::Convertible<double, typename TOutputImage::PixelType>));
00121 itkConceptMacro(DoubleLessThanOutputCheck,
00122 (Concept::LessThanComparable<double, typename TOutputImage::PixelType>));
00123
00125 #endif
00126
00127 protected:
00128 ConstrainedValueAdditionImageFilter() {}
00129 virtual ~ConstrainedValueAdditionImageFilter() {}
00130
00131 private:
00132 ConstrainedValueAdditionImageFilter(const Self&);
00133 void operator=(const Self&);
00134
00135 };
00136
00137 }
00138
00139
00140 #endif
00141