4.56

4.6 | 26 ratings Rate this file 88 downloads (last 30 days) File Size: 113.36 KB File ID: #4586

k-D tree

by Guy Shechter

 

06 Mar 2004 (Updated 14 Jun 2004)

Code covered by the BSD License  

Perform closest point search or range query using a k-D tree implementation.

Download Now | Watch this File

File Information
Description

This distribution contains the KDTREE, KDTREEIDX, and KDRANGEQUERY functions.

KDTREE Find closest points using a k-D tree.
 
 CP = KDTREE( REFERENCE, MODEL ) finds the closest points in
REFERENCE for each point in MODEL. The search is performed in an efficient manner by building a k-D tree from the datapoints in REFERENCE, and querying the tree for each datapoint in MODEL.

PTS = KDRANGEQUERY( ROOT, QUERYPT, DISTLIM ) finds all the points stored in the k-D tree ROOT that are within DISTLIM units from the QUERYPT. Proximity is quantified using a D-dimensional Euclidean (2-norm) distance.

Included are the source code files in kdtree/src, as well as precompiled mex files for the following systems:

  - Mac OS X (Matlab 6.5)
  - Win2K (MATLAB 6.1)
  - Redhat Linux (MATLAB 6.5)

Acknowledgements
This submission has inspired the following:
Iterative Closest Point Method, C++, kd-tree for matlab, Kdtree implementation in matlab
MATLAB release MATLAB 6.5 (R13)
Zip File Content  
Other Files
kdtree/README,
kdtree/kdrange_demo.m,
kdtree/kdrangequery.m,
kdtree/kdtree.m,
kdtree/kdtree_demo.m,
kdtree/kdtreeidx.m,
kdtree/src/kdrangequery.cc,
kdtree/src/kdtree.cc,
kdtree/src/kdtree_common.cc,
kdtree/src/kdtree_common.h,
kdtree/src/kdtreeidx.cc,
kdtree/mex/glx/kdrangequery.mexglx,
kdtree/mex/glx/kdtree.mexglx,
kdtree/mex/glx/kdtreeidx.mexglx,
kdtree/mex/mac/kdrangequery.mexmac,
kdtree/mex/mac/kdtree.mexmac,
kdtree/mex/mac/kdtreeidx.mexmac,
kdtree/mex/win/kdrangequery.dll,
kdtree/mex/win/kdtree.dll,
kdtree/mex/win/kdtreeidx.dll
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (32)
27 Apr 2004 Carles Matabosch  
20 Jun 2004 Dimitris Nicoloutsopoulos

Very useful. Quite happy, especially with the KDTREEIDX function. This new release (June 2004) includes improvements in memory usage aswell.

Big thanx

27 Jul 2004 Brian Bonnlander

Author was prompt and responsive to enhancement requests and bug reports. Code appears to work efficiently.

26 Sep 2004 Chris Kelly

Very useful program. I used it to get correspondance between isosurface vertices and matrix subscripts, with great success. Thanks to the author.

09 Nov 2004 Steven Knudsen

very easy to implement. All that is needed is an N x d matrix, where d is the dimension of a point in some space, and N is the number of points. Needs a p-nearest neighbor search.

09 Nov 2004 Hong zhou

Very useful program and very kind author. This speed up my programe a lot.
Thanks Guy for your patient and useful help

18 Nov 2004 ambrose thompson

Lovely Useful and Fast.

Using it to find nearby points in a scattered set for interpolation

03 Dec 2004 martin richards

the file kdtree just seems to contain information and no code. is it just me who has found this??

30 Dec 2004 Ray Hu

Very good. I don't need use my own classic KNN :-(

16 Mar 2005 A James

Useful but finding the K nearest neighbours rather than just the nearest would be a real improvement.

27 Jun 2005 Xu Chenghua

It seems very good. But i haven't the full code.

18 Jul 2005 j p  
28 Jul 2005 João Ferreira

As James said, a K nearest neighbours search option would be a definive plus. Otherwise, an excelent package --- helped me a great deal on distance range queries!

17 Sep 2005 wenchao hu

i cannnot run the demo in windows,why?

29 Sep 2005 Babak Taati

in response to wenchao hu:

> i cannnot run the demo in windows,why?

you need to add the DLL path to your Matlab path. But make sure you do NOT add the path to where the .m files stored to your Matla path.

05 Dec 2005 Anders Wiklund

Easy to use and great support by the author.

26 May 2006 Mandar Joshi

great work by author

20 Sep 2006 Marzia De Lucia

I am trying to run kdtree_demo in matlab 7.1 but returns "Attempt to execute SCRIPT kdtree as a function"

Marzia

06 Nov 2006 Samy Samy

I'm sure like me you've searched the web over and over looking for free ringtones only

24 Nov 2006 Deepak Trivedi

Great job! It's fast.

14 Mar 2007 Quan Ho

It could be better if you add kdrangequeryidx that works like kdtreeidx.

14 Mar 2007 Quan Ho

OK! Now I know how to use the kdrangequery to return indexes of nearest rows. It's excellent.

18 Dec 2007 ramanathan natarajan  
18 Jan 2008 Mert Sabuncu

great code!

25 Mar 2008 Yi Cao

The search is not very efficient. I have compared it against linear search for various size of data. Seems it is only suitable for very small dimension (<5). FEX ID 7030 is better than this one.

08 Aug 2008 Norah .

very good code
thanks

11 Sep 2008 Steven Boege

Thank you, Guy!
You saved me a lot of work!

Users please note that if you tweak the kdrange_demo by putting in a third left-hand-side argument, you will then get the ReferencePts indices of the points in the neighborhood in addition to the coordinates and distance you already were getting. This is useful when trying to find the interstitial spacing of the points within ReferencePts. Getting the index allows you to ignore the case where a point in ReferencePoints is its own nearest neighbor.

16 Sep 2008 Andrea Tagliasacchi

There is a bug somewhere in the range search. One of my experiments worked fine when I used a random dataset but when I used a customized one (namely, one for which I knew perfectly the structure), returned points were scattered without much meaning.

Since this was buggy and the one released with "fileid:7030" had problems compiling I am building a new "personal" one. I hope to keep the code as simple and easy to understand/edit as possible.

20 Mar 2009 Cengiz Oztireli

Nicely written! I would really like to have add point to the tree functionality rather than adding them all at once.

16 Oct 2009 Alok

Hi, guys .. could you tell me how to use these files in MATLAB. I am a complete novice in the area.

12 Nov 2009 Peter Iles

I'm having the same problem as others - when I try to run kdtree I get the "Attempt to execute SCRIPT kdtree as a function" error. Does this have something to do with the Matlab path? Can someone tell me what I need to do here? - Many thanks.

07 Jan 2010 Markus Leuthold

Peter, make sure ..\kdtree\mex\win appears BEFORE ..\kdtree. You can change the order of paths in File->Set Path

Please login to add a comment or rating.
Updates
14 Jun 2004

The new features added June 2004:
        + Use N dimensional data points, where N>3.
        + Use KDTREEIND to return the index value to the closest point, instead of the closest point values.
        + KDRANGEQUERY will also return indices.

Tag Activity for this File
Tag Applied By Date/Time
kd Guy Shechter 22 Oct 2008 07:15:51
tree Guy Shechter 22 Oct 2008 07:15:51
range Guy Shechter 22 Oct 2008 07:15:51
closest Guy Shechter 22 Oct 2008 07:15:51
neighborhood Guy Shechter 22 Oct 2008 07:15:51
tree A B 30 May 2009 03:30:23
kd A B 30 May 2009 03:30:26
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com