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

itkScalarConnectedComponentImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkScalarConnectedComponentImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2006/09/26 12:05:05 $
00007   Version:   $Revision: 1.6 $
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 __itkScalarConnectedComponentImageFilter_h
00021 #define __itkScalarConnectedComponentImageFilter_h
00022 
00023 #include "vnl/vnl_math.h"
00024 #include "itkNumericTraits.h"
00025 #include "itkConnectedComponentFunctorImageFilter.h"
00026 
00027 namespace itk
00028 {
00029 
00038 namespace Functor {  
00039   
00040 template<class TInput>
00041 class SimilarPixelsFunctor
00042 {
00043 public:
00044   SimilarPixelsFunctor()
00045     {m_Threshold = itk::NumericTraits<TInput>::Zero;};
00046   ~SimilarPixelsFunctor() {};
00047   bool operator!=( const SimilarPixelsFunctor & other ) const
00048   {
00049     if( m_Threshold != other.m_Threshold )
00050         {
00051         return true;
00052         }
00053     return false;
00054    }
00055   bool operator==( const SimilarPixelsFunctor & other ) const
00056   {
00057     return !(*this != other);
00058   }
00059 
00060   void SetDistanceThreshold(const TInput &thresh) {m_Threshold = thresh;};
00061   TInput GetDistanceThreshold() {return (m_Threshold);};
00062   
00063   bool operator()(const TInput &a, const TInput &b) {
00064     return (vnl_math_abs(a-b) <= m_Threshold);
00065   };
00066 
00067 protected:
00068   TInput m_Threshold;
00069                             
00070 };
00071 
00072 } // end namespace Functor 
00073 
00074 template <class TInputImage, class TOutputImage, class TMaskImage=TInputImage>
00075 class ITK_EXPORT ScalarConnectedComponentImageFilter :
00076     public ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage,
00077              Functor::SimilarPixelsFunctor<typename TInputImage::ValueType>,
00078                                            TMaskImage> 
00079 {
00080 public:
00082   typedef ScalarConnectedComponentImageFilter Self;
00083   typedef ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage, 
00084              Functor::SimilarPixelsFunctor<typename TInputImage::ValueType>,
00085              TMaskImage> Superclass;
00086   typedef SmartPointer<Self>   Pointer;
00087   typedef SmartPointer<const Self>  ConstPointer;
00088 
00090   itkNewMacro(Self);
00091 
00093   itkTypeMacro(ScalarConnectedComponentImageFilter,ConnectedComponentFunctorImageFilter);
00094 
00095   typedef typename TInputImage::PixelType  InputPixelType;
00096   
00097   virtual void SetDistanceThreshold(const InputPixelType& thresh)
00098     {this->GetFunctor().SetDistanceThreshold(thresh);}
00099 
00100   virtual InputPixelType GetDistanceThreshold()
00101     {return (this->GetFunctor().GetDistanceThreshold());}
00102 
00103 #ifdef ITK_USE_CONCEPT_CHECKING
00104 
00105   itkConceptMacro(InputEqualityComparableCheck,
00106     (Concept::EqualityComparable<InputPixelType>));
00107   itkConceptMacro(OutputEqualityComparableCheck,
00108     (Concept::EqualityComparable<typename TOutputImage::PixelType>));
00109   itkConceptMacro(MaskEqualityComparableCheck,
00110     (Concept::EqualityComparable<typename TMaskImage::PixelType>));
00111   itkConceptMacro(OutputIncrementDecrementOperatorsCheck,
00112     (Concept::IncrementDecrementOperators<typename TOutputImage::PixelType>));
00113 
00115 #endif
00116 
00117 protected:
00118   ScalarConnectedComponentImageFilter() {};
00119   virtual ~ScalarConnectedComponentImageFilter() {};
00120 
00121 private:
00122   ScalarConnectedComponentImageFilter(const Self&); //purposely not implemented
00123   void operator=(const Self&); //purposely not implemented
00124 
00125 };
00126 
00127 } // end namespace itk
00128 
00129 #endif
00130 

Generated at Tue Jul 29 22:06:43 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000