## Abstract

This work describes a rapid-phase unwrapping algorithm that combines the rapidity and simplicity of a path-dependent algorithm and the robustness of a path-independent algorithm by rotating the phase map or the unwrapping direction 90° after a scan in one direction. It offers a solution for noise-contaminated phase data, which includes artifacts, complex-shaped borders, or regions of holes. The algorithm can be used in real-time processing. In addition, a phase-dislocation masking method is presented that can be used to detect and clean inconsistent data and improve the rms values of signal-to-noise ratio in unwrapped phase maps.

© 2007 Optical Society of America

## 1. Introduction

Various optical processes can cause phase wrapping in data: interferometers, holography, moiré-deflectometry, and speckle interferometry, for example. In these optical techniques, the phase is obtained from an arctangent function, which gives a phase value that varies only within the range -π ~ π as modulo 2π of the true phase. This procedure produces saw-tooth shaped phase fringes. For further calculation, it is necessary to remove these 2π phase jumps to obtain a continuous phase map. The general method is the removal of the discontinuities by adding 2π to or subtracting 2π from the wrapped phase. Many methods have been developed for phase unwrapping [1–9]. These methods can be divided into two categories: a path-dependent unwrapping algorithm and a path-independent unwrapping algorithm. They differ remarkably in unwrapping speed and robustness.

As is shown in Fig. 1(a), a true phase map has a notable character: when scanning along a closed path from point P in a phase map, the sum of the phase differences of all the points passed is zero, and the number of phase jumps that is passed is zero. They cancel out each other. The result is the same, regardless of the path that is selected. Similarly, the sum of the phase differences of all the points between any two points P1 and P2 in a phase map is the same when scanning along any path. The number of the phase jumps is also the same. It shows that there are many paths that can be selected in a wrapped phase map to unwrap the phase. However, we need to select the best one to unwrap the phase map quickly and robustly, according to the particular condition.

There are three types of 2π phase jump fringes in all phase maps as presented by Wang et al. [Types I, II, and III in Fig. 1(b)] [1]. The third one is inconsistent in Fig. 1(b) because the rule stated in Fig. 1(a) is broken. The reason is that the phase surface is continuous without the 2π phase-jump fringe if observed along path ① from P1 to P2, but discontinues with the 2π phase jump fringe if observed along path ② from P1 to P2. It is this contradiction that causes the failure to unwrap a whole phase map.

The path-dependent unwrapping algorithm [2] is a conventional algorithm that unwraps line by line along several fixed unwrapping paths. The starting point is also fixed. The unwrapping usually proceeds from the center of the phase map upward, downward, leftward, and rightward. Since unwrapping occurs along fixed paths, the unwrapping is very fast. But it cannot effectively unwrap those phase maps if they contain complex-shaped borders and regions of holes. If such borders and regions are met, the algorithm cannot automatically bypass them.

The path-independent unwrapping algorithm [3] explores all possible paths between any two points for unwrapping. Because a new starting point is used, and all of the unwrapping paths are tried each time, the unwrapping paths will automatically bypass them if complex-shaped borders or regions of holes are encountered. However, this results in a slow unwrapping speed since it takes too much time to search many useless paths.

There are three differences between the path-dependent algorithm and the path-independent algorithm. First, the former algorithm selects the starting point only once, whereas the latter algorithm selects a new starting point in each of the iterations. Second, the former algorithm unwraps along one direction just once, and it unwraps a whole line or a whole column each time. However, the latter algorithm unwraps along the four directions many times, but it only unwraps a field of several points' length. Third, the former algorithm does not need iteration, whereas the latter algorithm does need iteration.

In this work, a simple and robust phase-unwrapping algorithm of arbitrary shaped areas is presented. It selects an appropriate unwrapped point as the starting point each time, and it unwraps the whole phase map by the path-dependent algorithm rightward, downward, leftward, and upward, accordingly, until the border or region of holes is met (rotating the unwrapping direction 90° relative to the phase map in one direction after each scan). If complex-shaped borders or regions of holes are encountered, the process of unwrapping a whole line or a whole column is stopped. The wrapped parts that are left can be unwrapped from another direction by another round of iteration. The complex-shaped borders or regions of holes are bypassed. The whole process is an iteration process until the whole phase map has been unwrapped. Thus, it combines the advantages of the path-dependent algorithm and the path-independent algorithm, which results in easier unwrapping.

## 2. Phase dislocation masking algorithm

The dislocation-masking process should be done before using the phase-unwrapping algorithm.

The algorithm presented by Goldstein [9] can find the residues of the two end points of inconsistent 2π phase jumps and connect the nearest opposite residues with branch cuts. This way, the parts of the true 2π phase jumps submerged in noises [Type II in Fig. 2(a)] can be masked. At the same time, the algorithm presented by Wang [1] can mask a whole strip of pseudo-2π phase jumps resulting from noises [Type III in Fig. 2(a)].

True 2π phase jumps [Type I in Fig. 2(a)] are usually longer, whereas the parts of true 2π phase jumps submerged in noises [Type II in Fig. 2(a)] and pseudo-2π phase jumps resulting from noises [Type III in Fig. 2(a)] are shorter (usually by several points). Thus, a length threshold (e.g., 10 points, according to the quality of the phase map) can be used to distinguish the two kinds of 2π jumps. The procedure is as follows:

- Wang's method is used for tracking the 2π phase jumps [Type 3 in Fig. 1(b)] by counting their length.
- If the length of these 2π phase jumps is shorter than the threshold, they are surely pseudo-2π phase jumps and can be masked by Wang's method. The result is the elimination of the pair of opposite residues if the two end points of pseudo-2π phase jumps are in the map or the elimination of a residue if only one end point of a pseudo-2π phase jump is in the map [Fig. 2(b)].
- The inconsistent data left are masked as part of the true 2π phase jumps submerged in noises by Goldstein's method. The residues of the two end points of the inconsistent 2π phase jumps are always opposite. We can connect the nearest plus and minus residues with a branch cut and can mask all points on it [Fig. 2(b)].

This method of combining Goldstein's method and Wang's method is efficient in the case of the inconsistent points being not very dense. Wang's method is used first in order to decrease the density of residues and to avoid connecting residues blindly. Thus, this avoids creating insular phase areas.

## 3. Phase unwrapping by spinning iteration

A robust phase-unwrapping algorithm for arbitrary shaped areas should be simple and efficient. The following procedure systematically unwraps every line and column, regardless of its shape, without any conditional programming statements.

Using the path-dependent algorithm, unwrap the phase map line by line and column by column in four directions (from left to right, from top to bottom, from right to left, and from bottom to top) successively. A round of iteration is finished after a cycle. The resolution procedure is as follows:

- Appoint a new starting point in the phase map and establish an image bitmap file. Mark the point as an unwrapped point at the corresponding point in the image file.
- Scan line by line from left to right using the path-dependent algorithm. During the process of unwrapping a line, if an unwrapped point is found and the point to the right is a wrapped point, take the unwrapped point as the new starting point and unwrap the line from left to right. Generally, the unwrapping part is to the right of the unwrapped point. If the masked point or border is met, stop unwrapping [Shown in Fig. 3(a)].
- Scan column by column from top to bottom using the path-dependent algorithm. During the process of unwrapping a column, if an unwrapped point is found and the point below is a wrapped point, take the unwrapped point as the new starting point and unwrap the column from top to bottom. Generally, the unwrapping part is below the unwrapped point. If the masked point or border is met, stop unwrapping [Shown in Fig. 3(b)].
- Scan line by line from right to left using the path-dependent algorithm. During the process of unwrapping a line, if an unwrapped point is found and the point to the left is a wrapped point, take the unwrapped point as the new starting point and unwrap the line from right to left. Generally, the unwrapping part is to the left of the unwrapped point. If the masked point or border is met, stop unwrapping [Shown in Fig. 3(c)].
- Scan column by column from bottom to top using the path-dependent algorithm. During the process of unwrapping a column, if an unwrapped point is found and the point above is a wrapped point, take the unwrapped point as the new starting point and unwrap the column from bottom to top. Generally, the unwrapping part is above the unwrapped point. If the masked point or border is met, stop unwrapping [Shown in Fig. 3(d)]. A round of iteration is done.
- If there are still wrapped parts, repeat the spinning iteration processes 2-5 clockwise until the whole phase map is unwrapped [Shown in Fig. 3(e)].

This algorithm proceeds faster than the description of it. The technique only takes 2-3 iterations (8-12 scans) to unwrap a complicated phase map, and it does not fail. The unwrapping algorithm is simple because it does not contain any parameter or condition.

The whole phase map is fixed in the algorithm mentioned above, while the unwrapping direction is rotated 90° clockwise each time. However, when writing the program, we can fix the unwrapping direction but rotate the phase map 90° counterclockwise or clockwise each time. It is convenient for file reading and data processing. By doing this we can speed up the unwrapping process, which is beneficial for practical use. The resolution procedure is as follows:

- Appoint a new starting point in the phase map and establish an image bitmap file. Mark the point as an unwrapped point at the corresponding point in the image file.
- Scan line by line from left to right by the path-dependent algorithm. During the process of unwrapping a line, if an unwrapped point is found and the point to the right is a wrapped point, take the unwrapped point as the new starting point and unwrap the line from left to right. Generally, the unwrapping part is to the right of the unwrapped point. If the masked point or border is met, stop unwrapping.
- Rotate the whole phase map 90° counterclockwise.
- Repeat 2-3 three times to finish one iteration.
- If there are still wrapped parts, repeat 2-4 until the whole phase map is unwrapped.

## 4. Application and results

In order to test the global unwrapping strategy for complex shaped areas, two shaded parts (black areas), which simulate the bad points and the complex borders, are added onto a wrapped phase map. Figure 4(a) shows the original wrapped phase map. A series of spinning iterations of the phase unwrapping algorithm are shown in Figs. 4(b)–(e). Figure 4(f) shows the unwrapped phase map. The whole process only needs 2 iterations (6 scans). It shows that the algorithm proceeds quickly and robustly.

Figure 5(a) shows a phase map calculated by the infinite fringe moiré-deflectometry. It shows that inconsistent data exists in the top right corner. First, a masking phase dislocation routine is applied with a result shown in Fig. 5(b). It shows that this part of the data has been completely masked. The final phase map is then unwrapped automatically in Fig. 5(c) by using an unwrapping phase in a spinning iteration.

## 5. Conclusion

As stated above, by combining Goldstein's method and Wang's method, the technique of masking phase dislocations has been proven to be effective both in simulated and in real application, especially for the situation where noise takes on a scattered distribution. The technique makes it possible to achieve consistent unwrapping.

Second, the phase unwrapping algorithm in a spinning iteration showed better performance than the conventional path-dependent unwrapping algorithm and the conventional path-independent unwrapping algorithm. It is proven to be robust and stable, even if the phase map has complex borders and regions of holes.

And more importantly, the unwrapping algorithm does not contain any parameters or any conditions. The technique takes 2-3 iterations (8-12 scans) to unwrap complicated structures and it does not fail, compared with hundreds of iterations using former methods. The algorithm can be used in real-time processing.

## References and links

**1. **B. Wang, Y. Shi, T. Pfeifer, and H. Mischo, “Phase unwrapping by blocks,” Measurement **25**, 285–290 (1999). [CrossRef]

**2. **K. Itoh, “Analysis of the phase unwrapping algorithm,” Appl. Opt. **21**, 2470–2470 (1982). [CrossRef] [PubMed]

**3. **D. C. Ghiglia, G. A. Mastin, and L. A. Romero, “Cellular-automata method for phase unwrapping,” J. Opt. Soc. Am. A **4**, 267–280 (1987). [CrossRef]

**4. **J. J. Gierloff, “Phase unwrapping by regions,” Proc. SPIE **818**, 2–9 (1987).

**5. **K. Andresen and Q. Yu, “Robust phase unwrapping by spin filtering combined with a phase direction map,” Optik **4**, 145–149 (1994).

**6. **J. M. Huntley, “Noise immune phase unwrapping algorithm,” Appl. Opt. **28**, 3268–3270 (1989). [CrossRef] [PubMed]

**7. **D. C. Ghiglia and L. A. Romero, “Robust two-dimensional weighted and unweighted phase unwrapping that uses fast transforms and iterative methods,” J. Opt. Soc. Am. A **11**, 107–117 (1994). [CrossRef]

**8. **A. Spik and D. W. Robinson, “Investigation of the cellular automata method for phase unwrapping and its implementation on an array processor,” Opt. Lasers Eng. **14**, 25–37 (1991). [CrossRef]

**9. **R. M. Goldstein, H. A. Zebker, and C. L. Werner, “Satellite radar interferometry: two-dimensional phase unwrapping,” Radio Sci. **23**, 713–720 (1988). [CrossRef]