Questions tagged [kdtree]

A k-d-tree (k-dimensional tree) is a data structure for storing points in multidimensional space. They can be used to efficiently query for whether a point exists, as well as to do Euclidean nearest-neighbor searches and searches inside of hyperdimensional rectangular regions.

457 questions
8
votes
5 answers

Efficient nearest neighbour search in Scala

Let this coordinates class with the Euclidean distance, case class coord(x: Double, y: Double) { def dist(c: coord) = Math.sqrt( Math.pow(x-c.x, 2) + Math.pow(y-c.y, 2) ) } and let a grid of coordinates, for instance val grid = (1 to 25).map {_…
elm
  • 20,117
  • 14
  • 67
  • 113
8
votes
1 answer

scipy kdtree with meta data

I'm currently looking for a way to build a couple of kd trees for quickly querying some n-dimensional data. However, I'm having some issue with the scipy KD tree algorithm My data consists of id -> {data: somedata, coordinate: x, y} I want to be…
Pwnna
  • 9,178
  • 21
  • 65
  • 91
8
votes
1 answer

Kd tree: data stored only in leaves vs stored in leaves and nodes

I am trying to implement a Kd tree to perform the nearest neighbor and approximate nearest neighbor search in C++. So far I came across 2 versions of the most basic Kd tree. The one, where data is stored in nodes and in leaves, such as here The…
Martin Drozdik
  • 12,742
  • 22
  • 81
  • 146
7
votes
2 answers

Parameterizing types by integers in Haskell

I am trying to make some Haskell types which are parametrized not by types but by elements of a type, specifically, integers. For instance, a (linear-algebra) vector in R^2 and a vector in R^3 are different typed objects. Specifically, I am…
7
votes
2 answers

How can I speed up nearest neighbor search with python?

I have a code, which calculates the nearest voxel (which is unassigned) to a voxel ( which is assigned). That is i have an array of voxels, few voxels already have a scalar (1,2,3,4....etc) values assigned, and few voxels are empty (lets say a value…
7
votes
1 answer

Surface Area Heuristic (SAH) kd-tree of triangles - flat cells

I've implemented a SAH kd-tree based upon the paper On building fast kd-Trees for Ray Tracing, and on doing that in O(N log N) by Wald and Havran. Note I haven't done their splicing and merging suggestion right at the end to speed up the building of…
PeteUK
  • 1,062
  • 12
  • 26
7
votes
1 answer

PCL kd-tree implementation extremely slow

I am using Point Cloud Library (PCL) based C++ implementation of kd-tree nearest neighbour(NN) searching. The data set contains about 2.2 million points. I am searching NN points for every other point. The search radius is set at 2.0. To fully…
ayan.c
  • 263
  • 2
  • 7
  • 17
7
votes
3 answers

Efficient way for SIFT descriptor matching

There are 2 images A and B. I extract the keypoints (a[i] and b[i]) from them. I wonder how can I determine the matching between a[i] and b[j], efficiently? The obvious method comes to me is to compare each point in A with each point in B. But it…
vancexu
  • 1,548
  • 3
  • 19
  • 30
6
votes
5 answers

When should I use a kd-tree?

The other day, I was reading about kd-trees. I was looking for a concrete and simple situation where such a data structure could be useful. Does anybody have such an example?
6
votes
4 answers

Nearest neighbor zones visualized

I'm writing an app that looks up points in two-dimensional space using a k-d tree. It would be nice, during development, to be able to "see" the nearest-neighbor zones surrounding each point. In the attached image, the red points are points in the…
6
votes
2 answers

Compare SURF descriptors in one image to a list of descriptors in other images

I want to compare the SURF descriptors in one image (A), with the descriptors in several other images (B,C,D,..) to find the most similar image to A. The descriptors have 64 dimensions. Using C# and Emgu, the match is done by comparing A's…
MortenGR
  • 803
  • 1
  • 8
  • 22
6
votes
1 answer

Understanding `leafsize` in scipy.spatial.KDTree

Problem statement: I have 150k points in a 3D space with their coordinates stored in a matrix with dimension [150k, 3] in mm. I want to find all the neighbors of a given point p that are within a radius r. And I want to do that in the most accurate…
seralouk
  • 30,938
  • 9
  • 118
  • 133
6
votes
2 answers

How to implement range search in KD-Tree

I have built a d dimensional KD-Tree. I want to do range search on this tree. Wikipedia mentions range search in KD-Trees, but doesn't talk about implementation/algorithm in any way. Can someone please help me with this? If not for any arbitrary d,…
Ankit Kumar
  • 1,145
  • 9
  • 30
6
votes
1 answer

Matching millions of people: k-d tree or locality-sensitive hashing?

I am looking for a performant algorithm to match a large number of people by location, gender and age according to this data structure: Longitude (denotes the persons location) Latitude (denotes the persons location) Gender (denotes the persons…
6
votes
4 answers

nearest neighbour search kdTree

To a list of N points [(x_1,y_1), (x_2,y_2), ... ] I am trying to find the nearest neighbours to each point based on distance. My dataset is too large to use a brute force approach so a KDtree seems best. Rather than implement one from scratch I…
RedPen
  • 223
  • 1
  • 2
  • 7
1 2
3
30 31