00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __itkConstrainedValueDifferenceImageFilter_h
00016 #define __itkConstrainedValueDifferenceImageFilter_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 ConstrainedValueDifference
00054 {
00055 public:
00056 ConstrainedValueDifference() {};
00057 ~ConstrainedValueDifference() {};
00058 bool operator!=( const ConstrainedValueDifference & ) const
00059 {
00060 return false;
00061 }
00062 bool operator==( const ConstrainedValueDifference & other ) const
00063 {
00064 return !(*this != other);
00065 }
00066 inline TOutput operator()( const TInput1 & A,
00067 const TInput2 & B)
00068 {
00069 const double dA = static_cast<double>( A );
00070 const double dB = static_cast<double>( B );
00071 const double diff = dA - dB;
00072 const double cdiff = ( diff > NumericTraits<TOutput>::min() ) ? diff : NumericTraits<TOutput>::min();
00073 return static_cast<TOutput>( cdiff );
00074 }
00075 };
00076 }
00077
00078 template <class TInputImage1, class TInputImage2, class TOutputImage>
00079 class ITK_EXPORT ConstrainedValueDifferenceImageFilter :
00080 public
00081 BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
00082 Functor::ConstrainedValueDifference<
00083 typename TInputImage1::PixelType,
00084 typename TInputImage2::PixelType,
00085 typename TOutputImage::PixelType> >
00086 {
00087 public:
00089 typedef ConstrainedValueDifferenceImageFilter Self;
00090 typedef BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
00091 Functor::ConstrainedValueDifference<
00092 typename TInputImage1::PixelType,
00093 typename TInputImage2::PixelType,
00094 typename TOutputImage::PixelType>
00095 > Superclass;
00096 typedef SmartPointer<Self> Pointer;
00097 typedef SmartPointer<const Self> ConstPointer;
00098
00100 itkNewMacro(Self);
00101
00102 #ifdef ITK_USE_CONCEPT_CHECKING
00103
00104 itkConceptMacro(Input1ConvertibleToDoubleCheck,
00105 (Concept::Convertible<typename TInputImage1::PixelType, double>));
00106 itkConceptMacro(Input2ConvertibleToDoubleCheck,
00107 (Concept::Convertible<typename TInputImage2::PixelType, double>));
00108 itkConceptMacro(DoubleConvertibleToOutputCheck,
00109 (Concept::Convertible<double, typename TOutputImage::PixelType>));
00110 itkConceptMacro(DoubleGreaterThanOutputCheck,
00111 (Concept::GreaterThanComparable<double, typename TOutputImage::PixelType>));
00112
00114 #endif
00115
00116 protected:
00117 ConstrainedValueDifferenceImageFilter() {}
00118 virtual ~ConstrainedValueDifferenceImageFilter() {}
00119
00120 private:
00121 ConstrainedValueDifferenceImageFilter(const Self&);
00122 void operator=(const Self&);
00123
00124 };
00125
00126 }
00127
00128
00129 #endif
00130