00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkKdTreeGenerator_h
00018 #define __itkKdTreeGenerator_h
00019
00020 #include <vector>
00021 #include "itkMacro.h"
00022 #include "itkPoint.h"
00023 #include "itkSize.h"
00024 #include "itkObject.h"
00025
00026 #include "itkSample.h"
00027 #include "itkSubsample.h"
00028 #include "itkKdTree.h"
00029 #include "itkStatisticsAlgorithm.h"
00030
00031 namespace itk{
00032 namespace Statistics{
00033
00038 template < class TSample >
00039 class ITK_EXPORT KdTreeGenerator : public Object
00040 {
00041 public:
00043 typedef KdTreeGenerator Self ;
00044 typedef Object Superclass ;
00045 typedef SmartPointer<Self> Pointer;
00046
00048 itkTypeMacro(KdTreeGenerator, Object);
00049
00051 itkNewMacro(Self) ;
00052
00054 typedef typename TSample::MeasurementVectorType MeasurementVectorType ;
00055 typedef typename TSample::MeasurementType MeasurementType ;
00056
00057 itkStaticConstMacro(MeasurementVectorSize, unsigned int,
00058 TSample::MeasurementVectorSize);
00059
00060 typedef KdTree< TSample > KdTreeType ;
00061 typedef KdTreeType OutputType ;
00062 typedef typename KdTreeType::Pointer OutputPointer ;
00063 typedef typename KdTreeType::KdTreeNodeType KdTreeNodeType ;
00064
00065 typedef Subsample< TSample > SubsampleType ;
00066 typedef typename SubsampleType::Pointer SubsamplePointer ;
00067
00068 void SetSample(TSample* sample) ;
00069
00070 void SetBucketSize(int size) ;
00071
00072 OutputType* GetOutput()
00073 { return m_Tree.GetPointer() ; }
00074
00075 void GenerateData() ;
00076
00077 unsigned int TotalInstance ;
00078 protected:
00079 KdTreeGenerator() ;
00080 virtual ~KdTreeGenerator() {}
00081 void PrintSelf(std::ostream& os, Indent indent) const ;
00082
00083 SubsamplePointer GetSubsample()
00084 { return m_Subsample ; }
00085
00086 virtual KdTreeNodeType* GenerateNonterminalNode(int beginIndex,
00087 int endIndex,
00088 MeasurementVectorType
00089 &lowerBound,
00090 MeasurementVectorType
00091 &upperBound,
00092 int level) ;
00093
00094 KdTreeNodeType* GenerateTreeLoop(int beginIndex, int endIndex,
00095 MeasurementVectorType &lowerBound,
00096 MeasurementVectorType &upperBound,
00097 int level) ;
00098
00099 void DumpVector(MeasurementVectorType &vec) ;
00100
00101 private:
00102 KdTreeGenerator(const Self&) ;
00103 void operator=(const Self&) ;
00104
00105 TSample* m_SourceSample ;
00106 SubsamplePointer m_Subsample ;
00107 int m_BucketSize ;
00108 OutputPointer m_Tree ;
00109 MeasurementVectorType m_TempLowerBound ;
00110 MeasurementVectorType m_TempUpperBound ;
00111 MeasurementVectorType m_TempMean ;
00112 } ;
00113
00114 }
00115 }
00116
00117 #ifndef ITK_MANUAL_INSTANTIATION
00118 #include "itkKdTreeGenerator.txx"
00119 #endif
00120
00121 #endif
00122
00123
00124
00125