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
00025 namespace itk{
00026 namespace Statistics{
00027
00049 template< class TMeasurementVector >
00050 class MeanShiftModeCacheMethod :
00051 public Object
00052 {
00053 public:
00055 typedef MeanShiftModeCacheMethod Self;
00056 typedef Object Superclass ;
00057 typedef SmartPointer<Self> Pointer;
00058 typedef SmartPointer<const Self> ConstPointer;
00059
00061 itkTypeMacro(MeanShiftModeCacheMethod, Object);
00062 itkNewMacro(Self) ;
00063
00064 typedef TMeasurementVector MeasurementVectorType ;
00065
00066 itkStaticConstMacro(MeasurementVectorSize, unsigned int,
00067 MeasurementVectorType::Length) ;
00068
00069 struct LessMeasurementVector
00070 {
00071 bool operator()(const MeasurementVectorType& mv1,
00072 const MeasurementVectorType& mv2) const
00073 {
00074 for ( unsigned int i = 0 ;
00075 i < itkGetStaticConstMacro( MeasurementVectorSize ) ;
00076 ++i )
00077 {
00078 if (mv1[i] < mv2[i])
00079 {
00080 return true ;
00081 }
00082 }
00083 return false ;
00084 }
00085 } ;
00086
00087 typedef std::map< MeasurementVectorType, MeasurementVectorType, LessMeasurementVector > CacheTableType ;
00088
00089 void SetMaximumConsecutiveFailures(unsigned int number)
00090 { m_MaximumConsecutiveFailures = number ; }
00091
00092 unsigned int GetMaximumConsecutiveFailures()
00093 { return m_MaximumConsecutiveFailures ; }
00094
00095 void SetHitRatioThreshold(float threshold)
00096 { m_HitRatioThreshold = threshold ; }
00097
00098 void SetMaximumEntries(unsigned int number)
00099 { m_MaximumEntries = number ; }
00100
00101 unsigned int GetMaximumEntries()
00102 { return m_MaximumEntries ; }
00103
00104 bool SetMeasurementVector(MeasurementVectorType& source,
00105 MeasurementVectorType& target) ;
00106
00107 bool GetMeasurementVector(MeasurementVectorType& source,
00108 MeasurementVectorType& target) ;
00109
00110 bool IsFull() ;
00111
00112 void DestroyCacheTable() ;
00113
00114 protected:
00115 MeanShiftModeCacheMethod() ;
00116 virtual ~MeanShiftModeCacheMethod() ;
00117 void PrintSelf(std::ostream& os, Indent indent) const;
00118
00119 private:
00120 unsigned int m_MaximumEntries ;
00121 float m_HitRatioThreshold ;
00122 unsigned int m_MaximumConsecutiveFailures ;
00123
00124 unsigned int m_NumberOfRequests ;
00125 unsigned int m_ConsecutiveFailures ;
00126 unsigned int m_HitsSuccess ;
00127
00128 unsigned long m_TotalHitsSuccess ;
00129 unsigned long m_TotalHitsFailure ;
00130
00131 unsigned long m_TotalTableSize ;
00132 unsigned int m_TimesOfRebuilding ;
00133
00134 unsigned int m_TimesOfRebuildingByHitRatio ;
00135 unsigned int m_TimesOfRebuildingByConsecutiveFailures ;
00136
00137 CacheTableType m_CacheTable ;
00138 } ;
00139
00140 }
00141 }
00142
00143 #ifndef ITK_MANUAL_INSTANTIATION
00144 #include "itkMeanShiftModeCacheMethod.txx"
00145 #endif
00146
00147 #endif
00148