An Image Inpainting Technique Based On The Fast Ma
An Image Inpainting Technique Based On The Fast Ma
An Image Inpainting Technique Based On The Fast Ma
net/publication/238183352
CITATIONS READS
1,229 16,797
1 author:
Alexandru Telea
University of Groningen
264 PUBLICATIONS 7,061 CITATIONS
SEE PROFILE
All content following this page was uploaded by Alexandru Telea on 08 September 2014.
1. Introduction
Several inpainting methods are based on the above ideas. In [Bertalmio 00,
Bertalmio 01], the image smoothness information, estimated by the image
Laplacian, is propagated along the isophotes directions, estimated by the im-
age gradient rotated 90 degrees. The Total Variational (TV) model [Chan
and Shen 00a] uses an Euler-Lagrange equation coupled with anisotropic dif-
fusion to maintain the isophotes’ directions. The Curvature-Driven Diffusion
(CCD) model [Chan and Shen 00b] enhances the TV method to drive dif-
fusion along the isophotes’ directions and thus allows inpainting of thicker
regions. All above methods essentially solve a Partial Differential Equation
(PDE) that describes the color propagation inside the missing region, subject
to various heuristics that attempt to preserve the isophotes’ directions. Pre-
serving isophotes is, however desirable, never perfectly attained in practice.
The main problem is that both isophote estimation and information propaga-
tion are subject to numerical diffusion. Diffusion is desirable as it stabilizes
the PDEs to be solved, but leads inevitably to a cetain amount of blurring of
the inpainted area.
A second type of methods [Oliveira 01] repeatedly convolves a simple 3 ×
3 filter over the missing regions to diffuse known image information to the
missing pixels.
However impressive, the above methods have several drawbacks that pre-
clude their use in practice. The PDE-based methods require implementing
nontrivial iterative numerical methods and techniques, such as anisotropic
diffusion and multiresolution schemes [Bertalmio 00]. Little or no informa-
tion is given on practical implementation details such as various thresholds
or discretization methods, although some steps are mentioned as numerically
unstable. Moreover, such methods are quite slow, e.g., a few minutes for
the relatively small inpainting region shown in Figure 1. In contrast, the
convolution-based method described in [Oliveira 01] is fast and simple to im-
plement. However, this method has no provisions for preserving the isophotes’
directions. High-gradient image areas must be selected manually before in-
painting and treated separately so as not to be blurred.
We propose a new inpainting algorithm based on propagating an image
smoothness estimator along the image gradient, similar to [Bertalmio 00]. We
estimate the image smoothness as a weighted average over a known image
neighborhood of the pixel to inpaint. We treat the missing regions as level
sets and use the fast marching method (FMM) described in [Sethian 96] to
propagate the image information. Our approach has several advantages:
• it is very simple to implement (the complete pseudocode is given here);
a) b)
2. Our Method
This section describes our inpainting method. First, we introduce the math-
ematical model on which we base our inpainting (Section 2.1). Next, we
describe how the missing regions are inpainted using the FMM (Section 2.2).
Finally, we detail the implementation of inpainting one point on the missing
region’s boundary (Section 2.3).
To explain our method, consider Figure 2, in which one must inpaint the
point p situated on the boundary ∂Ω of the region to inpaint Ω. Take a small
neighborhood Bε (p) of size ε of the known image around p (Figure 2(a)). As
described in [Bertalmio 00, Oliveira 01, Chan and Shen 00a], the inpainting
of p should be determined by the values of the known image points close to
p, i.e., in Bε (p). We first consider gray value images, color images being a
natural extension (see Section 2.4). For ε small enough, we consider a first
order approximation Iq (p) of the image in point p, given the image I(q) and
gradient ∇I(q) values of point q (Figure 2(b)):
a) b)
Figure 2. The inpainting principle.
The weighting function w(p, q), detailed in Section 2.3, is designed such that
the inpainting of p propagates the gray value as well as the sharp details of
the image over Bε (p).
Section 2.1 explained how to inpaint a point on the unknown region’s bound-
ary ∂Ω as a function of known image pixels only. To inpaint the whole Ω, we
iteratively apply Equation 2 to all the discrete pixels of ∂Ω, in increasing dis-
tance from ∂Ω’s initial position ∂Ωi , and advance the boundary inside Ω until
the whole region has been inpainted (see pseudocode in Figure 3). Inpaint-
ing points in increasing distance order from ∂Ωi ensures that areas closest
to known image points are filled in first, thus mimicking manual inpainting
techniques [Bertalmio 00, Bertalmio 01].
Implementing the above requires a method that propagates ∂Ω into Ω by
advancing the pixels of ∂Ω in order of their distance to the initial boundary
∂Ωi . For this, we use the fast marching method. In brief, the FMM is an
algorithm that solves the Eikonal equation:
|∇T | = 1 on Ω, with T = 0 on ∂Ω . (3)
The solution T of Equation 3 is the distance map of the Ω pixels to the
boundary ∂Ω. The level sets, or isolines, of T are exactly the successive
Telea: An Image Inpainting Technique 29
• BAND : the pixel belongs to the narrow band. Its T value undergoes
update.
• KNOWN : the pixel is outside ∂Ω, in the known image area. Its T and
I values are known.
• INSIDE : the pixel is inside ∂Ω, in the region to inpaint. Its T and I
values are not yet known.
We consider now how to inpaint a newly discovered point (k, l), as a function
of the KN OW N points around it, following the idea described in Section 2.1.
(Step 3 in Figure 4, detailed in Figure 5). We iterate over the KN OW N points
in the neighborhood Bε of the current point (i, j) and compute I(i, j) following
Equation 2. The image gradient ∇I (gradI in the code) is estimated by central
differences. As stated in Section 2.1, the design of the weighting function
w(p, q) is crucial to propagate the sharp image details and the smooth zones as
such into the inpainted zone. We design w(p, q) = dir(p, q) · dst(p, q) · lev(p, q)
The directional component dir(p, q) ensures that the contribution of the pix-
els close to the normal direction N = ∇T (gradT in the code), i.e., close
to the FMM’s information propagation direction, is higher than for those
farther from N . The geometric distance component dst(p, q) decreases the
contribution of the pixels geometrically farther from p. The level set distance
component lev(p, q) ensures that pixels close to the contour through p con-
tribute more than farther pixels. Both dst and lev are relative with respect
to the reference distances d0 and T0 . In practice, we set d0 and T0 to the
interpixel distance, i.e., to 1. Overall, the above factors model the manual
inpainting heuristics [Bertalmio 00] that describe how to paint a point by
strokes bringing color from a small region around it.
For ε up to about six pixels, i.e., when inpainting thin regions, dst and lev
have a weak effect. For thicker regions to inpaint, such as Figure 8(d), where
we used an ε of 12 pixels, using dst and lev provides better results than using
dir alone. The above is clearly visible in Figure 6, on a test image taken
from [Bertalmio 00], where the missing ring-shaped region is more than 30
pixels thick. Figure 6(c) shows, on an image detail, the effect of dir alone.
The results are somewhat less blurry when dir and dst (Figure 6(d)) or dir
and lev (Figure 6(e)) are used together. The inpainting is the best visually
when all three components are used (Figure 6(f)).
c) d)
a) b) e) f)
Figure 6. Thick region to inpaint (a) and result (b). Effect of weighting functions:
direction (c), direction and geometric distance (d), direction and level set distance
(e), direction, geometric, and level set distance (f).
Telea: An Image Inpainting Technique 33
3. Discussion
detail area
results of OBMC (shown in [Oliveira 01]) were visibly more blurry for regions
thicker than six pixels. The runtime for our method was in all cases much
shorter than for BSCB. Our C++ implementation took less than 3 seconds
on an 800 MHz PC for a 800 × 600 color image with about 15% pixels to
inpaint (Figure 1). On the same input, the original BSCB method, published
in [Bertalmio 00], is reported to take less than 5 minutes on a 300 MHz PC.
The BSCB implementation we used [Yung and Shankar ??], which is men-
tioned to be unoptimized by its authors, took between 2.5 and 3 minutes
on the 800 MHz PC, depending on its various parameter settings. In con-
trast, OBMC takes in all cases about the same time as our method. The
above matches the fact that both OBMC and our method are linear in the
inpainted region’s size.
The main limitation of our method (applicable to the BSCB and OBMC
methods mentioned here) is the blurring produced when inpainting regions
thicker than 10—15 pixels, especially visible when sharp isophotes intersect
the region’s boundary almost tangentially. See, for example, the inpainting
in Figure 8(d), (e) (in detail in Figure 8(i), (j)). The above is caused by
the linear and local character of our method. Techniques using an explicit
nonlinear and/or global image model, such as the TV [Chan and Shen 00a]
and CDD [Chan and Shen 00b] methods, achieve better results, at the cost of
considerably more complex implementations.
Overall, the presented inpainting method is simple to implement (our com-
plete C++ code is about 500 lines), fast, and easy to customize for different in-
painting strategies. We plan to extend the method by developing new inpaint-
ing functions that are better able to preserve the isophotes’ directions. One
such way is to integrate anisotropic diffusion, e.g., following [Bertalmio 00], in
the FMM boundary evolution in order to reduce the blurring for inpainting
Telea: An Image Inpainting Technique 35
a)
d) e)
b)
f) g) h)
c) i) j)
Figure 8. Inpainting examples. Damaged photo (a), inpainting by method BSCB
(b), our method (c), and close-ups (f, g, h). Damaged photo (d), distance-weighted
inpainting (e), and close-ups (i, j)
.
References
Web Information
Received October 24, 2002; accepted in revised form May 21, 2003.