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);
171 void PrintSelf(std::ostream & os,
Indent indent)
const;
173 void FillClusterLabels(KdTreeNodeType *node,
int closestIndex);
195 return static_cast< int >( m_Candidates.size() );
203 m_Candidates.resize( centroids.size() );
204 for (
unsigned int i = 0; i < centroids.size(); i++ )
209 m_MeasurementVectorSize);
212 m_Candidates[i] = candidate;
222 centroids.resize( this->
Size() );
223 for ( i = 0; i < (
unsigned int)this->
Size(); i++ )
225 centroids[i] = m_Candidates[i].
Centroid;
231 void UpdateCentroids()
235 for ( i = 0; i < (
unsigned int)this->
Size(); i++ )
237 if ( m_Candidates[i].
Size > 0 )
239 for ( j = 0; j < m_MeasurementVectorSize; j++ )
241 m_Candidates[i].Centroid[j] =
242 m_Candidates[i].WeightedCentroid[j]
243 / double(m_Candidates[i].
Size);
252 return m_Candidates[index];
274 std::vector< int > & validIndexes);
285 std::vector< int > validIndexes,
339 #ifndef ITK_MANUAL_INSTANTIATION
340 #include "itkKdTreeBasedKmeansEstimator.hxx"