G1
G2
, (5)
with N N sparse matrix components G1 and G2 that
76 D. Hale
approximate partial derivatives along the rst and sec
ond image dimensions, respectively.
In the nitedierence approximation of equation 4,
the tensor eld D is represented by a blockdiagonal
matrix
D =
D11 D12
D12 D22
, (6)
composed of N N diagonal matrices D11, D12 and
D22. The 3N possibly nonzero elements of those matri
ces determine the directions and extents of roughening,
which may vary from sample to sample.
1.1 Image smoothing
If an anisotropic Laplacian roughens in certain di
rections, then the inverse of an anisotropic Laplacian
smooths in those same directions, and one application
of such an inverse operator is structureoriented image
smoothing (e.g., Fehmers and Hocker, 2003). Given an
input image f , an anisotropically smoothed output im
age g may be obtained as the solution to:
(I +G
T
DG)g = f . (7)
The addition of the identity matrix I to the anisotropic
Laplacian G
T
DG has two consequences. First, it makes
the symmetric matrix I + G
T
DG positivedenite
(SPD) so that a solution g can be found eciently us
ing conjugategradient iterations. Second, it implies that
no smoothing occurs in eigenvector directions for which
corresponding eigenvalues of the tensors in D are zero.
The directions and extents of smoothing via equa
tion 7 are determined entirely by the elements of the
blockdiagonal matrix D. Those 3N values may be com
puted from the structure of the input image f (van Vliet
et al., 1995), which may vary from sample to sample. In
deed, our desire to perform spatiallyvarying smoothing
is the primary reason that we cannot simply use fast
Fourier transforms to solve equation 7.
1.2 Image painting
Another application of anisotropic Laplacians is image
painting, in which missing samples of a painting p are
computed to be consistent with the tensors in D and
known samples of p. Following Claerbout (1992), let M
denote a diagonal masking matrix that describes the
locations of the missing samples:
M[i, i] =
(
1 ; p[i] missing
0 ; p[i] known,
(8)
and let K be the diagonal complement of M such that
K+M = I. Then to compute the missing parts Mp of
p we may solve
(K+MG
T
DGM)p = (KMG
T
DGK)p. (9)
Figure 1. A seismic image of channels (provided by Joe
Stefani of Chevron).
To facilitate the solution of equation 9, I constructed
the matrix on the lefthandside to be symmetric and
positivedenite (SPD). Any solution p to equation 9
is also a solution to an alternative symmetric positive
semidenite (SPS) system analogous to that proposed
by Claerbout (1992, p. 178):
MG
T
DGMp = MG
T
DGKp. (10)
Using K+M = I, this system is equivalent to
MG
T
DGp = 0. (11)
which simply states that the missing parts of p should
vary linearly in spatiallyvarying directions determined
by eigendecomposition of the tensors in D.
In other words, solution of equation 9 yields a
structureoriented multidimensional linear interpola
tion of the known samples Kp of the painting p. In
practice, those known samples could be specied inter
actively or determined from other information. For seis
mic images of the earths subsurface, the known samples
could correspond to locations where well logs are avail
able.
Figures 1 and 2 show an example of image painting
via equation 9. In this example, I painted one pixel red
near the center of the image p shown in Figure 1. The
solution to equation 9 is shown in Figure 2. Although
this painting is an extreme example in which only a sin
gle pixel is known, it demonstrates that paint ows to
other samples according to the image structure repre
sented by the tensors in D.
The painted image in Figure 2 may vary depending
on the nitedierence approximations G1 and G2 in
equation 9. In fact, my rst attempts at image painting
yielded results more like the one shown in Figure 3, in
which artifacts roughly orthogonal to image features are
Finitedierence approximations 77
Figure 2. The image of Figure 1 painted with a nite
dierence approximation to an anisotropic Laplacian. A sin
gle pixel inside the white circle was constrained to be red.
All other pixels were painted using structure estimated from
the image.
Figure 3. The image of Figure 1 painted with a poor nite
dierence approximation to an anisotropic Laplacian. A sin
gle pixel inside the white circle was constrained to be red.
All other pixels were painted using structure estimated from
the image.
apparent. A closeup view in Figure 4 shows that these
artifacts have a checkerboard pattern corresponding to
high wavenumbers near the spatial Nyquist frequencies.
Artifacts such as those highlighted in Figure 4
are caused by poor nitedierence approximations to
Figure 4. The central portion of the image of Figure 3.
Painting artifacts have a checkerboard pattern corresponding
to high wavenumbers near the spatial Nyquist frequencies.
anisotropic Laplacians. The purpose of this paper is to
explain these artifacts and to derive the improved ap
proximations that were used to obtain the painting in
Figure 2.
I begin by designing a family of 2D nitedierence
approximations to isotropic Laplacians. The design
method used facilitates the derivation of approximations
to anisotropic Laplacians. I then use this same method
to obtain new 3D nitedierence approximations for
both isotropic and anisotropic Laplacians.
Both 2D and 3D approximations are compact in
that they approximate derivatives for any image sample
using only nearest neighbor samples: 9 samples for 2D
and 27 samples for 3D Laplacians. Both 2D and 3D
approximations maintain the SPS property of G
T
DG,
which ensures SPD systems of equations 7 and 9. Com
pact SPD nitedierence approximations lead to the
most ecient methods for solving such equations.
2 ISOTROPIC LAPLACIANS
Let us rst consider approximations to isotropic Lapla
cians in two dimensions:
G
T
G = G
T
1
G1 +G
T
2
G2. (12)
Finitedierence approximations G1 and G2 to par
tial derivatives are most succinctly described by stencils
that specify the weights applied to adjacent image sam
ples. To obtain compact stencils for G
T
G, I consider
78 D. Hale
approximations G1 and G2 with the following stencils:
G1 =
s r
s r
, G2 =
s s
r r
,
r s 0, r + s = 1. (13)
The condition r + s = 1 ensures that G
T
1
G1 and
G
T
2
G2 are 2ndorder approximations, assuming unit im
age sampling intervals.
Gathering image samples with weights provided by
the stencils in equations 13 is equivalent to multiplica
tion by the matrices G1 and G2. Scattering with the
same weights is equivalent to multiplication by their
transposes G
T
1
and G
T
2
. Here is a small fragment of
a computer program that both gathers and scatters in
this way to compute g = G
T
Gf :
for (int i2=1; i2<n2; ++i2) {
for (int i1=1; i1<n1; ++i1) {
float f1r = f[i2 ][i1 ]f[i2 ][i11];
float f1s = f[i21][i1 ]f[i21][i11];
float f2r = f[i2 ][i1 ]f[i21][i1 ];
float f2s = f[i2 ][i11]f[i21][i11];
float g1 = r*f1r+s*f1s;
float g2 = r*f2r+s*f2s; // gather ends
float g1r = g1*r; // scatter begins
float g1s = g1*s;
float g2r = g2*r;
float g2s = g2*s;
g[i2 ][i1 ] = g1r+g2r;
g[i2 ][i11] = g1rg2s;
g[i21][i1 ] += g1sg2r;
g[i21][i11] = g1s+g2s;
}
}
Although this program fragment ignores boundaries, it
can be easily modied to implement zerovalue or zero
slope boundary conditions.
Gathering and scattering in this way using the 22
stencils of equations 13 is equivalent to simply gathering
with the following 3 3 stencil:
G
T
G =
0 1 0
1 4 1
0 1 0
+ 2rs
1 2 1
2 4 2
1 2 1
. (14)
Compact nitedierence approximations to Laplacians
are often specied in this way, as a 33 stencil for G
T
G
(e.g., Patra and Karttunen, 2005). I focus instead on the
2 2 stencils for G1 and G2, the components of G, be
cause those will facilitate compact SPS nitedierence
approximations G
T
DG to anisotropic Laplacians with
spatiallyvarying tensors in D.
The conditions r s 0 and r + s = 1 imply
a family of nitedierence approximations for which
0 rs 1/4. Figure 5 shows three dierent members
of this family, corresponding to rs = 0, 1/12, and 1/4,
with their Fourier transforms.
0 1 0
1 4 1
0 1 0
?

k
1
k
2
(a) rs = 0
1/6 2/3 1/6
2/3 10/3 2/3
1/6 2/3 1/6
?

k
1
k
2
(b) rs = 1/12
1/2 0 1/2
0 2 0
1/2 0 1/2
?

k
1
k
2
(c) rs = 1/4
Figure 5. Stencils and Fourier transforms for three dierent
nitedierence approximations to Laplacians. Fourier am
plitudes displayed are clipped between zero (dark blue) and
four (dark red). Wavenumbers k
1
and k
2
are in the range
[, ] radians per sample.
The three approximations displayed in Figure 5 are
comparable near the origin, for low wavenumbers k1 and
k2, where contours are nearly circular with amplitudes
that well approximate the ideal Fourier transform k
2
=
k
2
1
+k
2
2
. This isotropy can be important in applications
such as image smoothing and painting, where results
should not depend on sampling directions.
For higher wavenumbers, errors are visible in all
three approximations, but contours for rs = 1/12 ap
pear most nearly circular. In fact, errors for this middle
approximation are wellknown to be isotropic to 2nd or
der, and among all compact 9point stencils this approx
imation to the isotropic Laplacian operator is optimal
in that sense (e.g., Patra and Karttunen, 2005).
Let us dene discretization error as a function E(k)
of wavenumber k by the Fourier transform pair
G
T
G k
2
[1 E(k)]. (15)
Finitedierence approximations 79
The Fourier transform of our nitedierence stencil
G
T
G (equation 14) is the product of the ideal factor
k
2
and a second factor [1E(k)]. The second factor in
cludes the error E(k) that we would like to be zero or,
failing that, at least isotropic to O(k
2
). From the series
expansion of the Fourier transform of G
T
G we nd that
for rs = 1/12 the discretization error
E(k) =
k
2
12
+ O(k
4
) (16)
is indeed isotropic to O(k
2
). For rs = 1/12, the rst
2ndorder term of this error is anisotropic; it depends
on the wavenumber vector k and not just its magnitude
k.
The coecients r and s of G1 and G2 for the opti
mal approximation are easily found from the conditions
r s 0, r + s = 1 and rs = 1/12. They are
r = 1/2 + 1/
6, s = 1/2 1/
6.
The coecients for rs = 1/4 are simply r = s =
1/2. These coecients imply a simple averaging of 
nite dierences in G1 and G2 dened by equations 13.
Observe however that the Fourier transform displayed
in Figure 5c implies that this approximation attenu
ates high wavenumbers near Nyquist, in addition to low
wavenumbers near the origin.
This observation can help us understand the image
painting artifacts in Figure 4. When the nitedierence
operator of Figure 5c is applied to an input constant or
checkerboard image f , the output image g = G
T
Gf
is zero. The inverse of such an operator will tend to
amplify the same constant or checkerboard features.
3 ANISOTROPIC LAPLACIANS
From nitedierence approximations G1 and G2 we
may also construct approximations
D G
T
DG =
G
T
1
G
T
2
D11 D12
D12 D22
G1
G2
(17)
to anisotropic Laplacians. We simply gather with G,
multiply by D, and scatter with G
T
. The corresponding
computer program might look like this:
for (int i2=1; i2<n2; ++i2) {
for (int i1=1; i1<n1; ++i1) {
float f1r = f[i2 ][i1 ]f[i2 ][i11];
float f1s = f[i21][i1 ]f[i21][i11];
float f2r = f[i2 ][i1 ]f[i21][i1 ];
float f2s = f[i2 ][i11]f[i21][i11];
float f1 = r*f1r+s*f1s;
float f2 = r*f2r+s*f2s;
float g1 = f1*d11[i2][i1]+f2*d12[i2][i1];
float g2 = f1*d12[i2][i1]+f2*d22[i2][i1];
float g1r = g1*r;
float g1s = g1*s;
float g2r = g2*r;
float g2s = g2*s;
g[i2 ][i1 ] = g1r+g2r;
g[i2 ][i11] = g1rg2s;
g[i21][i1 ] += g1sg2r;
g[i21][i11] = g1s+g2s;
}
}
The gatherscatter symmetry in this program en
sures an SPS implementation of G
T
DG. As above, this
implementation is equivalent to one that gathers with
a 9point stencil. However, the latter implementation
would require a more complex evaluation of stencil co
ecients that vary from sample to sample inside the
innermost loop.
3.1 The problem
Although the approximation implemented by this com
puter program is SPS, it is a rather poor approximation
except for the special case rs = 1/4. To see the problem,
let us rst consider the approximation with rs = 0, for
three dierent sets of constant coecients d11, d12 and
d22 of the tensor D.
Figure 6a shows the 9point stencil for the case
d11 = 1, d12 = d22 = 0. As expected, this stencil ap
proximates a second derivative in the direction of the
vertical axis x1.
The problem is apparent in the other two sten
cils shown in Figures 6b and 6c; these stencils approx
imate second derivatives in the directions x1 = x2 and
x1 = x2, respectively. Both stencils approximate the
appropriate derivatives; but they do so with very dier
ent discretization errors.
The stencil in Figure 6c should ideally be a rotated
version of the stencil in Figure 6b, but this clearly is not
the case. Image smoothing or painting with such stencils
will yield surprising dierences for features oriented at
angles of 45 degrees and +45 degrees with respect to
the sampling grid.
Stencils for rs = 1/12 show the same problem, as
indicated in Figures 7. Although rs = 1/12 is optimal
for the isotropic case d11 = d22 = 1, d12 = 0 shown
in Figures 5, this value is clearly not optimal for the
anisotropic cases shown in Figures 7.
Stencils for rs = 1/4, shown in Figures 8, do show
the expected (45degree) symmetry and in this sense
are better approximations to anisotropic Laplacians.
However, they unfortunately also exhibit the same at
tenuation at high wavenumbers near Nyquist that we
have already seen in Figures 5.
This attenuation of high wavenumbers in approx
imations to anisotropic Laplacians will cause ampli
cation of those same wavenumbers in image smoothing
and painting applications. These wavenumbers near the
spatial Nyquist frequencies are apparent in Figure 4,
where they appear as a checkboard pattern of painting
artifacts. These high wavenumbers are enhanced when
we invert approximations like those shown in Figures 8.
80 D. Hale
0 1 0
0 2 0
0 1 0
?

k
1
k
2
(a) d
11
= 1, d
12
= d
22
= 0
0 1 1/2
1 3 1
1/2 1 0
?

k
1
k
2
(b) d
11
= d
12
= d
22
= 1/2
0 0 1/2
0 1 0
1/2 0 0
?

k
1
k
2
(c) d
11
= d
12
= d
22
= 1/2
Figure 6. Finitedierence approximations G
T
DG for rs =
0.
3.2 A solution
Recall that the approximation for rs = 1/12 is in one
sense optimal; it is the most isotropic approximation
of the isotropic Laplacian. For anisotropic Laplacians
we can improve this approximation by considering two
additional approximations G1 and G2 to the gradient
operators.
G1a =
s r
s r
, G2a =
s s
r r
,
G
1b
=
r s
r s
, G
2b
=
r r
s s
, (18)
In hindsight, we had no reason above to prefer one
or the other of the approximations G1a or G
1b
; likewise
for G2a and G
2b
. In equations 13 above, I chose the sten
cils G1a and G2a, but I might just as well have chosen
G
1b
or G
2b
.
1/12 5/6 1/12
1/6 5/3 1/6
1/12 5/6 1/12
?

k
1
k
2
(a) d
11
= 1, d
12
= d
22
= 0
1/6 2/3 1/3
2/3 7/3 2/3
1/3 2/3 1/6
?

k
1
k
2
(b) d
11
= d
12
= d
22
= 1/2
0 0 1/2
0 1 0
1/2 0 0
?

k
1
k
2
(c) d
11
= d
12
= d
22
= 1/2
Figure 7. Finitedierence approximations G
T
DG for rs =
1/12.
With two choices for each of the nitedierence
approximations G1 and G2, we can form a total of four
dierent G
T
DG. Let us average all four to obtain
D
1
4
G
T
1a
G
T
2a
D11 D12
D12 D22
G1a
G2a
G
T
1a
G
T
2b
D11 D12
D12 D22
G1a
G
2b
G
T
1b
G
T
2a
D11 D12
D12 D22
G
1b
G2a
G
T
1b
G
T
2b
D11 D12
D12 D22
G
1b
G
2b
. (19)
This average of four SPS matrices is clearly SPS. For
rs = 1/12 and constant tensor coecients, this av
erage yields the 9point stencils shown in Figures 9.
These stencils exhibit desired symmetries the stencil
in Figure 9c is a rotated version of that in Figure 9b
and they do not attenuate wavenumbers near the spa
tial Nyquist frequencies. The nitedierence approx
Finitedierence approximations 81
1/4 1/2 1/4
1/2 1 1/2
1/4 1/2 1/4
?

k
1
k
2
(a) d
11
= 1, d
12
= d
22
= 0
1/2 0 0
0 1 0
0 0 1/2
?

k
1
k
2
(b) d
11
= d
12
= d
22
= 1/2
0 0 1/2
0 1 0
1/2 0 0
?

k
1
k
2
(c) d
11
= d
12
= d
22
= 1/2
Figure 8. Finitedierence approximations G
T
DG for rs =
1/4.
imation in equation 19 is the one that I used in the
image painting example of Figure 2.
The same average of four approximations for rs = 0
yields a slightly dierent nitedierence approximation
that was derived from a mixed niteelement method
by Arbogast et al. (1997). I favor the approximation
shown here with rs = 1/12 because as discussed above
its errors are more isotropic.
Implementation of the approximation in equa
tion 19 need not require a factor of four increase in com
putational cost, because the averaging can be performed
analytically. The derivation is tedious but the result is
simple, even for the case of spatially varying tensor co
ecients. For that case, dene symmetric tensors D at
the four corners of an image sample with indices (i1, i2)
1/12 5/6 1/12
1/6 5/3 1/6
1/12 5/6 1/12
?

k
1
k
2
(a) d
11
= 1, d
12
= d
22
= 0
1/3 1/3 1/6
1/3 5/3 1/3
1/6 1/3 1/3
?

k
1
k
2
(b) d
11
= d
12
= d
22
= 1/2
1/6 1/3 1/3
1/3 5/3 1/3
1/3 1/3 1/6
?

k
1
k
2
(c) d
11
= d
12
= d
22
= 1/2
Figure 9. Finitedierence approximations obtained by av
eraging four dierent G
T
DG for rs = 1/12.
as follows:
D(i1
1
2
, i2
1
2
)
a00 b00
b00 c00
D(i1
1
2
, i2 +
1
2
)
a10 b10
b10 c10
D(i1 +
1
2
, i2
1
2
)
a01 b01
b01 c01
D(i1 +
1
2
, i2 +
1
2
)
a11 b11
b11 c11
G
T
1
G
T
2
G
T
3
2
4
D11 D12 D13
D12 D22 D23
D13 D23 D33
3
5
2
4
G1
G2
G3
3
5
. (20)
Compact 2 2 2 stencils for G1, G2, and G3 are
rotated versions of each other:
G1 =
t s
t s
s r
s r
,
G2 =
t t
s s
s s
r r
,
G3 =
t s
s r
t s
s r
,
r s t 0, rt = s
2
, r + 2s + t = 1. (21)
In this notation, the back part of each stencil is specied
left of the front part. The condition rt = s
2
follows from
desired symmetries in G
T
1
G1, G
T
2
G2 and G
T
3
G3. The
condition r +2s +t = 1 ensures that G
T
1
G1, G
T
2
G2 and
G
T
3
G3 are 2ndorder approximations.
These stencils for G1, G2, and G3 lead to compact
3 3 3 27point stencils for G
T
DG. In the isotropic
case where D = I, we have
G
T
G = G
T
1
G1 +G
T
2
G2 +G
T
3
G3 (22)
For this case Patra and Karttunen (2005) give condi
tions for which compact 3D stencils have (to 2nd order)
isotropic discretization errors, and they list examples of
stencils that meet those conditions. In three dimensions,
unlike two dimensions, more than one such stencil is
possible.
However, none of the isotropic stencils they cite
can be expressed in the form of equation 22, in terms
of approximations to components of gradients. In other
words, they do not correspond to approximations G1,
G2, and G3 that we could use in the anisotropic form
of equation 20.
By carefully choosing the coecients r, s and t sub
ject to the conditions cited above, I found a new nite
Finitedierence approximations 83
dierence approximation with the desired form. The co
ecients are
t = 5/12 1/
6, r = (1
t)
2
, s =
rt.
These coecients lead to the following 27point stencil:
G
T
G =
c1 c2 c1
c2 c3 c2
c1 c2 c1
c2 c3 c2
c3 c4 c3
c2 c3 c2
c1 c2 c1
c2 c3 c2
c1 c2 c1
,
c1 = 1/48, c2 = 1/8, c3 = 5/12, c4 = 25/6.
(23)
This stencil meets the conditions for isotropic discretiza
tion errors specied by Patra and Karttunen (2005),
who cite a dierent 27point stencil proposed by Spotz
and Carey (1995):
c1 = 1/30, c2 = 1/10, c3 = 7/15, c4 = 64/15.
As noted above, this dierent stencil does not have cor
responding approximations G1, G2 and G3 that we can
use in equation 20.
Before inserting the stencils G1, G2 and G3 of equa
tions 21 into equation 20, we rst recognize that each of
these 3D stencils can be written in four dierent ways.
Those four ways are analogous to the two dierent ways
we expressed the 2D stencils G1 and G2 in equations 18.
Since each of the 3D stencils G1, G2 and G3 can
be written four dierent ways, we have a total of 64 =
4 4 4 combinations of the form of equation 20. By
averaging all 64 combinations, we obtain a composite
3D nitedierence approximation for an anisotropic
Laplacian.
This large number of combinations to average can
be reduced if we consider only pairwise combinations
such as G
T
1
D11G1 (four ways) or G
T
1
D12G2 (sixteen
ways). In any case, the averaging can again be per
formed analytically and, although too lengthy to be in
cluded in this paper, the result is analogous to that ob
tained above by averaging 2D approximations.
5 CONCLUSION
The method described here for nitedierence approxi
mation of anisotropic Laplacians is straightforward. We
begin with compact nitedierence approximations to
components of the gradient. We then average symmet
ric positivesemidenite combinations of those gradient
approximations to obtain the desired approximations
to anisotropic Laplacians. Finitedierence approxima
tions obtained in this way are guaranteed to be sym
metric and positivesemidenite.
This design method yields 9point stencils for 2D
approximations and 27point stencils for 3D approxi
mations of anisotropic Laplacians. Our 2D approxima
tion is a generalization of that proposed by Arbogast et
al. (1997), in that for one particular gradient approxi
mation we obtain the coecients of their 9point sten
cil. However, an alternative gradient approximation in
our method leads to a 9point stencil with isotropic dis
cretization errors.
Arbogast et al. (1997) also proposed a 19point
stencil for a 3D approximation, and our 27point sten
cil is not a generalization of theirs. Indeed, I have not
found a way to modify the design proposed here to ob
tain such a 19point stencil. A 19point stencil is attrac
tive because it implies lower computational costs.
In both 2D and 3D approximations, required
symmetry in the resulting 9point or 27point nite
dierence stencils implies only one free parameter in the
corresponding gradient approximations. I choose this
parameter to obtain stencils with isotropic discretiza
tion errors.
All nitedierence methods exhibit discretization
errors. By choosing methods for which those errors are
isotropic to leading order, we may reduce artifacts asso
ciated with sampling grids in applications such as image
smoothing and image painting.
REFERENCES
Arbogast, T., M.F. Wheeler and I. Yotov, 1997, Mixed nite
elements for elliptic problems with tensor coecients as
cellcentered nitedierences: SIAM Journal of Numeri
cal Analysis, 34, 828852.
Claerbout, J.F., 1992, Earth soundings analysis processing
versus inversion: Blackwell Scientic Publications.
Fehmers, G.C., C.F.W. Hocker, 2003, Fast structural inter
pretations with structureoriented ltering: Geophysics,
68, 12861293.
Patra, M. and M. Karttunen, 2005, Stencils with isotropic
discretization errors for dierential operators: Numerical
Methods for Partial Dierential Equations, 22, 936953.
Spotz, W.F. and G.F. Carey, 1996, A highorder compact for
mulation for the 3D Poisson equation: Numerical Meth
ods for Partial Dierential Equations, 12, 235243.
van Vliet, L.J., and P.W. Verbeek, 1995, Estimators for ori
entation and anisotropy in digitized images: Proceedings
of the rst annual conference of the Advanced School for
Computing and Imaging ASCI95, Heijen (The Nether
lands), 442450.
84 D. Hale