Calculating Perpendicular Distance Between Detected Edge and Smoothing Function
29 ビュー (過去 30 日間)
古いコメントを表示
Kajetan Planötscher
2024 年 11 月 15 日 12:09
コメント済み: Kajetan Planötscher
2024 年 11 月 19 日 7:17
The following picture shows an edge detected (yellow line) and a smoothing function approximating the detected edge (orange line). I want to determine the distance between the orange and the yellow line perpendicular to the orange line for each point of the yellow line. The yellow line is a nx2 double vector with x and y values, whereas the orange line is a curve created by the cscvn function. I attached both lines as .mat files. However, I neither found a suitable thread helping me out with this problem, nor did I come up with a solution myself. I would be very happy to get some suggestions on how to solve the issue. Thanks a lot!
0 件のコメント
採用された回答
John D'Errico
2024 年 11 月 15 日 12:31
編集済み: John D'Errico
2024 年 11 月 15 日 12:40
If your curve is represented as a sequence of points (which is always possible) then you can use my distance2curve utility. It finds the closest point on such a curve, by repreenting the sequence of points as a spline, then finds the closest point to that spline model.
Find distance2curve on the File Exchange.
For example, I used the code, starting with a set of points on an ellipse, so the small circles. Then for any other point using distance2curve, it finds the closest point on a curve (in a perpendicular sense) that passes through the points I provided. It returns the projected nearest point, as well as the distance.
その他の回答 (1 件)
Image Analyst
2024 年 11 月 15 日 13:03
You could just do a brute force search. Here is untested code.
closestDistances = zeros(1, numel(redx));
for k = 1 : numel(redx)
% Get distances of this red point to all other yellow points.
allDistances = sqrt((redx(k) - yellowx) .^ 2 + (redy(k) - yellowy) .^ 2);
% Assign the minimum distance to our output vector.
closestDistances(k) = min(allDistances);
end
参考
カテゴリ
Help Center および File Exchange で Interpolation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!