1. A method of measuring an overlay error between first and second targets having respective actual first target parameters and actual second target parameters and that are respectively associated with first and second patterns that surround the first and second targets and that have respective actual first pattern parameters and actual second pattern parameters, the method comprising: a) illuminating the first and second targets to generate a scattered light component and a specular light component having a relative phase; b) using an imaging system having an image plane, capturing the scattered and specular light components at the image plane to form at least three images, wherein the relative phase is different for the at least three images; c) performing an analytical regression to determine from the at least three images a complex amplitude of an optical field of the scattered light component at the image plane; d) using the complex amplitude of the optical field of the scattered light component to obtain estimated first and second target parameters and estimated first and second pattern parameters; e) performing a first numerical regression using an image model of the imaging system, including inputting into the image model the estimated first and second target parameters and the estimated first and second pattern parameters to generate a modeled image, wherein the first numerical regression iteratively compares the modeled image to the measured image and modifies the estimated first and second target parameters and the estimated first and second pattern parameters to minimize a difference between the modeled image and the measured image to determine the actual first and second target parameters and the actual first and second pattern parameters; f) determining an optimum phase shift from the actual first and second target parameters; g) capturing an image of the first and second targets using the optimum phase; and h) performing a second numerical regression using the image model and the image captured in act g) to determine a relative position between the first and second targets that defines the overlay error.