Find neighbors within a radius
[indices,dists] = findNeighborsInRadius(ptCloud,point,radius,Name, Value)
point— Query point
Query point, specified as an [X,Y,Z] vector.
Radius, specified as a scalar. The function finds the neighbors
radius of a query point.
comma-separated pairs of
the argument name and
Value is the corresponding value.
Name must appear inside single quotes (
' '). You can
specify several name and value pair arguments in any order as
'Sort'— Sort indices
Sort indices, specified as a logical scalar. When you set
the returned indices are sorted in the ascending order based on the
distance from a query point. To turn sorting off, set
'MaxLeafChecks'— Number of leaf nodes
inf(default) | integer
Number of leaf nodes, specified as an integer. Set
the number of leaf nodes to search in the Kdtree. When you set this
inf, the entire tree is searched. When
the entire tree is searched, it produces exact search results. Increasing
the number of leaf nodes to check increases accuracy, but reduces
indices— Indices of stored points
Indices of stored points, returned as a column vector. The
contains K linear indices to the stored points in the point cloud.
dists— Distances to query point
Distances to query point, returned as a column vector. The
K Euclidean distances to the query point.
Create a point cloud object with randomly generated points.
ptCloud = pointCloud(100*rand(1000,3,'single'));
Define a query point and set the radius.
point = [50,50,50]; radius = 5;
Get all of the points within the radius.
[indices, dists] = findNeighborsInRadius(ptCloud,point,radius)
indices = 0x1 empty uint32 column vector dists = 0x1 empty single column vector
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.