jlblancoc / nanoflann

nanoflann: a C++11 header-only library for Nearest Neighbor (NN) search with KD-trees
Other
2.26k stars 491 forks source link

Removing nodes from a KDTree #207

Open lukkio88 opened 1 year ago

lukkio88 commented 1 year ago

Hi,

I am trying to implement an algorithm ICP style. And to find correspondences between the two d-dimensional point sets (assuming same number of points per set).

However because I would like to enforce bijection in these correspondences my approach was to remove certain nodes from the tree iteratively.

Roughly the following pseudocode

input P,Q : d-dimensional point sets with |P| = |Q|
output: corresponce map C

T = KDTree constructed from Q
C = correspondence map of size |Q|
for each p in P:
  j = T.find(p);
  T.remove(j); //How to do this?
  C[p.index()] = j;

This should guarantee the bijection. But by looking through past issues it doesn't seem to me you implemented such feature? Can you tell me how to do this? or if removal is not available maybe some approaches maybe based on re-adjusting the tree cleverly?

I could construct a new tree everytime but I have a feeling at that point might be better just doing the naive way. But would be nice to have a solution that uses a KDTree.