zoukankan      html  css  js  c++  java
  • 一些距离测算方法

    曼哈顿距离

    出租车距离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 | ) 步 。有一种类似的一种距离度量方法叫切比雪夫距离。
     
    Solid white.svg a b c d e f g h Solid white.svg
    8 a8 five b8 four c8 three d8 two e8 two f8 two g8 two h8 two 8
    7 a7 five b7 four c7 three d7 two e7 one f7 one g7 one h7 two 7
    6 a6 five b6 four c6 three d6 two e6 one f6 white king g6 one h6 two 6
    5 a5 five b5 four c5 three d5 two e5 one f5 one g5 one h5 two 5
    4 a4 five b4 four c4 three d4 two e4 two f4 two g4 two h4 two 4
    3 a3 five b3 four c3 three d3 three e3 three f3 three g3 three h3 three 3
    2 a2 five b2 four c2 four d2 four e2 four f2 four g2 four h2 four 2
    1 a1 five b1 five c1 five d1 five e1 five f1 five g1 five h1 five 1
    Solid white.svg a b c d e f g h Solid white.svg
    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.htm

    Distance 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 Eqn:eqnmet1 and Eqn:eqnmet2, then the Euclidean distance is given by:

    Eqn:eqnmet3

    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:

    Eqn:eqnmet4

    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:

    Eqn:eqnmet5

    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:   ***************

  • 相关阅读:
    如何将AutoCAD(Dwg、Dxf)文件转换为Shapefile(Shp)文件?
    如何将AutoCAD(Dwg、Dxf)文件转换为KML(kml、kmz)文件?
    如何将Shapefile(Shp)文件转换为KML(kml、kmz)文件?
    如何将Shapefile(Shp)文件转换为AutoCAD(Dwg、Dxf)文件?
    vue-scroller下拉刷新及无限加载组件学习之路
    link和@important引入css的区别
    浏览器兼容问题
    学习vue一段时间的感想
    div在父元素中的居中问题
    jquery的ajax请求bug
  • 原文地址:https://www.cnblogs.com/cute/p/2195260.html
Copyright © 2011-2022 走看看