matlab(对点云的简单处理)

mac2026-01-10  9

虽然用pcl比较多,但是pcl运行比较慢,我很多时候还是喜欢用matlab做一个算法的验证;

项目主要是做一个物体的分割处理。

1.对物体做去噪处理

clc; clear; B=pcread('test(1).ply'); figure(1); pcshow(B); C=pcdenoise(B,'NumNeighbors',90,'Threshold',1); figure(2); pcshow(C);

效果如下:(主要就是一个基于最近邻+距离的去噪,类似pcl的统计滤波)

                          

2.做一个roi提取

roi = [-inf,+inf;-inf,inf;-10,inf]; indices = findPointsInROI(C, roi); ptCloudC = select(C,indices); figure(3); pcshow(ptCloudC); roi1 = [-inf,-8;-inf,inf;-10,inf]; indices1 = findPointsInROI(ptCloudC, roi1); ptCloudB = select(ptCloudC,indices1); figure(4); pcshow(ptCloudB);

 

3.想要得到上面的包,在做一个平面分割

maxDistance = 0.9; referenceVector = [0,0,-1]; maxAngularDistance = 7; [model1,inlierIndices,outlierIndices] = pcfitplane(ptCloudB,... maxDistance,referenceVector,maxAngularDistance); plane1 = select(ptCloudB,inlierIndices); remainPtCloud = select(ptCloudB,outlierIndices); figure pcshow(plane1) title('First Plane') figure pcshow(remainPtCloud) title('remainPtCloud Plane')

          

4.再做roi+滤波

          

5.聚类

 

 

minDistance = 0.9; [labels,numClusters] = pcsegdist(E,minDistance); pcshow(E.Location,labels) colormap(hsv(numClusters)) title('Point Cloud Clusters') disp(" the number of an jian:") disp(numClusters)

效果不是特别好,存在一些问题。先验证一下思路是可行的。 

5.长宽高的提取

都在matlab 的文件家中。不想复制了。。。 

最新回复(0)