Any distance metric between pixels
and
must satisfy:
Specifically, the distance between pixels at
and
at
can
be defined by one of the following:
(11) |
(12) |
(13) |
From these definitions we see that a general distance definition is
(14) |
The distance in digital image approximates the actual Euclidean
distance in continuous situation.
The numbers in the following array show the distances to the pixel
in the center. Note that all 4-neighbors have distance 1.
4 | 3 | 2 | 3 | 4 |
3 | 2 | 1 | 2 | 3 |
2 | 1 | 0 | 1 | 2 |
3 | 2 | 1 | 2 | 3 |
4 | 3 | 2 | 3 | 4 |
The numbers here are the distances to the pixel in the center.
Note that all 8-neighbors have distance 1.
2 | 2 | 2 | 2 | 2 |
2 | 1 | 1 | 1 | 2 |
2 | 1 | 0 | 1 | 2 |
2 | 1 | 1 | 1 | 2 |
2 | 2 | 2 | 2 | 2 |
The following figure shows the iso-distance contours composed of all
points having equal distance to the center point. The circle is for
Euclidean distance, the square is for the distance, the diamond
is for the
distance.
Distance between two connected pixels can be defined as the number of hops from one pixel to the next along the shortest path connecting the two pixels, according to the definition of connectivity (4, 8, or mix-connected).
The upper-right pixel is 8 and mix-connected to the lower-left pixel
with a distance 2:
0 | 0 | 1 |
0 | 1 | 0 |
1 | 0 | 0 |
The upper-right pixel is 4 and mix-connected to the lower-left pixel
with a distance 4:
0 | 1 | 1 |
0 | 1 | 0 |
1 | 1 | 0 |