点云下采样,目的是为了减少数据量,方便处理
下采样函数为pcdownsample,有三种重载方式:体素栅格下采样、随机下采样、非均匀网格下采样
ptCloud = pcread('hand.pcd');
pcshow(ptCloud);
title('原始点云');
%----------------体素下采样----------------
gridStep = 0.1; %体素网格过滤器的3D框大小
ptCloudOut1 = pcdownsample(ptCloud,'gridAverage',gridStep);
figure;
pcshow(ptCloudOut1);
title('体素下采样')
%----------------随机下采样----------------
percentage = 0.2; %输出点云为原始点云的百分比,取值:[0,1]
ptCloudOut2 = pcdownsample(ptCloud, 'random', percentage);
figure;
pcshow(ptCloudOut2)
title('随机下采样')
%----------------非均匀网格下采样----------------
maxNumPoints = 20; %网格框中的最大点数,指定为大于6的整数
ptCloudOut3 = pcdownsample(ptCloud, 'nonuniformGridSample',maxNumPoints);
figure;
pcshow(ptCloudOut3)
title('非均匀体素下采样')
结果如下: