00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkAbsoluteValueDifferenceImageFilter_h
00018 #define __itkAbsoluteValueDifferenceImageFilter_h
00019
00020 #include "itkBinaryFunctorImageFilter.h"
00021 #include "itkConceptChecking.h"
00022
00023 namespace itk
00024 {
00025
00049 namespace Functor {
00050
00051 template< class TInput1, class TInput2, class TOutput>
00052 class AbsoluteValueDifference2
00053 {
00054 public:
00055 AbsoluteValueDifference2() {};
00056 ~AbsoluteValueDifference2() {};
00057 bool operator!=( const AbsoluteValueDifference2 & ) const
00058 {
00059 return false;
00060 }
00061 bool operator==( const AbsoluteValueDifference2 & other ) const
00062 {
00063 return !(*this != other);
00064 }
00065 inline TOutput operator()( const TInput1 & A,
00066 const TInput2 & B)
00067 {
00068 const double dA = static_cast<double>( A );
00069 const double dB = static_cast<double>( B );
00070 const double diff = dA - dB;
00071 const double absdiff = ( diff > 0.0 ) ? diff : -diff;
00072 return static_cast<TOutput>( absdiff );
00073 }
00074 };
00075 }
00076
00077 template <class TInputImage1, class TInputImage2, class TOutputImage>
00078 class ITK_EXPORT AbsoluteValueDifferenceImageFilter :
00079 public
00080 BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
00081 Functor::AbsoluteValueDifference2<
00082 typename TInputImage1::PixelType,
00083 typename TInputImage2::PixelType,
00084 typename TOutputImage::PixelType> >
00085 {
00086 public:
00088 typedef AbsoluteValueDifferenceImageFilter Self;
00089 typedef BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
00090 Functor::AbsoluteValueDifference2<
00091 typename TInputImage1::PixelType,
00092 typename TInputImage2::PixelType,
00093 typename TOutputImage::PixelType>
00094 > Superclass;
00095 typedef SmartPointer<Self> Pointer;
00096 typedef SmartPointer<const Self> ConstPointer;
00097
00099 itkNewMacro(Self);
00100
00102 itkTypeMacro(AbsoluteValueDifferenceImageFilter,
00103 BinaryFunctorImageFilter);
00104
00105 #ifdef ITK_USE_CONCEPT_CHECKING
00106
00107 itkConceptMacro(Input1CovertibleToDoubleCheck,
00108 (Concept::Convertible<typename TInputImage1::PixelType, double>));
00109 itkConceptMacro(Input2ConvertibleToDoubleCheck,
00110 (Concept::Convertible<typename TInputImage2::PixelType, double>));
00111 itkConceptMacro(DoubleCovertibleToOutputCheck,
00112 (Concept::Convertible<double, typename TOutputImage::PixelType>));
00113
00115 #endif
00116
00117 protected:
00118 AbsoluteValueDifferenceImageFilter() {}
00119 virtual ~AbsoluteValueDifferenceImageFilter() {}
00120
00121 private:
00122 AbsoluteValueDifferenceImageFilter(const Self&);
00123 void operator=(const Self&);
00124
00125 };
00126
00127 }
00128
00129
00130 #endif
00131