itkVectorConnectedComponentImageFilter.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __itkVectorConnectedComponentImageFilter_h
00021 #define __itkVectorConnectedComponentImageFilter_h
00022
00023 #include "vnl/vnl_math.h"
00024 #include "itkNumericTraits.h"
00025 #include "itkConnectedComponentFunctorImageFilter.h"
00026
00027 namespace itk
00028 {
00029
00030 namespace Functor
00031 {
00032
00042 template<class TInput>
00043 class SimilarVectorsFunctor
00044 {
00045 public:
00046 SimilarVectorsFunctor()
00047 {m_Threshold = itk::NumericTraits<ITK_TYPENAME TInput::ValueType>::Zero;}
00048
00049 ~SimilarVectorsFunctor() {};
00050
00051 void SetDistanceThreshold(const typename TInput::ValueType &thresh)
00052 {m_Threshold = thresh;}
00053 typename TInput::ValueType GetDistanceThreshold() {return (m_Threshold);}
00054
00055 bool operator!=( const SimilarVectorsFunctor & ) const
00056 {
00057 return false;
00058 }
00059 bool operator==( const SimilarVectorsFunctor & other ) const
00060 {
00061 return !(*this != other);
00062 }
00063 bool operator()(const TInput &a, const TInput &b) const
00064 {
00065 typename TInput::ValueType dotProduct = vnl_math_abs(a * b);
00066 return (1.0 - dotProduct <= m_Threshold);
00067 }
00068
00069 protected:
00070 typename TInput::ValueType m_Threshold;
00071
00072 };
00073
00074 }
00075
00084 template <class TInputImage, class TOutputImage, class TMaskImage=TInputImage>
00085 class ITK_EXPORT VectorConnectedComponentImageFilter :
00086 public ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage,
00087 Functor::SimilarVectorsFunctor<typename TInputImage::ValueType>,
00088 TMaskImage>
00089 {
00090 public:
00092 typedef VectorConnectedComponentImageFilter Self;
00093 typedef ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage,
00094 Functor::SimilarVectorsFunctor<typename TInputImage::ValueType>,
00095 TMaskImage> Superclass;
00096 typedef SmartPointer<Self> Pointer;
00097 typedef SmartPointer<const Self> ConstPointer;
00098
00100 itkNewMacro(Self);
00101
00103 itkTypeMacro(VectorConnectedComponentImageFilter,ConnectedComponentFunctorImageFilter);
00104
00105 typedef typename TInputImage::PixelType::ValueType InputValueType;
00106
00107 virtual void SetDistanceThreshold(const InputValueType& thresh)
00108 {this->GetFunctor().SetDistanceThreshold(thresh);}
00109
00110 virtual InputValueType GetDistanceThreshold()
00111 {return (this->GetFunctor().GetDistanceThreshold());}
00112
00113 #ifdef ITK_USE_CONCEPT_CHECKING
00114
00115 itkConceptMacro(InputHasNumericTraitsCheck,
00116 (Concept::HasNumericTraits<InputValueType>));
00117
00119 #endif
00120
00121 protected:
00122 VectorConnectedComponentImageFilter() {};
00123 virtual ~VectorConnectedComponentImageFilter() {};
00124
00125 private:
00126 VectorConnectedComponentImageFilter(const Self&);
00127 void operator=(const Self&);
00128
00129 };
00130
00131 }
00132
00133 #endif
00134