Class KdTreeSearchBestBinFirst<P>
- Direct Known Subclasses:
KdTreeSearch1Bbf
,KdTreeSearchNBbf
Approximate search for K-D Trees
using the best-bin-first method [1] that supports
multiple trees. A priority queue is created where nodes that are more likely to contain points close to the target are given
higher priority. It is approximate since only predetermined number of nodes are considered.
Searches are initialized by searching each tree at least once down to a leaf. As these searches are performed, unexplored regions are added to the priority queue. Searching multiple trees is in response to [2], which proposes using a set of random trees to improve search performance and take better advantage of structure found in the data.
[1] Beis, Jeffrey S. and Lowe, David G, "Shape Indexing Using Approximate Nearest-Neighbour Search in
High-Dimensional Spaces" CVPR 1997
[2] Silpa-Anan, C. and Hartley, R. "Optimised KD-trees for fast image descriptor matching" CVPR 2008
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Contains information on a node -
Field Summary
Modifier and TypeFieldDescriptionprotected double
protected int
protected int
protected int
-
Constructor Summary
ModifierConstructorDescriptionprotected
KdTreeSearchBestBinFirst
(KdTreeDistance<P> distance, int maxNodesSearched) Configures the search -
Method Summary
Modifier and TypeMethodDescriptionvoid
_findClosest
(P target) protected void
addToQueue
(double closestDistanceSq, KdTree.Node node, P target) Adds a node to the priority queue.protected abstract boolean
canImprove
(double distanceSq) Checks to see if it is possible for this distance to improve upon the current bestprotected abstract void
checkBestDistance
(KdTree.Node node, P target) Checks to see if the current node's point is the closet point found so farprotected void
searchNode
(P target, KdTree.Node n) Traverse a node down to a leaf.void
setMaxDistance
(double maxDistance) void
void
-
Field Details
-
maxNodesSearched
protected int maxNodesSearched -
N
protected int N -
bestDistanceSq
protected double bestDistanceSq -
numNodesSearched
protected int numNodesSearched
-
-
Constructor Details
-
KdTreeSearchBestBinFirst
Configures the search- Parameters:
maxNodesSearched
- Maximum number of nodes it will search. Used to limit CPU time.
-
-
Method Details
-
setTree
-
setTrees
-
setMaxDistance
public void setMaxDistance(double maxDistance) -
_findClosest
-
searchNode
Traverse a node down to a leaf. Unexplored branches are added to the priority queue. -
addToQueue
Adds a node to the priority queue.- Parameters:
closestDistanceSq
- The closest distance that a point in the region could possibly be target
-
checkBestDistance
Checks to see if the current node's point is the closet point found so far -
canImprove
protected abstract boolean canImprove(double distanceSq) Checks to see if it is possible for this distance to improve upon the current best- Parameters:
distanceSq
- The distance being considered- Returns:
- true if it can be better or false if not
-