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 inline TOutput operator()( const TInput1 & A,
00059 const TInput2 & B)
00060 {
00061 const double dA = static_cast<double>( A );
00062 const double dB = static_cast<double>( B );
00063 const double diff = dA - dB;
00064 const double cdiff = ( diff > NumericTraits<TOutput>::min() ) ? diff : NumericTraits<TOutput>::min();
00065 return static_cast<TOutput>( cdiff );
00066 }
00067 };
00068 }
00069
00070 template <class TInputImage1, class TInputImage2, class TOutputImage>
00071 class ITK_EXPORT ConstrainedValueDifferenceImageFilter :
00072 public
00073 BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
00074 Functor::ConstrainedValueDifference<
00075 typename TInputImage1::PixelType,
00076 typename TInputImage2::PixelType,
00077 typename TOutputImage::PixelType> >
00078 {
00079 public:
00081 typedef ConstrainedValueDifferenceImageFilter Self;
00082 typedef BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
00083 Functor::ConstrainedValueDifference<
00084 typename TInputImage1::PixelType,
00085 typename TInputImage2::PixelType,
00086 typename TOutputImage::PixelType>
00087 > Superclass;
00088 typedef SmartPointer<Self> Pointer;
00089 typedef SmartPointer<const Self> ConstPointer;
00090
00092 itkNewMacro(Self);
00093
00094 protected:
00095 ConstrainedValueDifferenceImageFilter() {}
00096 virtual ~ConstrainedValueDifferenceImageFilter() {}
00097
00098 private:
00099 ConstrainedValueDifferenceImageFilter(const Self&);
00100 void operator=(const Self&);
00101
00102 };
00103
00104 }
00105
00106
00107 #endif