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: 2005/10/07 19:50:18 $
00007   Version:   $Revision: 1.2 $
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     {threshold = itk::NumericTraits<TInput>::Zero;};
00040 
00041   ~SimilarPixelsFunctor() {};
00042 
00043   void SetDistanceThreshold(const TInput &thresh) {threshold = thresh;};
00044   TInput GetDistanceThreshold() {return (threshold);};
00045   
00046   bool operator()(const TInput &a, const TInput &b) {
00047     return (vnl_math_abs(a-b) <= threshold);
00048   };
00049 
00050 protected:
00051   TInput threshold;
00052                             
00053 };
00054 
00055 } // end namespace Functor 
00056 
00057 template <class TInputImage, class TOutputImage, class TMaskImage=TInputImage>
00058 class ITK_EXPORT ScalarConnectedComponentImageFilter :
00059     public ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage,
00060              Functor::SimilarPixelsFunctor<typename TInputImage::ValueType>,
00061                                            TMaskImage> 
00062 {
00063 public:
00065   typedef ScalarConnectedComponentImageFilter Self;
00066   typedef ConnectedComponentFunctorImageFilter<TInputImage,TOutputImage, 
00067              Functor::SimilarPixelsFunctor<typename TInputImage::ValueType>,
00068              TMaskImage> Superclass;
00069   typedef SmartPointer<Self>   Pointer;
00070   typedef SmartPointer<const Self>  ConstPointer;
00071 
00073   itkNewMacro(Self);
00074 
00076   itkTypeMacro(ScalarConnectedComponentImageFilter,ConnectedComponentFunctorImageFilter);
00077 
00078   typedef typename TInputImage::PixelType  InputPixelType;
00079   
00080   virtual void SetDistanceThreshold(const InputPixelType& thresh)
00081     {this->GetFunctor().SetDistanceThreshold(thresh);}
00082 
00083   virtual InputPixelType GetDistanceThreshold()
00084     {return (this->GetFunctor().GetDistanceThreshold());}
00085   
00086 protected:
00087   ScalarConnectedComponentImageFilter() {};
00088   virtual ~ScalarConnectedComponentImageFilter() {};
00089 
00090 private:
00091   ScalarConnectedComponentImageFilter(const Self&); //purposely not implemented
00092   void operator=(const Self&); //purposely not implemented
00093 
00094 };
00095 
00096 } // end namespace itk
00097 
00098 #endif

Generated at Wed May 24 23:59:55 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000