00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __itkScalarConnectedComponentImageFilter_h
00015 #define __itkScalarConnectedComponentImageFilter_h
00016
00017 #include "vnl/vnl_math.h"
00018 #include "itkNumericTraits.h"
00019 #include "itkConnectedComponentFunctorImageFilter.h"
00020
00021 namespace itk
00022 {
00023
00032 namespace Functor {
00033
00034 template<class TInput>
00035 class SimilarPixelsFunctor
00036 {
00037 public:
00038 SimilarPixelsFunctor()
00039 {threshold = itk::NumericTraits<TInput>::Zero;};
00040
00041 ~SimilarPixelsFunctor() {};
00042
00043 void SetDistanceThreshold(const TInput &thresh) {threshold = thresh;};
00044 TInput GetDistanceThreshold() {return (threshold);};
00045
00046 bool operator()(const TInput &a, const TInput &b) {
00047 return (vnl_math_abs(a-b) <= threshold);
00048 };
00049
00050 protected:
00051 TInput threshold;
00052
00053 };
00054
00055 }
00056
00057 template <class TInputImage, class TOutputImage, class TMaskImage=TInputImage>
00058 class ITK_EXPORT ScalarConnectedComponentImageFilter :
00059 public ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage,
00060 Functor::SimilarPixelsFunctor<typename TInputImage::ValueType>,
00061 TMaskImage>
00062 {
00063 public:
00065 typedef ScalarConnectedComponentImageFilter Self;
00066 typedef ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage,
00067 Functor::SimilarPixelsFunctor<typename TInputImage::ValueType>,
00068 TMaskImage> Superclass;
00069 typedef SmartPointer<Self> Pointer;
00070 typedef SmartPointer<const Self> ConstPointer;
00071
00073 itkNewMacro(Self);
00074
00076 itkTypeMacro(ScalarConnectedComponentImageFilter,ConnectedComponentFunctorImageFilter);
00077
00078 typedef typename TInputImage::PixelType InputPixelType;
00079
00080 virtual void SetDistanceThreshold(const InputPixelType& thresh)
00081 {this->GetFunctor().SetDistanceThreshold(thresh);}
00082
00083 virtual InputPixelType GetDistanceThreshold()
00084 {return (this->GetFunctor().GetDistanceThreshold());}
00085
00086 protected:
00087 ScalarConnectedComponentImageFilter() {};
00088 virtual ~ScalarConnectedComponentImageFilter() {};
00089
00090 private:
00091 ScalarConnectedComponentImageFilter(const Self&);
00092 void operator=(const Self&);
00093
00094 };
00095
00096 }
00097
00098 #endif