Patent ID: 7577288

Claim:
A sample inspection apparatus comprising: an optical image scanning unit configured to scan an optical image of a sample to be inspected; a reference image generating unit configured to generate a reference image to be compared with the optical image on the basis of design data of the sample to be inspected; a first SSD (Sum of the Squared Difference) calculating unit configured to calculate the displacement amount from a preliminary alignment position of the optical image and the reference image to a position where the SSD (Sum of the Squared Difference) of a pixel value of the optical image and a pixel value of the reference image becomes minimum; a least-square method calculating unit configured to calculate the displacement amount from the preliminary alignment position of the optical image and the reference image, by least-square method by solving a correlation matrix equation using a value obtained by space differentiating the reference data in the x direction and a value obtained by space differentiating the reference data in the y direction; a second SSD calculating unit configured to calculate the SSD of the pixel value of the optical image and the pixel value of the reference image at a position displaced by the displacement amount calculated by the least-square method calculating unit from the preliminary alignment position of the optical image and the reference image; a determining unit configured to determine which of a minimum SSD obtained as the result of the calculation by the first SSD calculating unit and the SSD obtained as the result of the calculation by the second SSD calculating unit is a smaller SSD; a position correcting unit configured to correct the preliminary alignment position of the optical image and the reference image to a position where the smaller SSD determined by the determining unit is obtained; and a comparing unit configured to compare the optical image and the reference image whose alignment position has been corrected.