Instead of using a single list, pixels to be propagated are stored in a number of buckets, one for each possible distE(p,q) value. Indeed, distE(p,q) is an integer if p and q are located on an integer grid. Thus, it is an appropriate choice for the index d for the buckets, that are processed by increasing index values. For each pixel p in the propagation front, we store its coordinates (px,py) and its coordinates (dpx,dpy)=(px-qx,py-qy) relatively to the nearest pixel q of the object O. This gives the following algorithm, which we call "Euclidean Distance Transformation by Propagation using a Single Neighborhood", or EDT-PSN.
If N is the 4-direct neighborhood, we have
.
Thus, the termination
condition - that all buckets are empty - is true when the last
buckets are empty. With the 8-direct neighborhood,
the whole bucket structure is empty as soon as the last
buckets are empty.
As pointed our earlier [167], an efficient implementation
of the buckets' data structure requires a memory allocation in
chunks for the dynamic lists. In what follows, we use chunks of 16
elements, but a large range of values is acceptable, as discussed
at section
.
Also, special care should be given to the efficient computation of
distE( dp + n ). Leymarie [95] recommends to use eq.
(
), which only requires to use additions, one
shift and one increment. Instead, we routinely use lookup tables
for
,
so that
distE(dp+n)=sq[dpx+nx]+sq[dpy+ny]. This has a similar
computational cost and is more general when n belongs to a large
neighborhood, as we use later.
Finally, as shown by Ragnelmam [127], at most 2
neighbors need to be considered in the propagation phase, as soon
as d>1. For the 8-direct connectivity, this means the neighbors
of figure
. The neighbors for
the 4-direct connectivity are found in figure
.