The difference data between the real patter data Sij, and a 55 window with
a noticed pixel in the center and the design pattern data Rij obtained by the design
pattern data of the window being shifted in a plurality of directions with respect
to the design pattern data Rij is found by a shift direction operation section,
and the design pattern data in the direction in which the total of the pixels is
minimum is selected from the difference data by a selection section, the difference
between the central pixels Sij, Qij of the selected design pattern data and the
central pixels Sij, Qij of the windows of the real pattern data is found by a difference
operation section, and the difference and a threshold are compared in a defect
judgement section, and thereby the pattern inspection of the object is carried out.