Create a boundary of real numbers in a two dimentional matrix consisting of nan and real numbers

2 visualizzazioni (ultimi 30 giorni)
I have the organized point cloud data measured by Lidar.
That data is two dimentinal matrix consisting of nan and real numbers.
I want to divide the data by clutering with real number boundary.
Does this algorithm exist in the past? Or Is there a code like that?
Finally, I want to separate the obstacles' information.
  2 Commenti
Matt J
Matt J il 29 Nov 2022
It would be a good idea to attach an example set of input data, so that we can demonstrate solutions.
익환 류
익환 류 il 29 Nov 2022
a = [nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan;...
nan nan nan 0.5 0.5 0.5 0.5 nan nan nan nan nan nan 0.5 0.5 0.5 nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan;...
nan nan nan 0.5 0.5 0.5 0.5 nan nan nan nan nan nan 0.5 0.5 0.5 nan nan nan nan nan 0.5 0.5 0.5 nan nan nan 0.5 nan nan nan nan;...
nan nan nan 0.5 0.5 0.5 0.5 nan nan nan nan nan nan 0.5 0.5 0.5 nan nan nan nan nan 0.5 0.5 0.5 0.5 0.5 0.5 0.5 nan nan nan nan;...
nan nan nan 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 nan nan nan nan nan 0.5 0.5 0.5 nan nan nan 0.5 nan nan nan nan;...
nan nan nan 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 nan nan nan nan nan nan nan nan nan nan nan 0.5 nan nan nan nan;...
nan nan nan 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan;...
nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan];

Accedi per commentare.

Risposte (1)

Kartik
Kartik il 21 Mar 2023
Hi,
Yes, there are several algorithms in MATLAB that you can use to cluster the Lidar data based on real number boundaries. One approach you can use is the 'k-means' clustering algorithm. Here's an example code to get you started:
% Replace NaN values with zeros
a(isnan(a)) = 0;
% Set the number of clusters you want to create
num_clusters = 2;
% Perform k-means clustering
[idx, C] = kmeans(a(:), num_clusters);
% Reshape the clustered data to its original shape
idx = reshape(idx, size(a));
This code uses k-means clustering to create two clusters from the Lidar data. The 'kmeans' function takes the flattened data '(a(:))' and the number of clusters as input and returns the cluster indices '(idx)' and the centroid values '(C)'. The 'reshape' function is used to reshape the clustered data to its original shape.
You can adjust the number of clusters to match your needs. Note that the clustering result might not be perfect, especially if the data has a lot of noise or if the clusters are not well-separated. You might need to experiment with different clustering algorithms and parameters to get the best result for your data.

Community Treasure Hunt

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

Start Hunting!

Translated by