1. An inspection method comprising: acquiring an optical image of a patterns formed in a sample; generating a reference image corresponding to the optical image; measuring a dimension of the patterns in the optical image; obtaining a dimension distribution of the patterns in a surface of the sample from the dimension of the patterns in 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 the dimension distribution of the patterns in the surface of the sample on the regenerated reference image; and re-comparing an optical image detected as having a defect by the comparison and the regenerated reference image which corresponds to the optical image detected as having a defect by comparison to redetect the defect in the optical image detected as having a defect by the comparison, storing information on the defect when the defect is redetected, and determining that the optical image detected as having a defect by the comparison has no defect when the defect is not redetected from the optical image detected as having a defect by the comparison, wherein the obtaining of the dimension distribution of the patterns in the surface of the sample from the dimension of the patterns in the optical image is a process of calculating an average value of the dimensions of the patterns in units of arbitrary block sizes to obtain the dimension distribution.