00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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) ;
00070
00071 typedef TMeasurementVector MeasurementVectorType ;
00072
00073 struct LessMeasurementVector
00074 {
00075 bool operator()(const MeasurementVectorType& mv1,
00076 const MeasurementVectorType& mv2) const
00077 {
00078
00079
00080 for ( unsigned int i = 0 ;
00081 i < MeasurementVectorTraits::GetLength( &mv1 );
00082 ++i )
00083 {
00084 if (mv1[i] < mv2[i])
00085 {
00086 return true ;
00087 }
00088 }
00089 return false ;
00090 }
00091 } ;
00092
00093 typedef std::map< MeasurementVectorType, MeasurementVectorType, LessMeasurementVector > CacheTableType ;
00094
00095 void SetMaximumConsecutiveFailures(unsigned int number)
00096 { m_MaximumConsecutiveFailures = number ; }
00097
00098 unsigned int GetMaximumConsecutiveFailures()
00099 { return m_MaximumConsecutiveFailures ; }
00100
00101 void SetHitRatioThreshold(float threshold)
00102 { m_HitRatioThreshold = threshold ; }
00103
00104 void SetMaximumEntries(unsigned int number)
00105 { m_MaximumEntries = number ; }
00106
00107 unsigned int GetMaximumEntries()
00108 { return m_MaximumEntries ; }
00109
00110 bool SetMeasurementVector(MeasurementVectorType& source,
00111 MeasurementVectorType& target) ;
00112
00113 bool GetMeasurementVector(MeasurementVectorType& source,
00114 MeasurementVectorType& target) ;
00115
00116 bool IsFull() ;
00117
00118 void DestroyCacheTable() ;
00119
00120 protected:
00121 MeanShiftModeCacheMethod() ;
00122 virtual ~MeanShiftModeCacheMethod() ;
00123 void PrintSelf(std::ostream& os, Indent indent) const;
00124
00125 private:
00126 unsigned int m_MaximumEntries ;
00127 float m_HitRatioThreshold ;
00128 unsigned int m_MaximumConsecutiveFailures ;
00129
00130 unsigned int m_NumberOfRequests ;
00131 unsigned int m_ConsecutiveFailures ;
00132 unsigned int m_HitsSuccess ;
00133
00134 unsigned long m_TotalHitsSuccess ;
00135 unsigned long m_TotalHitsFailure ;
00136
00137 unsigned long m_TotalTableSize ;
00138 unsigned int m_TimesOfRebuilding ;
00139
00140 unsigned int m_TimesOfRebuildingByHitRatio ;
00141 unsigned int m_TimesOfRebuildingByConsecutiveFailures ;
00142
00143 CacheTableType m_CacheTable ;
00144 } ;
00145
00146 }
00147 }
00148
00149 #ifndef ITK_MANUAL_INSTANTIATION
00150 #include "itkMeanShiftModeCacheMethod.txx"
00151 #endif
00152
00153 #endif
00154