Abstract:
An image processing apparatus which compresses an image, the apparatus includes: a storage unit which stores a code book, the code book being prepared by allocating identification codes to code blocks, the code blocks being formed by executing quantization processing regarding a plurality of first image blocks as multidimensional vectors, the plurality of first image blocks being generated by cutting, in preset sizes, first regions out of a code book preparation image containing a first edge, each of the first regions surrounding and including an edge point of the first edge, the first edge being detected from the code book preparation image; an edge detection unit which detects a second edge from a compression target image containing the second edge; an image block generation unit which cuts, in preset sizes, second regions out of the compression target image to generate a plurality of second image blocks, each of the second regions surrounding and including an edge point of the detected second edge; a search unit which searches the code book stored in the storage unit for code blocks similar to the second image blocks; and an output unit which outputs information on the identification codes of the similar code blocks which have been searched for and information on coordinates of the edge points of the second image blocks.

Description:
CROSS REFERENCE TO RELATED APPLICATION 
       [0001]    This application claims benefit of priority under 35USC §119 to Japanese patent application No. 2006-116780, filed on Apr. 20, 2006, the contents of which are incorporated by reference herein. 
       BACKGROUND OF THE INVENTION 
       [0002]    1. Field of the Invention 
         [0003]    The present invention relates to an image processing apparatus, an image processing method, a defect detection method, a semiconductor device manufacturing method, and a program. 
         [0004]    2. Related Background Art 
         [0005]    A conventional art and its problems are described taking as an example a scanning electron microscope (SEM) image of a micropattern formed in a semiconductor manufacturing process. 
         [0006]    Dimensional measurement using a CD (critical dimension)-SEM is conducted to evaluate a micropattern of a semiconductor. The CDSEM acquires an SEM image in which a measurement target pattern is observed from above, and the dimensions of parts of the pattern are measured by an apparatus on the basis of the SEM image. Here, the acquired SEM image may be stored in a storage medium such as an HDD connected to an EWS for the purpose of subsequent remeasurement and reobservation. When the image is measured, it is preferable to use a pixel base format such as device independent bitmap (BWP) as a format of the image to be saved, in order to prevent the deterioration of measurement accuracy at the time of measurement. The BMP has been widely spread as a standard image format for Windows (registered trademark) independent of the model of a PC, but has a disadvantage that the file size of an image is increased. For example, the file size runs up to 16 BM in the case of an 8-bit gray scale image having a size of 4096×4096, which wastes storage medium resources for data storage such as the HDD and CPU resources of the PC for executing image processing. There are also problems of an increased load on a network and longer time required for transfer when the image data is transferred via the network. 
         [0007]    An image file is compressed by a run length encoding (RLE) method which carries out lossless compression to reduce the size of the file when the image file is stored on, for example, the HDD, and the image file is decompressed when the image therein is used, such that it is possible to save the storage medium resources such as the HDD. However, in the case of a natural image such as the SEM image, effects of the reduction of the image size by the compression are generally small, and new CPU resources and processing time are required for the compression and decompression. 
         [0008]    Furthermore, when the image is transferred through a network such as the Internet, it is possible to use joint photographic experts group (JPEG) which is a normally used compression image format with high compression efficiency. The JPEG is an image format developed for the compression and saving of the natural images. The JPEG provides lossless compression, but has an advantage of being capable of reducing the file sizes of some images several ten times. However, while the JPEG allows the designation of a compression ratio at the time of saving the image, the JPEG has disadvantages that high-frequency components are lost and the degree of deterioration becomes higher in information of the edge of the image when the compression ratio is increased and that the measurement accuracy decreases at the time of measurement. Thus, the JPEG image is not suitable to the image format for measurement. 
         [0009]    In addition to the JPEG, there has also been proposed a method called vector quantization (VQ) compression as a method suitable to the compression of a line image such as an illustration rather than the natural image. This method is characterized by the use of what is called a code book which is prepared in the following manner: an image is divided into small image blocks, each of the divided image blocks is regarded as one point in a multidimensional space, vector quantization is carried out to reduce the kinds of image blocks, and identification code numbers are assigned to the quantized image blocks. 
         [0010]    However, the weakness of this method is the appearance of the seams of the blocks in a reproduced image. Although human eyes can be deceived, this method still remains unsuitable to the measurement as in the case of the PEG. 
         [0011]    In measuring the image data via the network, means for reducing the load on the network is especially important when the target of the measurement is an image with a large size.  FIG. 8  is a table showing the relation between circuit speeds and transfer times for each image size. It can be understood from  FIG. 8  that about three seconds are required to transfer an image of 4096×4096 even by an FTTH circuit of 40 Mbps and that the speed of measurement processing is limited when a large volume of images are measured. Moreover, images targeted for measurement are generally images of products in mass production factories, and when these images as company secrets go outside through the Internet connection, a serious problem is caused in terms of security. Measurements can be taken for this problem by, for example, encrypting the images, but there is another problem of the requirement of heavy CPU resources and processing time for the encoding and decoding for the encryption. 
       SUMMARY OF THE INVENTION 
       [0012]    According to a first aspect of the present invention, there is provided an image processing apparatus which compresses an image, comprising: 
         [0013]    a storage unit which stores a code book, the code book being prepared by allocating identification codes to code blocks, the code blocks being formed by executing quantization processing regarding a plurality of first image blocks as multidimensional vectors, the plurality of first image blocks being generated by cutting, in preset sizes, first regions out of a code book preparation image containing a first edge, each of the first regions surrounding and including an edge point of the first edge, the first edge being detected from the code book preparation image; 
         [0014]    an edge detection unit which detects a second edge from a compression target image containing the second edge; 
         [0015]    an image block generation unit which cuts, in preset sizes, second regions out of the compression target image to generate a plurality of second image blocks, each of the second regions surrounding and including an edge point of the detected second edge; 
         [0016]    a search unit which searches the code book stored in the storage unit for code blocks similar to the second image blocks; and 
         [0017]    an output unit which outputs information on the identification codes of the similar code blocks which have been searched for and information on coordinates of the edge points of the second image blocks. 
         [0018]    According to a second aspect of the present invention, there is provided an image processing apparatus which reproduces a compressed image subjected to compression processing, the apparatus comprising: 
         [0019]    a storage unit which stores information on a code book, the code book being prepared during the compression processing by allocating identification codes to code blocks, respectively, the code blocks being formed by executing quantization processing regarding a plurality of first image blocks as multidimensional vectors, the plurality of first image blocks being generated by cutting, in preset sizes, first regions out of a code book preparation image containing a first edge, each of the first regions surrounding and including an edge point of the first edge, the first edge being detected from the code book preparation image; 
         [0020]    a reading unit which reads coordinates of second edge points and identification codes of the compressed image, the compressed image being defined by the coordinates of the second edge points and the identification codes of code blocks similar to second image blocks among the code blocks carried by the code book, the second image blocks being image blocks of the compressed image; and 
         [0021]    an image block composition unit which takes, from the code book, the code blocks corresponding to the read identification codes to write these code blocks into a reproduced image region around the coordinates of the second edge points in order to form a reproduced image. 
         [0022]    According to a third aspect of the present invention, there is provided an image processing method comprising an image compression method, the image compression method including: 
         [0023]    detecting a first edge from a code book preparation image having the first edge; 
         [0024]    cutting, in preset sizes, first regions out of the code book preparation image to generate a plurality of first image blocks, each of the first regions surrounding and including an edge point of the detected first edge; 
         [0025]    executing quantization processing regarding the plurality of first image blocks as multidimensional vectors to form code blocks; 
         [0026]    allocating identification codes to the code blocks to prepare a code book; 
         [0027]    detecting a second edge from a compression target image having the second edge; 
         [0028]    cutting, in preset sizes, second regions out of the compression target image to generate a plurality of second image blocks, each of the second regions surrounding and including an edge point of the detected second edge; 
         [0029]    searching the code book for code blocks similar to the second image blocks; and 
         [0030]    outputting coordinates of the edge points of the second image blocks and the identification codes of the similar code blocks. 
         [0031]    According to a fourth aspect of the present invention, there is provided an image processing method comprising an image reproduction method of reproducing a compressed image containing an edge and subjected to compression processing, the image reproduction method including: 
         [0032]    acquiring information on a code book, the code book being prepared during the compression processing by allocating identification codes to code blocks, respectively, the code blocks being formed by executing quantization processing regarding a plurality of first image blocks as multidimensional vectors, the plurality of first image blocks being generated by cutting out, in preset sizes, first regions out of a code book preparation image containing a first edge, each of the first regions surrounding and including an edge point of the first edge, the first edge being detected from the code book preparation image; 
         [0033]    reading coordinates of second edge points and identification codes of the compressed image, the compressed image being defined by the coordinates of the second edge points and the identification codes of code blocks similar to second image blocks, the second image blocks being image blocks of the compressed image among the code blocks carried by the code book; and 
         [0034]    taking, from the code book, the code blocks corresponding to the read identification codes to write these code blocks into a reproduced image region around the coordinates of the second edge points in order to form a reproduced image. 
         [0035]    According to a fifth aspect of the present invention, there is provided a method of detecting a defect in an imaged object, the method comprising: 
         [0036]    detecting a first edge and the directions of the first edge from a code book preparation image having the first edge; 
         [0037]    cutting, in preset sizes, first regions out of the code book preparation image to generate a plurality of first image blocks, each of the first regions surrounding and including an edge point of the detected first edge; 
         [0038]    executing quantization processing regarding the first image blocks as multidimensional vectors to form code blocks for each of the directions of the first edge; 
         [0039]    allocating identification codes to the code blocks to prepare a code book; 
         [0040]    acquiring an image of the imaged object; 
         [0041]    detecting a second edge which is the edge of the imaged object and the directions of the second edge from the image of the imaged object; 
         [0042]    cutting, in preset sizes, second regions out of the image of the imaged object to generate a plurality of second image blocks, each of the second regions surrounding and including an edge point of the detected second edge; 
         [0043]    selecting, from the code book, code blocks corresponding to the directions of the second edge to match these code blocks with the second image blocks, and defining the code blocks which have obtained matching scores exceeding a predetermined threshold value as code blocks similar to the second image blocks; and 
         [0044]    taking, from the code book, the similar code blocks to write these code blocks into a new image region along the directions of the second edge and around the coordinates of the second edge points, 
         [0045]    wherein when the second image blocks in which the matching scores are equal to or less than the predetermined threshold value are present in the matching of the second image blocks with the code blocks, the second image blocks are output as they are instead of the code blocks similar to the second image blocks, and the second image blocks are written into the new image region around the coordinates of the second edge points corresponding to a defective place. 
         [0046]    According to a sixth aspect of the present invention, there is provided a method of detecting a defect in an imaged object, the method comprising: 
         [0047]    detecting a first edge and the directions of the first edge from a code book preparation image having the first edge; 
         [0048]    cutting, in preset sizes, first regions out of a code book preparation image to generate a plurality of first image blocks, each of the first regions surrounding and including an edge point of the first edge; 
         [0049]    executing quantization processing regarding the first image blocks as multidimensional vectors to form code blocks for each of the directions of the first edge; 
         [0050]    allocating identification codes to the code blocks to prepare a code book; 
         [0051]    acquiring an image of the imaged objected; 
         [0052]    detecting a second edge which is the edge of the imaged object and the directions of the second edge from the image of the imaged object; 
         [0053]    cutting, in preset sizes, second regions out of the image of the imaged object to generate a plurality of second image blocks, each of the second regions surrounding and including an edge point of the detected second edge; 
         [0054]    selecting, from the code book, code blocks corresponding to the directions of the second edge to match these code blocks with the second image blocks, and defining the code blocks which have obtained matching scores exceeding a predetermined threshold value as code blocks having first identification codes and similar to the second image blocks; and 
         [0055]    taking, from the code book, the code blocks having the first identification codes to write these code blocks into a new image region along the directions of the second edge and around the coordinates of the second edge points, 
         [0056]    wherein second identification codes corresponding to the second image blocks in which the matching scores are equal to or less than the predetermined threshold value are preset in the code book, and 
         [0057]    when the second image blocks in which the matching scores are equal to or less than the predetermined threshold value are present in the matching of the second image blocks with the code blocks, the image blocks whose gradation values are 0 are written into the new image region around the coordinates of the second edge points corresponding to a defective place in accordance with the second identification codes. 
         [0058]    According to a seventh aspect of the present invention, there is provided a semiconductor device manufacturing method comprising executing a semiconductor device manufacturing process for a semiconductor substrate judged by a defect detection method for a pattern formed on the semiconductor substrate that the pattern has no defect, the defect detection method including: 
         [0059]    detecting a first edge and the directions of the first edge from a code book preparation image having the first edge; 
         [0060]    cutting, in preset sizes, first regions out of the code book preparation image to generate a plurality of first image blocks, each of the first regions surrounding and including an edge point of the detected first edge; 
         [0061]    executing quantization processing regarding the first image blocks as multidimensional vectors to form code blocks for each of the directions of the first edge; 
         [0062]    allocating identification codes to the code blocks to prepare a code book; 
         [0063]    acquiring an image of the pattern; 
         [0064]    detecting a second edge which is the edge of the pattern and the directions of the second edge from the image of the pattern; 
         [0065]    cutting, in preset sizes, second regions out of the image of the pattern to generate a plurality of second image blocks, each of the second regions surrounding and including an edge point of the detected second edge; 
         [0066]    selecting, from the code book, code blocks corresponding to the directions of the second edge to match these code blocks with the second image blocks, and defining the code blocks which have obtained matching scores exceeding a predetermined threshold value as code blocks similar to the second image blocks; and 
         [0067]    taking, from the code book, the similar code blocks to write these code blocks into a new image region around the coordinates of the second edge points and along the directions of the second edge, 
         [0068]    wherein when the second image blocks in which the matching scores are equal to or less than the predetermined threshold value are present in the matching of the second image blocks with the code blocks, the second image blocks are output as they are instead of the code blocks similar to the second image blocks, and the second image blocks are written into the new image region around the coordinates of the second edge points corresponding to a defective place. 
         [0069]    According to an eighth aspect of the present invention, there is provided a semiconductor device manufacturing method comprising executing a semiconductor device manufacturing process for a semiconductor substrate judged by a defect detection method for a pattern formed on the semiconductor substrate that the pattern has no defect, the defect detection method including: 
         [0070]    detecting a first edge and the directions of the first edge from a code book preparation image having the first edge; 
         [0071]    cutting, in preset sizes, first regions out of the code book preparation image to generate a plurality of first image blocks, each of the first regions surrounding and including an edge point of the first edge; 
         [0072]    executing quantization processing regarding the first image blocks as multidimensional vectors to form code blocks for each of the directions of the first edge; 
         [0073]    allocating identification codes to the code blocks to prepare a code book; 
         [0074]    acquiring an image of a pattern; 
         [0075]    detecting a second edge which is the edge of the pattern and the directions of the second edge from the image of the pattern; 
         [0076]    cutting, in preset sizes, second regions out of the image of the pattern to generate a plurality of second image blocks, each of the second regions surrounding and including an edge point of the detected second edge; 
         [0077]    selecting, from the code book, code blocks corresponding to the directions of the second edge to match these code blocks with the second image blocks, and defining the code blocks which have obtained matching scores exceeding a predetermined threshold value as code blocks having first identification codes and similar to the second image blocks; and 
         [0078]    taking, from the code book, the code blocks having the first identification codes to write these code blocks into a new image region around the coordinates of the second edge points and along the directions of the second edge, 
         [0079]    wherein second identification codes corresponding to the second image blocks in which the matching scores are equal to or less than the predetermined threshold value are preset in the code book, and 
         [0080]    when the second image blocks in which the matching scores are equal to or less than the predetermined threshold value are present in the matching of the second image blocks with the code blocks, the image blocks whose gradation values are 0 are written into the new image region around the coordinates of the second edge points corresponding to a defective place in accordance with the second identification codes. 
         [0081]    According to a ninth aspect of the present invention, there is provided a program which is contained in a computer-readable medium and which causes a computer to execute an image processing method comprising an image compression method, the image compression method including: 
         [0082]    detecting a first edge from a code book preparation image having the first edge; 
         [0083]    cutting, in preset sizes, first regions out of the code book preparation image to generate a plurality of first image blocks, each of the first regions surrounding and including an edge point of the detected first edge; 
         [0084]    executing quantization processing regarding the plurality of first image blocks as multidimensional vectors to form code blocks; 
         [0085]    allocating identification codes to the code blocks to prepare a code book; 
         [0086]    detecting a second edge from a compression target image having the second edge; 
         [0087]    cutting, in preset sizes, second regions out of the compression target image to generate a plurality of second image blocks, each of the second regions surrounding and including an edge point of the detected second edge; 
         [0088]    searching the code book for code blocks similar to the second image blocks; and 
         [0089]    outputting coordinates of the edge points of the second image blocks and the identification codes of the similar code blocks. 
         [0090]    According to a tenth aspect of the present invention, there is provided a program which is contained in a computer-readable medium and which causes a computer to execute an image processing method comprising an image reproduction method of reproducing a compressed image containing an edge and subjected to compression processing, the image reproduction method including: 
         [0091]    acquiring information on a code book, the code book being prepared during the compression processing by allocating identification codes to code blocks, respectively, the code blocks being formed by executing quantization processing regarding a plurality of first image blocks as multidimensional vectors, the plurality of first image blocks being generated by cutting out, in preset sizes, first regions out of a code book preparation image containing a first edge, each of the first regions surrounding and including an edge point of the first edge, the first edge being detected from the code book preparation image; 
         [0092]    reading coordinates of second edge points and identification codes of the compressed image, the compressed image being defined by the coordinates of the second edge points and the identification codes of code blocks similar to second image blocks, the second image blocks being image blocks of the compressed image among the code blocks carried by the code book; and 
         [0093]    taking, from the code book, the code blocks corresponding to the read identification codes to write these code blocks into a reproduced image region around the coordinates of the second edge points in order to form a reproduced image. 
         [0094]    According to an eleventh aspect of the present invention, there is provided a program which is contained in a computer-readable medium and which causes a computer to execute a method of detecting a defect in an imaged object within a compression target image, the method comprising: 
         [0095]    detecting a first edge and the directions of the first edge from a code book preparation image having the first edge; 
         [0096]    cutting, in preset sizes, first regions out of the code book preparation image to generate a plurality of first image blocks, each of the first regions surrounding and including an edge point of the detected first edge; 
         [0097]    executing quantization processing regarding the first image blocks as multidimensional vectors to form code blocks for each of the directions of the first edge; 
         [0098]    allocating identification codes to the code blocks to prepare a code book; 
         [0099]    acquiring an image of the imaged object; 
         [0100]    detecting a second edge which is the edge of the imaged object and the directions of the second edge from the image of the imaged object; 
         [0101]    cutting, in preset sizes, second regions out of the image of the imaged object to generate a plurality of second image blocks, each of the second regions surrounding and including an edge point of the detected second edge; 
         [0102]    selecting, from the code book, code blocks corresponding to the directions of the second edge to match these code blocks with the second image blocks, and defining the code blocks which have obtained matching scores exceeding a predetermined threshold value as code blocks similar to the second image blocks; and 
         [0103]    taking, from the code book, the similar code blocks to write these code blocks into a new image region along the directions of the second edge and around the coordinates of the second edge points, 
         [0104]    wherein when the second image blocks in which the matching scores are equal to or less than the predetermined threshold value are present in the matching of the second image blocks with the code blocks, the second image blocks are output as they are instead of the code blocks similar to the second image blocks, and the second image blocks are written into the new image region around the coordinates of the second edge points corresponding to a defective place. 
         [0105]    According to a twelfth aspect of the present invention, there is provided a program which is contained in a computer-readable medium and which causes a computer to execute a method of detecting a defect in an imaged object within a compression target image, the method comprising: 
         [0106]    detecting a first edge and the directions of the first edge from a code book preparation image having the first edge; 
         [0107]    cutting, in preset sizes, first regions out of a code book preparation image to generate a plurality of first image blocks, each of the first regions surrounding and including an edge point of the first edge; 
         [0108]    executing quantization processing regarding the first image blocks as multidimensional vectors to form code blocks for each of the directions of the first edge; 
         [0109]    allocating identification codes to the code blocks to prepare a code book; 
         [0110]    acquiring an image of the imaged objected; 
         [0111]    detecting a second edge which is the edge of the imaged object and the directions of the second edge from the image of the imaged object; 
         [0112]    cutting, in preset sizes, second regions out of the image of the imaged object to generate a plurality of second image blocks, each of the second regions surrounding and including an edge point of the detected second edge; 
         [0113]    selecting, from the code book, code blocks corresponding to the directions of the second edge to match these code blocks with the second image blocks, and defining the code blocks which have obtained matching scores exceeding a predetermined threshold value as code blocks having first identification codes and similar to the second image blocks; and 
         [0114]    taking, from the code book, the code blocks having the first identification codes to write these code blocks into a new image region along the directions of the second edge and around the coordinates of the second edge points, 
         [0115]    wherein second identification codes corresponding to the second image blocks in which the matching scores are equal to or less than the predetermined threshold value are preset in the code book, and 
         [0116]    when the second image blocks in which the matching scores are equal to or less than the predetermined threshold value are present in the matching of the second image blocks with the code blocks, the image blocks whose gradation values are 0 are written into the new image region around the coordinates of the second edge points corresponding to a defective place in accordance with the second identification codes. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0117]    In the accompanying drawings: 
           [0118]      FIG. 1  is a block diagram showing a schematic configuration of an image compression unit according to a first embodiment of the present invention; 
           [0119]      FIG. 2  is a block diagram showing a schematic configuration of an image reproduction unit according to the first embodiment of the present invention; 
           [0120]      FIG. 3  is a diagram showing one example of a code book preparation image; 
           [0121]      FIG. 4  is a diagram showing one example of a compression target image; 
           [0122]      FIG. 5  is a diagram showing one example of an image reproduced according to the first embodiment of the present invention; 
           [0123]      FIGS. 6A to 6D  are diagrams explaining a method of cutting out an image block in an image compression method according to the first embodiment of the present invention; 
           [0124]      FIG. 7  is a table showing an application of the first embodiment of the present invention; and 
           [0125]      FIG. 8  is a table showing the relation between circuit speeds and transfer times for each image size in a conventional art. 
       
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
       [0126]    Embodiments of the present invention will hereinafter be described with reference to the drawings. An SEM image of a micropattern formed in a semiconductor manufacturing process such as a lithography process or an etching process will be described below by way of example, but it should be understood that the present invention is not limited to the SEM image and can be used for subject images in general in various other fields. 
       (1) First Embodiment 
       [0127]    An image processing apparatus according to a first embodiment of the present invention will be described with reference to  FIG. 1  and  FIG. 2 . The image processing apparatus in the present embodiment comprises a code book type image compression unit  2 , and a code book type image reproduction unit  4 . Hereinafter, a code book means a reference table (look-up table) of a code corresponding to a code vector. 
         [0128]      FIG. 1  is a block diagram showing a schematic configuration of the image compression unit  2 . The image compression unit  2  comprises an image input unit  12 , an edge detection unit  14 , an image block generation unit  16 , a matching unit  18 , a code book storage unit  20 , a variable length encoding unit  22 , and a compressed data output unit  24 . 
         [0129]    The image input unit  12  acquires a compression target image, and inputs the compression target image to the edge detection unit  14 . The edge detection unit  14  detects edge points of a micropattern as image blocks together with the directions thereof from the input compression target image. The image block generation unit  16  cuts out the image around the detected edge points. The code book storage unit  20  stores a code book prepared by procedures  1  to  5  described later. The matching unit  18  selects from the code book an image block whose direction is closest to the direction of the image block added to information on the image blocks supplied from the image block generation unit  16  (matching). The matching unit  18  then supplies information on coordinates of the edge point of the cut-out image block together with an identification code of the selected image block to the variable length encoding unit  22 . The variable length encoding unit  22  performs variable length encoding processing on the sent coordinates of the edge point of the image block and on the identification code of the selected image block, and supplies them as compressed data to the compressed data output unit  24 . The compressed data output unit  24  outputs the compressed data to the outside. In the present embodiment, the matching unit  18  corresponds to, for example, a searching unit, and the variable length encoding unit  22  and the compressed data output unit  24  correspond to, for example, an output unit. 
         [0130]      FIG. 2  is a block diagram showing a schematic configuration of the image reproduction unit  4 . The image reproduction unit  4  comprises a compressed data input unit  42 , a variable length code input unit  44 , an image block composition unit  52 , and an image output unit  54 . In response to the supply of the compressed data from the compressed data output unit  24  of the image compression unit  2 , the compressed data input unit  42  sends the compressed data to the variable length code input unit  44 . The variable length code input unit  44  decompresses the compressed data, and supplies the coordinates of the edge point of the image block and the identification code thereof to the image block composition unit  52 . A code book storage unit  50  stores the same code book as the code book stored in the code book storage unit  20  in  FIG. 1 . The image block composition unit  52  takes, from the code book, the image block corresponding to the identification code around the edge point coordinates sent from the variable length code input unit  44 , and writes the image block into a predetermined reproduced image region, thereby forming a reproduced image. The image output unit  54  outputs, as the reproduced image, the image formed by the image block composition unit  52 . In the present embodiment, the compressed data input unit  42  and the variable length code input unit  44  correspond to, for example, a reading unit. 
         [0131]    An image compression and reproduction method using the compression unit  2  and the reproduction unit  4  respectively shown in  FIG. 1  and  FIG. 2  will be described as an image processing method according to the first embodiment of the present invention with reference to  FIG. 3  to  FIG. 7 . The procedures will be described below in detail in which a compression target image Imo (769 KB) in  FIG. 4  is compressed using a code book prepared from a code book preparation image Imr shown in  FIG. 3 , and reproduced as a reproduced image (258 KB) in  FIG. 5 . 
         [0132]    (i) Preparation of Code Book 
         [0133]    It is necessary to prepare a code book before the compression of an image. In the present embodiment, there is shown a method in which the code book is prepared using the code book preparation image Imr similar to the compression target image Imo. 
         [0134]    (Procedure 1) 
         [0135]    A pattern edge is detected from the code book preparation image Imr. The present embodiment is characterized in that not only the edge points but also the direction of the edge is detected at this point. Any algorithm may be used in detecting the edge. For example, according to a method using a Sobel filter, the edge points and the direction of the edge can be detected at the same time. However, the present invention is not limited to this method, and it is possible to use a method which separately obtains the edge points and the direction of the edge. The edge points may be obtained with sub-pixel accuracy, but in the present embodiment, the edge points are detected pixel by pixel at angles of 0, 45, 90 and 135 degrees in accordance with a method of Canny. In addition, 45 degrees are employed here as the degrees of dividing the direction, but the divisions may be smaller or larger depending not only on the quality of the compression target image, but also on specifications required for the use of the image such as measurement. 
         [0136]    (Procedure 2) 
         [0137]    Next, an image of a region having a predetermined number of pixels which includes the edge points and which surrounds the edge points is cut out as an image block from the code book preparation image Imr. In the present embodiment, an image of a region having 7×21 pixels is cut out around the edge points. This region may include parts in which different edge points overlap each other. However, it is necessary to change the shape of the region in accordance with the direction in which the edge points belong.  FIGS. 6A to 6D  illustrate regions (image blocks BL 1  to BL 4 ) reduced to 3×7 in the directions of 0 degree ( FIG. 6A ), 45 degrees ( FIG. 6B ), 90 degrees ( FIG. 6C ) and 135 degrees ( FIG. 6D ). In addition, cells of the edge points are indicated by crossed slant lines in these drawings. 
         [0138]    (Procedure 3) 
         [0139]    The respective image blocks cut out and generated from the code book preparation image Imr by Procedure 2 above are regarded as vectors distributed in a multidimensional space, and a predetermined number of representative vectors are generated per direction using a method of vector quantization.  32  representative vectors are generated in the present embodiment, such that 4×32=128 image blocks are generated in the present embodiment. 
         [0140]    (Procedure 4) 
         [0141]    For an image remaining after the image blocks are cut out of the code book preparation image Imr (such a region is called non-edge region in which the amount of information as edge information has been reduced due to the cutout of the main parts of the pattern edge), an average value of its gradation values is calculated. When the image is divided into several regions, an average value may be calculated for each region. 
         [0142]    (Procedure 5) 
         [0143]    Identification codes are given to the image blocks generated by Procedure 3 and to the average gradation value of the non-edge region calculated by Procedure 4, and a code book is prepared so that the contents of the image blocks and the non-edge region can be referred to by the identification codes. At this point, additional information such as information on an edge detection method and information on the setting of the image blocks may be written together into the code book. 
         [0144]    (ii) Compression of Image 
         [0145]    (Procedure 6) 
         [0146]    The compression unit  2  shown in  FIG. 1  reads the code book prepared by Procedures 1 to 5 above to acquire the information necessary for the pre-processing of the image compression, and stores the information in a predetermined storage area of the code book storage unit  20 . In the present embodiment, the edge detection method and the kind of edge direction are acquired together as the additional information. 
         [0147]    In addition, it is possible to use a method which writes such information in the code book, and it is also possible to omit the reading procedure by previous arrangement. 
         [0148]    (Procedure 7) 
         [0149]    In response to the supply of the compression target image, for example, an 8-bit gray scale image Imo of 512×512 pixels shown in  FIG. 4  from the image input unit  12 , the edge detection unit  14  performs edge detection processing on this image Imo. At this point, not only the edge points but also the direction of the edge is detected as in the code book preparation procedure described above. Procedure 7 is similar to Procedure 1 in that any algorithm may be used for the detection of the edge and in that the edge points may be obtained with sub-pixel accuracy, but it is not always necessary to use the same edge detection method as that in Procedure 1. In the present embodiment, the edge points are detected pixel by pixel in directions of 0, 45, 90 and 135 degrees using the method of Canny in Procedure 1. These directions do not necessarily have to be the same as the directions written in the code book, but at least one direction written in the code book is necessary. Since the total number of extracted edge points and the kind of direction influence the compression ratio, a user may be allowed to set these by a graphical user interface (GUI). 
         [0150]    (Procedure 8) 
         [0151]    In accordance with a procedure similar to Procedure 2, the image block generation unit  16  cuts out, from the compression target image Imo, the image of the region around the edge points which includes the edge points detected in the compression target image Imo, and thus generates a plurality of image blocks. When the edge points are detected in sub-pixel units, the region around the pixels where the edge points are present is cut out. Here, the positional relation between the edge points and the cut out region need to be the same as the positional relation at the time of the preparation of the code book. This positional relation may be written as additional information in the code book. 
         [0152]    (Procedure 9) 
         [0153]    The image blocks in the direction which best corresponds to the direction of the cut-out image block are selected from the code book. In the present embodiment, a score value obtained by image matching using the matching unit  18  serves as the standard of selection. However, the selection method is not limited to this, and any parameters may be used as long as such parameters indicate the correlation of the images. 
         [0154]    (Procedure 10) 
         [0155]    The variable length encoding unit  22  performs the variable length encoding processing on the identification code of the image block selected and supplied by the matching unit  18  (hereinafter referred to as a similar image block) together with the edge point coordinates, and writes them as compressed data in a data file. As a result, the compression target image Imo can be written in three elements (X coordinates of the edge points, Y coordinates of the edge points, and an identification code number of the similar image block). Therefore, for example, the number of edge points is 100, coordinate values of the edge points are detected with an accuracy of 12 bits, and the number of codes of the code book is 8 bit, in which case the file size of the compression target image Imo of 256 KB is 100×(12 bits×2+8 bits) and is thus compressed to about one eightieth. In the present embodiment, no processing is particularly performed to decrease the number of edge points, so that the file size is compressed to 151 KB, remaining at about 60% compression. 
         [0156]    The compressed data output unit  24  outputs compressed data in which edge point coordinates and identification code are written in the above mentioned manner. 
         [0157]    (iii) Reproduction of Image 
         [0158]    The image file compressed in Procedures 6 to 10 above is reproduced using the same code book as the code book used for the compression. 
         [0159]    (Procedure 11) 
         [0160]    First, the user specifies a file name of the code book used for the compression via unshown specifying means of the reproduction unit  4 . In response to this specification, the code book storage unit  50  stores its contents in a predetermined storage area. 
         [0161]    (Procedure 12) 
         [0162]    The compressed data input unit  42  reads the compressed image file, and the variable length code input unit  44  decompresses the compressed data and supplies the edge point coordinates and the identification code of the image block to the image block composition unit. The image block composition unit  52  first secures, within an unshown storage area, a memory area corresponding to the size of the image to be reproduced. The size of the memory area in the present embodiment is 512×512. The size of the image to be reproduced may be decided by decompressing in the variable length code input unit  44  a compressed file to which the size of the compression target image is attached in Procedure 10 above, or may conform to a preset size. 
         [0163]    (Procedure 13) 
         [0164]    Next, the image block composition unit  52  takes the image block corresponding to the number of the identification code from the code book stored in the code book storage unit, and writes all the image blocks in the reproduced image area secured in the unshown storage area by Procedure 12 around the edge point coordinates obtained by the decompression of the compressed data and along each direction of the edge. 
         [0165]    (Procedure 14) 
         [0166]    Here, when an area is produced where image blocks overlap each other, the average of the gradation values of these image blocks is considered as the volume of pixels of the image to be reproduced. 
         [0167]    (Procedure 15) 
         [0168]    When there is an area with no gradation value, a pixel value provided as an average gradation value of the non-edge region from the code book is brought into this area. Thus, an image of 512×512×8 bits is reproduced. 
         [0169]    The image compressed and reproduced by Procedures 6 to 15 above has been subjected to color subtraction, as shown in  FIG. 5 . Therefore, if lossless compression such as a graphic interchange format (GIF) is applied to the reproduced image, it is possible to achieve a file size smaller than the compressed image file. In the present embodiment, the file size is compressed to 77 KB which is about ten percent of the size of the compression target image. 
         [0170]    Thus, according to the present embodiment, natural images such as the SEM images can be efficiently compressed and reproduced with high accuracy. Moreover, costs for data storage and a load of network transfer can be reduced owing to the reduction of the file size. 
         [0171]    Several applications of the present embodiment are shown in a table of  FIG. 7 . 
       (2) Second Embodiment 
       [0172]    The code book carries the average gradation value of the non-edge region in the first embodiment described above, but the average gradation value may be extracted by the procedure of compressing the compression target image Imo and written in a compressed file. At this point, when the non-edge region is divided into a plurality of regions, a more natural reproduced image can be obtained if a procedure is added which comprises calculating an average gradation value for each of the divided regions and writing the average gradation values in the code book together with the positions of the divided regions, and reading, from the code book, the positions of the divided regions and the average gradation values in image reproduction processing and writing them in the reproduced image. For example, barycentric coordinates can be used for the positions of the divided regions. 
       (3) Third Embodiment 
       [0173]    In the present embodiment, procedures will be described for detecting an edge from a compression target image Imo with sub-pixel accuracy. The procedures of compression as such are the same as Procedures 6 to 10 described above in the first embodiment except that the size of a compressed file is increased. These procedures are different from Procedures 11 to 15 above in that a region for a reproduced image is prepared in a sub-pixel size in reproducing the image. That is, when an edge is requested with an accuracy of, for example, 1/10, a reproduced image is considered to be sized at 5120×5120 which is ten times the size of the memory area described above in Procedure 11 in the respective directions thereof, and image blocks are written in this region as in the first embodiment. The reproduced image thus generated has a size of 5120×5120. This image may be displayed as is, or used for remeasurement, or converted to a size of 512×512 by the compression of its pixels. 
       (4) Fourth Embodiment 
       [0174]    In the present embodiment, how to apply the image processing method according to the present invention to the detection of a defect will be described. When there is a defect, it means that the kind of edge which is not present in a code book preparation image is in a compression target image. In this case, a threshold value can be set in a score value in Procedure 9 in the first embodiment described above, and this threshold value can be used to detect the defect (see (v) in  FIG. 7 ). For example, when a score value equal to or less than the threshold value can only be obtained in matching processing by a matching unit  18 , an image block part of a compression target image Imo to which a corresponding similar image block can not be allotted is written as is in a compressed file as indicated by a dotted line part in  FIG. 1 , and this image block is used at the time of reproduction as indicated by a dotted line part in  FIG. 2 , the defect can be reproduced in the reproduced image. On the other hand, when it is not desired to reproduce the defect, the threshold value of a matching score is set to 0, such that the reproduced image can be expressed almost forcibly with the image blocks in the code book alone. Further, an identification code corresponding to the block equal to or less than the threshold value of the matching score is preset in the code book, and if the gradation value is brought to, for example, 0 at the time of reproduction, the defective region emerges as a white region on a colored background in the reproduced image, such that the defect can be rapidly and easily detected. 
       (5) Fifth Embodiment 
       [0175]    The present embodiment provides a method of removing, in image processing, the effect of charging due to the application of an electron beam in acquiring, for example, an SEM image. 
         [0176]    As illustrated by the code book preparation image Imr in  FIG. 1  and the compression target image Imo in  FIG. 2 , the code book is generally prepared using an image representing the compression target image. In the present embodiment, with an expectation of effects shown in a reproduced image, an ordinary image is used for the code book, while an image is selected as the compression target image in which the nonuniformity of contrast has been caused due to the effect of the charging. In this case as well, edges are substantially similarly detected in both of the images, but the asymmetry of the compression target image is not reproduced when the compressed image is reproduced because the code book preparation image has no asymmetry of the edge due to the change of contrast. 
         [0177]    Thus, according to the present embodiment, it is possible to obtain a reproduced image in which the effects of the charging in the compression target image are removed, without adding new procedures (see (iv) in  FIG. 7 ). 
       (6) Program 
       [0178]    A series of procedures of the image processing method described above may be read into and executed by a computer as a program to be executed by the computer. This makes it possible to achieve the image processing method according to the present invention by use of a general-purpose computer. The program may be read by the computer after contained in a recording medium. The recording medium is not limited to a portable medium such as a flexible disk, a magnetic disk, a CD-ROM or an optical disk, and may be a fixed recording medium such as a hard disk drive or a memory. Further, the program incorporating the series of procedures of the image processing method described above may be distributed via a communication line (including wireless communication) such as the Internet. Moreover, the program incorporating the series of procedures of the image processing method described above may be distributed in an encrypted, modulated or compressed state via a wired line such as the Internet or a wireless line or in a manner stored in a recording medium. 
       (7) Semiconductor Device Manufacturing Method 
       [0179]    When the defect detection method described above in the fourth embodiment is used in a process of manufacturing a semiconductor device, a defect in a pattern can be detected with high accuracy and in a short time, such that the semiconductor device can be manufactured with higher throughput and yield. 
         [0180]    More specifically, a semiconductor substrate is extracted per production lot, and a defect in a pattern formed on the extracted semiconductor substrate is detected by the defect detection method described above. When the semiconductor substrate is judged as a nondefective product as a result of the defection, the rest of the manufacturing process is continuously executed for the whole production lot to which the evaluated semiconductor substrate belongs. On the other hand, the semiconductor substrate exceeds a threshold value set in accordance with the specifications of a product and is judged as a defective product because a defect is found therein as a result of the detection, but the semiconductor substrate can be reworked, in which case rework processing is executed for the production lot to which the semiconductor substrate judged as the defective product belongs. When the rework processing is finished, the semiconductor substrate is extracted from the production lot and again subjected to defect detection. If the extracted semiconductor substrate is judged as a nondefective product as a result of the redetection, the rest of the manufacturing process is executed for the production lot finished with the rework processing. In addition, when the rework processing is impossible, the production lot to which the semiconductor substrate judged as the defective product belongs is disposed of. When the cause of the defect can be analyzed, results of the analysis are fed back to a person in charge of designing, a person in charge of an upstream process or the like.