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/03/30 15:36:25 $
00007   Version:   $Revision: 1.5 $
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 __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     {m_Threshold = itk::NumericTraits<TInput>::Zero;};
00040   ~SimilarPixelsFunctor() {};
00041   bool operator!=( const SimilarPixelsFunctor & other ) const
00042   {
00043     if( m_Threshold != other.m_Threshold )
00044         {
00045         return true;
00046         }
00047     return false;
00048    }
00049   bool operator==( const SimilarPixelsFunctor & other ) const
00050   {
00051     return !(*this != other);
00052   }
00053 
00054   void SetDistanceThreshold(const TInput &thresh) {m_Threshold = thresh;};
00055   TInput GetDistanceThreshold() {return (m_Threshold);};
00056   
00057   bool operator()(const TInput &a, const TInput &b) {
00058     return (vnl_math_abs(a-b) <= m_Threshold);
00059   };
00060 
00061 protected:
00062   TInput m_Threshold;
00063                             
00064 };
00065 
00066 } // end namespace Functor 
00067 
00068 template <class TInputImage, class TOutputImage, class TMaskImage=TInputImage>
00069 class ITK_EXPORT ScalarConnectedComponentImageFilter :
00070     public ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage,
00071              Functor::SimilarPixelsFunctor<typename TInputImage::ValueType>,
00072                                            TMaskImage> 
00073 {
00074 public:
00076   typedef ScalarConnectedComponentImageFilter Self;
00077   typedef ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage, 
00078              Functor::SimilarPixelsFunctor<typename TInputImage::ValueType>,
00079              TMaskImage> Superclass;
00080   typedef SmartPointer<Self>   Pointer;
00081   typedef SmartPointer<const Self>  ConstPointer;
00082 
00084   itkNewMacro(Self);
00085 
00087   itkTypeMacro(ScalarConnectedComponentImageFilter,ConnectedComponentFunctorImageFilter);
00088 
00089   typedef typename TInputImage::PixelType  InputPixelType;
00090   
00091   virtual void SetDistanceThreshold(const InputPixelType& thresh)
00092     {this->GetFunctor().SetDistanceThreshold(thresh);}
00093 
00094   virtual InputPixelType GetDistanceThreshold()
00095     {return (this->GetFunctor().GetDistanceThreshold());}
00096 
00097 #ifdef ITK_USE_CONCEPT_CHECKING
00098 
00099   itkConceptMacro(InputEqualityComparableCheck,
00100     (Concept::EqualityComparable<InputPixelType>));
00101   itkConceptMacro(OutputEqualityComparableCheck,
00102     (Concept::EqualityComparable<typename TOutputImage::PixelType>));
00103   itkConceptMacro(MaskEqualityComparableCheck,
00104     (Concept::EqualityComparable<typename TMaskImage::PixelType>));
00105   itkConceptMacro(OutputIncrementDecrementOperatorsCheck,
00106     (Concept::IncrementDecrementOperators<typename TOutputImage::PixelType>));
00107 
00109 #endif
00110 
00111 protected:
00112   ScalarConnectedComponentImageFilter() {};
00113   virtual ~ScalarConnectedComponentImageFilter() {};
00114 
00115 private:
00116   ScalarConnectedComponentImageFilter(const Self&); //purposely not implemented
00117   void operator=(const Self&); //purposely not implemented
00118 
00119 };
00120 
00121 } // end namespace itk
00122 
00123 #endif
00124 

Generated at Sat Sep 2 21:04:39 2006 for ITK by doxygen 1.4.7 written by Dimitri van Heesch, © 1997-2000