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 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Image Analyst
2014-5-27
编辑:Image Analyst
2014-5-27
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 个评论
Image Analyst
2014-5-27
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
