How can I automatically find the maximum distance between two objects?
2 次查看(过去 30 天)
显示 更早的评论
I want to find the distance from the dot on the left to the furthest point on the object to the right. How could I do this?
Thank you very much
0 个评论
采纳的回答
Matt J
2018-6-18
编辑:Matt J
2018-6-18
justdot= bwareafilt(yourImage,1,'smallest'); %image of dot only
S=regionprops(justdot,'Centroid'); %find center of dot
ctr=flip( round(S.Centroid) );
ic=ctr(1);
jc=ctr(2);
[Iw,Jw]=find( yourImage & ~justdot ); %coordinates of white pixels excluding dot
max_distance=sqrt( max( (ic-Iw).^2+(jc-Jw).^2) ) ); %the result
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!