A reticle is inspected with an imaging system to obtain a measured image of a structure on the reticle, and the structure has an unknown critical dimension (CD). Using a model, a calculated image is generated using a design database that describes a pattern used to form the structure on the reticle. The model generates the calculated image based on: optical properties of reticle materials of the structure, a computational model of the imaging system, and an adjustable CD. A norm of a difference between the measured and calculated images is minimized by adjusting the adjustable CD and iteratively repeating the operation of generating a calculated image so as to obtain a final CD for the unknown CD of the structure. Minimizing the norm of the difference is performed simultaneously with respect to the adjustable CD and one or more uncertain parameters of the imaging system.