K-means clustering of 3D point cloud
조회 수: 36 (최근 30일)
이전 댓글 표시
I have a 3D point cloud (ptCloud) with these data:
- Location [x,y,z]
- Intensity (I used some kind of vegetation index - GRVI)
Now, I want to perform k-means clustering to segment the vegetation part of the 3D point cloud.
I tried this:
group = imsegkmeans3(ptCloud,3)
But it does not accept a point cloud as "volume to segment"
How else can I perform k-means clustering of the point cloud based on the intensity values (GRVI)?
My MatLab is R2018b.
댓글 수: 1
Tiago Ramos
2020년 4월 14일
Perhaps use "kmeans" and not imsekgmeans3.
I would use kmeans in the GRVI values and use the output indices to create the groups. something like
ii = kmeans(GRVI,3);
ptCloud1 = ptCloud(ii==1,:);
ptCloud2 = ptCloud(ii==2,:);
ptCloud3 = ptCloud(ii==3,:);
답변 (1개)
Paola Donis Noriega
2022년 5월 24일
Hi Addie,
You can segment the point cloud based on its intensity values using either imsegkmeans or kmeans. imsegkmeans3 is to segment volumes, so it wouldn't work for the data stored in the intensity property of the point cloud. Consider the following example:
% Load location and intensity data.
ld = load('drivingLidarPoints.mat');
location = ld.ptCloud.Location;
intensity = ld.ptCloud.Intensity; % In your use case, intensity would be the vegetation index.
% Create a point cloud object with the location and intensity data.
% Notice that imsegkmeans supports inputs of type uint8, uint16, int8,
% int16 and single.
ptCloud = pointCloud(location, "Intensity", uint8(intensity));
% Segment based on intensity values.
numClusters = 10;
labels = imsegkmeans(ptCloud.Intensity, numClusters);
% Select each cluster and store it in a pointCloud object.
ptCloudArr = pointCloud.empty(0, numClusters);
for i = 1:numClusters
ptCloudArr(i) = select(ptCloud, labels == i);
end
% Optional: you can also visualize each cluster as follows.
colorsPlot = lines(numClusters);
for k = 1:numClusters
pcshow(ptCloudArr(k).Location, colorsPlot(k,:))
hold on
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1009685/image.jpeg)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Point Cloud Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!