Numerical Methods Image Processing
Numerical Methods Image Processing
PROCESSING
CHANG-OCK LEE
1. Getting Started
In this lecture note we will show how certain PDEs used in image analysis
can be discretized. The generic form of these PDEs is
Lv = F (t, x, y) ∈ R+ × Ω,
∂v
(t, x, y) = 0 on R+ × ∂Ω,
∂N
v(0, x, y) = f (x, y),
∂v
(t, x, y) + H(x, y, v(t, x, y), ∇v(t, x, y), ∇2 v(t, x, y)) = 0.
∂t
1
2 CHANG-OCK LEE
Figure 1: Grid on the space domain. The circles indicate the vertices
that belong to the 3 × 3 neighborhood of the vertex (i, j).
∆x = ∆y = h.
Notice that in many articles from the computer vision literature, it is even
choose as h = 1, which means that the pixel size is chosen as the unit
of reference. We will call the positions (ih, jh) vertices, nodes, or pixels
equivalently. We will denote by vi,jn (respectively un ) the values of the
i,j
exact solution (respectively the discrete solution) at location (ih, jh) and
tine n∆t.
Example: The PDE (1.1) is an initial-boundary value problem. To dis-
cretize it, we need to consider the following:
• The equation. To find the difference scheme associated with the
heat equation (1.1), we use Taylor expansions expanded about the
index (n∆t, ih, jh). Naturally, the simplest method is to consider
separately the discretization of each second-order derivative in x and
BASIC NUMERICAL METHODS FOR IMAGE PROCESSING 3
which can also be written in the y direction. The vertices involved in the
estimation (1.5) are represented in Figure 5. As for the case of the Laplacian,
these approximations are in fact “one-dimensional” and do not really take
advantage of the fact that the data is of dimension 2. This is visible if
we consider the value of the norm of the gradient of u in the two situations
described in Figure 4: We obtain either 12 or √12 . The solution is to use more
pixels in the estimation of the derivatives. In particular, we may suggest
the following approximation:
¯
∂v ¯¯ vi+1,j − vi−1,j
¯ ≈λ
∂x i,j 2h
(1.6) µ ¶
(1 − λ) vi+1,j+1 − vi−1,j+1 vi+1,j−1 − vi−1,j−1
+ + ,
2 2h 2h
differences:
div(b∇v)|i,j ≈ δx+ (bi,j δx− vi,j ) + δy+ (bi,j δy− vi,j )
1
= 2 (bi+1,j vi+1,j + bi,j vi−1,j + bi,j+1 vi,j+1 + bi,j vi,j−1
h
− (bi+1,j + bi,j+1 + 2bi,j )vi,j ) .
This approximation now involves the 3 × 3 neighborhood, but it introduces
an asymmetry: The values of b at ((i − 1)h, jh) and (ih, (j − 1)h) are not
used. A solution is to use the following approximation for the derivatives:
vi+ 1 ,j − vi− 1 ,j vi,j+ 1 − vi,j− 1
δx∗ vi,j = 2 2
and δy∗ vi,j = 2 2
,
h h
where vi± 1 ,j± 1 is the value of v at location ((i ± 21 )h, (j ± 21 )h), which can be
2 2
obtained by interpolation. As for (1.5). it is a second-order approximation.
Then we have
div(b∇v)|i,j ≈ δx∗ (bi,j δx∗ vi,j ) + δy∗ (bi,j δy∗ vi,j )
1
(2.2) = 2 (b+0 vi+1,j + b−0 vi−1,j + b0+ vi,j+1 + b0− vi,j−1
h
− (b+0 + b−0 + b0+ + b0− )vi,j ) .
where b±0 = bi± 1 ,j and b0± = bi,j∓ 1 . Notice that since we applied the
2 2
operators δx∗ and δy∗ twice, this approximation uses the values of v only at
((i ± 1)h, (j ± 1)h) (see Figure 6). However, interpolation is needed for b.
As mentioned previously for the estimation of the Laplacian, it would also
be interesting to take into account the diagonal values. Then, we can look
for an approximation such that
(2.3)
div(b∇v)|i,j ≈
λp
(b+0 vi+1,j + b−0 vi−1,j + b0+ vi,j+1 + b0− vi,j−1 − βp vi,j )
h2
λd
+ 2 (b++ vi+1,j+1 + b−− vi−1,j−1 + b−+ vi−1,j+1 + b+− vi+1,j−1 − βd vi,j )
h
with b±± = bi± 1 ,j± 1 ,
2 2
½
βp = b0+ + b0− + b+0 + b−0 ,
βd = b++ + b−− + b+− + b−+ ,
and where λp and λd are two weights to be chosen. The first condition is
that the scheme must be consistent, and it can be verified that this implies
λp + 2λd = 1.
Now there remains one degree of freedom. Two possibilities can be consid-
ered:
• The first is to choose (λp , λd ) constant, and for instance equal to
( 12 , 14 ), giving a privilege to the principal directions.
• The second is to choose (λp , λd ) by taking into account the orienta-
tion of the gradient of v, as described in Figure 7.
8 CHANG-OCK LEE
p
we easily get v(t, x, y) = x2 + y 2 + 2t − 1, from which we deduce
µ ¶ p
1 x x2 + y 2
∇v = p , |∇v| = p ,
x2 + y 2 + 2t y x2 + y 2 + 2t
µ ¶ µ ¶
∇v 1 x ∇v 1
=p , div =p ,
|∇v| 2
x +y 2 y |∇v| x + y2
2
so the two last quantities are not defined at the origin, and effectively a
spike occurs at the origin (see [9]). Moreover, the interface
Γ(t) = {(x, y) : v(t, x, y) = 0}
√
is the circle x2 + y 2 = 1 − 2t, and on Γ(t) we have |∇v| (t) = 1 − 2t.
Therefore v(t, x, y) becomes more and more flat as the interface evolves and
disappears at t = 21 . To circumvent this type of problem, we have to find a
numerical trick that prevents the gradient norm form vanishing (or blowing
up). This can be realized by reinitializing the function v from time to time
to a signed distance function.
More precisely, we run (4.2) until some step n; then we solve the auxiliary
PDE
∂φ + sign(φ)(|∇φ| − 1) = 0,
(4.3) ∂t
φ(0, x, y) = v(n∆t, x, y).
1These numbers are just an indication and naturally depend on the kind of equation
to be solved and on the time steps
12 CHANG-OCK LEE
where A(x, y) = (A1 (x, y), A2 (x, y)). For (4.5) we use a simple upwind
scheme, i.e., we check the sign of each component of A and construct a
one-side upwind difference in the appropriate direction:
£
un+1 n n − n n + n
i,j = ui,j + ∆t max((A1 )i,j , 0)δx ui,j + min((A1 )i,j , 0)δx ui,j
¤
+ max((A2 )ni,j , 0)δy− uni,j + min((A2 )ni,j , 0)δy+ uni,j .
4.4. Image Segmentation by the Geodesic Active Contour Model.
Now we can consider the geodesic active contour model (4.1), which can be
seen as the sum of the previous discretization. So the discrete scheme is
h £ ¤1
un+1
i,j = un
i,j + ∆t n
gi,j n
Ki,j (δx uni,j )2 + (δy uni,j )2 2
£ n
¤
+ α max(gi,j , 0)∇+ + min(gi,j n
, 0)∇− uni,j
+ max((gx )ni,j , 0)δx− uni,j + min((gx )ni,j , 0)δx+ uni,j
¤
+ max((gy )ni,j , 0)δy− uni,j + min((gy )ni,j , 0)δy+ uni,j ,
where ∇− uni,j is obtained from ∇+ uni,j by inverting the signs plus and minus.
Figure 14 shows a typical example.
Remark From a numerical point of view, all the equations presented in this
section involve local operations. Since we are interested only in the curve,
it is enough to update the values in a band around the current position of
the curve, also called a narrow band. Naturally, this region (band) has to
be updated as the curve evolves. See, for instance, [11] for more details.
References
[1] G. Aubert and P. Kornprobst, Mathematical Problems in Image Processing, Applied
Mathematical Sciences 147, Springer, 2002.
[2] P.G. Ciarlet and J.L. Lions, Handbook of Numerical Analyss. Vol. 1. Finite Difference
Methods. Solution of Equations in Rn , North Holland, 1990.
[3] E. Godlewski and P.A. Raviart, Hyperbolic Systems of Conservation Laws, Vol. 3/4
of Mathématiques et Applications, Ellipses, 1991.
[4] J. Gomes and O. Faugeras, Reconciling distance functions and level sets, J. Vis.
Comm. Image Rep. 11 (1990), 919–940.
14 CHANG-OCK LEE
[5] R.J. LeVeque, Numerical Methods for Conservation Laws, Birkhäuser, Basel, 1992.
[6] K.W. Morton and D.F. Mayers, Numerical Solution of Partial Differential Equations:
An Introduction, Second Edition, Cambridge University Press, 2005.
[7] S. Osher and L.I. Rudin, Feature-oriented image enhancement using shock filters,
SIAM J. Numer. Anal. 27 (2000), 209–223.
[8] S. Osher and J. Sethian, Fronts propagating with curvature dependent speed: al-
gprithms based on the Hamilton-Jacobi formulation, J. Comput. Physics. 79 (1988),
12–49.
[9] D. Peng, B. Merriman, S. Osher, H. Zhao, and M. Kang, A PDE-based fast local level
set method, J. Comput. Physics. 155 (1999), 420–438.
[10] J.A. Sethian, A fast marching level set method for monotonically advancing fronts,
In Proceedings of the National Academy of Sciences. 93 (1996), 1592–1694.
[11] J.A. Sethian, Level Set Methods and Fast Marching Methods: Evolving Interfaces in
Computational Geometry, Fluid Mechanics, Computer Vision, and Material Sciences,
Cambridge Monogarphs on Applied and Computational Mathematics. Cambridge
Univeristy Press, 1999.
[12] J.W. Thomas, Numerical Partial Differential Equations: Finite Difference Methods,
Springer-Verlag, 1995.
[13] J.N. Tsitsiklis, Efficient algorithms for globally optimal trajectories, IEEE Tran. Auto.
Control. 40 (1995), 1528–1538.