18 #ifndef itkKdTreeBasedKmeansEstimator_h
19 #define itkKdTreeBasedKmeansEstimator_h
22 #include <unordered_map>
73 template <
typename TKdTree>
129 itkSetMacro(MaximumIteration,
int);
130 itkGetConstMacro(MaximumIteration,
int);
135 itkSetMacro(CentroidPositionChangesThreshold,
double);
136 itkGetConstMacro(CentroidPositionChangesThreshold,
double);
140 SetKdTree(TKdTree * tree);
148 itkGetConstMacro(CurrentIteration,
int);
149 itkGetConstMacro(CentroidPositionChanges,
double);
160 itkSetMacro(UseClusterLabels,
bool);
161 itkGetConstMacro(UseClusterLabels,
bool);
168 PrintSelf(std::ostream & os,
Indent indent)
const override;
196 return static_cast<int>(m_Candidates.size());
205 m_Candidates.resize(centroids.size());
206 for (
unsigned int i = 0; i < centroids.size(); i++)
213 m_Candidates[i] = candidate;
224 centroids.resize(this->
Size());
225 for (i = 0; i < (
unsigned int)this->
Size(); i++)
227 centroids[i] = m_Candidates[i].Centroid;
238 for (i = 0; i < (
unsigned int)this->
Size(); i++)
240 if (m_Candidates[i].
Size > 0)
242 for (j = 0; j < m_MeasurementVectorSize; j++)
244 m_Candidates[i].Centroid[j] = m_Candidates[i].WeightedCentroid[j] / double(m_Candidates[i].
Size);
267 GetSumOfSquaredPositionChanges(InternalParametersType & previous, InternalParametersType & current);
272 GetClosestCandidate(ParameterType & measurements, std::vector<int> & validIndexes);
276 IsFarther(ParameterType & pointA,
277 ParameterType & pointB,
278 MeasurementVectorType & lowerBound,
279 MeasurementVectorType & upperBound);
284 Filter(KdTreeNodeType * node,
285 std::vector<int> validIndexes,
286 MeasurementVectorType & lowerBound,
287 MeasurementVectorType & upperBound);
291 CopyParameters(InternalParametersType & source, InternalParametersType & target);
295 CopyParameters(ParametersType & source, InternalParametersType & target);
299 CopyParameters(InternalParametersType & source, ParametersType & target);
303 GetPoint(ParameterType & point, MeasurementVectorType measurements);
306 PrintPoint(ParameterType & point);
310 int m_CurrentIteration{ 0 };
313 int m_MaximumIteration{ 100 };
316 double m_CentroidPositionChanges{ 0.0 };
320 double m_CentroidPositionChangesThreshold{ 0.0 };
335 bool m_UseClusterLabels{
false };
336 bool m_GenerateClusterLabels{
false };
344 #ifndef ITK_MANUAL_INSTANTIATION
345 # include "itkKdTreeBasedKmeansEstimator.hxx"