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;
225 centroids.resize(this->
Size());
226 for (i = 0; i < static_cast<unsigned int>(this->
Size()); ++i)
228 centroids[i] = m_Candidates[i].Centroid;
239 for (i = 0; i < static_cast<unsigned int>(this->
Size()); ++i)
241 if (m_Candidates[i].
Size > 0)
243 for (j = 0; j < m_MeasurementVectorSize; ++j)
245 m_Candidates[i].Centroid[j] =
246 m_Candidates[i].WeightedCentroid[j] / static_cast<double>(m_Candidates[i].
Size);
269 GetSumOfSquaredPositionChanges(InternalParametersType & previous, InternalParametersType & current);
274 GetClosestCandidate(ParameterType & measurements, std::vector<int> & validIndexes);
278 IsFarther(ParameterType & pointA,
279 ParameterType & pointB,
280 MeasurementVectorType & lowerBound,
281 MeasurementVectorType & upperBound);
286 Filter(KdTreeNodeType * node,
287 std::vector<int> validIndexes,
288 MeasurementVectorType & lowerBound,
289 MeasurementVectorType & upperBound);
293 CopyParameters(InternalParametersType & source, InternalParametersType & target);
297 CopyParameters(ParametersType & source, InternalParametersType & target);
301 CopyParameters(InternalParametersType & source, ParametersType & target);
305 GetPoint(ParameterType &
point, MeasurementVectorType measurements);
308 PrintPoint(ParameterType &
point);
312 int m_CurrentIteration{ 0 };
315 int m_MaximumIteration{ 100 };
318 double m_CentroidPositionChanges{ 0.0 };
322 double m_CentroidPositionChangesThreshold{ 0.0 };
337 bool m_UseClusterLabels{
false };
338 bool m_GenerateClusterLabels{
false };
346 #ifndef ITK_MANUAL_INSTANTIATION
347 # include "itkKdTreeBasedKmeansEstimator.hxx"