How to upsample a 3d point cloud?

I have a .ply 3d point cloud that I want to upsample to increase the density, how can I do that?
Should I use scatteredInterpolant ? If yes then I don't know what to use as the 'v' in the form of 'F = scatteredInterpolant(x,y,z,v)'. I have x y z point coordinates but have no clue what is v in this context!
Also any extra tips on what exactly are the steps to upsample a 3d point cloud from start to finish is immensely appreciated (like what to before or after getting the interpolant 'F').
Point cloud file attached.
UPDATE: Edited question title and body thanks to @Matt_J.

2 个评论

Matt J
Matt J 2020-7-12
编辑:Matt J 2020-7-12
I have x y z point coordinates but have no clue what is v in this context!
It is nothing. This is not an application of scatteredInterpolant. I wouldn't even call it interpolation ... maybe "scattered upsampling" instead.
@Matt that's exactly what I'm trying to do, "scattered upsampling"! Thank you :)

请先登录,再进行评论。

 采纳的回答

Matt J
Matt J 2020-7-12
编辑:Matt J 2020-7-12
Perhaps this is what you are trying to do,
[x1,y1,z1] = sphere(24); %Given points (example)
x1 = x1(:); y1 = y1(:); z1 = z1(:);
P = [x1 y1 z1];
P = unique(P,'rows');
shp = alphaShape(P(:,1),P(:,2),P(:,3),1);
[F,V]=boundaryFacets(shp);
F=F.'; V=V.';
Q=mean(reshape(V(:,F),3,3,[]),2);
Q=num2cell(reshape(Q,3,[]).',1);
[x2,y2,z2]=deal(Q{:}); %"Interpolated" points
hold on
plot(shp);
hg=scatter3(x1,y1,z1,'SizeData',50,'MarkerFaceColor','red','MarkerEdgeColor','none');
hi=scatter3(x2,y2,z2,'SizeData',50,'MarkerFaceColor','blue','MarkerEdgeColor','none');
legend([hg,hi],'Given Points','"Interpolated" Points');
hold off

3 个评论

@Matt thanks to you I managed to get the following piece of code which works great, but there are still some rough patches in some areas that I have pointed out in red circles in the images attached. How can I fix those or increase the 'upsampling' rate even more?
Thank you! :-)
% input point cloud
[FileName,PathName] = uigetfile({'*.ply';'*.pcd'},'Input point cloud');
ptCloud=pcread([PathName,FileName]);
% clean up
ptCloud=removeInvalidPoints(ptCloud);
x1 = ptCloud.Location(:,1);
y1 = ptCloud.Location(:,2);
z1 = ptCloud.Location(:,3);
P = [x1 y1 z1];
P = unique(P,'rows');
shp = alphaShape(P(:,1),P(:,2),P(:,3),1);
h=plot(shp);
F=h.Faces.';
V=h.Vertices.';
Q=mean(reshape(V(:,F),3,3,[]),2);
Q=num2cell(reshape(Q,3,[]).',1);
[x2,y2,z2]=deal(Q{:}); %"Interpolated" points
% create a new point cloud with only the new points
upsampledPoints=pointCloud([x2,y2,z2]);
% merge the new points with the original point cloud
ptCloudUpsampled = pcmerge(ptCloud,upsampledPoints,0.1);
figure('name','Point Cloud');
pcshow(ptCloud,'MarkerSize',20)
title('Point Cloud');
figure('name','Upsampled Point Cloud');
pcshow(ptCloudUpsampled,'MarkerSize',20)
title('Upsampled Point Cloud');
Ali, when you create the alpha shape,
shp = alphaShape(P(:,1),P(:,2),P(:,3),alpha_radius);
you may have to customize the choice alpha_radius parameter and the HoleThreshold parameter to your data so as to avoid gaps in the shape. Here are some examples in the documentation showing the influence of these parameters:
@Matt_J Changing the HoleThreshold didn't increase the sampling rate and at best lowered the generated points, as for the alpha_radius values lower or higher than '1' also lowered the points count. Anyway thanks for your time, helped a lot. :-)

请先登录,再进行评论。

更多回答(0 个)

类别

Community Treasure Hunt

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

Start Hunting!

Translated by