Etracting Wavefront Error From Shack-Hartmann Images Using Spatial Demodulation Edwin J. Sarver, PhD; Jim Schwiegerling, PhD; Raymond A. Applegate, OD, PhD ABSTRACT PURPOSE: To determine whether the spatial demodulation processing of Shack-Hartmann images is suitable for etracting wavefront gradients for ocular wavefront sensors. METHODS: We developed a custom software program to implement the spatial demodulation technique. To test the algorithm s performance, we generated simulated spot images and obtained an eye eamination image. We generated a collection of simulated aberrated spot images corresponding to: astigmatic wavefront ( 5.00 2.00 17), highly aberrated defocus ( 20.00 diopters [D]), high-resolution defocus ( 0.01 D), and third-order aberrations (trefoil and coma). The eye eamination image and its measured Zernike coeffi cients were obtained from a Shack-Hartmann ocular aberrations system. We evaluated the output from the algorithm in terms of comparing the results to the known Zernike coeffi cients (for the simulated images) or the previously measured Zernike coeffi cients (for the eye eamination image). RESULTS: The spatial demodulation algorithm was able to correctly recover the aberrations to better than 1/100 (0.01) D for the simulated spot images. The processing of the eye eamination image yielded results within approimately 1/4 (0.25) D to the values provided by the Shack-Hartmann system. CONCLUSIONS: From the set of simulated images and the eye eamination image used to test the spatial demodulation technique, it appears that the method is suitable for application in ocular wavefront aberrations Shack-Hartmann systems. The method appears capable of accurately processing high levels of aberrations ( 20.00 D) as well as providing high resolution as evidenced by fi nding the 0.01 D defocus. The method may be especially well suited for processing highly aberrated wavefronts. [J Refract Surg. 2006;22:949-953.] T he Shack-Hartmann wavefront sensor uses a two-dimensional micro lens array to measure the gradient of the wavefront. A two-dimensional image sensor is located at the focal plane of the micro lens array and the array of spots (regular array for an incident plane wave and an irregular array for an aberrated incident wavefront) is digitized for subsequent computer processing. In this technique, local slopes of the wavefront are sampled by the individual lenses of the micro lens array, and by eamining the location of the spots produced for each micro lens relative to its nominal position for an incident plane wave, the gradients of the wavefront can be determined. From these gradients the wavefront can be reconstructed using, for eample, a Zernike or Fourier epansion. The image-processing step is typically performed by finding the centroid of each spot and directly calculating the partial derivatives of the local wavefront slope in the and y directions. 1 It is also possible to obtain the gradients of the wavefront using two-dimensional Fourier transform analysis of the spots image. 2 In this method, which we refer to as the Fourier transform method, there is no need to find the individual spots in the spots image. The Fourier transform method as used here refers to a method to reconstruct the gradient field from the sensor spot image and not simply a method to reconstruct the wavefront from the gradient field. A third method of obtaining the wavefront gradients is closely related to the Fourier transform technique but only involves operations directly on the spots image. 3 We refer to this third method as spatial demodulation processing of Shack-Hartmann spot images. The purpose of this study is to determine whether the spatial demodulation processing of Shack-Hartmann spot images the third method mentioned above is a suitable technique for etracting the ocular wavefront error. From Sarver and Associates Inc, Carbondale, Ill (Sarver); Ophthalmology & Vision Sciences, University of Arizona, Tucson, Ariz (Schwiegerling); and Visual Optics Institute, College of Optometry, University of Houston, Houston, Te (Applegate). The authors have no financial or proprietary interests in the materials presented herein. Correspondence: Edwin J. Sarver, PhD, Sarver and Associates Inc, 131 Phillips Rd, Carbondale, IL 62902. Tel: 618.529.4225; Fa: 618.457.5600; E-mail: ejsarver@aol.com 949 JRSS1106SARVER.indd 949 10/26/2006 12:58:18 PM
Figure 1. Basic geometry of coordinate mapping at a micro lens. Figure 2. Basic spectrum of aberrated spots image with spectral regions of interest identified. MATERIALS AND METHODS Eplaining the operation of the Fourier transform technique first facilitates the eplanation of the spatial demodulation technique to follow. Thus, we begin with a discussion of the Fourier transform technique. It is convenient to represent the Shack-Hartmann spot image for an incident plane wave as the infinite cosine function product g 0 (,y) times a spatial domain aperture function that has a value of 1 inside the pupil and 0 outside. The function g 0 (,y) is given by Eq.(1). 950 g 0 (,y) = ( 1 2 1 2 cos ( 2 p ) ) ( 1 2 1 2 cos ( 2 p y y ) ) (1) In this equation, p and p y are the period of the micro lens array spacing in the and y directions. Although Eq.(1) is not the spots image predicted by diffraction theory, this particular model was selected for its simplicity and its ability to capture the primary spectral peaks of interest that are required for our purposes. The corresponding Fourier transform G 0 (u,v) is a twodimensional array of weighted delta functions: G 0 (u,v)= 1 4 (0,0) 1 8 ( ( u p 1,v ) ( u p 1,v y ) ) (2) For a sufficiently wide aperture, the Fourier transform of the aperture function times the function g 0 is only slightly different from the simple delta functions of Eq.(2). When the local slope of the incident wavefront is not zero, the irradiance distribution can be thought of as being warped by a coordinate transformation as illustrated in Figure 1. In this figure, the value of dely (and similar for delx) is given by dely = dw(y) f (3) dy The irradiance distribution for the aberrated incident wavefront is denoted g 1 (,y) and is given by g 1 (,y) = g 0 [ A(,y), y B(,y)] = ( 1 2 1 2 cos ( 2 p ( A(,y)) ) ) ( 1 1 2 2 cos ( 2 p y (y B(,y)) ) ) (4) where A(,y) and B(,y) are proportional to the partials of the wavefront (see Eq.[3]) with respect to and y. Now, writing the cosine functions as a sum of comple eponentials and taking the Fourier transform, we see that the function A(,y) appears as the argument of a comple eponential shifted to the frequency 1/p along the u ais in the Fourier domain. Likewise, the function B(,y) appears as the argument of a comple eponential shifted to the frequency 1/p y along the v ais in the Fourier domain. This is illustrated in Figure 2. Note that two regions must be processed: one for wavefront derivatives with respect to and the other for wavefront derivatives with respect to y. Now we can enumerate the top level steps used in the Fourier transform technique: 1. Compute the Fourier transform of the Shack-Hartmann image. 2. Isolate the region of interest in the Fourier domain and shift the center of the region of interest to the origin. 3. Compute the inverse Fourier transform and compute the comple angle to yield the wrapped phase. Two additional steps are needed to complete the process. 4. Unwrap the phase and normalize to yield the wavefront gradient; and 5. Reconstruct the wavefront from the gradients. In step 4, we need to unwrap the phase from the arrays (one for dw/d and the other for dw/dy) computed in step 3 and then normalize the arrays to account for the micro lens focal length. Note that the normalization must be performed after the unwrapping. When journalofrefractivesurgery.com JRSS1106SARVER.indd 950 10/26/2006 12:58:21 PM
there are no jump discontinuities (called residues) in the phase arrays, the unwrapping can be accomplished with a simple and fast algorithm as illustrated in Figure 3. In this case, the unwrapping algorithm (in one dimension with U = unwrapped and W = wrapped) can be described as: Set U(0) = W(0) For n=1 to the end of the array do the following D = W(n) W(n 1) If D then D = D 2 If D then D = D 2 U(n) = U(n 1) D This algorithm can be applied down the center of the array and then to the left and right to the edges of the arrays. Where there are phase discontinuities, more elaborate phase unwrapping techniques must be used. 4 Detecting phase discontinuities can be accomplished with a simple and quick test involving the sum of phase deltas around a closed contour of four samples. 4 After unwrapping and normalizing to obtain the wavefront slopes in the and y directions, the wavefront is constructed by fitting to a Zernike or Fourier epansion. SPATIAL DEMODULATION The previous processing using Fourier transforms can also be accomplished entirely in the spatial domain. In this method, the spots image is multiplied by a comple eponential to shift the desired neighborhood to the origin in the frequency domain. This operation can be described by the Fourier shift theorem shown in Eq.(5). e j2 a f() F(s a) (5) FT Figure 3. Simple unwrapping of a wrapped phase array. In Eq.(5), the parameter a is referred to as the shift constant. One comple eponential with the shift constant equal to 1/p is used to obtain the neighborhood for the wavefront slopes with respect to, and another with shift constant equal to 1/p y is used to obtain the neighborhood for the wavefront slopes with respect to y. These multiplications will lead to two complevalued arrays. A low-pass filter is then used to isolate the desired frequency band. The cutoff frequency of this low-pass filter is set to a fraction of the epected width of energy about the main peaks in the Fourier domain. We have empirically set this to 1/(2p ) in this study based on the separation of the main peaks (see Fig 2). This produces the wrapped phase arrays as we obtained in the Fourier method. The remaining steps of unwrapping the phase and reconstructing the wavefront are the same as for the Fourier method. To be practical, the low-pass filter must be efficient as it is computed in the spatial domain using convolution. One eample of such a computationally efficient lowpass filter is the bo filter in which all coefficients of the impulse response are equal. When implemented as a sliding sum, the filter is computed using only 2 adds and 2 subtracts per output sample. We use two passes of this filter to provide a triangle-shaped impulse response, which has much less energy in the side lobes of the filter s frequency response compared to the bo filter. The width of the low-pass filter leads to a region near the edge of the valid data (the edge of the pupil) that has phase errors due to convolution with zero values outside the pupil. Thus, we limit processing to the portion of the pupil inside a contour that accounts for this compromised region. We refer to this valid processing region as the region of interest. In Figure 4A, we denote the edge of the detected pupil with a red circle and the region of interest to be processed by a green region. The main steps in the spatial demodulation technique are: 1. Multiply the spots image by a comple eponential (one for and the other for y). 2. Isolate the region of interest by applying a low-pass filter. 3. Unwrap the phase and normalize to yield the wavefront gradient. 4. Reconstruct the wavefront from the gradients. We developed a custom program to implement the spatial demodulation algorithm above. TEST IMAGES To evaluate the spatial demodulation method, we used simulated spot images for known aberrated wavefronts and also an eamination image acquired from a Shack-Hartmann wavefront sensor. The simulated 951 JRSS1106SARVER.indd 951 10/26/2006 12:58:21 PM
Figure 4. Spatial demodulation processing steps of an astigmatic wavefront. A) Spots image with bounding contour identified. B) Wrapped phase corresponding to dw/d. C) Wrapped phase corresponding to dw/dy. D) Unwrapped phase corresponding to dw/d. E) Unwrapped phase corresponding to dw/dy. F) Wavefront map for reconstructed Zernike epansion. spot images were for an astigmatic wavefront, high dynamic range defocus ( 20.00 diopters [D]), high-resolution defocus ( 0.01 D), and third-order aberrations (trefoil and coma). The eye image had a large amount of background noise, but otherwise represented a normal eye. The amount of noise in the eye image is not uncommon for 50-year-old eyes with typical levels of nuclear opalescence. The simulated spot images were noise free. RESULTS Using the spatial demodulation algorithm, the wavefronts calculated from the simulated aberrated spot 952 images were virtually identical to the incident wavefronts. An eample is illustrated in Figure 4. Figure 4A shows the simulated spots image for a wavefront corresponding to 5.0 2.0 17. Figures 4B and 4C show the wrapped phase for dw/d and dw/dy, respectively. Figures 4D and 4E show the unwrapped phase for dw/d and dw/dy, respectively. Figure 4F shows a map for the reconstructed aberrations. The tet in the upper right corner of this image shows the sphere, cylinder, and ais (calculated from the second-order coefficients), which is equal to the wavefront used to simulate the spots image. The root-mean-square (RMS) errors in the calculated Zernike coefficients for the as- journalofrefractivesurgery.com JRSS1106SARVER.indd 952 10/26/2006 12:58:22 PM
tigmatic and the other simulated cases are shown in the Table. In the Table, we considered only the second order and above coefficients as is typical for reporting ocular aberrations. The errors in the Table are small for all cases. The calculated sphere, cylinder, and ais values for the first four simulation cases were found to be better than 1/100 D compared to that entered in the calculation of the simulation image. For the Shack-Hartmann eamination image (not one of the simulated images shown in the Table), the background noise posed no problem for the spatial demodulation technique. The Zernike coefficients calculated from this technique were not identical to the coefficients calculated from the spot centroids as reported by the Shack-Hartmann instrument, but they were within approimately 1/4 (0.25) D. The spatial demodulation processing yielded a correction of 3.37 2.07 125 compared to 3.12 1.80 125 for the spots centroid method. The difference between our calculation and the Shack-Hartmann system calculation could be due to differences in pupil center calculation, image processing to find the centroids not being perfect, or differences in actual system optical parameters (such as calibration data) compared to the values we estimated for the system. The difference may also be due to how our software and the Shack-Hartmann system software calculated the correction from the Zernike coefficients. DISCUSSION The spectrum illustrated in Figure 2 helps identify requirements for successful wavefront reconstruction using the Fourier transform or spatial demodulation technique. First, the wavefront spectrum must be band limited. In particular, the wavefront slope frequency must be low compared to the micro lens array spot frequency, ie, the value of the wavefront slope should not vary much over the region of a single micro lens. In addition, the width of the spot pattern should be large relative to the spot pitch, ie, a large number of spots should be present across the image. Both the Fourier transform and spatial demodulation techniques compute the wavefront without finding the locations of the individual spots. To shift the spectral region of interest to the center, the Fourier transform method computes the Fourier transform of the spots image and then shifts the array to the center. In the spatial decomposition method, this is accomplished by multiplying by a comple eponential. To isolate the desired band of frequencies of interest, the Fourier transform method sets all samples outside the central region of interest to zero. In the spatial decomposition method, this is accomplished by applying the low-pass filter. To obtain the wrapped wavefront TABLE Root-Mean-Square (RMS) Error in Calculated Zernike Coefficients for the Simulated Spot Images Simulation Case RMS Error (µm) Astigmatic wavefront ( 5.0 2.0 17) 0.01 20.0 D defocus 0.05 20.0 D defocus 0.004 0.01 D defocus 0.0003 1.8 µm trefoil 0.003 2.3 µm coma 0.01 derivatives, the Fourier transform method computes the inverse Fourier transform and then calculates the comple phase. In the spatial decomposition method, we calculate the comple phase. The remaining steps for both techniques are the same. Although not discussed in the algorithm steps above, other processing required includes finding the bounding contour of the region in the spots image to process and adjustments to the wavefront (,y location and derivative scaling) due to the Shack-Hartmann system optical layout. Compared to the Shack-Hartmann spot centroid method, the Fourier transform and spatial demodulation methods do not require finding the location of individual spots, easily allow spots to move outside their initial aperture region, but do require phase unwrapping algorithms. Because of this, the Fourier transform and spatial demodulation methods are especially suited for measuring highly aberrated wavefronts. From the set of simulated images and the eye eamination image used to test the spatial demodulation technique, it appears that the method is suitable for application in an ocular wavefront aberrations Shack-Hartmann system. The method appears capable of accurately processing high levels of aberrations ( 20.00 D) as well as providing high resolution as evidenced by finding the 0.01 D defocus. The method may be especially well suited for processing highly aberrated wavefronts. REFERENCES 1. Tyson RK. Principles of Adaptive Optics. 2nd ed. New York, NY: Academic Press; 1998. 2. Carmon Y, Ribak EN. Phase retrieval by demodulation of a Hartmann-Shack sensor. Optics Communications. 2003;215:285-288. 3. Talmi A, Ribak EN. Direct demodulation of Hartmann-Shack patterns. J Opt Soc Am. 2004;21:632-639. 4. Talmi A, Ribak EN. Two-Dimensional Phase Unwrapping. New York, NY: John Wiley; 1998. 953 JRSS1106SARVER.indd 953 10/26/2006 12:58:23 PM