Graphics Reference
In-Depth Information
Each pixel
p
=
(
x
,
y
)
∈
generates a linear equation in the unknown values of
I
(
x
,
y
)
. There are two cases, depending on the 4-neighborhood of
p
(denoted
N(
p
)
):
1.
N(
. In this case — such as pixel
A
in Figure
3.8
— the neighborhood of
the pixel is fully contained in
p
)
⊂
. There are no boundary conditions and we use
the usual approximations of the Laplacian:
I
(
x
+
1,
y
)
+
I
(
x
−
1,
y
)
+
I
(
x
,
y
+
1
)
+
I
(
x
,
y
−
1
)
−
4
I
(
x
,
y
)
=
S
(
x
+
1,
y
)
+
S
(
x
−
1,
y
)
+
S
(
x
,
y
+
1
)
+
S
(
x
,
y
−
1
)
−
4
S
(
x
,
y
)
(3.14)
2.
N(
. In this case—such as pixel
B
in Figure
3.8
— the pixel is on the edge
of the source region, and the estimate of the Laplacian includes pixels from
the target that are specified by the boundary condition:
p
)
⊂
+
−
I
(
q
)
T
(
q
)
4
I
(
x
,
y
)
q
∈
N
(
p
)
∩
q
∈
N
(
p
)
∩
∂
=
S
(
x
+
1,
y
)
+
S
(
x
−
1,
y
)
+
S
(
x
,
y
+
1
)
+
S
(
x
,
y
−
1
)
−
4
S
(
x
,
y
)
(3.15)
is well inside the target image (i.e., surrounded by a
healthy border of target pixels). However, if
Typically, the region
runs all the way to the image bor-
der, Equation (
3.14
) and Equation (
3.15
) need to be modified to avoid querying pixel
values outside the image. For example, if the upper left-hand corner
(
1, 1
)
∈
,we
would modify Equation (
3.14
)to
I
(
2, 1
)
+
I
(
1, 2
)
−
2
I
(
1, 1
)
=
S
(
2, 1
)
+
S
(
1, 2
)
−
2
S
(
1, 1
)
(3.16)
Collecting together all the equations for each
p
∈
results in a large, sparse linear
system. There are asmany unknowns as pixels in
, but atmost five nonzero elements
per row, with a regular structure on where these elements occur.
4
Solving the Poisson equation for the example images in Figure
3.7
results in
the improved composite in Figure
3.9
. As with the Laplacian pyramid, the Poisson
equation was applied to each color channel independently. We can see that the over-
all colors of the target image merge naturally into the source region, while keeping
the sharp detail of the source region intact.
We can obtain a slightly different interpretation of Equations (
3.11
)-(
3.12
)by
defining
E
(
x
,
y
)
=
I
(
x
,
y
)
−
S
(
x
,
y
)
and rearranging:
2
E
∇
(
x
,
y
)
=
0in
(3.17)
s
.
t
.
E
(
x
,
y
)
=
T
(
x
,
y
)
−
S
(
x
,
y
)
on
∂
(3.18)
That is,
E
is a “correction” that we add to the source pixels to get the final image
pixels. We can think of
E
(
x
,
y
)
as a smooth membrane that interpolates the samples
of the difference between the target and source pixels around the boundary of
(
x
,
y
)
.
Now Equation (
3.17
) is a Laplace equation, which implies that the solution
E
(
x
,
y
)
is
a
harmonic function
. Once we compute
E
(
x
,
y
)
, we recover
I
(
x
,
y
)
=
S
(
x
,
y
)
+
E
(
x
,
y
)
.
4
In fact, the same kinds of systems occurred when we considered the matting problem in Sections
2.4
and
2.6
.