Borrar filtros
Borrar filtros

How to find euclidean distance

112 visualizaciones (últimos 30 días)
aarti sawant
aarti sawant el 20 de En. de 2014
Comentada: William el 19 de Mayo de 2023
Plz help me to find euclidean distance between two pixels within same image without using direct matlab command
  2 comentarios
Walter Roberson
Walter Roberson el 20 de En. de 2014
What is a "direct MATLAB command"? Even
3 + 5
is considered a command and invokes a MATLAB function ("plus")
Fahim Ahmed
Fahim Ahmed el 23 de Feb. de 2020
i guess he meant a matlab in-built command

Iniciar sesión para comentar.

Respuesta aceptada

David Sanchez
David Sanchez el 20 de En. de 2014
pix_1 = [p11,p12];
pix_2 = [p21,p22];
distance = sqrt( (p21-p11)^2 + (p22-p12)^2 );
  10 comentarios
Walter Roberson
Walter Roberson el 21 de En. de 2014
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 el 19 de Mayo de 2023
Doesn't the dist(W,P) function also help with this?

Iniciar sesión para comentar.

Más respuestas (1)

Geetika
Geetika el 21 de En. de 2014
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 ) ;

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by