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: 2008-10-17 20:49:55 $
00007   Version:   $Revision: 1.7 $
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     {
00065     return (vnl_math_abs(a-b) <= m_Threshold);
00066     }
00067 
00068 protected:
00069   TInput m_Threshold;
00070                             
00071 };
00072 
00073 } // end namespace Functor 
00074 
00075 template <class TInputImage, class TOutputImage, class TMaskImage=TInputImage>
00076 class ITK_EXPORT ScalarConnectedComponentImageFilter :
00077     public ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage,
00078              Functor::SimilarPixelsFunctor<typename TInputImage::ValueType>,
00079                                            TMaskImage> 
00080 {
00081 public:
00083   typedef ScalarConnectedComponentImageFilter Self;
00084   typedef ConnectedComponentFunctorImageFilter<
00085     TInputImage,TOutputImage, 
00086     Functor::SimilarPixelsFunctor<typename TInputImage::ValueType>,
00087     TMaskImage>                               Superclass;
00088   typedef SmartPointer<Self>                  Pointer;
00089   typedef SmartPointer<const Self>            ConstPointer;
00090 
00092   itkNewMacro(Self);
00093 
00095   itkTypeMacro(ScalarConnectedComponentImageFilter,ConnectedComponentFunctorImageFilter);
00096 
00097   typedef typename TInputImage::PixelType  InputPixelType;
00098   
00099   virtual void SetDistanceThreshold(const InputPixelType& thresh)
00100     {this->GetFunctor().SetDistanceThreshold(thresh);}
00101 
00102   virtual InputPixelType GetDistanceThreshold()
00103     {return (this->GetFunctor().GetDistanceThreshold());}
00104 
00105 #ifdef ITK_USE_CONCEPT_CHECKING
00106 
00107   itkConceptMacro(InputEqualityComparableCheck,
00108     (Concept::EqualityComparable<InputPixelType>));
00109   itkConceptMacro(OutputEqualityComparableCheck,
00110     (Concept::EqualityComparable<typename TOutputImage::PixelType>));
00111   itkConceptMacro(MaskEqualityComparableCheck,
00112     (Concept::EqualityComparable<typename TMaskImage::PixelType>));
00113   itkConceptMacro(OutputIncrementDecrementOperatorsCheck,
00114     (Concept::IncrementDecrementOperators<typename TOutputImage::PixelType>));
00115 
00117 #endif
00118 
00119 protected:
00120   ScalarConnectedComponentImageFilter() {};
00121   virtual ~ScalarConnectedComponentImageFilter() {};
00122 
00123 private:
00124   ScalarConnectedComponentImageFilter(const Self&); //purposely not implemented
00125   void operator=(const Self&); //purposely not implemented
00126 
00127 };
00128 
00129 } // end namespace itk
00130 
00131 #endif
00132 

Generated at Sat Feb 28 13:28:29 2009 for ITK by doxygen 1.5.6 written by Dimitri van Heesch, © 1997-2000