void mitk::PointSetIndexToWorldTransformFilter::GenerateData()
{
  mitk::PointSet::ConstPointer input  = this->GetInput();
  mitk::PointSet::Pointer output  = this->GetOutput();

  typedef std::vector<mitk::Point3D> PointContainer;
  PointContainer points;
  int pointNo = 0;

  while(pointNo!= input->GetSize())
  {
    mitk::Point3D current = input->GetPoint(pointNo);
    points.push_back(current);
    pointNo++;
  }
  output->GetGeometry()->SetIdentity();
  PointContainer::iterator pointsIter = points.begin();

  pointNo = 0;
  while(pointsIter != points.end())
  {
    output->SetPoint(pointNo,(*pointsIter));
    pointNo++;
    pointsIter++;
  }

}
示例#2
0
PointContainer knn(const PointContainer& container, const Point& data, int k)
{
  std::map<float, Point> point_map;
  for(PointContainer::const_iterator it = container.begin(); it != container.end(); ++it)
  {
    point_map[euclidian(data, *it)] = *it;
  }

  PointContainer result;
  std::map<float, Point>::const_iterator it = point_map.begin();
  for(int i = 0; i < k; ++i)
  {
    result.push_back(it->second);
    ++it;
  }
  return result;
}
示例#3
0
int main(int argc, char** argv)
{
  CoverTree<float, std::vector<float>, float (*const)(const std::vector<float>&, const std::vector<float>&)> tree(&euclidian);

  PointContainer data = generate(VECTORLENGTH);

  boost::posix_time::ptime time = boost::posix_time::microsec_clock::local_time();
  for(PointContainer::const_iterator it = data.begin(); it != data.end(); ++it)
  {
    tree.insert(*it);
  }
  std::cout << "Build time " << (boost::posix_time::microsec_clock::local_time() - time) << std::endl;

  std::ofstream stream("dump.txt");
  tree.dump(stream);

  Point zero(2, 0.f);
  time = boost::posix_time::microsec_clock::local_time();
  PointContainer result = knn(data, zero, KNNSIZE);
  std::cout << "Out time (linear) " << (boost::posix_time::microsec_clock::local_time() - time) << std::endl;

  time = boost::posix_time::microsec_clock::local_time();
  PointContainer result2 = tree.knn(zero, KNNSIZE);
  std::cout << "Out time (cover_tree) " << (boost::posix_time::microsec_clock::local_time() - time) << std::endl;

  bool boolean = true;
  for(int i = 0; i < std::min(result.size(), result2.size()); ++i)
  {
    for(int j = 0; j < POINTSIZE; ++j)
    {
      boolean = boolean && (result[i][j] == result2[i][j]);
    }
    std::cout << i << std::endl << result[i] << result2[i];
  }
  std::cout << "Result " << (boolean && (result.size() == result2.size())) << std::endl;
  return EXIT_SUCCESS;
}