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

itkMeanShiftModeCacheMethod.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkMeanShiftModeCacheMethod.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/07/26 15:55:00 $
00007   Version:   $Revision: 1.5 $
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      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 
00018 #ifndef __itkMeanShiftModeCacheMethod_h
00019 #define __itkMeanShiftModeCacheMethod_h
00020 
00021 #include <map>
00022 #include "itkMacro.h"
00023 #include "itkObject.h"
00024 #include "itkMeasurementVectorTraits.h"
00025 
00026 namespace itk{ 
00027 namespace Statistics{
00028   
00056 template< class TMeasurementVector >
00057 class MeanShiftModeCacheMethod :
00058     public Object
00059 {
00060 public:
00062   typedef MeanShiftModeCacheMethod Self;
00063   typedef Object Superclass ;
00064   typedef SmartPointer<Self> Pointer;
00065   typedef SmartPointer<const Self> ConstPointer;
00066 
00068   itkTypeMacro(MeanShiftModeCacheMethod, Object);
00069   itkNewMacro(Self) ;
00071 
00072   typedef TMeasurementVector MeasurementVectorType ;
00073 
00074   struct LessMeasurementVector
00075   {
00076     bool operator()(const MeasurementVectorType& mv1, 
00077                     const MeasurementVectorType& mv2) const
00078     {
00079       // It is assumed that mv1 and mv2 are of the same length. For efficieny,
00080       // no checking is performed here.
00081       for ( unsigned int i = 0 ; 
00082             i < MeasurementVectorTraits::GetLength( &mv1 );
00083             ++i )
00084         {
00085         if (mv1[i] < mv2[i])
00086           {
00087           return true ;
00088           }
00089         }
00090       return false ;
00091     }
00092   } ; // end of struct
00093 
00094   typedef std::map< MeasurementVectorType, MeasurementVectorType, LessMeasurementVector > CacheTableType ;
00095 
00096   void SetMaximumConsecutiveFailures(unsigned int number)
00097   { m_MaximumConsecutiveFailures = number ; }
00098 
00099   unsigned int GetMaximumConsecutiveFailures()
00100   { return m_MaximumConsecutiveFailures ; }
00101   
00102   void SetHitRatioThreshold(float threshold)
00103   { m_HitRatioThreshold = threshold ; }
00104 
00105   void SetMaximumEntries(unsigned int number)
00106   { m_MaximumEntries = number ; }
00107 
00108   unsigned int GetMaximumEntries()
00109   { return m_MaximumEntries ; }
00110 
00111   bool SetMeasurementVector(MeasurementVectorType& source, 
00112                             MeasurementVectorType& target) ;
00113 
00114   bool GetMeasurementVector(MeasurementVectorType& source,
00115                             MeasurementVectorType& target) ;
00116 
00117   bool IsFull() ;
00118 
00119   void DestroyCacheTable() ;
00120 
00121 protected:
00122   MeanShiftModeCacheMethod() ;
00123   virtual ~MeanShiftModeCacheMethod() ;
00124   void PrintSelf(std::ostream& os, Indent indent) const;
00125 
00126 private:
00127   unsigned int m_MaximumEntries ;
00128   float m_HitRatioThreshold ;
00129   unsigned int m_MaximumConsecutiveFailures ;
00130 
00131   unsigned int m_NumberOfRequests ;
00132   unsigned int m_ConsecutiveFailures ;
00133   unsigned int m_HitsSuccess ;
00134 
00135   unsigned long m_TotalHitsSuccess ;
00136   unsigned long m_TotalHitsFailure ;
00137 
00138   unsigned long m_TotalTableSize ;
00139   unsigned int m_TimesOfRebuilding ;
00140 
00141   unsigned int m_TimesOfRebuildingByHitRatio ;
00142   unsigned int m_TimesOfRebuildingByConsecutiveFailures ;
00143 
00144   CacheTableType m_CacheTable ;
00145 } ; // end of class
00146     
00147 } // end of namespace Statistics 
00148 } // end of namespace itk 
00149 
00150 #ifndef ITK_MANUAL_INSTANTIATION
00151 #include "itkMeanShiftModeCacheMethod.txx"
00152 #endif
00153 
00154 #endif
00155 
00156 

Generated at Wed Nov 5 22:48:12 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000