1. An inspection method comprising: acquiring an optical image of a pattern formed in a sample; generating a reference image corresponding to the optical image; comparing the optical image and the reference image using a die-to-database method to detect a defect in the optical image and storing information on the defect; regenerating a reference image by reflecting a dimension distribution of a pattern in the surface of the sample on the reference image; and re-comparing an optical image in which a defect is detected by the comparison using the die-to-database method and the regenerated reference image which corresponds to the optical image using the die-to-database method to detect the defect in the optical image in which the defect has been detected, storing information on the defect when the defect is redetected, and determining that the optical image has no defect when the defect is not detected from the optical image in which the defect has been detected.