A Linear Time Algorithm For Computing Exact Euclidean Distance Transforms of Binary Images in Arbitrary Dimensions
A Linear Time Algorithm For Computing Exact Euclidean Distance Transforms of Binary Images in Arbitrary Dimensions
A Linear Time Algorithm for Computing acceleration techniques for ray-tracing) [37], [49], and shape-based
interpolation [16], [32].
Exact Euclidean Distance Transforms of The Euclidean DT (EDT) is the DT for which the metric is
Binary Images in Arbitrary Dimensions Euclidean distance. Sometimes the EDT is used, but often, even
when an exact EDT is desired, an approximation of the EDT such as
Calvin R. Maurer, Jr., Member, IEEE, Rensheng Qi, the chamfer DT is used because it is substantially faster to compute.
For some applications, an exact EDT is required. For example,
and Vijay Raghavan, Senior Member, IEEE
various approximations of the EDT have been used to generate
skeletons of binary objects [1], [24], but only the exact EDT can
Abstract—A sequential algorithm is presented for computing the exact Euclidean produce an accurate skeleton that is reversible (i.e., allows exact
distance transform (DT) of a k-dimensional binary image in time linear in the total reconstruction of the object), rotation invariant, and minimal [13].
number of voxels N. The algorithm, which is based on dimensionality reduction and The 3D EDT has recently been used to generate skeletons of
partial Voronoi diagram construction, can be used for computing the DT for a wide radiosurgical targets (e.g., brain tumors) for treatment planning and
class of distance functions, including the Lp and chamfer metrics. At each optimization in multiisocentric stereotactic radiosurgery [45], [46].
dimension level, the DT is computed by constructing the intersection of the Voronoi
The exact EDT of a k-D image can obviously be computed by
diagram whose sites are the feature voxels with each row of the image. This
construction is performed efficiently by using the DT in the next lower dimension. using a brute-force exhaustive search for CFVs, which is a procedure
The correctness and linear time complexity are demonstrated analytically and that inherently requires OðN 2 Þ time. Algorithms for computing the
verified experimentally. The algorithm may be of practical value since it is relatively exact EDT of a 2D image have been reported that require OðN 3=2 Þ
simple and easy to implement and it is relatively fast (not only does it run in time [25], [26], and OðN log NÞ time [20]. It is clear that the exact EDT
OðNÞ time but the time constant is small). A simple modification of the algorithm of a k-D image can be computed in OðN log NÞ time by calculating
computes the weighted Euclidean DT, which is useful for images with anisotropic
the Voronoi diagram of the FVs [6], [29]. A relatively efficient, but
voxel dimensions. A parallel version of the algorithm runs in OðN=pÞ time with
p processors. not linear time, algorithm for computing the EDT of a k-D image was
achieved using gray-scale morphology decomposition [18].
A substantial amount of effort has been devoted to algorithms
Index Terms—Euclidean distance transform, closest feature transform,
Voronoi diagram.
that compute the DT by propagation. One type of algorithm
propagates distance values from voxels to neighboring voxels.
æ Algorithms that require OðNÞ time for computing the DT of a k-D
image for the L1 , L1 , and chamfer (a weighted L1 metric that
1 INTRODUCTION provides an approximation to the L2 metric) metrics with a two-pass
A k-dimensional (k-D) binary image is a function I from the sequential raster scan are well-known [4], [5], [25], [26], [34], [35],
elements of an n1 . . . nk array to f0; 1g. The elements are called [48]. The weights in the kernel (propagation mask) can be chosen to
pixels when k ¼ 2 and voxels when k 3. Voxels of value 0 and 1 optimize the approximation of a chamfer DT to the EDT [3], [5], [33],
are called background voxels and foreground or feature voxels [38], [41], [44]. This type of approach has also been used to compute
(FVs), respectively. For a given distance metric, the distance constrained DTs, which are DTs where distance is defined only
transform (DT) of an image I is an assignment to each voxel x of within a specified constraint region [28], [42]. An alternative type of
the distance between x and the closest feature voxel (CFV) in I. algorithm propagates the position of the CFV (a vector pointing to
The closest feature transform (FT), also known as the nearest feature the CFV) rather than distance (a scalar). This idea was originally
transform and the nearest neighbor transform, of an image I is an proposed as a sequential raster-scan algorithm for 2D images [9] and
assignment to each voxel x of the identity of the CFV in I. It is clear was later generalized to arbitrary dimensions [31] and images with
that a DT can be computed from a FT in time linear in the total anisotropic voxel dimensions [23]. These raster-scan algorithms
number of voxels N ¼ n1 . . . nk . require OðNÞ time and produce an approximate EDT with small
DTs are useful for a variety of image processing and computer error (the maximum error in 2D is less than one pixel [9]). An
vision applications [25]. Examples include nearest-neighbor inter- alternative to raster-scan propagation is ordered propagation. In
polation, planar tesselation, morphological image processing (e.g., these algorithms, the information (distance [28], [42] or a vector
thinning, thickening, and skeletonization), pattern matching (e.g., pointing to the CFV [8], [10], [30], [43]) is propagated from each voxel
object detection and stereo feature matching), robot collision to its neighbors, starting from the contours of the object and using a
avoidance, and path finding. DTs are widely used in medical image dynamic list to store the pixels in the propagation front. Standard
processing. For example, in surface-based image registration, the propagation algorithms provide only approximate EDTs because
DT of a binary image in which the FVs represent a surface provides a the tiles of the Voronoi diagram on a discrete lattice are not
necessarily connected sets (the tiles on a continuous plane are
convenient and efficient method for precomputing and storing
connected sets). Parallel algorithms can overcome this limitation and
point-to-surface distance [12], [14], [19], [39], [40]. DTs have also
provide exact EDTs by allowing multiple propagation fronts to
been used in nonrigid image registration [22], [27], morphological follow each other [11], [18], [47]. Ordered propagation can provide
image segmentation [15], volume visualization (distance-based an exact EDT by emulating multiple-front propagation [10], [23],
[30], but the multiple propagation mechanics common to these exact
EDT algorithms require many unnecessary computations while
. C.R. Maurer, Jr. is with Image Guidance Laboratories, Department of successive propagation fronts reach the same voxel and update its
Neurosurgery, Stanford University, 300 Pasteur Drive, MC 5327, Room
value, and these algorithms require OðN 3=2 Þ time for some 2D images
S-012, Stanford, CA 94305-5327. E-mail: [email protected].
. R. Qi is with Imaging Diagnostic Systems, Inc., Plantation, FL 33313. [8]. One recent algorithm first computes an approximate EDT using
E-mail: [email protected]. an ordered propagation scheme and then produces an exact EDT by
. V. Raghavan is with the Department of Electrical Engineering and restoring the connectivity of the Voronoi tiles by considering larger
Computer Science, Vanderbilt University, Nashville, TN 37235. neighborhoods on the tile boundaries [8] (a similar approach using
E-mail: [email protected]. raster-scan propagation has also been reported [7]). This is the only
Manuscript received 20 Mar. 2001; revised 27 May 2002; accepted 23 July 2002. propagation algorithm we are aware of that produces an exact EDT
Recommended for acceptance by H. Christensen. in apparently OðNÞ time, but the time complexity was verified only
For information on obtaining reprints of this article, please send e-mail to: experimentally, and extension to multidimensional or anisotropic
[email protected], and reference IEEECS Log Number 113833. images has not been reported.
0162-8828/03/$17.00 ß 2003 IEEE Published by the IEEE Computer Society
266 IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. 25, NO. 2, FEBRUARY 2003
Saito and Toriwaki [36] presented an algorithm for computing 1) ðx; uÞ ðx; vÞ and ðy; vÞ < ðy; uÞ or 2) ðx; uÞ <
the exact EDT of a 2D or 3D image that is based on dimensionality ðx; vÞ and ðy; vÞ ðy; uÞ holds, ud < vd .
reduction, that is, at each dimension level, the EDT is determined
Property 5. Let x and y be two k-tuples that differ only in the values of
by using the EDT in the next lower dimension. They used some
the dth coordinates (i.e., xi ¼ yi , i 6¼ d). Let u and v be two k-tuples
geometrical bounds to reduce search intervals. The computational
cost of their algorithm is image dependent and requires OðN 3=2 Þ with identical values of the dth coordinates (i.e., ud ¼ vd ). If
time for some 2D images; this time complexity has been observed ðx; uÞ ðx; vÞ, then ðy; uÞ ðy; vÞ.
experimentally by us (unpublished) and others [7], [8]. Breu et al. It is well known that the Lp , weighted Lp , and chamfer metrics
[6] presented an algorithm which also uses the idea of dimension- satisfy Properties 1-4. Property 5 follows from the contrapositive of
ality reduction for computing the Euclidean FT of a 2D image in Property 4. Thus, any distance function that satisfies Property 4
OðNÞ time by constructing the intersection of the Voronoi diagram also satisfies Property 5. Property 5 is not an independent
whose sites are the FVs with each row of the image. Then, the EDT property, but it is convenient to include for later reference.
is computed from the FT. Guan and Ma [17] improved the In the next section, we give an algorithm for computing the FT
computational performance of the Breu approach by taking of a k-D binary image for any distance metric that satisfies
advantage of the fact that neighboring voxels tend to have the Properties 1, 2, 3, 4, and 5. This algorithm is not appropriate for all
same CFVs. They propagate CFV information in the form of distance functions. For example, consider the distance function
segment lists rather than individual voxels. ðx; yÞ ¼ jx1 ÿ y1 jjx2 ÿ y2 j, which is given as an example in [26].
In this paper, we first present an algorithm for computing the FT This function satisfies Properties 2 and 5 but not 1, 3, and 4.
of a k-D binary image in OðNÞ time. This algorithm can be used for a
wide class of distance functions, including Euclidean distance as
well as the Lp and chamfer metrics. We then present an algorithm for 3 THE FEATURE TRANSFORM ALGORITHM
computing, directly, the EDT in arbitrary dimensions that runs in
The Voronoi diagram V S of a set of Voronoi sites S ¼ ff i g for i ¼
OðNÞ time. This algorithm is in a sense a generalization of the Breu
1; . . . ; nS consists of a set of disjoint Voronoi cells V S ¼ fCf i g for
algorithm to arbitrary dimensions. Like Guan and Ma, we use
i ¼ 1; . . . ; nS [2], [29]. The Voronoi cell Cf is the set of all points whose
properties of the L2 metric to improve computational performance
closest point is f together with the cell boundary formed by points
with respect to Breu. Unlike both Breu and Guan and Ma, we
equidistant from f and one or more other Voronoi sites. The Voronoi
compute the EDT directly rather than first compute the FT; as a
result, our algorithm is an order of magnitude faster than their site f is also known as the Voronoi center of Cf . The FT of a binary
algorithms. We believe this is the first algorithm that computes the image can be thought of as a discretized version of the Voronoi
exact EDT of a k-D image in OðNÞ time without first computing a FT diagram whose Voronoi sites are the FVs of the image. If the
and for which the correctness and time complexity are formally complete Voronoi diagram is constructed, the FT can be computed
verified. This algorithm may be of practical value since it is relatively easily by querying the Voronoi diagram, i.e., by recording for each
simple and easy to implement and it is relatively fast (not only does it voxel the Voronoi site of the Voronoi cell in which the voxel lies. In
run in OðNÞ time but the time constant is small). A simple this algorithm, we do not construct the complete Voronoi diagram.
modification of the algorithm computes the weighted Euclidean Instead, our approach is based on the idea of dimensionality
DT, which is useful for images with anisotropic voxel dimensions. A reduction and partial Voronoi diagram construction. At each
parallel version of the algorithm runs in OðN=pÞ time with dimension level, the FT is determined by constructing directly the
p processors, 1 p minðn1 ; . . . ; nk Þ. intersection of the Voronoi diagram whose Voronoi sites are the FVs
with each row of the image. This construction is performed
efficiently by using the FT in the next lower dimension.
2 DISTANCE FUNCTIONS AND PROPERTIES The algorithm takes as input the k-D binary image I :
We are interested in the Lp distance metric ½1::n1 . . . ½1::nk ! f0; 1g and outputs the FT
Fig. 1. Illustrative example of the relationship among Sd , Sd0 , and Sd . In all panels, the dotted lines represent the grid of an 8 8 binary image, the open circles represent
Xd ¼ fxi g, the thick line running through the open circles represents the row Rd , the filled circles represent FVs, the thin lines represent the Voronoi cell boundaries of the
Voronoi diagram whose Voronoi sites are the FVs, and d ¼ k ¼ 2. (a) The FVs shown are the set Sd . (b) The FVs shown are the set Sd0 ¼ fFdÿ1 ðxi Þg, i.e., the set of CFVs in
the next lower dimension for the set of voxels fxi g on the row Rd . In this example, Fdÿ1 ðxi Þ is the CFV in the same column as xi . The two FVs indicated by arrows in the top
left panel are equidistant from Rd . The top one was chosen arbitrarily. (c) The FVs shown are the set Sd . (d) The FVs shown are the set Sd obtained by choosing the bottom
of the two equidistant FVs in the top left panel. Note that Sd Sd0 Sd and V d = V Sd \ Rd = V Sd0 \ Rd = V Sd \ Rd . This is true for both choices of the two equidistant FVs.
Remark 1. Let f ¼ Fdÿ1 ðxÞ, where x is a voxel on the row Sd . on the row Rd , it is not necessary to actually construct V d =
Clearly, the FV f belongs to the set Sd . Let g be any other FV fCf i g. It is sufficient to determine the ordered set Sd and visit
belonging to the set Sd such that f and g have identical values of each voxel by traversing the row in dth coordinate order.
the dth coordinate (i.e., fd ¼ gd ). From the definition of Fd , Remark 3. Let u, v, and w be three FVs belonging to the set Sd0 such
ðx; f Þ ðx; gÞ. Let y be any other point on the row Rd . By that ud < vd < wd . Let xuv denote the point on the line Rd that is
Property 5, ðy; f Þ ðy; gÞ, i.e., all points on the row Rd are at equidistant from u and v, i.e., ðu; xuv Þ = ðv; xuv Þ, and let
least as close to f as they are to g. This means that either the ðxuv Þd denote the dth coordinate of this point. Let xvw denote
Voronoi cell for site g does not intersect Rd ððx; f Þ < ðx; gÞÞ, another point defined analogously. By Property 4 and Remark 2,
or that the Voronoi cells for sites f and g both intersect Rd along Cv does not intersect Rd if ðxuv Þd > ðxvw Þd .
a common boundary ððx; f Þ ¼ ðx; gÞÞ and the choice of f or g The algorithm for computing the FT F from the binary image I is
is arbitrary. Since all FVs in the set Sd are either in the set Sd0 or performed with the initial invocation COMPUTEFTðkÞ. The algo-
have the same dth coordinate as a FV in the set Sd0 , V d = rithm variables I; F ; n1 ; . . . ; nk are global variables. The procedure
V Sd \ Rd = V Sd0 \ Rd . Thus, to construct V d , it is sufficient to COMPUTEFT (Fig. 2) implements dimensionality reduction using
consider the set Sd0 (rather than the larger set Sd ). recursion. The procedure VORONOIFT (Fig. 3) constructs and
Let Sd denote the subset of Sd that are the Voronoi sites (FVs) of queries the partial Voronoi diagram V d ¼ V Sd \ Rd ¼ V Sd \ Rd . The
Voronoi cells in V d , i.e., that are the Voronoi sites of Voronoi cells algorithm variable F contains successively F0 , F1 , . . . , Fkÿ1 , Fk ¼ F .
in V Sd that intersect Rd . Clearly, Sd Sd0 Sd . Fig. 1 shows an It contains Fdÿ1 before the call to VORONOIFT and Fd upon return.
illustrative example of the relationship among Sd , Sd0 , and Sd . As noted in Remark 2, the algorithm does not actually construct V d ,
but instead determines the ordered set Sd (VORONOIFT, lines 1-14)
Remark 2. Let f and g be FVs belonging to the set Sd . Let x and y and queries the diagram (visits each voxel) by traversing the row in
be voxels on the row Rd that lie in the Voronoi cells Cf and Cg , dth coordinate order (lines 18-24). The set Sd ¼ fgl g is constructed
respectively. By Property 4, if xd < yd , then fd < gd . Also, if from the set Sd0 ¼ ff i g by deleting those FVs in Sd0 that are the
fd < gd , then xd < yd . Thus, V d is a set of disjoint line segments Voronoi sites of Voronoi cells that do not intersect Rd . As noted in
V d = fCf i g. If the set of Voronoi sites (FVs) Sd are sorted by the Remark 1, it is sufficient to consider the set Sd0 ¼ fFdÿ1 ðxi Þg. This is
dth coordinate, the associated Voronoi cells are similarly the fundamental basis of the dimensionality reduction approach.
ordered. That is, as the row Rd is traversed from low values The set Sd is constructed in lines 1-14. It is initialized with the first
of the dth coordinate to high values, Cf is visited before Cg iff f two FVs of Sd0 . In the outer loop, additional FVs are added from Sd0
precedes g in the ordered set Sd . To compute Fd for each voxel one at a time. In the inner loop, FVs that are the Voronoi sites of
268 IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. 25, NO. 2, FEBRUARY 2003
V d ¼ V Sd \ Rd ¼ V Sd0 \ Rd ¼ V Sd0 \ Rd ¼ V Sd \ Rd : is the distance between u and the row Rd . Since xuv denotes the point
There are two subtleties in VORONOIFT, line 20 worth noting. on Rd that is equidistant from u and v, 2 ðu; xuv Þ ¼ 2 ðv; xuv Þ,
First, although an if statement may seem sufficient, in fact the while which can be rearranged to obtain
statement is necessary. The reason is that although the FT is discrete,
the Voronoi diagram V Sd and the row Rd are continuous. All 2 ðv; Rd Þ ÿ 2 ðu; Rd Þ þ v2d ÿ u2d
ðxuv Þd ¼ :
Voronoi cells in V Sd intersect Rd , but the first several cells may, for 2ðvd ÿ ud Þ
example, intersect Rd only where the dth coordinate is negative (an
A similar expression can be found for ðxvw Þd , from which it is easy to
example is illustrated in Fig. 1). Also, it is possible that a Voronoi cell
verify that the inequality ðxuv Þd > ðxvw Þd is equivalent to the
in V Sd intersects Rd only between two consecutive voxels xi and xiþ1
inequality
and, thus, the intersection does not contain any voxel on Rd . Second,
the “> ” symbol in the distance comparison could be replaced with
c 2 ðv; Rd Þ ÿ b 2 ðu; Rd Þ ÿ a 2 ðw; Rd Þ ÿ abc > 0; ð2Þ
the “ ” symbol. When two FVs are equidistant from the voxel x,
Fd ðxÞ is not unique and the choice is arbitrary. where a ¼ vd ÿ ud , b ¼ wd ÿ vd , c ¼ wd ÿ ud ¼ a þ b. This inequality
Initialization of F0 (COMPUTEFT, lines 2-8) takes OðNÞ time. requires only eleven integer arithmetic operations for its evalua-
At each dimension d, the procedure VORONOIFT is executed for tion if the squared distances between the FVs u, v, and w and the
each of the N=nd rows. For each row, construction of Sd takes row Rd are known (e.g., precomputed).
Oðnd Þ time, since there are nd FVs in Sd0 , and each FV is added to The algorithm in the previous section provides a method for
and removed from Sd at most once. This assumes that calculating computing the FT of the binary image I. The DT still needs to be
xuv requires Oð1Þ time. Querying (visiting each voxel by traversing computed from the FT. For the Lp metric, in general, and the L2
the row) simply requires Oðnd Þ time. Thus, at each dimension, the metric, in particular, it is possible to compute the DT directly. Let
time complexity is Oðnd N=nd Þ ¼ OðNÞ, and the algorithm for
us consider the squared EDT D. For each voxel x in I, DðxÞ ¼
computing the FT of I runs in OðNÞ time. Finally, it is clear that the
2 ðx; F ðxÞÞ is the squared Euclidean distance between x and the
DT of I can be computed from the FT in OðNÞ time.
CFV in I. By analogy with the definition of Fd in the previous
section, let Dd ðxÞ ¼ 2 ðx; Fd ðxÞÞ. We define D0 ðxÞ = 0 if IðxÞ = 1,
4 THE EUCLIDEAN DISTANCE TRANSFORM ALGORITHM 1 otherwise. We observe that if u ¼ Fdÿ1 ðxÞ, then
If the distance metric is the L2 metric (Euclidean distance), then 2 ðu; Rd Þ ¼ 2 ðx; uÞ ¼ 2 ðx; Fdÿ1 ðxÞÞ ¼ Ddÿ1 ðxÞ:
the procedure REMOVEFT can be implemented simply using only
integer arithmetic. The distance between u and xuv can be This important observation allows us to simply modify the
computed as FT algorithm procedures COMPUTEFT and VORONOIFT to obtain
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. 25, NO. 2, FEBRUARY 2003 269
the squared EDT algorithm procedures COMPUTEEDT (Fig. 4) and Fig. 5. Procedure VoronoiEDT(d; j1 ; . . . ; jdÿ1 ; jdþ1 ; . . . ; jk ).
VORONOIEDT (Fig. 5).
The algorithm for computing the squared EDT D from the binary tion than as a call to the procedure VORONOIEDT. This requires a
image I is performed with the initial invocation COMPUTEEDT(k). maximum of eight integer arithmetic operations per voxel. Also, we
The algorithm variable D contains successively D0 , D1 , . . . , Dkÿ1 , note that the number of arithmetic operations in VORONOIEDT, line
Dk ¼ D. It contains Ddÿ1 before the call to VORONOIEDT and Dd 20, can be reduced by taking advantage of similarities in successive
upon return. In VORONOIEDT, the procedure variable computations instead of treating them as independent ones; the
fi ¼ Ddÿ1 ðxi Þ ¼ 2 ðf i ; Rd Þ, gl ¼ 2 ðgl ; Rd Þ, and hl is the dth co- distance comparison requires only four arithmetic operations when l
ordinate of gl . The FV deletion procedure for the squared EDT is incremented. Using these simple optimizations, the squared
algorithm is REMOVEEDT (2 ðu; Rd Þ, 2 ðv; Rd Þ, 2 ðw; Rd Þ, ud , vd , EDT algorithm requires a maximum of 8 þ 33ðk ÿ 1Þ, which is 41 for
wd ), which returns TRUE if the inequality in (2) holds, FALSE k ¼ 2 and 74 for k ¼ 3, integer arithmetic operations per voxel, not
otherwise. including index increment/decrement, indirection, and assignment
operations.
The squared EDT algorithm executes substantially faster than the
5 DISCUSSION FT algorithm because much of the distance computation necessary
The EDT algorithm as presented above produces the squared EDT for the FV deletion procedure (see (2)) is inherently stored in Ddÿ1 .
for isotropic voxels of unit dimension. All computations can be We measured the execution time of straightforward (but not
implemented in integer arithmetic. The EDT can obviously be necessarily well optimized) implementations of the FT and squared
obtained simply from the algorithm output by taking the square EDT algorithms for 2D and 3D images over a wide range of sizes and
root of each element. The output can be scaled to account for content. Our tests included images with a single FV in a corner;
nonunit voxel dimension. And, the algorithm can be modified images with randomly generated FVs where the number of FVs was
easily to accommodate the weighted EDT (see (1)), e.g., for medical set at 1, 2, 5, 10, 20, 50, 80, 90, 95, 98, or 99 percent; images with solid
3D images with anisotropic voxel dimensions. The conversion circles/spheres or squares/cubes where the number, size, position,
requires simply replacing the six occurrences of the coordinate and orientation of the objects were randomly generated; and medical
variable “i” (but not the four occurrences of the subscript “i,” images (CT and MR images) of heads, where FVs were obtained by
which is an array index) in VORONOIEDT, lines 6, 8, 11, 20, and using various edge operators. The fastest execution times occurred
23, by “wd i,” where wd is the dth coordinate weight (see (1)). for the special cases of one FV in a corner or with a small number of
The squared EDT algorithm has a small time constant. All of the randomly generated FVs. This is probably due to the fact that for
arithmetic operations occur in VORONOIEDT, lines 8 and 20. In line images with sparse FVs, execution of line 8 in VORONOIEDT is
8, the procedure REMOVEEDT is essentially the evaluation of (2), frequently skipped. Except for these special cases, the execution
which requires 11 integer arithmetic operations. In line 20, the times were remarkably constant and independent of image content,
distance comparison requires seven arithmetic operations. As and there was little variation of execution time per voxel with the
explained earlier, both of these lines will execute a maximum of total number of image voxels N. The execution time of the squared
twice per voxel per dimension. Thus, the squared EDT algorithm EDT algorithm was approximately 0:23s/voxel (4.3 Mvoxel/s) for
requires a maximum of 36 integer arithmetic operations per voxel per 2D and 0:38s/voxel (2.6 Mvoxel/s) for 3D on a Sun Microsystems
dimension, not including index increment/decrement, indirection, SunBlade 2000 workstation with 1.05 GHz UltraSPARC III cpu, and
and assignment operations. It is easier to implement COMPUTEEDT approximately 0:21s/voxel (4.8 Mvoxel/s) for 2D and 0:36s/voxel
for a fixed number of dimensions (e.g., k ¼ 3) by computing D0 , D1 , (2.8 Mvoxel/s) for 3D on a PC with 2.2 GHz Pentium 4 cpu. The
. . . , Dkÿ1 , and Dk ¼ D in consecutive separately coded loops than by execution time of the FT algorithm was approximately four times
recursion. We note that the computation of D1 can be implemented longer in each case than that of the squared EDT algorithm. The
more efficiently as a simple forward-and-reverse distance propaga- memory requirements of the EDT algorithm are approximately half
270 IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. 25, NO. 2, FEBRUARY 2003
that of the FT algorithm because no intermediate FT is computed. We [18] C.T. Huang and O.R. Mitchell, “A Euclidean Distance Transform Using
also experimentally verified the correctness of the squared EDT Grayscale Morphology Decomposition,” IEEE Trans. Pattern Analysis and
Machine Intelligence, vol. 16, pp. 443-448, 1994.
algorithm by comparing the output with EDTs computed using two [19] H. Jiang, R.A. Robb, and K.S. Holton, “A New Approach to 3D Registration
other algorithms [18], [36] and an implementation based on of Multimodality Medical Images by Surface Matching,” Visualization in
k-D binary search trees. We observed no differences between the Biomedical Computing (VBC), vol. 1808, pp. 196-213, 1992.
outputs of the squared EDT algorithm and the outputs of the other [20] M.N. Kolountzakis and K.N. Kutulakos, “Fast Computation of the
algorithms for more than one million randomly generated tests. Euclidean Distance Maps for Binary Images,” Information Processing Letters,
vol. 43, pp. 181-184, 1992.
Because both the FT and squared EDT algorithms work one [21] F. Leymarie and M.D. Levine, “Fast Raster Scan Distance Propagation on
row at a time, they can be easily parallelized. Since the N=nd row the Discrete Rectangular Lattice,” CVGIP: Image Understanding, vol. 55,
computations at the dth dimension level are independent of each pp. 84-94, 1992.
other, all computations at the dth dimension level can be [22] J.A. Little, D.L.G. Hill, and D.J. Hawkes, “Deformations Incorporating Rigid
Structures,” Computer Vision Image Understanding, vol. 66, pp. 223-232, 1997.
performed in Oðnd N=nd 1=pÞ ¼ OðN=pÞ time with p proces- [23] J.C. Mullikin, “The Vector Distance Transform in Two and Three
sors, 1 p nd . Thus, parallel versions of these algorithms run in Dimensions,” CVGIP: Graphical Models and Image Processing, vol. 54,
OðN=pÞ time with p processors, 1 p minðn1 ; . . . ; nk Þ. This pp. 526-535, 1992.
approach is similar to the parallel method in [36]. It is [24] C.W. Niblack, P.B. Gibbons, and D.W. Capson, “Generating Skeletons and
Centerlines from the Distance Transform,” CVGIP: Graphical Models and
fundamentally different from the one in [11], which is a divide- Image Processing, vol. 54, pp. 420-437, 1992.
and-conquer algorithm that parallelizes a raster-scan propagation [25] D.W. Paglieroni, “Distance Transforms: Properties and Machine Vision
DT algorithm [21]. Applications,” CVGIP: Graphical Models and Image Processing, vol. 54, pp. 56-
74, 1992.
[26] D.W. Paglieroni, “A Unified Distance Transform Algorithm and Architec-
ture,” Machine Vision Applications, vol. 5, pp. 47-55, 1992.
ACKNOWLEDGMENTS [27] G.P. Penney, J.A. Little, J. Weese, D.L.G. Hill, and D.J. Hawkes, “Deforming
Calvin Maurer was supported in part by funds from the Ronald L. a Preoperative Volume to Represent the Intraoperative Scene,” Computer
Aided Surgery, vol. 7, pp. 63-73, 2002.
Bittner Endowed Fund in Biomedical Research and by CBYON, [28] J. Piper and E. Granum, “Computing Distance Transformations in Convex
Inc., Mountain View, CA. Rensheng Qi received partial support via and Non-Convex Domains,” Pattern Recognition, vol. 20, pp. 599-615, 1987.
a Special Opportunity Award from the Whitaker Foundation to the [29] F.P. Preparata and M.I. Shamos, Computational Geometry: An Introduction.
University of Rochester. Vijay Raghavan was supported in part by Springer Verlag, 1985.
the US National Science Foundation under Grant No. 9820840. The [30] I. Ragnemalm, “Neighborhoods for Distance Transformations Using Ordered
Propagation,” CVGIP: Image Understanding, vol. 56, pp. 399-409, 1992.
authors thank Philippe Batchelor and Kensaku Mori for their [31] I. Ragnemalm, “The Euclidean Distance Transform in Arbitrary Dimen-
helpful comments and suggestions. sions,” Pattern Recognition Letters, vol. 14, pp. 883-888, 1993.
[32] S.P. Raya and J.K. Udupa, “Shape-Based Interpolation of Multidimensional
Objects,” IEEE Trans. Medical Imaging, vol. 9, pp. 32-42, 1990.
REFERENCES [33] E. Remy and E. Thiel, “Optimizing 3D Chamfer Masks with Norm
Constraints,” Proc. Int’l Workshop Combinatorial Image Analysis, pp. 35-56, 2000.
[1] C. Arcelli and G. Sanniti di Baja, “Finding Local Maxima in a Pseudo- [34] A. Rosenfeld and J.L. Pfaltz, “Sequential Operations in Digital Picture
Euclidean Distance Transform,” Computer Vision, Graphics, and Image Processing,” J. ACM, vol. 13, pp. 471-494, 1966.
Processing, vol. 43, pp. 361-367, 1988. [35] A. Rosenfeld and J.L. Pfaltz, “Distance Functions on Digital Pictures,”
[2] F. Aurenhammer, “Voronoi Diagrams—A Survey of a Fundamental Pattern Recognition, vol. 1, pp. 33-61, 1968.
Geometric Data Structure,” ACM Computer Surveys, vol. 23, pp. 345-405, [36] T. Saito and J.-I. Toriwaki, “New Algorithms for Euclidean Distance
1991. Transformation of an n-dimensional Digitized Picture with Applications,”
[3] A.L.D. Beckers and A.W.M. Smeulders, “A Comment on ‘A Note on Pattern Recognition, vol. 27, pp. 1551-1565, 1994.
Distance Transformations in Digital Images,’” Computer Vision, Graphics, [37] M. Sramek and A. Kaufman, “Fast Ray-Tracing of Rectilinear Volume Data
and Image Processing, vol. 47, pp. 89-91, 1989. Using Distance Transforms,” IEEE Trans. Visualization Computer Graphics,
[4] G. Borgefors, “Distance Transformations in Arbitrary Dimensions,” vol. 6, pp. 236-252, 2000.
Computer Vision, Graphics, and Image Processing, vol. 27, pp. 321-345, 1984. [38] S. Svensson, “Representing and Analyzing 3D Digital Shape Using
[5] G. Borgefors, “Distance Transformations in Digital Images,” Computer Distance Information,” PhD thesis, Swedish Univ. of Agricultural Sciences,
Vision, Graphics, and Image Processing, vol. 34, pp. 344-371, 1986. Uppsala, 2001.
[6] H. Breu, J. Gil, D. Kirkpatrick, and M. Werman, “Linear time Euclidean [39] M. van Herk, “Image Registration Using Chamfer Matching,” Handbook of
Distance Transform Algorithms,” IEEE Trans. Pattern Analysis and Machine Medical Imaging Processing and Analysis, San Diego: Academic Press, I.N.
Intelligence, vol. 17, pp. 529-533, 1995. Bankman, ed., pp. 515-527, 2000.
[7] O. Cuisenaire and B. Macq, “Fast and Exact Signed Euclidean Distance [40] M. van Herk and H.M. Kooy, “Automated Three-Dimensional Correlation
Transformation with Linear Complexity,” Proc. IEEE Int’l Conf. Acoustics of CT-CT, CT-MRI, and CT-SPECT Using Chamfer Matching,” Medical
Speech Signal Processing, pp. 3293-3296, 1999. Physics, vol. 21, pp. 1163-1178, 1994.
[8] O. Cuisenaire and B. Macq, “Fast Euclidean Distance Transformation by [41] B.J.H. Verwer, “Local Distances for Distance Transformations in Two and
Propagation Using Multiple Neighborhoods,” Computer Vision and Image Three Dimensions,” Pattern Recognition Letters, vol. 12, pp. 671-682, 1991.
Understanding, vol. 76, pp. 163-172, 1999. [42] B.J.H. Verwer and P.W. Verbeek, S.T. Dekker, “An Efficient Uniform Cost
[9] P.-E. Danielsson, “Euclidean Distance Mapping,” Computer Vision, Graphics, Algorithm Applied to Distance Transforms,” IEEE Trans. Pattern Analysis
and Image Processing, vol. 14, pp. 227-248, 1980. and Machine Intelligence, vol. 11, pp. 425-429, 1989.
[10] H. Eggers, “Two Fast Euclidean Distance Transformations in Z 2 Based on [43] L. Vincent, “Exact Euclidean Distance Function by Chain Propagations,”
Sufficient Propagation,” Computer Vision and Image Understanding, vol. 69, Proc. IEEE Int’l Conf. Acoustics Speech Signal Processing, pp. 520-525, 1991.
pp. 106-116, 1998. [44] A.M. Vossepoel, “A Note on ‘Distance Transformations in Digital Images,’”
[11] H. Embrechts and D. Roose, “A Parallel Euclidean Distance Trasnformation Computer Vision and Graphics Image Processing, vol. 43, pp. 88-97, 1988.
Algorithm,” Computer Vision and Image Understanding, vol. 63, pp. 15-26, 1996. [45] Q.J. Wu and J.D. Bourland, “Morphology-Guided Radiosurgery Treatment
[12] J.M. Fitzpatrick, D.L.G. Hill, and C.R. Maurer, Jr., “Image Registration,” Planning and Optimization for Multiple Isocenters,” Medical Physics, vol. 26,
Handbook of Medical Imaging, Volume 2: Medical Image Processing and Analysis, pp. 2151-2160, 1999.
SPIE Press, M. Sonka and J.M. Fitzpatrick, eds., pp. 447-513, 2000. [46] Q.J. Wu and J.D. Bourland, “Three-Dimensional Skeletonization for
[13] Y. Ge and J.M. Fitzpatrick, “On the Generation of Skeletons from Discrete Computer-Assisted Treatment Planning in Radiosurgery,” Computer
Euclidean Distance Maps,” IEEE Trans. Pattern Analysis and Machine Medical Imaging Graphics, vol. 24, pp. 243-251, 2000.
Intelligence, vol. 18, pp. 1055-1066, 1996. [47] H. Yamada, “Complete Euclidean Distance Transformation by Parallel
[14] Y. Ge, C.R. Maurer, Jr., and J.M. Fitzpatrick, “Surface-Based 3-D Image Operation,” Proc. Seventh Int’l Conf. Pattern Recognition, pp. 69-71, 1984.
Registration Using the Iterative Closest Point Algorithm with a Closest [48] M. Yamashita and T. Ibaraki, “Distances Defined by Neighborhood
Point Transform,” Medical Imaging 1996: Image Processing, vol. 2710, pp. 358- Sequences,” Pattern Recognition, vol. 19, pp. 237-246, 1986.
367, 1996. [49] K.J. Zuiderveld, A.H.J. Koning, and M.A. Viergever, “Acceleration of Ray-
[15] J. Goutsias and S. Batman, “Morphological Methods for Biomedical Image Casting Using 3D Distance Transforms,” Visualization in Biomedical
Analysis,” Handbook of Medical Imaging, Vol. 2: Medical Image Processing and Computing (VBC), vol. 1808, pp. 324-335, 1992.
Analysis, M. Sonka and J.M. Fitzpatrick, eds., SPIE Press, pp. 175-272, 2000.
[16] G.J. Grevera and J.K. Udupa, “Shape-Based Interpolation of Multidimen-
sional Grey-Level Images,” IEEE Trans. Medical Imaging, vol. 15, pp. 881-
892, 1996.
[17] W. Guan and S. Ma, “A List-Processing Approach to Compute Voronoi
Diagrams and the Euclidean Distance Transform,” IEEE Trans. Pattern
Analysis and Machine Intelligence, vol. 20, pp. 757-761, 1998.