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 __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) const
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
00096 typedef SmartPointer<Self> Pointer;
00097 typedef SmartPointer<const Self> ConstPointer;
00098
00100 itkNewMacro(Self);
00101
00103 itkTypeMacro(AbsoluteValueDifferenceImageFilter,
00104 BinaryFunctorImageFilter);
00105
00106 #ifdef ITK_USE_CONCEPT_CHECKING
00107
00108 itkConceptMacro(Input1CovertibleToDoubleCheck,
00109 (Concept::Convertible<typename TInputImage1::PixelType, double>));
00110 itkConceptMacro(Input2ConvertibleToDoubleCheck,
00111 (Concept::Convertible<typename TInputImage2::PixelType, double>));
00112 itkConceptMacro(DoubleCovertibleToOutputCheck,
00113 (Concept::Convertible<double, typename TOutputImage::PixelType>));
00114
00116 #endif
00117
00118 protected:
00119 AbsoluteValueDifferenceImageFilter() {}
00120 virtual ~AbsoluteValueDifferenceImageFilter() {}
00121
00122 private:
00123 AbsoluteValueDifferenceImageFilter(const Self&);
00124 void operator=(const Self&);
00125
00126 };
00127
00128 }
00129
00130
00131 #endif
00132