轉自本人博客:點云下采樣有損壓縮
點云下采樣是通過一定規則對原點云數據進行再采樣,減少點云個數,降低點云稀疏程度,減小點云數據大小。
1. 體素下采樣(Voxel Down Sample)
std::shared_ptr<PointCloud> VoxelDownSample (double voxel_size) const;
voxel_size為體素(體積元素)的尺寸大小,體素的尺寸越大,下采樣的倍數越大,點云也就越稀疏。
相當于每隔一定的距離采集一個點。
示例:
std::shared_ptr<open3d::geometry::PointCloud> pcd = nullptr;
open3d::io::ReadPointCloud("rabbit.pcd", *pcd);
double voxelSize = 0.05;
pcd = pcd->VoxelDownSample(voxelSize);
2. 均勻下采樣(Uniform Down Sample)
std::shared_ptr<PointCloud> UniformDownSample (size_t every_k_points) const;
every_k_points為隔著的點數目,每隔every_k_points個點,保留一個點。
示例:
std::shared_ptr<open3d::geometry::PointCloud> pcd = nullptr;
open3d::io::ReadPointCloud("rabbit.pcd", *pcd);
size_t everyKPoints = 10;
pcd = pcd->UniformDownSample(everyKPoints);
3. 隨機下采樣(Random Down Sample)
std::shared_ptr<PointCloud> RandomDownSample (double sampling_ratio) const;
sampling_ratio為采樣的比率,隨機保留點,直至達成指定比率。
示例:
std::shared_ptr<open3d::geometry::PointCloud> pcd = nullptr;
open3d::io::ReadPointCloud("rabbit.pcd", *pcd);
double samplingRatio = 0.2;
pcd = pcd->RandomDownSample(samplingRatio);
4. 最遠點下采樣(FarthestPoint Down Sample)
std::shared_ptr<PointCloud> FarthestPointDownSample (size_t num_samples) const;
num_samples為采樣的點數。
首先隨機選擇一個點,其次,在剩下點中尋找最遠的點,再去再剩下點中找到同時離這兩個點最遠的點……,以此類推,直到滿足采樣點個數。
示例:
std::shared_ptr<open3d::geometry::PointCloud> pcd = nullptr;
open3d::io::ReadPointCloud("rabbit.pcd", *pcd);
size_t numSamples = 1000;
pcd = pcd->FarthestPointDownSample(numSamples);