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: 2010-03-02 03:40:37 $
00007   Version:   $Revision: 1.11 $
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 
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 } // end namespace Functor 
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&); //purposely not implemented
00127   void operator=(const Self&); //purposely not implemented
00128 
00129 };
00130 
00131 } // end namespace itk
00132 
00133 #endif
00134 

Generated at Mon Jul 12 2010 20:08:06 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000