Find all neighbors near the specified Point(x,y,z,) in 3D matrix
조회 수: 11 (최근 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!