18 #ifndef itkKdTreeBasedKmeansEstimator_h
19 #define itkKdTreeBasedKmeansEstimator_h
22 #include "itksys/hash_map.hxx"
76 template<
typename 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 virtual void PrintSelf(std::ostream & os,
Indent indent)
const ITK_OVERRIDE;
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;
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"
ParametersType m_Parameters
EuclideanDistanceMetric< ParameterType >::Pointer m_DistanceMetric
CandidateVector m_CandidateVector
Light weight base class for most itk classes.
TKdTree::SampleType SampleType
TKdTree::KdTreeNodeType KdTreeNodeType
MembershipFunctionBase< MeasurementVectorType > MembershipFunctionType
std::vector< MembershipFunctionPointer > MembershipFunctionVectorType
Represent the size (bounds) of a n-dimensional image.
TKdTree::Pointer m_KdTree
ParameterType m_TempVertex
double m_CentroidPositionChangesThreshold
SmartPointer< Self > Pointer
fast k-means algorithm implementation using k-d tree structure
DistanceToCentroidMembershipFunctionType::Pointer DistanceToCentroidMembershipFunctionPointer
SmartPointer< const Self > ConstPointer
unsigned int MeasurementVectorSizeType
MeasurementVectorSizeType m_MeasurementVectorSize
TKdTree::InstanceIdentifier InstanceIdentifier
TKdTree::MeasurementType MeasurementType
std::vector< ParameterType > InternalParametersType
Candidate & operator[](int index)
MembershipFunctionVectorObjectPointer m_MembershipFunctionsObject
void SetCentroids(InternalParametersType ¢roids)
Decorates any "simple" data type (data types without smart pointers) with a DataObject API...
static unsigned int GetLength()
KdTreeBasedKmeansEstimator Self
MembershipFunctionVectorObjectType::Pointer MembershipFunctionVectorObjectPointer
MembershipFunctionBase defines common interfaces for membership functions.
static void SetLength(T &m, const unsigned int s)
SimpleDataObjectDecorator< MembershipFunctionVectorType > MembershipFunctionVectorObjectType
MembershipFunctionType::ConstPointer MembershipFunctionPointer
Array< double > ParameterType
virtual ~CandidateVector()
itksys::hash_map< InstanceIdentifier, unsigned int > ClusterLabelsType
bool m_GenerateClusterLabels
void GetCentroids(InternalParametersType ¢roids)
double m_CentroidPositionChanges
std::vector< Candidate > m_Candidates
DistanceToCentroidMembershipFunction models class membership using a distance metric.
Array< double > ParametersType
Control indentation during Print() invocation.
DistanceToCentroidMembershipFunction< MeasurementVectorType > DistanceToCentroidMembershipFunctionType
CentroidType WeightedCentroid
TKdTree::MeasurementVectorType MeasurementVectorType
Base class for most ITK classes.
virtual ~KdTreeBasedKmeansEstimator() override
KdTreeNodeType::CentroidType CentroidType
MeasurementVectorSizeType m_MeasurementVectorSize
ClusterLabelsType m_ClusterLabels