## Abstract

The gamma effect of phase-measuring profilometry systems yields nonlinear errors, which will substantially reduce the 3D shape measurement accuracy. Here, a robust and flexible gamma correction method based on the probability distribution function (PDF) of the wrapped phase is presented. First, a series of PDF curves are generated from the simulated wrapped phase distributions with different gamma values. Second, an experimental PDF curve will be produced after obtaining the wrapped phase from the captured three-step phase-shift fringe images. Then, a correlation procedure will be used to find the most similar PDF curve from the simulated PDF curves, and the gamma value of the matched PDF curve is that of the current system. Note that the gamma value detected by this method will be smaller than the true value due to the defocusing effect of the projection system with a large aperture. Therefore, an improved PDF-based algorithm, which projects two sets of three-step phase-shifting sinusoidal fringe patterns with different pre-coded gamma values and produces two PDF curves, is also added. Then after one more correlation procedure, a more accurate systematic gamma value could be calculated. It does not need large-step phase-shift images and 2×3 fringe images are quite enough. The experimental results show that the technique is very fast, easy to use and quite accurate.

© 2019 Optical Society of America under the terms of the OSA Open Access Publishing Agreement

## 1. Introduction

The phase-shift fringe projection has been used widely with the advantage of high-accuracy and high-resolution in the variety of the 3D sensing methods [1]. In a real digital fringe projection system (DFPS), sinusoidal fringe patterns are commonly used due to their high accuracy [2,3]. There are two kinds of errors introduced by the commercially available digital devices. One is from uncertainty due to sensor noise. The other is the periodical error from the nonlinearity mainly introduced by the device’s gamma effect [4–6]. This kind of periodical phase error can be eliminated by using a large-step phase-shift technique [7]. However, in fast or real-time DFPS, a three-step phase-shift method is preferred, i.e. a method with less fringe images and higher accuracy is the common goal. To reduce the gamma influence, many methods of phase-error compensation or gamma correction have been proposed. Roughly those methods could be divided into two categories as mentioned in Ref. [8].

In the first category, these approaches are trying to project the ideal sinusoidal fringe patterns. One solution is to find the most proper gamma, which will be encoded in the projected fringe patterns and makes the captured fringe images perfectly. Among them, Guo [9] is to use the cumulative distribution function to find the gamma value by projecting different fringes with different backgrounds and modulations. Liu [10] is to illustrate a calculation formula to obtain the gamma value by using a large phase-shifting step. Thang [11] is to find the true gamma value by minimizing the difference between the real phase value of the three-step algorithm and the true phase value of a large phase-shifting step method. Li [12] thought that the gamma value calculated by Liu’s method would be less than the real gamma when the defocus effect of the system was taken into account. Therefore, to improve the phase accuracy, a more correct gamma value could be obtained by projecting two set of pre-coded gamma fringe patterns with a large phase-shifting step. Apparently, the most of the existing methods will bring a gamma value for every pixel at first. Then a mean value could be provided for the whole system. Another way to generate the ideal fringes is called defocusing technology [13–21]. The defocusing can work as a low-pass filter to eliminate high-frequency harmonics. However, it is difficult to control the defocusing degree precisely.

In the second category, the phase-error is compensated by a post processing instead of projecting the pre-coded fringes. Zhang [22] is to compensate the phase error by generating a Look-up-Table (LUT) between the phase error value and the corresponding phase value. Pan [23] is to use an iterative algorithm to reduce the phase error owing to non-sinusoidal waveforms. Cai [24] is to use the Hilbert Transformation (HT), which produces a phase error model with the identical amplitude and opposite direction compared with the phase error model without HT. Then, the phase error can be compensated flexibly and simply by averaging the phases in the two domains.

In this paper, we demonstrate a flexible gamma calculation technique, which uses the probability distribution function (PDF) to find the correct gamma value. Because the smoothness of the PDF curves is related to the system’s gamma values, the characteristics of PDF could be used to find the system’s gamma. Two PDF-based methods are detailed. Experimental results show that the proposed methods are flexible and robust, and can lead to a fast gamma calculation.

## 2. Principle

#### 2.1 The relationship between the phase error and the nonlinearity

The gray images captured by the measurement system of DFPS are formed through the procedures illustrated in Fig. 1. Sinusoidal fringe patterns generated by a computer have intensity *I _{n}*(

*x*,

*y*). The output intensity of the fringe patterns becomes

*I*(

_{n}^{p}*x*,

*y*) after being projected by the projector. The projector projects light onto a surface, and the distorted fringe patterns are modulated by the surface of an object. The camera captured fringe patterns have intensity

*I*(

_{n}^{c}*x, y*).

In DFPS, a N-step phase-shifting method is commonly used to calculate the wrapped phase, and then the height information of the measured object can be recovered after phase unwrapping and calibration. When the projected grating is shifted by 1/*N* of its period, the intensity function of the ideal computer-generated fringe pattern can be expressed as:

*x*,

*y*) denotes an arbitrary point in the image,

*a*(

*x*,

*y*) is the background intensity,

*b*(

*x*,

*y*) is the intensity modulation,

*ϕ*(

*x*,

*y*) is the fringe phase,

*δ*is the phase-shifting amount. The three-step phase-shifting algorithm requires the least number of patterns and the nonlinear effect has the most obvious effect on wrapped phase distribution, therefore, only three-step phase-shifting algorithm is discussed in this paper. For convenience, (

_{n}*x*,

*y*) will be omitted from the equations hereafter.

In the camera, the intensity of the captured patterns distorted by gamma effect is now described as:

*A*denotes the direct component,

*B*denotes the magnitude of the

_{k}*k*

^{th}harmonic component. Without the loss of generality, we only consider harmonics up to the third order, the measured phase

*ϕ*can be given as:

*γ*is the projector’s gamma. In order to make the captured fringe images have ideal sinusoidal property, an appropriate gamma is encoded in the computer-generated sinusoidal fringes to reduce the nonlinear effect. Then the intensity of the captured fringe images is rewritten as

_{0}*γ*=

_{p}*1/γ*will yield

_{0}*γ*= 1, which means that the fringe pattern captured by the camera is an ideal sinusoidal fringe. Because digital projectors are equipped with large apertures, which results in a narrow depth of field, various degrees of out-of-focus blur would occur in the field of view. Then Eq. (6) can be rewritten as

_{0}′*C*are system parameters, when

_{1}, C_{2}, γ_{a}, γ_{b}*γ*=0, the Eq. (7) is equivalent to Eq. (6). The corrected gamma value of the system can be described as

_{b}#### 2.2 Probability distribution function of the wrapped phase distribution

The phase error, which is introduced by nonlinearity, will be periodical as shown in Eq. (4), i.e. the phase error can be regarded as the function of the true wrapped phase, whose values range from -π to π and can be calculated by Eq. (3). Here, we named a probability distribution function as PDF, which is an object function of the wrapped phase. Let P{.} indicated probability, the PDF can be calculated by

where*M*means the number of the sampling points, normally

*M*can be any integer greater than 1, and

*m*= 0, 1, 2, …,

*M*–1. For example,

*M*= 63, which is used for this whole paper.

The PDF curve, which is calculated from the ideal wrapped phase, will be quite smooth, because each phase value has the same probability, which is a numerical value without units as shown in Fig. 2(d). However, if the nonlinearity exists, the periodical phase error dramatically increases the amount of some phase values and decreases that of some other phase values as shown in Fig. 2(d). Figure 2(a) shows the ideal fringe pattern, i.e. the pre-coded gamma is 1. The deformed fringe pattern whose pre-encoded gamma is 2 is shown in Fig. 2(b). Figure 2(c) shows the phase error vs. the true phase distribution. The PDF curves with different gamma values are shown in Fig. 2(d). Apparently, the PDF curve is a smooth line, when gamma = 1. And the PDF value of each sample point will be same, i.e. *F*(*m*) = *1*/*M*. For example, *F*(*m*) should be 0.0159 theoretically for *M *= 63. In other words, the purpose of gamma correction is to make the system’s PDF curve smooth.

#### 2.3 Gamma calculation based on PDF

The gamma calculation process is shown in Fig. 3. First, a series of PDF curves with different gamma values are generated by computer simulation. Second, a real PDF curve will be obtained from the measured wrapped phase distribution. Then, a correlation process will be launched to find the most similar one from the simulated PDF curves by

where*F*is the PDF curve of the measured fringe patterns,

*F*is the

_{i}*i*curve in the simulated PDF curves. In practice, the function of Eq. (10) is to evaluate the degree of similarity between the measured PDF curve and simulation curves. Therefore, the gamma value corresponding to the curve of the maximum

^{th}*R*is the actual measurement system’s gamma value.

_{i}Here, the gamma values of the simulated PDF curves are between 1 and 3. But the gamma value can be even larger w.r.t the real system. If the maximum value of the correlation curve locates at gamma = 2 as shown in Fig. 4, then the gamma value of the real DFPS will be 2 exactly.

In practice, because of the complex factors such as defocusing effect and background effect exist in the measurement system, the intensity of captured fringe patterns should adopt the Eq. (7), accordingly, the corrected gamma value of the system can be described as Eq. (8). Thus, the gamma calculation process is as shown in Fig. 5, by projecting two sets of three-step phase-shifting sinusoidal fringe patterns with the different pre-coded gamma values, the corrected gamma value of the system *γ _{1}′* and

*γ*can be calculated, and

_{2}′*γ*are the pre-encoded gamma values. According to Eq. (8), we have:

_{p1}, γ_{p2}*γ*and

_{a}*γ*can be obtained by Eq. (11). Setting

_{b}*γ′*=1, which means the captured fringe patterns have ideal sinusoidal property, will yield:

## 3. Simulation

In the practical measurement system, electronic noise, which is known as random noise, is introduced by the ambient light as well as the electronic devices such as projector and camera. It will reduce the phase measurement accuracy and may influence the gamma calculation. Thus, we simulated the sinusoidal fringe model with noise to verify the effect of different noise on the system’s gamma values.

By adding 1% to 10% random noise to the actual sinusoidal fringe patterns, the system’s gamma value was calculated 100 times for each noise level and its standard deviation (STD) was evaluated as shown in Fig. 6(a). It can be seen that the STD is still less than 0.004, even the added random noise is 10%. Therefore, the proposed gamma correction method has high anti-noise ability. Figure 6(b) shows the result, when the adding random noise is 4%, and the red area includes all the simulated PDF curves with different gamma values. In the simulation, the system parameters are set as *γ _{a0}*=1.82,

*γ*=0.11, and

_{b0}*γ*=2.0449, which can be obtained from Eq. (12). With two pre-coded

_{p0}*γ*=1,

_{p1}*γ*=2 computer-generated fringes, the correlation process can detect the matching gamma values

_{p2}*γ*and

_{1}′*γ*, which are 1.9391 and 1.0203, respectively. The system pre-encoded gamma

_{2}′*γ*calculated by Eqs. (11)–(12) is 2.0453, which is highly consistent with the ground truth. It means that the gamma correction method proposed in this paper is robust in the case of noise.

_{p}## 4. Experiment

The 3D measurement system is comprised of a DLP projector and an IDS UI-124xSE-M camera. When we aimed at the fastest calculation process, we can ignore the effect of defocusing and other factors, i.e. to calculate the gamma values of the measurement system based on PDF correlation with the gamma model of Eq. (6). The result is shown in Fig. 7(a). The range of simulated gamma values can be adjusted according to the needs of measurement. The correlation coefficient of PDF curves result between the simulated fringes and measured fringe is shown in Fig. 7(b). It is seen that the point A has the maximum value, therefore, the system’s pre-encoded gamma *γ _{p }*= 1.93.

For comparison, Thang’s method [11] (with considering the effect of defocusing and other factors) and Liu’s method [10] (without considering the effect of defocusing and other factors) were also employed to obtain the *γ _{p}*. Each method will produce a gamma value. To evaluate the gamma correction result, an eighteen-step phase-shifting algorithm is used to measure a reference plane, and to be taken as the ground truth. Each calculated gamma value will be encoded into three phase-shift fringes to obtain the wrapped phase via the three-step phase-shift technique. The residual phase errors are shown in Fig. 8.

The comparison result is shown in Table 1. The STD values of the measured phase errors are 0.1683, 0.0198, 0.0291 and 0.0238, respectively. Obviously, these methods can improve the measurement accuracy significantly. Among them, Thang’s method [11] has the highest accuracy, because it took the complex factors such as defocusing effect and background effect into account. And the calculated gamma values by the proposed method and Liu′s method [10] are smaller than the true values. Our method only needs three frames of fringes. Therefore, the method presented in this paper can lead to a rapid detection for the system’s gamma

When the defocusing effect and other factors are taken into account, the gamma model should be described by Eq. (7). There are two unknown parameters, *γ _{a}* and

*γ*, therefore, it is necessary to project two sets of three-step phase-shifting fringes with different pre-encoded gamma values. First, the pre-encoded gamma values are,

_{b}*γ*=1 and

_{p1}*γ*=2, which are used to produce the wrapped phase distributions. Second,

_{p2}*γ*and

_{1}′*γ*are detected by the above-mentioned correlation method. The detected results are 1.93 and 1.02 as shown in Fig. 9(a). Then the system gamma

_{2}′*γ*can be calculated by Eqs. (11)–(12). The value is 2.0449. Figure 9(b) shows the residual phase errors compared with the ground truth.

_{p}The comparison with Thang’s method [11] is shown in Table 2. The STD of the measured phase error are 0.0198 and 0.0188, respectively. It means that the gamma value of the proposed method is almost equal to that of Thang’s method [11]. And the gamma value is also close to the real systematic gamma when the defocusing and other factors are considered. Noted that, the required number of fringe patterns in our method is 6 compared with 24 images required in Thang’s method. And the simulated PDF curves can even be produced in advance, which could further save the consuming time. Therefore, the proposed method can dramatically shorten the calculation process as well as keeping the accuracy.

Next, a gourd model is measured. Figure 10(a) shows one of three deformed fringe images. The recovered phase without phase compensation is shown in Fig. 10(b), which is the area marked by A in Fig. 10(a). Apparently, there are serious waviness phase errors with a periodic structure, which are caused by non-sinusoidal effect. The recovered phase rectified by Thang’s method [11] and our method are shown in Figs. 10(c) and 10(d), respectively. Figure 10(e) shows the cross sections, which is marked by B in Fig. 10(a). The periodical phase error owing to the gamma effect can be effectively removed by using the proposed gamma correction method.

## 5. Conclusion and discussion

The gamma effect is quite common in a digital fringe projection system, which is composed of a digital projector and a CCD camera. In this paper, a robust and flexible gamma correction method based on the PDF curves of the wrapped phase is presented. A series of PDF curves are calculated from the simulated wrapped phase with different pre-coded gamma values. Then, the system gamma value can be detected by a correlation process as long as the experimental PDF curve is calculated. We offer two ways to calculate the system’s gamma based on PDF. One is to project only one set of three-step phase-shifting fringe and directly calculate the gamma of the system. To the best of our knowledge, it is the fastest algorithm, and it might also be suitable for a non-digital projection system. The other is to take more factors, such as the influence of defocusing and ambient light, into account, therefore, it needs to project one more set of fringes. With the same correlation operations, a more accurate gamma value can be detected. In the proposed method, there are no more than 2×3 fringe images needed. Compared with other gamma correction methods, the proposed method can reach high accuracy as well as a fast-speed correction process.

## Funding

National Natural Science Foundation of China (61675141).

## References

**1. **J. Salvi, S. Fernandez, T. Pribanic, and X. Llado, “A state of the art in structured light patterns for surface profilometry,” Pattern Recognit. **43**(8), 2666–2680 (2010). [CrossRef]

**2. **C. Quan, X. Y. He, C. F. Wang, C. J. Tay, and H. M. Shang, “Shape measurement of small objects using LCD fringe projection with phase shifting,” Opt. Commun. **189**(1-3), 21–29 (2001). [CrossRef]

**3. **S. Gorthi and P. Rastogi, “Fringe Projection Techniques: Whither we are?” Opt. Lasers Eng. **48**(2), 133–140 (2010). [CrossRef]

**4. **C. Rathjen, “Statistical properties of phase-shift algorithms,” J. Opt. Soc. Am. A **12**(9), 1997–2008 (1995). [CrossRef]

**5. **G. H. Notni and G. Notni, “Digital fringe projection in 3D shape measurement: an error analysis,” Proc. SPIE **5144**, 372–380 (2003). [CrossRef]

**6. **A. Patil, R. Langoju, P. Rastogi, and S. Ramani, “Statistical study and experimental verification of high-resolution methods in phase-shifting interferometry,” J. Opt. Soc. Am. A **24**(3), 794–813 (2007). [CrossRef]

**7. **Z. Wang, D. A. Nguyen, and J. C. Barnes, “Some practical considerations in fringe projection profilometry,” Opt. Lasers Eng. **48**(2), 218–225 (2010). [CrossRef]

**8. **S. Zhang, “Comparative study on passive and active projector nonlinear gamma calibration,” Appl. Opt. **54**(13), 3834–3841 (2015). [CrossRef]

**9. **H Guo, H He, and M Chen, “Gamma correction for digital fringe projection profilometry,” Appl. Opt. **43**(14), 2906–2914 (2004). [CrossRef]

**10. **K. Liu, Y. Wang, D. Lau, Q. Hao, and L. Hassebrook, “Gamma model and its analysis for phase measuring profilometry,” J. Opt. Soc. Am. A **27**(3), 553–562 (2010). [CrossRef]

**11. **T. Hoang, B. Pan, D. Nguyen, and Z. Wang, “Generic gamma correction for accuracy enhancement in fringe-projection profilometry,” Opt. Lett. **35**(12), 1992–1994 (2010). [CrossRef]

**12. **Z. Li and Y. Li, “Gamma-distorted fringe image modeling and accurate gamma correction for fast phase measuring profilometry,” Opt. Lett. **36**(2), 154–156 (2011). [CrossRef]

**13. **X. Y. Su, W. Zhou, G. von Bally, and D. Vukicevic, “Automated phase-measuring profilometry using defocused projection of a Ronchi grating,” Opt. Commun. **94**, 561–573 (1992). [CrossRef]

**14. **M. J. Baker, J. Xi, and J. F. Chicharo, “Elimination of gamma non-linear luminance effects for digital video projection phase measuring profilometers,” in 4th IEEE International Symposium on Electronic Design, Test and Applications (IEEE, 2008), pp. 496–501.

**15. **S. Lei and S. Zhang, “Flexible 3-D shape measurement using projector defocusing,” Opt. Lett. **34**(20), 3080–3082 (2009). [CrossRef]

**16. **Y. Wang and S. Zhang, “Optimal pulse width modulation for sinusoidal fringe generation with projector defocusing,” Opt. Lett. **35**(24), 4121–4123 (2010). [CrossRef]

**17. **Y. Xu, L. Ekstrand, J. Dai, and S. Zhang, “Phase error compensation for three-dimensional shape measurement with projector defocusing,” Appl. Opt. **50**(17), 2572–2581 (2011). [CrossRef]

**18. **D. Zheng and F. Da, “Absolute phase retrieval for defocused fringe projection three-dimensional measurement,” Opt. Commun. **312**, 302–311 (2014). [CrossRef]

**19. **W. Lohry and S. Zhang, “Genetic method to optimize binary dithering technique for high-quality fringe generation,” Opt. Lett. **38**(4), 540 (2013). [CrossRef]

**20. **J. Dai, B. Li, and S. Zhang, “High-quality fringe pattern generation using binary pattern optimization through symmetry and periodicity,” Opt. Lasers Eng. **52**, 195–200 (2014). [CrossRef]

**21. **Y. Li, C. Zhao, Y. Qian, H. Wang, and H. Jin, “High-speed and dense three-dimensional surface acquisition using defocused binary patterns for spatially isolated objects,” Opt. Express **18**, 21628–21635 (2010). [CrossRef]

**22. **S. Zhang and S. T. Yau, “Generic nonsinusoidal phase error correction for three-dimensional shape measurement using a digital video projector,” Appl. Opt. **46**(1), 36 (2007). [CrossRef]

**23. **B. Pan, Q. Kemao, L. Huang, and A. Asundi, “Phase error analysis and compensation for nonsinusoidal waveforms in phase-shifting digital fringe projection profilometry,” Opt. Lett. **34**(4), 416–418 (2009).

**24. **Z. Cai, X. Liu, H. Jiang, D. He, X. Peng, S. Huang, and Z. Zhang, “Flexible phase error compensation based on Hilbert transform in phase shifting profilometry,” Opt. Express **23**, 25171–25181 (2015). [CrossRef]