how to find cityblock distance?
Ältere Kommentare anzeigen
how to find the city block distance between feature vectors to query image feature vector, in matlab2013?
Antworten (3)
Jan
am 2 Okt. 2018
0 Stimmen
pdist and pdist2 can calculate the city block distance.
Fowzi barznji
am 16 Mär. 2020
0 Stimmen
x=[1 3 9 6 4 2 6 8 3 6];
y=[4 -2 6 8 8 3 7 2 1 1];
cityblockvalue = sum((abs(x - y)));
cityblockvalue= 32
7 Kommentare
Fowzi barznji
am 16 Mär. 2020
so u can use
cityblockvalue = pdist2(X,Y,'cityblock');
same result
Image Analyst
am 16 Mär. 2020
This will give the "as the crow flies" city block distance. If you have a path that is not directly from point A to point B in a straight line, for example a spiral, then you'll have to actually follow the path and sum up the delta x and delta y as you step along the path from one point to the next. That is probably not the case you have, but I'm just mentioning it for completeness.
Fowzi barznji
am 16 Mär. 2020
100% right
thanks to your skill
rema
am 10 Jan. 2023
hi ,please how applied city block distance if have two vecter such as
a=[1,2,3]
b=[4,5,6;
7,8,9;
10,11,12]
Rik
am 10 Jan. 2023
You don't have two vectors, you have a vector and a matrix. The numbere of elements also doesn't match. What would you do if you had to calculate this by hand?
b is not a vector. It depends what the relationship between a and b is.
Assuming that a is a row vector and applies in whole to each row of b in the same way, then the distance for each row is:
x = [1 2 3];
y = [4 5 6; % i made this 4x3 so that it's easy to see the orientation
7 8 9;
10 11 12;
13 14 15];
D = pdist2(x,y,'cityblock').'
D = sum((abs(x - y)),2) % works R2016b+
rema
am 16 Feb. 2023
thank you
Fowzi barznji
am 16 Mär. 2020
0 Stimmen
try these files
may be contain an interest to u
2 Kommentare
rema
am 16 Feb. 2023
hi,how obtain on lable image for using in classification by using knn
Kategorien
Mehr zu Nearest Neighbors finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!