minimum distance between 2 objects
古いコメントを表示
I plotted boundries with bwboundries and smoothed them with the sgolay filter then plotted these boundries over RGB image. Could you kindly help me in finding the shortest distance between these two boundaries (the shortest distance of the area in-between the red and yellow lines)?
採用された回答
その他の回答 (1 件)
Image Analyst
2022 年 11 月 20 日
If xy is an N by 2 array of (x,y) coordinates, then (untested)
allDistances = pdist2(xy1, xy2);
minDistance = min(allDistances(:))
% Find index of closest pair
[row, column] = find(allDistances == minDistance);
% Draw a line between them
x1 = xy1(row, 1);
y1 = xy1(row, 2);
x2 = xy2(col, 1);
y2 = xy2(col, 2);
hold on;
line([x1, x2], [y1, y2], 'LineWidth', 2, 'Color', 'b')
カテゴリ
ヘルプ センター および File Exchange で Image Category Classification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!