Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Find nearest neighbors of a point in point cloud

`[indices,dists] = findNearestNeighbors(ptCloud,point,K)`

`[indices,dists] = findNearestNeighbors(ptCloud,point,K,camMatrix)`

`[indices,dists] = findNearestNeighbors(___,Name,Value)`

`[`

returns the K-nearest neighbors of a query point in the input point cloud. The input point
cloud can be an unorganized or organized point cloud data. The K-nearest neighbors of the
query point are computed by using the Kd-tree based search algorithm. `indices`

,`dists`

] = findNearestNeighbors(`ptCloud`

,`point`

,`K`

)

`[`

returns the K-nearest neighbors of a query point in the input point cloud. The input point
cloud is an organized point cloud data generated by a depth camera. The K-nearest neighbors
of the query point are determined using fast approximate K-nearest neighbor search
algorithm. The function uses the camera projection matrix `indices`

,`dists`

] = findNearestNeighbors(`ptCloud`

,`point`

,`K`

,`camMatrix`

)`camMatrix`

to
know the relationship between adjacent points and hence, speeds up the nearest neighbor
search. However, the results have lower accuracy as compared to the Kd-tree based approach.

This function only supports organized point cloud data produced by RGB-D sensors.

You can use

`estimateCameraMatrix`

to estimate camera projection matrix for the given point cloud data.

`[`

specifies options using one or more name-value arguments in addition to the input arguments
in the preceding syntaxes.`indices`

,`dists`

] = findNearestNeighbors(___,`Name,Value`

)

[1] Muja, M. and David G. Lowe. "Fast
Approximate Nearest Neighbors with Automatic Algorithm Configuration". *In VISAPP
International Conference on Computer Vision Theory and Applications*. 2009. pp.
331–340.