int main(int, char *[])
{
SampleType::Pointer sample = SampleType::New();
sample->SetMeasurementVectorSize( 3 );
MeasurementVectorType mv;
mv[0] = 181; mv[1] = 181; mv[2] = 173;
sample->PushBack(mv);
mv[0] = 165.376; mv[1] = 166.376; mv[2] = 160.376;
sample->PushBack(mv);
mv[0] = 139.64; mv[1] = 140.64; mv[2] = 134.64;
sample->PushBack(mv);
mv[0] = 178.688; mv[1] = 181.416; mv[2] = 174.552;
sample->PushBack(mv);
mv[0] = 175.328; mv[1] = 176.328; mv[2] = 168.328;
sample->PushBack(mv);
mv[0] = 180.52; mv[1] = 181.52; mv[2] = 173.52;
sample->PushBack(mv);
mv[0] = 174.456; mv[1] = 176.456; mv[2] = 165.456;
sample->PushBack(mv);
mv[0] = 180; mv[1] = 177; mv[2] = 172;
sample->PushBack(mv);
mv[0] = 179.696; mv[1] = 176.696; mv[2] = 171.696;
sample->PushBack(mv);
TreeGeneratorType::Pointer treeGenerator = TreeGeneratorType::New();
treeGenerator->SetSample( sample );
treeGenerator->SetBucketSize( 16 );
std::cout << "Tree measurement vector size: " << treeGenerator->GetMeasurementVectorSize() << std::endl;
treeGenerator->Update();
typedef TreeGeneratorType::KdTreeType TreeType;
EstimatorType::Pointer estimator = EstimatorType::New();
EstimatorType::ParametersType initialMeans(2*3);
initialMeans.Fill(0.0f);
estimator->SetParameters( initialMeans );
estimator->SetKdTree( treeGenerator->GetOutput() );
estimator->SetMaximumIteration( 200 );
estimator->SetCentroidPositionChangesThreshold(0.0);
estimator->StartOptimization();
EstimatorType::ParametersType estimatedMeans = estimator->GetParameters();
std::cout << "estimatedMeans: " << estimatedMeans << std::endl;
return EXIT_SUCCESS;
}