00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkBinaryMagnitudeImageFilter_h
00018 #define __itkBinaryMagnitudeImageFilter_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 Modulus2
00052 {
00053 public:
00054 Modulus2() {};
00055 ~Modulus2() {};
00056 bool operator!=( const Modulus2 & ) const
00057 {
00058 return false;
00059 }
00060 bool operator==( const Modulus2 & other ) const
00061 {
00062 return !(*this != other);
00063 }
00064 inline TOutput operator()( const TInput1 & A,
00065 const TInput2 & B) const
00066 {
00067 const double dA = static_cast<double>( A );
00068 const double dB = static_cast<double>( B );
00069 return static_cast<TOutput>( vcl_sqrt(dA*dA + dB*dB) );
00070 }
00071 };
00072 }
00073
00074 template <class TInputImage1, class TInputImage2, class TOutputImage>
00075 class ITK_EXPORT BinaryMagnitudeImageFilter :
00076 public
00077 BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
00078 Functor::Modulus2<
00079 typename TInputImage1::PixelType,
00080 typename TInputImage2::PixelType,
00081 typename TOutputImage::PixelType> >
00082 {
00083 public:
00085 typedef BinaryMagnitudeImageFilter Self;
00086 typedef BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
00087 Functor::Modulus2<
00088 typename TInputImage1::PixelType,
00089 typename TInputImage2::PixelType,
00090 typename TOutputImage::PixelType>
00091 > Superclass;
00092 typedef SmartPointer<Self> Pointer;
00093 typedef SmartPointer<const Self> ConstPointer;
00094
00096 itkNewMacro(Self);
00097
00099 itkTypeMacro(BinaryMagnitudeImageFilter,
00100 BinaryFunctorImageFilter);
00101
00102 #ifdef ITK_USE_CONCEPT_CHECKING
00103
00104 itkConceptMacro(Input1ConvertibleToDoubleCheck,
00105 (Concept::Convertible<typename TInputImage1::PixelType, double>));
00106 itkConceptMacro(Input2ConvertibleToDoubleCheck,
00107 (Concept::Convertible<typename TInputImage2::PixelType, double>));
00108 itkConceptMacro(DoubleConvertibleToOutputCheck,
00109 (Concept::Convertible<double, typename TOutputImage::PixelType>));
00110
00112 #endif
00113
00114 protected:
00115 BinaryMagnitudeImageFilter() {}
00116 virtual ~BinaryMagnitudeImageFilter() {}
00117
00118 private:
00119 BinaryMagnitudeImageFilter(const Self&);
00120 void operator=(const Self&);
00121
00122 };
00123
00124 }
00125
00126
00127 #endif
00128