2.6.1 Distance Transform

The distance transform is an operator normally only applied to binary images. The result of the transform is a graylevel image that looks similar to the input image, except that the graylevel intensities of points inside foreground regions are changed to show the distance to the closest boundary from each point.

There is a dual to the distance transform which provides the distance for the backgroundregion rather than the foreground region. It is equivalent to inverting the image and applying the regular distance transform.

There are at least the following three distance metrics:

  • Euclidean Distance: sqrt((x2-x1)2+(y2-y1)2)
  • City Block Distance: abs(x2-x1)+abs(y2-y1)
  • Chessboard Distance: max(abs(x2-x1),abs(y2-y1))

    Here are some examples:
    Before
    After