How to find euclidean distance

149 次查看(过去 30 天)
Plz help me to find euclidean distance between two pixels within same image without using direct matlab command
  2 个评论
Walter Roberson
Walter Roberson 2014-1-20
What is a "direct MATLAB command"? Even
3 + 5
is considered a command and invokes a MATLAB function ("plus")
Fahim Ahmed
Fahim Ahmed 2020-2-23
i guess he meant a matlab in-built command

请先登录,再进行评论。

采纳的回答

David Sanchez
David Sanchez 2014-1-20
pix_1 = [p11,p12];
pix_2 = [p21,p22];
distance = sqrt( (p21-p11)^2 + (p22-p12)^2 );
  10 个评论
Walter Roberson
Walter Roberson 2014-1-21
bwdist() does not compute distance between millions of points. bwdist() finds the points that are not part of objects, and calculates the distance from each point to the closest point that is part of some object.
If you want to operate on multiple points, then the small change to the formula already given is
distance = sqrt( (p21-p11).^2 + (p22-p12).^2 );
where the variables given there are all vectors.
If you want to calculate the distance of each point to every other point then you can use pdist() from the Stats toolbox.
William
William 2023-5-19
Doesn't the dist(W,P) function also help with this?

请先登录,再进行评论。

更多回答(1 个)

Geetika
Geetika 2014-1-21
if you have two vectors with any number of point, for instance, x1=[1 2 3 4 5] and x2=[2 3 4 5 6], then Euc_dist = norm( x1 - x2 ) ;

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by