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);
162 itkBooleanMacro(UseClusterLabels);
169 PrintSelf(std::ostream & os,
Indent indent)
const override;
197 return static_cast<int>(m_Candidates.size());
206 m_Candidates.resize(centroids.size());
207 for (
unsigned int i = 0; i < centroids.size(); ++i)
214 m_Candidates[i] = candidate;
223 centroids.resize(this->
Size());
224 for (
unsigned int i = 0; i < static_cast<unsigned int>(this->
Size()); ++i)
226 centroids[i] = m_Candidates[i].Centroid;
236 for (
unsigned int i = 0; i < static_cast<unsigned int>(this->
Size()); ++i)
238 if (m_Candidates[i].
Size > 0)
240 for (
unsigned int j = 0; j < m_MeasurementVectorSize; ++j)
242 m_Candidates[i].Centroid[j] =
243 m_Candidates[i].WeightedCentroid[j] / static_cast<double>(m_Candidates[i].
Size);
254 return m_Candidates[index];
271 GetSumOfSquaredPositionChanges(InternalParametersType & previous, InternalParametersType & current);
276 GetClosestCandidate(ParameterType & measurements, std::vector<int> & validIndexes);
280 IsFarther(ParameterType & pointA,
281 ParameterType & pointB,
282 MeasurementVectorType & lowerBound,
283 MeasurementVectorType & upperBound);
288 Filter(KdTreeNodeType * node,
289 std::vector<int> validIndexes,
290 MeasurementVectorType & lowerBound,
291 MeasurementVectorType & upperBound);
295 CopyParameters(InternalParametersType & source, InternalParametersType & target);
299 CopyParameters(ParametersType & source, InternalParametersType & target);
303 CopyParameters(InternalParametersType & source, ParametersType & target);
307 GetPoint(ParameterType &
point, MeasurementVectorType measurements);
310 PrintPoint(ParameterType &
point);
314 int m_CurrentIteration{ 0 };
317 int m_MaximumIteration{ 100 };
320 double m_CentroidPositionChanges{ 0.0 };
324 double m_CentroidPositionChangesThreshold{ 0.0 };
339 bool m_UseClusterLabels{
false };
340 bool m_GenerateClusterLabels{
false };
348 #ifndef ITK_MANUAL_INSTANTIATION
349 # include "itkKdTreeBasedKmeansEstimator.hxx"