文章目錄
曼哈頓距離
出租車距離Taxicab geometry或曼哈頓距離 city block distance, Manhattan distance, or Manhattan length
曼哈頓距離——兩點在南北方向上的距離加上在東西方向上的距離,即d(i,j)=|xi-xj|+|yi-yj|。對於一個具有正南正北、正東正西方向規則布局的城鎮街道,從一點到達另一點的距離正是在南北方向上旅行的距離加上在東西方向上旅行的距離,因此曼哈頓距離又稱為出租車距離,曼哈頓距離不是距離不變數,當座標軸變動時,點間的距離就會不同。
曼哈頓與歐幾裡得距離: 紅、藍與黃線分別表示所有曼哈頓距離都擁有一樣長度(12),而綠線表示歐幾裡得距離有6×√2 ≈ 8.48的長度。
---------------------------------------------------------------------------------------------------------------------------------------
歐幾裡得距離Euclidean distance ,用尺子測量的距離
In mathematics, the Euclidean distance or Euclidean metric is the "ordinary" distance between two points that one would measure with a ruler, and is given by the Pythagorean formula
歐式距離即兩項間的差是每個變數值差的平方和再平方根。
3、切比雪夫距離 Chebyshev distance
國際象棋玩過嗎?國王走一步能夠移動到相鄰的8個方格中的任意一個。那麼國王從格子(x1y1)走到格子(x2y2)最少需要多少步?自己走走試試。你會發現最少步數總是max( | x2-x1 | | y2-y1 | ) 步 。有一種類似的一種距離度量方法叫切比雪夫距離。
|
a |
b |
c |
d |
e |
f |
g |
h |
|
| 8 |
|
|
|
|
|
|
|
|
8 |
| 7 |
|
|
|
|
|
|
|
|
7 |
| 6 |
|
|
|
|
|
|
|
|
6 |
| 5 |
|
|
|
|
|
|
|
|
5 |
| 4 |
|
|
|
|
|
|
|
|
4 |
| 3 |
|
|
|
|
|
|
|
|
3 |
| 2 |
|
|
|
|
|
|
|
|
2 |
| 1 |
|
|
|
|
|
|
|
|
1 |
|
a |
b |
c |
d |
e |
f |
g |
h |
|
The Chebyshev distance between two spaces on a chess board gives the minimum number of moves a kingrequires to move between them. This is because a king can move diagonally, so that the jumps to cover the smaller distance parallel to a rank or column is effectively absorbed into the jumps covering the larger. Above are the Chebyshev distances of each square from the square f6. --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------http://homepages.inf.ed.ac.uk/rbf/HIPR2/metric.htmDistance Metrics
It is often useful in image processing to be able to calculate the distance between two pixels in an image, but this is not as straightforward as it seems. The presence of the pixel grid makes several so-called distance metrics possible which often give different answers to each other for the distance between the same pair of points. We consider the three most important ones.
Euclidean Distance
This is the familiar straight line distance that most people are familiar with. If the two pixels that we are considering have coordinates and , then the Euclidean distance is given by:
City Block Distance
Also known as the Manhattan distance. This metric assumes that in going from one pixel to the other it is only possible to travel directly along pixel grid lines. Diagonal moves are not allowed. Therefore the `city block' distance is given by:
Chessboard Distance
This metric assumes that you can make moves on the pixel grid as if you were a King making moves in chess, i.e. a diagonal move counts the same as a horizontal move. This means that the metric is given by:
Note that the last two metrics are usually much faster to compute than the Euclidean metric and so are sometimes used where speed is critical but accuracy is not too important.
參考:
http://en.wikipedia.org/wiki/Distance_transform
Common metrics are: ***************
- Euclidean distance
- Taxicab geometry, also known as City block distance or Manhattan distance.
- Chessboard distance