I have 8 balloons which scatter on a binary image with no specific pattern, I want to get the distance every pairwise of balloons, could you give me any suggestion or codes?how can I do that?

4 visualizzazioni (ultimi 30 giorni)
I have 8 balloons which scatter on a binary image with no specific pattern, I want to get the distance between every pairwise of balloons, could you give me any suggestion or codes?how cando i that?

Risposta accettata

Image Analyst
Image Analyst il 27 Mag 2014
Modificato: Image Analyst il 27 Mag 2014
See my image segmentation tutorial to get the centroids. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 Then use the Pythagorean theorem to find distances between each pair of centroids. Post your image if you want better advice.
  3 Commenti
Image Analyst
Image Analyst il 27 Mag 2014
Let me attach the BlobsDemo tutorial I referred you to. To find the centroid of any given blob, you can do
blobCentroid = blobMeasurements(k).Centroid;
So you just do a double loop:
for j = 1 : numberOfBlobs % Loop through all blobs.
for k = 1 : numberOfBlobs % Loop through all blobs.
blobCentroidj = blobMeasurements(j).Centroid;
blobCentroidk = blobMeasurements(k).Centroid;
horizontalDistances(j, k) = blobCentroidj(1) - blobCentroidk(1);
verticalDistances(j, k) = blobCentroidj(2) - blobCentroidk(2);
end
end
Then just plug in any j and k you want and get the horizontal or vertical distances.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by