# Half-Period Gray-Level Coding Strategy for Absolute Phase Retrieval

^{1}

^{2}

^{3}

^{4}

^{5}

^{*}

## Abstract

**:**

^{2}codewords with n gray levels in one pattern. Moreover, this method is insensitive to moderate image blurring. Various experiments demonstrate the robustness and effectiveness of the proposed strategy.

## 1. Introduction

^{m}codewords. In order to expand the amount of codewords, the n-ary gray-level (nGL) method [30,31,32,33,34,35,36] that uses n > 2 intensity values was developed. In the nGL method, the number can be broadened to n

^{m}with the same m patterns.

## 2. Principles

#### 2.1. Three-Step Phase-Shifting Method

#### 2.2. The Proposed Method

#### 2.2.1. Coding Strategy

^{2}different codewords. Without loss of generality, this paper selects n = 4 intensity levels, generating 16 fringe orders. The specific codewords for each period are listed in Table 1. C

_{1}cycles in the loop of ‘1234’ four times and C

_{2}is arranged as ‘1234234134124123’. C

_{1}and C

_{2}can form a unique 2-bit codeword C

_{1}C

_{2}together to determine the fringe order. Figure 1 shows the designed codewords, where C

_{1}and C

_{2}are plotted in green and red, respectively. From this picture, we can see that every period is embedded with a 2-bit codeword. Let C

_{1}and C

_{2}be the sequences shown in Table 1. Then, the codes can be mathematically described as:

_{1}. In contrast, if x lies in the second half-period, code is assigned to C

_{2}. Consequently, the coded pattern can be described by:

#### 2.2.2. Unwrapping Strategy

**Step 1: Generate masks**. As Equations (6) and (7) indicate, we can obtain the wrapped phase $\varphi \left(x,y\right)$ and Mask to remove the background. Afterwards, three masks can be produced by the wrapped phase $\varphi \left(x,y\right)$ and Mask. The process is shown in Figure 3 and the three masks can be mathematically presented by:

_{1}and C

_{2}, while Mask3 is used to merge them into a 2-bit codeword C

_{1}C

_{2}.

**Step 2: Correct and quantize half-period**. Due to sharp changes between the intensities of C

_{1}and C

_{2}, some of the boundary pixels would be calculated inaccurately. For example, the codeword of the 13th period is assigned as ‘14’, but in practice some pixels in the boundary of C

_{1}and C

_{2}might be computed as ‘2’ or ‘3’. Different from Cai’s method that corrects two identical parts of a 1-bit codeword, the half-period correction method is applied to correct two different bits of a 2-bit codeword. In detail, we first multiply the captured coded pattern with Mask1 and Mask2 to align the maps of C

_{1}and C

_{2}with the wrapped phase at every $2\pi $ boundary. Then, we use a bwlabel function in Matlab to segment and mark the connected regions. After that, we compute the average intensity value of every labeled region and replace each region with the average value. Thus, the wrong boundary codewords can be corrected. Briefly, this correction method makes use of characteristics of the wrapped phase to align the codewords at each $2\pi $ boundary, and then employs an averaging operation to reduce the errors brought about by noises and reduce defocusing to the least level. As a result, it can eliminate the errors at the boundaries to a great extent.

_{1}and C

_{2}. Next, we use an AND function among the two maps and Mask3. Then, we can acquire the map of 2-bit codewords C

_{1}C

_{2}. It is clear to see in Figure 3 that this map is split into many stripes and each stripe corresponds to a 2-bit codeword.

**Step 3: Decode codewords**. The codewords include normal codewords and defective codewords. Figure 4 gives the detailed process. The normal codewords represent those complete codewords that have both C

_{1}and C

_{2}in one period. For this kind of codeword, it is easy to find the corresponding fringe orders by the look-up table given in Table 1.

_{1}or C

_{2}, due to the location of the objects or the inappropriate thresholds. These defective codewords cannot be determined directly but can be calculated by referring to their adjacent codewords. In other words, if we have calculated the fringe order of the previous codeword or the next codeword, the fringe order of the current defective codeword can be obtained by its previous fringe order plus one or the next fringe order minus one. Once all the codewords are decoded, the absolute phase can be recovered based on Equation (8).

## 3. Simulation

## 4. Experiments

#### 4.1. Measurement of Complex Object

_{1}and C

_{2}, obtained by Mask1 and Mask2, respectively. C

_{1}is labelled in red and C

_{2}is labelled in blue. In Figure 7d, the normal codewords consisting of both C

_{1}and C

_{2}are labelled in green. Obviously, there are two defective codewords on the left and right edges of Doraemon, which lost their half-code. The normal codewords can easily find their corresponding fringe orders by Table 1, whereas the fringe orders of defective codewords need to be calculated by referring to their neighbors. For example, the codeword on the right edge lost its right half-code. The left adjacent codeword is ‘31’, whose corresponding fringe order is 11. Consequently, we could acquire the fringe order of the defective codeword by 11 plus1, and that is 12. The map of fringe orders and the result of 3D reconstruction are shown in Figure 7e,f, respectively. The 400th cross-section of two objects is presented in Figure 8. Although some codewords are defective, we can still obtain the right fringe order.

#### 4.2. Measurement of the Standard Ball

#### 4.3. Measurement under Defocused Scenes

## 5. Conclusions

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Conflicts of Interest

## References

- Zhong, K.; Li, Z.; Zhou, X.; Li, Y.; Shi, Y.; Wang, C. Enhanced phase measurement profilometry for industrial 3D inspection automation. Int. J. Adv. Manuf. Technol.
**2014**, 76, 1563–1574. [Google Scholar] [CrossRef] - Heist, S.; Zhang, C.; Reichwald, K.; Kuhmstedt, P.; Notni, G.; Tunnermann, A. 5D hyperspectral imaging: Fast and accurate measurement of surface shape and spectral characteristics using structured light. Opt. Express
**2018**, 26, 23366–23379. [Google Scholar] [CrossRef] - Inanç, A.; Kösoğlu, G.; Yüksel, H.; Naci Inci, M. 3-D optical profilometry at micron scale with multi-frequency fringe projection using modified fibre optic Lloyd’s mirror technique. Opt. Lasers Eng.
**2018**, 105, 14–26. [Google Scholar] [CrossRef] - Van der Jeught, S.; Dirckx, J.J.J. Real-time structured light profilometry: A review. Opt. Lasers Eng.
**2016**, 87, 18–31. [Google Scholar] [CrossRef] - Zuo, C.; Huang, L.; Zhang, M.; Chen, Q.; Asundi, A. Temporal phase unwrapping algorithms for fringe projection profilometry: A comparative review. Opt. Lasers Eng.
**2016**, 85, 84–103. [Google Scholar] [CrossRef] - Zhang, S. High-speed 3D shape measurement with structured light methods: A review. Opt. Lasers Eng.
**2018**, 106, 119–131. [Google Scholar] [CrossRef] - Zhang, S. Absolute phase retrieval methods for digital fringe projection profilometry A review. Opt. Lasers Eng.
**2018**, 107, 28–37. [Google Scholar] [CrossRef] - Xu, J.; Zhang, S. Status, challenges, and future perspectives of fringe projection profilometry. Opt. Lasers Eng.
**2020**, 135, 106193. [Google Scholar] [CrossRef] - Cai, B.; Wang, Y.; Wang, K.; Ma, M.; Chen, X. Camera Calibration Robust to Defocus Using Phase-Shifting Patterns. Sensors
**2017**, 17, 2361. [Google Scholar] [CrossRef] [Green Version] - Lu, P.; Sun, C.; Liu, B.; Wang, P. Accurate and robust calibration method based on pattern geometric constraints for fringe projection profilometry. Appl. Opt.
**2017**, 56, 784–794. [Google Scholar] [CrossRef] - Cai, B.; Wang, Y.; Wu, J.; Wang, M.; Li, F.; Ma, M.; Chen, X.; Wang, K. An effective method for camera calibration in defocus scene with circular gratings. Opt. Lasers Eng.
**2019**, 114, 44–49. [Google Scholar] [CrossRef] - Takeda, M.; Mutoh, K. Fourier transform profilometry for the automatic measurement of 3-D object shapes. Appl. Opt.
**1983**, 22, 3977. [Google Scholar] [CrossRef] [PubMed] - Zhang, Z.; Jing, Z.; Wang, Z.; Kuang, D. Comparison of Fourier transform, windowed Fourier transform, and wavelet transform methods for phase calculation at discontinuities in fringe projection profilometry. Opt. Lasers Eng.
**2012**, 50, 1152–1160. [Google Scholar] [CrossRef] - Kemao, Q. Applications of windowed Fourier fringe analysis in optical measurement: A review. Opt. Lasers Eng.
**2015**, 66, 67–73. [Google Scholar] [CrossRef] - Zuo, C.; Feng, S.; Huang, L.; Tao, T.; Yin, W.; Chen, Q. Phase shifting algorithms for fringe projection profilometry: A review. Opt. Lasers Eng.
**2018**, 109, 23–59. [Google Scholar] [CrossRef] - Tao, B.; Liu, Y.; Huang, L.; Chen, G.; Chen, B. 3D reconstruction based on photoelastic fringes. Concurr. Comput. Pract. Exp.
**2021**, 34, e6481. [Google Scholar] [CrossRef] - Wang, Y.; Cai, J.; Liu, Y.; Chen, X.; Wang, Y. Motion-induced error reduction for phase-shifting profilometry with phase probability equalization. Opt. Lasers Eng.
**2022**, 156, 107088. [Google Scholar] [CrossRef] - Wang, Y.; Cai, J.; Zhang, D.; Chen, X.; Wang, Y. Nonlinear Correction for Fringe Projection Profilometry With Shifted-Phase Histogram Equalization. IEEE Trans. Instrum. Meas.
**2022**, 71, 5005509. [Google Scholar] [CrossRef] - Cui, H. Reliability-guided phase-unwrapping algorithm for the measurement of discontinuous three-dimensional objects. Opt. Eng.
**2011**, 50, 063602. [Google Scholar] [CrossRef] - Zhang, S.; Li, X.; Yau, S.T. Multilevel quality-guided phase unwrapping algorithm for real-time three-dimensional shape reconstruction. Appl. Opt.
**2007**, 46, 50–57. [Google Scholar] [CrossRef] - Zhong, H.; Tang, J.; Zhang, S.; Chen, M. An Improved Quality-Guided Phase-Unwrapping Algorithm Based on Priority Queue. IEEE Geosci. Remote Sens. Lett.
**2011**, 8, 364–368. [Google Scholar] [CrossRef] - Wu, J.; Zhou, Z.; Liu, Q.; Wang, Y.; Wang, Y.; Gu, Y.; Chen, X. Two-wavelength phase-shifting method with four patterns for three-dimensional shape measurement. Opt. Eng.
**2020**, 59, 024107. [Google Scholar] [CrossRef] - Liu, K.; Wang, Y.; Lau, D.L.; Hao, Q.; Hassebrook, L.G. Dual-frequency pattern scheme for high speed 3-D shape measurement. Opt. Express
**2010**, 18, 5229–5244. [Google Scholar] [CrossRef] [PubMed] [Green Version] - Song, L.; Dong, X.; Xi, J.; Yu, Y.; Yang, C. A new phase unwrapping algorithm based on Three Wavelength Phase Shift Profilometry method. Opt. Laser Technol.
**2013**, 45, 319–329. [Google Scholar] [CrossRef] - Zhang, Q.; Su, X.; Xiang, L.; Sun, X. 3-D shape measurement based on complementary Gray-code light. Opt. Lasers Eng.
**2012**, 50, 574–579. [Google Scholar] [CrossRef] - Zheng, D.; Da, F.; Kemao, Q.; Seah, H.S. Phase-shifting profilometry combined with Gray-code patterns projection: Unwrapping error removal by an adaptive median filter. Opt. Express
**2017**, 25, 4700–4713. [Google Scholar] - Wang, Y.; Zhang, S. Novel phase-coding method for absolute phase retrieval. Opt. Lett.
**2012**, 37, 2067–2069. [Google Scholar] [CrossRef] - Chen, X.; Wang, Y.; Wang, Y.; Ma, M.; Zeng, C. Quantized phase coding and connected region labeling for absolute phase retrieval. Opt. Express
**2016**, 24, 28613–28624. [Google Scholar] [CrossRef] - Chen, X.; Wu, J.; Fan, R.; Liu, Q.; Xiao, Y.; Wang, Y.; Wang, Y. Two-digit phase-coding strategy for fringe projection profilometry. IEEE Trans. Instrum. Meas.
**2020**, 91, 242–256. [Google Scholar] [CrossRef] - Porras-Aguilar, R.; Falaggis, K.; Ramos-Garcia, R. Optimum projection pattern generation for grey-level coded structured light illumination systems. Opt. Lasers Eng.
**2017**, 91, 242–256. [Google Scholar] [CrossRef] - Chen, X.; Chen, S.; Luo, J.; Ma, M.; Wang, Y.; Wang, Y.; Chen, L. Modified Gray-Level Coding Method for Absolute Phase Retrieval. Sensors
**2017**, 17, 2383. [Google Scholar] [CrossRef] [PubMed] [Green Version] - Cai, B.; Yang, Y.; Wu, J.; Wang, Y.; Wang, M.; Chen, X.; Wang, K.; Zhang, L. An improved gray-level coding method for absolute phase measurement based on half-period correction. Opt. Lasers Eng.
**2020**, 128, 106012. [Google Scholar] [CrossRef] - Ma, M.; Yao, P.; Deng, J.; Deng, H.; Zhang, J.; Zhong, X. A morphology phase unwrapping method with one code grating. Rev. Sci. Instrum.
**2018**, 89, 073112. [Google Scholar] [CrossRef] - Wang, Y.; Liu, L.; Wu, J.; Chen, X.; Wang, Y. Spatial binary coding method for stripe-wise phase unwrapping. Appl. Opt.
**2020**, 59, 4279–4285. [Google Scholar] [CrossRef] - Wu, Z.; Guo, W.; Zhang, Q. High-speed three-dimensional shape measurement based on shifting Gray-code light. Opt. Express
**2019**, 27, 22631–22644. [Google Scholar] [CrossRef] - Wu, Z.; Zuo, C.; Guo, W.; Tao, T.; Zhang, Q. High-speed three-dimensional shape measurement based on cyclic complementary Gray-code light. Opt. Express
**2019**, 27, 1283–1297. [Google Scholar] [CrossRef] [PubMed] - Tang, C.; Hou, C.; Song, Z. Defocus map estimation from a single image via spectrum contrast. Opt. Lett.
**2013**, 38, 1706–1708. [Google Scholar] [CrossRef] [PubMed] [Green Version]

**Figure 2.**Patterns used in the proposed method. (

**a**)Three sinusoidal patterns. (

**b**) The coded pattern.

**Figure 5.**Blurred reference patterns and results of simulation with different standard deviation σ. (

**a**–

**c**) Blurred reference pattern, one section of fringe order and reconstruction of reference plane with σ = 5, respectively. (

**d**–

**f**) Blurred reference pattern, one section of fringe order and reconstruction of reference plane with σ = 10, respectively. (

**g**–

**i**) Blurred reference pattern, one section of fringe order and reconstruction of reference plane with σ = 15, respectively.

**Figure 7.**Processing of the sculpture of Doraemon. (

**a**) Captured coded pattern. (

**b**) The map of C

_{1}. (

**c**) The map of C

_{2}. (

**d**) The map of 2-bit codewords C

_{1}C

_{2}. (

**e**) The map of fringe orders. (

**f**) The result of 3D reconstruction.

**Figure 9.**Three-dimensional reconstruction of the sculpture of Doraemon. (

**a**) The proposed method. (

**b**) Method in Ref. [32].

**Figure 10.**Three-dimensional reconstruction of the standard ball; (

**a**) 20-step phase-shifting method. (

**b**) The proposed method. (

**c**) Method in Ref. [32].

**Figure 11.**Three-dimensional reconstructions under defocused scenes; (

**a**) 3D reconstruction of the proposed method; (

**b**) 3D reconstruction of Ref. [32]; (

**c**) 3D reconstruction of the conventional nGL method.

k | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

C_{1} | 1 | 2 | 3 | 4 | 1 | 2 | 3 | 4 | 1 | 2 | 3 | 4 | 1 | 2 | 3 | 4 |

C_{2} | 1 | 2 | 3 | 4 | 2 | 3 | 4 | 1 | 3 | 4 | 1 | 2 | 4 | 1 | 2 | 3 |

C_{1}C_{2} | 11 | 22 | 33 | 44 | 12 | 23 | 34 | 41 | 13 | 24 | 31 | 42 | 14 | 21 | 32 | 43 |

Method | RMSE (rad) |
---|---|

The proposed method | 0.0066 |

Ref. [32] | 0.0064 |

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Ran, Z.; Tao, B.; Zeng, L.; Chen, X.
Half-Period Gray-Level Coding Strategy for Absolute Phase Retrieval. *Photonics* **2022**, *9*, 492.
https://doi.org/10.3390/photonics9070492

**AMA Style**

Ran Z, Tao B, Zeng L, Chen X.
Half-Period Gray-Level Coding Strategy for Absolute Phase Retrieval. *Photonics*. 2022; 9(7):492.
https://doi.org/10.3390/photonics9070492

**Chicago/Turabian Style**

Ran, Zipeng, Bo Tao, Liangcai Zeng, and Xiangcheng Chen.
2022. "Half-Period Gray-Level Coding Strategy for Absolute Phase Retrieval" *Photonics* 9, no. 7: 492.
https://doi.org/10.3390/photonics9070492