distance between several objects in binary image

Does anyone know how can I find distance between these three animals from each other in a binary image (distance between each two red points)?

 採用された回答

Image Analyst
Image Analyst 2014 年 12 月 1 日

0 投票

I already gave code for something almost identical to that here.

6 件のコメント

Image Analyst
Image Analyst 2014 年 12 月 1 日
All right, attached is a more general purpose one that works with multiple blobs to find all closest distance pairs.
Faiz Yusoff
Faiz Yusoff 2021 年 2 月 20 日
How can i get this result using thermal image?
Image Analyst
Image Analyst 2021 年 2 月 20 日
What result? Is that image the "result" you want to get? Or is that your thermal image and you want to find the distance between each hot spot? Please use more words to describe exactly what you want. And it's best to start your own new question on this.
Faiz Yusoff
Faiz Yusoff 2021 年 2 月 20 日
i already asked in the question and mentioned you, if you could find it. Yes exactly i want to use the thermal image to find the distance between the each of hot spots.
Image Analyst
Image Analyst 2021 年 2 月 20 日
@Faiz Yusoff I already answered this in another post of yours.
Faiz Yusoff
Faiz Yusoff 2021 年 2 月 20 日
noted thank you so much!

サインインしてコメントする。

その他の回答 (1 件)

yanqi liu
yanqi liu 2021 年 2 月 20 日

0 投票

sir, may be use the follow code
clc; clear all; close all;
img=imread('image.jpeg');
J = rgb2lab(img);
a = mat2gray(J(:,:,2));
bw = im2bw(a, graythresh(a));
bw = imclose(bw, strel('disk', 5));
stats = regionprops(bw);
cens = cat(1, stats.Centroid);
figure;
imshow(img);
hold on;
plot(cens(:,1), cens(:,2), 'co', 'MarkerFaceColor', 'c');
dis_m = [];
for i = 1 : size(cens, 1)
pti = cens(i,:);
if i > size(cens, 1)/2+1
continue;
end
for j = 1 : size(cens, 1)
if i == j
continue;
end
ptj = cens(j,:);
dis = norm(pti-ptj);
dis_m(i,j) = dis;
plot([pti(1) ptj(1)], [pti(2) ptj(2)], 'r--', 'LineWidth', 2);
text(mean([pti(1) ptj(1)]), mean([pti(2) ptj(2)]), sprintf('%.1f', dis), 'Color', 'm', 'FontSize', 15);
end
end

質問済み:

Abo
2014 年 12 月 1 日

コメント済み:

2021 年 2 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by