00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkConstrainedValueDifferenceImageFilter_h
00018 #define __itkConstrainedValueDifferenceImageFilter_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 ConstrainedValueDifference
00058 {
00059 public:
00060 ConstrainedValueDifference() {};
00061 ~ConstrainedValueDifference() {};
00062 bool operator!=( const ConstrainedValueDifference & ) const
00063 {
00064 return false;
00065 }
00066 bool operator==( const ConstrainedValueDifference & 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 diff = dA - dB;
00076 const double cdiff1 = diff > NumericTraits<TOutput>::NonpositiveMin() ?
00077 diff : NumericTraits<TOutput>::NonpositiveMin();
00078 const double cdiff2 = cdiff1 < NumericTraits<TOutput>::max() ?
00079 cdiff1 : NumericTraits<TOutput>::max();
00080 return static_cast<TOutput>( cdiff2 );
00081 }
00082 };
00083 }
00084
00085 template <class TInputImage1, class TInputImage2, class TOutputImage>
00086 class ITK_EXPORT ConstrainedValueDifferenceImageFilter :
00087 public
00088 BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
00089 Functor::ConstrainedValueDifference<
00090 typename TInputImage1::PixelType,
00091 typename TInputImage2::PixelType,
00092 typename TOutputImage::PixelType> >
00093 {
00094 public:
00096 typedef ConstrainedValueDifferenceImageFilter Self;
00097 typedef BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
00098 Functor::ConstrainedValueDifference<
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(ConstrainedValueDifferenceImageFilter,
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(DoubleConvertibleToOutputCheck,
00120 (Concept::Convertible<double, typename TOutputImage::PixelType>));
00121 itkConceptMacro(DoubleGreaterThanOutputCheck,
00122 (Concept::GreaterThanComparable<double, typename TOutputImage::PixelType>));
00123
00125 #endif
00126
00127 protected:
00128 ConstrainedValueDifferenceImageFilter() {}
00129 virtual ~ConstrainedValueDifferenceImageFilter() {}
00130
00131 private:
00132 ConstrainedValueDifferenceImageFilter(const Self&);
00133 void operator=(const Self&);
00134
00135 };
00136
00137 }
00138
00139
00140 #endif
00141