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