Averaging points in a point cloud

13 Ansichten (letzte 30 Tage)
Fezan Tabassum
Fezan Tabassum am 28 Mär. 2021
Beantwortet: Aditya Patil am 31 Mär. 2021
Hello everyone,
I am working towards having a method for scanning and averaging each point with the neighbouring points (in a specific radius defined by the user) for a point cloud. I have been told this is referred to as kernel filtering but I might be wrong on that, so apologies in advance. I have been testing this algorithm on the kettle point cloud provided by MATLAB.
I had the idea to try to grab the indices of the neighbouring points for a single point in a specificed radius (which will be tweaked by the user once created into a function). Then to compare this set of indices to the Nx3 matrix (point cloud matrix) to get the neighbours of the point, which are all (median) averaged to get a new point. I have came across a few problems while working on this algorithm.
load('xyzPoints.mat');
PC = pointCloud(xyzPoints);
r = 0.5; %Radius
n =1; %iteration variable
for i= min(PC.XLimits) : max(PC.XLimits)
for j = min(PC.YLimits) : max(PC.YLimits)
for k = min(PC.ZLimits) : max(PC.ZLimits)
%isempty might be a good method of checking for empty index values
[indices,dists] = findNeighborsInRadius(PC,[i,j,k],r) %scanning the neighbours of a point in the radius of r
pts = PC.Location(indices,:,:) % looks for the indices of the nieghbouring point in the point cloud matrix (Nx3)
ptsX(n,1) = median(pts(:,1));
ptsY(n,1) = median(pts(:,2));
ptsZ(n,1) = median(pts(:,3));
n = n+1;
end
end
end
AveragedPC = [ptsX,ptsY,ptsZ];
This is the properties of the kettle point cloud (xyzPoints)
This method will only works for a certain amount of points because of how the limits for i,j,k are set up, they skip over more precise points. So instead of having ~5000 points, the algorithm collects 140 (as seen by the variable AveragedPC).
Also I have a problem with the AveragedPC showing a lot of NaN values. This happens when there are not any indices to collect near the specified point. I am unsure of how to implement a method to skip to the next point if no indices are collectable within the radius of the point. The main problem I would love some help on though is the method of scanning, as there isn't much point trying to filter out NaN points when basically all the points are being removing for the point cloud.
Either way, thank you for taking the time read this and any advice on scanning all the points in the point cloud would be appreciated.
Best Regards

Akzeptierte Antwort

Aditya Patil
Aditya Patil am 31 Mär. 2021
From the code, it seems you are taking the median of points in each sphere in the grid. As these spheres won't cover all the space, some points will be skipped.
If you want all points to be covered, use cubes instead of spheres. Also, it's more efficient to iterate over points, instead of iterating over each cell of the grid.
If your goal is only to downsample the pc, the gridaverage method in pcdownsample should suffice.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by