Wavefront sensing is a powerful technique to assess and quantify the aberrations
present in optical systems. Turning this idea around and assuming an ideal optical
system, it can also be used to accurately measure the three-dimensional shape
of transparent or reflecting objects placed inside the optical setup. Subsequent
processing of the obtained images often involves the separation of low and high
frequency spatial modes, which for the case of circular objects or pupils are conventionally
taken to be Zernike polynomials. In this work we develop fast and
highly parallel algorithms to accurately compute the Zernike mode coefficients of
a given wavefront image. We then extend this method to improve the performance
in the more complicated and realistic cases when the pupil or the object are not
perfectly circular.