Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Kluwer - Handbook of Biomedical Image Analysis Vol

.1.pdf
Скачиваний:
106
Добавлен:
10.08.2013
Размер:
10.58 Mб
Скачать

Shape From Shading Models

265

integrals of the form

 

E = F(x, y, Z, p, q)dx dy.

E has an extremum only if the Euler differential equation

 

Fz

 

Fp

 

Fq = 0

∂ x

∂ y

is satisfied. If the solution is subject to the constraints g j (x, y, Z) = 0, j = 1, . . . , k,

then we have

k

G = F + λ j g j (x, y, Z).

j=1

Now the Euler equation is

 

 

 

 

 

 

 

 

 

 

k

∂g j

 

 

Fz

∂ x

Fp

∂ y

Fq +

λ j

∂ Z

= 0.

(5.13)

 

 

 

 

 

j=1

 

 

 

The λ j s are called Lagrange multipliers. An example is provided in Section

5.3.2.1.

5.2.3.2 The Constraint Functions Used in SFS Models

When iterative algorithms are used for solving the SFS problem, constraints will be proposed to secure a weak solution. The following constraints are examples:

(1) total squared brightness error [27]:

G0 = (I(x, y) − R( p, q))2dx dy. (5.14)

(2) weak smoothness: After the tangent planes are available, the surface Z

is reconstructed by minimizing the following functional:

G1 = ( px2 + p2y + qx2 + qy2)dx dy. (5.15)

(3)integrability: Since p and q are considered independent variables, ( p, q) may not correspond to the orientation of the underlying surface Z, that is, the surface Z cannot be derived by integrating Zx = p, Zy = q. An

266

 

Shen and Yang

 

integrability constraint is then posed as

 

 

G2 = ( py qx)2dx dy,

(5.16)

 

or

 

 

G3 = (Zx p)2 + (Zy q)2dx dy.

(5.17)

(4)

depth [58]:

 

 

G4 = (Z(x, y) − d(x, y))2dx dy.

(5.18)

(5)

minimal curvature:

 

 

G5 = (Zxx2 + 2Zxy2 + Z2yy)dx dy.

(5.19)

(6)strong smoothness [31]: Introduced in [31], this constraint is used to enforce a stronger integrability and smoothness:

G6 = (Zxx p)2 + (Zyy q)2 dx dy. (5.20)

A combination of the first three of the above constrains (5.14), (5.15), and (5.16), that is,

3

Eng( p, q) =

λkGk,

(5.21)

 

k=1

 

is commonly used to control the stability of iteration algorithms. Here λk, k = 1, 2, 3, are the Lagrange multipliers. The last three of the above constraints are introduced to enforce the smoothness and convergence (of the depth constraint) of the approximation solution. We will demonstrate some examples in Section 5.3.

An iterative scheme for solving the shape from shading problem has been proposed by Horn et al. [27]. The method consists the following two steps.

Step 1. A preliminary phase recovers information about orientation of the planes tangent to the surface at each point by minimizing a functional containing the image irradiance equation and an integrability constraint:

Eng( p, q) = (E(x, y) − R( p, q))2 + λ( py qx)2 dx dy, (5.22)

Step 2. After the tangent planes are available, the surface Z is reconstructed by minimizing the functional (5.17).

Shape From Shading Models

267

Remark 1. The variational approach introduced in [27] does not necessarily guarantee the existence of a solution of the problem. In fact, [10] has addressed this crucial question and shown that the variational approach does not lead to an exact solution of the SFS problem in general. For the discretization of the Euler differential equation and some numerical methods used to solve it, see Sections 5.2.5 and 5.3.

5.2.4Numerical Methods for Linear and Nonlinear SFS Models

Unfortunately, in practice, even with greatly simplified initial and boundary conditions, the analytic solution for a nonlinear PDE is too difficult to obtain in a closed form. A numerical technique is then employed to find a reasonable approximate solution. In this sense, it is more useful to know of such numerical methods which provide us a technique to be actually used in everyday life.

When dealing with the shape from shading model, it becomes clear that the analytic solutions to the irradiance equation (5.2) or the system of ordinary equations (5.8) are practically impossible.

To obtain a numerical approximation for the solution, the first step is to simplify the irradiance equation. The basic approaches for this purpose include:

direct method: discretizing the irradiance equation directly using Taylor series or difference formula.

integral transform: using linear transforms, such as Fourier transform and wavelet transform [13, 15].

projection method: approximating the solution by a finite set of basis functions.

The second step is to choose a criterion to discretize the simplified irradiance equation to get an algebraic equation. Then a numerical method is chosen to solve the algebraic equation. Some of these steps can be done simultaneously.

5.2.4.1 Finite Difference Method

The FDM consists of two steps: (1) replacing the (partial) derivatives by some numerical differentiation formulas to get a difference equation, that is,

268

Shen and Yang

derivatives are discretized by using “difference” and (2) solving the derived difference equation—an algebraic equation—by using either an iterative or a direct method.

To begin with, we first partition the domain by a mesh grid. For example, we use a uniform mesh grid with grid lines:

xj = x0 + jh,

j = 0, 1, . . . , J,

yl = y0 + lk,

l = 0, 1, . . . , L,

where h = xi+1 xi and k = yi+1 yi are the mesh sizes in the x and ydirections, respectively. For simplicity, we write fj,l = f (xj , yl ), the function values on the nodes of the mesh.

Using Taylor expansion and intermediate value theorem, we can derive the following numerical differentiation formulas:

forward difference formula:

 

 

 

 

 

 

 

1

 

(ui+1, j ui, j ),

 

ux(x, y) ≈

 

 

 

 

 

 

 

h

(5.23)

 

 

 

 

 

 

 

1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(ui, j+1 ui, j );

 

uy(x, y) ≈

 

 

 

 

 

 

k

 

backward difference formula:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1

(ui, j

ui−1, j ),

 

ux(x, y) ≈

 

 

 

 

 

h

(5.24)

 

 

 

 

 

 

 

1

 

 

 

 

 

 

 

 

 

 

 

 

 

(ui, j

ui, j+1);

 

uy(x, y) ≈

 

 

 

 

k

 

centered difference formula:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ux(x, y) ≈

1

 

(ui+1, j ui−1, j ),

 

 

 

 

 

2h

(5.25)

 

 

 

 

 

 

 

1

 

 

 

 

 

 

 

 

uy(x, y) ≈

(ui, j+1

ui, j−1).

 

 

 

2k

 

Similarly, the three second-order partial derivatives are given by

 

1

 

 

(ui+1, j 2ui, j

+ ui−1, j ),

 

uxx(x, y) ≈

 

 

 

 

hk

 

1

 

(ui, j+1 2ui, j

+ ui, j−1),

(5.26)

uyy(x, y) ≈

 

 

hk

1

(ui+1, j+1 2ui, j + ui−1, j−1),

 

uxy(x, y) ≈

 

 

hk

 

Formulas (5.23–5.26) will be used in Section 5.3 to discretize (or linearize) the irradiance equation (5.2).

Shape From Shading Models

269

We now demonstrate the idea of FDM by the following examples.

Example 3. As an example, we consider using FDM to solve the linear shape from shading problem (5.3) on a square domain:

= {(x, y), 0 < x < 1, 0 < y < 1}

with the boundary condition given by (5.4). Using forward difference formula (5.23), we have

 

 

 

 

 

 

 

 

 

1

 

 

 

 

 

 

 

 

 

 

1

(Zi, j+1 Zi, j ).

 

(5.27)

 

 

 

 

 

 

 

p

 

(Zi+1, j Zi, j ) and q

 

 

 

 

 

 

 

 

h

k

 

We rewrite Eq. (5.3) as

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

where =

 

 

 

 

 

 

 

 

I(x, y) = p0 p + q0q,

 

 

 

(5.28)

 

 

 

ρ . Substituting (5.27) and (5.28), we have

1 + p02 + q02

 

 

 

 

 

 

 

 

 

 

 

 

 

p0

 

 

 

 

 

 

q0

(Zi, j+1 Zi, j ).

 

 

 

 

 

 

 

 

 

 

Ii, j =

 

(Zi+1, j Zi, j ) +

 

 

 

 

 

 

 

 

 

 

 

 

h

k

 

 

Solving for Zi, j+1, we have

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Zi, j+1 = −α Zi+1, j + (α + 1)Zi, j + β Ii, j ,

 

 

 

 

 

 

p0 k

k

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

where α =

 

, β

= q0 , i = 0, . . . , n − 2, Zi,0

= g1(xi) and Zn−1, j

= g2(yj ), j =

q0 h

0, . . . , n − 2. Written in matrix format, we have

 

 

 

 

 

 

Z0, j+1

 

 

α

 

 

1 −α

 

 

0 . . .

 

 

 

0

 

 

Z0, j

 

 

 

+

 

 

 

 

 

 

 

 

 

+

 

 

 

 

 

 

 

 

 

 

 

Z1, j

1

 

 

+

 

 

 

α

1 α . . .

 

 

 

0

 

Z1, j

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

− +

 

 

 

 

 

 

 

. . .

 

 

. . . . . .

 

 

 

. . .

 

 

 

. . . .

 

 

 

=

. . .

 

 

 

 

 

 

 

 

. . . .

 

 

Zn 2, j 1

0

I1, j

0

 

 

 

. . . . . .

 

α

 

1 Zn 2, j

 

 

 

 

 

 

 

 

 

 

 

0

 

 

 

+

 

 

 

(5.29)

 

 

 

 

 

I0, j

 

 

 

 

0

 

 

 

 

 

 

 

 

 

 

 

 

 

+ β

. . . .

 

 

+ . . . .

 

, j = 0, 1, . . . , n − 2.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

In 2, j

 

α Zn 1, j

 

 

 

 

 

 

 

Figure 5.1 shows the discretization we are using.

The finite difference scheme (5.29) is called the explicit method since it is given by an iterative formula. If instead, the central (5.25) and forward difference formulas (5.23) are used to approximate the partial derivatives, an implicit finite difference scheme can be derived. The approximate solution is then derived iteratively by using the iteration formula (5.29). Numerical

270

Shen and Yang

Figure 5.1: The grid mesh for the discretization in Example 3.

methods used to solve these matrix equations, for example, the Jacobi method, can be found in the standard numerical analysis textbooks [24].

For a nonlinear shape from shading model (5.5), we have to linearize the reflectance map by using Taylor expansion to get a linear equation and then apply the FDM in a similar way as in the above example. To linearize the equation, we only need to replace the nonlinear part in Eq. (5.2) by its linear approximation. We first rewrite the equation to separate the linear and nonlinear parts:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I(x, y)

1 + p02 + q02 1 + p2 + q2 = ρ(1 + p0 p + q0q).

 

 

 

 

 

 

(5.30)

Denoting the nonlinear part by

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

F( p, q) :=

 

 

 

 

 

,

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1 + p2 + q2

 

 

 

 

 

 

 

 

 

 

the Taylor expansion of F( p, q) at (

 

 

 

 

,

 

 

 

) is

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

p

q

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

F( p, q) = F(

 

,

 

 

) + ( p

 

)Fp(

 

 

 

,

 

 

) + (q

 

)Fq (

 

,

 

)

 

 

 

 

 

 

 

 

 

 

 

 

p

q

p

p

q

q

p

q

 

 

 

 

 

 

 

 

 

 

+ O (|( p

 

 

)2 + (q

 

 

)2|)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(5.31)

 

p

q

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

≈ 1 +

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2 +

 

 

2 + ( p

 

 

 

 

)

 

 

 

 

 

 

 

 

 

 

p

 

 

 

 

 

 

+ (q

 

)

 

 

 

q

 

 

 

,

p

q

p

 

 

 

 

 

 

 

 

 

 

 

 

 

q

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1

+

p02

+

q02

1

+

 

p02

+

q02

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

where the error term O (|( p p)2 + (q q)2|) depends on the value of ( p, q)

and the smoothness of the solution function Z. If we assume that Z C2( ), then this error term can be ignored locally. Now we substitute (5.30) into (5.31) to have the linearized irradiance equation:

P(x, y) p + Q(x, y)q = !I(x, y),

(5.32)

Shape From Shading Models

271

where

P(x, y) = − pI(x, y) + ρp0,

Q(x, y) = −q I(x, y) + ρq0,

!

1 + p02 + q02 1 + p2 + q2 − ( p2 + q2) − ρ .

I(x, y) =

Note that (5.32) is a first-order partial differential equation with nonconstant coefficients P and Q and, therefore, the FDM can be used to solve it in the same way as in Example 2.

5.2.4.2 Remarks

Remark 2. About convergence of finite difference method. Every numerical method provides a formalism of generating discrete algorithms for approximating the solution of a PDE. Such a task could be done automatically by a computer if there were no mathematical skills that require human involvement. Consequently, it is necessary to understand the mathematics in this black box which you put in your PDE for processing. This will involve discussion on convergence, stability, and error analysis. However, these topics are beyond the scope of this introductory chapter. We hope the loose ends left here will stimulate your curiosity and further motivate your deep interest in this subject. For the finite difference method used to solve the SFS model, some results related to the issue of convergence can be found in Ulich [64]. For the linear problem, Ulich proved convergence for three methods: forward difference method, backward difference method, and central and forward difference method for certain light directions. For the central and forward finite difference method applied to the linear PDE derived from linearization of a nonlinear shape from shading problem, she was able to prove convergence for all light directions. For the case of application of FDM to the linear shape from shading models, Wei et al. [65] discussed the convergence properties for four explicit, two implicit, and four semi-implicit finite difference algorithms. They also give comparisons of accuracy, solvability, stability, and convergence of these schemes.

Remark 3. About Multiscale methods. Simple iterative methods (such as the Jacobi method) tend to damp out high-frequency components of the error faster than any other method. Multiscale methods are introduced to

272

Shen and Yang

improve the convergence and accuracy of the numerical solutions derived in the “single scale” methods. The multigrid method appears to be one of the most successful multiscale methods for solving the SFS problems. The multigrid method associated with vision problems was studied in the early 1960s by Fedorenko and Bakhvalov [3] and later in the work of many others, for example, [1, 56, 57]. For readers without previous experiences in the multigrid method, excellent tutorials can be found in the books [8] and [44, 62]. A classic book on multigrid method is [23]. Some other novel multiscale methods are developed recently, for example, the panel-clustering method, waveletbased matrix compression, and the hierarchical matrix decomposition technique.

5.3Numerical Algorithms and Their Implementations

It is understood that the problem of shape from shading is fundamentally a very difficult mathematical problem. Nevertheless, some methods were developed while attempting to solve the problem numerically for some particular cases. Most of the methods work for a particular type of images.

SFS techniques can be roughly divided into four groups:

(1)Minimization approach. The method is to reconstruct the shape of the object by minimizing the well-designed energy function over the entire image. The idea is similar to that in deformable models used in image segmentation which segment the object by minimizing certain predefined energy functions. The constraint functions can be the brightness constraint, the gradient constraint, the smooth constraint, etc. (See Section 5.2.3.2).

(2)Propagation approach. The method starts from some initial curve, which is defined as special points such as the brightest or the darkest points in the image, and propagates the shape information across the entire image. (See 5.2.2).

(3)Local approach. The method reconstructs the shape by assuming local surface type. The surface is derived by matching derivatives of measured intensity to those assumed spherical surface.

Shape From Shading Models

273

(4)Linear approach. The method linearizes the reflectance map in tilts or depth. The linear model can be solved and the shape of the object can be calculated. The basic assumption behind this idea is that the lower order components of the reflectance maps dominate the reflectance maps.

In the rest of this section, we will discuss in detail two widely used methods: the linear approach and the minimization approach.

5.3.1 Linear Approaches

In this approach, the basic idea is to linearize the reflectance map and solve the depth information of the shape from the equations. Different linear functions can be formulated in terms of surface gradient or the height of the surface. In the following contexts we will introduce two approaches which are based on linear equations in terms of gradients and the heights of the surface. Both start with the use of first-order finite difference to discretize the reflectance equation. However, they are different after the initial discretization. Pentland’s algorithm uses the Fourier transform and inverse Fourier transform to obtain the depth map, while Tsai–Shah’s algorithm uses the Newton method to derive the depth map. We will explain these two linear approaches in the following sections.

5.3.1.1 Pentland’s Linear Approach

Pentland [6,46,47] introduced a method which takes directly linearization of the reflectance map in the surface gradient ( p, q). It greatly simplifies the shape from shading problem with scarifying part of the accuracy of the reconstruction result. We start with the expansion of the right-hand side of the irradiance equation (5.2) at p = p0, q = q0 using Taylor’s expansion. We have

 

∂ R

∂ R

 

R( p, q) = R( p0, q0) + ( p p0)

 

( p0, q0) + (q q0)

 

( p0, q0).

(5.33)

∂ p

∂q

For Lambertian reflectance, Eq. (5.33) at p0 = 0, q0 = 0 can be reduced to

∂ R

 

∂ R

 

I(x, y) = R(0, 0) + p

 

(0, 0)

+ q

 

(0, 0).

(5.34)

∂ p ∂q

274

Shen and Yang

Denoting by τ the tilt of the illuminant and by γ the slant of the illuminant, the above equation can be rewritten as

I(x, y) = cos γ + p cos τ sin γ + q sin τ cos γ .

(5.35)

Using forward difference formula (5.23), we have

 

 

 

p =

 

 

 

Z(x, y) = Z(x + 1, y) − Z(x, y),

∂ x

 

 

(5.36)

q =

 

Z(x, y) = Z(x, y + 1)

Z(x, y).

∂ y

By taking Fourier transform on the two sides of Eq. (5.36), we can get the following results:

 

 

F

 

p =

 

 

Z(x, y) − FZ (w1, w2)(−iw1),

 

∂ x

 

 

 

F

 

q =

 

 

Z(x, y) − FZ (w1, w2)(−iw2).

(5.37)

 

∂ x

Substituting Eq. (5.37) into Eq. (5.35) and taking Fourier transform on both sides, we obtain

FI (w1, w2) = FZ (w1, w2)(−iw1) cos τ sin σ + FZ (w1, w2)(−iw2) sin τ sin σ,

(5.38) where FI (w1, w2) and FZ (w1, w2) are the Fourier transform of the input image

I(x, y) and depth map Z(x, y), respectively.

After rearranging Eq. (5.38), we obtain

FZ (w1

, w2)

=

 

 

FI (w1, w2)

.

(5.39)

 

 

 

2π ( w12 + w22) sin γ (w1 cos τ + w2 sin τ )

 

 

 

 

By taking the inverse Fourier transform, we can obtain the depth map

 

 

 

Z(x, y) = F−1(FZ (w1, w2)).

 

(5.40)

It is obvious that this approach does not need iterative computation and can provide an approximate solution quickly. However, like all the other linear approaches, this method makes an assumption that the reflectance map is locally linear. Comparing Eq. (5.35) with the normal reflectance equation:

R( p, q)

=

cos γ + p cos τ sin γ + q sin τ cos γ .

(5.41)

 

 

 

 

 

 

 

 

 

1 + p2 + q2