改成自己的ply文件地址即可运行(体素下采样)
%读取一份点云:
ptCloud = pcread('000020.ply');
%设置3-D分辨率为(0.1 x 0.1 x 0.1):
figure(1);
pcshow(ptCloud,"MarkerSize",30,"BackgroundColor",'w');
%调整点的显示大小及背景颜色
title('原始点云');
gridStep = 0.4;
ptCloudA = pcdownsample(ptCloud,'gridAverage',gridStep);
%可视化下采样数据:
figure('Color','r');
pcshow(ptCloudA,"MarkerSize",30,"BackgroundColor",'w');
%调整点的显示大小及背景颜色
title('体素下采样点云');
%pcshow(ptCloudA);
%将点云与使用固定步长下采样的数据进行比较:
stepSize = floor(ptCloud.Count/ptCloudA.Count);
indices = 1 : stepSize : ptCloud.Count;
ptCloudB = select(ptCloud, indices);
figure;
pcshow(ptCloudB,"MarkerSize",30,"BackgroundColor",'w');
title('YUANS');
下面是随机下采样
%读取一份点云: