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?
1 view (last 30 days)
Show older comments
Zohreh Tavakkoli
on 27 May 2014
Commented: Zohreh Tavakkoli
on 27 May 2014
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?
0 Comments
Accepted Answer
Image Analyst
on 27 May 2014
Edited: Image Analyst
on 27 May 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 Comments
Image Analyst
on 27 May 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.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!