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: 2009-04-01 14:36:37 $
00007   Version:   $Revision: 1.9 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012   Portions of this code are covered under the VTK copyright.
00013   See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.
00014 
00015      This software is distributed WITHOUT ANY WARRANTY; without even 
00016      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00017      PURPOSE.  See the above copyright notices for more information.
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   
00039 namespace Functor {  
00040   
00041 template<class TInput>
00042 class SimilarVectorsFunctor
00043 {
00044 public:
00045   SimilarVectorsFunctor()
00046     {m_Threshold = itk::NumericTraits<ITK_TYPENAME TInput::ValueType>::Zero;}
00047 
00048   ~SimilarVectorsFunctor() {};
00049 
00050   void SetDistanceThreshold(const typename TInput::ValueType &thresh)
00051     {m_Threshold = thresh;}
00052   typename TInput::ValueType GetDistanceThreshold() {return (m_Threshold);}
00053   
00054   bool operator!=( const SimilarVectorsFunctor & ) const
00055     {
00056     return false;
00057     }
00058   bool operator==( const SimilarVectorsFunctor & other ) const
00059     {
00060     return !(*this != other);
00061     }
00062   bool operator()(const TInput &a, const TInput &b) const
00063     {
00064     typename TInput::ValueType dotProduct = vnl_math_abs(a * b);
00065     return (1.0 - dotProduct <= m_Threshold);
00066     }
00067 
00068 protected:
00069   typename TInput::ValueType m_Threshold;
00070                             
00071 };
00072 
00073 } // end namespace Functor 
00074 
00075 template <class TInputImage, class TOutputImage, class TMaskImage=TInputImage>
00076 class ITK_EXPORT VectorConnectedComponentImageFilter :
00077     public ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage,
00078              Functor::SimilarVectorsFunctor<typename TInputImage::ValueType>,
00079                                            TMaskImage> 
00080 {
00081 public:
00083   typedef VectorConnectedComponentImageFilter Self;
00084   typedef ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage, 
00085              Functor::SimilarVectorsFunctor<typename TInputImage::ValueType>,
00086              TMaskImage>                      Superclass;
00087   typedef SmartPointer<Self>                  Pointer;
00088   typedef SmartPointer<const Self>            ConstPointer;
00089 
00091   itkNewMacro(Self);
00092 
00094   itkTypeMacro(VectorConnectedComponentImageFilter,ConnectedComponentFunctorImageFilter);
00095 
00096   typedef typename TInputImage::PixelType::ValueType  InputValueType;
00097   
00098   virtual void SetDistanceThreshold(const InputValueType& thresh)
00099     {this->GetFunctor().SetDistanceThreshold(thresh);}
00100 
00101   virtual InputValueType GetDistanceThreshold()
00102     {return (this->GetFunctor().GetDistanceThreshold());}
00103 
00104 #ifdef ITK_USE_CONCEPT_CHECKING
00105 
00106   itkConceptMacro(InputHasNumericTraitsCheck,
00107                   (Concept::HasNumericTraits<InputValueType>));
00108 
00110 #endif
00111 
00112 protected:
00113   VectorConnectedComponentImageFilter() {};
00114   virtual ~VectorConnectedComponentImageFilter() {};
00115 
00116 private:
00117   VectorConnectedComponentImageFilter(const Self&); //purposely not implemented
00118   void operator=(const Self&); //purposely not implemented
00119 
00120 };
00121 
00122 } // end namespace itk
00123 
00124 #endif
00125 

Generated at Tue Sep 15 05:16:26 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000