Zernike Polynomials Background
Total Page:16
File Type:pdf, Size:1020Kb
Zernike Polynomials • Fitting irregular and non-rotationally symmetric surfaces over a circular region. • Atmospheric Turbulence. • Corneal Topography • Interferometer measurements. • Ocular Aberrometry Background • The mathematical functions were originally described by Frits Zernike in 1934. • They were developed to describe the diffracted wavefront in phase contrast imaging. • Zernike won the 1953 Nobel Prize in Physics for developing Phase Contrast Microscopy. 1 Phase Contrast Microscopy Transparent specimens leave the amplitude of the illumination virtually unchanged, but introduces a change in phase. Applications • Typically used to fit a wavefront or surface sag over a circular aperture. • Astronomy - fitting the wavefront entering a telescope that has been distorted by atmospheric turbulence. • Diffraction Theory - fitting the wavefront in the exit pupil of a system and using Fourier transform properties to determine the Point Spread Function. Source: http://salzgeber.at/astro/moon/seeing.html 2 Applications • Ophthalmic Optics - fitting corneal topography and ocular wavefront data. • Optical Testing - fitting reflected and transmitted wavefront data measured interferometically. Surface Fitting • Reoccurring Theme: Fitting a complex, non-rotationally symmetric surfaces (phase fronts) over a circular domain. • Possible goals of fitting a surface: – Exact fit to measured data points? – Minimize “Error” between fit and data points? – Extract Features from the data? 3 1D Curve Fitting 25 20 15 10 5 0 -0.1 0.1 0.3 0.5 0.7 0.9 1.1 1.3 1.5 Low-order Polynomial Fit 25 y = 9.9146x + 2.3839 R2 = 0.9383 20 15 10 5 0 -0.1 0.1 0.3 0.5 0.7 0.9 1.1 1.3 1.5 In this case, the error is the vertical distance between the line and the data point. The sum of the squares of the error is minimized. 4 High-order Polynomial Fit 180025 1600 140020 1200 1000 15 800 600 10 400 200 5 0 -0.1 0.1 0.3 0.5 0.7 0.9 1.1 1.3 1.5 -200 0 -0.1-400 0.1 0.3 0.5 0.7 0.9 1.1 1.3 1.5 2 16 y = a0 + a1x + a2x + … a16x Cubic Splines 25 20 15 10 5 0 -0.1 0.1 0.3 0.5 0.7 0.9 1.1 1.3 1.5 Piecewise definition of the function. 5 Fitting Issues • Know your data. Too many terms in the fit can be numerically unstable and/or fit noise in the data. Too few terms may miss real trends in the surface. • Typically want “nice” properties for the fitting function such as smooth surfaces with continuous derivatives. For example, cubic splines have continuous first and second derivatives. • Typically want to represent many data points with just a few terms of a fit. This gives compression of the data, but leaves some residual error. For example, the line fit represents 16 data points with two numbers: a slope and an intercept. Why Zernikes? • Zernike polynomials have nice mathematical properties. – They are orthogonal over the continuous unit circle. – All their derivatives are continuous. – They efficiently represent common errors (e.g. coma, spherical aberration) seen in optics. – They form a complete set, meaning that they can represent arbitrarily complex continuous surfaces given enough terms. 6 Orthogonal Functions • Orthogonal functions are sets of surfaces which have some nice mathematical properties for surface fitting. • These functions satisfy the property ⎧C i = j V (x, y)V (x, y)dxdy = j ∫∫ i j ⎨ A ⎩ 0 Otherwise where Cj is a constant for a given j Orthogonality and Expansion Coefficients Linear Expansion W(x, y) = ∑a iVi (x, y) i W(x, y)Vj (x, y) = ∑aiVi (x, y)Vj (x, y) i W(x, y)V (x, y)dxdy = a V (x, y)V (x, y)dxdy ∫∫ j ∑ i ∫∫ i j A i A 1 a = W(x, y)V (x, y)dxdy j ∫∫ j C j A 7 Orthogonality - 1D Example Consider the integral 2π ∫sin()(mx cos m'x )dx where m and m' are integers 0 1 2π = ∫[]sin()()m + m' x + sin m − m' x dx 2 0 x=2π 1 ⎡cos(m + m')x cos(m − m')x ⎤ = − ⎢ + ⎥ 2 ⎣ m + m' m − m' ⎦ x=0 = 0 Orthogonality - 1D Example Two sine terms 2π ∫sin()(mx sin m'x )dx where m and m' are integers 0 1 2π = − ∫[]cos()()m + m' x − cos m − m' x dx 2 0 x=2π 1 ⎡sin(m + m')x sin(m − m')x ⎤ = − ⎢ − ⎥ 2 ⎣ m + m' m − m' ⎦ x=0 = 0 if m ≠ m’ !!! 8 Orthogonality - 1D Example Two sine terms with m = m’ 2π ∫sin()(mx sin m'x )dx where m and m' are integers 0 2π = ∫sin 2 ()mx dx 0 x=2π ⎡x sin(2mx)⎤ = ⎢ − ⎥ ⎣ 2 4m ⎦ x=0 = π Similar arguments for two cosine terms Orthogonality - 1D Example From the previous arguments, we can define ⎧ ⎛ j ⎞ ⎪ cos⎜ x⎟ ⎪ ⎝ 2 ⎠ j even Vj = ⎨ ⎛ j+1 ⎞ j odd ⎪sin⎜ x⎟ ⎩⎪ ⎝ 2 ⎠ Note that when j = 0, V0 = 1 and 2π 2π V x V x dx= dx= 2π ∫ 0()0 () ∫ 0 0 so the constant Cj = 2π for j = 0, and Cj = π for all other values of j. 9 Orthogonality - 1D Example The functions satisfy the orthogonality condition over [0, 2π] 2π ⎧(1+δ )π i = j V x V x dx= i0 ∫ i ()j () ⎨ 0 ⎩ 0 Otherwise where δ is the Kronecker delta function defined as ⎧1 i = j δij = ⎨ ⎩0 Otherwise Fit to W(x) = x j aj 7 0 π 1 -2 6 2 0 5 4 3 -1 W(x) 1 term 3 4 0 3 terms 11 terms 5 -0.6666 2 6 0 1 7 -0.5 0 01234567 8 0 -1 9 -0.4 10 0 10 Extension to Two Dimensions In many cases, wavefronts take on a complex shape defined over a circular region and we wish to fit this surface to a series of simpler components. Wavefront Fitting -0.003 x = + 0.002 x + 0.001 x 11 Unit Circle Divide the real y radial coordinate by the maximum radius to get a normalized coordinate ρ ρ θ 1 x Orthogonal Functions on the Unit Circle • Taylor polynomials (i.e. 1, x, y, x2, xy, y2,….) are not orthogonal on the unit circle. 2π 1 ⎧C i = j V (ρ,θ)V (ρ,θ)ρdρdθ = j ∫∫ i j ⎨ 0 0 ⎩ 0 Otherwise where Cj is a constant for a given j Many solutions, but let’s try something with the form Vi (ρ,θ) = Ri (ρ) Θi (θ) 12 Orthogonal Functions on the Unit Circle • The orthogonality condition separates into the product of two 1D integrals ⎡ 1 ⎤⎡2π ⎤ ⎧C i = j R (ρ)R (ρ)ρdρ Θ (θ) Θ (θ)dθ = j ⎢∫ i j ⎥⎢ ∫ i j ⎥ ⎨ ⎣ 0 ⎦⎣ 0 ⎦ ⎩ 0 Otherwise This has extra ρ in it, so This looks like the 1D Example, we need different functions so sin(mθ) and cos(mθ) a possibility ANSI Standard Zernikes ⎪⎧ NmR m (ρ)cosmθ ;for m ≥ 0 Zm (ρ,θ) = n n n ⎨ m m ⎩⎪ − Nn Rn (ρ)sinmθ ;for m < 0 Azimuthal Double Index Component n is radial order Radial m is azimuthal Component frequency Normalization ANSI Z80.28-2004 Methods for Reporting Optical Aberrations of Eyes. 13 ANSI Standard Zernikes (n− m )/ 2 s m (−1) (n −s)! n−2s Rn (ρ) = ∑ ρ s=0 s![]0.5(n + m) −s ![]0.5(n − m) −s ! only depends on |m| (i.e. same Constant that depends Powers of ρ for both sine & on n and m cosine terms The Radial polynomials satisfy the orthogonality equation 1 δ R m (ρ)R m (ρ)ρdρ= nn' ∫ n n' 0 2n+2 ANSI Standard Zernikes m 2n+2 Nn = 1+δm0 constant that depends on n & m 14 Orthogonality 2π1 ⎧C for n = n';m = m' Zm'(ρ,θ)Zm(ρ,θ)ρdρdθ = n,m ∫∫ n' n ⎨ 0 0 ⎩0 Otherwise 2π⎧ cos(m'θ) ⎫⎧ cos(mθ) ⎫ Nm'Nm dθ n' n ∫⎨ ⎬⎨ ⎬ 0 ⎩sin()−m'θ ⎭⎩sin()−mθ ⎭ 1 ⎧C for n = n';m = m' × Rm'(ρ)Rm(ρ)ρdρ = n,m ∫ n' n ⎨ 0 ⎩0 Otherwise Orthogonality m' m ⎡ δn'n ⎤ ⎧Cn,m for n = n';m = m' Nn' Nn []δm'm()1+δm0 π ⎢ ⎥ = ⎨ ⎣2n+2⎦ ⎩0 Otherwise This equals zero unless m=m’ This equals zero So this portion is unless n=n’ satisfied What happens when n=n’ and m=m’? 15 Orthogonality When n=n’ and m=m’ m 2 ⎡ 1 ⎤ ()Nn []()1+δm0 π ⎢ ⎥ = Cn,m ⎣2n +2⎦ ⎡2n+2⎤ ⎡ 1 ⎤ ⎢ ⎥ []()1+δm0 π ⎢ ⎥ = Cn,m ⎣1+δm0 ⎦ ⎣2n +2⎦ Cn,m = π Orthogonality 2π1 Zm' (ρ,θ)Zm(ρ,θ)ρdρdθ = πδ δ ∫∫ n' n n'n m'm 0 0 16 The First Few Zernike Polynomials 0 Z0 (ρ,θ) =1 −1 Z1 ()ρ,θ = ρsin θ 1 Z1()ρ,θ = ρcosθ −2 2 Z2 ()ρ,θ = 6()ρ sin 2θ 0 2 Z2 ()ρ,θ = 3()2ρ −1 2 2 Z2 ()ρ,θ = 6()ρ cos 2θ Zernike Polynomials ρ 0 Z0 −1 1 Z1 Z1 Polynomial, Polynomial, −2 0 2 Z2 Z2 Z2 Radial −3 −1 1 3 Z3 Z3 Z3 Z3 −4 −2 0 2 4 Z4 Z4 Z4 Z4 Z4 Azimuthal Frequency, θ 17 Caveats to the Definition of Zernike Polynomials • At least six different schemes exist for the Zernike polynomials. • Some schemes only use a single index number instead of n and m. With the single number, there is no unique ordering or definition for the polynomials, so different orderings are used. • Some schemes set the normalization to unity for all polynomials.