フィルターのクリア

How to find the nearest points from 2D image?

3 ビュー (過去 30 日間)
Sara
Sara 2022 年 10 月 6 日
編集済み: Matt J 2022 年 10 月 6 日
Hi
I am working on how to find the nears points in 2D images. I was able to find the coorndates of these image
upload1 = load('xy_data.mat');
x = upload1.x
y = upload1.y
P = [x y];
figure,
plot(x(:),y(:),'bo');
The idea is select 3 poins as
[px0 py0] = ginput(3);
From the 2D image, then find the distance between the selected points to all other points in the image.
My apparoch is finding the magntude of the selecting poins.
% find postios
point0 = [px0(1) py0(1)];
point1 = [px0(2) py0(2)];
point2 = [px0(3) py0(3)];
% distance
a_point01 = point1(1) - point0(1);
b_point01 = point1(2) - point0(2);
a_point02 = point2(1) - point0(1);
b_point02 = point2(2) - point0(2);
% find vector
vx = sqrt(a_point01^2 + b_point01^2);
vy = sqrt(a_point02^2 + b_point02^2);
magntude = [vx vy];
I need to find the all neaset poisnts to the magntude that I did in my code.
I attached mat file for x y

回答 (1 件)

Matt J
Matt J 2022 年 10 月 6 日
編集済み: Matt J 2022 年 10 月 6 日
Just use pdist2 or bwdist.

カテゴリ

Help Center および File ExchangeImage Segmentation and Analysis についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by