필터 지우기
필터 지우기

how to find the distance of all objects in given image

조회 수: 9 (최근 30일)
Rahul punk
Rahul punk 2021년 5월 11일
댓글: Rahul punk 2021년 5월 22일

채택된 답변

DGM
DGM 2021년 5월 11일
편집: DGM 2021년 5월 11일
This will give an array mapping the distance from every object to every other object. You could reduce this with triu() if you want, due to the symmetry.
inpict = rgb2gray(imread('dots.jpeg'))>128;
L = bwlabel(inpict); % this identfies all the objects
C = regionprops(inpict,'centroid');
C = vertcat(C.Centroid);
D = sqrt((C(:,1)-C(:,1).').^2 + (C(:,2)-C(:,2).').^2);
If you wanted to find the distance to the nearest object, you could use this (there are probably other ways).
D(abs(D)<1E-6) = NaN; % remove zeros
[Dn Nn] = min(D,[],2); % minimize
% Dn is distance to nearest neighbor
% Nn is nearest neighbor
.
  댓글 수: 18
DGM
DGM 2021년 5월 21일
I don't know what that means.
Rahul punk
Rahul punk 2021년 5월 22일
i d'nt required center distance i have only required corner to corner distances. i agree with DGm Answer.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by