finding x-y coordinate of object with specific distance

3 次查看(过去 30 天)
hello,
I have a binary image with five objects in it, I've found the distances between each pair, I gonna find the x-y coordinates of the two objects which have the special distances (for example the biggest distances), how can I do that? Thank you for your help in advance.

采纳的回答

Walter Roberson
Walter Roberson 2015-11-19
With PairWiseDistanceArray being your 5 x 5 distance array where the index (I,J) is the distance between object #I and object #J, then:
[maxdistance, maxidx] = max(PairWiseDistanceArray(:));
[object1idx, object2idx] = ind2sub(size(PairWiseDistanceArray),maxidx);
The maximum distance was maxdistance and it was between object #object1idx and object #object2idx
  11 个评论
Walter Roberson
Walter Roberson 2015-11-21
obj1 and obj2 are not the x and y coordinates, they are the object number.
xp1 = centrex(obj1);
xp2 = centrex(obj2);
yp1 = centreY(obj1);
yp2 = centreY(obj2);

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geometric Transformation and Image Registration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by