How can I automatically find the maximum distance between two objects?

조회 수: 1 (최근 30일)
khalid jackson
khalid jackson 2018년 6월 18일
편집: Matt J 2018년 6월 18일
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

채택된 답변

Matt J
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개)

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by