fast algorithm for integrating inconsistent gradient fields

10

Click here to load reader

Upload: ramon

Post on 02-Oct-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fast algorithm for integrating inconsistent gradient fields

Fast algorithm forintegrating inconsistent gradient fields

Mariano Rivera, Jose L. Marroquin, Manuel Servin, and Ramon Rodriguez-Vera

A discrete Fourier transform ~DFT! based algorithm for solving a quadratic cost functional is proposed;this regularized functional allows one to obtain a consistent gradient field from an inconsistent one. Thecalculated consistent gradient may then be integrated by use of simple methods. The technique ispresented in the context of the phase-unwrapping problem; however, it may be applied to other problems,such as shapes from shading ~a robot-vision technique! when inconsistent gradient fields with irregulardomains are obtained. The regularized functional introduced here has advantages over existing tech-niques; in particular, it is able to manage complex irregular domains and to interpolate over regions withinvalid data without any smoothness assumptions over the rest of the lattice, so that the estimation erroris reduced. Furthermore, there are no free parameters to adjust. The DFT is used to compute apreconditioner because there is highly efficient hardware to perform the calculations and also because itmay be computed by optical means. © 1997 Optical Society of America

Key words: Metrology, interferometry, inverse problems, phase unwrapping.

1. Introduction

The phase-unwrapping problem consists of the recon-struction of a real-valued discrete phase field f@x, y#from noisy wrapped observations g@x, y#, i.e., a noisyprincipal-valued phase field ~we use square bracketsherein to denote the discrete nature of the fields!.The relation between the unwrapped and the ob-served wrapped phase is

g@x, y# 5 f@x, y# 1 n@x, y# 1 2pk@x, y#, (1)

where @x, y# [ S is the domain where the observa-tions are available, n@x, y# is a noise term, and k@x, y#is an unknown integer-valued field. The observa-tions may consist of the wrapped phase field g@x, y# orits unwrapped derivatives gx@x, y# and gy@x, y#. Thederivatives can be obtained either from a direct-measurement method,1 a difference method,2 or adirect-computation method.3 The desired solutionmay be either the phase field f@x, y# or the gradientfields fx@x, y# and fy@x, y#.

Fried4 and Hudgin5 proposed a least-squares ~LS!

M. Rivera, M. Servin, and R. Rodriguez-Vera are with the Centrode Investigaciones en Optica, Apdo. Postal 1-948, 37000 Leon,Mexico. J. L. Marroquin is with the Centro de Investigacion enMatematicas, Apdo. Postal 402, 36000 Guanajuato, Mexico.

Received 13 December 1996; revised manuscript received 18April 1997.

0003-6935y97y328381-10$10.00y0© 1997 Optical Society of America

solution to the two-dimensional phase-unwrappingproblem that may solve two-dimensional path incon-sistencies. This LS solution consists of finding afield f@x, y# such that its gradient $fx@x, y#, fy@x, y#%minimizes the discrete energy functional:

U~f@x, y#! 5 (@ x,y#

$~gx@x, y# 2 DxBf@x, y#!2

1 ~gy@x, y# 2 DyBf@x, y#!2%, (2)

where x and y are integers,

$gx@x, y#, gy@x, y#% 5 $W~DxBg@x, y#!, W~Dy

Bg@x, y#!% (3)

~see Ref. 2!, W is the wrapping operator

W~f@x, y#! 5 f@x, y# 1 2pk@x, y#, (4)

and k@x, y# is chosen in such a way such that W~f@x,y#! [ @2p, p!. The first backward differences DB aredefined by

fx@x, y# 8 DxBf @x, y# 5 f @x, y# 2 f @x 2 1, y#, (5a)

fy@x, y# 8 DyBf @x, y# 5 f @x, y# 2 f @x, y 2 1#. (5b)

10 November 1997 y Vol. 36, No. 32 y APPLIED OPTICS 8381

Page 2: Fast algorithm for integrating inconsistent gradient fields

The Fried–Hudgin LS equation ~2! is obtained bysubstitution of the right-hand side of expressions ~5a!and ~5b! into Eq. ~2!:

U1~f@x, y#! 5 (@ x,y#

~gx@x, y# 2 f@x, y# 1 f@x 2 1, y#!2

1 (@ x,y#

~gy@x, y# 2 f@x, y# 1 f@x, y 2 1#!2,

(6)

where f@x, y# represents the desired phase field and@x, y# [ L, the whole lattice. Assuming that sam-pling of the fringe pattern is constrained by theNyquist theorem, we must have at least two obser-vations for each fringe in the original fringe-patternimage. Therefore the phase difference between twoneighboring samples cannot be more than p. Math-ematically this means that

uDlf @x, y#u # p, l [ $x, y%. (7)

It has been shown6 that this LS estimation is equiv-alent to the solution of the Poisson discrete equation:

¹2f@x, y# 5 r@x, y#, (8)

which one obtains simply by setting the derivatives ofU1~f@x, y#! with respect to the variables f@x, y# equalto 0, where

r@x, y# 8 gx@x 1 1, y# 2 gx@x, y#

1 gy@x, y 1 1# 2 gy@x, y# (9)

for all @x, y# such that @x 1 1, y#, @x, y#, @x 2 1, y#, @x,y 1 1#, @x, y 2 1# [ L, and ¹2 is the discrete Laplacianoperator. To solve expression ~9! one must have ob-servations of g@x, y# for every site in L ~see Takajo andTakahashi6!.

To extend the above approach to the case in whichthe subset of sites where we want to get a solution~subset R! does not coincide with the subset of siteswhere the observations are available ~subset S!, Mar-roquin and Rivera7 proposed the inclusion of a regu-larization term in Eq. ~2!. This term establishesthat, instead of expression ~9!, the following equationis solved:

¹2f@x, y#S@x, y# 2 ¹4f@x, y# 5 r@x, y#S@x, y#, (10)

where

S@x,y# 5 H1 if @x 1 1, y#,@x, y#,@x 2 1, y#,@x, y 1 1#,@x, y 2 1# [ S,

0 otherwise

with @x, y# [ R, R , L, S , L, and l a positiveparameter.

The term ¹4f@x, y# is the Laplacian of the Lapla-cian of f@x, y# and penalizes the roughness of theapproximation; it represents the prior knowledge ofthe behavior of the solution, which is introduced tosolve the corresponding ill-posed problem. Thewavelength l parameter controls the smoothness ofthe solution, and it also represents a compromise

8382 APPLIED OPTICS y Vol. 36, No. 32 y 10 November 1997

between the fidelity of the observations and the priorsmoothness assumption. Where the observationsare present, the regularization term smoothes out thedata, and where they are not present it smoothlyinterpolates the data, preserving continuity at theboundaries.

Marroquin and Rivera7 showed that the regular-ization term has the effect of reducing noise. How-ever, as the noise is smoothed out, the slopes of theoriginal phase are also reduced, thus producing aflattening effect in the solution. This effect is re-duced by the multiplication of the whole solution by ascaling factor. However, the distortion introducedby the regularization term is not completely correctedby this simple scaling factor because the distortiondepends on the magnitudes of the slopes. In otherwords, sites with different concavities need to be mul-tiplied by different factors. The root of the problemis the assumption of the smoothness of the solutionimplemented by the regularization term, which isnevertheless necessary for obtaining a smooth inter-polation.

In this paper we propose a quadratic cost func-tional inspired by the one originally proposed byHorn,8 which generates a coupled set of elliptical dif-ferential equations different from the Poisson equa-tion. The solution of these differential equationsyields an estimate of a consistent phase-gradient fieldfrom which the phase field may be obtained by path-independent integration. We indicate how to add aregularization term for interpolating the regions withmissing data. This term is restricted to regions withinvalid data and has no effect over the rest of thelattice.

An important advantage of this method is that onemay derive a fast method to find the consistent gra-dient field. This fast algorithm can unwrap phasefields in irregular domains, and, unlike the algorithmdeveloped by Marroquin and Rivera,7 the algorithmpresented in this paper smoothly interpolates overregions with missing data without oversmoothing thecomputed phase. This is a desirable characteristicin an unwrapping algorithm, particularly if the orig-inal phase is piecewise continuous. Since the pro-posed algorithm uses the discrete Fourier transform~DFT!, to increase the speed of the technique or toimplement the algorithm in an optical–digital setupone can calculate the DFT by using specialized hard-ware for digital image processing.

2. Proposed Cost Functional

In this section we introduce a regularized cost func-tional that allows one to recover a phase field withoutany prior smoothness assumptions over the regionswith valid data. The objective is to distinguish a con-sistent gradient field ¹f@x, y# 5 $fx@x, y#, fy@x, y#% fromthe observed gradient field ¹g@x, y# 5 $gx@x, y#, gy

Page 3: Fast algorithm for integrating inconsistent gradient fields

@x, y#%. The consistent gradient is obtained by theminimization of

U0~fx, fy! 5 (@ x,y#[S1

~gx@x, y# 2 fx@x, y#!2

1 (@ x,y#[S2

~gy@x, y# 2 fy@x, y#!2, (11)

subject to

Cc~fx, fy! 8 ~DyBfx@x, y# 2 Dx

Bfy@x, y#! 5 0,

@x, y# [ L, (12)

where

S1 5 $@x, y# such that an observation gx@x, y# exists%,

S2 5 $@x, y# such that an observation gy@x, y# exists%.

(13)

The functional U0~fx, fx! represents the compatibil-ity of the solution with the observations. Cc~fx, fy!is the consistency constraint in the estimated gradi-ent field necessary for path-independent integrabil-ity. This consistency constraint was previously usedby Horn9 for the reconstruction of depth maps frominconsistent gradient fields, with these fields ob-tained as the result of the application of machine-vision methods.

One way of transforming the constrained problem@expression ~12!# into an unconstrained one is to addto the objective function a penalty10,11 for violatingthe constraint. The resulting energy functional is

Uc~fx, fy! 5 U0~fx, fy! 1 l1 (@ x,y#[L

@Cc~fx, fy!#2,

where the parameter l1 provides a means for weight-ing the relative contributions of the penalty terms.The consistency constraint allows one to reduce thenoise produced by the fact that gx and gy may beobserved independently. Note that this equationwill not have an unique minimum for those sitesoutside S1 ø S2 because the linear system obtainedby the differentiation of Uc does not have full rank.To get a unique solution we need to add a regulariz-ing term that constrains fx and fy for regions whereno valid data are available. The complete con-strained objective function is

U2~fx, fx! 5 (@ x,y#[S1

~gx@x, y# 2 fx@x, y#!2

1 (@ x,y#[S2

~gy@x, y# 2 fy@x, y#!2

1 l1 (@ x,y#[L

~DyBfx@x, y# 2 Dx

Bfy@x, y#!2

1 n (@ x,y#[y S1

~fx@x, y#!2

1 n (@ x,y#[y S2

~fy@x, y#!2. (14)

Note that the parameters control only the consistencyand the interpolation process of the gradient field, sothat l1 will be a very large constant ~i.e., l1 5 10,000!and n will be a small number ~we take a value of n 5l1

21!. Furthermore, their values are independent ofthe particular image characteristics ~dimension,bandwidth, etc.!.

To apply functional equation ~14! to phase unwrap-ping it is necessary that the observed gradient satisfyexpression ~7!. This gradient can be obtained froman observed principal-valued phase field g@x, y# withthe use of the wrapped operator proposed by Itoh2

@see Eq. ~3!#. If one is using a Fourier-based methodfor computing the phase12 from the fringe pattern,the wrapped gradient can be computed directly byuse of the Fourier derivative theorem.3 In eithercase, however, the wrapped gradient will in generalbe inconsistent. That is, the integrability constraintwould be violated in some places: Cc~gx, gy! Þ 0 @seeexpression ~12!#. The inconsistencies in thewrapped gradient can be the result of ~a! an originalphase f@x, y# with discontinuities, ~b! noise n@x, y#introduced into the observations, or ~c! a combinationof both.

3. Fast Minimization Algorithm

To calculate the gradient that minimizes the energy-functional equation ~14!, we must find the solution tothe system:

]U2~fx, fy!

]fx5 0,

]U2~fx, fy!

]fy5 0. (15)

This system is defined by

fx@x, y#$Sx@x, y#~1 2 n! 1 n% 2 l1DyF~Dy

Bfx@x, y#

2 DxBfy@x, y#! 5 gx@x, y#Sx@x, y#,

fy@x, y#$Sy@x, y#~1 2 n! 1 n% 1 l1DxF~Dy

Bfx@x, y#

2 DxBfy@x, y#! 5 gy@x, y#Sy@x, y#, (16)

where

Sx@x, y# 5 $1 if @x, y# [ S1, 0 otherwise%,

Sy@x, y# 5 $1 if @x, y# [ S2, 0 otherwise%, (17)

and DxF and Dy

F are the first forward-difference op-erators, which are used to center the second differ-ences.

We study the discrete frequency response of thesystem given by Eqs. ~16!, assuming that the originalphase is periodic and we have a whole domain prob-lem, i.e., S@x, y# 5 1, for all @x, y#. First, it is neces-sary to define the first difference operators as circular~see Appendix A!. For example, the circular opera-tor Dx

B is defined by

DxBf @x, y# 5 Hf @x, y# 2 f @x 2 1, y#

f @0, y# 2 f @M 2 1, y#1 # x # M 2 1x 5 0 .

(18)

10 November 1997 y Vol. 36, No. 32 y APPLIED OPTICS 8383

Page 4: Fast algorithm for integrating inconsistent gradient fields

Then Eqs. ~16! are transformed by means of the DFTto

Gx@u, v# 5 H1 1 l14 sin2SpvN DJ Fx@u, v#

1 l1HexpSj2pvN D 2 1J

3 H1 2 expS2j2puM DJ Fy@u, v#,

Gy@u, v# 5 l1HexpSj2puM D 2 1JH1 2 expS2j2pv

N DJ3 Fx@u, v# 1 H1 1 l14 sin2Spu

M DJFy@u, v#,

(19)

where Gx@u, v# 8 DFT$gx@x, y#%, Gy@u, v# 8 DFT$gy@x,y#%, Fx@u, v# 8 DFT$fx@x, y#%, and Fy@u, v# 8DFT$fy@x, y#%, for u 5 0, . . . , M 2 1 and v 5 0, . . . ,N 2 1. Defining the inconsistency error as

e~gx@x, y#, gy@x, y#! 8 DyBgx@x, y# 2 Dx

Bgy@x, y#, (20)

we solve system equations ~19! for Fx@u, v# and Fy@u,v# and, applying the inverse DFT ~IDFT!, we obtain

fx@x, y# 5 gx@x, y# 1 DyFIDFT{IH@u, v#

3 DFT$e~gx@x, y#, gy@x, y#!%},

fy@x, y# 5 gy@x, y# 2 DxFIDFT{IH@u, v#

3 DFT$e~gx@x, y#, gy@x, y#!%}, (21)

where IH@u, v# is given by

IH@u, v# 5l1

1 1 l1F4 sin2SpuM D 1 4 sin2Spv

N DG . (22)

Note that, if the observed gradient is consistent$e~gx@x, y#, gy@x, y#! 5 0, for all @x, y#%, then Eqs. ~21!become

fx@x, y# 5 gx@x, y#, fy@x, y# 5 gy@x, y#.

Equations ~21! represent the transfer function of theminimization of the functional equation ~14! underthe above-mentioned assumptions; as one can see, forinconsistent gradient fields this method acts an all-pass filter.

If the assumptions with respect to observations inthe whole lattice and periodic boundary conditionsare not satisfied, the method given by Eqs. ~20! maybe used to compute an approximated solution andthen an iterative algorithm @such as the gradient-descent or conjugate-gradient ~CG! algorithms# canbe used to refine its solution. Note that, even withperiodic boundary conditions, the differences at theboundary of the wrapped field are generally differentfrom the differences of the unwrapped field, i.e.,

DxB{W$ f @0, x#%} Þ Dx

B{f @0, x#}.

8384 APPLIED OPTICS y Vol. 36, No. 32 y 10 November 1997

Thus the circular differences at the boundary areinvalid data, and they should not be used with aniterative algorithm to find the refined solution.Therefore, instead of Eqs. ~17!, the following defini-tions of Sx@x, y# and Sy@x, y# should be used:

Sx@x, y# 5 H1 if @x, y# [ S1, x Þ 00 otherwise ,

Sy@x, y# 5 H1 if @x, y# [ S2, y Þ 00 otherwise .

A more efficient choice for computing the refined so-lution is the preconditioned conjugate-gradient~PCG! algorithm. This is explained in Subsection3.A.

A. Preconditioned Conjugate-Gradient Algorithm

The PCG algorithm13 is used to minimize quadraticcost functionals. Here we introduce the consider-ations necessary to use the DFT in the precondition-ing stage. The PCG algorithm may be understoodas an optimization method that uses conjugate direc-tions in a successive quasi-Newtonian approach.This is explained below.

Consider the minimization problem

min f ~x! 512 xTAx 2 xTb, (23)

where A is a symmetric positive definite matrix ~i.e.,xTAx . 0, for all x Þ 0!. The minimization of Eq.~23! is obtained if its gradient f9~x! 5 Ax 2 b is setequal to zero, that is,

Ax 2 b 5 0. (24)

We use r to denote the gradient vector @i.e., r 8 f9~x!#.We can see that any method that solves Eq. ~24! willminimize Eq. ~23!, and vice versa. The iterative-solution method for minimizing Eq. ~23! is given by

xi11 5 xi 1 aisi, (25)

where i denotes the iteration number, si is the searchdirection, and ai is the step size. The optimum stepsize is obtained when

]f ~xi 1 aisi!

]ai5 0.

If we choose si 5 2ri and the optimal value of ai, thenthe algorithm defined by Eq. ~24! becomes thesteepest-descent method. This method is not effi-cient because the number of iterations needed to findthe solution is O~N2!, where N is the dimension of thex vector.

There are faster methods, called quasi-Newtonian,which are based on the Newton–Raphson algorithm;they search along directions given by si 5 2H21ri,where H21 is an approximation of the inverse of theHessian of f ~x! ~which is f0~x! 5 A!. This algorithmwill be as good as the approximation H21 for repre-senting the inverse of A. Quasi-Newtonian methodsgive the best results if the search is performed along

Page 5: Fast algorithm for integrating inconsistent gradient fields

conjugate directions. Two search directions si and sjare said to be A conjugate if and only if si

TAsj 5 0.The number of conjugate directions of the matrix A isequal to its rank ~number of linearly independentrows!. The use of the optimum descent step alongeach conjugate direction ensures that the functionequation ~23! will be minimized in at most a numberof iterations equal to the dimension of x.

The CG algorithm is one of the algorithms thatuses the advantages of conjugate directions to in-crease its convergence rate. In the CG algorithmthe new conjugate search direction is chosen as alinear combination of the current gradient and thelast conjugate search direction. That is, with the CGalgorithm, si 5 2ri 1 bisi21, where bi is chosen in away such that si

TAsi21 5 0. The PCG algorithmcombines the power of the quasi-Newtonian methodswith conjugated search directions and is usually theone with the fastest convergence rate. In the PCGalgorithm, the new search direction is calculated by si5 2H21ri 1 bisi21, where the matrix H21 is calledthe preconditioner. A good preconditioner can re-duce dramatically the convergence rate of the algo-rithm. This is because the introduction of thepreconditioner modifies the original linear systemequation ~24! to

Ax 2 b 5 0, (26)

where A 8 H21A must be definite positive and b 8H21b. To have fast convergence one should set A 'I.

The complete PCG algorithm is

LET x0 5 0, r0 5 b, b0 5 0, i 5 0, ε 5 tolerance.COMPUTE H21.REPEAT

1. si 5 2H21ri 1 bisi21.2. COMPUTE a such that @]f ~xi 1 asi!#y]a 5 0.3. xi11 5 xi 1 asi.4. ri11 5 Axi11 2 b.5. COMPUTE bi11 such that si11

TAsi 5 0,that is, ~2H21ri11 1 bi11si!

TAsi 5 0.6. i 5 i 1 1.

UNTIL iri11i2 , ε OR i 5 rank~A!.

In Subsection 3.B we show how to use the DFT tocompute the preconditioner H21 for minimizing thefunctional equation ~14!.

B. Preconditioning with the Discrete Fourier Transform

The vector zi 8 H21ri may be computed efficientlywith the use of the DFT. Assume that we want tosolve the following system:

Hzi 5 ri.

If H is a circular matrix ~each of its rows is a circularshift of the previous row!, then the DFT of the zvector is calculated by

Z 51

H0R,

where R and H0 are the DFT’s of r and the first rowof H, respectively. In our case, the matrix A ~hencethe matrix H! will be circular if the circular definitionof the first difference operators @see Eq. ~18!# is usedand the parameter n in Eq. ~14! is different from zero.This, however, will give an incorrect difference valueat the boundary pixels, which should therefore beconsidered as invalid data. It should be remarkedthat the periodic boundary conditions induced by theDFT affect, in this case, only the boundary pixelsbecause the filter that corresponds to the solution ofthe linear system exhibits an all-pass frequency re-sponse, as explained above. This will not be the casefor a whole-lattice smoothing regularization func-tional ~such as that developed by Marroquin andRivera7!, in which case the error produced by theperiodic conditions will propagate to the interior pix-els as well.

Since we can write systems ~16! in a matrix form@as Eq. ~24!# where the unknowns are the vector$fx@x, y#, fy@x, y#%T and the data are the vector $gx@x,y#Sx@x, y#, gy@x, y#Sy@x, y#%T, then preconditioning iscomputed with

zx@x, y# 5 rx@x, y# 1 DyFIDFT{IH@u, v#

3 DFT$e~rx@x, y#, ry@x, y#!%},

zy@x, y# 5 ry@x, y# 2 DxFIDFT{IH@u, v#

3 DFT$e~rx@x, y#, ry@x, y#!%}, (27)

where IH@u, v# is given by Eq. ~22! and e~rx@x, y#, ry@x,y#! is computed with expression ~20!. Note that inthe calculation of Eqs. ~27! only a single DFT and asingle IDFT are needed. The details of the algo-rithm are presented in Appendix A.

4. Numerical Experiment

In this section we illustrate the application of theproposed technique. We compare it with the onlyknown fast algorithm that works with irregular do-mains and can interpolate regions with missing data,that is, the PCG algorithm of Marroquin and Rivera~PCGMR!. The PCG of Ghiglia and Romero9 be-comes unstable when the domain of observations isdifferent from the whole lattice. We use a syntheticwrapped field to make these comparisons because ofthe following reasons:

1. We know the exact real phase field, and weknow the domain of the observations.

2. No error is introduced by any fringe-analysismethod for phase recovery.

3. In the test phase we introduce the character-istics that allow us to compare the real performanceof each technique ~discontinuities!.

In Fig. 1~a! we show the test phase field, where M and

10 November 1997 y Vol. 36, No. 32 y APPLIED OPTICS 8385

Page 6: Fast algorithm for integrating inconsistent gradient fields

Fig. 1. ~a! Sintetic test phase. ~b! Wrapped phase. Sites in white ~c! with valid information and ~d! where the unwrapped phase willbe computed.

N are the dimensions of the image ~in this case M 5N 5 64!; this field is given by

f@x, y# 5 {13 sinH px2~M 2 1!JsinHp~y 2 10!

N 2 1 J1 step@x, y#} p S@x, y#,

step@x, y# 5 Hint~xy10!y30

y , Ny2otherwise.

Figure 1~b! shows the principal values of the wrappedphase computed with

g@x, y# 8 W~f@x, y#! 5 tan21$tan~f@x, y#!%.

Figure 1~c! shows the domain of valid observationsS@x, y#, and Fig. 1~d! shows the region where a solu-tion is computed, R@x, y#.

8386 APPLIED OPTICS y Vol. 36, No. 32 y 10 November 1997

Figure 2 shows the unwrapped phase computedwith the PCG method, which minimizes functionalequation ~14!, that imposes consistency constraints,~PCG–CC!, and the PCGMR algorithm. Figure 2~a!shows the phase field computed with the PCGMRtechnique with l 5 1.0. One can observe the intro-duced distortion because of oversmoothing of the so-lution. Although this distortion is reduced with asmaller value of l, the oversmoothing effect is stillpresent ~see Fig. 3!. In Fig. 2~b! we show the com-puted phase field by using the proposed PCG–CCalgorithm with l1 5 10,000 and n 5 l1

21. Remem-ber that the precise values of l1 and n are not impor-tant @Eq. ~14!# as long as they are large enough ~say,l1 . 1000! and small enough, respectively.

Figures 3~a! and 3~b! show the map error for solu-tions computed by use of the PCGMR algorithm withl 5 1.0 and l 5 0.01, respectively. Figure 3~c! showsthe map error for the solution computed by use of the

Page 7: Fast algorithm for integrating inconsistent gradient fields

PCG–CC algorithm. Note that, although the errorsfor the PCGMR algorithm at the phase discontinui-ties are attenuated by use of a smaller value of l, aresidual error remains near the borders of the image.If we further reduce the value of l to diminish theoversmoothing effect, then the algorithm may becomeunstable and there is no rule for choosing the small-est l that keeps the algorithm stable.

The mean-square errors are 8.45 3 1023 and5.58 3 1024 and the peak errors are 0.1479 and0.01217 for solutions computed with the PCGMR ~l 50.01! and PCG–CC techniques, respectively. As wecan see, the PCG–CC method yields a much betterperformance. The behavior of the mean-square er-ror versus the iteration number for both schemes isshown in Fig. 4.

In Fig. 5 we show the unwrapping of real data.Figure 5~a! shows a 256 3 256 image portraying thewrapped phase field obtained from four phase-stepping images of electronic speckle pattern inter-ferometry ~ESPI!.14 They represent the out-of-planedeformations in an aluminum plate when a heatsource is located at its posterior surface. Figure 5~b!shows the computed unwrapped phase field obtainedwith the PCG–CC algorithm with l1 5 10,000 and n5 l1

21 after 20 iterations. The unwrapping process

Fig. 2. Unwrapped phase fields of the wrapped phase showed inFig. 1~b! after 13 iterations with ~a! the PCGMR with l 5 1.0 and~b! the PCG–CC with l1 5 10,000 ~n 5 l1

21!.

took approximately 1 min on a PC with the IntelPentium processor at 133 MHz.

5. Discussion and Conclusions

We have presented a fast algorithm ~the PCG–CC! forcomputing a consistent gradient field from an incon-sistent one, and we have shown the application of thisalgorithm to phase unwrapping. This algorithm isbased on the variational formulation for integrabilityproblems previously presented by Horn.8 In thecontext of regularization theory, the consistency con-straint can be understood as a regularization term

Fig. 3. Map errors of solutions computed with ~a! PCGMR with l5 1.0, ~b! PCGMR with l 5 0.01, ~c! PCG–CC with l1 5 10,000 (n5 l1

21!.

10 November 1997 y Vol. 36, No. 32 y APPLIED OPTICS 8387

Page 8: Fast algorithm for integrating inconsistent gradient fields

that introduces the prior knowledge that a true gra-dient field must satisfy. Note that the inconsistencyconstraint is binary-valued ~there are no grades ofconsistency!. This fact offers an advantage over thesmoothness constraint ~see Marroquin and Rivera7!,where the regularization parameter is related to the~commonly unknown! noise variance of the observa-tions. The consistency constraint combined with anappropriate regularization term can be used to inter-polate over regions with missing data, and its appli-cation does not distort the solution for regions withvalid observations.

It is also possible to consider as “missing observa-

Fig. 4. Mean-square error ~MSE! versus iteration number for thePCGMR algorithm with l 5 1.0 ~open circles!, l 5 0.1 ~stars!, andl 5 0.01 ~plus signs! and for the PCG–CC with l1 5 10,000 ~dash-es!.

tions” the sites where the observed gradients are in-consistent ~to detect these sites, see Ref. 15!, so thatthe error in the solution is reduced. Furthermore,the algorithm presented can work with irregular do-mains, that is, the region where a solution is calcu-lated may not be the whole lattice.

It is interesting to note that, even without the reg-ularization term @i.e., taking a value of n 5 0 in Eq.~14!#, the proposed PCG–CC algorithm still interpo-lates over regions where no data are available, pro-vided the following initial conditions are used:

gx@x, y# 5 gx@x, y#Sx@x, y#,

gy@x, y# 5 gy@x, y#Sy@x, y#.

The results with and without the regularization termare in this case undistinguishable.

If the regularization term ~controlled by n! is ex-tended to the full lattice, then it will have a scalingeffect in the consistent gradient field obtained, and nosmoothing effect is observed. To add a smoothnessconstraint to the energy functional @Eq. ~14!# pre-sented to control the behavior of the solution ~thismay be desirable in situations when the observationsare noisy!, we can include constraints on the deriva-tives of the gradient. These constraints are imple-mented by the following penalty terms:

l2iP2xfxi2 5 l2 (

@ x,y#[Rx

~DxFDx

Bfx@x, y#!2,

l2iP2yfyi2 5 l2 (

@ x,y#[Ry

~DyFDy

Bfy@x, y#!2,

where

Rx 5 $@x, y# [ R : ] @x 1 1, y#, @x 2 1, y#,

3 @x 2 2, y# [ R%,

Fig. 5. ~a! ESPI phase map. ~b! Unwrapped phase after 20 iterations with the PCG–CC algorithm ~l1 5 10,000!.

8388 APPLIED OPTICS y Vol. 36, No. 32 y 10 November 1997

Page 9: Fast algorithm for integrating inconsistent gradient fields

Ry 5 $@x, y# [ R : ] @x, y 1 1#, @x, y 2 1#,

3 @x, y 2 2# [ R%,

where l2 controls the smoothing process. These con-straints mean that we want smooth changes in thesecond derivatives of the calculated gradient ~or,equivalently, smooth changes in the third derivativesof the estimated phase field!. In this case, the esti-mated phase in the interpolated regions will havethird derivatives equal to zero. It is important toobserve than these smoothing terms are not neces-sary for interpolating regions with missing data.

A fast solution to the phase-unwrapping problem ina rectangular domain with complete data may becomputed by use of the DFT-based algorithm devel-oped by Takajo and Takahashi16 or with the cosine-transform-based algorithm developed by Ghiglia andRomero.9 However, these algorithms are not able tounwrap phase fields with irregular domains or inter-polate regions with missing data. For solving thesecases, we have proposed the PCG–CC algorithm. Ithas the following advantages over existing algo-rithms:

1. PCG of Ghiglia and Romero ~PCGGR!: Theproblem with this formulation may be understoodfrom the perspective of PCG algorithms: The matrixA is not positive definite if there are regions withmissing data. This algorithm is therefore unstablewhen S Þ L, although it may sometimes work if S 'L.

2. PCG of Marroquin and Rivera ~PCGMR!:This method can manage irregular domains and in-terpolate missing data. However, the regulariza-tion term penalizes the roughness in the solution,and as a result the computed phase may be over-smoothed, especially if the original phase is onlypiecewise continuous. On the other hand, if the reg-ularization parameter is too small, the algorithmmay become unstable.

We showed the general requisites for using theDFT in the preconditioning stage of the PCG algo-rithm to minimize a quadratic cost functional. Al-though other transformations ~e.g., the Hartley,wavelet, and cosine transforms! may be used to com-pute the preconditioner, we choose the DFT becausean optical–digital setup may be implemented easilyto increase of speed of the unwrapping process.

Appendix A: Preconditioned Conjugate Gradient forIntegrating an Inconsistent Gradient Field

1. Definitions

Let M and N be the dimensions of a rectangularlattice L, where

0 # x # M 2 1, 0 # y # N 2 1

are the variables in the space domain, and

0 # u # M 2 1, 0 # v # N 2 1

are the variables in the frequency domain.Define the first forward-difference operators as

DxFf @x, y# 5 Hf @x 1 1, y# 2 f @x, y#

f @0, y# 2 f @M 2 1, y#0 # x # M 2 2x 5 M 2 1

in the x direction and

DyFf @x, y# 5 Hf @x, y 1 1# 2 f @x, y#

f @x, 0# 2 f @x, N 2 1#0 # y # N 2 2y 5 N 2 1

in the y direction.Define the first backward-difference operators as

DxBf @x, y# 5 Hf @x, y# 2 f @x 2 1, y#

f @0, y# 2 f @M 2 1, y#1 # x # M 2 1x 5 0

in the x direction and

DyBf @x, y# 5 Hf @x, y# 2 f @x, y 2 1#

f @x, 0# 2 f @x, N 2 1#1 # y # N 2 1y 5 0

in the y direction.Define the wrapping operator as

W$ f % 5 tan21{tan$ f %} : [@2p, p!.

Define the inconsistent measuring function as

inco~ fx@x, y#, fy@x, y#! 5 DyBfx@x, y# 2 Dx

Bfy@x, y#

and the preconditioner in the DFT domain as

IH@u, v# 5l1

1 1 l1H4 sin2SpuM D 1 4 sin2Spv

N DJ .

Let F@u, v# 5 DFT$ f @x, y#% be the DFT of f @x, y# andlet f @x, y# 5 IDFT$F@u, v#% be the IDFT of F@u, v#.

2. Algorithm: PreconditionedConjugate-Gradient–Consistency Constraints

Let l1 be the consistent grade of the solution ~typi-cally 10,000!, where

• n is the regularization parameter ~typicallyl1

21!,• T is the maximum number of iterations,• ε is the maximum desirable error ~of the mag-

nitude of the residual gradient vector!,• gx and gy are the inconsistent gradients @gener-

ally calculated with Eq. ~3!#,• Sx@x, y# 5 1 in the sites where the value of gx is

valid ~equal to 0 otherwise!,• Sy@x, y# 5 1 in the sites where the value of gy is

valid ~equal to 0 otherwise!,• R@x, y# 5 1 in the sites where we want calculate

a solution ~equal to 0 otherwise!.

For all @x, y# [ L do the following:

1. Set

Sx@0, y# 5 0, Sy@x, 0# 5 0,

rx@x, y# 5 gx@x, y#, ry@x, y# 5 gy@x, y#,

10 November 1997 y Vol. 36, No. 32 y APPLIED OPTICS 8389

Page 10: Fast algorithm for integrating inconsistent gradient fields

fx@x, y# 5 0, fy@x, y# 5 0,

t 5 0.

2. Set

c@x, y# 5 IDFT$IH@u, v#DFT{$inco~rx@x, y#, ry@x, y#!%}.

3. Set

zx@x, y# 5 rx@x, y# 1 DyFc@x, y#,

zy@x, y# 5 ry@x, y# 2 DxFc@x, y#.

4. Set

W 5 ( ~zx@x, y#rx@x, y# 1 zy@x, y#ry@x, y#!.

5. IF ~t 5 0!,set b 5 0,ELSE set b 5 WyWold.

6. Set

px@x, y# 5 zx@x, y# 1 bpx@x, y#,

py@x, y# 5 zy@x, y# 1 bpy@x, y#.

7. IF ~x 5 0!set

ux@x, y# 5 2l1DyFinco~px@x, y#, py@x, y#!,

ELSE set

ux@x, y# 5 px@x, y#$Sx@x, y#~1 2 n! 1 n%

2 l1DyFinco~px@x, y#, py@x, y#!.

8. IF ~y 5 0!,set

uy@x, y# 5 l1DxFinco~px@x, y#, py@x, y#!,

ELSE set

uy@x, y# 5 py@x, y#$Sy@x, y#~1 2 n! 1 n%

1 l1DxFinco~px@x, y#, py@x, y#!.

9. Set

a 5W

( ~px@x, y#ux@x, y# 1 py@x, y#uy@x, y#!.

10. Set

fx@x, y# 5 fx@x, y# 1 apx@x, y#,

fy@x, y# 5 fy@x, y# 1 apy@x, y#,

rx@x, y# 5 rx@x, y# 2 aux@x, y#,

ry@x, y# 5 ry@x, y# 2 auy@x, y#.

11. IF uWu , ε,OR t . T, STOP,ELSE set Wold 5 W, t 5 t 1 1,and go to step 2.

12. Integrate the consistent and unwrapped gra-dient:

8390 APPLIED OPTICS y Vol. 36, No. 32 y 10 November 1997

Set

fx@0, 0# 5 0,

and compute

f@x, y# 5 H(i50

x

fx@i, 0# 1 (j51

y

fy@x, j#JR@x, y#.

The authors were supported in part by grants fromthe Consejo Nacional de Ciencia y Tecnologia, Mex-ico. M. Rivera was also supported in part by grantsfrom the Instituto Tecnologico de Chihuahua, Mex-ico. We thank the anonymous referees for their sug-gestions, which helped us improve the quality of thispaper.

References1. M. V. Mantravadi, “Lateral shearing interferometers,” in Op-

tical Shop Testing, 2nd ed., D. Malacara, ed. ~Wiley, New York,1992!, pp. 123–206.

2. K. Itoh, “Analysis of the phase unwrapping algorithm,” Appl.Opt. 21, 2470 ~1982!.

3. J. M. Tribolet, “A new phase unwrapping algorithm,” IEEETrans. Acoust. Speech Signal Process. ASSP-25, 170–177~1977!.

4. D. L. Fried, “Least-squares fitting of a wave-front distortionestimate to an array of phase-difference measurements,” J.Opt. Soc. Am. 67, 370–375 ~1977!.

5. R. H. Hudgin, “Wave-front reconstruction for compensated im-aging,” J. Opt. Soc. Am. 67, 375–378 ~1977!.

6. H. Takajo and T. Takahashi, “Least-squares phase estimationfrom the phase difference,” J. Opt. Soc. Am. A 5, 416–425~1988!.

7. J. L. Marroquin and M. Rivera, “Quadratic regularizationfunctional for phase unwrapping,” J. Opt. Soc. Am. A 12, 2393–2400 ~1995!.

8. K. P. Horn, Robot Vision ~MIT Press, Cambridge, Mass., 1986!,Chap. 11.

9. D. C. Ghiglia and L. A. Romero, “Robust two-dimensionalweighted and unweighted phase unwrapping that uses fasttransforms and iterative methods,” J. Opt. Soc. Am. A 11,107–117 ~1994!.

10. R. Fletcher, Practical Methods of Optimization, 2nd ed. ~Wiley,New York, 1987!.

11. R. Courant, “Variational methods for the solution of problemsof equilibrium and vibrations,” Bull. Am. Math. Soc. 49, 1–23~1943!.

12. M. Takeda, H. Ina, and S. Kobayashi, “Fourier-transformmethod of fringe-pattern analysis for computer-based topogra-phy and interferometry,” J. Opt. Soc. Am. 72, 156–160 ~1982!.

13. G. H. Golub and C. F. van Loan, Matrix Computations ~JohnsHopkins U. Press, Baltimore, Md., 1989!, Chap. 10.

14. R. Jones and C. Wykes, Holographic and Speckle Interferom-etry ~Cambridge U. Press, Cambridge, 1989!.

15. D. C. Ghiglia, G. A. Masting, and L. A. Romero, “Cellular-automata method for phase unwrapping,” J. Opt. Soc. Am. A 4,267–280 ~1987!.

16. H. Takajo and T. Takahashi, “Noniterative method for obtain-ing the exact solution for the normal equation in least phaseestimation from the phase difference,” J. Opt. Soc. Am. A 5,1818–1827 ~1988!.