GPU-Based Parallel Euclidean Distance Transform Algorithm
Abstract
1. Introduction
2. Related Work
2.1. Serial Algorithms
2.2. Parallel Algorithms
3. Parallel Euclidean Distance Transform Algorithm
3.1. Overview
- Partitioning: The input image is horizontally divided into k sub-blocks, denoted as , , …, . The input image in Figure 2 uses 0 and 1 to represent foreground and background pixels, respectively. The example sub-block contains a contiguous set of rows, ranging from row i to row .
- Candidate Proximate-point Matrix Computation: An upper candidate proximate-point matrix and a lower candidate proximate-point matrix are constructed via row-wise forward propagation and row-wise backward propagation. Each row of these matrices stores the upper or lower candidate proximate-point set corresponding to that image row.
- Proximate-point Set Computation: The upper and lower proximate-point sets for all rows within each sub-block are generated using a row-wise recursive strategy. In illustrated in Figure 2, the upper proximate-point set of row i is obtained by eliminating dominated candidate proximate points through a dominance check on the upper candidate proximate-point set of that row. Subsequently, a row-wise recurrence is performed from row i to row to compute the upper proximate-point sets for rows i to . An analogous procedure is applied in the reverse direction, from row to row i, to compute the lower proximate-point set.
- Euclidean Distance Computation: Based on the upper and lower proximate-point set of all rows in the sub-block, the nearest background pixel for each foreground pixel is determined, and the corresponding Euclidean distance is calculated, thereby producing the Euclidean distance map of the sub-block.

3.2. Computation of the Upper and Lower Candidate Proximate-Point Matrices
3.3. Computation of the Upper and Lower Proximate-Point Sets
3.3.1. Computation of the Upper Proximate-Points Set for the First Row of Each Sub-Block
| Algorithm 1 Computation of Upper Proximate-Points Sets of the First Row of Each Sub-block |
| Input: Upper candidate proximate-point matrix M; Sub-blocks , , …, . Output: Upper proximate-point sets of the first row of all sub-blocks: , , …, . 1: for all to k in parallel do 2: Initialize an empty upper proximate-point set 3: Retrieve the upper candidate proximate-point list from M 4: for to do 5: Extract the j-th candidate proximate point from 6: Insert into 7: Check whether geometrically dominates one or more previously inserted proximate points 8: if dominated points exist then 9: Remove all dominated proximate points from 10: end if 11: end for 12: end for |
3.3.2. Recurrence of the Upper Proximate-Point Set for the Next Row
| Algorithm 2 Detection of Consecutively Dominated Proximate Points |
| Input: Two proximate points and ; a sequence of proximate points Output: A set of dominated proximate points 1: Begin 2: for to k do 3: 4: if then 5: Mark as dominated 6: 7: else 8: break 9: end if 10: end for |
| Algorithm 3 Computation of the Upper Proximate-Point Set for Row |
| Input: Upper proximate-point sets of row i for all sub-blocks: ; Background-pixel sets of row for all sub-blocks: . Output: Upper proximate-point sets of row for all sub-blocks: , …, . 1: Begin 2: for all in parallel do 3: Initialize 4: 5: for all do 6: Evaluate whether is dominated by and 7: if is dominated then 8: Mark as dominated 9: end if 10: Check for consecutively dominated proximate points on the left of 11: Check for consecutively dominated proximate points on the right of 12: end for 13: Compact by removing all points marked as dominated 14: Insert all background pixels in into (ordered by x-coordinate) 15: For each inserted background pixel, test and mark any proximate points it dominates (left/right) 16: Compact again to remove newly marked points 17: end for 18: End |
3.4. Euclidean Distance Computation
3.5. GPU Memory Organization and Thread Configuration
3.6. Time Complexity Analysis
4. Experiments and Results Analysis
4.1. Experimental Setup
- to evaluate the performance overhead and time distribution of each step in the PR-EDT algorithm;
- to examine the adaptability and efficiency of the algorithm when applied to images with varying levels of background-pixel sparsity; and
- to assess the impact of the sub-block size on the overall performance.
- to compare the memory usage of the PR-EDT algorithm with that of the optimized serial algorithm, the Man algorithm and the Black algorithm.
4.2. Performance Analysis of Each Step in the PR-EDT Algorithm
4.3. Performance Comparison with the Serial, Man, and Black Algorithms
4.4. Performance Comparison of the Algorithm on Images with Sparse and Dense Background Pixels
4.5. Performance Analysis Under Varying Sub-Block Sizes
4.6. Memory Usage Analysis
5. Limitations and Scalability Analysis
5.1. GPU Memory Constraints
5.2. Scalability with Image Resolution and Sub-Block Partitioning
6. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Fabbri, R.; Costa, L.d.F.; Torelli, J.C.; Bruno, O.M. 2D Euclidean distance transform algorithms: A comparative survey. ACM Comput. Surv. 2008, 40, 1–44. [Google Scholar] [CrossRef]
- Mussabayev, R. Optimizing Euclidean Distance Computation. Mathematics 2024, 12, 3787. [Google Scholar] [CrossRef]
- Cuisenaire, O.; Macq, B. Fast and exact signed Euclidean distance transformation with linear complexity. In Proceedings of the IEEE International Conference on Acoustics, Speech, and Signal Processing, Phoenix, AZ, USA, 15–19 March 1999; pp. 3293–3296. [Google Scholar] [CrossRef]
- Shih, F.Y.; Wu, Y.T. Fast Euclidean distance transformation in two scans using a 3 × 3 neighborhood. Comput. Vis. Image Underst. 2004, 93, 195–205. [Google Scholar] [CrossRef]
- Shih, F.Y.; Wu, Y.T. The efficient algorithms for achieving Euclidean distance transformation. IEEE Trans. Image Process. 2004, 13, 1078–1091. [Google Scholar] [CrossRef] [PubMed]
- Cuisenaire, O.; Macq, B. Fast Euclidean distance transformations by propagation using multiple neighborhoods. Comput. Vis. Image Underst. 1999, 76, 163–172. [Google Scholar] [CrossRef]
- Eggers, H. Two fast Euclidean distance transformations in Z2 based on sufficient propagation. Comput. Vis. Image Underst. 1998, 69, 106–116. [Google Scholar] [CrossRef]
- Paglieroni, D.W. Distance transforms: Properties and machine vision applications. CVGIP Graph. Model. Image Process. 1992, 54, 56–74. [Google Scholar] [CrossRef]
- Paglieroni, D.W. A unified distance transform algorithm and architecture. Mach. Vis. Appl. 1992, 5, 47–55. [Google Scholar] [CrossRef]
- Hirata, T. A unified linear-time algorithm for computing distance maps. Inf. Process. Lett. 1996, 58, 129–133. [Google Scholar] [CrossRef]
- Lotufo, R.A.; Zampirolli, F.A. Fast multidimensional parallel Euclidean distance transform based on mathematical morphology. In Proceedings of the Brazilian Symposium on Computer Graphics and Image Processing, Florianopolis, Brazil, 15–18 October 2001; pp. 100–105. [Google Scholar] [CrossRef]
- Maurer, C.R.; Raghavan, V.; Qi, R. A linear time algorithm for computing the Euclidean distance transform in arbitrary dimensions. In Proceedings of the Information Processing in Medical Imaging, Davis, CA, USA, 18–22 June 2001; pp. 358–364. [Google Scholar] [CrossRef]
- Silva, D.J.; Miranda, P.A.V.; Alves, W.A.L.; Hashimoto, R.F.; Kosinka, J.; Roerdink, J.B.T.M. Differential maximum Euclidean distance transform computation in component trees. In Proceedings of the International Conference on Discrete Geometry and Mathematical Morphology, Florence, Italy, 15–18 April 2024; pp. 67–79. [Google Scholar] [CrossRef]
- Ali, U.; Wu, L.; Müller, A.; Sukkar, F.; Kaupp, T.; Vidal-Calleja, T.A. Interactive Distance Field Mapping and Planning to Enable Human-Robot Collaboration. IEEE Robot. Autom. Lett. 2024, 9, 10850–10857. [Google Scholar] [CrossRef]
- Elizondo-Leal, J.C.; Ramirez-Torres, J.G.; Barrón-Zambrano, J.H.; Diaz-Manríquez, A.; Nuño-Maganda, M.A.; Saldivar-Alonso, V.P. Parallel raster scan for Euclidean distance transform. Symmetry 2020, 12, 1808. [Google Scholar] [CrossRef]
- Aaa, M.; Dorent, R.; Vercauteren, T. FastGeodis: Fast generalised geodesic distance transform. J. Open Source Softw. 2022, 7, 4532. [Google Scholar] [CrossRef]
- Criminisi, A.; Sharp, T.; Siddiqui, K. Interactive geodesic segmentation of n-dimensional medical images on the graphics processor. In Proceedings of the Radiological Society of North America, Chicago, IL, USA, 29 November–4 December 2009. [Google Scholar]
- He, X.; Agarwal, D.; Prasad, S.K. Design and implementation of a parallel priority queue on many-core architectures. In Proceedings of the International Conference on High Performance Computing, Pune, India, 18–22 December 2012; pp. 1–10. [Google Scholar] [CrossRef]
- He, X.; Wu, Y.; Di, Z.; Chen, J. GPU-based morphological reconstruction system. J. Comput. Appl. 2019, 39, 2008–2013. [Google Scholar] [CrossRef]
- Rong, G.; Tan, T.S. Variants of jump flooding algorithm for computing discrete Voronoi diagrams. In Proceedings of the International Symposium on Voronoi Diagrams in Science and Engineering, Glamorgan, UK, 9–11 July 2007; pp. 176–181. [Google Scholar] [CrossRef]
- Cuntz, N.; Kolb, A. Fast Hierarchical 3D Distance Transforms on the GPU; The Eurographics Association: Eindhoven, The Netherlands, 2007; pp. 93–96. [Google Scholar] [CrossRef]
- Zampirolli, F.D.A.; Filipe, L. Distance transform separable by mathematical morphology in GPU. In Proceedings of the Progress in Pattern Recognition, Image Analysis, Computer Vision, and Applications, Havana, Cuba, 20–23 November 2013; pp. 41–48. [Google Scholar] [CrossRef]
- Cao, T.T.; Tang, K.; Mohamed, A.A.; Tan, T.S. Parallel banding algorithm to compute exact distance transform with the GPU. In Proceedings of the ACM on Computer Graphics and Interactive Techniques, Los Angeles, CA, USA, 26–30 July 2010; pp. 83–90. [Google Scholar] [CrossRef]
- Man, D.; Uda, K.; Ueyama, H.; Ito, Y.; Nakano, K. Implementations of parallel computation of Euclidean distance map in multicore processors and GPUs. In Proceedings of the International Conference on Networking & Computing, Washington, DC, USA, 30 November–2 December 2011; pp. 120–127. [Google Scholar] [CrossRef]
- Man, D.; Uda, K.; Ito, Y.; Nakano, K. Accelerating computation of Euclidean distance map using the GPU with efficient memory access. Int. J. Parallel Emergent Distrib. Syst. 2013, 28, 383–406. [Google Scholar] [CrossRef]
- Mandudu, M.; Jones, M.W. A work efficient parallel algorithm for exact Euclidean Distance Transform. IEEE Trans. Image Process. 2019, 28, 5322–5335. [Google Scholar] [CrossRef] [PubMed]
- Breu, H.; Gil, J.; Kirkpatrick, D.; Werman, M. Linear time Euclidean distance transform algorithms. IEEE Trans. Pattern Anal. Mach. Intell. 2002, 17, 529–533. [Google Scholar] [CrossRef]
- Chen, Y.; Lai, S.; Cui, J.; Wang, B.; Chen, B.M. GPU-accelerated incremental Euclidean distance transform for online motion planning of mobile robots. IEEE Robot. Autom. Lett. 2022, 7, 6894–6901. [Google Scholar] [CrossRef]
- Black, D.; Li, W.; Zhang, Q.; Molloi, S. Accelerating Euclidean distance transforms: A fast and flexible approach with multi-vendor GPU, multi-threading, and multi-language support. IEEE Access 2025, 13, 44636–44649. [Google Scholar] [CrossRef]
- Gallet, B.; Michael, G. Leveraging GPU tensor cores for double precision Euclidean distance calculations. In Proceedings of the International Conference on High Performance Computing, Data, and Analytics (HiPC), Bengaluru, India, 18–21 December 2022; pp. 135–144. [Google Scholar] [CrossRef]
- Zhu, D.; Wang, C.; Wang, W.; Garg, R.; Scherer, S.; Meng, M.Q.H. VDB-EDT: An Efficient Euclidean Distance Transform Algorithm Based on VDB Data Structure. arXiv 2021, arXiv:2105.04419. [Google Scholar] [CrossRef]
- Han, X.; Zeng, P. A Hardware Design of EDT Algorithm Applied to Binary Images. In Proceedings of the International Conference on Computer Science and Electronics Engineering; IEEE: Piscataway, NJ, USA, 2013. [Google Scholar] [CrossRef][Green Version]
- Sengupta, S.; Harris, M.; Zhang, Y.; Owens, J.D. Scan primitives for GPU computing. In Proceedings of the ACM Eurographics Workshop on Graphics Hardware, San Diego, CA, USA, 4–5 August 2007; pp. 97–106. [Google Scholar] [CrossRef]








| Image Resolution/Background Ratio | Serial (ms) | Man (ms) | Black (ms) | PR-EDT (ms) | |||
|---|---|---|---|---|---|---|---|
| 1024 × 1024 (1%) | 59.77 | 40.58 | 12.40 | 7.68 | 1.47 | 4.82 | 7.78 |
| 2048 × 2048 (1%) | 278.37 | 82.88 | 62.52 | 13.3 | 3.35 | 4.45 | 20.93 |
| 4096 × 4096 (1%) | 1094.07 | 169.22 | 333.11 | 28.08 | 6.46 | 3.28 | 38.96 |
| 8192 × 8192 (1%) | 4380.63 | 344.24 | 1688.41 | 84.19 | 12.72 | 2.59 | 52.03 |
| 1024 × 1024 (99%) | 205.39 | 82.05 | 13.45 | 14.15 | 2.50 | 15.27 | 14.51 |
| 2048 × 2048 (99%) | 864.44 | 168.04 | 58.09 | 39.24 | 5.14 | 14.88 | 22.02 |
| 4096 × 4096 (99%) | 3484.25 | 343.88 | 385.77 | 116.77 | 10.13 | 9.03 | 29.83 |
| 8192 × 8192 (99%) | 13,862.27 | 713.49 | 2256.60 | 341.91 | 19.42 | 6.14 | 40.54 |
| Image Resolution | Serial (MiB) | Man (MiB) | Black (MiB) | PR-EDT (MiB) |
|---|---|---|---|---|
| 1024 × 1024 | 17 | 624 | 34 | 258 |
| 2048 × 2048 | 68 | 748 | 84 | 324 |
| 4096 × 4096 | 272 | 1240 | 275 | 588 |
| 8192 × 8192 | 1088 | 3210 | 1090 | 1644 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.
Share and Cite
Lu, Y.; Zhu, X.; Pang, A.; He, X. GPU-Based Parallel Euclidean Distance Transform Algorithm. Mathematics 2026, 14, 597. https://doi.org/10.3390/math14040597
Lu Y, Zhu X, Pang A, He X. GPU-Based Parallel Euclidean Distance Transform Algorithm. Mathematics. 2026; 14(4):597. https://doi.org/10.3390/math14040597
Chicago/Turabian StyleLu, Yucheng, Xiaoying Zhu, Anlong Pang, and Xi He. 2026. "GPU-Based Parallel Euclidean Distance Transform Algorithm" Mathematics 14, no. 4: 597. https://doi.org/10.3390/math14040597
APA StyleLu, Y., Zhu, X., Pang, A., & He, X. (2026). GPU-Based Parallel Euclidean Distance Transform Algorithm. Mathematics, 14(4), 597. https://doi.org/10.3390/math14040597

