slmsuite.holography.analysis.image_zernike_fit#

image_zernike_fit(phase_images, grid, order=10, iterations=2, leastsquares=True, unwrap=True, **kwargs)[source]#

Fits sets of Zernike polynomials to a stack of phase_images, up to a desired order. This is done in two steps:

  • First, an iterative approach is used to subtract Zernike orders from each image. If the Zernike aperture is not cropped or occluded, the orthogonality of the Zernike basis makes this a good and exact approach apart from sampling error. However, if the polynomials lose orthogonality, then this process produces a good guess at best.

  • Thus, the second step is to refine the guess with a least squares optimization. This can be time consuming.

Note

The piston term (Zernike ANSI index 0) is omitted from the fit return.

Note

In the future, we might also fit to the derivatives.

Parameters:
  • phase_images (numpy.ndarray (image_count, height, width)) – An image or array of phase_images to fit. A single image is interpreted correctly as (1, h, w) even if (h, w) is passed.

  • grid ((array_like, array_like) OR None) – Components of the meshgrid describing coordinates over the phase_images. If None, makes a grid with unit pitch centered on the phase_images.

  • order (int) – Maximal radial Zernike order for the fitting basis.

  • iterations (int) – Number of times to iterate the subtractive approach.

  • leastsquares (bool) – Whether to do the least squares optimization step.

  • unwrap (bool) – Whether to unwrap the phase images before fitting.

  • **kwargs – Passed to zernike_sum().