Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkVectorConnectedComponentImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkVectorConnectedComponentImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/10/07 19:50:18 $
00007   Version:   $Revision: 1.2 $
00008 
00009      This software is distributed WITHOUT ANY WARRANTY; without even 
00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00011      PURPOSE.  See the above copyright notices for more information.
00012 
00013 =========================================================================*/
00014 #ifndef __itkVectorConnectedComponentImageFilter_h
00015 #define __itkVectorConnectedComponentImageFilter_h
00016 
00017 #include "vnl/vnl_math.h"
00018 #include "itkNumericTraits.h"
00019 #include "itkConnectedComponentFunctorImageFilter.h"
00020 
00021 namespace itk
00022 {
00023   
00033 namespace Functor {  
00034   
00035 template<class TInput>
00036 class SimilarVectorsFunctor
00037 {
00038 public:
00039   SimilarVectorsFunctor()
00040     {threshold = itk::NumericTraits<typename TInput::ValueType>::Zero;};
00041 
00042   ~SimilarVectorsFunctor() {};
00043 
00044   void SetDistanceThreshold(const typename TInput::ValueType &thresh)
00045     {threshold = thresh;};
00046   typename TInput::ValueType GetDistanceThreshold() {return (threshold);};
00047   
00048   bool operator()(const TInput &a, const TInput &b)
00049     {
00050     typename TInput::ValueType dotProduct = vnl_math_abs(a * b);
00051     return (1.0 - dotProduct <= threshold);
00052     };
00053 
00054 protected:
00055   typename TInput::ValueType threshold;
00056                             
00057 };
00058 
00059 } // end namespace Functor 
00060 
00061 template <class TInputImage, class TOutputImage, class TMaskImage=TInputImage>
00062 class ITK_EXPORT VectorConnectedComponentImageFilter :
00063     public ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage,
00064              Functor::SimilarVectorsFunctor<typename TInputImage::ValueType>,
00065                                            TMaskImage> 
00066 {
00067 public:
00069   typedef VectorConnectedComponentImageFilter Self;
00070   typedef ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage, 
00071              Functor::SimilarVectorsFunctor<typename TInputImage::ValueType>,
00072              TMaskImage> Superclass;
00073   typedef SmartPointer<Self>   Pointer;
00074   typedef SmartPointer<const Self>  ConstPointer;
00075 
00077   itkNewMacro(Self);
00078 
00080   itkTypeMacro(VectorConnectedComponentImageFilter,ConnectedComponentFunctorImageFilter);
00081 
00082   typedef typename TInputImage::PixelType::ValueType  InputValueType;
00083   
00084   virtual void SetDistanceThreshold(const InputValueType& thresh)
00085     {this->GetFunctor().SetDistanceThreshold(thresh);}
00086 
00087   virtual InputValueType GetDistanceThreshold()
00088     {return (this->GetFunctor().GetDistanceThreshold());}
00089   
00090 protected:
00091   VectorConnectedComponentImageFilter() {};
00092   virtual ~VectorConnectedComponentImageFilter() {};
00093 
00094 private:
00095   VectorConnectedComponentImageFilter(const Self&); //purposely not implemented
00096   void operator=(const Self&); //purposely not implemented
00097 
00098 };
00099 
00100 } // end namespace itk
00101 
00102 #endif

Generated at Thu May 25 00:11:28 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000