ArticleslgStudy

computer science

Jump flooding algorithm

Jump flooding algorithm is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Jump flooding algorithm rather than just read about it. In short: 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.

Jump flooding algorithm — main illustration
Jump flooding algorithm — illustration

Key takeaways

  • Jump flooding algorithm belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Jump flooding algorithm to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Jump flooding algorithm from memory before moving on to harder problems.

Reference excerpt

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. The JFA has desirable attributes in GPU computation, notably for its efficient 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.

Implementation The JFA original formulation is simple to implement. Take an N × N {\displaystyle N\times N} grid of pixels (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 k ∈ { N 2 , N 4 , … , 1 } {\displaystyle k\in \{{\tfrac {N}{2}},{\tfrac {N}{4}},\dots ,1\}} , run one iteration of the JFA:

Iterate over every pixel p {\displaystyle p} at ( x , y ) {\displaystyle (x,y)} . For each neighbor q {\displaystyle q} at ( x + i , y + j ) {\displaystyle (x+i,y+j)} where i , j ∈ { − k , 0 , k } {\displaystyle i,j\in \{-k,0,k\}} : if p {\displaystyle p} is undefined and q {\displaystyle q} is colored, change p {\displaystyle p} 's color to q {\displaystyle q} 's if p {\displaystyle p} is colored and q {\displaystyle q} is colored, if d i s t ( p , s ) > d i s t ( p , s ′ ) {\displaystyle \mathrm {dist} (p,s)>\mathrm {dist} (p,s')} where s {\displaystyle s} and s ′ {\displaystyle s'} are the seed pixels for p {\displaystyle p} and q {\displaystyle q} , respectively, then change p {\displaystyle p} 's color to q {\displaystyle q} '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 9 log 2 ⁡ ( N ) {\displaystyle 9\log _{2}(N)} times over each pixel, for an overall computational complexity of O ( N 2 log 2 ⁡ ( N ) ) {\displaystyle O(N^{2}\log _{2}(N))} .

Variants 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 2 {\displaystyle ^{2}} has log 2 ⁡ ( N ) {\displaystyle \log _{2}(N)} 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. 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. 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.

Uses

The jump flooding algorithm and its variants may be used for calculating Voronoi maps and centroidal Voronoi tessellations (CVT), generating distance fields, point-cloud rendering, feature matching, the computation of power diagrams, and soft shadow rendering. The grand strategy game developer Paradox Interactive uses the JFA to render borders between countries and provinces.

Further developments The JFA has inspired the development of numerous similar algorithms. Some have well-defined error properties which make them useful for scientific computing. In the computer vision domain, the JFA has inspired new belief propagation algorithms to accelerate the solution of a variety of problems.

References

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.

Worked examples

Example 1 — a first encounter with Jump flooding algorithm

Start with the simplest possible case. Write down what Jump flooding algorithm claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Jump flooding algorithm before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Jump flooding algorithm ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Jump flooding algorithm

In research
Jump flooding algorithm appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Jump flooding algorithm in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Jump flooding algorithm is common in secondary-school and first-year university syllabi. It links to neighbouring topics Flooding algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Jump flooding algorithm outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Jump flooding algorithm in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Jump flooding algorithm means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Jump flooding algorithm out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Jump flooding algorithm in simple terms?

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.

Why does Jump flooding algorithm matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Jump flooding algorithm?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Jump flooding algorithm.

Tags

  • Flooding algorithms

Keep exploring