18 #ifndef __itkKdTreeBasedKmeansEstimator_h
19 #define __itkKdTreeBasedKmeansEstimator_h
22 #include "itksys/hash_map.hxx"
76 template<
class TKdTree >
136 itkSetMacro(MaximumIteration,
int);
137 itkGetConstMacro(MaximumIteration,
int);
142 itkSetMacro(CentroidPositionChangesThreshold,
double);
143 itkGetConstMacro(CentroidPositionChangesThreshold,
double);
146 void SetKdTree(TKdTree *tree);
148 const TKdTree * GetKdTree()
const;
153 itkGetConstMacro(CurrentIteration,
int);
154 itkGetConstMacro(CentroidPositionChanges,
double);
160 void StartOptimization();
164 itkSetMacro(UseClusterLabels,
bool);
165 itkGetConstMacro(UseClusterLabels,
bool);
170 void PrintSelf(std::ostream & os,
Indent indent)
const;
172 void FillClusterLabels(KdTreeNodeType *node,
int closestIndex);
194 return static_cast< int >( m_Candidates.size() );
202 m_Candidates.resize( centroids.size() );
203 for (
unsigned int i = 0; i < centroids.size(); i++ )
208 m_MeasurementVectorSize);
211 m_Candidates[i] = candidate;
221 centroids.resize( this->
Size() );
222 for ( i = 0; i < (
unsigned int)this->
Size(); i++ )
224 centroids[i] = m_Candidates[i].
Centroid;
230 void UpdateCentroids()
234 for ( i = 0; i < (
unsigned int)this->
Size(); i++ )
236 if ( m_Candidates[i].
Size > 0 )
238 for ( j = 0; j < m_MeasurementVectorSize; j++ )
240 m_Candidates[i].Centroid[j] =
241 m_Candidates[i].WeightedCentroid[j]
242 / double(m_Candidates[i].
Size);
251 return m_Candidates[index];
273 std::vector< int > & validIndexes);
284 std::vector< int > validIndexes,
338 #ifndef ITK_MANUAL_INSTANTIATION
339 #include "itkKdTreeBasedKmeansEstimator.hxx"