When there are a lot of points, I want to find the minimum distances of all points from neighboring points.
It's too slow right now because there are so many dots.
distances = ;
for i = 1:k
for j = 1:k
distances(i,j) = 100000;
distances(i,j) = pdist2(blobMeasurements(i).Centroid, blobMeasurements(j).Centroid);
[distances_min, distances_min_index] = min(distances);
I need to find the distance from a point to the nearest point
Also, I have to calculate this process for every point.
Is there a good way?