This document gives some additional details on the implementation
of the Poisson solver used in the paper
"Diffusion Curves: A Vector Representation for Smooth-Shaded Images"
by Alexandrina Orzan, Adrien Bousseau, Holger Winnemoller,
Pascal Barla, JoĆ«lle Thollot, David Salesin.
To perform a fast color diffusion, we use a simplified multigrid
approach very similar to the one used in the paper
"Real time gradient domain painting"
http://graphics.cs.cmu.edu/projects/gradient-paint/.
A good starting point when implementing multigrid is the first
chapters of the book "A multigrid tutorial"
https://computation.llnl.gov/casc/people/henson/mgtut/welcome.html.
In practice, we solve the poisson equation (Lapl(I) = div(G))
using Jacobi iterations. Lapl(I) is expressed as
4I(x,y) - I(x-1,y) - I(x+1,y) - I(x,y-1) - I(x,y+1), which gives:
4I(x,y) - I(x-1,y) - I(x+1,y) - I(x,y-1) - I(x,y+1) = div(G) which leads to:
I(x,y) = [div(G) + I(x-1,y) + I(x+1,y) + I(x,y-1) + I(x,y+1)]/4
div(G) is computed in a preprocess as:
div(G)(x,y) = 0.5*(Gx(x-1,y) - Gx(x+1,y)) + 0.5*(Gy(x,y-1) - Gy(x,y+1)),
with Gx and Gy the x and y derivatives of the image.
The Jacobi iteration consists in computing I(x,y) with the values
of I from the previous iteration using this equation.
I is initialized with a gray value (0.5,0.5,0.5).
A local constraint (the "color sources") of value vi and position (xi,yi)
is imposed after each iteration by setting I(xi,yi) = vi.
The Jacobi iterations are usually very slow to converge,
which is why we use a multi-scale approach: the multigrid.
The idea is to downsample the gradient field G several time
until we reach a very coarse solution.
We then compute I at this coarse solution by applying a fixed
number of Jacobi iterations. The coarse solution is then upsampled,
and a few more iterations are performed.
This is repeated until we reach the original resolution.
The main simplification in comparison with the traditional multigrid
is that we apply a fixed number of iterations on the solution at each scale,
without taking into account the residual to check for convergence.
The gradient field is downsampled (or "restricted") with the same kernel
as in "Real time gradient domain painting".
The local constraints are downsampled with an average filter:
a pixel at coarse scale receives the average of the constraints of
the 4 corresponding pixels in the finner scale.
If you download our prototype from our webpage you will be able
to see our shaders. It can give you a better idea of our implementation.