You are on page 1of 10

# CWP-593

## Compact nite-dierence approximations for

anisotropic image smoothing and painting
Dave Hale
Center for Wave Phenomena, Colorado School of Mines, Golden CO 80401, USA
ABSTRACT
Finite-dierence approximations are succinctly represented by their stencils, a
set of weights that when applied to adjacent samples of a function approximate
some dierential operator. In image processing the samples are pixels or vox-
els, and the dierential operators must be inverted for smoothing or painting
applications. For eciency in such applications requiring inverses, the nite-
dierence stencils should be compact, using only a small 3 3 set of nine pixels
or a 3 3 3 set of twenty-seven voxels.
From 2 2 and 2 2 2 approximations to gradient operators I obtain 3 3
(9-point) and 3 3 3 (27-point) stencils that approximate Laplacian oper-
ators. The latter may include tensor coecients that make them anisotropic.
By deriving nite-dierence stencils for anisotropic Laplacians in this way, that
is, from approximations to gradients, we guarantee that our approximations to
anisotropic Laplacians are symmetric and positive-semidenite. And by choos-
ing the gradient approximations carefully, discretization errors can be made
isotropic to leading order.
Key words: nite-dierence numerical methods
1 INTRODUCTION
A Laplacian is a symmetric dierential operator that
roughens. When applied to a function, it removes any
constant bias or linear trend while enhancing higher fre-
quencies.
This behavior is apparent in the Fourier trans-
form of the Laplacian operator. For if F(k) denotes the
Fourier transform of a function f(x)
f(x) F(k), (1)
then
f(x) k
2
F(k). (2)
The minus sign in makes this symmetric dier-
ential operator positive-semidenite (SPS); its Fourier
transform k
2
= k
T
k is non-negative and implies ampli-
cation of higher wavenumbers.
An isotropic Laplacian roughens a function equally
in all directions; its Fourier transform k
2
depends on
only the magnitude k of the wavenumber vector k.
To roughen a function in one direction more
than others, we may include a symmetric positive-
semidenite (SPS) tensor D in our Laplacian operator:
Df(x) k
T
DkF(k). (3)
For this anisotropic Laplacian operator, the direction of
maximum roughening is aligned with that eigenvector
of D having largest eigenvalue.
In practical applications involving images, the func-
tion f(x) is sampled and partial derivatives must be
approximated with nite dierences. If we arrange all
image samples into a single column vector f , then an
anisotropic Laplacian may be approximated by
Df G
T
DGf , (4)
where G is some sparse matrix that represents a nite-
dierence approximation to a gradient. In particular, for
a 2-D image with N = N1 N2 samples, G is a 2NN
matrix
G =

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 nite-dierence approximation of equation 4,
the tensor eld D is represented by a block-diagonal
matrix
D =

D11 D12
D12 D22

, (6)
composed of N N diagonal matrices D11, D12 and
D22. The 3N possibly non-zero 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 structure-oriented 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 positive-denite
(SPD) so that a solution g can be found eciently us-
ing conjugate-gradient 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
block-diagonal 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 spatially-varying 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 left-hand-side to be symmetric and
positive-denite (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 spatially-varying directions determined
by eigen-decomposition of the tensors in D.
In other words, solution of equation 9 yields a
structure-oriented multi-dimensional 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 nite-dierence 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
Finite-dierence 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 nite-dierence 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 2-D nite-dierence
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 3-D nite-dierence approximations for
both isotropic and anisotropic Laplacians.
Both 2-D and 3-D approximations are compact in
that they approximate derivatives for any image sample
using only nearest neighbor samples: 9 samples for 2-D
and 27 samples for 3-D Laplacians. Both 2-D and 3-D
approximations maintain the SPS property of G
T
DG,
which ensures SPD systems of equations 7 and 9. Com-
pact SPD nite-dierence 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)
Finite-dierence 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 2nd-order 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 ][i1-1];
float f1s = f[i2-1][i1 ]-f[i2-1][i1-1];
float f2r = f[i2 ][i1 ]-f[i2-1][i1 ];
float f2s = f[i2 ][i1-1]-f[i2-1][i1-1];
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 ][i1-1] -= g1r-g2s;
g[i2-1][i1 ] += g1s-g2r;
g[i2-1][i1-1] -= g1s+g2s;
}
}
Although this program fragment ignores boundaries, it
can be easily modied to implement zero-value 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 nite-dierence 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 nite-dierence
approximations G
T
DG to anisotropic Laplacians with
spatially-varying tensors in D.
The conditions r s 0 and r + s = 1 imply
a family of nite-dierence 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
nite-dierence 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 well-known to be isotropic to 2nd or-
der, and among all compact 9-point 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)
Finite-dierence approximations 79
The Fourier transform of our nite-dierence 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
2nd-order 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 nite-dierence
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 nite-dierence 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 ][i1-1];
float f1s = f[i2-1][i1 ]-f[i2-1][i1-1];
float f2r = f[i2 ][i1 ]-f[i2-1][i1 ];
float f2s = f[i2 ][i1-1]-f[i2-1][i1-1];
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 ][i1-1] -= g1r-g2s;
g[i2-1][i1 ] += g1s-g2r;
g[i2-1][i1-1] -= g1s+g2s;
}
}
The gather-scatter 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 9-point 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 9-point 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 (45-degree) 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. Finite-dierence 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. Finite-dierence approximations G
T
DG for rs =
1/12.
With two choices for each of the nite-dierence
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 9-point 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 nite-dierence approx-
Finite-dierence 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. Finite-dierence 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 nite-dierence approximation
that was derived from a mixed nite-element 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. Finite-dierence 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

## Then, using the nite-dierence approximation of equa-

tion 19, the 9-point stencil centered on the image sample
82 D. Hale
with indices (i1, i2) is
1
2
b00 a00 a10 b10
a00 + a01 + a10 + a11
c00 c01 +b00 b01 b10 + b11 c10 c11
+c00 + c01 + c10 + c11
b01 a01 a11 b11
+rs
a00 + a10
a00 c00 +c00 + c10 a10 c10
a00 + a01 a00 a01 a10 a11 a10 + a11
+c00 + c01 c00 c01 c10 c11 +c10 + c11
a01 c01 a01 + a11 a11 c11
+c01 + c11
.
For rs = 0 only the rst part of this stencil is signi-
cant, and this part is the nite-dierence approximation
of Arbogast et al. (1997). Addition of the second part
with rs = 1/12 yields a nite-dierence approximation
with errors that are more isotropic. For constant tensor
coecients a = d11, b = d12 and c = d22 this stencil is
consistent with the three examples in Figures 9.
For spatially varying tensor coecients, the various
sums and dierences in this 9-point stencil maintain the
important SPS property of our nite-dierence approx-
imation. As shown above, a simpler way to maintain
this SPS property is to gather and scatter consistently,
as illustrated by the following program fragment:
for (int i2=1; i2<n2; ++i2) {
for (int i1=1; i1<n1; ++i1) {
float a = 0.5f*d11[i2][i1];
float b = 0.5f*d12[i2][i1];
float c = 0.5f*d22[i2][i1];
float t = 2.0f*rs*(a+c);
float fpp = f[i2 ][i1 ];
float fpm = f[i2 ][i1-1];
float fmp = f[i2-1][i1 ];
float fmm = f[i2-1][i1-1];
float apppm = (a-t)*(fpp-fpm);
float ampmm = (a-t)*(fmp-fmm);
float bppmm = (b+t)*(fpp-fmm);
float bpmmp = (b-t)*(fpm-fmp);
float cppmp = (c-t)*(fpp-fmp);
float cpmmm = (c-t)*(fpm-fmm);
g[i2 ][i1 ] = apppm+bppmm+cppmp;
g[i2 ][i1-1] -= apppm+bpmmp-cpmmm;
g[i2-1][i1 ] += ampmm+bpmmp-cppmp;
g[i2-1][i1-1] -= ampmm+bppmm+cpmmm;
}
}
Note that this implementation requires for each image
sample only one evaluation of tensor elements.
4 3-D LAPLACIANS
The methodology used above to derive a nite-dierence
approximation to a 2-D anisotropic Laplacian extends
naturally to three dimensions. The two important steps
are
(i) Find approximations G1, G2, and G3
to components of the gradient such that
G
T
G = G
T
1
G1 + G
T
2
G2 + G
T
3
G3 has (to second
order) isotropic discretization errors.
(ii) Average all possible combinations of these com-
ponents in approximations G
T
DG to the anisotropic
Laplacian.
The combinations G
T
DG will have the form
G
T
DG =

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 2nd-order approximations.
These stencils for G1, G2, and G3 lead to compact
3 3 3 27-point 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 3-D 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-
Finite-dierence 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 27-point 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 27-point 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 3-D stencils can be written in four dierent ways.
Those four ways are analogous to the two dierent ways
we expressed the 2-D stencils G1 and G2 in equations 18.
Since each of the 3-D 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
3-D nite-dierence 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 2-D approximations.
5 CONCLUSION
The method described here for nite-dierence approxi-
mation of anisotropic Laplacians is straightforward. We
begin with compact nite-dierence approximations to
components of the gradient. We then average symmet-
ric positive-semidenite combinations of those gradient
approximations to obtain the desired approximations
to anisotropic Laplacians. Finite-dierence approxima-
tions obtained in this way are guaranteed to be sym-
metric and positive-semidenite.
This design method yields 9-point stencils for 2-D
approximations and 27-point stencils for 3-D approxi-
mations of anisotropic Laplacians. Our 2-D 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 9-point sten-
cil. However, an alternative gradient approximation in
our method leads to a 9-point stencil with isotropic dis-
cretization errors.
Arbogast et al. (1997) also proposed a 19-point
stencil for a 3-D approximation, and our 27-point 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 19-point stencil. A 19-point stencil is attrac-
tive because it implies lower computational costs.
In both 2-D and 3-D approximations, required
symmetry in the resulting 9-point or 27-point 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 nite-dierence 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
cell-centered nite-dierences: 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 structure-oriented 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 high-order 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