Azzera filtri
Azzera filtri

K-means clustering of 3D point cloud

36 visualizzazioni (ultimi 30 giorni)
Addie Ira Parico
Addie Ira Parico il 11 Mar 2019
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 Commento
Tiago Ramos
Tiago Ramos il 14 Apr 2020
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,:);

Accedi per commentare.

Risposte (1)

Paola Donis Noriega
Paola Donis Noriega il 24 Mag 2022
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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by