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
00062 template < class TSample >
00063 class ITK_EXPORT KdTreeGenerator : public Object
00064 {
00065 public:
00067 typedef KdTreeGenerator Self ;
00068 typedef Object Superclass ;
00069 typedef SmartPointer<Self> Pointer;
00070 typedef SmartPointer<const Self> ConstPointer;
00071
00073 itkTypeMacro(KdTreeGenerator, Object);
00074
00076 itkNewMacro(Self) ;
00077
00079 typedef typename TSample::MeasurementVectorType MeasurementVectorType ;
00080 typedef typename TSample::MeasurementType MeasurementType ;
00081
00082 itkStaticConstMacro(MeasurementVectorSize, unsigned int,
00083 TSample::MeasurementVectorSize);
00084
00086 typedef KdTree< TSample > KdTreeType ;
00087
00089 typedef KdTreeType OutputType ;
00090
00092 typedef typename KdTreeType::Pointer OutputPointer ;
00093
00095 typedef typename KdTreeType::KdTreeNodeType KdTreeNodeType ;
00096
00098 typedef Subsample< TSample > SubsampleType ;
00099
00101 typedef typename SubsampleType::Pointer SubsamplePointer ;
00102
00104 void SetSample(TSample* sample) ;
00105
00108 void SetBucketSize(int size) ;
00109
00111 OutputPointer GetOutput()
00112 { return m_Tree ; }
00113
00115 void Update()
00116 { this->GenerateData() ; }
00117
00119 void GenerateData() ;
00120
00122 unsigned int TotalInstance ;
00123
00124 protected:
00126 KdTreeGenerator() ;
00127
00129 virtual ~KdTreeGenerator() {}
00130
00131 void PrintSelf(std::ostream& os, Indent indent) const ;
00132
00134 SubsamplePointer GetSubsample()
00135 { return m_Subsample ; }
00136
00138 virtual KdTreeNodeType* GenerateNonterminalNode(int beginIndex,
00139 int endIndex,
00140 MeasurementVectorType
00141 &lowerBound,
00142 MeasurementVectorType
00143 &upperBound,
00144 int level) ;
00145
00147 KdTreeNodeType* GenerateTreeLoop(int beginIndex, int endIndex,
00148 MeasurementVectorType &lowerBound,
00149 MeasurementVectorType &upperBound,
00150 int level) ;
00151
00152 private:
00153 KdTreeGenerator(const Self&) ;
00154 void operator=(const Self&) ;
00155
00157 TSample* m_SourceSample ;
00158
00162 SubsamplePointer m_Subsample ;
00163
00166 int m_BucketSize ;
00167
00169 OutputPointer m_Tree ;
00170
00172 MeasurementVectorType m_TempLowerBound ;
00173
00175 MeasurementVectorType m_TempUpperBound ;
00176
00178 MeasurementVectorType m_TempMean ;
00179 } ;
00180
00181 }
00182 }
00183
00184 #ifndef ITK_MANUAL_INSTANTIATION
00185 #include "itkKdTreeGenerator.txx"
00186 #endif
00187
00188 #endif
00189
00190
00191
00192