Jump flooding algorithm

From Wikipedia, the free encyclopedia

The jump flooding algorithm (JFA) is a flooding algorithm used in the construction of Voronoi diagrams and distance transforms. The JFA was introduced by Rong Guodong at an ACM symposium in 2006.[1]

The JFA has desirable attributes in GPU computation, notably constant-time performance. However, it is only an approximate algorithm and does not always compute the correct result for every pixel, although in practice errors are few and the magnitude of errors is generally small.[1]


The JFA original formulation is simple to implement.

Take an grid of pixels[2] (like an image or texture). All pixels will start with an "undefined" color unless it is a uniquely-colored "seed" pixel. As the JFA progresses, each undefined pixel will be filled with a color corresponding to that of a seed pixel.

For each step size , run one iteration of the JFA:

Iterate over every pixel at .
For each neighbor at where :
if is undefined and is colored, change 's color to 's
if is colored and is colored, if where and are the seed pixels for and , respectively, then change 's color to 's.

Note that pixels may change color more than once in each step, and that the JFA does not specify a method for resolving cases where distances are equal, therefore the last-checked pixel's color is used above.

The JFA finishes after evaluating the last pixel in the last step size. Regardless of the content of the initial data, the innermost loop runs a total of times over each pixel, for an overall computational complexity of .


Some variants of JFA are:

  • Additional pass at the end: JFA+1 has one additional pass with step size of 1, i.e. the step sizes are N/2, N/4, ..., 1, 1; JFA+2 has two additional passes with step sizes of 2 and 1, i.e. the step sizes are N/2, N/4, ..., 1, 2, 1; JFA has additional passes, i.e. the step sizes are N/2, N/4, ..., 1, N/2, N/4, ..., 1. JFA+1 has much fewer errors than JFA, and JFA+2 has even fewer errors.[1]
  • Additional pass at the beginning: 1+JFA has one additional pass with step size of 1, i.e. the step sizes are 1, N/2, N/4, ..., 1. 1+JFA has very low error rate (similar to JFA+2) and the same performance as JFA+1.[3]
  • Half resolution: This variant runs normal JFA at a half resolution, and enlarge the result into the original resolution and run one additional pass with step size of 1. Because most of the passes has only half resolution, the speed of this variant is much faster than the full resolution JFA.[3]


The jump flooding algorithm and its variants may be used for calculating Voronoi maps[1][3] and centroidal Voronoi tessellations (CVT),[4] generating distance fields,[5][how?] point-cloud rendering,[6] feature matching,[7] the computation of power diagrams,[8] and soft shadow rendering.[9] The grand strategy game developer Paradox Interactive uses the JFA to render borders between countries and provinces.[10]

Further developments[edit]

The JFA has inspired the development of numerous similar algorithms. Some have well-defined error properties which make them useful for scientific computing.[11]

In the computer vision domain, the JFA has inspired new belief propagation algorithms to accelerate the solution of a variety of problems.[12][13]


  1. ^ a b c d Rong, Guodong; Tan, Tiow-Seng (2006-03-14). "Jump flooding in GPU with applications to Voronoi diagram and distance transform" (PDF). Proceedings of the 2006 symposium on Interactive 3D graphics and games - SI3D '06. Redwood City, California: Association for Computing Machinery. pp. 109–116. doi:10.1145/1111411.1111431. ISBN 978-1-59593-295-2. S2CID 7282879.
  2. ^ The original paper uses the optimal case, a square grid, as an example, but a grid of any size works. Albeit with reduced efficiency. See this StackOverflow question for more.
  3. ^ a b c Rong, Guodong; Tan, Tiow-Seng (July 2007). "Variants of Jump Flooding Algorithm for Computing Discrete Voronoi Diagrams". 4th International Symposium on Voronoi Diagrams in Science and Engineering (ISVD 2007). pp. 176–181. doi:10.1109/ISVD.2007.41. ISBN 978-0-7695-2869-4. S2CID 386735.
  4. ^ Guodong Rong; Yang Liu; Wenping Wang; Xiaotian Yin; Gu, X D; Xiaohu Guo (2011-03-25). "GPU-Assisted Computation of Centroidal Voronoi Tessellation". IEEE Transactions on Visualization and Computer Graphics. 17 (3): 345–356. doi:10.1109/TVCG.2010.53. hdl:10722/132211. ISSN 1077-2626. PMID 21233516. S2CID 11970070.
  5. ^ Golus, Ben (2021-04-01). "The Quest for Very Wide Outlines". Medium. Retrieved 2021-08-19.
  7. ^ Yu, Pei; Yang, Xiaokang; Chen, Li (2012). "Parallel-Friendly Patch Match Based on Jump Flooding". In Zhang, Wenjun; Yang, Xiaokang; Xu, Zhixiang; An, Ping; Liu, Qizhen; Lu, Yue (eds.). Advances on Digital Television and Wireless Multimedia Communications. Communications in Computer and Information Science. Vol. 331. Berlin, Heidelberg: Springer. pp. 15–21. doi:10.1007/978-3-642-34595-1_3. ISBN 978-3-642-34595-1.
  8. ^ Zheng, Liping (2019-05-01). "GPU-based efficient computation of power diagram". Computers & Graphics. 80: 29–36. doi:10.1016/j.cag.2019.03.011. ISSN 0097-8493. S2CID 131923624.
  9. ^ Rong, Guodong; Tan, Tiow-Seng (2006-11-01). "Utilizing jump flooding in image-based soft shadows". Proceedings of the ACM symposium on Virtual reality software and technology. VRST '06. Limassol, Cyprus: Association for Computing Machinery. pp. 173–180. doi:10.1145/1180495.1180531. ISBN 978-1-59593-321-8. S2CID 15339123.
  10. ^ Boczula, Bartosz; Eriksson, Daniel (2020). "Optimized Gradient Border Rendering in Imperator: Rome". Intel. Retrieved 2021-03-28.
  11. ^ Schneider, Jens; Kraus, Martin; Westermann, Rüdiger (2010). "GPU-Based Euclidean Distance Transforms and Their Application to Volume Rendering". In Ranchordas, AlpeshKumar; Pereira, João Madeiras; Araújo, Hélder J.; Tavares, João Manuel R. S. (eds.). Computer Vision, Imaging and Computer Graphics. Theory and Applications. Communications in Computer and Information Science. Vol. 68. Berlin, Heidelberg: Springer. pp. 215–228. doi:10.1007/978-3-642-11840-1_16. ISBN 978-3-642-11840-1.
  12. ^ Alchatzidis, Stavros; Sotiras, Aristeidis; Paragios, Nikos (2011-11-06). "Efficient parallel message computation for MAP inference". 2011 International Conference on Computer Vision (PDF). pp. 1379–1386. doi:10.1109/ICCV.2011.6126392. ISBN 978-1-4577-1102-2. S2CID 17554205.
  13. ^ Choi, Jungwook; Rutenbar, Rob A. (2016-08-29). "Configurable and scalable belief propagation accelerator for computer vision". 2016 26th International Conference on Field Programmable Logic and Applications (FPL). pp. 1–4. doi:10.1109/FPL.2016.7577316. ISBN 978-2-8399-1844-2. S2CID 10923625.

As of this edit, this article uses content from "Is Jump Flood Algorithm Separable?", authored by alan-wolfe, trichoplax at Stack Exchange, which is licensed in a way that permits reuse under the Creative Commons Attribution-ShareAlike 3.0 Unported License, but not under the GFDL. All relevant terms must be followed.