The article presents a new method for resolving measurement ambiguity in diffractive image microscopy (D.I.M.) for automated optical inspection (AOI) in advanced manufacturing. The D.I.M. is developed as a new microscopic profilometry for six-degrees-freedom (6DOF) surface reconstruction using a multiple-layer perceptron (MLP) to learn the underlying relationship between detected microscopic images and multiple surface geometric properties of the sample. To ensure the validity of the proposed method, there should be a one-to-one correspondence between the microscopic image and surface properties, and matching ambiguity has to be avoided through machine learning. Optical aberration exists in the microscope as the system default property is generally ineffective in generating the unique one-to-one corresponding optical transformation. By inserting additional aberration into the D.I.M., the degree of optical aberration can be quantitatively controlled to avoid mapping ambiguity between the detected diffractive image and the measured surface geometry. Experimental results showed that measurement accuracy can be achieved with a maximum height error of 1.33 μm and less than 0.123° in tilting angle. With the proposed AF-based D.I.M., it was verified that the original measurement ambiguity can be effectively avoided. Measurement errors can be further minimized by building a finer database. The proposed method is proven capable of measuring and reconstructing 3D surfaces by detecting the surface position and its orientation.