ITK  6.0.0
Insight Toolkit
itkKdTreeGenerator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkKdTreeGenerator_h
19 #define itkKdTreeGenerator_h
20 
21 #include <vector>
22 
23 #include "itkKdTree.h"
24 #include "itkStatisticsAlgorithm.h"
25 
26 namespace itk
27 {
28 namespace Statistics
29 {
70 template <typename TSample>
71 class ITK_TEMPLATE_EXPORT KdTreeGenerator : public Object
72 {
73 public:
74  ITK_DISALLOW_COPY_AND_MOVE(KdTreeGenerator);
75 
78  using Superclass = Object;
81 
83  itkOverrideGetNameOfClassMacro(KdTreeGenerator);
84 
86  itkNewMacro(Self);
87 
89  using MeasurementVectorType = typename TSample::MeasurementVectorType;
90  using MeasurementType = typename TSample::MeasurementType;
91 
93  using MeasurementVectorSizeType = unsigned int;
94 
97 
100 
103 
106 
109 
112 
114  void
115  SetSample(TSample * sample);
116  itkGetConstMacro(SourceSample, TSample *);
121  void
122  SetBucketSize(unsigned int size);
123  itkGetConstMacro(BucketSize, unsigned int);
129  {
130  return m_Tree;
131  }
132 
134  void
136  {
137  this->GenerateData();
138  }
139 
141  void
142  GenerateData();
143 
146  itkGetConstMacro(MeasurementVectorSize, unsigned int);
147 
148 protected:
150  KdTreeGenerator();
151 
153  ~KdTreeGenerator() override = default;
154 
155  void
156  PrintSelf(std::ostream & os, Indent indent) const override;
157 
159  SubsamplePointer
161  {
162  return m_Subsample;
163  }
164 
166  virtual KdTreeNodeType *
167  GenerateNonterminalNode(unsigned int beginIndex,
168  unsigned int endIndex,
169  MeasurementVectorType & lowerBound,
170  MeasurementVectorType & upperBound,
171  unsigned int level);
172 
174  KdTreeNodeType *
175  GenerateTreeLoop(unsigned int beginIndex,
176  unsigned int endIndex,
177  MeasurementVectorType & lowerBound,
178  MeasurementVectorType & upperBound,
179  unsigned int level);
180 
181 private:
183  TSample * m_SourceSample{};
184 
188  SubsamplePointer m_Subsample{};
189 
192  unsigned int m_BucketSize{};
193 
195  OutputPointer m_Tree{};
196 
198  MeasurementVectorType m_TempLowerBound{};
199 
201  MeasurementVectorType m_TempUpperBound{};
202 
204  MeasurementVectorType m_TempMean{};
205 
207  MeasurementVectorSizeType m_MeasurementVectorSize{};
208 }; // end of class
209 } // end of namespace Statistics
210 } // end of namespace itk
211 
212 #ifndef ITK_MANUAL_INSTANTIATION
213 # include "itkKdTreeGenerator.hxx"
214 #endif
215 
216 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::Statistics::KdTree
This class provides methods for k-nearest neighbor search and related data structures for a k-d tree.
Definition: itkKdTree.h:527
itk::Statistics::KdTreeGenerator::KdTreeNodeType
typename KdTreeType::KdTreeNodeType KdTreeNodeType
Definition: itkKdTreeGenerator.h:105
itk::Statistics::KdTreeGenerator::SubsamplePointer
typename SubsampleType::Pointer SubsamplePointer
Definition: itkKdTreeGenerator.h:111
itkStatisticsAlgorithm.h
itk::Statistics::KdTreeGenerator::GetSubsample
SubsamplePointer GetSubsample()
Definition: itkKdTreeGenerator.h:160
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Statistics::KdTreeGenerator::MeasurementVectorType
typename TSample::MeasurementVectorType MeasurementVectorType
Definition: itkKdTreeGenerator.h:89
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::Statistics::Subsample
This class stores a subset of instance identifiers from another sample object. You can create a subsa...
Definition: itkSubsample.h:42
itk::Statistics::KdTreeGenerator::OutputPointer
typename KdTreeType::Pointer OutputPointer
Definition: itkKdTreeGenerator.h:102
itkKdTree.h
itk::Statistics::KdTreeGenerator::MeasurementType
typename TSample::MeasurementType MeasurementType
Definition: itkKdTreeGenerator.h:90
itk::Statistics::KdTreeGenerator::Update
void Update()
Definition: itkKdTreeGenerator.h:135
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::Statistics::KdTreeGenerator
This class generates a KdTree object without centroid information.
Definition: itkKdTreeGenerator.h:71
itk::Statistics::KdTreeGenerator::GetOutput
OutputPointer GetOutput()
Definition: itkKdTreeGenerator.h:128
itk::Statistics::KdTreeNode
This class defines the interface of its derived classes.
Definition: itkKdTree.h:65
itk::Statistics::KdTreeGenerator::MeasurementVectorSizeType
unsigned int MeasurementVectorSizeType
Definition: itkKdTreeGenerator.h:93