Find all neighbors near the specified Point(x,y,z,) in 3D matrix
10 次查看(过去 30 天)
显示 更早的评论
I want to find all neighbors who are near the specified point(x,y,z) or find all objects who are in k distance from specified point(x,y,z).
For example I want to find all objects near the point(1,1,1) or they are in k distance from point(1,1,1).
I try to use from rangesearch function, but I can't use it.
13 个评论
Walter Roberson
2017-10-6
Unless the point cloud has special properties, the 27 nearest neighbours will include points that are not at "adjacent" coordinates. Do you have reason to expect that the points will form a cubic grid that is aligned with the axes? If so then the problem reduces to one of examining the min() and max() of the coordinates to figure out where the ranges begin and end, and determine the coordinate spacing, after which everything else is pre-determined by the properties of a cuboid with appropriate size.
Image Analyst
2017-10-7
You could also use meshgrid() to create a list of coordinates:
middleRow = 100; % Whatever - wherever it is for this cube.
middleCol = 1000; % Whatever - wherever it is for this cube.
middlePlane = 10; % Whatever - wherever it is for this cube.
[rows, columns, planes] = meshgrid(1:3, 1:3, 1:3)
% Make 1-D arrays
rows = rows(:) + middleRow
columns = columns(:) + middleCol
planes = planes(:) + middlePlane
% Get rid of center voxel so we have only neighbors
rows(14) = []; % Delete middle one
columns(14) = []; % Delete middle one
planes(14) = []; % Delete middle one
采纳的回答
Image Analyst
2014-9-12
Then just mask the array
withinSphere = array3D .* sphereVoxels; % Voxel values.
After that I don't know what you want because all you say is you want to "detect all objects" but "detect" is such a vague, imprecise term that I don't know what sort of numerical data to return to you. Please define "detect".
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!