[Insight-users] Get ID from a neighbor found using a kd-tree?

motes motes mort.motes at gmail.com
Mon Nov 2 10:40:42 EST 2009


I am using the itk::kdtree to find the k-nearest neighbors from a
queryPoint within a specified radius.From the example: KdTree.cxx it
looks something like this:

  double radius = 437.0;
  tree->Search( queryPoint, radius, neighbors ) ;
  std::cout << "kd-tree radius search result:" << std::endl
            << "query point = [" << queryPoint << "]" << std::endl
            << "search radius = " << radius << std::endl;
  std::cout << "measurement vector : distance" << std::endl;
  for ( unsigned int i = 0 ; i < neighbors.size() ; ++i )
    {
    std::cout << "[" << tree->GetMeasurementVector( neighbors[i] )
              << "] : "
              << distanceMetric->Evaluate(
                  tree->GetMeasurementVector( neighbors[i]))
              << std::endl;
    }


But each neighbors is actually an object that contains a deformation
vector and a unique identifier: ID.

How do I lookup the ID and the deformation vector from the neighbors
returned from the "Search" call?

It seems that this is not possible with the above implementation of a
kd-tree since a neighbor is only identified by a vector which does not
allow for any extra information.


More information about the Insight-users mailing list