ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkKdTreeGenerator_h 00019 #define __itkKdTreeGenerator_h 00020 00021 #include <vector> 00022 00023 #include "itkKdTree.h" 00024 #include "itkStatisticsAlgorithm.h" 00025 00026 namespace itk 00027 { 00028 namespace Statistics 00029 { 00069 template< class TSample > 00070 class ITK_EXPORT KdTreeGenerator:public Object 00071 { 00072 public: 00074 typedef KdTreeGenerator Self; 00075 typedef Object Superclass; 00076 typedef SmartPointer< Self > Pointer; 00077 typedef SmartPointer< const Self > ConstPointer; 00078 00080 itkTypeMacro(KdTreeGenerator, Object); 00081 00083 itkNewMacro(Self); 00084 00086 typedef typename TSample::MeasurementVectorType MeasurementVectorType; 00087 typedef typename TSample::MeasurementType MeasurementType; 00088 00090 typedef unsigned int MeasurementVectorSizeType; 00091 00093 typedef KdTree< TSample > KdTreeType; 00094 00096 typedef KdTreeType OutputType; 00097 00099 typedef typename KdTreeType::Pointer OutputPointer; 00100 00102 typedef typename KdTreeType::KdTreeNodeType KdTreeNodeType; 00103 00105 typedef Subsample< TSample > SubsampleType; 00106 00108 typedef typename SubsampleType::Pointer SubsamplePointer; 00109 00111 void SetSample(TSample *sample); 00112 00115 void SetBucketSize(unsigned int size); 00116 00118 OutputPointer GetOutput() 00119 { 00120 return m_Tree; 00121 } 00122 00124 void Update() 00125 { 00126 this->GenerateData(); 00127 } 00128 00130 void GenerateData(); 00131 00134 itkGetConstMacro(MeasurementVectorSize, unsigned int); 00135 protected: 00136 00138 KdTreeGenerator(); 00139 00141 virtual ~KdTreeGenerator() {} 00142 00143 void PrintSelf(std::ostream & os, Indent indent) const; 00144 00146 SubsamplePointer GetSubsample() 00147 { 00148 return m_Subsample; 00149 } 00150 00152 virtual KdTreeNodeType * GenerateNonterminalNode(unsigned int beginIndex, 00153 unsigned int endIndex, 00154 MeasurementVectorType 00155 & lowerBound, 00156 MeasurementVectorType 00157 & upperBound, 00158 unsigned int level); 00159 00161 KdTreeNodeType * GenerateTreeLoop(unsigned int beginIndex, unsigned int endIndex, 00162 MeasurementVectorType & lowerBound, 00163 MeasurementVectorType & upperBound, 00164 unsigned int level); 00165 00166 private: 00167 KdTreeGenerator(const Self &); //purposely not implemented 00168 void operator=(const Self &); //purposely not implemented 00169 00171 TSample *m_SourceSample; 00172 00176 SubsamplePointer m_Subsample; 00177 00180 unsigned int m_BucketSize; 00181 00183 OutputPointer m_Tree; 00184 00186 MeasurementVectorType m_TempLowerBound; 00187 00189 MeasurementVectorType m_TempUpperBound; 00190 00192 MeasurementVectorType m_TempMean; 00193 00195 MeasurementVectorSizeType m_MeasurementVectorSize; 00196 }; // end of class 00197 } // end of namespace Statistics 00198 } // end of namespace itk 00199 00200 #ifndef ITK_MANUAL_INSTANTIATION 00201 #include "itkKdTreeGenerator.hxx" 00202 #endif 00203 00204 #endif 00205