|
|
Home | Alpha Telephone | Domain Names | Web Hosting | Get Traffic | xrEvidence | xrSoccer United States Patent
Electron beam exposure or system inspection or measurement apparatus and its method and height detection apparatus An electron beam apparatus includes a movable table which mounts a specimen, an electron optical system including an electron beam source which emits electron beams, an element for deflecting the emitted electron beams, an objective lens for converging and irradiating the deflected electron beams onto the specimen mounted on the table, and a detector for detecting a secondary electron emanated from the specimen by the irradiation of the electron beams. A surface height detection unit is provided which optically detects a height of a surface of the specimen by projecting light onto the surface of the specimen from an oblique direction to the surface and detecting light reflected from the specimen. A focus controller is provided for focusing the electron beam onto the surface of the specimen by controlling a position of the table in a height direction in accordance with the height information from the surface height detection unit.
Attorney, Agent or Firm: CROSS REFERENCE TO RELATED APPLICATION This is a continuation of U.S. application Ser. No. 09/642,014, filed Aug. 21, 2000, now U.S. Pat. No. 6,333,510, which is a continuation of U.S. application Ser. No. 09/132,220, filed Aug. 11, 1998, now U.S. Pat. No. 6,107,637, the subject matter of which is incorporated by reference herein. What is claimed is: 1. An electron beam apparatus, comprising: a table which mounts a specimen and is movable in three dimensional directions; an electron optical system including an electron beam source, an element for deflecting an electron beam emitted from the electron beam source, an objective lens for converging and irradiating the electron beam deflected by the deflection element onto a specimen mounted on the table and a detector for detecting a secondary electron emanated from the specimen by the irradiation of the electron beams; a surface height detection unit which optically detects a height of a surface of the specimen by projecting light onto the surface of the specimen from an oblique direction to the surface and detecting light reflected from the specimen mounted on the table which is continuously moved; and a focus controller which controls a relative position of the table in a height direction while the table is continuously moved between a focus position of the electron optical system and the table in accordance with information of the height from the surface height detection unit. 2. An electron beam apparatus according to claim 1, wherein the surface height detection unit projects a repetitive light pattern onto the surface of the specimen and detects light reflected from the specimen with a linear sensor. 3. An electron beam apparatus according to claim 1, further comprising an image data processing unit which receives secondary electron image data from the detector of the electron optical system and processes the received image data. 4. An electron beam apparatus according to claim 3, further comprising a display unit which displays a secondary electron image of the surface of the specimen outputted from the image data processing unit. 5. A method of obtaining an image of a specimen, comprising the steps of: irradiating and scanning an electron beam onto a specimen set on a table; optically detecting height of a surface of the specimen set on the table by projecting light onto the surface of the specimen from an oblique direction at an angle greater than 60 degrees from a normal to the surface and detecting light reflected from the specimen; focusing the electron beam onto the surface of the specimen by controlling a position of the table in a height direction in accordance with the optically detected height information; obtaining an image of the surface of the specimen by detecting a secondary electron emanated from the surface by the irradiation of the electron beam focused on the surface; and outputting information of a secondary electron image of the surface of the specimen obtained by the obtaining step. 6. A method according to claim 5, wherein the step of outputting includes displaying the secondary electron image on a monitor screen. 7. A method of obtaining an image of a specimen, comprising the steps of: setting a specimen on a table; irradiating and scanning an electron beam on a specimen set on the table which is moving in one direction; optically detecting a height of a surface of the specimen set on the table which is moving in said direction by projecting light onto the surface of the specimen from an oblique direction to the surface and detecting light reflected from the specimen; focusing the electron beam onto the surface of the specimen by controlling a relative position in a height direction while the table is continuously moved between the table and an electron optical system from which said electron beam is irradiated in accordance with information of the optically detected height; obtaining an image of the surface of the specimen by detecting a secondary electron emanated from the surface by the irradiation of the electron beam focused on the surface; and processing the obtained image and outputting the processed image. 8. A method according to claim 7, further comprising a step of displaying a secondary electron image of the surface of the specimen obtained by the obtaining step on a monitor screen. 9. A method of obtaining an image of a specimen, comprising the steps of: irradiating and scanning in one direction an electron beam on a specimen set on a table while the table is moving in another direction which is substantially pernendicular to said one direction; optically detecting a height of a surface of the specimen set on the table which is moving in said another direction; focusing the electron beam onto the surface of the specimen set on the table which is moving in said another direction by controlling a relative position of a height direction while the table is continuously moved between a focus position of an electron optical system from which the electron beam is irradiated and the table in accordance with information of the optically detected height; obtaining an image of the surface of the specimen by detecting a secondary electron emanated from the surface of the specimen by the irradiation of the electron beam focused on the surface; processing the obtained image; and displaying a processed information on a monitor screen. 10. A method according to claim 5, wherein in the step of irradiating and scanning, the electron beam passes through an electrical field which decelerates an electron of the electron beam in the vicinity of the specimen mounting on the table. 11. A method according to claim 9, wherein the focusing the electron beam onto the surface of the specimen is conducted by controlling a position of the table in a height direction in accordance with the optically detected height information. 12. A method according to claim 9, wherein the processing includes inspection or measurement of the obtained image. 13. A method of inspecting a specimen, comprising the steps of: irradiating and scanning an electron beam on a specimen set on a table; optically detecting height of a surface of the specimen set on the table by projecting light onto the surface of the specimen from an oblique direction at an angle greater than 60 degrees from a normal to the surface and detecting light reflected from the specimen; focusing the electron beam onto the surface of the specimen by controlling a relative position of a height direction between a focus position of an electron optical system from which the electron beam is irradiated and the table in accordance with information of the optically detected height; obtaining an image of the surface of the specimen by detecting a secondary electron emanated from the surface of the specimen by the irradiation of the electron beam focused on the surface; processing the obtained image to detect a defect of the specimen; and outputting information of the detected defect on a monitor screen. 14. A method according to claim 13, wherein the step of optically detecting height of the surface of the specimen includes projecting a light pattern onto the surface of the specimen from an oblique direction to the surface and detecting a reflected light from the surface. 15. A method according to claim 13, wherein the step of processing includes comparing the obtained image with another obtained image to detect a defect. 16. A method according to claim 13, wherein the step of outputting information of the detected defect includes displaying an image of the detected defect on a monitor screen. 17. A method according to claim 13, wherein the table continuously moves at least in one direction while optically detecting height of the surface of the specimen set on the table and focusing the electron beam. BACKGROUND OF THE INVENTION The present invention relates to an electron beam exposure or system inspection or measurement or processing apparatus having an observation function using charged particle beams such as electron beams or ion beams and its method and an optical height detection apparatus. Heretofore, a focus of an electron microscope has been adjusted by adjusting a control current of an objective lens while an electron beam image is observed. This process requires a lot of time, and also, a sample surface is scanned by electron beams many times. Accordingly, there is the possibility that a sample will be damaged. In order to solve the above-mentioned problem, in a prior-art technique (Japanese laid-open patent application No. 5-258703), there is known a method in which a control current of an optimum objective lens relative to a height of a sample surface in several samples are measured in advance before the inspection is started and focuses of respective points are adjusted by interpolating these data when samples are inspected. In this method, SEM images obtained by changing an objective lens control current at every measurement point are processed, and an objective lens control current by which an image of a highest sharpness is recorded. It takes a lot of time to measure an optimum control current before inspection. Moreover, there is the risk that a sample will be damaged due to the irradiation of electron beams for a long time. Further, there is the problem that a height of a sample surface will be changed depending upon a method of holding a wafer during the inspection. Moreover, as the prior-art technique of the apparatus for inspecting a height of a sample, there are known Japanese laid-open patent application No. 58-168906 and Japanese laid-open patent application No. 61-74338. According to the above-mentioned prior art, in the electron beam apparatus, the point in which a clear SEM image without image distortion is detected and a defect of a very small pattern formed on the inspected object like a semiconductor wafer such as ULSI or VLSI is inspected and a dimension of a very small pattern is measured with high accuracy and with high reliability has not been considered sufficiently. SUMMARY OF THE INVENTION It is therefore an object of the present invention is to provide an electron beam exposure or system inspection or measurement apparatus and a method thereof in which the image distortion caused by the deflection and the aberration of the electron optical system can be reduced, the decrease of the resolution due to the de-focusing can be reduced so that the quality of the electron beam image (SEM image) can be improved and in which the inspection and the measurement of length based on the electron beam image (SEM image) can be executed with high accuracy and with high reliability. It is another object of the present invention is to provide an electron beam exposure or system inspection or measurement apparatus and a method thereof in which the height of the surface of the inspected object can be detected real time and the electron optical system can be controlled real time so that an electron beam image (SEM image) of high resolution without image distortion can be obtained by the continuous movement of the stage, an inspection efficiency and its stability can be improved and in which an inspection time can be reduced. It is a further object of the present invention to provide an electron beam exposure apparatus and a converging ion beam manufacturing apparatus in which very small patterns can be exposed and manufactured without image distortion and with a high resolution. In order to attain the above-mentioned objects, according to the present invention, there is provided an electron beam system inspection or measurement apparatus which is comprised of a detection apparatus including an electron optical system comprising an electron beam source, a deflection element for deflecting electron beams emitted from the electron beam source, and an objective lens for converging and irradiating electron beams deflected by the deflection element on an inspected object, an electron beam image detection optical system for detecting a secondary electron beam image generated from the inspected object by the electron beams deflected by the electron optical system and converged and irradiated, a projection optical system for projecting a luminous flux of a repetitive light pattern or lattice shape on the inspected object from the oblique upper direction of the inspected object and a detection optical system for detecting the position of an optical image by focusing the luminous flux of the repetitive light pattern which was reflected on the surface of the inspected object by the luminous flux of the repetitive light pattern projected by the projection optical system, an optical height detection apparatus arranged so as to optically detect a height of the surface in an area on the inspected object based on the change of the position of an optical image composed of a luminous flux of the repetitive light pattern detected by the detection optical system, a focus controller for focusing electron beams on the inspected object in a properly-focused state by controlling a current flowed to or a voltage applied to an objective lens of the electron optical system on the basis of the height of the surface on the inspected object detected by the optical height detection apparatus and an image processor for inspecting or measuring a pattern formed on the inspected object on the basis of the secondary electron beam image detected by the electron beam image detection optical system. In accordance with the present invention, there is provided an electron beam apparatus comprising a pattern writing apparatus including an electron optical system comprising an electron beam source, a deflection element for deflecting electron beams emitted from the electron beam source, and an objective lens for converging and irradiating electron beams deflected by deflection element on a processed object, a projection optical system for projecting a luminous flux a repetitive light pattern on the processed object from an oblique upper direction of the processed object and a detection optical system for detecting the position of an optical image by focusing the luminous flux of the repetitive light pattern which was reflected on a surface of the processed object by the luminous flux of the repetitive light pattern projected by the projection optical system, an optical height detection apparatus arranged so as to optically detect a height of the surface in an area on the processed object based on the change of the position of an optical image composed of the luminous flux of the repetitive light pattern detected by the detection optical system, and a focus controller for focusing electron beams on the processed object in a properly-focused state by controlling a current flowed to or a voltage applied to the objective lens of the electron optical system on the basis of the height of the surface on the inspected object detected by the optical height detection apparatus. Further, according to the another feature present invention, there is provided an electron beam system inspection or measurement apparatus which is comprised of a detection apparatus including an electron optical system comprising an electron beam source, a deflection element for deflecting electron beams emitted from the electron beam source, and an objective lens for converging and irradiating electron beams deflected by the deflection element on an inspected object, an electron beam image detection optical system for detecting a secondary electron beam image generated from the inspected object by the electron beams deflected by the electron optical system and converged and irradiated, an optical height detection apparatus for optically detecting a height of a surface in an area on the inspected object irradiated by electron beams deflected and converged by the electron optical system, a focus controller for focusing electron beams on the inspected object in a properly-focused state by controlling a current flowed to or a voltage applied to the objective lens of the electron optical system on the basis of the height of the surface on the inspected object detected by the optical height detection apparatus, a deflection controller for correcting an image distortion containing a magnification error of electron beams generated on the basis of the focus control by correcting a deflection amount of the electron optical system to the deflection element on the basis of the height of the surface on the inspected object detected by the optical height detection apparatus, and an image processor for inspecting or measuring a pattern formed on the inspected object on the basis of a secondary electron beam image detected by the electron beam detection optical system. in accordance with the present invention, there is provided an electron beam system inspection or measurement apparatus which is comprised of an electron optical system including an electron beam source, a deflection element for deflecting electron beams emitted from the electron beam source and an objective lens for converging and irradiating electron beams deflected by the deflection element on the inspected object, an electron beam image detection system for detecting a secondary electron beam image generated from the inspected object by the electron beams deflected and converged by the electron optical system, an optical height detection apparatus for optically detecting a height of a surface in an area on the inspected object irradiated by electron beams deflected and converged by the electron optical system, a focus controller for calculating a focus control current or a focus control voltage based on a correction parameter between a height of a surface on the inspected object and a focus control current or a focus control voltage from a height of a surface on the inspected object detected by the optical height detection apparatus and converging electron beams on the inspected object in a properly-focused state by supplying the calculated focus control current or focus control voltage to an objective lens of the electron optical system, and an image processor for inspecting or measuring a pattern formed on the inspected object on the basis of a secondary electron beam image detected by the electron beams image detection optical system. The present invention also provides that the electron beam system inspection or measurement apparatus further includes a deflection controller for correcting an image distortion containing a magnification error of an electron beam image generated on the basis of the focus control by correcting a deflection amount of the electron optical system to a deflection element on the basis of a height of a surface on the inspected object detected by the optical height detection apparatus. According to another feature of the present invention, there is provided an electron beam system inspection or measurement apparatus which is comprised of an electron optical system including an electron beam source, a deflection element for deflecting electron beams emitted from the electron beam source and an objective lens for converging and irradiating electron beams deflected by the deflection element on the inspected object, an electron beam image detection system for detecting a secondary electron beam image generated from the inspected object by the electron beams deflected and converged by the electron optical system, an optical height detection apparatus for optically detecting a height of a surface in a place in which a focus control delay is shifted in an area on the inspected object irradiated with electron beams by the electron optical system, a focus controller for calculating a focus control current or a focus control voltage based on a correction parameter between a height of a surface on the inspected object and a focus control current or a focus control voltage from a height of a surface on the inspected object detected by the optical height detection apparatus and converging electron beams on the inspected object in a properly-focused state by supplying the calculated focus control current or focus control voltage to an objective lens of the electron optical system, and an image processor for inspecting or measuring a pattern formed on the inspected object on the basis of a secondary electron beam image detected by the electron beam image detection optical system. According to the present invention, the electron beam system inspection or measurement apparatus further includes a deflection controller for correcting an image distortion containing a magnification error of an electron beam image generated on the focus control by correcting a deflection amount of the electron optical system to a deflection element on the basis of a height of a surface in a place in which a focus control delay is shifted on the inspected object detected by the optical height detection apparatus. Further, according to the present invention, there is provided an electron beam system inspection or measurement apparatus which is comprised of an electron optical system including an electron beam source, a deflection element for deflecting electron beams emitted from the electron beam source and an objective lens for converging and irradiating electron beams deflected by the deflection element on the inspected object, an electron beam image detection system for detecting a secondary electron beam image generated from the inspected object by the electron beams deflected and converged by the electron optical system, an optical height detection apparatus for optically detecting a height of a surface in a place in which a position displacement corrected amount is shifted in an area on the inspected object irradiated with electron beams by the electron optical system, a focus controller for calculating a focus control current or a focus control voltage based on a correction parameter between a height of a surface on the inspected object and a focus control current or a focus control voltage from a height of a surface in which a position displacement corrected amount is shifted in an area on the inspected object detected by the optical height detection apparatus and converging electron beams on the inspected object in a properly-focused state by supplying the calculated focus control current or focus control voltage to an objective lens of the electron optical system, and an image processor for inspecting or measuring a pattern formed on the inspected object on the basis of a secondary electron beam image detected by the electron beams image detection optical system. According to the present invention, the electron beam system inspection or measurement apparatus further includes deflection controller for correcting an image distortion containing a magnification error of an electron beam image generated on said focus control by correcting a deflection amount of said electron optical system to a deflection element on the basis of a height of a surface in a place in which a position displacement correction amount is shifted on the inspected object detected by the optical height detection apparatus. Further, according to the present invention, the optical height detection apparatus in the electron beam system inspection or measurement apparatus includes a projection optical system for projecting a luminous flux of linear or lattice shape or a repetitive light pattern on the inspected object from the oblique upper direction of the inspected object and a detection optical system for detecting a position of an optical image by focusing a luminous flux reflected on the surface of the inspected object by the luminous flux projected by the projection optical system, and in which a height of a surface of the inspected object is detected on the basis of the change of the position of an optical image detected by the detection optical system. Additionally, according to the present invention, the optical height detection apparatus in the electron beam system inspection or measurement apparatus includes a plurality of projection optical systems for projecting a luminous flux of linear or lattice shape or repetitive light pattern on the inspected object from the oblique upper direction of the inspected object and detection optical systems for detecting a position of an optical image by focusing a luminous flux reflected on the surface of the inspected object by the luminous flux projected by the projection optical systems disposed symmetrically with respect to an optical axis of the electron optical system, and in which position changes of optical images detected by the respective detection optical systems are synthesized and a height of a surface of the inspected object is detected on the basis of the position change of the synthesized optical image. Further, according to the present invention, white light is used as the luminous flux projected by the projection optical system in the optical height detection apparatus of the electron beam system inspection or measurement apparatus. Further, according to the present invention, S-polarized light is used as the luminous flux projected by the projection optical system in the optical height detection apparatus of the electron beam system inspection or measurement apparatus. According to the present invention, there is also provided an electron beam system inspection or measurement apparatus which is comprised of a detection apparatus including an electron optical system comprising an electron beam source, a deflection element for deflecting electron beams emitted from the electron beam source, and an objective lens for converging and irradiating electron beams deflected by the deflection element on an inspected object, an electron beam image detection optical system for detecting a secondary electron beam image generated from the inspected object by the electron beams deflected by the electron optical system and converged and irradiated, a projection optical system for projecting a luminous flux of lattice shape or a repetitive light pattern on the inspected object from the oblique upper direction of the inspected object and a detection optical system for detecting the position of an optical image by focusing the luminous flux of lattice shape or repetitive light pattern which was reflected on the surface of the inspected object by the luminous flux of lattice shape or repetitive light pattern projected by the projection optical system, an optical height detection apparatus arranged so as to optically detect a height of the surface in an area on the inspected object based on the change of the position of an optical image composed of a luminous flux of lattice shape or repetitive light pattern detected by the detection optical system, a focus controller for focusing electron beams on the inspected object in a properly-focused state by controlling a relative position of a height direction between a focus position obtained by the electron optical system and a table for holding the inspected object on the basis of the height of the surface on the inspected object detected by the optical height detection apparatus and an image processor for inspecting or measuring a pattern formed on the inspected object on the basis of the secondary electron beam image detected by the electron beam image detection optical system. According to other features of the present invention, there is provided an electron beam system inspection or measurement method which is comprised of the steps of moving an inspected object at least in a predetermined direction, optically detecting a height of a surface in an area on the inspected object irradiated with electron beams from an optical height detection apparatus on the basis of the change of the position of an optical image composed of a luminous flux of a repetitive light pattern or lattice shape, deflecting electron beams emitted from an electron beam source by a deflection element of an electron optical system and focusing the same on the inspected object by controlling a current flowed to or a voltage applied to an objective lens of the electron optical system based on the height of the surface on the detected inspected object in a properly-focused state, detecting a secondary electron beam image generated from the inspected object by irradiated electron beams deflected and focused in a properly-focused state by an electron beam image detection optical system, and inspecting or measuring a pattern formed on the inspected object based on the detected secondary electron beam image. Further, according to additional features the present invention, there is provided an electron beam system inspection or measurement method comprising the steps of moving an inspected object at least in a predetermined direction, optically detecting a height of a surface in an area on the inspected object irradiated with electron beams by an optical height detection apparatus, deflecting election beams emitted from an electron beams source by a deflection element of an electron optical system by controlling a current flowed to or a voltage applied to an objective lens of the electron optical system on the basis of the height of the surface on the detected inspected object such that the election beams are converged on the inspected object in a properly-focused state, correcting an image distortion containing a magnification error of an electron beam image generated based on the focus control by correcting a deflection amount to a deflection element of the electron optical system, detecting a secondary electron beam image generated from the inspected object by electron beams corrected, deflected, converged in a properly-focused state and irradiated by means of an electron beam detection optical system, and inspecting or measuring a pattern formed on the inspected object on the basis of the detected secondary electron beam image. According to the present invention, there is provided an electron beam system inspection or measurement method which is comprised of the steps of moving the inspected object at least in a predetermined direction, optically detecting a height of a surface in an area on an inspected object irradiated with electron beams from an optical height detection apparatus, calculating a focus control current or a focus control voltage on the basis of a correction parameter between the height of the surface on the inspected object and a focus control current or a focus control voltage, deflecting electron beams emitted from the electron beam source and focusing the same on the inspected object in a properly-focused state by supplying the calculated focus control current or focus control voltage to an objective lens of the electron optical system, detecting a secondary electron beam image generated from the inspected object by irradiated electron beams deflected and focused in a properly-focused state by an electron beam image detection optical system, and inspecting or measuring a pattern formed on the inspected object on the basis of the detected secondary electron beam image. Further, according to the present invention, the electron beam system inspection or measurement method further includes the step of correcting an image distortion containing a magnification error of an electron beam image generated on the basis of the focus control by correcting a deflection amount of a deflection element of the electron optical system on the basis of a height of a surface on the detected inspected object. Additionally, according to the present invention, there is provided an electron beam system inspection or measurement method which is comprised of the steps of moving an inspected object at least in a predetermined direction, optically detecting a height of a surface in an area on the inspected object irradiated with electron beams by an optical height detection apparatus, calculating a focus control current or a focus control voltage on basis of a correction parameter between the height of the surface on the inspected object and a focus control current or a focus control voltage from a height of a surface in a place in which a focus control delay on the detected inspected object is shifted, deflecting electron beams emitted from an electron beam source by a deflection element of an electron optical system and focusing the same on the inspected object in a properly-focused state by supplying the calculated focus control current or focus control voltage to an objective lens of the electron optical system, detecting a secondary electron beam image generated from the inspected object with irradiated electron beams deflected and focused in a properly-focused state by an electron beam image detection optical system, and inspecting or measuring a pattern formed on the inspected object on the basis of the detected secondary electron beam image. There is provided an electron beam system inspection or measurement method which is comprised of the steps of moving an inspected object at least in a predetermined direction, optically detecting a height of a surface in an area on the inspected object irradiated with electron beams by an optical height detection apparatus, calculating a focus control current or a focus control voltage on basis of a correction parameter between the height of the surface on the inspected object and a focus control current or a focus control voltage from a height of a surface in a place in which a position displacement corrected amount on the detected inspected object is shifted, deflecting electron beams emitted from an electron beam source by a deflection element of an electron optical system and focusing the same on the inspected object in a properly-focused state by supplying the calculated focus control current or focus control voltage to an objective lens of the electron optical system, detecting a secondary electron beam image generated from the inspected object with irradiated electron beams deflected and focused in a properly-focused state by an electron beam image detection optical system, and inspecting or measuring a pattern formed on the inspected object on the basis of the detected secondary electron beam image. In accordance with the present invention, there is also provided an electron beam system inspection or measurement method which is comprised of the steps of moving an inspected object at least in a predetermined direction, optically detecting a height of a surface in an area on the inspected object irradiated with electron beams from an optical height detection apparatus, deflecting electron beams emitted from an electron beam source by a deflection element of an electron optical system and focusing the same on the inspected object in a properly-focused state by controlling a relative position of a height direction between a focus position of an electron optical system and a table for holding the inspected object on the basis of a height of a surface on the detected inspected object, detecting a secondary electron beam image generated from the inspected object by irradiated electron beams deflected and focused in a properly-focused state by an electron beam image detection optical system, and inspecting or measuring a pattern formed on the inspected object on the basis of the detected secondary electron beam image. Further, according to the present invention, there is provided an optical height detection apparatus which is comprised of a plurality of projection optical systems for projecting a luminous flux of linear or lattice shape or repetitive light pattern on the inspected object from the oblique upper direction of the inspected object and detection optical systems for detecting a position of an optical image by focusing a luminous flux reflected on the surface of the inspected object by the luminous flux projected by the projection optical systems disposed symmetrically with respect to a predetermined optical axis, and in which position changes of optical images detected by the respective detection optical systems are synthesized and a height of a surface of the inspected object is detected on the basis of the position change of the synthesized optical image. Other features of the present invention include that in the optical height detection apparatus, a one-dimensional or two-dimensional image sensor is used as a detector for detecting the change of the position of the optical image. Further, as the detector for detecting the change of the position of the optical image, a mask having a transmission pattern similar to a projection pattern is vibrated and a photoelectric detector such as a photodiode is disposed behind the mask, whereby the change of the position is detected by a synchronizing-detection. Additionally, a shape formed by repeatedly arranging a plurality of rectangular patterns is used as a shape of luminous flux projected onto an object. Also, white light is used as a luminous flux projected onto an object. Further, a luminous flux is projected onto an object with an angle greater than 60 degrees and S-polarized light is used as a luminous flux projected onto an object. Further, the optical height detection apparatus includes two height detectors, and the two height detectors are disposed symmetrically with respect to a normal from a measured position on an object. Height detection values of the two height detectors are combined so that a height of the same observation position on the object can be constantly detected with high accuracy regardless of the change of the height of the object, the change of the inclination or the surface state of the object. Also, in the optical height detection apparatus, one or a plurality of height measurement patterns are selected from a plurality of pattern images and a height is measured by using these patterns, whereby a height measurement position on the object can be selected. Further, not only a height of an object but also an inclination thereof is detected by an image formed by arranging a plurality of rectangular patterns, and at least one of a height measurement position on the object and a detection error caused by the inclination of the object is corrected by using this information. Additionally, a height distribution on the cross-section of the object is detected by using an image formed by arranging a plurality of rectangular patterns. Further, the image in which a plurality of rectangular patterns are arranged is detected and processed by a two-dimensional image sensor or an arrangement in which a plurality of one-dimensional image sensors are disposed in parallel, whereby a height distribution of a two-dimensional surface of an object can be detected. According to the present invention, there is also provided an electron beam system automatic inspection apparatus which is comprised of an electron optical system for converging electrons emitted from an electron source on a focus, an observer for observing an arbitrary position at which an inspected object is brought by a stage for holding the inspected object and which can be moved within a plane through the electron optical system, a detector for continuously detecting a height of the inspected object in an observation area of the electron optical system by an optical method, and a positioner for constantly maintaining a relative position between a focus position of an electron beam image and the inspected object by using a result of height detection and wherein an automatic inspection can be executed by processing the resultant properly-focused electron beam image to detect a defect. Further, according to the present invention, there is provided an electron beam system automatic inspection method which is comprised of an electron optical system for converging electrons emitted from an electron source on a focus, an observer for observing an arbitrary position at which an inspected object is brought by a stage for holding the inspected object and which can be moved within a plane through the electron optical system, a detector for continuously detecting a height of the inspected object in an observation area of the electron optical system by an optical method, and a positioner for constantly maintaining a relative position between a focus position of an electron beam image and the inspected object by using a result of height detection and wherein an automatic inspection can be executed by processing the resultant properly-focused electron beam image to detect a defect. In accordance with the present invention, the electron beam system automatic inspection apparatus also includes two height detectors. The two height detectors are disposed symmetrical with respect to a normal from an observation position of an electron optical system on an object. Height detection values of the two height detectors are synthesized so that the height of the observation position of the electron optical system on the object can constantly be detected with high accuracy regardless of the change of the height of the object, the change of the inclination, or the surface state of the object. The electron beam system automatic inspection apparatus includes a positioner for constantly maintaining a relative position between the focus position of the electron beam image and the inspected object by using a result of height detection, and in which the automatic inspection can be executed by processing the resultant properly-focused electron beam to detect a defect. Further, according to the present invention, in the electron beam system automatic inspection apparatus, one or a plurality of slits used to measure a height are selected from a plurality of rectangular pattern images and a height is measured by using these slits to thereby select the height measurement position on the object. Thus, the stage scanning and a detection time delay of a height detector or a measurement position displacement caused by an adjustment error of an optical system can be corrected. Further, according to the present invention, in the electron beam system automatic inspection apparatus, not only a height of an object but also an inclination thereof is detected by an image formed by arranging a plurality of rectangular patterns, and at least one of a height measurement position on the object and a detection error caused by the inclination of the object is corrected by using this information. Further, according to the present invention, in the electron beam system automatic inspection apparatus, a height distribution on the cross-section of the object is detected by using an image formed by arranging a plurality of rectangular patterns, and electron beams are properly focused on an arbitrary area of the object by using this information. Further, according to the present invention, in the electron beam system automatic inspection apparatus, the image in which a plurality of rectangular patterns are arranged is detected and processed by a two-dimensional image sensor or an arrangement in which a plurality of one-dimensional image sensors are disposed in parallel, whereby a height distribution of a two-dimensional surface of an object can be detected, and electron beams are properly focused by using this information. Further, according to the present invention, the electron beam system automatic inspection apparatus has a function to control the focus position of the electron beams relative to the scanning of the stage at a sufficiently high speed by the arrangement of the electron optical system, an objective lens or an electrostatic lens or a condenser lens or a combination of one or a plurality of means of a deflection system. By using the inspected object surface height obtained from the optical height detection apparatus, an electron beam image can be obtained under the condition that the relative position between the surface of the inspected object and the focus position of the electron beam can be maintained constant. Further, according to the present invention, the electron beam system automatic inspection apparatus has a function to control the focus position of the electron beams relative to the scanning of the stage at a sufficiently high speed by the arrangement of the electron optical system, an objective lens or an electrostatic lens or a condenser lens or a combination of one or a plurality of means of a deflection system. By using the inspected object surface shape distribution obtained from the optical height detection apparatus, an electron beam image can be obtained under the condition that the relative position between the inspected object surface shape and the orbit of the focus position of the electron beam can be maintained constant. Further, according to the present invention, the electron beam system automatic inspection apparatus includes a Z stage which can finely adjust the height of the surface of the inspected object at a sufficiently high speed, and an electron beam image in which the relative position between the surface of the inspected object and the focus position of the electron beam can be maintained constant can be constantly obtained by using the inspected surface height obtained from the optical height detection apparatus. Further, the present invention utilizes a correction standard pattern made of a stable material which can be prevented from being affected with the irradiation of charged particle beams, the surface of which has a pattern that can be observed by a charged particle optical system and which has at least more than two stepped differences or inclinations of which height differences are clear. Further, the present invention is a height detection apparatus and a charged particle optical system correction method using the above-mentioned standard pattern fixed to a stage for holding an inspected object. Further, the present invention is an electron beam system automatic inspection apparatus capable of correcting a height detection apparatus and an electron optical system by using the above-mentioned standard pattern fixed to a stage for moving an inspected object. Furthermore, the present invention is an electron beam system automatic inspection apparatus including an electron optical system capable of changing a deflection amount of electron beams in real time in response to a fluctuation of a height of a sample surface and which has a function to correct a magnification based on a fluctuation of an inspected object surface as well as to adjust the focus of electron beams. Furthermore, the present invention is characterized by the application to apparatus (electron beam system length measuring apparatus, scanning electron microscope, electron beam exposing apparatus, converging ion beam manufacturing apparatus) using a charged particle optical system of the above-mentioned height detection apparatus. As described above, according to the above-mentioned arrangement, without being affected by the surface state of the inspected object, the image distortion caused by the deflection and the aberration of the electron optical system can be reduced and the decrease of the resolution due to the de-focusing can be reduced so that the quality of the electron beam image (SEM image) can be improved. Thus, the inspection and the measurement of length based on the electron beam image (SEM image) can be executed with high accuracy and with high reliability. Furthermore, according to the above-mentioned arrangement, since the height of the surface of the inspected object can be detected in real time and the electron optical system can be controlled in real time, an electron beam image (SEM image) of high resolution without image distortion can be obtained by the continuous movement of the stage, and the inspection can be executed. Hence, an inspection efficiency and its stability can be improved. In addition, an inspection time can be reduced. These and other objects, features and advantages of the present invention will become more apparent from the following description when taken in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS FIGS. 1(a)-1(d) show a semiconductor wafer and image obtained at different areas thereof so as to explain that electron beams need be focused on an inspected object such as a semiconductor wafer in an electron beam inspection according to the present invention. FIG. 2 is a schematic diagram of an electron beam apparatus (SEM apparatus) according to an embodiment of the present invention. FIG. 3 is a schematic diagram showing an electron beam inspection apparatus (SEM inspection apparatus) according to an embodiment of the present invention. FIG. 4 shows an electron beam inspection apparatus (SEM inspection apparatus) according to an embodiment of the present invention. FIGS. 5(a)-5(c) show a semiconductor wafer in which a semiconductor memory is formed according to the present invention and enlarged portions thereof. FIGS. 6(a) and 6(b) show a detection image f1(x, y) and a comparison image g1(x, y) which are compared and inspected in the electron beam inspection apparatus (SEM inspection apparatus) according to the present invention. FIG. 7 shows an electron beam inspection apparatus (SEM inspection apparatus) according to another embodiment of the present invention. FIG. 8 shows a pre-processing circuit forming a part of FIGS. 4 and 7. FIG. 9 shows curves for explaining the contents that are corrected by the pre-processing circuit shown in FIG. 8. FIG. 10 shows a height detection optical apparatus according to an embodiment of the present invention. FIGS. 11(a) and 11(b) are used to explain a principle in which a detection error is reduced by a multi-slit. FIG. 12 is a diagram used to explain a detection error caused by a multiple reflection on a transparent film such as an insulating film existing on a semiconductor wafer or the like. FIG. 13 shows a graph graphing the change of a reflectance versus an incident angle in silicon and resist (a transparent film such as an insulating film) existing on a semiconductor wafer or the like. FIG. 14 shows waveforms used to explain a height detection algorithm processed by a height calculating unit of a height detection apparatus according to an embodiment of the present invention. FIG. 15 shows an arrangement in which a measured position displacement is canceled out by both-side projections of a height detection optical apparatus in a height detection apparatus according to a second embodiment of the present invention. FIG. 16 shows an arrangement in which a detection error is reduced by a polarizing plate of a height detection optical apparatus in a height detection apparatus according to a third embodiment of the present invention. FIG. 17 is a diagram used to explain the manner in which a detection error caused by a detection position displacement when a sample is inclined in the height detection optical apparatus according to the present invention. FIG. 18 is a diagram used to explain the manner in which a detection error caused by the inclination of a sample is eliminated in the height detection optical apparatus according to the present invention. FIGS. 19(a) and 19(b) are diagrams used to explain the manner in which a height is detected by the selection of the slit under the condition that a detection position is not displaced by a height of a sample surface in the height detection apparatus according to the present invention. FIG. 20 is a diagram used to explain a height detection which can correct a detection position displacement caused by a detection time delay and a sample scanning on the basis of the selection of the slit in the height detection apparatus according to the present invention. FIG. 21 is a diagram used to explain the manner in which a height of an arbitrary point can be detected by using detected surface-shape data in the height detection apparatus according to the present invention. FIG. 22 is a diagram used to explain a detection time delay correction method that can be used regardless of a scanning direction of a stage and a projection-detection direction of a multi-slit in the height detection apparatus according to the present invention. FIG. 23 is a diagram used to explain a detection time delay correction method that can be used regardless of a scanning direction of a stage and a projection-detection direction of a multi-slit in the height detection apparatus according to the present invention. FIG. 24 is a diagram used to explain the manner in which a dynamic focus adjustment of electron beam is executed by using surface shape data detected from the height detection apparatus according to the present invention. FIG. 25 shows an arrangement in which a measured position displacement is canceled out by both-side projections in a height detection optical apparatus according to another embodiment of the present invention. FIG. 26 shows an arrangement in which a measured position displacement is canceled out by both-side projections in a height detection optical apparatus according to another embodiment of the present invention. FIG. 27 shows an embodiment in which the same position is constantly detected by elevating and lowering a detector in a height detection optical apparatus according to the present invention. FIG. 28 is a diagram showing a direction of a projection slit and a pattern on a sample in a height detection optical apparatus according to the present invention. FIGS. 29(a) and 29(b) are diagrams showing a detection position displacement and the manner in which a detection position displacement is decreased in a height detection optical apparatus according to the present invention. FIG. 30 shows an example of an arrangement in which a height distribution on a surface is measured in a height detection optical apparatus according to the present invention. FIG. 31 shows waveforms used to explain the embodiment in which a position of a multi-slit pattern is detected by a Gabor filter which is a height detection algorithm processed by a height calculating means in a height detection apparatus according to the present invention. FIG. 32 is a graph in which a slit edge position which is a height detection algorithm processed by a height calculating means is measured in a height detection apparatus according to the present invention. FIGS. 33(a) and 33(b) show an embodiment in which a position of a multi-slit image is measured by a vibrating mask in a height detection apparatus according to the present invention. FIG. 34 shows an electron beam apparatus in which a standard pattern for correction is disposed on an X-Y stage. FIG. 35 shows in a perspective view a standard pattern for correction with an inclined portion. FIGS. 36(a)-36(c) are graphs used to explain a correction curve obtained by a standard pattern for correction in an electron beam apparatus according to the present invention. FIGS. 37(a) and 37(b) show in perspective view standard patterns for correction according to other embodiments of the present invention. FIG. 38 is a flowchart showing a processing for calculating a parameter for correction. FIG. 39 is a flowchart in which a stage is driven at a constant speed and an appearance is inspected while an error is corrected by using a correction parameter in an electron beam inspection apparatus according to the present invention. FIG. 40 is a schematic diagram showing an optical appearance inspection apparatus according to another embodiment of the present invention. FIGS. 41(a) and 41(b) show multi-slit patterns in which the center spacing between the multi-slit patterns is increased and in which the center slit is made wider, respectively. DESCRIPTION OF THE PREFERRED EMBODIMENTS An embodiment of an automatic inspection system for inspecting/measuring a micro-circuit pattern formed on a semiconductor wafer which is an inspected object according to the present invention will be described. A defect inspection of the micro-circuit pattern formed on the semiconductor wafer or the like is executed by comparing inspected patterns and good pattern and patterns of the same kind on the inspected wafer. Also in the case of an appearance inspection using an electron microscope image (SEM image), a defect inspection is executed by comparing pattern images. Furthermore, also in the case of the length measurement (SEM length measurement) executed by a scanning-type electron microscope which measures a line width or a hole diameter of a micro-circuit pattern used to set or monitor a manufacturing process condition of semiconductor devices, the length measurement can be automatically executed by the image processing. In the comparison inspection for detecting a defect by comparing electron beam images of a similar pattern or when a line width of a pattern is measured by processing an electron beam image, a quality of an obtained electron beam image exerts a serious influence upon the reliability of the inspected results. The quality of electron beam image is deteriorated by an image distortion caused by deflection and aberration of an electron optical system and is also deteriorated as resolution is lowered by a de-focusing. The deterioration of the image quality lowers a comparison and inspection efficiency and a length measurement efficiency. Referring now to the drawings, a height of a surface of an inspected object is not even and an inspection is executed over the whole range of heights under the same condition for a wafer as shown in FIG. 1(a), then as shown in FIGS. 1(b)-(d), electron beam images (SEM images) are changed in accordance with the inspection portions (area A, area B, area C). As a result, if an inspection is carried out by comparing an image (electron beam image of area A (height za) of a properly-focused point shown in FIG. 1(b), a de-focused image (electron beam image of area B (height zb) shown in FIG. 1(c), and a defocused image (electron beam image of area C (height zc) shown in FIG. 1(d), then a correct inspected result cannot be obtained. Moreover, in these images, the width of the pattern is changed, and an edge detected result of an image cannot be obtained stably so that the line width and the hole diameter of the pattern also cannot be measured stably. An electron beam apparatus according to an embodiment of the present invention will be described with reference to FIG. 2. An electron beam apparatus 100 composed of an electron beam column for irradiating electron beams on an inspected object (sample) 106 comprises an electron beam source 101 for emitting electron beams, a deflection element 102 for deflecting electron beams emitted from the electron beam source 101 in a two-dimensional fashion, and an objective lens 103 which is controlled so as to focus the electron beam on the sample 106. Specifically, the electron beam emitted from the electron beam source 101 is passed through the deflection element 102 and the objective lens 103 and focused on the sample 106. The sample 106 rests on an XY stage 105 and the position thereof is measured by a laser length measuring system 107. Further, in the case of an SEM apparatus, a secondary electron emitted from the sample 106 is detected by a secondary electron detector 104, and a detected secondary electron signal is converted by an A/D converter 122 into an SEM image. The SEM image thus converted is processed by an image processing unit 124. In the case of the length measuring SEM, for example, the image processing unit 124 measures a distance between patterns of a designated image. Also, in the case of an observation SEM (appearance inspection based on the SEM image), the image processing unit 124 executes a processing such as emphasis of the image or the like. The secondary electron includes a secondary electron with a higher energy level which is sometimes called a back-scattered electron. From the viewpoint of forming scanning electron images, it is not meaningful to discriminate between the back-scattered electron and the secondary electron. In accordance with the present invention, an electron beam image is prevented from being deteriorated in the above-mentioned electron beam apparatus (observation SEM apparatus, length measuring SEM apparatus). The quality of the electron beam image is deteriorated due to image distortion caused by deflection and aberration of the electron optical system, and a resolution is lowered by de-focusing. For preventing the image quality from being deteriorated, the present invention provides, as shown in FIG. 2, a height detection apparatus 200 composed of a height detection optical apparatus 200a and a height calculating unit 200b, a focus control apparatus 109, a deflection signal generating apparatus 108, and an entirety control apparatus 120. The height detection apparatus 200 composed of the height detection optical apparatus 200a and the height calculating unit 200b is arranged substantially similarly to a second embodiment which will be described later, and is installed about an optical axis 110 of an electron beam symmetrically with respect to the sample 106. An illumination optical system of each height detection optical apparatus 200a comprises a light source 201, a condenser lens 202, a mask 203 with a multi-slit pattern, a half mirror 205, and a projection/detection lens 220. A detection optical system of each height detection optical apparatus 200a comprises a projection/detection lens 220, a magnifying lens 264 for focusing an intermediate multi-slit image focused by the projection/detection lens 220 on a line image sensor 214 in an enlarged scale, a mirror 206, a cylindrical lens (cylindrical lens) 213, and a line image sensor 214. By the illumination optical system of the respective height detection optical apparatus which is installed symmetrically, a multi-slit shaped pattern is projected at the measurement position on the sample 106 for detecting an SEM image with the above-mentioned irradiation of electron beams. This regularly-reflected image is focused by the detection optical system of each height detection optical apparatus 200a and thereby detected as a multi-slit image. Specifically, since the height detection optical apparatus 200a projects and detects patterns of multi-slit shape from the left and right symmetrical directions and the height calculating unit 200b constantly obtains a height of a constant point 110 by averaging both detected values, it is necessary to locate a pair of height detection optical apparatus 200a in the left and right directions. Initially, a light beam emitted from the light source 201 is converged by the condenser lens 202 in such a manner that a light source image is focused at the pupil of the projection/detection lens. This light beam further illuminates the mask 203 on which the multi-slit shaped pattern is formed. Of the light beams, the light beam that was reflected on the half mirror 205 is projected by the projection/detection lens 220 onto the sample 106. The multi-slit pattern that was projected onto the sample is regularly reflected and passed through the projection/detection lens 220 of the opposite side. Then, the light beam passed through the half mirror 205 is focused in front of the magnifying lens 264. This intermediate image is focused on the line image sensor 214 by the magnifying lens 264. At that time, of the luminous flux, the portion that was passed through the half mirror 205 is focused on the line image sensor 214. In this embodiment, the cylindrical lens 213 is disposed ahead of the line image sensor 214 to compress the longitudinal direction of the slit and thereby the light beam is converged on the line image sensor 214. Assuming that m is a magnification of the detection optical system, then when the height of the sample is changed by z, a multi-slit image is shifted by 2 mz sin.theta. on the whole. By utilizing this fact, the height calculating unit 200b calculates a shift amount of the multi-slit image from a signal of a multi-slit image detected from the detection optical system of each height detection optical apparatus 200a, calculates a height of a sample from the calculated shift amount of the multi-slit image, and obtains a height on the electron beam optical axis 110 on the sample by averaging these calculated heights of the sample. Specifically, the height calculating means 200b calculates the height of the sample 106 from the shift amounts of the right and left multi-slit images. Here, an average value therebetween is calculated by using the height detected values obtained from the right and left detection system 200a, and is set to a height detection value at the final point 110. The position 110 at which the height is to be detected becomes an optical axis of the upper observation system. Incidentally, while the height detection optical apparatus 200a is arranged substantially similarly to a second embodiment as shown in FIG. 15 as described above, it is apparent that the optical system according to the first embodiment as shown in FIG. 10 or an optical system according to a third embodiment as shown in FIG. 16 or optical systems according to embodiments as shown in FIGS. 25, 26, 27, 30 may be used. The focus control apparatus 109 drives and controls an electromagnetic lens or an electrostatic lens on the basis of height data 190 obtained from the height calculating unit 200b to thereby focus an electron beam on the surface of the sample 106. A deflection signal generating apparatus 108 generates the deflection signal 141 to the deflection element 102. At that time, the deflection signal generating apparatus 108 corrects the deflection signal 141 on the basis of the height data obtained from the height calculating unit 200b in such a manner as to compensate for an image magnification fluctuation caused by the fluctuation of the height of the surface of the sample 106 and an image rotation caused by the control of the electromagnetic lens 103. Incidentally, if an electrostatic lens is used as the objective lens 103 instead of the electromagnetic lens, then the image rotation caused when the focus is controlled does not occur so that the image rotation need not be corrected by the height data 190. Further, if lens 103 is comprised of a combination of an electromagnetic lens and an electrostatic lens, the electromagnetic lens has a main converging action and the electrostatic lens adjusts the focus position, then the image rotation, of course, need not be corrected by the height data 190. Further, instead of directly controlling the focus position of the electromagnetic lens or the electrostatic lens 103 by the focus control apparatus 109 under the condition that the stage 105 is used as an XYZ stage, the height of the stage 105 may be controlled. The entirety control apparatus 120 controls the whole of the electron beam apparatus (SEM apparatus), displays a processed result processed by the image processing apparatus 124 on a display 143 or stores the same in a memory 142 together with coordinate data for the sample. Also, the entirety control apparatus 120 controls the height calculating unit 200b, the focus control apparatus 109 and the deflection signal generating apparatus 108 thereby to realize a high-speed auto focus control in the electron beam apparatus and an image magnification correction and an image rotation correction caused by this focus control. Furthermore, the entirety control apparatus 120 executes a correction of a height detected value, which will be described later. FIG. 3 shows a defect detection apparatus using an SEM image according to an embodiment of the present invention. Specifically, the appearance inspection apparatus using an SEM image comprises an electron beam source 101 for generating electron beams, a beam deflector 102 for forming an image by scanning beams, an objective lens 103 for focusing electron beams on an inspected object 106 formed of a wafer or the like, a grid 118 disposed between the objective lens 103 and an inspected object 106, a stage 105 for holding, scanning or positioning the inspected object 106, a secondary electron detector 104 for detecting secondary electrons generated from the inspected object 106, a height detection optical apparatus 200a, a focus position control apparatus 109 for adjusting a focus position of the objective lens 103, an electron beam source potential adjusting unit 121 for controlling a voltage of the electron beam source, a deflection control apparatus (deflection signal generating apparatus) 108 for realizing a beam scanning by controlling the beam deflector 102, a grid potential adjusting unit 127 for controlling a potential of the grid 118, a sample holder potential adjusting unit 125 for adjusting a potential of a sample holder, an A/D converter 122 for A/D-converting a signal from the secondary electron detector 104, an image processing circuit 124 for processing a digital image thus A/D-converted, an image memory 123 therefor, a stage control unit 126 for controlling the stage, an entirety control unit 120 for controlling the entirety, and a vacuum sample chamber (vacuum reservoir) 100. A height detection value 190 of the height detection sensor 200 is constantly fed back to the focus position control apparatus 109 and a deflection control apparatus (deflection signal generating apparatus) 108. When the inspected object 106 is inspected, the entirety control unit 120 continuously moves the stage 105 by issuing a command to the stage control apparatus 126. Concurrently therewith, the entirety control unit 120 issues a command to the deflection control apparatus (deflection signal generating apparatus) 108, and the deflection control apparatus 108 drives the beam deflector 102 to scan electron beams in the direction perpendicular thereto. Simultaneously, the deflection control apparatus 108 receives the height detection value 190 obtained from the height calculating unit 200b and corrects a deflection direction and a deflection width. The focus position control apparatus 109 drives the electromagnetic lens or electrostatic lens 103 in accordance with the height detection value 190 obtained from the calculating unit 200b, and corrects a properly-focused height of electron beam. At that time, the secondary electron detector 104 detects secondary electrons generated from the sample 106 and enters the detected secondary electron into the A/D converter 122 to thereby continuously obtain SEM images. When the appearance of the inspected object is inspected based on the SEM image, a two-dimensional SEM image should be obtained over a certain wide area. As a result, driving the beam deflector 102 to scan electron beams in the direction substantially perpendicular to the movement direction of the stage 105 while the stage 105 is being continuously moved, it is necessary to detect a two-dimensional secondary electron image signal by the secondary electron detector 104. Specifically, while the stage 105 is being continuously moved in the X direction, for example, the beam deflector 102 is moved to scan electron beams in the Y direction substantially perpendicular to the movement direction of the stage 105, and then the stage 105 is moved in a stepwise fashion in the Y direction. Thereafter, while the stage 105 is being continuously moved in the X direction, the beam deflector 102 is driven to scan electron beams in the Y direction substantially perpendicular to the movement direction of the stage 105, and a two-dimensional secondary electron image signal has to be detected by the secondary electron detector 104. The processes of (1) continuous movement of the stage, (2) beam scanning, (3) optical height detection, (4) focus control and/or deflection direction and width correction, and (5) secondary electron image acquisition should be executed simultaneously. In this way, the acquired SEM image is kept focused and distortion-corrected while the image is being acquired continuously and speedily. By this control, fast and high-sensitivity defect detection can be achieved. Then, the image processing circuit 124 compares corresponding images or repetitive patterns by comparing an electron beam image delayed by the image memory and an image directly inputted from the A/D converter 124, thereby resulting in the comparison inspection being realized. The entirety control unit 120 receives the inspected result at the same time it controls the image processing circuit 124, and then displays the inspected result on the display 143 or stores the same in the memory 142. Incidentally, in the embodiment shown in FIG. 3, while a focus is adjusted by controlling a control current flowing to the objective lens 103 having an excellent responsiveness, the present invention is not limited thereto, and the stage 105 may be elevated and lowered. However, if the focus is adjusted by elevating and lowering the stage 105, then responsiveness is deteriorated. Further, the appearance inspection apparatus using an SEM image will be described with reference to FIGS. 4 to 9. FIG. 4 shows the appearance inspection apparatus using an SEM image according to an embodiment of the present invention. In this embodiment, an electron beam 112 scans the inspected object 106 such as a wafer and electrons generated from the inspected object 106 are detected by the irradiation of electron beams. Then, an electronic beam image at the scanning portion is obtained on the basis of the change of intensity, and the pattern is inspected by using the electron beam image. As the inspected object 106, there is the semiconductor wafer 3 as shown in FIGS. 5(a)-5(c), for example. On this semiconductor wafer 3, there are arrayed a number of chips 3a which form the same product finally as shown in FIG. 5(a). An inside pattern layout of the chip 3a comprises a memory mat portion 3c in which memory cells are regularly arranged at the same pitch in a two-dimensional fashion and a peripheral circuit portion 3b as shown by an enlarged view in FIG. 5(b). When the present invention is applied to the inspection of the pattern of this semiconductor wafer 3, a detected image at a certain chip (e.g. chip 3d) is memorized in advance, and then compared with a detected image of another chip (e.g. 3e) (hereinafter referred to as "chip comparison"). Alternatively, a detected image at a certain memory cell (e.g. memory cell 3f) is memorized in advance, and then compared with a detected image of other cell (e.g. cell 3g) (hereinafter referred to as "cell comparison") as shown in FIG. 5(c), thereby resulting in a defect being recognized. If the repetitive patterns (chips or cells of the semiconductor wafer, by way of example) of the inspected object 106 are equal to each other strictly and if equal detected images are obtained, then only defects cannot agree with each other when images are compared with each other. Thus, it is possible to recognize a defect. However, in actual practice, a disagreement between images exists in the normal portion. As a disagreement at the normal portion, there are a disagreement caused by the inspected object, and a disagreement caused by the image detection system. The disagreement caused by the inspected object is based on a subtle difference caused between the repetitive patterns by a wafer manufacturing process such as exposure, development or etching. This disagreement appears as a subtle difference of pattern shape and a difference of gradation value. The disagreement caused by the image detection system is based on a fluctuation of a quantity of illumination light, a vibration of stage, various electrical noises, and a disagreement between detection positions of two images or the like. These disagreements appear as a difference of gradation value of a partial image, a distortion of pattern, and a positional displacement of an image on the detected image. In the embodiment according to the present invention, a detection image (first two-dimensional image) in which gradation values of coordinates (x, y) aligned at the pixel unit are f1(x, y) and a compared image (second two-dimensional image) in which gradation values of coordinates (x, y) are g1(x, y) are compared with each other, a threshold value (allowance value) used when a defect is determined is set at every pixel considering the positional displacement of pattern and a difference between the gradation values, and a defect is determined on the basis of a threshold value (allowance value set at every pixel. A pattern inspection system according to the present invention comprises, as shown in FIGS. 4 and 7, a detection unit 115, an image output unit 140, an image processing unit 124 and an entirety control unit 120 for controlling the entire system. Incidentally, the present pattern inspection system includes an inspection chamber 100 whose inside is vacated and exhausted by vacuum and a reserve chamber (not shown) for inserting and ejecting the inspected object 106 into and from the inspection chamber 100. This reserve chamber can be vacated and exhausted by vacuum independently of the inspection chamber 100. Initially, the inspection unit 115 will be described with reference to FIGS. 4 and 7. Specifically, the inside of the inspection chamber 100 in the detection unit 115 generally comprises, as shown in FIG. 7, an electron optical system 116, an electron detection unit 117, a sample chamber 119, and an optical microscope unit 118. The electron optical system 116 comprises an electron gun 31 (101), an electron beam deriving electrode 11, a condenser lens 32, a blanking deflector 13, a scanning deflector 34 (102), an iris 14, an objective lens 33 (103), a reflecting plate 17, an ExB deflector 15, and a Faraday cup (not shown) for detecting a beam current. The reflecting plate 17 is shaped as a circular cone in order to achieve a secondary electron amplification effect. Of the electron detection unit 117, the electron detector 35 (104) for detecting electrons such as secondary electrons or reflection electrons is installed above the objective lens 33 (103), for example, within the inspection chamber 100. An output signal from the electron detector 35 is amplified by an amplifier 36 installed outside the inspection chamber 100. The sample chamber 119 comprises a sample holder 30, an X stage 31 and a Y stage 32 previously referred to as stage 105, a position monitoring length measuring device 107 and a height measuring apparatus 200 such as an inspected based plate height measuring device. Incidentally, there may be provided a rotary stage on the stage. The position monitoring length measuring device 107 monitors a position such as the stages 31, 32 (stage 105), and transfers a monitored result to the entirety control unit 120. The driving systems of the stages 31, 32 also are controlled by the entirety control unit 120. As a result, the entirety control unit 120 is able to precisely understand the area and the position irradiated with electron beams 112 on the basis of such data. The inspected base plate height measuring device is adapted to measure the height of the inspected object 106 resting on the stages 31, 32. Then, a focal length of the objective lens 33 (103) for converging the electron beam 112 is dynamically corrected on the basis of measured data measured by the inspected base plate height measuring device 200 so that electron beams can be irradiated under the condition that electron beams are constantly properly-focused on the inspected area. Incidentally, in FIG. 7, although the height measuring apparatus 200 is installed within the inspection chamber 100, the present invention is not limited thereto, and there may used a system in which the height measuring device is installed outside the inspection chamber 100 and light is projected into the inside of the inspection chamber 100 through a glass window or the like. The optical microscope unit 118 is located at the position near the electron optical system 116 within the room of the inspection chamber 100 and which position is distant to the extent that the optical microscope unit and the electron optical system cannot affect each other. A distance between the electron optical system 116 and the optical microscope unit 118 should naturally be a known value. Then, the X stage 31 or the Y stage 32 is reciprocally moved between the electron optical system 116 and the optical microscope unit 118. The optical microscope unit 118 comprises a light source 61, an optical lens 62, and a CCD camera 63. The optical microscope unit 118 detects the inspected object 106, e.g. an optical image of a circuit pattern formed on the semiconductor wafer 3, calculates a rotation displacement amount of circuit patterns based on the optical image thus detected, and transmits the rotation displacement amount thus calculated to the entirety control unit 120. Then, the entirety control unit 120 becomes able to correct this rotation displacement amount by rotating a rotating stage forming a part of stage 2 (105) which includes stages 31 and 32, for example. Also, the entirety control unit 120 sends this rotation displacement amount to a correction control circuit 120', and the correction control circuit 120' becomes able to correct the rotation displacement by correcting the scanning deflection position of electron beams caused by the scanning deflector 34, for example, on the basis of this rotation displacement amount. Moreover, the optical microscope unit 118 detects the inspected object 106, e.g. the optical image of the circuit pattern formed on the semiconductor wafer 3, observes this optical image, for example, displayed on the monitor 50, and sets the inspection area on the entirety control unit 120 by entering the coordinates of the inspection area into the entirety control unit 120 by using an input based on the optical image thus observed. Furthermore, the pitch between the chips on the circuit pattern formed on the semiconductor wafer 3, for example, or the repetitive pitch of the repetitive pattern such as the memory cell can be measured in advance and can be inputted to the entirety control unit 120. Incidentally, while the optical microscope unit 118 is located within the inspection chamber 100 in FIG. 7, the present invention is not limited thereto, and the optical microscope unit may be located outside the inspection chamber 100 to thereby detect the optical image of the semiconductor wafer 3 through a glass window or the like. As shown in FIGS. 4 and 7, the electron beam emitted from the electron gun 31 (101) travels through the condenser lens 32 and the objective lens 33 (103) and is converged to a beam diameter of about pixel size on the sample surface. In that case, a negative potential is applied to the sample by the ground electrode 38 (118) and the retarding electrode 37 and the electron beam between the objective lens 33 (103) and the inspected object (sample) 106 is decelerated, whereby a resolution can be improved in a low acceleration voltage area. When irradiated with electron beams, the inspected object (wafer 3) 106 generates electrons. The scanning deflector 34 (102) scans repeatedly electron beams in the X direction and electrons generated from the inspected object 106 in synchronism with the continuous movement of the inspected object (sample) 106 in the X direction by the stage 2 (105) are detected, thereby obtaining a two-dimensional electron beam image of the inspected object. The electrons generated from the inspected object are detected by the detector 35 (104), and amplified by the amplifier 36. In order to make the high-speed scanning possible, an electrostatic deflector of which deflection speed is high should preferably be used as the deflector 34 (102) for repeatedly scanning electron beams in the X direction. Moreover, a thermal electric field radiation type electron gun should preferably be used as the electron gun 31 (101) because it can reduce the irradiation time by increasing the electron beam current. Further, a semiconductor detector which can be driven at a high speed should preferably be used as the detector 35 (104). Next, the image output unit 140 will be described with reference to FIGS. 4, 7, and 8. Specifically, an electron detection signal detected by the electron detector 35 (104) in the electron detection unit 117 is amplified by the amplifier 36, and then converted by the A/D converter 39 (122) into digital image data (gradation image data). Then, the output from the A/D converter 39 (122) is transmitted by an optical converter (light-emitting element) 23, a transmission device (optical fiber cable) 24, and an electric converter (light-receiving device) 25. According to this arrangement, the transmission device 24 may have the same transmission speed as the clock frequency of the A/D converter 39 (122). The output from the A/D converter 39 is converted by the optical converter (light-emitting element) 23 into an optical digital signal, optically transmitted by the transmission device (optical fiber cable) 24 and then converted by the electric converter (light-receiver) 25 into digital image data (gradation image data). The reason that the output signal is converted into the optical signal and then transmitted is that, in order to supply electrons 52 from the reflection plate 17 into the semiconductor detector 35 (104), constituents (semiconductor detector 35, amplifier 36, A/D converter 39, and optical converter (light-emitting element) 23 from the semiconductor detector 35 to the optical converter 23 should be floated at a positive high potential by a high-voltage power supply source (not shown). More precisely, only the semiconductor detector 35 need be floated to the positive high potential. However, the amplifier 36 and the A/D converter 39 should preferably be located near the semiconductor detector in order to prevent noise from being mixed and a signal from being deteriorated. It is difficult to maintain only the semiconductor detector 35 at the positive high voltage, and hence all of the above-mentioned constituents should be held at the high voltage. Specifically, since the transmission device (optical fiber cable) 24 is made of a high insulating material, after the image signal which is held at the positive high potential level in the optical converter (light-emitting element) 23 is passed through the transmission device (optical fiber cable) 24, the electric converter (light-receiver) 25 outputs an image signal of earth level. The pre-processing circuit (image correcting circuit) 40 comprises, as shown in FIG. 8, a dark level correcting circuit 72, an electron beam source fluctuation correcting circuit 73, a shading correcting circuit 74 and the like. Digital image data (gradation image data) 71 obtained from the electric converter (light-receiving element) 25 is supplied to the pre-processing circuit (image correcting circuit) 40, in which it is image-corrected such as a dark level correction, an electron beam source fluctuation correction or a shading correction. In the dark level correction in the dark level correcting circuit 72, as shown in FIG. 9, a dark level is corrected on the basis of a detection signal 71 in a beam blanking period extracted based on a scanning line synchronizing signal 75 obtained from the entirety control unit 120. Specifically, the reference signal for correcting the dark level sets an average of a gradation value of a specific number of pixels in a particular position during the beam blanking period to the dark level, and updates the dark level at every scanning line. As described above, in the dark level correcting circuit 72, the detection signal detected during the beam blanking period is dark-level-corrected to the reference signal which is updated at every line. When the electron beam source fluctuation is corrected by the electron beam source fluctuation correcting circuit 73, as shown in FIG. 9, a detection signal 76 of which the dark level is corrected is normalized by a beam current 77 monitored by the Faraday cup (not shown) which detects the above-mentioned beam current at a correction cycle (e.g. line unit of 100 kHz). Since the fluctuation of the electron beam source is not rapid, it is possible to use a beam current that was detected one to several lines before. When a shading is corrected by the shading correcting circuit 74, as shown in FIG. 9, the fluctuation of the quantity of light caused in a detection signal 78 in which the electron beam source fluctuation was corrected at the beam scanning position 79 obtained from the entirety control unit 120 is corrected. Specifically, the shading correction executes the correction (normalization) at every pixel on the basis of reference brightness data 83 which is previously detected. The shading correction reference data 83 is previously detected, the detected image data is temporarily stored in an image memory, the image data thus stored is transmitted to a computer disposed within the entirety control unit 120 or a high-order computer connected to the entirety control unit 120 through a network, and processed by software in the computer disposed within the entirety control unit 120 or the high-order computer connected through the network to the entirety control unit 120, thereby resulting in the shading correction reference data being created. Moreover, the shading correction reference data 83 is calculated in advance and held by the high-order computer connected to the entirety control unit 120 through the network. When the inspection is started, the data is downloaded, and this downloaded data may be latched in a CPU in the shading correcting circuit 74. To cope with a full visual field width, the shading correcting circuit 74 includes two correction memories having pixel number (e.g. 1024 pixels) of an amplitude of an ordinary electron beam, and the memories are switched during a time (time from the end of one visual field inspection to the start of the next one visual field inspection) outside the inspection area. The correction data may have pixel number (e.g. 5000 pixels) of a maximum amplitude of an electron beam, and the CPU may rewritten such data in each correction memory till the end of the next one visual field inspection. As described above, after the dark level correction (dark level is corrected on the basis of the detection signal 71 during the beam blanking period), the electron beam current fluctuation correction (beam current intensity is monitored and a signal is normalized by a beam current) and the shading correction (fluctuation of quantity of light at the beam scanning position is corrected) are effected on the digital image data (gradation image data) 71 obtained from the electric converter (light-receiving element) 25, the filtering processing is effected on the corrected digital image data (gradation image data) 80 by a Gaussian filter, a mean value filter or an edge-emphasizing filter in the filtering processing circuit 81, thereby resulting a digital image signal 82 with an image quality being improved. If necessary, a distortion of an image is corrected. These pre-processings are executed in order to convert a detected image so as to become advantageous in the later defect judgment processing. Although the delay circuit 41 formed of a shift register or the like delays the digital image signal 82 (gradation image signal) with an improved image quality from the pre-processing circuit 40 by a constant time, if a delay time is obtained from the entirety control unit 120 and set to a time during which the stage 2 is moved by a chip pitch amount (d1 in FIG. 5(a)), then a delayed signal g0 and a signal f0 which is not delayed become image signals obtained at the same position of the adjacent chips, thereby resulting in the aforementioned chip comparison inspection being realized. Alternatively, if the delay time is obtained from the entirety control unit 120 and set to a time during which the stage 2 is moved by a pitch amount (d2 in FIG. 5(c)) of the memory cell, then the delayed signal g0 and the signal f0 which is not delayed become image signals obtained at the same position of the adjacent memory cells, thereby resulting in the aforementioned cell comparison inspection being realized. As described above, the delay circuit 41 is able to select an arbitrary delay time by controlling a read-out pixel position based on information obtained from the entirety control unit 120. As described above, compared digital image signals (gradation image signals) f0 and g0 are outputted from the image output unit 140. Hereinafter, f0 will be referred to as a detection image and g0 will be referred to as a comparison image. Incidentally, as shown in FIG. 7, the comparison image signal f0 may be stored in a first image memory unit 46 composed of a shift register and an image memory and the detection image signal f0 may be stored in a second image memory unit 47 composed of a shift register and an image memory. As described above, the first image memory unit 46 may comprise the delay circuit 41, and the second image memory unit 47 is not necessarily required. Moreover, an electron beam image latched within the preprocessing circuit 40 and the second image memory unit 47 or the like or the optical image detected by the optical microscope unit 118 may be displayed on the monitor and can be observed. The image processing unit 124 will be described with reference to FIG. 4. The pre-processing circuit 40 outputs a detection image f0(x, y) expressed by a gradation value (light and shade value) with respect to a certain inspection area on the inspected object 106, and the delay circuit 41 outputs a comparison image (standard image:reference image) g0(x, y) expressed by a gradation value (light and shade value) with respect to a certain area on the inspected object 106 which becomes a standard to be compared. The pixel unit position alignment unit 42 of image processing unit 124 displaces the position of comparison image, for example, in such a manner that the position displacement amount of the comparison image g0(x, y) relative to the above-mentioned detection image f0(x, y) falls in a range of from 0 to 1 pixel, in other words, the position at which a "matching degree" between f0(x, y) and g0(x, y) becomes maximum falls within a range of from 0 to 1 pixel. As a consequence, as shown in FIGS. 6(a) and 6(b), for example, the detection image f0(x, y) and the comparison image g0(x, y) are aligned with an alignment accuracy of less than one pixel. A square portion shown by dotted lines in FIG. 6 denotes a pixel. This pixel is a unit detected by the electron detector 35, sampled by the A/D converter 39 (122), and converted into a digital value (gradation value:light and shade value). That is, the pixel unit denotes a minimum unit detected by the electron detector 35. Incidentally, as the above-mentioned "matching degree", there may be considered the following equation (expression 1): max .vertline.f)-g0.vertline. shows a maximum value of an absolute value of a difference between the detection image f0(x, y) and the comparison image g0(x, y). .SIGMA..SIGMA..vertline.f0-g0.vertline. shows a total of absolute value of a difference between the detection image f0(x, y) and the comparison image g0(x, y) within the image. ZZ (f0-g0) shows a value which results from squaring a difference between the detection image f0(x, y) and the comparison image g0(x, y) and integrating the squared result in the x direction and the y direction. Although the processed content is changed depending upon the adoption of any one of the above-mentioned (expression 1), the case that .SIGMA..SIGMA..vertline.f0-g0.vertline. is adopted will be described below. Mx assumes the displacement amount of the comparison image g0(x, y) in the x direction, and my assumes the displacement in the y direction (mx, my are integers). Then, e1(mx, my) and s1(mx, my) are defined by equations of (expression 2) and (expression 3), respectively: In the expression 2, .SIGMA..SIGMA. shows a total within the image. Since what is required to calculate is a value obtained when mx assumes the displacement amount of the x direction in which s1(mx, my) becomes minimum and a value obtained when my assumes the displacement amount of the y direction, by changing mx and my as .+-.0, 1, 2, 3, 4, . . . n, in other words, by changing the comparison image g0(x, y) with a pixel pitch, there is calculated s1(mx, my) of each time. Then, a value mx0 of mx in which the calculated value becomes minimum and a value my0 of my in which the calculated value becomes minimum are calculated. Incidentally, the maximum displacement amount n of the comparison image should be increased as the positional accuracy is lowered in response to the positional accuracy of the detection unit 115. The pixel unit position alignment unit 42 outputs the detection image f0(x, y) at it is, and outputs the comparison image g0(x, y) with a displacement of (mx0, my0). That is, f1(x, y)=f0(x, y), g1(x, y)=g0(x+mx0, y+my0). A positional displacement detection unit (not shown) for detecting a positional displacement of less than a pixel divides the images f1(x, y), g(x, y) aligned at the pixel unit into small areas (e.g. partial images composed of 128*256 pixels), and calculates positional displacement amounts (positional displacement amounts become real number of 0 to 1) of less than the pixel at every divided area (partial image). The reason that the images are divided into small areas is in order to cope with a distortion of an image, and hence should be set to a small area to the extent that a distortion can be neglected. As a measure for measuring a matching degree, there are the selection branches shown in the expression 1. An example is shown in which the third "sum of squares of difference" (.SIGMA..SIGMA. (f0-g0)2) is adopted. Let it be assumed that an intermediate position between f1(x, y) and g1(x, y) is held at the positional displacement amount 0 and that, as shown in FIG. 6, f1 is displaced y-.delta.x in the x direction, f1 is displaced by -.delta.y in the by direction, g1 is displaced by +.delta.x in the x direction, and that g1 is displaced by +.delta.y in the y direction. That is, the displacement amounts of f1 and g1 are 2*.delta.x in the x direction and 2*.delta.y in the y direction. Since .delta.x, .delta.y are not integers, in order to displace f1 and g1 by .delta.x, .delta.y, it is necessary to define a value between the pixels. An image f2 in which f1 is displaced by +.delta.x in the x direction and by +.delta.y in the y direction and an image g2 in which g1 is displaced by -.delta.x in the x direction and by -.delta.y in the y direction are defined as the following equations of (expression 4) and (expression 5): The expression 4 and the expression 5 are what might be called linear interpolations. A matching degree e2(.delta.x, .delta.y) of f2 and g2 is represented by the following equation of (expression 6) if "sum of squares of difference" is adopted. .SIGMA..SIGMA. denotes a total within small areas (partial images). The object of the positional displacement detection unit (not shown) for detecting a positional displacement of less than the pixel unit is to obtain a value .delta.x0 of .delta.x and a value .delta.y0 of .delta.y in which e2(.delta.x, .delta.y) takes the minimum value. To this end, an equation which results from partially differentiating the above-mentioned expression 6 by .delta.x, .delta.y is set to 0 and may be solved. The results are obtained as shown by the following equations of (expression 7) and (expression 8): However, respective ones of C0, Cx, Cy establish relationships shown by the following equations of (expression 9), (expression 10) and (expression 11): In order to obtain .delta.x0, .delta.y0, respectively, as shown by the (expression 7) and the (expression 8), it is necessary to obtain a variety of statistic amounts .SIGMA..SIGMA.Ck*Ck (Ck=C0, Cx, Cy). The statistic amount calculating unit 44 calculates a variety of statistic amount .SIGMA..SIGMA.Ck*Ck on the basis of the detection image f1(x, y) composed of the gradation value (light and shade value) aligned at the pixel unit obtained from the pixel unit position alignment unit 42 and the comparison image g1(x, y). The sub-CPU 45 obtains .delta.x0, .delta.y0 by calculating the (expression 7) and the (expression 8) by using the .SIGMA..SIGMA.Ck*Ck which was calculated in the statistic amount calculating unit 44. The delay circuits 46, 47 formed of the shift register or the like are adapted to delay the image signals f1 and g1 by the time which is required by the less than pixel positional displacement unit (not shown) to calculate .delta.x0, .delta.y0. The difference image extracting circuit (difference extracting circuit:distance extracting unit) 49 is adapted to obtain a difference image (distance image) sub(x, y) between f1 and g1 having positional displacements 2*.delta.x0, 2*.delta.y0 from a calculation standpoint. This difference image (distance image) sub(x, y) is expressed by the equation of (expression 12) as follows: The threshold value computing circuit (allowance range computing unit) 48 is adapted to calculate by using the image signals f1, g1 from the delay circuits 46, 47 and the positional displacement amounts .delta.x0, .delta.y0 of less than the pixel obtained from the less than pixel positional displacement detection unit (not shown) two threshold values (allowance values indicative of allowance ranges) thH(x, y) and thL(x, y) which are used by the defect deciding circuit (defect judgment unit) 50 to determine in response to the value of the difference image (distance image) sub(x, y) obtained from the difference image extracting circuit (difference extracting circuit:distance extracting unit) 49 whether or not the inspected object is the nominated defect. ThH(x, y) is the threshold value (allowance value indicative of allowance range) which determines the upper limit of the difference image (distance image) sub(x, y), and thL(x, y) is the threshold value (allowance value indicative of allowance range) which determines the lower limit of the difference image (distance image) sub(x, y). Contents of the computation in the threshold value computing circuit 48 are expressed by the equations of (expression 13) and (expression 14) as follows: However, A(x, y) is a term expressed by a relationship of the following equation of (expression 16) and which is used to correct the threshold values by using the less than pixel positional displacement amounts .delta.x0, .delta.y0 in response to the value of the difference image (distance image) sub(x, y) substantially. Also, B(x, y) is a term expressed by a relationship of the equation of the (expression 16) and which is used to allow a very small positional displacement of a pattern edge (very small difference of pattern shape, pattern distortion also returns to a very small positional displacement of pattern edge from a local standpoint) between the detection image f1 and the comparison image g1. Also, C(x, y) is a term expressed by a relationship of the equation of (expression 17) and which is used to allow a very small difference of gradation value (light and shade value) between the detection image f1 and the comparison image g1). where .alpha., .beta. are the real numbers ranging from 0 to 0.5, .gamma. is the real number greater than 0, and .epsilon. is the integer greater than 0. dx1(x, y) is expressed by a relationship of the equation of (expression 18), and indicates a changed amount of a gradation value (light and shade value) with respect to the x direction +1 adjacent image in the detection image f1(x, y). dy2(x, y) is expressed by a relationship of the equation of (expression 19), and indicates a changed amount of a gradation value (light and shade value) with respect to the x direction -1 adjacent image in the comparison image g1(x, y). dy1(x, y) is expressed by a relationship of the equation of (expression 20), and indicates a changed amount of a gradation value (light and shade value) with respect to the y direction +1 adjacent image in the detection image f1(x, y). dy2(x, y) is expressed by a relationship of the equation of (expression 21), and indicates a changed amount of a gradation value (light and shade value) with respect to the y direction -1 adjacent image in the comparison image g1(x, y). max1 is expressed by a relationship of the equation of (expression 22), and indicates maximum gradation values (light and shade values) of x direction +1 adjacent image and y direction +1 adjacent image including itself in the detection image f1(x, y). max2 is expressed by a relationship of the equation of (expression 23), and indicates maximum gradation values (light and shade values) of x direction -1 adjacent image and y direction--adjacent image including itself in the comparison image g1(x, y). First, the first term A(x, y) in the equations of (expression 13) and (expression 14) for calculating the threshold values thH(x, y), thL(x, y) will be described. Specifically, the first term A(x, y) in the equations of (expression 13) and (expression 14) for calculating the threshold values thH(x, y) and thL(x, y) is the term used to correct the threshold values in response to the less than pixel positional displacement amounts .delta.x0, .delta.y0 which were calculated by the positional displacement detection unit 43. Since dx1 expressed by (expression 18), for example, is a local changing rate of a gradation value of f1 in the x direction, dx1(x, y)*.delta.x0 expressed by (expression 15) can be regarded as a predicted value of the change of the gradation value (light and shade value) of f1 obtained when the position is shifted by .delta.x0. Therefore, the first term {dx1(x, y)*.delta.x0-dx2(x, y)*(-.delta.x0)} can be regarded as a value which predict at every pixel a changing rate of a gradation value (light and shade value) of the difference image (distance image) of f1 and g1 obtained when the position of f1 is displaced by .delta.x0 in the x direction and the position of g1 is displaced by -.delta.x0 in the x direction. Similarly, the second term can be regarded as the value which predicts a changing rate with respect to the y direction. Specifically, {dx1(x, y)+dx2(x, y)}*.delta.x0 is a value which can predict a changing rate of a gradation value (light and shade value of difference image (distance image) of f1 and g1 in the x direction by multiplying a local changing rate {dx1(x, y)+dx2(x, y)} of the difference image (distance image) between the detection image f1 and the comparison image g1 in the x direction with the positional displacement .delta.x0. Also, {dy1(x, y)+dy2(x, y)}*.delta.y0 is a value which predicts at every pixel a changing rate of a gradation value (light and shade value) of the difference image (distance image) of f1 and g1 by multiplying a local changing rate {dy1(x, y)+dy2(x, y) of the difference image (distance image) between the detection image f1 and the comparison image g1 in the y direction with the positional displacement .delta.y0. As described above, the first term A)x, y) in the threshold values thh(x, y) and thL(x, y) is the term used to cancel the known positional displacements .delta.x0, .delta.y0. The second term B(x, y) in the equations of (expression 13) and (expression 14) for calculating the threshold values thH(x, y) and thL(x, y) will be described. Specifically, the second term B(x, y) in the equations of (expression 13) and (expression 14) for calculating the threshold values thH(x, y) and thL(x, y) is the term used to allow a very small positional displacement of pattern edge (very small difference of pattern shape and pattern distortion also are returned to very small positional displacements of pattern edge from a local standpoint) As will be clear from the comparison of the (expression 15) for calculating A(x, y) and the (expression 16) for calculating B(x, y), B(x, y) is an absolute value of a change prediction of a gradation value (light and shade value) of the difference image (distance image) brought about by the positional displacements .alpha., .beta.. If the positional displacement is canceled by A(x, y), then the addition of B(x, y) to A(x, y) means that the position aligned state is further displaced by .alpha. in the x direction and by .beta. in the y direction considering a very small positional displacement of pattern edge caused by a very small difference based on the pattern shape and the pattern distortion. That is, +B(x, y) expressed by the equation of (expression 13) is to allow the positional displacement of +.alpha. in the x direction and the positional displacement of +.beta. in the y direction as the very small positional displacements of the pattern edge caused by the very small differences based on the pattern shape and the pattern distortion. Further, the subtraction of B(x, y) from A(x, y) in the equation of (expression 14) means that the positional aligned state is positionally displaced by -.alpha. in the x direction and by -.beta. in the y direction. -B(x, y) expressed by the equation of (expression 14) is adapted to allow the positional displacement of -.alpha. in the x direction and -.beta. in the y direction. As shown by the equations of (expression 13) and (expression 14), if the threshold value includes the upper limit thH(x, y) and the lower limit thL(x, y), then it is possible to allow the positional displacements of .+-..alpha., .+-..beta.. Then, if the threshold value computing circuit 48 sets the values of the inputted parameters .alpha., .beta. to proper values, then it becomes possible to freely control the allowable positional displacement amounts (very small positional displacement amounts of pattern edge) caused by the very small difference based on the pattern shape and the pattern distortion. Next, the third term C(x, y) in the equations of (expression 13) and (expression 14) for calculating the threshold values thH(x, y) and thL(x, y) will be described. The third term C(x, y) in the equations of (expression 13) and (expression 14) for calculating the threshold values thH(x, y) and thL(x, y) is a term used to allow a very small difference of a gradation value (light and shade value) between the detection image f1 and the comparison image g1. As shown by the equation of (expression 13), the addition of C(x, y) means that the gradation value (light and shade value) of the comparison image g1 is larger than the gradation value (light and shade value) of the detection image f1 by C(x, y). As shown by the equation of (expression 14), the subtraction of C(x, y) means that the gradation value (light and shade value) of the comparison value g1 is smaller than the gradation value (light and shade value) of the detection image by C(x, y). While C(x, y) is a sum of a value which results from multiplying a representing value (max value) of a gradation value at the local area with the proportional constant .gamma. and the constant .epsilon. as shown by the equation of (expression 17), the present invention is not limited to the above-mentioned function. If the manner in which the gradation value is fluctuated is already known, then it is possible to use a function which can cope with such manner. For example, if it is clear that a fluctuation width is proportional to a square root of a gradation value, then the equation of (expression 17) should be replaced with C(x, y)=(square root of (max1+max2))*.gamma.+.epsilon.. Thus, the threshold value computing circuit 48 becomes able to freely control a difference of allowable gradation value (light and shade value) by the inputted parameters .gamma., .epsilon. similarly to B(x, y). Specifically, the threshold value computing circuit (allowable range computing unit) 48 includes a computing circuit for computing {dx1(x, y)+dx2(x, y)} by the equations of (expression 18) and (expression 19) based on the detection image f1(x, y) composed of a gradation value (light and shade value) inputted from the delay circuit 46 and the comparison image g1(x, y) composed of a gradation value (light and shade value) inputted from the delay circuit 47, a computing circuit for computing {dy1(x, y)+dy2(x, y)} by the equations of (expression 20) and (expression 21) and a computing circuit for computing (max1+max2) by the equations of (expression 22) and (expression 23). Further, the threshold value computing circuit 48 includes a computing circuit for computing ({dx1(x, y)+dx2(x, y)}*.delta.x0.+-..vertline.{dx1(x, y)+dx2(x, y)}.vertline.*.alpha.) which is a part of (expression 15) and a part of (expression 16) on the basis of {dx1(x, y)+dx2(x, y)} obtained from the computing circuit, .delta.x0 obtained from the less than pixel displacement detection unit 43 and the inputted a parameter, a computing circuit for computing (dy1(x, y)+dy2(x, y))*.delta.y0.+-..vertline.{dy1(x, y)+dy2(x, y)}.vertline.*.beta.) which is a part of (expression 15) and a part of (expression 16) on the basis of {dy1(x, y)+dy2(x, y)} obtained from the computing circuit, .delta.y0 obtained from the less than pixel displacement detection unit 43 and the inputted .beta. parameter and a computing circuit for computing ((max1+max2)/2)*.gamma.+.epsilon.) in accordance with the equation of (expression 17), for example, on the basis of (max1+max2) obtained from the computing circuit and the inputted .gamma., .epsilon. parameters. Further, the threshold value computing circuit 48 includes an adding circuit for positively adding ({dx1(x, y)+dx2(x, y)}*.delta.x0+.vertline.{dx1(x, y)+dx2(x, y)}.vertline.*.alpha.), ({dy1(x, y)+dy2(x, y)}*.delta.y0+.vertline.{dy1(x, y)+dy2(x, y)}.vertline.*.beta.) obtained from the computing circuit and ((max1+max2)/2)*.gamma.+.epsilon.) obtained from the computing circuit to output the threshold value thH(x, y) of the upper limit, a subtracting circuit for negatively computing (((max1+max2)/2)*.gamma.+.epsilon.) obtained from the computing circuit and an adding circuit for positively computing ({dx1(x, y)+dx2(x, y)}*.delta.x)-.vertline.{dx1(x, y)+dx2(x, y).vertline.*.alpha.} obtained from the computing circuit, ({dy1(x, y)+dy2(x, y)}*.delta.y0-.vertline.{dy1(x, y)+dy2(x, y)}.vertline.*.beta.) obtained from the computing circuit and -((max1+max2)/2*.gamma.+.epsilon.) obtained from the subtracting circuit to output the threshold value thL(x, y) of the lower limit. Incidentally, the threshold value computing circuit 48 may be realized by a CPU by software processing. Further, the parameters .alpha., .beta., .gamma., .epsilon. inputted to the threshold value computing circuit 48 may be entered by an input means (e.g. keyboard, recording medium, network or the like) disposed in the entirety control unit 120. The defect deciding circuit (defect judgment unit) 50 decides by using the difference image (distance image) sub(x, y) obtained from the difference image extracting circuit (difference extracting circuit) 49, the threshold value of the lower limit (allowable value indicating the allowable range of lower limit) thL(x, y) obtained from the threshold value computing circuit 48 and the threshold value of the upper limit (allowable value indicating the allowable range of upper limit) thH(x, y) that the pixel at the position (x, y) is a non-defect nominated pixel of the following equation of (expression 24) is satisfied and that the pixel at the position (x, y) is a defect nominated pixel if it is not satisfied. The defect deciding circuit 50 outputs def(x, y) which takes a value of 0, for example, with respect to the non-defect nominated pixel and which takes a value greater than 1, for example, the defect-nominated pixel indicating a disagreement amount. The feature extracting circuit 50a executes a noise elimination processing (e.g. contracts/expands def(x, y). When all of 3.times.3 pixels are not simultaneously the defect-nominated pixels, the center pixel is set to 0 (non-defect nominated pixel), for example, and eliminated by a contraction processing, and is returned to the original one by an expansion processing. After a noise-like output (e.g. all 3.times.3 pixels are not simultaneously the defect-nominated pixels) is deleted, there is executed a defect-nominated pixel merge processing in which nearby defect-nominated pixels are collected into one. Thereafter, barycentric coordinates and XY projection lengths (maximum lengths in the |