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: 2009-07-05 17:36:22 $
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 __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     {
00046     m_Threshold = NumericTraits<TInput>::Zero;
00047     }
00048 
00049   ~SimilarPixelsFunctor() 
00050     {
00051     }
00052 
00053   bool operator!=( const SimilarPixelsFunctor & other ) const
00054     {
00055     if( m_Threshold != other.m_Threshold )
00056       {
00057       return true;
00058       }
00059     return false;
00060     }
00061 
00062   bool operator==( const SimilarPixelsFunctor & other ) const
00063     {
00064     return !(*this != other);
00065     }
00066 
00067   void SetDistanceThreshold(const TInput &thresh) 
00068     {
00069     m_Threshold = thresh;
00070     }
00071 
00072   TInput GetDistanceThreshold() 
00073     {
00074     return (m_Threshold);
00075     }
00076   
00077   bool operator()(const TInput &a, const TInput &b) const
00078     {
00079     typedef typename NumericTraits<TInput>::RealType InputRealType;
00080     TInput absDifference = static_cast<TInput>( vnl_math_abs( 
00081                            static_cast<InputRealType>(a)
00082                            - static_cast<InputRealType>(b) ) );
00083     if( absDifference <= m_Threshold )
00084       {
00085       return true;
00086       }
00087     else
00088       {
00089       return false;
00090       }
00091     }
00092 
00093 protected:
00094   TInput m_Threshold;
00095                             
00096 };
00097 
00098 } // end namespace Functor 
00099 
00100 template <class TInputImage, class TOutputImage, class TMaskImage=TInputImage>
00101 class ITK_EXPORT ScalarConnectedComponentImageFilter :
00102     public ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage,
00103              Functor::SimilarPixelsFunctor<typename TInputImage::ValueType>,
00104                                            TMaskImage> 
00105 {
00106 public:
00108   typedef ScalarConnectedComponentImageFilter Self;
00109   typedef ConnectedComponentFunctorImageFilter<
00110     TInputImage,TOutputImage, 
00111     Functor::SimilarPixelsFunctor<typename TInputImage::ValueType>,
00112     TMaskImage>                               Superclass;
00113   typedef SmartPointer<Self>                  Pointer;
00114   typedef SmartPointer<const Self>            ConstPointer;
00115 
00117   itkNewMacro(Self);
00118 
00120   itkTypeMacro(ScalarConnectedComponentImageFilter,ConnectedComponentFunctorImageFilter);
00121 
00122   typedef typename TInputImage::PixelType  InputPixelType;
00123   
00124   virtual void SetDistanceThreshold(const InputPixelType& thresh)
00125     {this->GetFunctor().SetDistanceThreshold(thresh);}
00126 
00127   virtual InputPixelType GetDistanceThreshold()
00128     {return (this->GetFunctor().GetDistanceThreshold());}
00129 
00130 #ifdef ITK_USE_CONCEPT_CHECKING
00131 
00132   itkConceptMacro(InputEqualityComparableCheck,
00133     (Concept::EqualityComparable<InputPixelType>));
00134   itkConceptMacro(OutputEqualityComparableCheck,
00135     (Concept::EqualityComparable<typename TOutputImage::PixelType>));
00136   itkConceptMacro(MaskEqualityComparableCheck,
00137     (Concept::EqualityComparable<typename TMaskImage::PixelType>));
00138   itkConceptMacro(OutputIncrementDecrementOperatorsCheck,
00139     (Concept::IncrementDecrementOperators<typename TOutputImage::PixelType>));
00140 
00142 #endif
00143 
00144 protected:
00145   ScalarConnectedComponentImageFilter() {};
00146   virtual ~ScalarConnectedComponentImageFilter() {};
00147 
00148 private:
00149   ScalarConnectedComponentImageFilter(const Self&); //purposely not implemented
00150   void operator=(const Self&); //purposely not implemented
00151 
00152 };
00153 
00154 } // end namespace itk
00155 
00156 #endif
00157 

Generated at Mon Jul 12 2010 19:45:03 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000