ration, which allows the best algorithm and parameter
settings to be determined automatically for any given
dataset. This approach allows for easy extension if
other algorithms are identified in the future that pro-
vide superior performance for particular datasets. Our
code is being made available in the public domain to
make it easy for others to perform comparisons and
contribute to improvements.
We also introduce an algorithm which modifies
the previous method of using hierarchical k-means
trees. While previous methods for searching k-means
trees have used a branch-and-bound approach that
searches in depth-first order, our method uses a pri-
ority queue to expand the search in order according to
the distance of each k-means domain from the query.
In addition, we are able to reduce the tree construc-
tion time by about an order of magnitude by limiting
the number of iterations for which the k-means clus-
tering is performed. For many datasets, we find that
this algorithm has the highest known performance.
For other datasets, we have found that an algo-
rithm that uses multiple randomized kd-trees provides
the best results. This algorithm has only been pro-
posed recently (Silpa-Anan and Hartley, 2004; Silpa-
Anan and Hartley, 2008) and has not been widely
tested. Our results show that once optimal parame-
ter values have been determined this algorithm often
gives an order of magnitude improvement compared
to the best previous method that used a single kd-tree.
From the perspective of a person using our soft-
ware, no familiarity with the algorithms is neces-
sary and only some simple library routines are called.
The user provides a dataset, and our algorithm uses
a cross-validation approach to identify the best algo-
rithm and to search for the optimal parameter val-
ues to minimize the predicted search cost of future
queries. The user may also specify a desire to ac-
cept a less than optimal query time in exchange for
reduced memory usage, a reduction in data structure
build-time, or reduced time spent on parameter selec-
tion.
We demonstrate our approach by matching image
patches to a database of 100,000 other patches taken
under different illumination and imaging conditions.
In our experiments, we show it is possible to obtain
a speed-up by a factor of 1,000 times relative to lin-
ear search while still identifying 95% of the correct
nearest neighbors.
2 PREVIOUS RESEARCH
The most widely used algorithm for nearest-neighbor
search is the kd-tree (Freidman et al., 1977), which
works well for exact nearest neighbor search in low-
dimensional data, but quickly loses its effectiveness
as dimensionality increases. Arya et al. (Arya et al.,
1998) modify the original kd-tree algorithm to use
it for approximate matching. They impose a bound
on the accuracy of a solution using the notion of ε-
approximate nearest neighbor: a point p ∈ X is an ε-
approximate nearest neighbor of a query point q ∈ X,
if dist(p,q) ≤ (1 + ε)dist(p
∗
,q) where p
∗
is the true
nearest neighbor. The authors also propose the use of
a priority queue to speed up the search in a tree by
visiting tree nodes in order of their distance from the
query point. Beis and Lowe (Beis and Lowe, 1997)
describe a similar kd-tree based algorithm, but use a
stopping criterion based on examining a fixed number
E
max
of leaf nodes, which can give better performance
than the ε-approximate cutoff.
Silpa-Anan and Hartley (Silpa-Anan and Hartley,
2008) propose the use of multiple randomized kd-
trees as a means to speed up approximate nearest-
neighbor search. They perform only limited tests, but
we have found this to work well over a wide range of
problems.
Fukunaga and Narendra (Fukunaga and Narendra,
1975) propose that nearest-neighbor matching be per-
formed with a tree structure constructed by clustering
the data points with the k-means algorithm into k dis-
joint groups and then recursively doing the same for
each of the groups. The tree they propose requires a
vector space because they compute the mean of each
cluster. Brin (Brin, 1995) proposes a similar tree,
called GNAT, Geometric Near-neighbor Access Tree,
in which he uses some of the data points as the cluster
centers instead of computing the cluster mean points.
This change allows the tree to be defined in a general
metric space.
Liu et al. (Liu et al., 2004) propose a new kind
of metric tree that allows an overlap between the chil-
dren of each node, called the spill-tree. However, our
experiments so far have found that randomized kd-
trees provide higher performance while requiring less
memory.
Nister and Stewenius (Nister and Stewenius,
2006) present a fast method for nearest-neighbor fea-
ture search in very large databases. Their method is
based on accessing a single leaf node of a hierarchi-
cal k-means tree similar to that proposed by Fukunaga
and Narendra (Fukunaga and Narendra, 1975).
In (Leibe et al., 2006) the authors propose an effi-
cient method for clustering and matching features in
large datasets. They compare several clustering meth-
ods: k-means clustering, agglomerative clustering,
and a combined partitional-agglomerative algorithm.
Similarly, (Mikolajczyk and Matas, 2007) evaluates
VISAPP 2009 - International Conference on Computer Vision Theory and Applications
332