# Using Spherical-Harmonics Expansions for Optics Surface Reconstruction from Gradients

^{1}

^{2}

^{3}

^{4}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Shack–Hartmann Wavefront Sensor

## 3. Wavefront Reconstruction Method

#### 3.1. Matrix Assembly

#### 3.2. Least-Squares Method and Singular Value Decomposition

#### 3.3. Wavefront Retrieving

## 4. Half Circular Harmonics

## 5. Classical Zernike Decomposition

## 6. Legendre Polynomials for Square and Rectangular Domains

## 7. OpenWavefrontReconstructor Implementation Details

- A mock-up generator of various types of incident wavefronts (see Section 8.1 for specific functions).
- Implementation of different wavefront reconstruction algorithms: Zernike polynomials and Half Circular Harmonics for circular domains, and Legendre polynomials for square domains.
- Runtime selection of the linear algebra library to perform the algebraic computations
- Time profiling of the linear algebraic operations (mainly the CPU time (aka the process time) needed to generate the matrices $\mathit{M}$, and $\mathit{R}$ defined in Equations (8) and (11), and also to record the time of the matrix-vector product for performing the operation described in Equation (11)).

- The user can choose the input wavefront as a simulated optical field generated by the mock-up generator, or as a direct input from a sensor. Usually, the sensor vendors provide libraries that can be used to retrieve information such as the focal spots coordinates, wher the slopes are measured, and obviously these also provide the slopes. These coordinates and slopes are the inputs received by OpenWavefrontReconstructor, and are used to configure the matrices $\mathit{M}$ and $\mathit{R}$ defined by Equations (8) and (11).
- Similarly, the user can choose the particular algorithm that will perform the wavefront reconstruction, which can be instantiated as an object from the available classes representing the different approaches (see the previous enumeration list—item 2—for the list of available polynomials).
- Finally, the user can also select, at runtime, the linear algebra library to perform the linear algebraic operations. In version 1.0.0 of OpenWavefrontReconstructor, only the armadillo library is merged in the code; however, we plan to include more options, and the user can also implement the libraries of his/her preference. OpenWavefrontReconstructor’s design is intended to provide an easy-to-follow (nearly copy-paste) environment to implement new linear algebra libraries.

## 8. Numerical Results and Discussion

#### 8.1. Testing Functions

#### 8.2. Qualitative Reconstruction

#### 8.3. Accuracy

#### 8.4. Performance

## 9. Conclusions

## Acknowledgments

## Author Contributions

## Conflicts of Interest

## References

- Geary, J.M. Introduction to Wavefront Sensors; SPIE: Bellingham, WA, USA, 1995; p. 168. [Google Scholar]
- Liang, L.; Grimm, B.; Goelz, S.; Bille, J.F. Objective measurement of wave aberrations of the human eye with the use of a Hartmann–Shack wave-front sensor. J. Opt. Soc. Am. A
**1994**, 11, 1949–1957. [Google Scholar] [CrossRef] - Booth, M. Adaptive optics in microscopy. Philos. Trans. R. Soc. A Math. Phys. Eng. Sci.
**2007**, 365, 2829–2843. [Google Scholar] [CrossRef] [PubMed] - Rukosuev, A.L.; Kudryashov, A.V.; Lylova, A.N.; Samarkin, V.V.; Sheldakova, Y.V. Adaptive optics system for real-time wavefront correction. Atmos. Ocean. Opt.
**2015**, 28, 381–386. [Google Scholar] [CrossRef] - Bon, P.; Maucort, G.; Wattellier, B.; Monneret, S. Quadriwave lateral shearing interferometry for quantitative phase microscopy of living cells. Opt. Express
**2009**, 17, 13080–13094. [Google Scholar] [CrossRef] [PubMed] - Chanteloup, J.C. Multiple-wave lateral shearing interferometry for wave-front sensing. Appl. Opt.
**2005**, 44, 1559–1571. [Google Scholar] [CrossRef] [PubMed] - Shen, W.; Chang, M.W.; Wan, D.S. Zernike polynomial fitting of lateral shearing interferometry. Opt. Eng.
**1997**, 36, 905–914. [Google Scholar] [CrossRef] - Bakshi, S.; Yang, Y.H. Shape from shading for non-Lambertian surfaces. In Proceedings of the 1st International Conference on Image Processing, Austin, TX, USA, 13–16 November 1994; Volume 2, pp. 130–134. [Google Scholar]
- Geary, J.M. High-energy laser wavefront sensors. Proc. SPIE
**1991**, 1414. [Google Scholar] [CrossRef] - Doane, J.F.; Slade, S.G. An introduction to wavefront-guided refractive surgery. Int. Ophthalmol. Clin.
**2003**, 43, 101–117. [Google Scholar] [CrossRef] [PubMed] - Zernike, v.F. Beugungstheorie des schneidenver-fahrens und seiner verbesserten form, der phasenkontrastmethode. Physica
**1934**, 1, 689–704. (In German) [Google Scholar] [CrossRef] - Trevino, J.P.; Gómez-Correa, J.E.; Iskander, D.R.; Chávez-Cerda, S. Zernike vs. Bessel circular functions in visual optics. Ophthalmic Physiol. Opt.
**2013**, 33, 394–402. [Google Scholar] [CrossRef] [PubMed] - Mahajan, V.N.; Dai, G.M. Orthonormal polynomials in wavefront analysis: Analytical solution. J. Opt. Soc. Am. A
**2007**, 24, 2994–3016. [Google Scholar] [CrossRef] - Nirmaier, T.; Pudasaini, G.; Bille, J. Very fast wave-front measurements at the human eye with a custom CMOS-based Hartmann-Shack sensor. Opt. Express
**2003**, 11, 2704–2716. [Google Scholar] [CrossRef] [PubMed] - Gerard, A.; Mourou, G.K.; Sandner, W.; Collie, J.L. ELI White Book; Andreas Thoss: Berlin, Germany, 2011. [Google Scholar]
- Noll, R.J. Zernike polynomials and atmospheric turbulence. J. Opt. Soc. Am.
**1976**, 66, 207–211. [Google Scholar] [CrossRef] - Golub, G.H.; Van Loan, C.F. Matrix Computations, 4th ed.; The Johns Hopkins University Press: Baltimore, MA, USA, 2013. [Google Scholar]
- Singular Value Decomposition. Available online: http://mathworld.wolfram.com/SingularValueDecomposition.html (accessed on 28 November 2017).
- Sanderson, C.; Curtin, R. Armadillo: A template-based C++ library for linear algebra. J. Open Source Softw.
**2016**, 1, 26. [Google Scholar] [CrossRef] - OpenWavefrontReconstructor’s Github Repository. Available online: https://github.com/SciCompDEV (accessed on 28 November 2017).
- Coefficient of Determination. Available online: https://en.wikipedia.org/wiki/Coefficient_of_determination (accessed on 28 November 2017).

Sample Availability: The source code of the library OpenWavefrontReconstructor can be found in https://github.com/SciCompDEV. |

**Figure 1.**(

**a**) Side view of a simplified Shack–Hartmann wavefront sensor scheme; (

**b**) top view of the spotfield produced by a perfectly plane wavefront hitting a lenslet array.

**Figure 2.**The mappings to transform the coordinates from the original Cartesian set ${\Gamma}_{1}\phantom{\rule{3.33333pt}{0ex}}=\phantom{\rule{3.33333pt}{0ex}}\left(\right)open="\{"\; close="\}">(\xi ,\eta )|\phantom{\rule{4pt}{0ex}}{\xi}^{2}+{\eta}^{2}1$ to the target set ${\Gamma}_{3}=\left(\right)open="\{"\; close="\}">(\mu ,\phi )|1\mu 0\phantom{\rule{4pt}{0ex}}\phantom{\rule{4pt}{0ex}}\phantom{\rule{4pt}{0ex}}\phantom{\rule{4pt}{0ex}}0\phi 2\pi $.

**Figure 3.**A visual representation of the different possibilities offered by the library for wavefront reconstruction.

**Figure 4.**Topview of the wavefronts used to measure the reconstruction algorithm’s accuracy. The functions depicted are as follows. (

**a**) a tilted plane, both around the x- and y-axis; (

**b**) the function ${f}_{1}$ (see Equation (27)); (

**c**) a centered Gaussian; (

**d**) and off-centered Gaussian; (

**e**) a centered super-Gaussian of order 4; and (

**f**) a centered super-Gaussian of order 6.

**Figure 5.**Qualitative reconstruction of several wavefronts, using Half Circular Harmonics, with $J=81$. The functions depicted are: (

**a**) the test function ${f}_{1}$ (see Equation (27), and Figure 4b for the top view); (

**b**) a centered Gaussian (see Figure 4c); (

**c**) an off-centered Gaussian (see Figure 4d); and (

**d**) a centered super-Gaussian of order 6 (see Figure 4f).

**Figure 6.**Compared accuracy (1-(Coefficient of determination)) vs. J (number of polynomial terms) between Half Circular Harmonics (HCH) and the Zernike (Z])polynomials, for the test functions (

**a**) Tilted Plane (TP/TP*), ${f}_{1}$, (

**b**) a centered Gaussian (GC), an off-centered Gaussian (GOC), and (

**c**) super-Gaussians of order 4 (SG4) and 6 (SG6).

**Figure 7.**Compared Root Mean Square (R.M.S.) vs. J (number of polynomial terms) between Half Circular Harmonics (HCH) and the Zernike (Z) polynomials, for the test functions (

**a**) Tilted Plane (TP), ${f}_{1}$, (

**b**) a centered Gaussian (GC), an off-centered Gaussian (GOC), and (

**c**) super-Gaussians of order 4 (SG4) and 6 (SG6).

**Figure 8.**Processing times (CPU times) for different grid sizes (I), number of polynomial terms (J), and matrix operations. SVD is Singular Value Decomposition, VSUG represents the product $\mathit{V}{\mathit{S}}^{-\mathbf{1}}{\mathit{U}}^{\mathit{T}}\mathit{G}$ (Equation (10)), and RA the product $\mathit{RA}$ (Equation (11)). (

**a**) matrix operations for a system with $I=648$; (

**b**) matrix operations for a system with $I=2724$; (

**c**) the ratio between SVD and VSGU CPU times, ${t}_{\mathrm{SVD}}/{t}_{\mathrm{VSGU}}$; the arrow indicates increasing I, and I takes the values $I=276,\phantom{\rule{4pt}{0ex}}648,\phantom{\rule{4pt}{0ex}}1184,\phantom{\rule{4pt}{0ex}}1876,\phantom{\rule{4pt}{0ex}}2724,\phantom{\rule{4pt}{0ex}}3720$, and 4872. In (

**a**,

**c**), $a(8I{J}^{2}+8{J}^{3})$ is the theoretical flops times a scaling constant a.

© 2017 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 (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Solano-Altamirano, J.M.; Vázquez-Otero, A.; Khikhlukha, D.; Dormido, R.; Duro, N.
Using Spherical-Harmonics Expansions for Optics Surface Reconstruction from Gradients. *Sensors* **2017**, *17*, 2780.
https://doi.org/10.3390/s17122780

**AMA Style**

Solano-Altamirano JM, Vázquez-Otero A, Khikhlukha D, Dormido R, Duro N.
Using Spherical-Harmonics Expansions for Optics Surface Reconstruction from Gradients. *Sensors*. 2017; 17(12):2780.
https://doi.org/10.3390/s17122780

**Chicago/Turabian Style**

Solano-Altamirano, Juan Manuel, Alejandro Vázquez-Otero, Danila Khikhlukha, Raquel Dormido, and Natividad Duro.
2017. "Using Spherical-Harmonics Expansions for Optics Surface Reconstruction from Gradients" *Sensors* 17, no. 12: 2780.
https://doi.org/10.3390/s17122780