Blender
V4.3
source
blender
compositor
realtime_compositor
algorithms
COM_algorithm_jump_flooding.hh
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2023 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
5
#pragma once
6
7
#include "
COM_context.hh
"
8
#include "
COM_result.hh
"
9
10
namespace
blender::realtime_compositor
{
11
12
/* Computes a jump flooding table from the given input and writes the result to the output. A jump
13
* flooding table computes for each pixel the texel location of the closest "seed pixel". A seed
14
* pixel is a pixel that is marked as such in the input, more on this later. This table is useful
15
* to compute a Voronoi diagram where the centroids are the seed pixels, it can be used to
16
* accurately approximate an euclidean distance transform, finally, it can be used to flood fill
17
* regions of an image.
18
*
19
* The input is expected to be initialized by the initialize_jump_flooding_value function from the
20
* gpu_shader_compositor_jump_flooding_lib.glsl library. Seed pixels should specify true for the
21
* is_seed argument, and false otherwise. The texel input should be the texel location of the
22
* pixel. Both the input and output results should be of type ResultType::Int2.
23
*
24
* To compute a Voronoi diagram, the pixels lying at the centroid of the Voronoi cell should be
25
* marked as seed pixels. To compute an euclidean distance transform of a region or flood fill a
26
* region, the boundary pixels of the region should be marked as seed.
27
*
28
* The algorithm is based on the paper:
29
*
30
* Rong, Guodong, and Tiow-Seng Tan. "Jump flooding in GPU with applications to Voronoi diagram
31
* and distance transform." Proceedings of the 2006 symposium on Interactive 3D graphics and
32
* games. 2006.
33
*
34
* But uses the more accurate 1+JFA variant from the paper:
35
*
36
* Rong, Guodong, and Tiow-Seng Tan. "Variants of jump flooding algorithm for computing discrete
37
* Voronoi diagrams." 4th international symposium on voronoi diagrams in science and engineering
38
* (ISVD 2007). IEEE, 2007.*
39
*
40
* The algorithm is O(log2(n)) per pixel where n is the maximum dimension of the input, it follows
41
* that the execution time is independent of the number of the seed pixels. However, the developer
42
* should try to minimize the number of seed pixels because their number is proportional to the
43
* error of the algorithm as can be seen in "Figure 3: Errors of variants of JFA" in the variants
44
* paper. */
45
void
jump_flooding
(Context &context, Result &input, Result &output);
46
47
}
// namespace blender::realtime_compositor
COM_context.hh
COM_result.hh
blender::realtime_compositor
Definition
BKE_node.hh:80
blender::realtime_compositor::jump_flooding
void jump_flooding(Context &context, Result &input, Result &output)
Definition
jump_flooding.cc:38
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0