KR102090568B1 - Image processing method and defect inspection method - Google Patents

Image processing method and defect inspection method Download PDF

Info

Publication number
KR102090568B1
KR102090568B1 KR1020180069570A KR20180069570A KR102090568B1 KR 102090568 B1 KR102090568 B1 KR 102090568B1 KR 1020180069570 A KR1020180069570 A KR 1020180069570A KR 20180069570 A KR20180069570 A KR 20180069570A KR 102090568 B1 KR102090568 B1 KR 102090568B1
Authority
KR
South Korea
Prior art keywords
image
difference
pixel
value
original
Prior art date
Application number
KR1020180069570A
Other languages
Korean (ko)
Other versions
KR20190001914A (en
Inventor
츠카사 가토
다이조 우메자키
Original Assignee
가부시키가이샤 도쿄 웰드
다이조 우메자키
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 가부시키가이샤 도쿄 웰드, 다이조 우메자키 filed Critical 가부시키가이샤 도쿄 웰드
Publication of KR20190001914A publication Critical patent/KR20190001914A/en
Application granted granted Critical
Publication of KR102090568B1 publication Critical patent/KR102090568B1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/174Segmentation; Edge detection involving the use of two or more images
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20212Image combination
    • G06T2207/20224Image subtraction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30108Industrial image inspection
    • G06T2207/30164Workpiece; Machine component

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Investigating Materials By The Use Of Optical Means Adapted For Particular Applications (AREA)
  • Image Processing (AREA)
  • Image Analysis (AREA)

Abstract

본 발명은 피검사물의 촬상 화상으로부터 검사 대상 영역을 선별할 때에, 작업자에게 숙련을 요구하는 판단 등의 부담이 생기는 것을 경감하며, 또한 임계값을 간단하게 설정해서 검사 대상 영역을 용이하게 선출하는 것을 가능하게 하는 것을 과제로 한다.
이러한 과제를 해결하기 위한 수단으로서 화상 처리 방법은, 기준 직선에 대하여 선대칭이 되는 제 1 및 제 2 영역을 갖는 단색의 원(原)화상을, 기준 직선에 의해 제 1 및 제 2 영역으로 분할하고, 제 1 및 제 2 영역 내에서 기준 직선에 대하여 선대칭의 위치에 배치되는 2개의 원(原)화소의 각 페어(pair)에 대해서, 2개의 원화소의 화소값의 차분이 되는 차분 화소값을 산출하는 차분 산출 공정을 구비한다. 화상 처리 방법은 또한, 차분 화소값을 갖는 차분 화소를 배치해서 차분 화상을 생성하는 차분 화상 생성 공정으로서, 제 1 영역 내의 제 1 위치의 원화소와 제 2 영역 내의 제 2 위치의 원화소의 페어를 이용하여 산출된 차분 화소값을 갖는 차분 화소를, 차분 화상의 제 1 및 제 2 위치에 배치해서 차분 화상을 생성하는 차분 화상 생성 공정을 구비한다.
The present invention alleviates the burden of judgment, etc. that requires skill from an operator when selecting an inspection target area from a captured image of an inspected object, and also makes it easy to select an inspection target area by simply setting a threshold. The task is to make it possible.
As a means for solving such a problem, the image processing method divides a monochromatic original image having first and second regions that are line-symmetric with respect to a reference straight line into first and second regions by a reference straight line. , A difference pixel value that is a difference between the pixel values of the two original pixels for each pair of the two original pixels arranged at a line symmetry position with respect to the reference straight line in the first and second regions A difference calculating step for calculating is provided. The image processing method is also a difference image generation process in which a difference image is generated by arranging difference pixels having difference pixel values, and a pair of an original pixel at a first position in a first area and an original pixel at a second position in a second area And a difference image generation process in which a difference pixel having a difference pixel value calculated by using is arranged in first and second positions of the difference image to generate a difference image.

Description

화상 처리 방법 및 결함 검사 방법{IMAGE PROCESSING METHOD AND DEFECT INSPECTION METHOD}Image processing method and defect inspection method {IMAGE PROCESSING METHOD AND DEFECT INSPECTION METHOD}

본 발명은 촬상 장치에 의해 피검사물의 표면을 촬상해서 얻어진 촬상 화상을 이용하여, 피검사물의 표면에 대하여 결함 검사를 행해야 할 검사 대상 영역을 선출하는 화상 처리 방법 및 그것을 이용한 결함 검사 방법에 관한 것이며, 특히 선대칭성을 갖는 피검사물에 대하여, 결함의 종류에 의존하지 않고, 고정밀도이면서 또한 용이하게 검사 대상 영역을 선출하는 것이 가능한 화상 처리 방법 및 그것을 이용한 결함 검사 방법에 관한 것이다.The present invention relates to an image processing method for selecting an inspection target area to be subjected to defect inspection on a surface of an object to be inspected using a captured image obtained by imaging the surface of the object to be inspected by an imaging device, and a defect inspection method using the same In particular, it relates to an image processing method and a defect inspection method using the same, which is capable of selecting a region to be inspected with high precision and easily, regardless of the type of defect, for an inspected object having line symmetry.

촬상 장치에 의해 피검사물의 표면을 촬상해서 얻어진 촬상 화상을 이용하여, 피검사물의 표면에 대하여 결함의 유무를 검사하는 결함 검사가 널리 행해지고 있다. 출원인은, 크랙이라고 불리는 선상(線狀) 결함을 검출하는 결함 검사 방법을 이미 출원하고 있다(특허문헌 1).Defect inspection is widely performed to inspect the surface of an object to be inspected for the presence or absence of a defect by using the captured image obtained by imaging the surface of the object to be inspected by an imaging device. The applicant has already applied for a defect inspection method for detecting linear defects called cracks (Patent Document 1).

피검사물의 표면에는, 상기 크랙 이외에도 균열, 흠집, 타흔(打痕), 마킹 미스 등의 다방면에 걸치는 결함이 존재한다. 그들 결함을 검출할 때에는, 디지털화한 촬상 화상을 디지털 처리하는 화상 처리 알고리즘(화상 처리 방법)을 이용할 수 있다.On the surface of the inspected object, in addition to the above-mentioned cracks, there are defects covering various aspects such as cracks, scratches, marks, and misses. When detecting these defects, an image processing algorithm (image processing method) that digitally processes the digitized captured image can be used.

피검사물을 촬상하는 촬상 장치로서, CCD(Charged-coupled devices) 혹은 CMOS(Complementary metal-oxide-semiconductor)와 같은 촬상 소자를 탑재한 카메라가 사용되고 있다. 촬상 시에 피검사물로부터 나온 광이 이들 촬상 소자에 입력되면, 광의 강약이 전기 신호의 강약으로 변환되어서 디지털화되어, 디지털 화상으로서 기록된다.As an imaging device for imaging an object to be inspected, a camera equipped with an imaging element such as a charged-coupled devices (CCD) or a complementary metal-oxide-semiconductor (CMOS) is used. When light emitted from the object to be inspected is input to these imaging elements at the time of imaging, the intensity of light is converted into the intensity of electrical signals, digitized, and recorded as a digital image.

(1) 디지털 화상(1) Digital image

여기서, 디지털 화상에 대해 설명한다. 화상을 구성하는 최소 요소를 화소라고 하며, 디지털 화상은 2차원으로 배열된 화소로 이루어진다. 각 화소는 색 정보로서 0과 1을 조합시킨 2진법으로 표현되는 수치를 개별적으로 갖고 있으며, 이 수치가 피검사물로부터 나온 광의 강도나 피검사물의 표면의 색을 나타내고 있다. 각 화소가 갖는 수치를 화소값이라고 하며, 화상은 예를 들면 컬러 화상, 그레이 스케일 화상 등의 종류로 나누어진다.Here, the digital image will be described. The minimum element constituting the image is called a pixel, and the digital image is composed of pixels arranged in two dimensions. Each pixel individually has a numerical value expressed by a binary method in which 0 and 1 are combined as color information, and the numerical value represents the intensity of light emitted from the inspected object or the color of the surface of the inspected object. The numerical value of each pixel is referred to as a pixel value, and images are divided into, for example, color images and gray scale images.

컬러 화상에서는, 하나의 화소의 색은 당해 화소를 구성하는 성분으로서의 R(빨강), G(초록), B(파랑) 삼원색의 성분 비율에 의해 결정된다. 따라서, 컬러 화상에서 1개의 화소의 화소값을 표현할 때에는, RGB 요소를 각각 8비트로 표현한 24비트(= 8비트×3색)를 사용하는 경우가 많다.In a color image, the color of one pixel is determined by the ratio of the components of the three primary colors of R (red), G (green), and B (blue) as components constituting the pixel. Therefore, when expressing the pixel value of one pixel in a color image, 24 bits (= 8 bits x 3 colors) in which RGB elements are represented by 8 bits are often used.

컬러 화상에 대하여, 흑백의 농담으로 표현한 화상을 그레이 스케일 화상이라고 한다. 그레이 스케일 화상은 1개의 화소의 화소값을 8비트로 표현하며, 색 정보는 포함하지 않고 밝기 정보만을 포함하고 있다. 어두운 화소는 낮은(작은) 화소값을 갖고, 밝은 화소는 높은(큰) 화소값을 갖고 있다. 이러한 명암 단계의 수를 계조라고 한다. 1개의 화소에 할당하는 정보량에 의해 계조는 변화된다. 여기에, 정보량의 단위를 비트수라고 하며, 비트수가 클수록 계조가 커진다. 구체적으로는 비트수를 n으로 했을 때의 계조수는 2n이 된다. 예를 들면 상기 그레이 스케일 화상은 비트수가 8비트이기 때문에, 계조수는 28=256이 된다. 그리고 계조수가 256이기 때문에, 그레이 스케일 화상에 있어서의 화소값의 최소값은 칠흑에 대응하는 0이고, 최대값은 순백에 대응하는 255이다.For a color image, an image expressed in black and white shades is called a gray scale image. A gray scale image expresses a pixel value of one pixel in 8 bits, and does not include color information, but only brightness information. Dark pixels have low (small) pixel values, and bright pixels have high (large) pixel values. This number of contrast steps is called gradation. The gradation varies depending on the amount of information allocated to one pixel. Here, the unit of the amount of information is called the number of bits, and the larger the number of bits, the larger the gradation. Specifically, the number of gradations when the number of bits is n is 2 n . For example, since the gray scale image has 8 bits, the number of gradations is 2 8 = 256. And since the number of gradations is 256, the minimum value of the pixel value in the gray scale image is 0 corresponding to jet black, and the maximum value is 255 corresponding to pure white.

또한 컬러 화상에 있어서는, 색을 상기 R(빨강), G(초록), B(파랑)의 삼원색으로 분해하고, 각각의 색에 대해서 밝기를 같은 계조수로 표현하는 경우가 많다. 이것은, 컬러 화상으로부터 3개의 그레이 스케일 화상 즉 단색 화상을 생성하는 것과 등가이다. 상기의 그레이 스케일 화상의 계조수 256(8비트)을 RGB 각 색에 적용하면, 전술한 바와 같이 컬러 화상은 비트수가 8비트×3색=24비트가 된다. 이 경우의 계조수는 224=16777216이 되며, 이 계조수에 의해 모든 색을 디지털 화상에 의해 표현하는 것이 가능하다. 컬러 화상을 24비트로 표현한 색은, 인간의 눈으로 보았을 때에 극히 자연스러운 색으로 느껴진다. 이 때문에, 24비트로 표현한 컬러 화상의 것을 풀(full) 컬러 화상이라고 부른다.In addition, in a color image, colors are often decomposed into three primary colors of R (red), G (green), and B (blue), and the brightness is often expressed in the same number of gradations for each color. This is equivalent to generating three gray scale images, that is, monochrome images from color images. When the number of gradations of the gray scale image 256 (8 bits) is applied to each color of RGB, as described above, the color image has 8 bits x 3 colors = 24 bits. The number of gradations in this case is 2 24 = 16777216, and it is possible to express all colors with a digital image. The color that expresses a color image in 24-bit feels extremely natural when viewed with the human eye. For this reason, a color image expressed in 24-bit is called a full color image.

컬러 화상으로부터 단색 화상을 생성하는 방법은, 상기한 바와 같이 컬러 화상을 R(빨강), G(초록), B(파랑)의 삼원색으로 분해해서 3개의 단색 화상을 생성하는 것에 한정되지 않는다. 그 외에 컬러 화상으로부터 하나의 단색 화상을 생성하는 방법도 있다. 그 일례로서, 텔레비전의 방송 규격으로서 알려진 NTSC 신호를 사용하는 방법이 있다. NTSC 신호를 얻기 전단계에서 사용되는 컴포넌트 신호로서 YIQ 신호가 있는데, 이 YIQ 신호의 Y 성분은 휘도값이다. 이제, 컬러 화상의 신호 즉 R 신호, G 신호, B 신호 각각의 화소값인 ER, EG, EB에 계수를 곱해 가산하여, 새로운 화소값으로서의 휘도값 Y를 생성하는 것을 생각한다. 그 때에, 인간의 눈에 보이는 휘도에 가장 가까워지도록, NTSC 계수를 사용한 가중평균을 적용하는 것이 알려져 있다. 구체적으로는, Y=0.299ER+0.687EG+0.114EB의 연산을 행하여, 휘도값 Y를 생성한다.The method for generating a monochromatic image from a color image is not limited to generating three monochromatic images by decomposing the color image into three primary colors of R (red), G (green), and B (blue), as described above. In addition, there is a method of generating a single monochrome image from a color image. As an example, there is a method using an NTSC signal known as a television broadcasting standard. As a component signal used in the step before obtaining the NTSC signal, there is a YIQ signal. The Y component of this YIQ signal is a luminance value. Now, it is considered to generate a luminance value Y as a new pixel value by multiplying and multiplying the pixel values E R , E G , and E B of each of the signals of the color image, that is, the R signal, the G signal, and the B signal. At that time, it is known to apply a weighted average using NTSC coefficients to be closest to the luminance visible to the human eye. Specifically, Y = 0.299E R + 0.687E G + 0.114E B is calculated to generate a luminance value Y.

한편, 전술한 바와 같이 화상의 결함을 검출할 때에는, 디지털화한 촬상 화상을 디지털 처리하는 화상 처리 알고리즘을 사용할 수 있다. 이 화상 처리 알고리즘을 사용한다는 것은, 상기 화소값에 대하여 연산을 행하는 것과 다름없다. 그리고 연산 방법을 연구함으로써, 연산 결과에 의거하여 화상 중에 존재하는 결함 검사의 대상이 되는 영역을 선출할 수 있다. 그러한 선출 작용을 갖도록 연산 방법을 연구한 화상 처리 알고리즘은, 종래 기술로서 널리 사용되고 있다.On the other hand, when detecting a defect in the image as described above, an image processing algorithm that digitally processes the digitized captured image can be used. The use of this image processing algorithm is equivalent to arithmetic on the pixel values. And by studying the calculation method, it is possible to select an area to be subjected to defect inspection existing in the image based on the calculation result. Image processing algorithms that have studied computation methods to have such an elective action are widely used as prior art.

(2) 종래 기술의 화상 처리 알고리즘(2) Prior art image processing algorithm

종래 기술의 화상 처리 알고리즘에 대해, 도 32 내지 도 37을 사용하여 설명한다. 또, 이하의 설명에 있어서는, 표면의 결함 검사를 행하는 대상이 되는 피검사물을 주로 워크라고 기재한다. 또한, 상기 화상 중에 존재하는 결함 검사의 대상이 되는 영역의 것을, 검사 대상 영역이라고 기재한다. 아울러, 결함 검사의 대상이 되지 않는 영역 즉 검사 대상 영역 이외의 영역의 것을, 제외 영역이라고 기재한다.The prior art image processing algorithm will be described with reference to Figs. In addition, in the following description, the object to be inspected for surface defect inspection is mainly described as a work. In addition, the area | region which becomes the object of defect inspection existing in the said image is described as an inspection object area. In addition, an area not subject to defect inspection, that is, an area other than the inspection target area, is described as an excluded area.

워크 표면의 결함 검사를 행할 때에는, 촬상 장치를 사용하여 워크를 촬상해서 촬상 화상을 얻고, 그 촬상 화상에 대하여 화상 처리 알고리즘을 적용한다. 여기에, 얻어진 촬상 화상은 그레이 스케일 화상이라고 한다. 촬상 방법은, 워크가 예를 들면 6면체와 같은 입체 형상일 경우에는, 워크를 수평으로 설치한 받침 상에 재치하고, 워크의 각 면에 대향하는 위치에 배치한 촬상 장치를 사용하여 각 면을 촬상한다. 또한 워크가 종이 또는 얇은 판자 모양으로 형성된 목재나 수지로 이루어지는 평면 형상일 경우에는, 워크를 수평으로 설치한 받침 상에 재치하고, 받침의 상측에 배치한 촬상 장치를 사용하여 워크의 윗면을 촬상한다.When conducting defect inspection of the work surface, a work is imaged using an imaging device to obtain a captured image, and an image processing algorithm is applied to the captured image. Here, the obtained captured image is referred to as a gray scale image. In the imaging method, when the workpiece is a three-dimensional shape such as a hexahedron, for example, the workpiece is placed on a horizontally installed base, and each face is photographed using an imaging device disposed at a position facing each face of the workpiece. Take an image. In addition, when the work is a flat shape made of wood or resin formed of paper or thin board, the work is placed on a horizontally installed base, and the upper surface of the workpiece is imaged using an imaging device disposed on the upper side of the base. .

또, 이하의 설명에 있어서는 단순화를 위해, 도면에 있어서의 워크의 형상, 워크 표면에 마킹되는 표시, 워크 표면에 존재하는 결함의 형상 등은, 원, 타원, 장방형, 정방형 등의 단순한 도형을 이용하여 모식도로서 나타낸다.In the following description, for simplicity, simple shapes such as circles, ellipses, rectangles, and squares are used for the shape of the work in the drawings, the markings on the work surface, and the shape of defects on the work surface. It is shown as a schematic diagram.

도 32의 (a)는 촬상 장치를 사용하여 양품인 워크(양품 워크)(WG1)의 한면을 촬상해서 얻은 양품 화상(PG1)이며, 배경(B1) 및 워크(WG1)가 촬상되어 있다. 워크(WG1)는 장방형의 외형을 갖고, 그 표면에 원형의 표시(MG1)가 마킹되어 있다. 워크(WG1)의 대각선의 교점과 표시(MG1)의 중심 위치는 대체로 일치하고 있다.32 (a) is a good product image PG1 obtained by imaging one surface of a good work product (good work) WG1 using an imaging device, and the background B1 and the work WG1 are imaged. The work WG1 has a rectangular outer shape, and a circular mark MG1 is marked on the surface. The intersection of the diagonal lines of the work WG1 and the center position of the display MG1 are generally coincident.

도 33의 (a)는 촬상 장치를 사용하여 표면에 결함을 가진 워크, 즉 불량인 워크(불량 워크)(WD1)의 한면을 촬상해서 얻은 불량 화상(PD1)이다. 양품 화상(PG1)과 불량 화상(PD1)의 차이는, 불량 화상(PD1)의 워크(WD1) 내에 결함(D1)이 존재하고, 또한 표시(MD1) 내에 결함(D2)이 존재하는 점이다.33A is a defective image PD1 obtained by imaging one surface of a workpiece having a defect on its surface, that is, a defective workpiece (bad workpiece) WD1 using an imaging device. The difference between the good image PG1 and the bad image PD1 is that the defect D1 exists in the work WD1 of the bad image PD1, and the defect D2 exists in the display MD1.

여기에, 도 32의 (a)의 양품 화상(PG1) 및 도 33의 (a)의 불량 화상(PD1)은 모두 그레이 스케일의 디지털 화상이다. 그리고 양품 화상(PG1) 및 불량 화상(PD1)에 있어서 각 영역의 색을 목시(目視)에 의해 비교하면, 이하와 같이 되어 있다. 양품 화상(PG1) 및 불량 화상(PD1) 모두, 배경(B1)은 검고, 워크(WG1 및 WD1)는 짙은 그레이(gray)이며, 표시(MG1 및 MD1)는 희다. 또한, 불량 화상(PD1)에 있어서 워크(WD1)의 결함(D1)은 옅은 그레이이며, 표시(MD1) 상의 결함(D2)도 또한 옅은 그레이이다. 단, 똑같이 옅은 그레이여도, 결함(D2)은 결함(D1)에 비하면 약간 짙다.Here, both the good image PG1 in FIG. 32 (a) and the bad image PD1 in FIG. 33 (a) are gray scale digital images. Then, the color of each area in the good image PG1 and the bad image PD1 is compared as follows. Both the good image PG1 and the bad image PD1, the background B1 is black, the works WG1 and WD1 are dark gray, and the displays MG1 and MD1 are white. Further, in the defective image PD1, the defect D1 of the work WD1 is light gray, and the defect D2 on the display MD1 is also light gray. However, even if it is equally light gray, the defect D2 is slightly darker than the defect D1.

이들의 비교는 작업자가 도 33의 (a)의 불량 화상(PD1)을 목시한 결과이며, 실제의 불량 화상(PD1)은 전술한 바와 같이 디지털 화상으로서 촬상 장치 내에 기록되어 있다. 그 기록된 디지털 화상에 대해, 상기 각 영역의 화소값의 대소 관계를 영역의 명칭을 이용하여 부등식으로 표현하면,These comparisons are the result of the operator visualizing the defective image PD1 in Fig. 33A, and the actual defective image PD1 is recorded in the imaging device as a digital image as described above. For the recorded digital image, if the relationship between the pixel values of each area is expressed inequality using the name of the area,

배경(B1) < 워크(WD1) < 결함(D2) < 결함(D1) < 표시(MD1) (1)Background (B1) <Work (WD1) <Defect (D2) <Defect (D1) <Display (MD1) (1)

로 되어 있다. 여기에, 상기 각 영역은 모두 복수의 화소에 의해 구성되어 있다. 그리고, 동일 영역을 구성하는 복수의 화소가 갖는 화소값은 개별적으로 다른 값을 갖는다. 그러나, 이하의 설명에 있어서는 단순화를 위해, 동일 영역을 구성하는 복수의 화소는 모두 동일한 화소값을 갖는 것으로 한다.It is made. Here, each of the regions is composed of a plurality of pixels. Then, the pixel values of the plurality of pixels constituting the same area have different values individually. However, in the following description, for simplicity, it is assumed that a plurality of pixels constituting the same area have the same pixel value.

이 (1)에 나타내는 화소값의 대소 관계는, 도 33의 (a)에 나타내는 불량 화상(PD1)을 목시했을 때에, 워크(WD1)의 정상인 부분에 비해서 그 결함(D1)이 밝게(백색을 띠어) 보이는 것을 의미한다. 마찬가지로, 워크(WD1) 상의 표시(MD1)의 정상인 부분에 비해서 그 결함(D2)이 어둡게(흑색을 띠어) 보이는 것을 의미한다. 또한, 도 32의 (a)의 양품 화상(PG1)의 경우의 당해 영역의 화소값의 대소 관계는, (1)로부터 2종류의 결함과 관련된 화소값을 제외하여,When the defective image PD1 shown in Fig. 33 (a) is observed, the defect D1 is brighter (white in color) than the normal part of the work WD1 when the size relationship between the pixel values shown in (1) is observed. It means to be visible. Likewise, it means that the defect D2 is darker (in black color) than the normal portion of the display MD1 on the work WD1. In addition, in the case of the good image PG1 in Fig. 32 (a), the relationship between the pixel values of the region is excluded from (1), and the pixel values associated with the two types of defects are excluded.

배경(B1) < 워크(WG1) < 표시(MG1) (2)Background (B1) <Walk (WG1) <Display (MG1) (2)

로 되어 있다. 상기 (1)(2)의 구체적인 예로서, 도 32의 (a)의 양품 화상(PG1) 및 도 33의 (a)의 불량 화상(PD1)에 있어서의 각 영역에 부여된 부호와 각 영역의 화소값을 대응시켜서, 각각 도 32의 (b) 및 도 33의 (b)에 표형식으로 나타내고 있다. 이하, 단순화를 위해, 설명의 대상을 도 33의 (a)의 불량 화상(PD1)에 한정한다.It is made. As specific examples of (1) (2) above, the codes assigned to the respective areas in the good image PG1 in Fig. 32A and the defective image PD1 in Fig. 33A are shown. Pixel values are correlated and are shown in tabular form in Figs. 32B and 33B, respectively. Hereinafter, for the sake of simplicity, the object of explanation is limited to the defective image PD1 in Fig. 33A.

다음으로, 도 33의 (a)에 나타내는 불량 화상(PD1)을 이용하여 워크 표면의 결함 검사를 행할 때에 사용하는 화상 처리 알고리즘에 대해 설명한다. 도 33의 (a)의 불량 화상(PD1)에는 배경(B1)과 워크(WD1)가 촬상되어 있지만, 결함 검사를 행하는 대상이 되는 것은 워크(WD1)이다. 여기서, 촬상 화상 중의 워크의 위치는 촬상의 때마다 다양하게 변화된다. 일례로서 도 34의 (a)에, 도 33의 (a)와 마찬가지로 상기 불량 워크(WD1)와 다른 불량 워크(WD2)를 촬상한 불량 화상(PD2)을 나타낸다. 아울러 도 33에 있어서의 것과 마찬가지로, 도 34의 (a)에 나타내는 불량 화상(PD2)에 있어서의 각 영역에 부여된 부호와 각 영역의 화소값을 대응시켜서, 도 34의 (b)에 표형식으로 나타내고 있다.Next, an image processing algorithm used for defect inspection of the work surface using the defective image PD1 shown in Fig. 33A will be described. Although the background B1 and the work WD1 are imaged in the defective image PD1 in Fig. 33A, the work WD1 is a target for performing defect inspection. Here, the position of the work in the picked-up image varies variously each time picking up. As an example, the defective image PD2 in which the defective work WD1 and the other defective work WD2 are imaged is shown in FIG. 34 (a) as in FIG. 33 (a). In addition, similarly to that in Fig. 33, the code assigned to each area in the defective image PD2 shown in Fig. 34 (a) and the pixel value of each area are made to correspond to each other in the form of a table in Fig. 34 (b). Is showing.

도 34의 (a)의 불량 화상(PD2)에 있어서의 워크(WD2)의 위치는, 도 33의 (a)의 불량 화상(PD1)에 있어서의 워크(WD1)의 위치와는 다르다. 이 때문에, 촬상 화상마다 워크의 위치에 관계 없이 워크를 정확하게 추출하는 것이 필요하다. 이 공정을 워크 추출 공정이라고 명명한다. 워크 추출 공정에 사용할 수 있는 화상 처리 알고리즘으로서, 조사 대상 화상 중에서 특정의 화상 패턴을 추출하는 템플릿 매칭법(TM법)이 알려져 있다. 이것은, 이하의 수순으로 실행되는 알고리즘이다.The position of the work WD2 in the defective image PD2 in Fig. 34A is different from the position of the work WD1 in the defective image PD1 in Fig. 33A. For this reason, it is necessary to accurately extract the work for each captured image regardless of the position of the work. This process is called a work extraction process. As an image processing algorithm that can be used in the work extraction process, a template matching method (TM method) is known in which a specific image pattern is extracted from an image to be irradiated. This is an algorithm executed in the following procedure.

[수순 1] 상기 특정의 화상 패턴으로서[Procedure 1] As the specific image pattern described above

미리 결정된 화상 패턴(템플릿)을 준비한다.A predetermined image pattern (template) is prepared.

[수순 2] 조사 대상 화상과 템플릿을 대조(매칭)해서[Procedure 2] Contrast (match) the image and template to be investigated

가장 일치하는 개소(箇所)를 탐색한다.Search for the closest match.

[수순 3] 일치한 개소를 상기 특정의 화상 패턴으로서 추출한다.[Procedure 3] Matched locations are extracted as the specific image pattern.

예를 들면 도 33의 (a)의 불량 화상(PD1)을 조사 대상 화상으로 했을 경우에는, 도 32의 (a)의 양품 화상(PG1)에 촬상된 워크(WG1)의 형상을 템플릿으로 하면 된다. 그리고 불량 화상(PD1)과 템플릿을 대조하면, 워크(WD1)의 위치가 불량 화상(PD1) 중에서 다양하게 변화되어도, 예를 들면 도 33의 (a)와 같이 WD1이 대략 중앙에 위치할 경우에도, 혹은 도 35의 (a)에 나타내는 불량 화상(PD1a)과 같이 워크(WD1)가 오른쪽 아래에 위치할 경우에도, 도 35의 (b)와 같은 형상을 갖는 워크(WD1)를 추출할 수 있다.For example, when the defective image PD1 in FIG. 33 (a) is an image to be irradiated, the shape of the work WG1 imaged on the good image PG1 in FIG. 32 (a) may be used as a template. . Further, when the template is compared with the defective image PD1, even if the position of the work WD1 is variously changed among the defective images PD1, even when the WD1 is located approximately in the center as shown in FIG. 33 (a), for example. Alternatively, even when the work WD1 is located at the lower right, such as the defective image PD1a shown in FIG. 35 (a), the work WD1 having the shape as shown in FIG. 35 (b) can be extracted. .

다음으로 이 추출한 워크(WD1)에 대해, 검사 대상 영역과 제외 영역을 선별한다. 이 공정을 검사 영역 선별 공정이라고 명명한다. 검사 영역 선별 공정에 사용되는 종래 기술로서의 화상 처리 알고리즘은, 이하의 [조건 1]에 의해 검사 대상 영역과 제외 영역을 선별한다.Next, for the extracted work WD1, the inspection target area and the exclusion area are selected. This process is called an inspection area selection process. The image processing algorithm as a conventional technique used in the inspection area selection process selects the inspection target area and the exclusion area according to the following [Condition 1].

[조건 1] 검사 대상 영역의 화소값은,[Condition 1] The pixel value of the inspection target area is

당해 영역에 인접하는 제외 영역의 화소값과 비교해서 큰가, 작은가.Is it large or small compared to the pixel value of the excluded area adjacent to the area?

여기서, [조건 1]에 기재된「당해 영역에 인접하는 제외 영역」에는 2가지의 경우가 있다는 것에 주의해 둘 필요가 있다. 구체적으로는, 제외 영역이 검사 대상 영역의 외부에서 인접할 경우와, 검사 대상 영역의 내부에 그 부분집합으로서 내포되는 것 같이 인접할 경우가 있다. 그리고 후자의 경우에는, 제외 영역을 내포하는 검사 대상 영역을 제 1 검사 대상 영역이라고 했을 경우에, 이 내포되는 제외 영역을 제 1 검사 대상 영역에 대하여 독립한 제 2 검사 대상 영역으로서 층화(層化)하는 경우가 있을 수 있다. 그 결과로서, 복수의 검사 대상 영역을 조합시켜서 내포시키면서 검사 대상 영역을 구성하게 된다. 이러한 검사 대상 영역의 층화를 포함한 검사 영역 선별 공정에 대해, 도 35 및 도 36을 사용하여 설명한다.Here, it is necessary to note that there are two cases of the "excluded region adjacent to the region of interest" described in [Condition 1]. Specifically, there are cases where the excluded region is adjacent to the outside of the region to be inspected, and may be adjacent to the inside of the region to be examined as being contained as a subset thereof. In the latter case, when the inspection target area containing the excluded area is referred to as the first inspection target area, the nested excluded area is stratified as a second inspection target area independent of the first inspection target area. ). As a result, a region to be inspected is constructed while combining and including a plurality of regions to be inspected. The inspection area selection process including the stratification of the inspection target area will be described with reference to FIGS. 35 and 36.

먼저 도 35의 (a)의 불량 화상(PD1a)에 대하여, 템플릿 매칭법을 사용한 워크 추출 공정을 실행해서 워크(WD1)를 추출한다. 추출한 워크(WD1)는 그 위치가 불량 화상의 오른쪽 아래인 것, 및 최외측 가장자리가 장방형인 것이 명확해져 있다. 이와 같이 워크(WD1)를 추출한 뒤, 검사 영역 선별 공정을 실행한다.First, for the defective image PD1a in Fig. 35A, a work extraction process using a template matching method is executed to extract the work WD1. It is clear that the extracted work WD1 has its position at the lower right of the defective image, and the outermost edge is rectangular. After the work WD1 is extracted in this way, an inspection area selection process is performed.

검사 영역 선별 공정의 제 1 단계는, 워크(WD1)의 외측에 상기 최외측 가장자리의 치수규격의 최대값보다 α만큼 큰 치수의 둘레 테두리(F1)를 배치하여, 워크(WD1)의 최외측 가장자리를 둘러싼다. 이 제 1 단계를 실행한 뒤의 모습을 도 36의 (a)에 나타낸다. 여기에, 워크(WD1)는 제조 오차에 의해 최외측 가장자리의 치수에 편차가 생긴다. 그 치수에는 최대값 및 최소값에 의해 규정되는 규격이 있으며, 당해 규격을 만족하는 워크(WD1)가 치수에 관한 양품으로 판정된다. 그리고 이 치수에 관한 양품인 워크(WD1)를 촬상한 뒤, 전술한 템플릿 매칭법을 이용하여 워크 추출 공정을 실행하고 있다. 이 때문에, 워크 추출 공정의 결과로서 얻어진 워크(WD1)의 최외측 가장자리의 치수는, 상기 치수규격의 최대값으로부터 최소값까지의 모든 수치를 취할 가능성이 있다. 따라서, 치수규격의 최대값보다 α만큼 큰 치수의 둘레 테두리(F1)를 배치하면, 모든 워크(WD1)에 대해 최외측 가장자리의 더욱 외측에 둘레 테두리(F1)를 배치하는 것이 가능해진다.In the first step of the inspection area selection step, the outermost edge of the work WD1 is disposed by arranging a circumferential edge F1 having a dimension larger by α than the maximum value of the dimension specification of the outermost edge on the outside of the work WD1. Surrounds. The state after executing this first step is shown in Fig. 36 (a). Here, the workpiece WD1 has a deviation in the dimension of the outermost edge due to manufacturing errors. There are standards specified by the maximum and minimum values for the dimensions, and a work WD1 that satisfies the standards is judged to be a good product related to the dimensions. And after picking up the workpiece | work WD1 which is a good product regarding this dimension, the work extraction process is performed using the above-mentioned template matching method. For this reason, the dimension of the outermost edge of the work WD1 obtained as a result of the work extraction process may take all values from the maximum value to the minimum value of the dimensional standard. Therefore, by arranging the circumferential border F1 having a dimension larger than α by the maximum value of the dimensional standard, it becomes possible to arrange the circumferential border F1 further outside the outermost edge for all the works WD1.

검사 영역 선별 공정의 제 2 단계는, 도 36의 (a)의 각 영역을 구성하는 화소의 화소값에 착안해서 검사 대상 영역의 선별을 행한다. 도 36의 (a)에 있어서 제 1 단계에서 배치한 둘레 테두리(F1)와 워크(WD1)의 최외측 가장자리 사이의 영역(이하 워크 주위 영역)(WDS1)을 구성하는 화소의 화소값은, 배경(b)를 구성하는 화소의 화소값과 동일하다는 것은 명확하다. 여기서, 워크 주위 영역(WDS1)과 워크(WD1)의 화소값의 대소 관계에 착안한다. 도 33의 (b) 및 식 (1)로부터, 워크 주위 영역(WDS1)의 화소값은 배경(B1)의 화소값과 동일한 10이며, 워크(WD1)의 화소값은 100이다. 그래서, 도 36의 (a)에 있어서의 둘레 테두리(F1) 내부에 있어서, 예를 들면 화소값 50을 워크 선별 임계값(TWD1)으로서 설정한다. 그리고, 워크 선별 임계값(TWD1) 이상의 영역을 선별함으로써, 화소값이 100인 워크(WD1)의 내부를 검사 대상 영역의 후보가 되는 대상 후보 영역으로서 선별할 수 있다.In the second step of the inspection area selection step, the inspection target area is selected by focusing on the pixel values of the pixels constituting each area of FIG. 36A. The pixel values of the pixels constituting the area between the circumferential edge F1 and the outermost edge of the work WD1 (hereinafter, the area around the work) WDS1 arranged in the first step in FIG. 36A are backgrounds. It is clear that the pixel values of the pixels constituting (b) are the same. Here, the size of the pixel values of the work surrounding area WDS1 and the work WD1 is focused. 33 (b) and (1), the pixel value of the area around the work WDS1 is 10 equal to the pixel value of the background B1, and the pixel value of the work WD1 is 100. Therefore, within the circumferential frame F1 in Fig. 36A, for example, the pixel value 50 is set as the work selection threshold value TWD1. Then, by selecting an area above the work selection threshold value TWD1, the interior of the work WD1 having a pixel value of 100 can be selected as a target candidate area to be a candidate for the inspection target area.

다음으로, 검사 영역 선별 공정의 제 3 단계 이후에 있어서, 상기 대상 후보 영역 중에서 검사 대상 영역을 선별한다. 이 선별이 필요한 이유를, 이하에 설명한다. 도 36의 (a)에 있어서 워크(WD1)의 내부에 있어서의 정상 영역과 결함의 각각의 화소값을 비교하면, 도 33의 (b)에 나타내는 바와 같이 워크(WD1)(정상 영역)의 화소값은 100이며, 워크의 결함(D1)의 화소값은 200이다. 이 것으로부터, 예를 들면 워크(WD1) 내의 영역에 있어서 화소값 140을 워크 결함 임계값(TD1)으로서 설정하고, 워크 결함 임계값(TD1) 이상의 영역을 선별하면, 결함(D1)을 검출할 수 있는 것처럼 보인다. 그러나, 워크(WD1) 내의 영역에는 워크 상의 표시(M1)(정상 영역)가 존재하고 있으며, 그 화소값은 250이다. 따라서, 워크(WD1) 내의 영역에 있어서 워크 결함 임계값(TD1)으로서의 화소값 140 이상의 영역을 선별했을 경우에는, 화소값 200을 갖는 결함(D1)과 함께 정상 영역인 화소값 250을 갖는 워크 상의 표시(MD1)도 결함으로서 선별되어버린다. 이것은, 결함 검사의 결과로서 맞지 않음은 명백하다. 이것을 방지하기 위해서는, 대상 후보 영역으로서의 워크(WD1) 내의 영역으로부터 워크 상의 표시(MD1) 내의 영역을 제외한 영역을 검사 대상 영역으로 하면 된다. 이것이 검사 영역 선별 공정의 제 3 단계 이후이다.Next, after the third step of the inspection area selection process, the inspection target area is selected from the candidate candidate areas. The reason why this sorting is necessary is explained below. When the pixel values of the normal area and the defect in the interior of the work WD1 in Fig. 36A are compared, the pixels of the work WD1 (normal area) as shown in Fig. 33B. The value is 100, and the pixel value of the defect D1 of the work is 200. From this, for example, when the pixel value 140 is set as the work defect threshold value TD1 in the area within the work WD1, and the area above the work defect threshold value TD1 is selected, the defect D1 is detected. It seems to be possible. However, the display M1 (normal area) on the work exists in the area within the work WD1, and the pixel value is 250. Therefore, when an area within the work WD1 is selected with a pixel value of 140 or more as the work defect threshold value TD1, the defect D1 having the pixel value 200 and the work area having the pixel value 250 as the normal area The display MD1 is also selected as a defect. It is clear that this is not correct as a result of the defect inspection. In order to prevent this, an area to be inspected may be an area excluding the area in the display MD1 on the work from the area in the work WD1 as the target candidate area. This is after the third step of the inspection area selection process.

여기에, 상기 검사 영역 선별 공정의 제 2 단계에 있어서 선별한 워크(WD1) 내의 영역을, 제 1 대상 후보 영역이라고 명명한다. 그리고, 이 제 1 대상 후보 영역으로부터 제외해야 할 워크 상의 표시(MD1) 내의 영역을, 제 1 제외 영역이라고 명명한다. 마지막으로, 제 1 대상 후보 영역으로부터 제 1 제외 영역을 제외한 영역을, 제 1 검사 대상 영역이라고 명명한다. 구체적으로는, 검사 영역 선별 공정의 제 3 단계에 있어서, 상기 워크 추출 공정과 마찬가지의 템플릿 매칭법을 사용하여, 워크 상의 표시(MD1)만을 선별한다.Here, the region in the work WD1 selected in the second step of the inspection region selection step is referred to as a first target candidate region. The area in the display MD1 on the work to be excluded from the first target candidate area is referred to as a first exclusion area. Finally, an area excluding the first excluded area from the first candidate area is referred to as a first inspection target area. Specifically, in the third step of the inspection area selection process, only the display MD1 on the work is selected using the template matching method similar to the work extraction process.

다음으로 제 4 단계에 있어서, 상기 제 1 단계와 마찬가지로, 도 36의 (b)에 나타내는 바와 같이 워크 상의 표시(MD1)의 외측에 그 최외측 가장자리의 치수규격의 최대값보다 β만큼 큰 치수의 둘레 테두리(F2)를 배치하고, 워크 상의 표시(MD1)의 최외측 가장자리를 둘러싼다. Next, in the fourth step, as in the first step, as shown in Fig. 36 (b), the dimension is larger by β than the maximum value of the dimension specification of the outermost edge on the outside of the display MD1 on the work. A circumferential edge F2 is disposed and surrounds the outermost edge of the display MD1 on the work.

그리고 제 5 단계에 있어서, 상기 제 2 단계와 마찬가지로, 둘레 테두리(F2)와 워크 상의 표시(MD1)의 최외측 가장자리 사이의 영역(이하 표시 주위 영역)(M1S1)을 구성하는 화소의 화소값이, 워크(WD1)를 구성하는 화소의 화소값과 동일한 것에 착안한다. 도 36의 (b)로부터 표시 주위 영역(M1S1)의 화소값은 워크(WD1)의 화소값과 동일한 100이며, 워크 상의 표시(MD1)의 화소값은 250이다. 그래서, 도 36의 (b)에 있어서의 둘레 테두리(F2) 내부에 있어서, 예를 들면 화소값 200을 표시 선별 임계값(TM1)으로서 설정한다. 그리고, 표시 선별 임계값(TM1) 이상의 영역을 선별함으로써, 화소값이 250인 워크 상의 표시(M1)의 내부를 제 1 대상 후보 영역으로부터 제외해야 할 제 1 제외 영역으로서 선별할 수 있다.In the fifth step, as in the second step, the pixel values of the pixels constituting the area between the circumferential edge F2 and the outermost edge of the display MD1 on the work (hereinafter referred to as the display surrounding area) M1S1 are Pay attention to the same as the pixel values of the pixels constituting the work WD1. 36 (b), the pixel value of the display surrounding area M1S1 is 100 equal to the pixel value of the work WD1, and the pixel value of the display MD1 on the work is 250. Thus, within the circumferential frame F2 in Fig. 36B, for example, the pixel value 200 is set as the display selection threshold TM1. Then, by selecting an area equal to or greater than the display selection threshold TM1, the inside of the display M1 on the work having a pixel value of 250 can be selected as the first exclusion area to be excluded from the first target candidate area.

다음으로 제 6 단계로서, 제 1 대상 후보 영역으로부터 제 1 제외 영역을 제외하여, 제 1 검사 대상 영역으로 한다. 다음으로, 상기 제 1 제외 영역으로서 선별된 워크 상의 표시(MD1)에 착안한다. 도 36의 (b)에 나타내는 바와 같이, 이 워크 상의 표시(MD1) 내에는 결함(D2)이 존재할 경우가 있다. 따라서, 워크 상의 표시(MD1)는 결함(D2)을 검출해야 할 제 2 대상 후보 영역으로 고려하는 것이 적절하다. 즉 제 7 단계 이후에서, 워크 상의 표시(MD1)를 제 2 대상 후보 영역으로서 선별한 뒤, 필요에 따라 제 2 대상 후보 영역 내에서 제 2 제외 영역을 선별하고, 제 2 대상 후보 영역으로부터 제 2 제외 영역을 제외한 영역을 제 2 검사 대상 영역으로서 선별한다. 그런데 도 36의 (b)에 의하면, 워크 상의 표시(MD1)를 제 2 대상 후보 영역으로 했을 때, 이 영역 내에는 제 2 제외 영역은 존재하지 않는다. 따라서, 제 2 검사 대상 영역은 워크 상의 표시(MD1) 내의 전체 영역이 된다. 도 35의 (a)에 나타내는 불량 화상(PD1a)에 이상의 공정을 실행한 결과로서 얻어지는 검사 대상 영역은, 상기 제 6 단계에 있어서 선별한 제 1 검사 대상 영역과 상기 제 7 단계에 있어서 선별한 제 2 검사 대상 영역의 2개의 영역이 된다. 여기까지에 의해서, 검사 영역 선별 공정을 종료한다.Next, as a sixth step, the first exclusion area is excluded from the first candidate area, and the first inspection target area is used. Next, the display on the selected work MD1 as the first exclusion area is focused. As shown in Fig. 36B, a defect D2 may be present in the display MD1 on this work. Therefore, it is appropriate to consider the display MD1 on the work as the second target candidate area for detecting the defect D2. That is, after the seventh step, the display MD1 on the work is selected as the second target candidate region, and then, if necessary, the second excluded region is selected from the second target candidate region, and the second target candidate region is selected from the second target candidate region. The area excluding the excluded area is selected as the second inspection target area. According to Fig. 36B, when the display MD1 on the work is used as the second target candidate area, there is no second excluded area in this area. Therefore, the second inspection target area becomes the entire area in the display MD1 on the work. The inspection target area obtained as a result of performing the above process on the defective image PD1a shown in Fig. 35A is the first inspection target area selected in the sixth step and the agent selected in the seventh step. 2 It becomes two areas of the inspection target area. Thus, the inspection area selection process is ended.

검사 영역 선별 공정에 있어서 제 1 검사 대상 영역 및 제 2 검사 대상 영역이 선별되면, 다음으로 각 검사 대상 영역에 있어서 결함을 검출하는 것이 가능한 결함 임계값을 설정하는 결함 임계값 설정 공정으로 이행한다. 이 결함 임계값 설정 공정에 있어서는, 각 검사 대상 영역을 결함이 아닌 정상 영역과 결함으로 선별 가능한, 특정한 하나의 화소값을 결함 임계값으로서 설정한다. 그 때에 이하의 [조건 2]에 의해 검사 대상 영역 내의 정상 영역과 결함을 선별한다.When the first inspection target area and the second inspection target area are selected in the inspection area selection process, the process proceeds to a defect threshold setting process that sets a defect threshold value capable of detecting defects in each inspection target area. In this defect threshold setting step, a specific pixel value is set as a defect threshold, where each inspection target region can be selected as a defect and a normal region rather than a defect. At that time, normal areas and defects in the inspection target area are selected according to the following [Condition 2].

[조건 2] 검사 대상 영역 내에 있는 결함의 화소값은,[Condition 2] The pixel value of the defect in the inspection target area is:

당해 영역 내의 정상 부분의 화소값과 비교해서 큰가, 작은가.Is it large or small compared to the pixel value of the normal part in the area?

먼저 결함 임계값 설정 공정의 제 1 단계에 있어서, 제 1 검사 대상 영역에 있어서의 결함 임계값으로서, 제 1 결함 임계값을 설정한다. 전술한 바와 같이, 제 1 검사 대상 영역은 워크(WD1) 내에 있어서의 워크 상의 표시(MD1) 이외의 영역이다. 그리고 도 33의 (b)로부터 제 1 검사 대상 영역의 화소값은 100이며, 워크의 결함(D1)의 화소값은 200이다. 이 것으로부터, 제 1 검사 대상 영역에 있어서 예를 들면 화소값 150을 제 1 결함 임계값(TD1)으로서 설정하고, 제 1 결함 임계값(TD1) 이상의 영역을 선별함으로써, 결함(D1)만을 선별하는 것이 가능해진다. 즉, 제 1 결함 임계값(TD1)을 150으로 설정한다. First, in the first step of the defect threshold setting process, the first defect threshold is set as the defect threshold in the first inspection subject area. As described above, the first inspection target area is an area other than the display MD1 on the work in the work WD1. 33 (b), the pixel value of the first inspection subject area is 100, and the pixel value of the defect D1 of the work is 200. From this, only the defect D1 is selected by, for example, setting the pixel value 150 as the first defect threshold TD1 in the first inspection target area, and selecting a region equal to or greater than the first defect threshold TD1. It becomes possible to do. That is, the first defect threshold TD1 is set to 150.

다음으로 결함 임계값 설정 공정의 제 2 단계에 있어서, 제 2 검사 대상 영역에 있어서의 결함 임계값으로서, 제 2 결함 임계값을 설정한다. 제 2 검사 대상 영역은 워크 상의 표시(MD1) 내의 영역이다. 그리고 도 33의 (b)로부터 제 2 검사 대상 영역의 화소값은 250이며, 워크 상의 표시(MD1)에 있어서의 결함(D2)의 화소값은 180이다. 이 것으로부터, 제 2 검사 대상 영역에 있어서 예를 들면 화소값 210을 제 2 결함 임계값(TD2)으로서 설정하고, 제 2 결함 임계값(TD2) 이하의 영역을 선별함으로써, 결함(D2)을 선별하는 것이 가능해진다. 즉, 제 2 결함 임계값(TD2)을 210으로 설정한다. 여기까지에 의해서, 결함 임계값 설정 공정을 종료한다.Next, in the second step of the defect threshold setting step, the second defect threshold is set as the defect threshold in the second inspection target area. The second inspection target area is an area in the display MD1 on the work. 33 (b), the pixel value of the second inspection target area is 250, and the pixel value of the defect D2 in the display MD1 on the work is 180. From this, by setting the pixel value 210 as the second defect threshold TD2 in the second inspection target area, for example, by selecting the area below the second defect threshold TD2, the defect D2 is identified. Screening becomes possible. That is, the second defect threshold TD2 is set to 210. Thus, the defect threshold setting process is ended.

전술한 바와 같이, 검사 영역 선별 공정의 제 2 단계에 있어서, 화소값 50을 워크 선별 임계값(TWD1)으로서 설정하고 있다. 그 목적은, 도 36의 (a)에 있어서의 둘레 테두리(F1) 내부에서 워크(WD1)의 내부를 배경(B1)으로부터 선별하고, 결함 검사의 대상 영역이 되는 제 1 대상 후보 영역으로서 선별하기 위해서이다. 또한, 제 5 단계에 있어서, 화소값 200을 표시 선별 임계값(TM1)으로서 설정하고 있다. 그 목적은, 도 36의 (b)에 있어서의 둘레 테두리(F2) 내부로부터 워크 상의 표시(MD1)의 내부를 제 1 대상 후보 영역으로부터 제외해야 할 제 1 제외 영역으로서 선별하기 위해서이다.As described above, in the second step of the inspection area selection step, the pixel value 50 is set as the work selection threshold value TWD1. The objective is to select the inside of the work WD1 from the background B1 inside the circumferential border F1 in Fig. 36A, and to select it as the first target candidate area to be the target area for defect inspection. It is for. Further, in the fifth step, the pixel value 200 is set as the display selection threshold value TM1. The purpose is to select the inside of the display MD1 on the work from the inside of the circumferential frame F2 in Fig. 36B as the first exclusion area to be excluded from the first target candidate area.

마찬가지로, 결함 임계값 설정 공정의 제 1 단계에 있어서 화소값 150을 제 1 결함 임계값(TD1)으로서 설정하고 있다. 그 목적은, 제 1 검사 대상 영역에 있어서의 결함을 선별하기 위해서이다. 또한 제 2 단계에 있어서 화소값 210을 제 2 결함 임계값(TD2)으로서 설정하고 있다. 그 목적은, 제 2 검사 대상 영역에 있어서의 결함을 선별하기 위해서이다.Similarly, in the first step of the defect threshold value setting process, the pixel value 150 is set as the first defect threshold value TD1. The purpose is to sort defects in the first inspection target area. In addition, in the second step, the pixel value 210 is set as the second defect threshold TD2. The purpose is to sort defects in the second inspection target area.

이들 각종 임계값은, 도 33의 (a)의 불량 화상(PD1) 및 도 35의 (a)의 불량 화상(PD1a)에 있어서의 워크 표면의 결함 검사에 최적인 임계값이다. 그 이유는, 이들 불량 화상의 각 영역에 있어서의 화소값이 도 33의 (b)에 나타내는 값으로 되어 있기 때문이다. 여기서, 도 33의 (a)의 불량 화상(PD1) 이외의 불량 화상, 즉 다른 불량 워크를 촬상한 화상에 있어서의 각 영역의 화소값에 대해 생각한다. 워크마다 각 영역의 화소값은 어떤 범위에 걸쳐 편차를 갖는 것이 상정된다. 불량 화상을 목시하는 한에 있어서는, 각 영역의 상대적인 밝기 또는 어둡기는 어느 워크를 촬상한 촬상 화상에 대해서도 동등하다.These various threshold values are optimal values for defect inspection of the work surface in the defective image PD1 in Fig. 33 (a) and the defective image PD1a in Fig. 35 (a). The reason is that the pixel values in each region of these defective images are the values shown in Fig. 33B. Here, the pixel values of each region in the defective image other than the defective image PD1 in Fig. 33A, that is, an image in which another defective work is captured are considered. It is assumed that the pixel values of each region have a variation over a certain range for each work. As long as the defective image is visually observed, the relative brightness or darkness of each area is the same for the captured image of which the work is captured.

그러나 디지털 화상으로서 생각하면, 화소값의 차이가 문제로 된다. 예를 들면 서로 다른 2개의 워크의 촬상 화상을 목시했을 때, 양자(兩者)에 있어서의 동일한 영역의 목시 결과가 다같이 백(白)이었던 것으로 한다. 그러나, 이들 2개의 촬상 화상을 디지털 화상으로서 기록하면, 한쪽의 백의 화소값은 240이고 다른 쪽의 백의 화소값은 220이라고 하는 경우가 있을 수 있다. 마찬가지로, 양자에 있어서의 동일한 영역의 목시 결과가 다같이 짙은 그레이여도, 디지털 화상에 있어서의 한쪽의 짙은 그레이의 화소값은 100이고, 다른 쪽의 짙은 그레이의 화소값은 80이라고 하는 경우가 있을 수 있다. 이와 같이, 워크마다 각 영역의 화소값은 어느 정도의 편차를 갖고 있다. 따라서, 전술한 바와 같이 도 33의 (a)의 불량 화상(PD1)을 사용하여, 검사 영역 선별 공정 혹은 결함 임계값 설정 공정에 있어서 설정한 각종 임계값을 사용하면, 모든 불량 화상에 대해서 확실하게 검사 대상 영역의 선별이 가능하며, 또한 그 영역 내에 있어서의 결함의 선별이 가능하다는 보증은 없다. 이 때문에, 상기 각종 임계값이 적절한 것을 확인하는 임계값 확인 공정을 실행할 필요가 있다. 임계값 확인 공정의 수순을 이하에 설명한다.However, when considered as a digital image, the difference in pixel values becomes a problem. For example, it is assumed that when the captured images of two different workpieces are visualized, the visual results of the same area in both are all white. However, when these two captured images are recorded as digital images, the pixel value of one white may be 240 and the pixel value of the other white may be 220 in some cases. Similarly, even if the visual results of the same region in both are all dark gray, the pixel value of one dark gray in a digital image may be 100, and the pixel value of the other dark gray may be 80. have. As described above, the pixel values of each region have a certain degree of variation for each work. Therefore, as described above, by using the defective images PD1 in Fig. 33 (a) and using various threshold values set in the inspection area selection process or the defect threshold setting process, all the defective images are reliably used. There is no guarantee that the inspection target area can be selected and defects within the area can be selected. For this reason, it is necessary to perform a threshold value confirmation process to confirm that the various threshold values are appropriate. The procedure of the threshold value confirmation process will be described below.

먼저 제 1 단계에 있어서, B개(B는 자연수)의 불량 워크를 촬상해서 얻은 B개의 불량 화상을 준비한다. 이들 불량 화상의 각각에 대하여, 도 33의 (a)의 불량 화상(PD1)에 의거하여 설정한 각종 임계값을 이용하여, 검사 대상 영역의 선별 및 결함의 선별을 실행한다. 그리고, 모든 불량 화상에 대하여 동일한 검사 대상 영역을 선별하는 것이 가능하며, 또한 불량 화상마다 다른 결함을 각각 확실하게 선별하는 것을 확인한다. 만일 검사 대상 영역 혹은 결함을 정확하게 선별하는 것이 가능하지 않은 불량 화상이 발견되었을 경우에는, 당해 불량 화상과 당초의 임계값 설정에 사용한 도 33의 (a)의 불량 화상(PD1)의 각 영역에 있어서의 화소값(도 33의 (b))을 비교하여, 임계값을 수정한다. 그리고, 수정한 임계값을 이용하여 재차 B개의 불량 화상에 대하여 검사 대상 영역 및 결함을 선별한다. 이 선별의 확인과 임계값의 수정을, 모든 불량 화상에 대하여 동일한 검사 대상 영역을 선별하는 것이 가능하며, 또한 결함을 확실하게 선별하는 것이 가능하게 될 때까지 반복한다.First, in the first step, B defective images obtained by imaging B defective work pieces (B is a natural number) are prepared. For each of these defective images, the inspection target area is selected and defects are selected using various threshold values set based on the defective image PD1 in Fig. 33A. It is also confirmed that the same inspection target area can be selected for all defective images, and that different defects are clearly selected for each defective image. If an inspection target area or a defective image in which it is not possible to accurately select defects is found, in each region of the defective image PD1 in FIG. 33 (a) used for setting the defective image and the original threshold value The threshold value is corrected by comparing the pixel values of (Fig. 33 (b)). Then, the inspection target area and defects are selected again for the B defective images using the corrected threshold. Confirmation of this sorting and correction of the threshold value are repeated until it is possible to select the same inspection target area for all defective images, and also it is possible to reliably sort out defects.

그것이 종료하면, 다음으로 제 2 단계로서, B개의 불량 화상을 이용하여 확인함으로써 수정한 각종 임계값을 양품 화상에 적용했을 때에, 모든 양품 화상에 대하여 동일한 검사 대상 영역을 선별하는 것이 가능하며, 또한 결함이 선별되지 않는 것을 확인한다. 이 경우에는 A개(A는 자연수)의 양품 화상을 준비하고, 전술한 B개의 불량 화상에 대한 확인과 마찬가지로 행한다. 만일 검사 대상 영역이 정확하게 선별되지 않는 양품 화상 혹은 결함이 선별되는 양품 화상이 발견되었을 경우에는, 역시 전술한 B개의 불량 화상을 이용한 확인에 대응하는 수정과 마찬가지로, 임계값의 수정을 행한다. 즉, 당해 양품 화상과 당초의 임계값 설정에 사용한 도 33의 (a)의 불량 화상(PD1)의 각 영역에 있어서의 화소값(도 33의 (b))을 비교하여, 임계값을 수정한다. 그리고, A개의 양품 화상의 모두에 대해서 동일한 검사 대상 영역을 선별하는 것이 가능하며, 또한 결함이 선별되지 않게 될 때까지 확인과 수정을 반복한다. 여기에 B 및 A의 구체적인 값은, 예를 들면 양산 시에 있어서 1일당 결함 검사의 대상이 되는 워크의 개수나 워크의 제조 편차 등을 고려하여, 통계학의 방법을 이용하여 결정하면 된다.When it is finished, as the second step, it is possible to select the same inspection target area for all good images when applying various threshold values corrected by checking by using B bad images, as well as Confirm that the defect is not screened. In this case, A good quality images (A is a natural number) are prepared, and the same is done for confirmation of the B bad images described above. If a good product image in which the inspection target area is not accurately screened or a good product in which defects are selected is found, the threshold value is corrected, similarly to the correction corresponding to the confirmation using the B defective images described above. That is, the threshold value is corrected by comparing the pixel value (Fig. 33 (b)) in each region of the defective image PD1 in Fig. 33 (a) used to set the original threshold value. . Then, it is possible to select the same inspection target area for all of the A good quality images, and check and correction are repeated until no defects are screened. Here, the specific values of B and A may be determined by using a method of statistics, taking into account the number of workpieces subject to defect inspection per day or the manufacturing variation of the workpieces during mass production, for example.

이와 같이 하여 각종 임계값이 적절한 것의 확인이 완료하면, 임계값 확인 공정을 종료한다. 그리고, 이들 적절한 임계값을 이용하여 피검사물로서의 워크의 촬상 화상에 대하여 결함 검사를 행하는 검사 실행 공정으로 이행한다. 검사 실행 공정은, 피검사물의 촬상 화상에 대하여 전술한 검사 영역 선별 공정을 실행하여, 검사 대상 영역을 선별한다. 다음으로, 검사 대상 영역에 대하여 결함 임계값을 이용하여, 결함의 유무를 검사한다. 결함이 없으면 양품으로 판단하고, 결함이 있으면 불량으로 판단한다.In this way, when it is confirmed that various threshold values are appropriate, the threshold value confirmation process is ended. Then, by using these appropriate threshold values, the process proceeds to an inspection execution process in which defect inspection is performed on the captured image of the work as an object to be inspected. In the inspection execution step, the inspection area selection step described above is performed on the captured image of the inspected object to select the inspection target area. Next, the presence or absence of a defect is inspected for the region to be inspected using a defect threshold. If there is no defect, it is judged as a good product, and if there is a defect, it is judged as defective.

여기서, 도 33의 (a)의 불량 화상(PD1)의 경우와 다른 촬상 화상의 화소값의 예에 대해, 도 37의 (a)에 나타내는 불량 화상(PD11)을 이용하여 설명한다. 도 37의 (a)의 불량 화상(PD11)에 있어서 각 영역의 색을 목시에 의해 비교하면, 이하와 같이 되어 있다. 배경(B11)은 희고, 워크(WD11)는 옅은 그레이이며, 표시(MD11)는 검다. 또한, 워크(WD11)의 결함(D11)은 짙은 그레이이며, 표시(MD11) 상의 결함(D21)은 옅은 그레이이다. 단, 똑같이 옅은 그레이여도, 결함(D21)은 워크(WD11)에 비하면 약간 옅다. 이 불량 화상(PD11)을 디지털 화상으로서 기록했을 경우에, 상기 각 영역의 화소값의 대소 관계는,Here, an example of the pixel value of the captured image different from the case of the defective image PD1 in Fig. 33A is explained using the defective image PD11 shown in Fig. 37A. In the defective image PD11 in Fig. 37A, the color of each area is visually compared, and it is as follows. The background B11 is white, the work WD11 is light gray, and the display MD11 is black. The defect D11 of the work WD11 is dark gray, and the defect D21 on the display MD11 is light gray. However, even if it is equally light gray, the defect D21 is slightly lighter than the work WD11. When this defective image PD11 is recorded as a digital image, the relationship between the pixel values of the respective regions is large and small.

표시(MD11) < 결함(D11) < 워크(WD11) < 결함(D21) < 배경(B11) (3)Display (MD11) <Defect (D11) <Work (WD11) <Defect (D21) <Background (B11) (3)

으로 되어 있다. 이 (3)에 나타내는 화소값의 대소 관계는, 도 37의 (a)의 불량 화상(PD11)을 목시했을 때에, 워크(WD11)의 정상인 부분에 비해서 그 결함(D11)이 어둡게(흑색을 띠어) 보이는 것을 의미한다. 마찬가지로, 워크(WD11) 상의 표시(MD11)의 정상인 부분에 비해서 그 결함(D21)이 밝게(백색을 띠어) 보이는 것을 의미한다. 이들 화소값을 도 37의 (b)에 표로서 나타낸다.It is made. When the defective image PD11 in Fig. 37 (a) is observed, the defect D11 is darker (black) than the normal part of the work WD11 when the defective value PD11 in Fig. 37A is observed. ) Means to be visible. Likewise, it means that the defect D21 is brighter (white) than the normal portion of the display MD11 on the work WD11. These pixel values are shown as a table in Fig. 37B.

도 37의 (a)의 불량 화상(PD11)에 대하여 전술한 검사 영역 선별 공정 및 결함 임계값 설정 공정을 실행할 때의 각종 임계값 및 선별해야 할 영역의 화소값과 임계값의 대소 관계는, 이하와 같이 된다.The relationship between the pixel values of the various threshold values and the areas to be sorted and the threshold values when performing the inspection area selection process and the defect threshold setting process described above with respect to the defective image PD11 in FIG. 37A is as follows. It becomes like this.

먼저, 검사 영역 선별 공정의 제 2 단계에 있어서 워크 선별 임계값(TWD11)을 설정한다. 그 목적은, 워크(WD11)의 내부를 배경(B11)으로부터 선별하고, 결함 검사의 대상 영역이 되는 제 1 대상 후보 영역으로서 선별하기 위해서이다. 여기에, 도 37의 (b)로부터 워크(WD11)의 화소값은 130이며, 배경(B11)의 화소값은 250이다. 이들 화소값을 비교하면, 워크 선별 임계값(TWD11)을 예를 들면 180으로 설정하고, 워크 선별 임계값(TWD11) 이하의 화소값을 갖는 영역을 선별하면, 제 1 대상 후보 영역을 선별하는 것이 가능함을 알 수 있다.First, in the second step of the inspection area selection process, a work selection threshold (TWD11) is set. The purpose is to sort the inside of the work WD11 from the background B11 and to select it as a first target candidate area that becomes the target area for defect inspection. Here, the pixel value of the work WD11 from 130 in FIG. 37B is 130, and the pixel value of the background B11 is 250. When comparing these pixel values, if the work selection threshold (TWD11) is set to 180, for example, and when an area having a pixel value equal to or less than the work selection threshold (TWD11) is selected, selecting the first target candidate area You can see that it is possible.

다음으로 제 5 단계에 있어서, 표시 선별 임계값(TM11)을 설정한다. 그 목적은, 워크 상의 표시(MD11)의 내부를 제 1 대상 후보 영역으로부터 제외해야 할 제 1 제외 영역으로서 선별하기 위해서이다. 여기에, 도 37의 (b)로부터 워크(WD11)의 화소값은 130이며, 표시(MD11)의 화소값은 40이다. 이들 화소값을 비교하면, 표시 선별 임계값(TM11)을 예를 들면 90으로 설정하고, 표시 선별 임계값(TM11) 이하의 화소값을 갖는 영역을 선별하면, 제 1 제외 영역을 선별하는 것이 가능함을 알 수 있다.Next, in the fifth step, the display selection threshold TM11 is set. The purpose is to select the inside of the display MD11 on the work as the first exclusion area to be excluded from the first target candidate area. Here, the pixel value of the work WD11 is 130 from FIG. 37B, and the pixel value of the display MD11 is 40. When these pixel values are compared, the display selection threshold TM11 is set to, for example, 90, and when a region having a pixel value equal to or lower than the display selection threshold TM11 is selected, it is possible to select the first excluded region. Can be seen.

마찬가지로, 결함 임계값 설정 공정의 제 1 단계에 있어서 제 1 결함 임계값을 설정한다. 그 목적은, 제 1 검사 대상 영역에 있어서의 결함을 선별하기 위해서이다. 여기에, 도 37의 (b)로부터 워크(WD11)의 화소값은 130이며, 결함(D11)의 화소값은 80이다. 이들 화소값을 비교하면, 제 1 결함 임계값(TD11)을 예를 들면 100으로 설정하고, 제 1 결함 임계값 이하의 화소값을 갖는 영역을 선별하면, 결함(D11)을 선별하는 것이 가능함을 알 수 있다.Similarly, the first defect threshold is set in the first step of the defect threshold setting process. The purpose is to sort defects in the first inspection target area. Here, the pixel value of the workpiece WD11 is 130 from Fig. 37B, and the pixel value of the defect D11 is 80. Comparing these pixel values, it is possible to select the defect D11 by setting the first defect threshold TD11 to, for example, 100, and selecting an area having a pixel value equal to or less than the first defect threshold. Able to know.

또한, 제 2 단계에 있어서 제 2 결함 임계값을 설정한다. 그 목적은, 제 2 검사 대상 영역에 있어서의 결함을 선별하기 위해서이다. 여기에, 도 37의 (b)로부터 표시(MD11)의 화소값은 40이며, 결함(D21)의 화소값은 170이다. 이들 화소값을 비교하면, 제 2 결함 임계값(TD21)을 예를 들면 100으로 설정하고, 제 2 결함 임계값 이상의 화소값을 갖는 영역을 선별하면, 결함(D21)을 선별하는 것이 가능함을 알 수 있다.Also, in the second step, a second defect threshold is set. The purpose is to sort defects in the second inspection target area. Here, the pixel value of the display MD11 from FIG. 37B is 40, and the pixel value of the defect D21 is 170. When comparing these pixel values, it is understood that it is possible to select the defect D21 by setting the second defect threshold TD21 to, for example, 100, and selecting a region having a pixel value equal to or greater than the second defect threshold. You can.

이상과 같이, 종래 기술로서의 화상 처리 알고리즘에 있어서의 각종 임계값의 설정 및 선별해야 할 영역의 화소값과 임계값의 대소 관계는, 촬상 화상에 있어서의 2개의 정보에 의거하여 결정된다. 첫번째 정보는, 촬상 화상을 디지털 화상으로서 기록했을 때의 당해 영역의 화소값이다. 그리고 두번째 정보는, 작업자가 촬상 화상을 목시해서 얻을 수 있는 각 영역의 밝기(백색을 띠는 정도)와 어둡기(흑색을 띠는 정도)의 비교 결과, 즉 각 영역간의 밝기 정보의 비교 결과이다. 두번째 정보 중, 특히 중요한 것은, 검사 대상 영역에 있어서의 정상 부분과 결함의 밝기 정보의 비교이다.As described above, the setting of various threshold values in the conventional image processing algorithm and the relationship between the pixel values of the areas to be selected and the threshold values are determined based on two pieces of information in the captured image. The first information is the pixel value of the area when the captured image is recorded as a digital image. The second information is a comparison result of brightness (a degree of whiteness) and a darkness (a degree of blackness) of each region, that is, a comparison result of brightness information between each region, which can be obtained by the operator visually viewing the captured image. Of the second information, particularly important is the comparison of the brightness information of the normal portion and the defect in the inspection subject area.

지금까지의 설명에 있어서는, 불량 화상 및 양품 화상으로서의 촬상 화상은 그레이 스케일 화상인 것으로 했다. 만일 촬상 화상이 컬러 화상일 경우에는, 컬러 화상의 색을 R(빨강), G(초록), B(파랑)의 삼원색으로 분해하고, 각각의 색에 대해서 그레이 스케일 화상을 생성한다. 그리고, 불량 화상으로부터 생성한 3종류의 그레이 스케일 화상을 작업자가 목시하고, 각 영역간의 밝기 정보를 비교함으로써, 가장 결함을 명료하게 식별할 수 있다고 판단한 하나의 그레이 스케일 화상을 선택한다. 이 선택한 그레이 스케일 화상에 대하여, 상기 화상 처리 알고리즘을 적용하면 된다.In the description so far, it is assumed that the captured images as defective images and good products are gray scale images. If the captured image is a color image, the color of the color image is decomposed into three primary colors of R (red), G (green), and B (blue), and a gray scale image is generated for each color. Then, one gray-scale image judged to be able to clearly identify the most defective one is selected by the operator seeing three types of gray-scale images generated from the defective images and comparing the brightness information between the respective regions. The image processing algorithm may be applied to the selected gray scale image.

(3) 종래 기술의 화상 처리 알고리즘의 문제점(3) Problems of prior art image processing algorithms

이상과 같은 종래 기술로서의 화상 처리 알고리즘에는, 이하의 문제점이 있다. 그것은, 촬상 화상에 대한 화상 처리 알고리즘 적용 시에, 작업자에 의한 목시의 작업이 많아지는 것이다. 전술한 바와 같이, 검사 영역 선별 공정에 있어서 각종 임계값을 설정할 때에, 작업자는 촬상 화상을 목시해서 각 영역간의 밝기 정보를 비교한다. 그리고 그 비교 결과에 의거하여, 선별해야 할 검사 대상 영역의 내부에 결함과 식별되어야 할 정상인 영역으로서의 제외 영역이 존재하는지의 여부를 판단한다.The above-described conventional image processing algorithm has the following problems. That is, when the image processing algorithm is applied to the captured image, the number of visual work by the operator increases. As described above, when setting various threshold values in the inspection area selection process, the operator visually observes the captured image and compares the brightness information between each area. Then, based on the comparison result, it is determined whether or not a defect and an excluded region as a normal region to be identified exist in the region to be examined.

예를 들면 전술한 도 33의 (a)에 나타내는 불량 화상(PD1)을 이용한 검사 영역 선별 공정에 관한 설명에 있어서는, 도 33의 (b)와 같이 워크(WD1)의 화소값이 100이고, 워크(WD1) 상의 결함(D1)의 화소값이 200이다. 그리고 워크(WD1) 내의 표시(MD1)의 화소값이 250이다. 이 때문에, 워크(WD1) 상에 있어서 결함(D1)을 정확하게 선별하기 위해서, 제 1 대상 후보 영역인 워크(WD1) 내로부터 표시(MD1)를 제 1 제외 영역으로서 제외함으로써 제 1 검사 대상 영역을 선별하고 있다. 이들 작업에 있어서, 작업자의 목시가 달성하는 역할은 매우 크며, 작업자에 대하여 숙련이 요구된다. 예로서 상기 설명에서 사용한 도 33의 (a)에 나타내는 불량 화상(PD1)의 경우에는, 제외 영역이 1개이고 검사 대상 영역이 2개이었다. 그러나, 제외 영역 및 검사 대상 영역의 수는 이것에 한정되는 것이 아니다.For example, in the description of the inspection area selection process using the defective image PD1 shown in Fig. 33 (a), the pixel value of the work WD1 is 100, as shown in Fig. 33 (b). The pixel value of the defect D1 on the (WD1) is 200. The pixel value of the display MD1 in the work WD1 is 250. For this reason, in order to accurately select the defect D1 on the work WD1, the first inspection target area is excluded by excluding the display MD1 as the first exclusion area from within the work candidate WD1, which is the first target candidate area. Screening. In these tasks, the role that the operator's vision achieves is very large, and skill is required of the operator. As an example, in the case of the defective image PD1 shown in Fig. 33 (a) used in the above description, there were one excluded area and two inspected areas. However, the number of excluded areas and inspection target areas is not limited to this.

워크 표면을 구성하는 부품(parts)의 수량, 결함이 발생하는 부품과 그들의 배치 및 각 부품 및 그들에 대응하는 결함의 화소값 등에 의해, 제외 영역 및 검사 대상 영역의 수는 더 증가하는 것도 생각할 수 있다. 또한, 전술한 바와 같이 촬상 화상이 컬러 화상일 경우에는, 컬러 화상의 색을 R(빨강), G(초록), B(파랑)의 삼원색으로 분해하고, 각각의 색에 대해서 그레이 스케일 화상을 생성하고 나서, 작업자가 그들 3종류의 그레이 스케일 화상을 목시해서 비교하는 작업이 추가된다. 이들과 같이 제외 영역 및 검사 대상 영역이 증가할 경우, 혹은 컬러 촬상 화상에 대한 처리가 필요할 경우에는, 영역을 선별하기 위한 임계값의 수가 증가하는 등, 작업자의 목시에 요하는 시간이 더 증가한다. 또한 그것과 함께 작업자의 판단 항목이 증가하여, 작업자의 부담이 증가한다. 이와 같은 작업자의 목시에 요하는 시간의 증가 및 부담의 증가에 기인하여, 검사 속도 및 검사 정밀도가 저하한다.It is also conceivable that the number of excluded areas and inspected areas increases further due to the number of parts constituting the work surface, the parts where defects occur, their arrangement, and the pixel values of each part and the defects corresponding to them. have. In addition, when the captured image is a color image as described above, the color of the color image is decomposed into three primary colors of R (red), G (green), and B (blue), and a gray scale image is generated for each color. Then, an operator is added to visually compare the three types of gray scale images. When the exclusion area and the inspection target area increase as described above, or when processing for a color image is required, the time required for visual inspection of the operator increases further, such as an increase in the number of thresholds for selecting the area. . In addition, the item of judgment of the worker increases with it, and the burden on the worker increases. Due to the increase in the time required for the operator's eyesight and the increase in the burden, the inspection speed and inspection accuracy are lowered.

일본국 특개 2015-4538호 공보Japanese Patent Application No. 2015-4538

본 발명의 목적은, 선대칭성을 갖는 피검사물의 촬상 화상으로부터 검사 대상 영역을 선별할 때에, 작업자의 목시 작업을 줄임으로써, 작업자에게 숙련을 요구하는 판단 등의 부담이 생기는 것을 경감하며, 또한 임계값을 간단하게 설정해서 검사 대상 영역을 용이하게 선출하는 것을 가능하게 하는, 검사 속도의 향상에 기여함과 동시에 작업자의 숙련도의 차이에 영향을 받지 않는 화상 처리 방법과, 그 화상 처리 방법을 이용한 결함 검사 방법을 제공하는 것이다.The object of the present invention is to reduce the burden of judgment and the like that requires the skill of the operator by reducing the visual work of the operator when selecting the inspection target area from the picked-up image of the inspected object having linear symmetry, and also thresholding An image processing method that contributes to an increase in the inspection speed and makes it possible to easily select an area to be inspected by simply setting a value, and an image processing method that is not affected by differences in operator skill and defects using the image processing method It is to provide an inspection method.

본 발명의 일 태양인 화상 처리 방법은, 기준 직선에 대하여 선대칭이 되는 제 1 및 제 2 영역을 갖는 단색의 원(原)화상을, 상기 기준 직선에 의해 상기 제 1 및 제 2 영역으로 분할하고, 상기 제 1 및 제 2 영역 내에서 상기 기준 직선에 대하여 선대칭의 위치에 배치되는 2개의 원(原)화소의 각 페어에 대해서, 상기 2개의 원화소의 화소값의 차분이 되는 차분 화소값을 산출하는 차분 산출 공정과, 상기 차분 화소값을 갖는 차분 화소를 배치해서 차분 화상을 생성하는 차분 화상 생성 공정으로서, 상기 제 1 영역 내의 제 1 위치의 원화소와 상기 제 2 영역 내의 제 2 위치의 원화소의 페어를 이용하여 산출된 상기 차분 화소값을 갖는 차분 화소를, 상기 차분 화상의 상기 제 1 및 제 2 위치에 배치해서 상기 차분 화상을 생성하는 차분 화상 생성 공정을 구비하는 것을 특징으로 한다.An image processing method, which is an aspect of the present invention, divides a monochromatic original image having first and second regions that are line-symmetrical to a reference straight line into the first and second regions by the reference straight line, A difference pixel value that is a difference between the pixel values of the two original pixels is calculated for each pair of two original pixels arranged at a line symmetry position with respect to the reference straight line in the first and second regions A difference calculation process to be performed, and a difference image generation process in which a difference pixel having the difference pixel value is arranged to generate a difference image, wherein the original pixel at the first position in the first area and the circle at the second position in the second area And a difference image generating process for arranging difference pixels having the difference pixel values calculated using a pair of pixels at the first and second positions of the difference image to generate the difference images. It is characterized by.

또한, 상기 화상 처리 방법에 있어서, 상기 기준 직선은, 상기 원화상을, 동일한 수의 원화소를 포함하는 상반분(上半分)의 상기 제 1 영역과 하반분(下半分)의 상기 제 2 영역으로 분할하는 제 1 직선인 것을 특징으로 한다.In addition, in the image processing method, the reference straight line includes the first region in the upper half and the second region in the lower half containing the same number of original pixels in the original image. It is characterized in that the first straight line dividing by.

또한, 상기 화상 처리 방법에 있어서, 상기 기준 직선은, 상기 원화상을, 동일한 수의 원화소를 포함하는 좌반분(左半分)의 상기 제 1 영역과 우반분(右半分)의 상기 제 2 영역으로 분할하는 제 2 직선인 것을 특징으로 한다.Further, in the image processing method, the reference straight line includes the first region of the left half and the second region of the right half of the original image containing the same number of original pixels. Characterized in that it is a second straight line divided by.

또한, 상기 화상 처리 방법에 있어서, 상기 차분 화상 생성 공정에서는, 동일한 상기 원화상으로부터 상기 차분 화상으로서, 제 1 차분 화상과, 상기 제 1 차분 화상과 다른 제 2 차분 화상을 생성하고, 상기 화상 처리 방법은, 상기 제 1 차분 화상과 상기 제 2 차분 화상을 이용하여, 상기 원화상에 있어서의 검사 대상 영역을 선출하는 검사 영역 선출 공정을 더 구비하는 것을 특징으로 한다.Further, in the image processing method, in the difference image generation process, a first difference image and a second difference image different from the first difference image are generated as the difference image from the same original image, and the image processing is performed. The method is characterized by further comprising an inspection area selection step of selecting an inspection target area in the original image using the first difference image and the second difference image.

본 발명의 일 태양인 결함 검사 방법은, 상기 화상 처리 방법을 이용하여 피검사물에 대하여 결함 검사를 행하는 결함 검사 방법이며, 양품(良品)임이 기지(旣知)인 복수의 피검사물을 촬상해서 얻어지는 촬상 화상으로부터 생성되는 단색 화상을 제 1 원화상으로 하여, 생성된 복수의 제 1 원화상으로부터 상기 화상 처리 방법을 이용하여 복수의 양품 차분 화상을 생성하는 제 1 공정과, 불량임이 기지인 복수의 피검사물을 촬상해서 얻어지는 촬상 화상으로부터 생성되는 단색 화상을 제 2 원화상으로 하여, 생성된 복수의 제 2 원화상으로부터 상기 화상 처리 방법을 이용하여 복수의 불량 차분 화상을 생성하는 제 2 공정을 구비하는 임계값 설정 모드로서, 상기 복수의 불량 차분 화상의 차분 화소 중에서, 차분 화소값이 다른 차분 화소값으로부터 소정값 이상으로 이간하는 동시에 각 불량 차분 화상에 있어서 동일한 위치에 배치되는 이간 화소를 선출하는 것이 가능하며, 또한, 상기 복수의 양품 차분 화상의 차분 화소 중에서 상기 이간 화소와 동일한 위치에 배치되는 차분 화소를 상기 이간 화소로서 선출하지 않도록 하는 것이 가능한 하나의 검사 영역 임계값을 설정하는 임계값 설정 모드와, 결함 검사 대상인 피검사물을 촬상해서 얻어지는 촬상 화상으로부터 생성되는 단색 화상을 제 3 원화상으로 하여, 생성된 제 3 원화상으로부터 상기 화상 처리 방법을 이용하여 차분 화상을 생성하고, 상기 차분 화상과 상기 검사 영역 임계값을 이용하여 상기 제 3 원화상에 있어서의 검사 대상 영역을 선출하고, 상기 검사 대상 영역에 대하여 결함 검사를 실행하는 검사 실행 모드를 구비하는 것을 특징으로 한다.A defect inspection method, which is one aspect of the present invention, is a defect inspection method for performing defect inspection on an inspected object by using the image processing method, and is an imaging obtained by imaging a plurality of inspected objects known to be good products. A first step of generating a plurality of quality difference images by using the image processing method from a plurality of first original images generated by using a single-color image generated from the image as a first original image, and a plurality of tests with known defects A second step of generating a plurality of defective difference images by using the image processing method from a plurality of second original images generated by using a single color image generated from the captured image obtained by imaging an object as a second original image. As a threshold setting mode, among the difference pixels of the plurality of defective difference images, a difference pixel value is predetermined from a difference pixel value that is different. It is possible to select the spaced apart pixels arranged at the same position in each defective difference image at the same time as above, and further, the difference pixels arranged at the same position as the spaced apart pixels among the difference pixels of the plurality of good difference images A threshold value setting mode for setting a threshold value of one inspection area capable of not being elected as a separation pixel, and a monochrome image generated from a captured image obtained by imaging a target object to be inspected as a third original image are generated. A difference image is generated from the third original image using the image processing method, and an inspection target area in the third original image is selected using the difference image and the inspection area threshold, and the inspection target area is It is characterized by having a test execution mode for performing a defect inspection for do.

또한, 상기 결함 검사 방법에 있어서, 상기 촬상 화상은 비(非)컬러 화상이며, 각 촬상 화상으로부터 생성되는 단색 화상은 하나인 것을 특징으로 한다.In addition, in the defect inspection method, the captured image is a non-color image, and there is one monochromatic image generated from each captured image.

또한, 상기 결함 검사 방법에 있어서, 상기 촬상 화상은 컬러 화상이고, 각 촬상 화상으로부터 생성되는 단색 화상은 2개 이상이며, 상기 임계값 설정 모드의 상기 제 1 공정에서는, 각 단색 화상을 상기 제 1 원화상으로 하여, 생성된 복수의 제 1 원화상으로부터 상기 복수의 양품 차분 화상을 생성하고, 상기 임계값 설정 모드의 상기 제 2 공정에서는, 각 단색 화상을 상기 제 2 원화상으로 하여, 생성된 복수의 제 2 원화상으로부터 상기 복수의 불량 차분 화상을 생성하고, 상기 임계값 설정 모드에서는, 상기 검사 영역 임계값의 설정 가능 범위가 가장 넓은 단색 화상을 하나 선출하고, 선출한 단색 화상에 대하여 상기 검사 영역 임계값을 설정하고, 상기 검사 실행 모드에서는, 상기 결함 검사 대상인 피검사물을 촬상해서 얻어지는 상기 촬상 화상으로부터 생성되는 2개 이상의 단색 화상 중에서, 상기 임계값 설정 모드에서 선출된 단색 화상과 같은 종류의 단색 화상을 선출해서 상기 제 3 원화상으로 하여, 생성된 상기 제 3 원화상으로부터 상기 차분 화상을 생성하고, 상기 차분 화상과 상기 검사 영역 임계값을 이용하여 상기 검사 대상 영역을 선출하고, 상기 검사 대상 영역에 대하여 결함 검사를 실행하는 것을 특징으로 한다.In the defect inspection method, the captured image is a color image, and there are two or more monochrome images generated from each captured image, and in the first step of the threshold setting mode, each monochrome image is the first. As the original image, the plurality of quality difference images are generated from the generated first original images, and in the second step of the threshold setting mode, each monochrome image is generated as the second original image. The plurality of defective difference images are generated from a plurality of second original images, and in the threshold setting mode, one of the monochrome images having the largest setting range of the inspection area threshold is selected, and the selected monochrome image is An inspection area threshold is set, and in the inspection execution mode, from the captured image obtained by imaging the inspected object as the defect inspection object Among the two or more monochromatic images generated from the data, a monochromatic image of the same kind as the monochromatic image selected in the threshold setting mode is selected as the third original image, and the differential image is generated from the generated third original image. And selecting the inspection target area using the difference image and the inspection area threshold, and performing defect inspection on the inspection target area.

또한, 상기 결함 검사 방법은, 상기 제 3 원화상 중에서 템플릿 매칭법을 이용하여 상기 결함 검사 대상인 피검사물을 추출하는 피검사물 추출 공정을 더 구비하는 것을 특징으로 한다.In addition, the defect inspection method is characterized in that it further comprises an object extraction process for extracting the object to be inspected for defects using a template matching method among the third original images.

본 발명의 화상 처리 방법을 검사 대상 워크(결함 검사 대상인 피검사물)의 화상이 특정의 직선에 관해서 선대칭일 경우에 사용하면, 작업자가 워크의 화상을 목시해서 어떠한 판단을 행하는 공정이 거의 존재하지 않으며, 단순한 화상 처리의 연산을 이용하여 하나의 임계값을 설정하여, 용이하게 검사 대상 워크의 화상에 있어서의 검사 대상 영역을 선출할 수 있다. 이 때문에, 종래 기술과 같이 작업자에 대하여 숙련이 요구될 경우가 없어, 작업자의 부담이 적어진다. 또한 화상 처리 방법을 소프트웨어에 의해 자동화해서 검사 대상 워크의 화상에 대한 결함 검사를 용이하게 실행할 수 있다. 이 때문에, 종래 기술에 의한 결함 검사에 비해서 검사 속도가 현격히 향상되는 동시에, 작업자의 숙련도의 차이에 영향을 받지 않는다.When the image processing method of the present invention is used when the image of the workpiece to be inspected (the object to be inspected for defects) is linearly symmetrical with respect to a specific straight line, there is almost no process in which an operator makes any judgment by visually viewing the image of the workpiece. , By setting a single threshold value using simple image processing calculation, it is possible to easily select an inspection target area in an image of a work to be inspected. For this reason, there is no case that skill is required for the worker as in the prior art, and the burden on the worker is reduced. In addition, the image processing method can be automated by software to easily carry out defect inspection on an image of a work to be inspected. For this reason, the inspection speed is significantly improved compared to the defect inspection according to the prior art, and at the same time, it is not affected by the difference in the skill level of the operator.

도 1의 (a)(b)는 본 발명의 화상 처리 알고리즘의 설명도.
도 2는 본 발명의 화상 처리 알고리즘의 설명도.
도 3의 (a)(b)(c)(d)(e)는 본 발명의 화상 처리 알고리즘의 설명도.
도 4의 (a)(b)(c)는 본 발명의 화상 처리 알고리즘의 설명도.
도 5의 (a)(b)(c)(d)(e)는 본 발명의 화상 처리 알고리즘의 설명도.
도 6의 (a)(b)(c)는 본 발명의 화상 처리 알고리즘의 설명도.
도 7의 (a)(b)는 본 발명의 화상 처리 알고리즘의 설명도.
도 8의 (a)(b)(c)(d)(e)는 본 발명의 화상 처리 알고리즘의 설명도.
도 9의 (a)(b)(c)는 본 발명의 화상 처리 알고리즘의 설명도.
도 10의 (a)(b)(c)(d)(e)는 본 발명의 화상 처리 알고리즘의 설명도.
도 11의 (a)(b)(c)는 본 발명의 화상 처리 알고리즘의 설명도.
도 12는 본 발명의 화상 처리 알고리즘의 설명도.
도 13의 (a)(b)는 본 발명의 화상 처리 알고리즘의 설명도.
도 14의 (a)(b)는 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 15는 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 16은 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 17은 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 18은 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 19는 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 20은 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 21은 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 22는 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 23은 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 24는 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 25는 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 26은 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 27은 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 28은 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 29는 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 30은 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 31은 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법의 설명도.
도 32의 (a)(b)는 종래 기술의 화상 처리 알고리즘의 설명도.
도 33의 (a)(b)는 종래 기술의 화상 처리 알고리즘의 설명도.
도 34의 (a)(b)는 종래 기술의 화상 처리 알고리즘의 설명도.
도 35의 (a)(b)는 종래 기술의 화상 처리 알고리즘의 설명도.
도 36의 (a)(b)는 종래 기술의 화상 처리 알고리즘의 설명도.
도 37의 (a)(b)는 종래 기술의 화상 처리 알고리즘의 설명도.
1 (a) (b) is an explanatory diagram of the image processing algorithm of the present invention.
2 is an explanatory diagram of the image processing algorithm of the present invention.
3 (a) (b) (c) (d) (e) is an explanatory diagram of the image processing algorithm of the present invention.
4 (a) (b) (c) is an explanatory diagram of the image processing algorithm of the present invention.
5 (a) (b) (c) (d) (e) are explanatory diagrams of the image processing algorithm of the present invention.
6 (a) (b) (c) is an explanatory diagram of the image processing algorithm of the present invention.
7 (a) (b) is an explanatory diagram of the image processing algorithm of the present invention.
8 (a) (b) (c) (d) (e) is an explanatory diagram of the image processing algorithm of the present invention.
9 (a) (b) (c) is an explanatory diagram of the image processing algorithm of the present invention.
10 (a) (b) (c) (d) (e) are explanatory diagrams of the image processing algorithm of the present invention.
11 (a) (b) (c) is an explanatory diagram of the image processing algorithm of the present invention.
12 is an explanatory diagram of the image processing algorithm of the present invention.
13A and 13B are explanatory diagrams of the image processing algorithm of the present invention.
14 (a) (b) is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
15 is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
16 is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
17 is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
18 is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
19 is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
20 is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
21 is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
22 is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
23 is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
24 is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
25 is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
26 is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
27 is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
28 is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
29 is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
30 is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
31 is an explanatory diagram of a defect inspection method using the image processing algorithm of the present invention.
32 (a) (b) is an explanatory diagram of a prior art image processing algorithm.
33 (a) (b) is an explanatory diagram of a prior art image processing algorithm.
34 (a) (b) is an explanatory diagram of a prior art image processing algorithm.
35 (a) (b) is an explanatory diagram of a prior art image processing algorithm.
36 (a) (b) is an explanatory diagram of a prior art image processing algorithm.
37 (a) (b) is an explanatory diagram of a prior art image processing algorithm.

이하, 본 발명의 실시예를, 도면을 참조해서 설명한다.Hereinafter, embodiments of the present invention will be described with reference to the drawings.

(1) 본 발명의 화상 처리 알고리즘(1) The image processing algorithm of the present invention

본 발명의 기본이 되는 화상 처리 알고리즘에 대해, 도 1 내지 도 6을 사용하여 설명한다. 도 1의 (a)는 도 33의 (a)의 불량 화상(PD1)에 촬상되어 있는 불량 워크(WD1)를 원(原)화상 즉 화상 처리의 대상으로 하는 디지털 화상으로 하고, 이 원화상에 본 발명의 화상 처리 알고리즘을 적용하기 위한 설명도이다. 여기에, 도 1의 (a)의 불량 워크(WD1)는 상기 불량 화상(PD1) 중에서 템플릿 매칭법을 이용하여 추출한 것이다. 불량 워크(WD1)의 표면의 각 영역에 대해서는 이미 도 33의 (a)를 사용하여 설명했으므로, 여기서는 생략한다. 또한 도 1의 (b)에, 도 1의 (a)에 나타내는 원화상에 있어서의 각 영역의 화소값을 표형식으로 나타낸다. 이들 화소값은 도 33의 (b)의 대응하는 영역의 화소값과 동일하다. 즉 도 1의 (a)의 원화상도 또한 도 33의 (a)와 같이 그레이 스케일 화상이다.The image processing algorithm which is the basis of the present invention will be described with reference to Figs. Fig. 1 (a) shows the defective work WD1 imaged on the defective image PD1 in Fig. 33 (a) as an original image, that is, a digital image to be subjected to image processing, and this original image It is an explanatory diagram for applying the image processing algorithm of the present invention. Here, the defective work WD1 of FIG. 1A is extracted from the defective image PD1 using a template matching method. Each region of the surface of the defective work WD1 has already been described with reference to FIG. 33A, and thus is omitted here. 1 (b), the pixel values of each region in the original image shown in FIG. 1 (a) are shown in a tabular format. These pixel values are the same as the pixel values of the corresponding area in Fig. 33B. That is, the original image in Fig. 1A is also a gray scale image as in Fig. 33A.

먼저 도 1의 (a)에 있어서, 워크(WD1) 및 표시(MD1)의 영역에 주목한다. 이들 영역에는 각각 결함(D1 및 D2)이 존재한다. 그리고 결함(D1 및 D2)을 제외한 영역, 즉 도 32의 (a)의 양품 화상(PG1) 내의 양품 워크(WG1)와 동일한 영역을 보면, 선대칭성을 갖는 영역인 것을 알 수 있다. 이 양품 워크(WG1)와 동일한 영역은, 불량 워크(WD1)와 그 표면에 마킹되어 있는 표시(MD1)에 의해 구성되어 있다. 그리고 전술한 바와 같이 불량 워크(WD1)는 장방형의 외형을 갖고, 표시(MD1)는 원형이다. 또한 워크(WD1)의 대각선의 교점과 표시(MD1)의 중심 위치는 대체로 일치하고 있다. 따라서 불량 워크(WD1)와 표시(MD1)로 이루어지는 영역은, 도 1의 (a)에 나타내는 2개의 직선(L1 및 L2)에 관해서 선대칭인 것을 알 수 있다. 구체적으로는 기준 직선으로서의 제 1 직선(L1)을 대칭축으로 하여 상하 대칭이며, 제 1 직선(L1)은 원화상을 상반분(上半分)과 하반분(下半分)에 동일한 수의 화소로 분할한다. 마찬가지로 기준 직선으로서의 제 2 직선(L2)을 대칭축으로 하여 좌우 대칭이며, 제 2 직선(L2)은 원화상을 좌반분(左半分)과 우반분(右半分)에 동일한 수의 화소로 분할한다.First, in (a) of FIG. 1, attention is paid to the areas of the work WD1 and the display MD1. Defects D1 and D2 are present in these regions, respectively. Then, when the areas except the defects D1 and D2, that is, the same area as the good work WG1 in the good product image PG1 in Fig. 32 (a), it can be seen that the area has line symmetry. The same area as the good product work WG1 is constituted by the defective work WD1 and the display MD1 marked on the surface. In addition, as described above, the defective work WD1 has a rectangular outer shape, and the display MD1 is circular. In addition, the intersection of the diagonal lines of the work WD1 and the center position of the display MD1 generally coincide. Therefore, it can be seen that the region formed of the defective work WD1 and the display MD1 is line symmetrical with respect to the two straight lines L1 and L2 shown in Fig. 1A. Specifically, the first straight line L1 as a reference straight line is symmetrical up and down, and the first straight line L1 divides the original image into the same number of pixels in the upper half and lower half. do. Likewise, the second straight line L2 as the reference straight line is symmetrical to the left and right, and the second straight line L2 divides the original image into the same number of pixels in the left half and the right half.

본 발명의 화상 처리 알고리즘은, 이와 같이 1개 이상의 대칭축에 관해서 선대칭이 되는 영역을 갖는 화상에 대해, 결함 검사를 행해야 할 검사 대상 영역을 용이하게 선출할 수 있는 것이다. 본 발명의 화상 처리 알고리즘의 원리를 설명할 때에는, 단순화를 위해 도 2에 나타내는 바와 같은 세로 4개, 가로 4개의 정방형 형상으로 배치된 16개의 화소를 사용하는 것으로 한다. 도 2에 있어서 각 화소는 정방형의 형상이며, 그 중에 각각의 화소의 위치를 나타내는 고유한 어드레스가 기재되어 있다. 이 어드레스는, 각 화소에 대하여 도 2의 가로방향이 되는 X 및 세로방향이 되는 Y를 조합시킨 이차원 표시로 부여된다. 구체적인 어드레스의 부여 방법을 이하에 설명한다.The image processing algorithm of the present invention can easily select an inspection target region to be subjected to defect inspection for an image having an area that is line-symmetrical with respect to one or more symmetric axes. When explaining the principle of the image processing algorithm of the present invention, for simplicity, it is assumed that 16 pixels arranged in four vertical and four horizontal square shapes as shown in FIG. In Fig. 2, each pixel has a square shape, in which a unique address indicating the position of each pixel is described. This address is given to each pixel by a two-dimensional display combining X in the horizontal direction and Y in the vertical direction in FIG. 2. A specific addressing method will be described below.

먼저 X 방향 및 Y 방향의 어드레스 값의 증가하는 방향을 정하기 위해서, X=0 및 Y=0이 되는 원점을 좌측 상단에 취한다. 그리고, 이차원 어드레스(X, Y)의 X와 Y를 각각 도 2의 화살표 X 방향 및 Y 방향으로 증가시킨다. 즉, 좌측 상단 모서리에 위치하는 화소의 어드레스는 (0,0)이 되고, 그 우측에 위치하는 화소의 어드레스는 (0,0)으로부터 X 어드레스의 값을 1만큼 증가시켜서(1,0)이 된다. 마찬가지로 좌측 상단 모서리의 화소의 하측에 위치하는 화소의 어드레스는 (0,0)으로부터 Y 어드레스의 값을 1만큼 증가시켜서 (0,1)이 된다. 이와 같이 하여 X 어드레스와 Y 어드레스의 값을 변화시켜서, 원점으로부터 가장 먼 우측 하단 모서리에 위치하는 화소의 어드레스는 (0,0)으로부터 X 어드레스의 값을 3만큼 증가시키는 동시에, Y 어드레스의 값을 3만큼 증가시켜서 (3,3)이 된다. 이하의 설명에 있어서는, 화소의 어드레스를 이 방법에 의해 표현한다.First, in order to determine the increasing direction of the address values in the X direction and the Y direction, the origin of X = 0 and Y = 0 is taken at the upper left. Then, the X and Y of the two-dimensional addresses (X, Y) are increased in the arrow X direction and the Y direction of Fig. 2, respectively. That is, the address of the pixel located in the upper left corner becomes (0,0), and the address of the pixel located in the right corner increases the value of the X address from (0,0) by 1 (1,0). do. Similarly, the address of the pixel located below the pixel in the upper left corner becomes (0,1) by increasing the value of the Y address from (0,0) by one. By changing the values of the X address and the Y address in this way, the address of the pixel located in the lower right corner farthest from the origin increases the value of the X address from (0,0) by 3, while increasing the value of the Y address. Increase by 3 to become (3,3). In the following description, the address of the pixel is expressed by this method.

도 3 내지 도 6은, 본 발명의 화상 처리 알고리즘의 원리를 설명하는 도면이다. 도 3의 (a)는, 도 32의 (a)의 양품 화상(PG1) 내의 양품 워크(WG1)를, 도 2에 나타내는 바와 같은 세로 4개, 가로 4개의 정방형 형상으로 배치된 16개의 화소로 원화상으로서 모델화한 것이다. 각 화소에는 도 32의 (b)의 표에 대응하는 바와 같은 화소값을 기재하고 있다. 또, 도 32의 (a)에 있어서의 양품 워크(WG1)의 형상은 장방형이지만, 도 3의 (a)에 있어서는 단순화를 위해 정방형으로 모델화하고 있다. 또한 도 32의 (a)에 있어서의 표시(MG1)는 원형이지만, 도 3의 (a)에 있어서는 전체 16개로 이루어지는 화소 중 중앙부에 있는 어드레스 (1,1), (2,1), (1,2), (2,2)의 4개의 화소로 모델화하고 있다. 이 경우, 이들 중앙부의 4개의 화소를 둘러싸는 12개의 화소가, 도 32의 (a)에 있어서의 양품 워크(WG1)를 모델화한 것으로 된다.3 to 6 are diagrams for explaining the principle of the image processing algorithm of the present invention. Fig. 3 (a) shows the quality work WG1 in the quality image PG1 of Fig. 32 (a) as 16 pixels arranged in four vertical and four horizontal square shapes as shown in Fig. 2. It was modeled as an original image. In each pixel, pixel values as corresponding to the table in FIG. 32B are described. In addition, although the shape of the good product work WG1 in FIG. 32 (a) is rectangular, in FIG. 3 (a), it is modeled as a square for simplification. In addition, the display MG1 in FIG. 32 (a) is circular, but in FIG. 3 (a), the addresses (1,1), (2,1), and (1) in the center of the pixel composed of all 16 pixels It is modeled as four pixels of (2, 2), (2, 2). In this case, 12 pixels surrounding the four pixels in the central portion are modeled on the good work WG1 in Fig. 32A.

여기에, 도 32의 (b)에 있어서의 양품 워크(WG1)의 화소값은 100이며, 표시(MG1)의 화소값은 250이다. 그러나 도 3의 (a)에 있어서는, 양품 워크(WG1)의 화소값으로서 100 근방의 몇 개의 흩어지게 한 값을 상기 12개의 화소의 각각에 할당하는 동시에, 표시(MG1)의 화소값으로서 250 근방의 몇 개의 흩어지게 한 값을 상기 4개의 화소의 각각에 할당하고 있다. 이러한 화소값의 편차는 실제의 화상에 있어서, 예를 들면 노이즈에 의해 생기는 것이다.Here, the pixel value of the good work WG1 in FIG. 32B is 100, and the pixel value of the display MG1 is 250. However, in Fig. 3A, several scattered values in the vicinity of 100 are assigned to each of the 12 pixels as pixel values of the good work WG1, and at the same time, around 250 as the pixel values of the display MG1. Several scattered values of are assigned to each of the four pixels. The variation in the pixel values is caused by, for example, noise in an actual image.

또 도 3의 (a)에 있어서는, 16개의 화소의 각각의 화소값에 대응하여, 당해 화소의 밝기(백색을 띠는 정도)와 어둡기(흑색을 띠는 정도)를 시각적 및 상대적으로 표현하고 있다. 예를 들면, 도 32의 (a)에 있어서의 표시(MG1)에 대응하는 도 3의 (a)의 화소는, 전술한 바와 같이 중앙부의 어드레스 (1,1), (2,1), (1,2), (2,2)의 4개의 화소이다. 이들 화소의 화소값은 250 근방이며, 목시하면 백색이다. 따라서, 상기 중앙부의 4개의 화소는 바탕에 모양이 없는 백발(白拔)의 정방형으로 되어 있다. 한편, 도 32의 (a)에 있어서의 양품 워크(WG1)에 대응하는 도 3의 (a)의 화소는, 전술한 바와 같이 상기 중앙부의 4개의 화소를 둘러싸는 12개의 화소이다. 이들 화소의 화소값은 100 근방이며, 목시하면 짙은 그레이이다. 따라서, 상기 12개의 화소는 화소값을 나타내는 숫자 이외의 바탕 부분에, 다수의 대단히 짧은 수평한 선분으로 이루어지는 모양을 배치한 정방형으로 되어 있다. 이들 16개의 화소를 나타내는 도 3의 (a)를 목시하면, 도 1의 (a)와 마찬가지로 중앙 부분이 희며 또한 그 주위가 짙은 그레이인 것을, 시각적으로 이해하는 것이 가능해진다. 이후, 본 발명의 화상 처리 알고리즘의 설명에 있어서는, 도 3의 (a) 이외의 16개의 화소에 의한 모델에 대해서도 마찬가지의 방법으로, 각 화소의 상대적인 밝기나 어둡기를 시각적으로 표현한다.In Fig. 3 (a), the brightness (the degree of whiteness) and the darkness (the degree of blackness) of the pixel are visually and relatively expressed in correspondence with each pixel value of 16 pixels. . For example, the pixel of FIG. 3A corresponding to the display MG1 in FIG. 32A is the addresses (1, 1), (2, 1), ( 1,2) and (2,2) are four pixels. The pixel values of these pixels are around 250, and are white when viewed visually. Accordingly, the four pixels in the central portion are in the form of a white-haired square without a shape on the background. On the other hand, the pixel in Fig. 3A corresponding to the good work WG1 in Fig. 32A is 12 pixels surrounding the four pixels in the center as described above. The pixel values of these pixels are around 100 and are dark gray when viewed. Therefore, the 12 pixels have a square shape in which a shape composed of a number of very short horizontal line segments is arranged on a base portion other than a number representing a pixel value. 3 (a) showing these 16 pixels, it becomes possible to visually understand that the center portion is white and the circumference is dark gray as in FIG. 1 (a). Thereafter, in the description of the image processing algorithm of the present invention, the relative brightness or darkness of each pixel is visually expressed in the same manner for a model with 16 pixels other than Fig. 3A.

또, 이하의 설명에 있어서는 문장의 간소화를 목적으로 하여, 어드레스 (a, b)에 배치되는 화소의 것을 (a, b)의 화소로 표기한다. 마찬가지로, 어드레스 (a, b)에 배치되는 화소의 화소값의 것을 (a, b)의 화소값으로 표기한다. 여기서, 도 3의 (a)에는 도 1과 마찬가지로 대칭축으로서의 제 1 직선(L1) 및 제 2 직선(L2)을 겹쳐 기재하고 있다. 이 도 3의 (a)를 이용하여, 이하에 본 발명의 화상 처리 알고리즘에 대해서 순서를 따라 설명한다.In addition, in the following description, for the purpose of simplification of a sentence, the pixel arranged at the address (a, b) is referred to as a pixel (a, b). Similarly, the pixel values of the pixels arranged at the addresses (a, b) are denoted by the pixel values of (a, b). Here, in FIG. 3 (a), the first straight line L1 and the second straight line L2 as symmetry axes are overlapped as in FIG. 3 (a), the image processing algorithm of the present invention will be described below in order.

본 발명의 화상 처리 알고리즘은, 전술한 바와 같이 기준 직선으로서의 대칭축 즉 도 3의 (a)에 있어서의 제 1 직선(L1) 혹은 제 2 직선(L2)에 관해서 선대칭이 되는 영역을 갖는 화상에 적용된다(한쪽의 영역을 제 1 영역이라고 부르고, 다른 쪽의 영역을 제 2 영역이라고 부른다). 여기에, 도 3의 (a)에 있어서 제 1 직선(L1)을 대칭축으로 했을 경우에 대해서, 각 화소의 화소값의 대칭성에 착안한다. 예를 들면 (0,0)에 위치하는 화소값 100의 화소와 (0,3)에 위치하는 화소값 103의 화소는, 대칭 위치에 배치되어 있다. 마찬가지로 예를 들면 (2,1)에 위치하는 화소값 255의 화소와 (2,2)에 위치하는 화소값 253의 화소도 또한 대칭 위치에 배치되어 있다. 이후 원화상을 구성하는 화소를 원화소라고 명명한다.As described above, the image processing algorithm of the present invention is applied to an image having an axis of symmetry as a reference straight line, that is, an area that becomes line-symmetric with respect to the first straight line L1 or the second straight line L2 in Fig. 3A. (One area is called the first area, and the other area is called the second area). Here, in the case where the first straight line L1 is the symmetry axis in Fig. 3A, the symmetry of the pixel values of each pixel is focused. For example, pixels having a pixel value of 100 located at (0,0) and pixels having a pixel value of 103 positioned at (0,3) are arranged at symmetrical positions. Similarly, for example, pixels with a pixel value of 255 located at (2, 1) and pixels with a pixel value of 253 located at (2, 2) are also arranged in a symmetrical position. The pixels constituting the original image are hereinafter referred to as original pixels.

이 때 도 3의 (a)의 16개의 원화소의 집합을 정방형의 접기종이라고 생각하면, 제 1 직선(L1)을 접은 자국으로 해서 이 접기종이를 접음으로써 상기 대칭 위치에 있는 원화소끼리를 서로 겹칠 수 있다. 이 처리를 상하 접음이라고 부른다. 본 발명의 화상 처리 알고리즘은, 먼저 이 상하 접음에 의해 겹친 2개의 원화소 즉 제 1 직선(L1)에 관해서 선대칭의 위치에 배치되는 2개의 원화소의 화소값에 대해서, 차분(差分)이 되는 차분 화소값을 전체 원화소에 대해서 산출한다. 달리 말하면, 상하 접음에 의해 겹친 2개의 원화소를 하나의 페어로 하여, 전체 페어의 각각에 대해서 차분 화소값을 산출한다. 이 공정을 차분 산출 공정이라고 명명한다. 차분 산출 공정 이후에, 산출한 차분 화소값을 갖는 차분 화소를, 그 차분 화소값의 산출에 사용한 2개의 원화소와 동일한 위치에 배치해서 차분 화상(제 1 차분 화상)을 생성한다. 예를 들면 제 1 영역 내의 제 1 위치의 원화소와 제 2 영역 내의 제 2 위치의 원화소의 페어를 사용하여 차분 화소값을 산출했을 경우에는, 이 차분 화소값을 갖는 차분 화소를, 차분 화상의 제 1 위치와 제 2 위치에 배치해서 차분 화상을 생성한다. 이 공정을 차분 화상 생성 공정이라고 명명한다.In this case, if the set of 16 original pixels in Fig. 3A is regarded as a square folding species, folding the folding papers with the first straight line L1 as folding marks, thereby folding the original pixels at the symmetrical positions. They can overlap each other. This process is called vertical folding. The image processing algorithm of the present invention first becomes a difference with respect to the pixel values of the two original pixels overlapped by the vertical folding, i.e., the two linear pixels arranged at the line symmetry relative to the first straight line L1. The difference pixel value is calculated for all the original pixels. In other words, the difference pixel values are calculated for each of the entire pair by using two original pixels overlapped by vertical folding as one pair. This process is called a difference calculation process. After the difference calculation step, a difference pixel (first difference image) is generated by disposing a difference pixel having the calculated difference pixel value at the same position as the two original pixels used to calculate the difference pixel value. For example, when a difference pixel value is calculated using a pair of the original pixel at the first position in the first area and the original pixel at the second position in the second area, the difference pixel having the difference pixel value is a difference image Difference images are generated by arranging them in the first position and the second position. This process is called a difference image generation process.

도 3의 (a)의 원화상에 대하여 차분 산출 공정 및 차분 화상 생성 공정을 실행해서 생성한 제 1 차분 화상을 도 3의 (b)에 나타낸다. 예를 들면 도 3의 (a)의 원화상에 있어서, 상기 (0,0)의 원화소와 (0,3)의 원화소를 이용하여 차분 산출 공정을 실행하면, 얻어지는 차분 화소값은 103-100=3이 된다. 따라서 이 차분 화소값 3을 갖는 차분 화소를 이용하여 차분 화상 생성 공정을 실행하면, 도 3의 (b)의 제 1 차분 화상에 있어서 (0,0) 및 (0,3)의 화소값은 3이 된다. 마찬가지로 원화상에 있어서 상기 (2,1)의 원화소와 (2,2)의 원화소를 이용하여 차분 산출 공정을 실행하면, 얻어지는 차분 화소값은 255-253=2가 된다. 따라서 이 차분 화소값 2를 갖는 차분 화소를 이용하여 차분 화상 생성 공정을 실행하면, 도 3의 (b)의 제 1 차분 화상에 있어서 (2,1) 및 (2,2)의 화소값은 2가 된다.The first difference image generated by executing the difference calculation process and the difference image generation process with respect to the original image in Fig. 3A is shown in Fig. 3B. For example, in the original image of Fig. 3A, when the difference calculation process is performed using the original pixel of (0,0) and the original pixel of (0,3), the difference pixel value obtained is 103- 100 = 3. Therefore, when the difference image generation process is executed using the difference pixel having the difference pixel value 3, the pixel values of (0,0) and (0,3) in the first difference image in FIG. 3B are 3 It becomes. Similarly, if the difference calculation process is performed using the original pixel of (2,1) and the original pixel of (2,2) in the original image, the difference pixel value obtained is 255-253 = 2. Therefore, when the difference image generation process is performed using the difference pixel having the difference pixel value 2, the pixel values of (2, 1) and (2, 2) in the first difference image in FIG. 3B are 2 Becomes

여기서, 도 3의 (b)에 나타내는 제 1 차분 화상에 있어서, 16개의 화소의 화소값은 전부 최소의 화소값인 0에 극히 가까운 작은 값이다. 이러한 작은 화소값이 생성되는 것은, 전술한 바와 같이 도 3의 (a)에 있어서 제 1 직선(L1)을 대칭축으로 하여 대칭 위치에 배치되는 2개의 원화소의 차분 화소를, 이들 2개의 원화소와 동일한 위치에 배치해서 도 3의 (b)를 생성하는 것에 기인하고 있다. 이들 2개의 원화소는 대칭 위치에 배치되어 있기 때문에, 각각의 화소값이 극히 근접해 있다. 따라서, 이들 2개의 화소의 차분 화소값은 0에 극히 가까운 값이 된다. 이러한 화소값을 갖는 도 3의 (b)의 16개의 화소를 목시하면 흑색이다. 이것에 대응해서 도 3의 (b)에 있어서의 16개의 화소는 전부, 화소값을 나타내는 숫자 이외의 바탕 부분에, 다수의 우측 올림 사선으로 이루어지는 모양을 배치한 정방형으로 되어 있다.Here, in the first difference image shown in Fig. 3B, the pixel values of all 16 pixels are small values extremely close to 0, which is the minimum pixel value. As described above, these small pixel values are generated using the difference pixels of the two original pixels arranged at symmetric positions with the first straight line L1 as a symmetric axis in FIG. This is due to the fact that it is arranged in the same position as and generates FIG. 3 (b). Since these two original pixels are arranged at symmetrical positions, the pixel values of each are very close. Therefore, the difference pixel values of these two pixels are extremely close to zero. When 16 pixels in Fig. 3B having such pixel values are visually observed, they are black. Corresponding to this, all of the 16 pixels in FIG. 3B are squares in which a shape made up of a number of right-handed diagonal lines is arranged on a base portion other than a number indicating a pixel value.

다음으로 본 발명의 화상 처리 알고리즘은, 도 3의 (a)에 있어서 좌우 대칭의 대칭축인 제 2 직선(L2)에 주목한다. 이 제 2 직선(L2)은 원화상을 좌반분과 우반분에 동일한 8개의 화소로 분할한다. 제 2 직선(L2)의 좌측에 위치하는 8개의 원화소와, 제 2 직선(L2)의 우측에 위치하는 8개의 원화소는 서로 대칭 위치에 배치되어 있다. 예를 들면 (0,0)에 위치하는 화소값 100의 원화소와 (3,0)에 위치하는 화소값 110의 원화소는, 대칭 위치에 배치되어 있다. 마찬가지로 예를 들면 (1,1)에 위치하는 화소값 254의 원화소와 (2,1)에 위치하는 화소값 255의 원화소도 또한 대칭 위치에 배치되어 있다.Next, the image processing algorithm of the present invention pays attention to the second straight line L2, which is a symmetric axis of left and right symmetry in Fig. 3A. This second straight line L2 divides the original image into eight pixels equal to the left half and the right half. The eight original pixels located on the left side of the second straight line L2 and the eight original pixels located on the right side of the second straight line L2 are arranged in symmetrical positions with each other. For example, the original pixel of the pixel value 100 located at (0,0) and the original pixel of the pixel value 110 located at (3,0) are arranged in a symmetrical position. Similarly, for example, an original pixel with a pixel value of 254 located at (1, 1) and an original pixel with a pixel value of 255 located at (2, 1) are also arranged at symmetrical positions.

이 때 전술한 제 1 직선(L1)에 관한 선대칭의 경우와 마찬가지로, 도 3의 (a)의 16개의 원화소의 집합을 정방형의 접기종이라고 생각하면, 제 2 직선(L2)을 접은 자국으로 하여 이 접기종이를 접음으로써 상기 대칭 위치에 있는 원화소끼리를 서로 겹칠 수 있다. 이 처리를 좌우 접음이라고 부른다. 이 좌우 접음에 의해 겹친 2개의 원화소 즉 제 2 직선(L2)에 관해서 선대칭의 위치에 배치되는 2개의 원화소의 화소값에 대해서, 차분이 되는 차분 화소값을 전체 원화소에 대해서 산출하는 차분 산출 공정을 실행한다. 차분 산출 공정 이후에, 산출한 차분 화소값을 갖는 차분 화소를, 그 차분 화소값의 산출에 사용한 2개의 원화소와 동일한 위치에 배치해서 차분 화상(제 2 차분 화상)을 생성하는 차분 화상 생성 공정을 실행한다.In this case, as in the case of line symmetry with respect to the first straight line L1 described above, if the set of 16 original pixels in Fig. 3A is considered to be a square folding species, the second straight line L2 is a folded mark. By folding the folding paper, the original pixels in the symmetrical position can overlap each other. This process is called folding left and right. The difference which calculates the difference pixel value which becomes a difference with respect to the pixel values of the two original pixels superimposed by the left and right folds, that is, the two straight pixels L2 arranged at a line symmetry position, with respect to the entire original pixels The calculation process is performed. After the difference calculation step, a difference image generation step of generating a difference image (second difference image) by arranging the difference pixels having the calculated difference pixel values at the same positions as the two original pixels used to calculate the difference pixel values Run

도 3의 (a)의 원화상에 대하여 차분 산출 공정 및 차분 화상 생성 공정을 실행해서 생성한 제 2 차분 화상을 도 3의 (c)에 나타낸다. 예를 들면 도 3의 (a)의 원화상에 있어서, 상기 (0,0)의 원화소와 (3,0)의 원화소를 이용하여 차분 산출 공정을 실행하면, 얻어지는 차분 화소값은 110-100=10이 된다. 따라서 이 차분 화소값 10을 갖는 차분 화소를 이용하여 차분 화상 생성 공정을 실행하면, 도 3의 (c)의 제 2 차분 화상에 있어서 (0,0) 및 (3,0)의 화소값은 10이 된다. 마찬가지로 원화상에 있어서 상기 (1,1)의 원화소와 (2,1)의 원화소를 이용하여 차분 산출 공정을 실행하면, 얻어지는 차분 화소값은 255-254=1이 된다. 따라서 이 차분 화소값 1을 갖는 차분 화소를 이용하여 차분 화상 생성 공정을 실행하면, 도 3의 (c)의 제 2 차분 화상에 있어서 (1,1) 및 (2,1)의 화소값은 1이 된다.The second difference image generated by executing the difference calculation process and the difference image generation process with respect to the original image in Fig. 3A is shown in Fig. 3C. For example, in the original image of Fig. 3A, when the difference calculation process is performed using the original pixel of (0,0) and the original pixel of (3,0), the difference pixel value obtained is 110- 100 = 10. Therefore, when the difference image generation process is executed using the difference pixel having the difference pixel value 10, the pixel values of (0,0) and (3,0) in the second difference image in FIG. 3C are 10. It becomes. Similarly, if the difference calculation process is performed using the original pixel of (1, 1) and the original pixel of (2, 1) in the original image, the difference pixel value obtained is 255-254 = 1. Therefore, when the difference image generation process is executed using the difference pixel having the difference pixel value 1, the pixel values of (1,1) and (2,1) in the second difference image in FIG. 3C are 1 It becomes.

여기서, 도 3의 (c)에 나타내는 제 2 차분 화상에 있어서 16개의 화소의 화소값은 전부 최소의 화소값인 0에 극히 가까운 작은 값이다. 이러한 작은 화소값이 생성되는 것은 전술한 도 3의 (b)에 관한 설명과 마찬가지로, 도 3의 (a)에 있어서 제 2 직선(L2)을 대칭축으로 해서 대칭 위치에 배치되는 2개의 원화소의 차분 화소를, 이들 2개의 원화소와 동일한 위치에 배치해서 도 3의 (c)를 생성하는 것에 기인하고 있다. 이들 2개의 원화소는 대칭 위치에 배치되어 있기 때문에, 각각의 화소값이 극히 근접해 있다. 따라서, 이들 2개의 화소의 차분 화소값은 0에 극히 가까운 값이 된다. 이러한 화소값을 갖는 도 3의 (c)의 16개의 화소를 목시하면 흑색이다. 이것에 대응해서 도 3의 (c)에 있어서는 도 3의 (b)와 마찬가지로 16개의 화소는 전부, 화소값을 나타내는 숫자 이외의 바탕 부분이 다수의 우측 올림의 사선으로 이루어지는 모양을 배치한 정방형으로 되어 있다.Here, in the second difference image shown in Fig. 3C, the pixel values of the 16 pixels are all small values extremely close to 0, which is the minimum pixel value. This small pixel value is generated in the same manner as described with reference to FIG. 3 (b), as shown in FIG. 3 (a). This is due to the fact that the difference pixels are arranged at the same positions as these two original pixels to generate Fig. 3 (c). Since these two original pixels are arranged at symmetrical positions, the pixel values of each are very close. Therefore, the difference pixel values of these two pixels are extremely close to zero. When 16 pixels in Fig. 3C having such pixel values are visually observed, they are black. Corresponding to this, in Fig. 3 (c), as in Fig. 3 (b), all 16 pixels are squares in which a portion of the background other than the number representing the pixel value is made up of a number of right-rounded diagonal lines. It is done.

여기서, 상기 차분 산출 공정에 있어서의 상하 접음 및 좌우 접음을 소프트웨어에서 실행하는 구체적인 알고리즘에 대해, 설명을 보충한다. 도 3의 (a)에 있어서의 16개의 화소에는 각각 도 2와 같이 어드레스가 부여되어 있다.Here, a description is supplemented with respect to a specific algorithm for executing up and down folding and left and right folding in the difference calculation process in software. Addresses are assigned to the 16 pixels in Fig. 3A as shown in Fig. 2, respectively.

그래서 상하 접음을 실행할 때에는, 도 2에 의거하여 도 3의 (a)에 있어서의 제 1 직선(L1)의 일단의 어드레스 및 타단의 어드레스를 결정한 뒤, 이들 어드레스를 차분 산출 공정을 실행하는 소프트웨어(이하 차분 산출 소프트웨어)에 입력으로서 전달한다. 이에 따라 차분 산출 소프트웨어는 대칭축을 인식하고, 그 일단 및 타단의 어드레스에 의해 상하 접음인 것을 판단할 수 있다.Therefore, when performing folding up and down, the software which executes the difference calculation process after determining the address of one end and the other end of the first straight line L1 in FIG. 3 (a) based on FIG. Hereinafter, as the input to the difference calculation software). Accordingly, the difference calculation software recognizes the axis of symmetry and can determine that the fold is up or down by the addresses of the one end and the other end.

마찬가지로 좌우 접음을 실행할 때에는, 도 2에 의거하여 도 3의 (a)에 있어서의 제 2 직선(L2)의 일단의 어드레스 및 타단의 어드레스를 결정한 뒤, 이들 어드레스를 차분 산출 소프트웨어에 입력으로서 전달한다. 이에 따라 차분 산출 소프트웨어는 대칭축을 인식하고, 그 일단 및 타단의 어드레스에 의해 좌우 접음인 것을 판단할 수 있다.Similarly, when performing the folding of the left and right, the addresses of one end and the other end of the second straight line L2 in Fig. 3A are determined based on Fig. 2, and then these addresses are transmitted to the difference calculation software as input. . Accordingly, the difference calculation software recognizes the axis of symmetry and can determine that the fold is left and right by the addresses of the one end and the other end.

도 3의 (a)에 있어서의 제 1 직선(L1)의 일단의 어드레스는, (0,1)과 (0,2)의 2개의 화소에 끼워져 있었던 위치에 대응한다. 따라서, 그 어드레스는 (0,1.5)가 되며, 이것은 도 2에 있어서 화살표 Y로 나타내는 방향에 있어서의 (0,0)과 (0,3)의 화소의 어드레스의 중앙값과 다름없다.The address of one end of the first straight line L1 in Fig. 3A corresponds to a position sandwiched by two pixels (0, 1) and (0, 2). Therefore, the address becomes (0,1.5), which is equal to the median value of the address of the pixels of (0,0) and (0,3) in the direction indicated by arrow Y in FIG. 2.

마찬가지로 도 3의 (a)에 있어서의 제 1 직선(L1)의 타단의 어드레스는, (3,1)과 (3,2)의 2개의 화소에 끼워져 있었던 위치에 대응한다. 따라서, 그 어드레스는 (3,1.5)가 되고, 이것은 도 2에 있어서 화살표 Y에서 나타내는 방향에 있어서의 (3,0)과 (3,3)의 화소의 어드레스의 중앙값과 다름없다.Similarly, the address of the other end of the first straight line L1 in Fig. 3A corresponds to a position sandwiched between two pixels (3, 1) and (3, 2). Therefore, the address becomes (3,1.5), which is equal to the median value of the address of the pixels (3,0) and (3,3) in the direction indicated by arrow Y in FIG. 2.

이와 같이 하여 결정한 (0,1.5) 및 (3,1.5)라고 하는 2개의 어드레스를 차분 산출 소프트웨어에 입력으로서 전달하면, 차분 산출 소프트웨어는 도 2의 어드레스를 테이블로서 가지므로, 이 테이블을 참조해서 대칭축으로서의 제 1 직선(L1)을 생성할 수 있다. 그리고 대칭축이 수평한 것으로부터, 차분 산출 소프트웨어는 상하 접음을 실행하는 것으로 판단하여, 예를 들면 상기의 도 3의 (a)에 있어서의 (0,0)의 화소값과 (0,3)의 화소값에 대해서 차분을 산출하고, 마찬가지로 (2,1)의 화소값과 (2,2)의 화소값에 대해서 차분을 산출한다.If the two addresses (0,1.5) and (3,1.5) determined in this way are passed to the difference calculation software as the input, the difference calculation software has the address of Fig. 2 as a table, so refer to this table and refer to the symmetric axis It is possible to generate the first straight line L1 as. And since the axis of symmetry is horizontal, the difference calculation software judges to perform up and down folding, for example, the pixel values of (0,0) and (0,3) in (a) of Fig. 3 above. The difference is calculated for the pixel values, and similarly, the difference is calculated for the pixel values of (2, 1) and the pixel values of (2, 2).

도 3의 (a)에 있어서의 제 2 직선(L2)에 대해서도 마찬가지로, 일단의 어드레스로서 (0,0)과 (3,0)의 중앙값인 (1.5,0)을 차분 산출 소프트웨어에 입력으로서 전달하는 동시에, 타단의 어드레스로서 (0,3)과 (3,3)의 중앙값인 (1.5,3)을 차분 산출 소프트웨어에 입력으로서 전달하면 된다. 이들 어드레스를 수취한 차분 산출 소프트웨어는, 상기 제 1 직선(L1)의 경우와 마찬가지로, 도 2의 어드레스의 테이블을 참조해서 대칭축으로서의 제 2 직선(L2)을 생성할 수 있다. 그리고 대칭축이 수직한 것으로부터, 차분 산출 소프트웨어는 좌우 접음을 실행하는 것으로 판단하여, 예를 들면 상기의 도 3의 (a)에 있어서의 (0,0)의 화소값과 (3,0)의 화소값에 대해서 차분을 산출하고, 마찬가지로 (1,1)의 화소값과 (2,1)의 화소값에 대해서 차분을 산출한다.Similarly for the second straight line L2 in Fig. 3A, (0,0) and (1.5,0), which are the median values of (3,0) as a set of addresses, are transmitted to the difference calculation software as input. At the same time, (0,3) and (1.5,3), which are the median values of (0,3) and (3,3), can be transferred to the difference calculation software as inputs. The difference calculation software having received these addresses can generate the second straight line L2 as a symmetric axis by referring to the table of the address in FIG. 2, similarly to the case of the first straight line L1. Then, from the vertical axis of symmetry, it is determined that the difference calculation software performs left and right folding, for example, the pixel values of (0,0) and (3,0) in (a) of FIG. 3 above. The difference is calculated with respect to the pixel value, and similarly, the difference is calculated with respect to the pixel value of (1,1) and the pixel value of (2,1).

이상의 공정에 의해, 도 3의 (a)의 원화상으로부터 도 3의 (b)에 나타내는 제 1 차분 화상 및 도 3의 (c)에 나타내는 제 2 차분 화상을 생성하면, 다음으로 각 차분 화상을 구성하는 16개의 화소의 화소값에 주목한다. 구체적으로는, 이들 16개의 화소 중, 대다수의 화소값에 비하여 크게 이간(離間)된 값이 되는 화소값(이하 이간 화소값)을 갖는 화소(이하 이간 화소)를 선출한다. 그 수순을 도 3의 (d) 내지 도 4의 (c)를 이용하여, 이하에 설명한다.When the first difference image shown in Fig. 3 (b) and the second difference image shown in Fig. 3 (c) are generated from the original image in Fig. 3 (a) by the above steps, each difference image is next generated. Note the pixel values of the 16 pixels that constitute. Specifically, among these 16 pixels, a pixel (hereinafter referred to as an inter-pixel) having a pixel value (hereinafter referred to as an inter-pixel value) that is significantly separated from the majority of the pixel values is selected. The procedure will be described below using Figs. 3D to 4C.

먼저 도 3의 (b)에 나타내는 16개의 차분 화소의 화소값을 내림차순으로 나열한다. 그 결과를 도 3의 (b)의 바로 아래에 도 3의 (d)로서 나타낸다. 도 3의 (d)는 상하에 배치되는 3개의 단(段)으로 구성되어 있다. 각 단에는 수치가 기재되며, 그 좌단에 당해 단의 수치의 의미를 표제로서 적고 있다. 각 단의 수치간에는 하향의 화살표가 기재되며, 이에 따라 화살표의 상측의 단의 수치로부터 화살표의 하측의 단의 수치를 생성하는 공정의 설명을 이해하는데 일조하고 있다.First, pixel values of 16 difference pixels shown in FIG. 3B are arranged in descending order. The results are shown immediately below FIG. 3 (b) as FIG. 3 (d). 3 (d) is composed of three stages arranged at the top and bottom. Numerical values are written in each column, and the meaning of the numerical values of the column is written in the left column. A downward arrow is described between the numerical values of each stage, thereby helping to understand the description of the process of generating the numerical value of the lower stage of the arrow from the numerical value of the upper stage of the arrow.

도 3의 (d)의 상단의 표제는 차분 화소값 내림차순이며, 상기 도 3의 (b)에 나타내는 16개의 차분 화소의 화소값을 내림차순으로 나열한 결과이다. 화소값은 7, 3, 2, 1의 4종류이며, 좌단에 최대값이 되는 7을 배치하고, 거기서부터 우측으로 순차적으로 작은 화소값을 배치하고 있다. 우단은 최소값이 되는 1이 배치되어 있다.The heading at the top of FIG. 3D is the descending order of the difference pixel values, and is a result of listing the pixel values of the 16 differential pixels shown in FIG. 3B in the descending order. There are four types of pixel values: 7, 3, 2, and 1, with 7 being the maximum value at the left end, and small pixel values sequentially arranged therefrom. At the right end, 1, which is the minimum value, is placed.

다음으로 상단에 있어서 인접하는 차분 화소값간의 차분을 산출해서 중단에 배열한다. 중단의 표제는 인접 차분 화소값의 차분값이며, 상기 차분값이 적혀 있다. 좌단의 수치는 4이며, 이 4라는 값은 상단에 있어서의 좌단의 7과 그 우측에 인접하는 3의 차분이다. 이것을 나타내기 위해서, 차분값 4의 산출에 사용한 상단의 화소값 7 및 3과 중단의 차분값 4가 각각 하향의 화살표에 의해 대응지어져 있다. 중단에 있어서의 그 밖의 수치에 관해서도 마찬가지이다.Next, the difference between adjacent difference pixel values at the top is calculated and arranged in the middle. The title of the middle is the difference value of the adjacent difference pixel value, and the difference value is written. The numerical value at the left end is 4, and the value of 4 is the difference between 7 at the left end at the top and 3 adjacent to the right. To show this, the upper pixel values 7 and 3 used for the calculation of the difference value 4 and the difference value 4 of the middle are respectively associated with the downward arrows. The same may be said of other numerical values in interruption.

이상의 공정을 종료하면, 다음으로 중단의 수치에 있어서의 최대값을 선출한다. 이 선출은, 전술한 이간 화소를 선출하기 위한 공정이다. 도 3의 (d)의 경우에는 중단에 있어서의 좌단의 수치 4가 최대값이다. 그리고, 이 최대값이 되는 차분값을 생성한 상단의 2개의 화소값은, 좌단의 7과 그것에 인접하는 3이다. 이 7과 3의 구간은 중단의 차분값이 최대가 되는 구간이며, 이 구간에 있어서 7과 3의 중앙값을 임계값으로서 설정하면, 상기의 이간 화소를 선출할 수 있다. 실제로, 도 3의 (d)의 상단에 적힌 4개의 수치를 보면, 좌단의 수치 7에 대하여 나머지 3개의 수치는 3, 2, 1이며, 이들 3개의 수치간의 차분은 비교적 작다. 이에 대하여 좌단의 7만이 크게 이간되어 있으며, 이간 화소로 생각된다.When the above process is completed, the maximum value in the numerical value of the interruption is selected next. This election is a process for selecting the above-described inter-pixel. In the case of Fig. 3 (d), the numerical value 4 at the left end in the middle is the maximum value. In addition, the two pixel values at the top that generated the difference value that becomes the maximum value are 7 at the left end and 3 adjacent to it. The interval of 7 and 3 is a section in which the difference value of the middle is the maximum, and when the median of 7 and 3 is set as a threshold value in this section, the above-described inter pixel can be selected. In fact, when looking at the four values written at the top of FIG. 3 (d), the remaining three values are 3, 2, and 1 with respect to the value 7 at the left end, and the difference between these three values is relatively small. On the other hand, 70,000 at the left end are largely separated, and are considered to be separated pixels.

이와 같이 중단의 차분값이 최대가 되는 구간을 선출한 뒤, 당해 구간의 양단의 차분 화소값의 중앙값을 산출하여, 이간 화소를 선출하기 위한 임계값으로 한다. 이 임계값 산출 결과를 도 3의 (d)의 하단에 나타낸다. 하단의 표제는 차분값의 최대 구간에 있어서의 임계값이며, 중단의 수치로부터 선출된 최대의 차분값 4를 산출한 상단의 화소값인 7과 3의 중앙값으로서의 5(소수점 이하는 올림)를 임계값으로서 기재하고 있다.In this way, after the section where the difference value of the middle is maximized is selected, the median value of the difference pixel value at both ends of the section is calculated, and is used as a threshold value for selecting the separated pixel. The result of this threshold calculation is shown at the bottom of Fig. 3D. The heading at the bottom is the threshold value in the maximum section of the difference value, and the threshold value of 5 (rounding up to the decimal point) is 5 as the median value of 7 and 3, which are the upper pixel values that calculated the maximum difference value 4 selected from the number of interruptions. It is described as a value.

이상의 공정을 거쳐서 임계값을 설정하면, 상단의 화소값 중에서 이 임계값보다 큰 값이 되는 화소값을 선출한다. 이 선출된 화소값이 이간 화소값이며, 이간 화소값을 갖는 화소가 이간 화소이다. 선출되는 화소값이 7인 것은, 상기의 설명으로부터 명확하다.When the threshold value is set through the above steps, a pixel value that is greater than this threshold value is selected from the upper pixel values. This elected pixel value is a separation pixel value, and a pixel having a separation pixel value is a separation pixel. It is clear from the above description that the pixel value to be selected is 7.

그 결과, 이간 화소의 화소값「7」은, 다른 화소값「3, 2, 1」로부터 소정값 이상으로 이간되어 있다. 소정값의 예는, 최대의 차분값 4이다. 이 경우, 이간 화소의 화소값「7」은, 화소값「3」으로부터는 4만큼 이간되고, 화소값「2」로부터는 5만큼 이간되고, 화소값「1」로부터는 6만큼 이간되어 있고, 다른 화소값으로부터 소정값 이상으로(즉 4 이상) 이간되어 있다.As a result, the pixel value "7" of the separated pixel is separated from the other pixel values "3, 2, 1" by a predetermined value or more. An example of the predetermined value is the maximum difference value 4. In this case, the pixel value "7" of the separated pixel is separated by 4 from the pixel value "3", separated by 5 from the pixel value "2", and separated by 6 from the pixel value "1", They are separated from other pixel values by a predetermined value or more (ie, 4 or more).

이상의 도 3의 (b)에 나타내는 제 1 차분 화상에 대한 도 3의 (d)의 공정과 마찬가지로, 도 3의 (c)에 나타내는 제 2 차분 화상에 대하여도 도 3의 (e)의 공정에 의해 임계값을 설정하여, 도 3의 (c)의 화소 중에서 이간 화소값 10을 선출한다. 도 3의 (c)와 도 3의 (e)의 관계는 전술한 도 3의 (b)와 도 3의 (d)의 관계와 동일하다. 또한 도 3의 (e)의 상단, 중단, 하단의 수치와 각 단 사이의 화살표의 의미도 도 3의 (d)와 동일하다. 따라서, 도 3의 (e)에 대한 상세한 설명은 생략한다.Similar to the process of Fig. 3 (d) for the first difference image shown in Fig. 3 (b), the second difference image shown in Fig. 3 (c) is also used in the process of Fig. 3 (e). By setting the threshold value, the inter-pixel value 10 is selected from the pixels in Fig. 3C. The relationship between FIG. 3 (c) and FIG. 3 (e) is the same as the relationship between FIG. 3 (b) and FIG. 3 (d). In addition, the meanings of the arrows at the top, middle, and bottom of FIG. 3 (e) and each stage are the same as in FIG. 3 (d). Therefore, detailed description of FIG. 3E is omitted.

이상의 공정을 거쳐서 선출된 도 3의 (b) 및 도 3의 (c)에 있어서의 이간 화소를, 각각 도 4의 (a) 및 도 4의 (b)에 화소값을 이중 테두리로 둘러싸는 것에 의해 표시한다. 이렇게 해서 2개의 차분 화상에 있어서 이간 화소를 선출한 뒤에, 다음 공정으로서 2개의 차분 화상에 있어서의 이간 화소의 공통 부분을 선출한다. 그리고, 이 선출한 공통 부분이 원화상에 있어서 결함이 존재할 가능성이 있는 영역, 즉 결함 검사를 행해야 할 검사 대상 영역으로 된다.3 (b) and 3 (c), which were selected through the above steps, to surround the pixel values with double borders in FIGS. 4 (a) and 4 (b), respectively. Display. After the separation pixels are selected in the two difference images, the common portion of the separation pixels in the two difference images is selected as the next step. Then, the selected common portion is an area where defects may be present in the original image, that is, an area to be inspected for defect inspection.

여기서, 도 4의 (a) 및 도 4의 (b)에는 이간 화소의 공통 부분이 존재하지 않는다. 그 이유는, 도 3의 (a)의 원화상이 도 32의 (a)에 나타내는 양품 워크(WG1), 즉 결함을 갖고 있지 않은 워크를 모델화한 것이며, 2개의 대칭축으로서의 제 1 직선(L1) 및 제 2 직선(L2)에 대하여 선대칭이 되기 때문이다. 따라서 도 3의 (a)의 원화상에 있어서 결함 검사를 행해야 할 검사 대상 영역은 존재하지 않는다.Here, in FIG. 4A and 4B, a common portion of the inter-pixel is not present. The reason is that the original image in Fig. 3 (a) is a model of a good work WG1 shown in Fig. 32 (a), that is, a work having no defects, and the first straight line L1 as two symmetric axes And the line symmetry with respect to the second straight line L2. Therefore, in the original image in Fig. 3 (a), there is no inspection target area for defect inspection.

도 3의 (a)의 원화상에 있어서, 도 4의 (a) 및 도 4의 (b)에 화소값을 이중 테두리로 둘러싸는 것에 의해서 나타내는 이간 화소의 공통 부분과 동일한 위치에 배치되는 원화소를, 화소값을 이중 테두리로 둘러싸는 것에 의해서 나타낸 화상을 도 4의 (c)에 나타낸다. 전술한 바와 같이 도 4의 (a) 및 도 4의 (b)에 상기 이중 테두리로 나타내는 2개의 차분 화상에 있어서의 이간 화소는, 공통 부분을 갖고 있지 않다. 이 때문에, 도 4의 (c)에는 화소값이 이중 테두리로 둘러싸여지는 화소는 존재하지 않으며, 도 3의 (a)와 동일한 화상으로 된다.In the original image of Fig. 3A, the original pixel arranged at the same position as the common portion of the spaced apart pixels shown by enclosing the pixel values in Figs. 4A and 4B with double borders. Fig. 4 (c) shows an image shown by enclosing the pixel values with double borders. As described above, the spaced pixels in the two difference images shown by the double frame in Figs. 4A and 4B do not have a common portion. For this reason, there is no pixel in which the pixel value is surrounded by a double frame in FIG. 4C, and the image is the same as in FIG. 3A.

이상과 같은 도 3의 (a)의 모델을 사용한 설명으로부터, 도 32의 (a)의 양품 화상(PG1)에 나타내는 바와 같은 선대칭의 영역을 갖는 양품 워크(WG1)의 원화상에 대하여 본 발명의 화상 처리 알고리즘을 적용했을 경우에는, 결함 검사를 행해야 할 검사 대상 영역은 선출되지 않는 것을 알 수 있다.From the above description using the model of Fig. 3 (a), the original image of the good work WG1 having a line-symmetrical region as shown in the good product image PG1 in Fig. 32 (a) of the present invention When the image processing algorithm is applied, it can be seen that the inspection target area to which defect inspection is to be performed is not selected.

(2) 본 발명의 화상 처리 알고리즘의 적용예(2) Application example of the image processing algorithm of the present invention

다음으로 도 33의 (a)의 불량 화상(PD1)에 나타내는 바와 같은 선대칭의 영역을 갖는 불량 워크(WD1)의 화상에 대하여 본 발명의 화상 처리 알고리즘을 적용했을 경우에 대해 설명한다. 도 5의 (a)는, 도 33의 (a)의 불량 화상(PD1) 내의 불량 워크(WD1)를, 상기의 도 3의 (a)와 마찬가지로 16개의 화소를 이용하여 원화상으로서 모델화한 것이다. 각 화소에는 도 33의 (b)의 표에 대응하는 바와 같은 화소값을 기재하고 있다.Next, the case where the image processing algorithm of the present invention is applied to an image of a defective work WD1 having a line-symmetrical region as shown in the defective image PD1 in Fig. 33A is described. 5 (a) is a model of the defective work WD1 in the defective image PD1 in FIG. 33 (a) as an original image using 16 pixels as in FIG. 3 (a) above. . In each pixel, pixel values as corresponding to the table in Fig. 33B are described.

여기서 도 5의 (a)와 도 3의 (a)의 상위(相違)점, 즉 도 5의 (a)에 있어서의 결함의 표현에 대해 설명한다. 도 5의 (a)와 도 3의 (a)의 상위점은, 어드레스 (0,0) 및 (2,2)에 배치되는 화소의 화소값에 있다. 도 3의 (a)에 있어서의 어드레스 (0,0)의 화소값은 100이며, 이 화소값은 도 32의 (b)에 나타내는 양품 워크(WG1)의 화소값에 대응하고 있다. 이에 대하여 도 5의 (a)에 있어서의 어드레스 (0,0)의 화소값은 200이며, 이 화소값은 도 33의 (b)에 나타내는 불량 워크(WD1) 상의 결함(D1)의 화소값에 대응하고 있다. 마찬가지로 도 3의 (a)에 있어서의 어드레스 (2,2)의 화소값은 100이며, 이 화소값은 도 32의 (b)에 나타내는 표시(MG1)의 화소값에 대응하고 있다. 이에 대하여 도 5의 (a)에 있어서의 어드레스 (2,2)의 화소값은 180이며, 이 화소값은 도 33의 (b)에 나타내는 표시(MD1) 상의 결함(D2)의 화소값에 대응하고 있다.Here, the difference between the points (a) of FIG. 5 and (a) of FIG. 3, that is, the expression of the defects in FIG. 5 (a) will be described. The difference between FIG. 5 (a) and FIG. 3 (a) lies in the pixel values of the pixels arranged at the addresses (0,0) and (2,2). The pixel value of the address (0,0) in Fig. 3A is 100, and this pixel value corresponds to the pixel value of the good work WG1 shown in Fig. 32B. On the other hand, the pixel value of the address (0,0) in Fig. 5A is 200, and this pixel value corresponds to the pixel value of the defect D1 on the defective work WD1 shown in Fig. 33B. Is responding. Similarly, the pixel value of the address (2, 2) in Fig. 3A is 100, and this pixel value corresponds to the pixel value of the display MG1 shown in Fig. 32B. On the other hand, the pixel value of the address (2,2) in Fig. 5A is 180, and this pixel value corresponds to the pixel value of the defect D2 on the display MD1 shown in Fig. 33B. Doing.

그리고, 도 5의 (a)에 있어서도 도 3의 (a)와 마찬가지로, 중앙부에 있는 어드레스 (1,1), (2,1), (1,2), (2,2)의 4개의 화소를 둘러싸는 12개의 화소가 불량 워크(WD1)로 된다. 또한 도 5의 (a)에 있어서의 불량 워크(WD1)의 화소값은, 결함을 나타내는 상기 (0,0)을 제외하고 도 3의 (a)와 동일한 값으로 되어 있다. 마찬가지로 표시(MD1)의 화소값은, 결함을 나타내는 상기 (2,2)를 제외하고 도 3의 (a)와 동일한 값으로 되어 있다. 또, 도 5에 나타내는 각 화소의 화소값과 당해 화소를 나타내는 정방형의 바탕 모양의 관계는, 도 3과 동일하다.Also in FIG. 5 (a), as in FIG. 3 (a), four pixels of addresses (1,1), (2,1), (1,2), and (2,2) in the center Twelve pixels surrounding the defective work WD1. In addition, the pixel value of the defective work WD1 in Fig. 5A is the same as that in Fig. 3A, except for the above (0,0) indicating a defect. Similarly, the pixel value of the display MD1 is set to the same value as that in Fig. 3 (a) except for the above (2, 2) indicating a defect. In addition, the relationship between the pixel value of each pixel shown in FIG. 5 and the square ground shape showing the pixel is the same as in FIG. 3.

여기에, 전술한 바와 같이 도 5의 (a)의 화소값과 도 3의 (a)의 화소값을 비교하면, 도 5의 (a)에 있어서의 (0,0) 및 (2,2)의 화소값이 각각 도 3의 (a)와 다른 200 및 180이다. 이들 화소값을 목시하면, 도 33의 (b)에 나타내는 바와 같이 모두 옅은 그레이이다. 이 목시에서 옅은 그레이로 보이는 화소는 양품 화상인 도 32의 (a)의 각 영역의 대응을 나타내는 도 32의 (b)에는 존재하지 않으며, 그 결과로서 도 32의 (a)를 모델화한 도 3의 (a)에는 존재하지 않는다. 그래서 이 옅은 그레이에 대응하기 때문에, 도 5의 (a)에 있어서의 (0,0) 및 (2,2)의 화소는 화소값을 나타내는 숫자 이외의 바탕 부분에, 다수의 도트(dot)로 이루어지는 모양을 배치한 정방형으로 되어 있다.If the pixel values in Fig. 5A are compared with the pixel values in Fig. 3A as described above, (0,0) and (2,2) in Fig. 5A. The pixel values of are 200 and 180, which are different from those in Fig. 3A. When these pixel values are visually observed, they are all light gray as shown in Fig. 33B. In this visual, the pixels shown in light gray do not exist in Fig. 32 (b) showing the correspondence of each region of Fig. 32 (a), which is a good image, and as a result, Fig. 3 (a) is modeled. It does not exist in (a). Therefore, since it corresponds to this light gray, the pixels of (0,0) and (2,2) in Fig. 5A are formed of a number of dots on the background portion other than the number representing the pixel value. It becomes a square in which the shape made is arrange | positioned.

도 5의 (a)의 원화상에 대하여 전술한 차분 산출 공정 및 차분 화상 생성 공정을 실행해서 생성한 제 1 차분 화상을 도 5의 (b)에 나타낸다. 또한, 마찬가지의 공정을 실행해서 생성한 제 2 차분 화상을 도 5의 (c)에 나타낸다. 여기서 도 5의 (b) 및 도 5의 (c)를, 각각 도 3의 (b) 및 도 3의 (c)와 비교한다. 먼저 도 5의 (b)와 도 3의 (b)를 비교하면, 양자에는 차이가 있음을 알 수 있다. 도 3의 (b)에 있어서의 16개의 화소의 화소값은 전부, 전술한 바와 같이 0에 극히 가깝다. 이에 대하여 도 5의 (b)에 있어서의 16개의 화소값 중, (0,0) 및 (0,3)의 화소값은 97이며, (2,2) 및 (2,1)의 화소값은 65이다. 이들은 다른 화소의 화소값이 극히 0에 가까운 것에 반하여, 0에 비해 상당히 큰 화소값 즉 0으로부터 이간된 화소값이다.The first difference image generated by executing the above-described difference calculation step and the difference image generation step with respect to the original image in Fig. 5A is shown in Fig. 5B. 5C shows the second difference image generated by performing the same process. Here, Fig. 5 (b) and Fig. 5 (c) are compared with Figs. 3 (b) and 3 (c), respectively. First, when FIG. 5 (b) and FIG. 3 (b) are compared, it can be seen that there is a difference between the two. All of the pixel values of the 16 pixels in FIG. 3B are extremely close to 0 as described above. On the other hand, of the 16 pixel values in Fig. 5B, the pixel values of (0,0) and (0,3) are 97, and the pixel values of (2,2) and (2,1) are 65. These are pixel values that are significantly larger than 0, that is, pixel values separated from 0, while pixel values of other pixels are extremely close to zero.

이들 4개의 화소의 화소값이 0으로부터 이간되는 이유를 이하에 설명한다. 도 5의 (a)의 원화상에 있어서, 결함에 대응하는 (0,0)의 화소값은 200이다. 그리고 제 1 직선(L1)을 대칭축으로 하여 (0,0)의 화소와 대칭 위치에 배치되는 화소는 결함에 대응하지 않는 (0,3)이며, 그 화소값은 103이다. 이들 2개의 화소값의 차분 화소값을 원화상의 (0,0) 및 (0,3)의 위치에 배치한 것이, 도 5의 (b)의 제 1 차분 화상이다. 이 때문에, 원화상에 있어서 결함에 대응하는 (0,0)의 화소값과 결함에 대응하지 않는 (0,3)의 화소값의 차분이 큰 것에 기인하여, 도 5의 (b)의 (0,0) 및 (0,3)의 화소값이 커져서, 0으로부터 이간된다. 또한 도 5의 (a)의 원화상에 있어서, 결함에 대응하는 (2,2)의 화소값은 180이다. 그리고 제 1 직선(L1)을 대칭축으로 하여 (2,2)의 화소와 대칭 위치에 배치되는 화소는 결함에 대응하지 않는 (2,1)이며, 그 화소값은 255이다. 이들 2개의 화소값의 차분 화소값을 원화상의 (2,2) 및 (2,1)의 위치에 배치한 것이, 도 5의 (b)의 제 1 차분 화상이다. 이 때문에, 원화상에 있어서 결함에 대응하는 (2,2)의 화소값과 결함에 대응하지 않는 (2,1)의 화소값의 차분이 큰 것에 기인하여, 도 5의 (b)의 (2,2) 및 (2,1)의 화소값이 커져서, 0으로부터 이간된다.The reason why the pixel values of these four pixels are separated from 0 will be described below. In the original image in Fig. 5A, the pixel value of (0,0) corresponding to the defect is 200. In addition, the pixel arranged at the symmetric position with the pixel of (0,0) with the first straight line L1 as the axis of symmetry is (0,3) that does not correspond to the defect, and the pixel value is 103. Differences between these two pixel values Pixel values are arranged at positions (0,0) and (0,3) of the original image, which is the first difference image in Fig. 5B. For this reason, due to the large difference between the pixel value of (0,0) corresponding to the defect and the pixel value of (0,3) not corresponding to the defect in the original image, (0) in FIG. The pixel values of, 0) and (0,3) become large, and are separated from zero. In addition, in the original image in Fig. 5A, the pixel value of (2, 2) corresponding to the defect is 180. And the pixel arranged in the symmetric position with the pixel of (2,2) with the first straight line L1 as the axis of symmetry is (2,1) which does not correspond to the defect, and the pixel value is 255. Differences between these two pixel values Pixel values are arranged at positions (2, 2) and (2, 1) of the original image, which is the first difference image in Fig. 5B. For this reason, due to the large difference between the pixel value of (2,2) corresponding to the defect and the pixel value of (2,1) not corresponding to the defect in the original image, (2) of FIG. The pixel values of, 2) and (2,1) become large, and are separated from zero.

다음으로 도 5의 (c)와 도 3의 (c)를 비교하면, 역시 양자에는 차이가 있음을 알 수 있다. 도 3의 (c)에 있어서의 16개의 화소의 화소값은 전부, 전술한 바와 같이 0에 극히 가깝다. 이에 대하여 도 5의 (c)에 있어서의 16개의 화소값 중, (0,0) 및 (3,0)의 화소값은 90이며, (1,2) 및 (2,2)의 화소값은 71이다. 이들은 다른 화소의 화소값이 극히 0에 가까운 것에 반하여, 0에 비해 상당히 큰 화소값 즉 0으로부터 이간된 화소값이다.Next, when comparing FIG. 5 (c) and FIG. 3 (c), it can be seen that there is a difference between the two. All of the pixel values of the 16 pixels in FIG. 3C are extremely close to 0 as described above. On the other hand, among the 16 pixel values in Fig. 5C, the pixel values of (0,0) and (3,0) are 90, and the pixel values of (1,2) and (2,2) are 71. These are pixel values that are significantly larger than 0, that is, pixel values separated from 0, while pixel values of other pixels are extremely close to zero.

이들 4개의 화소의 화소값이 0으로부터 이간되는 이유를 이하에 설명한다. 도 5의 (a)의 원화상에 있어서, 결함에 대응하는 (0,0)의 화소값은 200이다. 그리고 제 2 직선(L2)을 대칭축으로 하여 (0,0)의 화소와 대칭 위치에 배치되는 화소는 결함에 대응하지 않는 (3,0)이며, 그 화소값은 110이다. 이들 2개의 화소값의 차분 화소값을 원화상의 (0,0) 및 (3,0)의 위치에 배치한 것이, 도 5의 (c)의 제 2 차분 화상이다. 이 때문에, 원화상에 있어서 결함에 대응하는 (0,0)의 화소값과 결함에 대응하지 않는 (3,0)의 화소값의 차분이 큰 것에 기인하여, 도 5의 (c)의 (0,0) 및 (3,0)의 화소값이 커져서, 0으로부터 이간된다. 또한 도 5의 (a)의 원화상에 있어서, 결함에 대응하는 (2,2)의 화소값은 180이다. 그리고 제 2 직선(L2)을 대칭축으로 하여 (2,2)의 화소와 대칭 위치에 배치되는 화소는 결함에 대응하지 않는 (1,2)이며, 그 화소값은 251이다. 이들 2개의 화소값의 차분 화소값을 원화상의 (2,2) 및 (1,2)의 위치에 배치한 것이, 도 5의 (c)의 제 2 차분 화상이다. 이 때문에, 원화상에 있어서 결함에 대응하는 (2,2)의 화소값과 결함에 대응하지 않는 (1,2)의 화소값의 차분이 큰 것에 기인하여, 도 5의 (c)의 (2,2) 및 (1,2)의 화소값이 커져서, 0으로부터 이간된다.The reason why the pixel values of these four pixels are separated from 0 will be described below. In the original image in Fig. 5A, the pixel value of (0,0) corresponding to the defect is 200. In addition, the pixel arranged at the symmetric position with the pixel of (0,0) with the second straight line L2 as the axis of symmetry is (3,0) that does not correspond to the defect, and the pixel value is 110. The difference between these two pixel values The pixel values are arranged at positions (0, 0) and (3, 0) of the original image, which is the second difference image in Fig. 5 (c). For this reason, due to the large difference between the pixel value of (0,0) corresponding to the defect and the pixel value of (3,0) not corresponding to the defect in the original image, (0 of FIG. 5C) The pixel values of, 0) and (3,0) become large, and are separated from zero. In addition, in the original image in Fig. 5A, the pixel value of (2, 2) corresponding to the defect is 180. And the pixel arranged in the symmetric position with the pixel of (2,2) with the second straight line L2 as the axis of symmetry is (1,2) that does not correspond to the defect, and the pixel value is 251. Differences between these two pixel values Pixel values are arranged at positions (2, 2) and (1, 2) of the original image, which is the second difference image in Fig. 5 (c). For this reason, due to the large difference between the pixel value of (2,2) corresponding to the defect and the pixel value of (1,2) not corresponding to the defect in the original image, (2) of FIG. The pixel values of, 2) and (1,2) become large, and are separated from zero.

이상의 사실에 의해, 차분 산출 공정 및 차분 화상 생성 공정을 실행하면, 결함이 존재할 가능성이 있는 영역의 화소값으로부터 생성되는 차분 화소값은, 결함이 존재하지 않는 영역의 화소값으로부터 생성되는 차분 화소값에 비하여 크게 이간되는 것을 알 수 있다. 이것을 이용하여, 도 5의 (b) 및 도 5의 (c)의 차분 화상에 있어서 이간 화소값을 갖는 이간 화소를 선출하면, 원화상에 있어서 이간 화소를 생성한 원화소가 배치되는 위치에는 결함이 존재할 가능성이 있는 것으로 판단할 수 있다. 이 이간 화소값을 선출하는 공정이, 상기의 도 3의 (d) 및 도 3의 (e)를 사용한 설명에 있어서의, 인접 차분 화소값의 차분값이 최대가 되는 구간에 임계값을 설정하는 공정에 해당한다.Due to the above, when the difference calculation process and the difference image generation process are executed, the difference pixel value generated from the pixel value of the area where the defect may exist is the difference pixel value generated from the pixel value of the area where the defect does not exist. It can be seen that the separation is significantly larger than that. By using this, if an interpolated pixel having the inter-pixel value is selected in the difference images in FIGS. 5B and 5C, the original pixel generating the inter-pixel in the original image is defective. It can be judged that there is a possibility. In the process of selecting the inter-pixel values, the threshold value is set in a section in which the difference value between adjacent difference pixel values becomes the maximum in the description using FIGS. 3D and 3E above. Corresponds to the process.

여기서, 도 5의 (b) 및 도 5의 (c)에 대하여 도 3의 (d) 및 도 3의 (e)와 동일한 공정을 실시했을 경우의 결과를 도 5의 (d) 및 도 5의 (e)에 나타낸다. 도 5의 (d) 및 도 5의 (e)의 기재 방법은, 각각 도 3의 (d) 및 도 3의 (e)와 동일하다. 따라서, 도 5의 (d) 및 도 5의 (e)에 관한 상세한 설명은 생략한다. 도 5의 (d)의 하단에 기재된 임계값을 이용하여 도 5의 (b)의 화소 중에서 이간 화소값을 선출하면, 65 및 97이 된다. 마찬가지로 도 5의 (e)의 하단에 기재된 임계값을 이용하여 도 5의 (c)의 화소 중에서 이간 화소값을 선출하면, 71 및 90이 된다.5 (d) and 5 (c) of FIG. 5 (d) and FIG. It is shown in (e). The description method of FIG. 5 (d) and FIG. 5 (e) is the same as that of FIG. 3 (d) and FIG. 3 (e), respectively. Therefore, detailed description of FIGS. 5D and 5E is omitted. When the inter-pixel values are selected from the pixels in FIG. 5B using the threshold values described at the bottom of FIG. 5D, 65 and 97 are obtained. Similarly, if the inter-pixel values are selected from the pixels in Fig. 5C using the threshold values described at the bottom of Fig. 5E, they become 71 and 90.

이상의 공정을 거쳐서 선출된 도 5의 (b) 및 도 5의 (c)에 있어서의 이간 화소를, 각각 도 6의 (a) 및 도 6의 (b)에 화소값을 이중 테두리로 둘러싸는 것에 의해서 표시한다. 이렇게 하여 2개의 차분 화상에 있어서 이간 화소가 선출된 뒤에, 다음 공정으로서 2개의 차분 화상에 있어서의 이간 화소의 공통 부분을 선출한다. 도 6의 (a) 및 도 6의 (b)에 있어서의 이간 화소의 공통 부분은 (0,0) 및 (2,2)이다.5B and 5C, which were selected through the above steps, enclose the pixel values in double borders in FIGS. 6A and 6B, respectively. Is indicated by. After the separation pixels are selected in the two difference images in this way, a common portion of the separation pixels in the two difference images is selected as the next step. The common parts of the spaced-out pixels in FIGS. 6A and 6B are (0,0) and (2,2).

도 5의 (a)의 원화상에 있어서 이 공통 부분과 동일한 위치에 배치되는 원화소를, 화소값을 이중 테두리로 둘러싸는 것에 의해서 나타낸 화상을 도 6의 (c)에 나타낸다. 이 이중 테두리의 화소는, 도 5의 (a)에 있어서 결함에 대응하는 화소와 동일하다. 즉 도 33의 (a)의 불량 화상(PD1)에 나타내는 바와 같은, 결함(D1 및 D2) 이외의 영역이 선대칭이 되는 불량 워크(WD1)의 원화상에 비하여 본 발명의 화상 처리 알고리즘을 적용했을 경우에는, 결함 검사를 행해야 할 검사 대상 영역을 용이하게 선출할 수 있음을 알 수 있다. 이 공정을 전술한 종래 기술에 있어서 검사 대상 영역을 선별하는 공정과 비교하면, 공정 수가 크게 감소하고 있음을 알 수 있다. 또한, 작업자가 원화상을 목시해서 판단을 행하는 공정이 대폭 삭감되어 있음을 알 수 있다. 이것은 원화상이 대칭축에 관해서 선대칭이 되는 영역을 가질 경우에, 본 발명의 화상 처리 알고리즘을 사용함으로써 생기는 효과이다.Fig. 6 (c) shows an image in which the original pixels arranged in the same position as the common portion in the original image in Fig. 5A are surrounded by double borders of pixel values. The pixel of this double frame is the same as the pixel corresponding to the defect in Fig. 5A. That is, as shown in the defective image PD1 in Fig. 33 (a), the image processing algorithm of the present invention is applied as compared to the original image of the defective work WD1 in which areas other than the defects D1 and D2 become line symmetry. In this case, it can be seen that the inspection target area to which defect inspection is to be performed can be easily selected. It can be seen that the number of processes is greatly reduced when this process is compared with the process of selecting the inspection target region in the above-mentioned conventional technology. In addition, it can be seen that the process of making a judgment by visually inspecting the original image is significantly reduced. This is an effect produced by using the image processing algorithm of the present invention when the original image has a region that is line symmetric with respect to the axis of symmetry.

이상의 설명에 있어서는, 원화상으로서 도 3의 (a)와 같은, 정방형의 중심에 한 둘레 작은 정방형표시를 갖는, 상하 대칭이면서 또한 좌우 대칭인 형상을 갖는 워크의 모델을 예로 들었다. 이 경우에는 전술한 바와 같이 2개의 대칭축을 갖고 있으며, 원화상으로부터 생성되는 차분 화상은 대칭축의 수에 대응한 2개가 된다. 그러나, 본 발명에 있어서는 대칭축의 수는 2개로 한정되는 것이 아니다. C를 자연수라고 했을 때에, 대칭축의 수가 C개이면, 상기 차분 산출 공정 및 차분 화상 생성 공정을 거쳐서 생성되는 차분 화상의 수는 C개가 된다. 그 경우에는 C개의 차분 화상에 대해서 이간 화소를 선출하고, 그들의 공통 부분을 원화상에 있어서 결함 검사를 행해야 할 검사 대상 영역으로 한다.In the above description, a model of a work having a symmetrical shape that is vertically symmetrical and vertically symmetrical, having a small square display around the center of the square, as shown in Fig. 3 (a), is exemplified as the original image. In this case, as described above, there are two symmetrical axes, and the difference image generated from the original image becomes two corresponding to the number of symmetrical axes. However, in the present invention, the number of symmetrical axes is not limited to two. When C is a natural number, if the number of symmetric axes is C, the number of difference images generated through the difference calculation process and the difference image generation process is C. In this case, the spaced-out pixels are selected for the C difference images, and the common portion thereof is used as the inspection target area for defect inspection in the original image.

(3) 본 발명의 워크 반송과 화상 처리: 제 1 직선(L1) 및 제 2 직선(L2)을 사용(3) Work conveyance and image processing of the present invention: using the first straight line L1 and the second straight line L2

한편, 다수의 워크의 촬상 화상을 얻기 위해서는, 촬상 장치가 워크를 촬상하는 것이 가능해지는 위치까지, 반송 수단에 의해 워크를 잇달아 반송하는 것이 필요하다. 이 때, 워크가 상기 대칭축을 갖고 있을 경우여도, 워크의 외형 및 그 면 상에 있어서의 부품의 배치에 따라서는, 반송 수단에 있어서의 워크의 반송 방법에 기인하여, 복수의 촬상 화상에 있어서의 워크의 대칭축의 방향이 하나로 정해지지 않을 경우가 있다. 그 일례에 대해서, 도 7을 사용하여 설명한다. 이 설명에 있어서는 단순화를 위해, 대칭축이 1개인 양품 워크를 예로 들고 있다.On the other hand, in order to obtain captured images of a large number of workpieces, it is necessary to continuously convey the workpieces by means of conveying to a position where the imaging device can image the workpieces. At this time, even if the work has the above-mentioned symmetry axis, depending on the outer shape of the work and the arrangement of parts on the surface, due to the conveying method of the work in the conveying means, in a plurality of captured images In some cases, the direction of the axis of symmetry of the work may not be determined as one. The example will be described with reference to FIG. 7. In this description, for simplicity, a good-quality work piece having one symmetric axis is taken as an example.

도 7의 (a)는 양품 워크(WG2)(이하 워크(WG2))를 촬상한 뒤, 상기의 템플릿 매칭법을 이용하여 워크(WG2)를 추출함으로써 생성한 원화상의 형상 및 치수를 나타내는 도면이다. 워크(WG2)는 한 변이 a인 정방형이며, 그 한 변의 중점(P0)에 있어서 당해 변에 접해서 원형의 표시(MG2)가 마킹되어 있다. 당해 변의 일단이 되는 워크(WG2)의 모서리로부터 중점(P0)까지의 길이 a/2와 표시(MG2)의 직경 d 사이에는 d < a/2의 관계가 있다. 이 원화상에 겹쳐서, 도 1의 (a)와 마찬가지로 제 1 직선(L1)과 제 2 직선(L2)을 기재하고 있다. 도 7의 (a)에 있어서, 원화상은 분명히 제 1 직선(L1)에 관해서 선대칭이 아니라, 제 2 직선(L2)에 관해서 선대칭이다. 즉 대칭축은 제 2 직선(L2)이다.Fig. 7 (a) is a view showing the shape and dimensions of the original image generated by imaging the good work WG2 (hereinafter, the work WG2) and then extracting the work WG2 using the above template matching method. to be. The work WG2 is a square in which one side is a, and the circular mark MG2 is marked in contact with the side at the midpoint P0 of the side. There is a relationship of d < a / 2 between the length a / 2 from the edge of the work WG2 serving as one end of the side to the midpoint P0 and the diameter d of the display MG2. Overlapping this original image, the first straight line L1 and the second straight line L2 are described as in Fig. 1A. In Fig. 7 (a), the original image is clearly not line symmetry with respect to the first straight line L1, but line symmetry with respect to the second straight line L2. That is, the axis of symmetry is the second straight line L2.

여기서, 워크(WG2)를 촬상 수단에 의한 촬상이 가능해지는 위치까지 반송하는 반송 수단에 대해서, 도 7의 (b)를 사용하여 설명한다. 도 7의 (b)는 반송 수단(T1)에 의해 반송되는 워크(WG2)를 반송 수단(T1)의 상측으로부터 본 모습을 나타낸다. 반송 수단(T1)은 수평으로 설치되며, 워크(WG2)를 재치한 상태에서 반송하는, 양측에 서로 대략 평행한 에지(E1 및 E2)를 가진 가늘고 긴 직선 모양의 피더(F1)를 구비하고 있다. 에지(E1 및 E2)에는, 재치한 워크(WG2)가 피더(F1)의 외측으로 튀어 나오는 것을 방지하는 기구가 부가될 경우도 있다. 워크(WG2)는 도 7의 (a)에 나타내는 면이 상측으로 되도록, 또한 당해 면의 대향하는 2 변이 에지(E1 및 E2)와 대략 평행하게 되도록, 피더(F1)의 윗면에 재치된다. 그리고 도시되지 않은 구동 기구의 작용에 의해, 도 7의 (b)에 나타내는 화살표 X1의 방향으로 피더(F1)가 이동함으로써, 워크(WG2)는 직선 경로로 반송된다. 도시되지 않은 촬상 수단은 반송 수단(T1)의 상측에 설치되어, 워크(WG2)가 그 바로 아래 위치까지 반송되었을 때에, 워크(WG2)의 윗면을 도 7의 (a)에 나타내는 촬상 화상을 얻도록 촬상 가능하다.Here, the conveying means for conveying the work WG2 to a position at which imaging by the imaging means becomes possible will be described using Fig. 7B. Fig. 7B shows a view of the work WG2 conveyed by the conveying means T1 from the upper side of the conveying means T1. The conveying means T1 is provided horizontally, and is equipped with elongated straight feeders F1 having edges E1 and E2 substantially parallel to each other on both sides for conveying while the work WG2 is mounted. . A mechanism may be added to the edges E1 and E2 to prevent the placed work WG2 from jumping out of the feeder F1. The work WG2 is mounted on the upper surface of the feeder F1 so that the surface shown in Fig. 7 (a) is on the upper side and is substantially parallel to the two opposite edges E1 and E2 of the surface. And the work WG2 is conveyed by a linear path by the feeder F1 moving to the direction of arrow X1 shown in FIG. 7B by the action of the drive mechanism not shown. The imaging means (not shown) is provided on the upper side of the conveying means T1, and when the work WG2 is transported to a position immediately below it, an image of the top surface of the work WG2 shown in Fig. 7A is obtained. It is possible to take images.

또 도 7의 (b)에 있어서는, 반송 수단(T1)에 재치된 워크(WG2)를 W1 내지 W4의 4가지 방향에 대해 도시하고 있다. 전술한 바와 같이 워크(WG2)는 정방형이다. 그리고 반송 수단(T1)은 워크(WG2)를 재치할 때에, 전술한 바와 같이 도 7의 (a)에 나타내는 면이 상측으로 되도록, 또한 당해 면의 대향하는 2 변이 에지(E1 및 E2)와 대략 평행하게 되도록 위치 결정하고 있다. 즉, 워크(WG2)가 반송 수단(T1)에 의해 반송될 때에, 표시(MG2)는 반송 방향(화살표 X1)에 대하여 4가지의 위치 관계가 생긴다. 이 4가지의 위치 관계를 도 7의 (b)에 있어서, 반송되는 선두의 워크(W1), 선두로부터 2번째의 워크(W2), 3번째의 워크(W3), 최후미의 워크(W4)로서 나타낸다.7 (b), the work WG2 placed on the conveying means T1 is shown in four directions W1 to W4. As described above, the work WG2 is square. Then, when the work WG2 is mounted, the conveying means T1 is such that the surface shown in Fig. 7 (a) becomes the upper side as described above, and the two opposite edge edges E1 and E2 facing the surface are approximately It is positioned to be parallel. That is, when the work WG2 is conveyed by the conveying means T1, the display MG2 has four positional relationships with respect to the conveying direction (arrow X1). In Fig. 7 (b), these four positional relations are the first work W1 to be conveyed, the second work W2 from the first, the third work W3, and the last work W4. Is represented as.

도 7의 (b)에 있어서는 또한, 촬상 화상에 있어서의 대칭축이 될 수 있는 상기의 제 1 직선(L1) 및 제 2 직선(L2)을 각 워크(W1 내지 W4)에 겹쳐서 표시하고 있다. 워크(W1 내지 W4)에 있어서의 제 1 직선(L1) 및 제 2 직선(L2)으로부터 명확한 바와 같이, W1과 W3의 촬상 화상은 제 2 직선(L2)이 대칭축으로 되고, W2과 W4의 촬상 화상은 제 1 직선(L1)이 대칭축으로 된다. 즉, 워크(WG2)가 반송 수단에 재치되는 방향에 의존하여, 촬상 화상으로부터 워크를 추출하여 생성한 원화상의 대칭축의 방향이 하나로 정해지지 않는다.In Fig. 7B, the above-described first straight line L1 and second straight line L2, which can be symmetrical axes in the captured image, are superimposed on each work W1 to W4. As is evident from the first straight line L1 and the second straight line L2 in the work W1 to W4, the captured image of W1 and W3 is the second straight line L2 as the axis of symmetry, and the imaging of W2 and W4 In the image, the first straight line L1 is a symmetric axis. That is, depending on the direction in which the work WG2 is placed on the conveying means, the direction of the axis of symmetry of the original image generated by extracting the work from the captured image is not determined as one.

이러한 경우에, 작업자가 원화상을 개별적으로 목시하고, 제 1 직선(L1) 및 제 2 직선(L2) 중의 어느 것이 대칭축이 되는지를 그 때마다 결정하는 것은, 대단히 번잡하다. 그러나 본 발명의 화상 처리 알고리즘은, 이와 같이 개개의 원화상에 대하여 2개의 대칭축 중의 어느 하나를 선택할 필요가 있어도, 전술한 도 3 및 도 4 혹은 도 5 및 도 6를 사용한 설명과 마찬가지로, 2개의 대칭축의 양쪽에 대해서 차분 화상을 생성함으로써, 정확하게 검사 대상 영역을 선출할 수 있다. 그 공정에 대해서, 도 8 내지 도 11을 사용하여 검증하면서 설명한다.In such a case, it is very troublesome for the operator to visually view the original image individually and to determine at any time which one of the first straight line L1 and the second straight line L2 becomes the axis of symmetry. However, in the image processing algorithm of the present invention, even if it is necessary to select one of two symmetrical axes for each original image, as in the description using FIGS. 3 and 4 or FIGS. 5 and 6 described above, the two By generating differential images on both sides of the axis of symmetry, it is possible to accurately select an inspection target region. The process will be described with verification using FIGS. 8 to 11.

도 8의 (a)는 도 7의 (a)에 나타내는 양품 워크(WG2)를, 도 3의 (a)와 마찬가지로 16개의 화소에 의해 모델화한 원화상이다. 도 7의 (a)에 있어서의 표시(MG2)는, 도 8의 (a)에 있어서 (1,0) 및 (2,0)의 2개의 화소로 모델화하고 있다. 그들의 화소값은 도 3의 (a)에 있어서 중앙부에 배치되는 (1,1), (2,1), (1,2), (2,2)의 4개의 화소와 유사한 값이다. 또한 도 8의 (a)에 있어서 (1,0) 및 (2,0)의 2개의 화소 이외의 14개의 화소는, 도 7의 (a)에 있어서 표시(MG2)를 제외한 양품 워크(WG2)를 모델화한 것이다. 그들의 화소값은, 도 3의 (a)에 있어서 중앙부에 배치되는 (1,1), (2,1), (1,2), (2,2)를 둘러싸는 12개의 화소와 유사한 값이다. 또한, 도 8의 (a)에는 도 3의 (a)와 마찬가지로 제 1 직선(L1) 및 제 2 직선(L2)을 겹쳐서 기재하고 있다.Fig. 8 (a) is an original image obtained by modeling the good work WG2 shown in Fig. 7 (a) by 16 pixels as in Fig. 3 (a). The display MG2 in Fig. 7A is modeled as two pixels (1,0) and (2,0) in Fig. 8A. Their pixel values are similar to those of the four pixels (1, 1), (2, 1), (1, 2), and (2, 2) arranged in the center in Fig. 3A. In addition, 14 pixels other than the two pixels (1, 0) and (2, 0) in FIG. 8 (a), a non-defective work (WG2) excluding the display (MG2) in FIG. 7 (a). Is modeled. Their pixel values are similar to those of the 12 pixels surrounding (1,1), (2,1), (1,2), and (2,2) arranged at the center in Fig. 3A. . 8 (a), the first straight line L1 and the second straight line L2 are overlapped as in FIG. 3 (a).

또, 이하의 설명에서 사용하는 도 8의 (b), 도 8의 (c), 도 9의 (a) 내지 도 9의 (c)에서 각 화소를 나타내는 16개의 정방형에 있어서, 각각의 화소값을 나타내는 숫자 이외의 정방형 내부의 모양은 도 3의 그것과 동일하다. 또한, 도 8의 (d) 및 도 8의 (e)의 표기 방법도 도 3의 (d) 및 도 3의 (e)와 동일하다. 따라서, 이들에 관한 상세한 설명은 생략한다.In addition, in the 16 squares shown in Figs. 8 (b), 8 (c) and 9 (a) to 9 (c) used in the following description, each pixel value The shape of the inside of the square other than the number denoting is the same as that of FIG. 3. In addition, the notation method of FIG. 8 (d) and FIG. 8 (e) is the same as that of FIG. 3 (d) and FIG. 3 (e). Therefore, detailed description of these is omitted.

도 8의 (a)의 원화상에 대하여 차분 산출 공정 및 차분 화상 생성 공정을 실행해서 생성한 제 1 차분 화상을 도 8의 (b)에 나타낸다. 또한, 마찬가지로 해서 생성한 제 2 차분 화상을 도 8의 (c)에 나타낸다. 여기서, 도 8의 (a)에 나타내는 원화상은 제 1 직선(L1)에 대해서 대칭성을 갖고 있지 않다. 구체적으로는 (1,0) 및 (2,0)의 화소와 제 1 직선(L1)에 관해서 대칭 위치에 배치되는 (1,3) 및 (2,3)의 화소는, 화소값이 크게 다르다. 이것은 도 8의 (a)가 도 7의 (a)의 양품 워크(WG2)를 모델화한 화상인 것으로부터 명확하다. 도 8의 (a)에 있어서의 (1,0) 및 (2,0)의 화소는 도 7의 (a)에 있어서의 표시(MG2)에 대응하고 있다. 이에 대하여 도 8의 (a)에 있어서의 (1,3) 및 (2,3)의 화소는 도 7의 (a)에 있어서의 양품 워크(WG2)에 대응하고 있다.The first difference image generated by executing the difference calculation process and the difference image generation process with respect to the original image in Fig. 8A is shown in Fig. 8B. Also, the second difference image generated in the same manner is shown in Fig. 8C. Here, the original image shown in Fig. 8A does not have symmetry with respect to the first straight line L1. Specifically, the pixels of (1,0) and (2,0) and the pixels of (1,3) and (2,3) arranged at symmetrical positions with respect to the first straight line L1 have significantly different pixel values. . This is clear from FIG. 8 (a) being an image modeling the good work WG2 of FIG. 7 (a). The pixels (1,0) and (2,0) in Fig. 8A correspond to the display MG2 in Fig. 7A. On the other hand, the pixels (1,3) and (2,3) in Fig. 8A correspond to the good work WG2 in Fig. 7A.

도 7의 (a)를 목시하면, 제 1 직선(L1)에 대해서 대칭성을 갖고 있지 않은 것은 명확하다. 이 때문에, 원화상에 대하여 상하 접음을 실행해서 생성되는 도 8의 (b)의 제 1 차분 화상에 있어서, 원화상이 상기 대칭성을 갖고 있지 않은 위치에 배치되는 (1,0)과 (1,3)의 화소값은 145이다. 그리고 마찬가지로 원화상이 상기 대칭성을 갖고 있지 않은 위치에 배치되는 (2,0)과 (2,3)의 화소값은 142이다. 이들 화소값은, 다른 12개의 화소값에 대하여 이간 화소값으로 되어 있다. 한편, 이들의 150 근방의 화소값은 이 도 8의 (b)에 있어서 처음으로 출현했다. 이것에 시각적으로 대응하기 위해서, 이들 4개의 화소는 모두, 화소값을 나타내는 숫자 이외의 바탕 부분이 다수의 우측 내림 사선으로 이루어지는 모양을 배치한 정방형으로 되어 있다.7 (a), it is clear that the first straight line L1 has no symmetry. For this reason, in the first difference image in Fig. 8 (b) generated by folding up and down on the original image, (1,0) and (1, which are arranged at positions where the original image does not have the symmetry) The pixel value of 3) is 145. Similarly, the pixel values of (2,0) and (2,3) in which the original image is disposed at a position not having the symmetry are 142. These pixel values are separated from each other by 12 pixel values. On the other hand, these pixel values around 150 first appeared in Fig. 8B. In order to visually cope with this, all of these four pixels have a square shape in which a base portion other than a number representing a pixel value is formed of a plurality of right and left diagonal lines.

한편, 도 8의 (a)의 원화상은 제 2 직선(L2)에 관해서 대칭성을 갖고 있다. 이 때문에, 원화상에 대하여 좌우 접음을 실행해서 생성되는 도 8의 (c)의 제 2 차분 화상은, 모든 화소가 0에 극히 가까운 화소값이다. 다음으로, 도 8의 (b) 및 도 8의 (c)에 대하여 전술한 도 3의 (d) 및 도 3의 (e)와 동일한 공정을 실시했을 경우의 결과를 도 8의 (d) 및 도 8의 (e)에 나타낸다. 도 8의 (d)의 하단에 기재된 임계값을 이용하여, 도 8의 (b)의 화소 중에서 이간 화소값을 선출하면, 142 및 145가 된다. 마찬가지로 도 8의 (e)의 하단에 기재된 임계값을 이용하여, 도 8의 (c)의 화소 중에서 이간 화소값을 선출하면, 9 및 10이 된다.On the other hand, the original image in Fig. 8 (a) has symmetry with respect to the second straight line L2. For this reason, in the second difference image in Fig. 8 (c) generated by folding the left and right sides of the original image, all the pixels are pixel values extremely close to zero. Next, the results obtained when the same process as in Figs. 3 (d) and 3 (e) is performed with respect to Figs. 8 (b) and 8 (c) are shown in Figs. 8 (d) and 8 (c). It is shown in FIG. 8 (e). When the inter-pixel values are selected from the pixels in FIG. 8B using the threshold values described at the bottom of FIG. 8D, 142 and 145 are obtained. Similarly, using the threshold value described at the bottom of FIG. 8 (e), if an inter-pixel value is selected from the pixels in FIG. 8 (c), it becomes 9 and 10.

이상의 공정을 거쳐서 선출된 도 8의 (b) 및 도 8의 (c)에 있어서의 이간 화소를, 각각 도 9의 (a) 및 도 9의 (b)에 화소값을 이중 테두리로 둘러싸는 것에 의해 표시한다. 이와 같이 해서 2개의 차분 화상에 있어서 이간 화소가 선출된 뒤에, 다음 공정으로서 2개의 차분 화상에 있어서의 이간 화소의 공통 부분을 선출한다. 도 9의 (a) 및 도 9의 (b)에 있어서의 이간 화소의 공통 부분은 존재하지 않는다. 그 이유는, 전술한 도 4의 (a)와 도 4의 (b)에 있어서 이간 화소에 공통 부분이 존재하지 않는 이유와 동일하다. 이 때문에, 도 8의 (a)의 원화상에 있어서 이 공통 부분과 동일한 위치에 배치되는 원화소의 화소값을, 이중 테두리로 둘러싸는 것에 의해 나타낸 화상을 생성하면 도 9의 (c)와 같이 되어, 이중 테두리로 둘러싸여지는 화소값은 존재하지 않는다. 이와 같이 본 발명의 화상 처리 알고리즘은, 2개의 대칭축 중의 어느 하나에 관해서만 대칭성을 갖는 양품 워크의 원화상에 대하여도, 2개의 대칭축을 갖는 원화상에 대한 경우와 마찬가지로 적용할 수 있다.8 (b) and 8 (c), which were selected through the above steps, to surround the pixel values with double borders in FIGS. 9 (a) and 9 (b), respectively. Display. In this way, after the separation pixels are selected in the two difference images, a common portion of the separation pixels in the two difference images is selected as the next step. There is no common portion of the separation pixels in Figs. 9A and 9B. The reason is the same as the reason that the common portion does not exist in the inter-pixel in FIGS. 4A and 4B described above. For this reason, when the image shown by enclosing the pixel value of the original pixel arranged in the same position as this common part in the original image in Fig. 8A is surrounded by a double frame, as shown in Fig. 9C. Therefore, a pixel value surrounded by a double border does not exist. As described above, the image processing algorithm of the present invention can be applied to the original image of a good-quality work product having symmetry with respect to only one of the two symmetrical axes as in the case of the original image having two symmetrical axes.

다음으로, 도 7의 (a)의 양품 워크(WG2)에 대하여 결함을 부가한 불량 워크를 도 8의 (a)와 같이 모델화하고, 도 8의 (b) 내지 도 9의 (c)와 마찬가지의 공정을 실행한다. 도 10의 (a)는 도 8의 (a)에 나타내는 원화상에 2개소의 결함을 부가한 불량 워크(WD2)의 원화상이다. 결함을 나타내는 화소는 (0,1) 및 (2,3)이다.Next, the defective work in which a defect is added to the good work WG2 of Fig. 7 (a) is modeled as in Fig. 8 (a), and the same as in Figs. 8 (b) to 9 (c). To carry out the process. Fig. 10A is an original image of the defective work WD2 in which two defects are added to the original image shown in Fig. 8A. The pixels showing defects are (0, 1) and (2, 3).

여기서 도 8의 (a) 즉 도 7의 (a)의 양품 워크(WG2)에 대응하는 원화상을 보면, 다음의 것을 알 수 있다. 도 8의 (a)에 있어서 (1,0) 및 (2,0)의 화소 및 제 1 직선(L1)에 관해서 이들 2개의 화소와 대칭 위치에 배치되는 (1,3) 및 (2,3)의 화소를 제거하면, 원화상은 알파벳의 H에 유사한 형상이 된다. 그리고 이 H 형상의 원화상을 구성하는 12개의 화소값으로부터 볼 때, H 형상의 원화소는 제 1 직선(L1) 및 제 2 직선(L2)의 어느 것에 관해서도 대칭성을 갖고 있다. 그리고, 제거한 4개의 화소에 의해 구성되는 영역은, 제 2 직선(L2)에 대하여만 대칭성을 갖고 있다.Here, looking at the original image corresponding to the good work WG2 of Fig. 8 (a), that is, Fig. 7 (a), the following can be seen. In (a) of FIG. 8, (1,3) and (2,3) arranged in a symmetrical position with these two pixels with respect to the pixels (1,0) and (2,0) and the first straight line (L1) When the pixel of) is removed, the original image becomes a shape similar to the letter H of the alphabet. And from the 12 pixel values constituting the original H-shaped image, the original H-shaped pixel has symmetry with respect to either of the first straight line L1 and the second straight line L2. The region formed by the four removed pixels has symmetry only with respect to the second straight line L2.

그리고 도 10의 (a)에서 결함을 가진 화소로서 부가했던 (0,1)의 화소는, 상기의 H 형상의 원화소 즉 제 1 직선(L1) 및 제 2 직선(L2)의 어느 것에 관해서도 대칭성을 갖는 영역에 속해 있다. 또한, 도 10의 (a)에서 결함을 가진 화소로서 부가했던 (2,3)의 화소는, 상기의 제거한 원화소 즉 제 2 직선(L2)에 대하여만 대칭성을 갖는 영역에 속해 있다. 이와 같이 결함을 나타내는 화소를, 원화상에 있어서 대칭성의 관점으로부터 다른 성질을 갖는 2개소에 배치한 모델이 도 10의 (a)이다. 또 상기 (0,1) 및 (2,3)의 화소는 모두, 도 7의 (a)에 나타내는 양품 워크(WG2)에 있어서의 표시(MG2) 이외의 워크 상의 결함에 대응하는 위치에 배치되어 있다. 그리고, 도 10의 (a)에 있어서 (0,1)의 화소값은 22이며, 표시(MG2) 이외의 워크 상의 화소값이 100 근방인 것에 반해서 상당히 작고, 목시하면 정상 부분에 비해서 검게 보이는 결함이다. 또한, 도 10의 (a)에 있어서 (2,3)의 화소값은 170이며, 표시(MG2) 이외의 워크 상의 화소값이 100 근방인 것에 반해서 상당히 크고, 목시하면 정상 부분에 비해서 희게 보이는 결함이다.In addition, the pixel of (0,1) added as a defective pixel in Fig. 10A is symmetrical with respect to any of the H-shaped original pixels, that is, the first straight line L1 and the second straight line L2. It belongs to the area having. In addition, in (a) of FIG. 10, pixels (2, 3) added as defective pixels belong to a region having symmetry only with respect to the removed original pixel, that is, the second straight line L2. 10 (a) is a model in which pixels showing defects are arranged in two places having different properties from the viewpoint of symmetry in the original image. In addition, all of the pixels of (0, 1) and (2, 3) are arranged at positions corresponding to defects on the work other than the display MG2 in the good work WG2 shown in Fig. 7A. have. In addition, in (a) of FIG. 10, the pixel value of (0, 1) is 22, and the pixel value on the work other than the display MG2 is considerably small as compared to 100, and when viewed, the defect looks black compared to the normal part. to be. In addition, in (a) of FIG. 10, the pixel value of (2, 3) is 170, and the pixel value on the work other than the display MG2 is considerably larger than that of 100, and visually, a defect that appears white compared to the normal portion to be.

이 도 10의 (a)에 나타내는 불량 워크의 원화상에 대하여 전술한 차분 산출 공정 및 차분 화상 생성 공정을 실행해서 생성한 제 1 차분 화상을 도 10의 (b)에 나타낸다. 또한, 마찬가지의 공정을 실행해서 생성한 제 2 차분 화상을 도 10의 (c)에 나타낸다. 그리고, 도 10의 (b) 및 도 10의 (c)에 대하여 도 8의 (d) 및 도 8의 (e)와 동일한 공정을 실시했을 경우의 결과를 도 10의 (d) 및 도 10의 (e)에 나타낸다. 도 10의 (d)의 하단에 기재된 임계값을 이용하여, 도 10의 (b)의 화소 중에서 이간 화소값을 선출하면, 73, 83, 142, 145가 된다. 마찬가지로 도 10의 (e)의 하단에 기재된 임계값을 이용하여, 도 10의 (c)의 화소 중에서 이간 화소값을 선출하면, 64 및 87이 된다.The first difference image generated by executing the above-described difference calculation process and the difference image generation process with respect to the original image of the defective work shown in Fig. 10A is shown in Fig. 10B. 10 (c) shows a second difference image generated by performing the same process. 10 (d) and 10 (c), the same results as those of FIGS. 8 (d) and 8 (e) were performed. It is shown in (e). Using the threshold value described at the bottom of FIG. 10D, if an inter-pixel value is selected from the pixels in FIG. 10B, it becomes 73, 83, 142, and 145. Similarly, if the inter-pixel values are selected from the pixels in FIG. 10C using the threshold values described at the bottom of FIG. 10E, it becomes 64 and 87.

이상의 공정을 거쳐서 선출된 도 10의 (b) 및 도 10의 (c)에 있어서의 이간 화소를, 각각 도 11의 (a) 및 도 11의 (b)에 화소값을 이중 테두리로 둘러싸는 것에 의해 표시한다. 이와 같이 해서 2개의 차분 화상에 있어서 이간 화소가 선출된 뒤에, 다음 공정으로서 2개의 차분 화상에 있어서의 이간 화소의 공통 부분을 선출한다. 도 11의 (a) 및 도 11의 (b)에 있어서의 이간 화소의 공통 부분은 (0,1), (1,3), (2,3)이다. 도 10의 (a)의 원화상에 있어서 도 11의 (a) 및 도 11의 (b)에 나타내는 이간 화소의 공통 부분과 동일한 위치에 배치되는 원화소의 화소값을, 이중 테두리로 둘러싸는 것에 의해 나타낸 화상을 도 11의 (c)에 나타낸다. 도 11의 (c)에 있어서의 이중 테두리의 화소는 결함 검사를 행해야 할 검사 대상 영역이며, 도 10의 (a)에 있어서 결함에 대응하는 화소를 포함하고 있다. 이와 같이 본 발명의 화상 처리 알고리즘은, 2개의 대칭축 중의 어느 하나에 관해서만 대칭성을 갖는 불량 워크의 원화상에 대하여도, 2개의 대칭축을 갖는 원화상에 대한 경우와 마찬가지로 적용할 수 있고, 용이하게 검사 대상 영역을 선출할 수 있다.10B and 10C, which were selected through the above steps, to surround the pixel values in double borders in FIGS. 11A and 11B, respectively. Display. In this way, after the separation pixels are selected in the two difference images, a common portion of the separation pixels in the two difference images is selected as the next step. The common portions of the spaced-out pixels in Figs. 11A and 11B are (0,1), (1,3), and (2,3). In the original image of FIG. 10 (a), surrounding the pixel values of the original pixels arranged at the same position as the common portion of the spaced pixels shown in FIGS. 11 (a) and 11 (b) is surrounded by a double border. The image shown by is shown in Fig. 11C. The double-rimmed pixel in Fig. 11C is an inspection target area to be inspected for defects, and includes pixels corresponding to the defects in Fig. 10A. In this way, the image processing algorithm of the present invention can be applied to the original image of a defective work having symmetry only with respect to either of the two symmetrical axes, as in the case of the original image having two symmetrical axes, and can be applied easily. The area to be inspected can be selected.

(4) 본 발명의 워크 반송과 화상 처리: 제 3 직선(L3)을 사용(4) Work conveyance and image processing of the present invention: using the third straight line L3

상기의 도 3 내지 도 6 등을 사용한 본 발명의 화상 처리 알고리즘의 설명에 있어서는, 원화상의 대칭축이 되는 제 1 직선 혹은 제 2 직선은, 수평 혹은 수직하였다. 그러나, 본 발명의 알고리즘에 있어서의 대칭축은 이들에 한정되는 것이 아니다. 다른 대칭축의 예로서, 경사진 대칭축에 대해서 도 12 및 도 13을 사용하여 설명한다.In the description of the image processing algorithm of the present invention using the above Figs. 3 to 6 and the like, the first straight line or the second straight line serving as the symmetric axis of the original image was horizontal or vertical. However, the axis of symmetry in the algorithm of the present invention is not limited to these. As an example of another axis of symmetry, the inclined axis of symmetry will be described with reference to FIGS. 12 and 13.

도 12는 양품 워크(WG3)(이하 워크(WG3))를 촬상한 뒤, 상기의 템플릿 매칭법을 이용하여 워크(WG3)를 추출함으로써 생성한 원화상의 형상 및 치수를 나타내는 도면이다. 워크(WG3)는 한 변이 a인 정방형이며, 그 한 변의 한 점(P30) 및 당해 변에 인접하는 변의 한 점(P31)에 있어서 각각의 변에 접해서 직경 d인 원형의 표시(MG31)가 마킹되어 있다. 여기에, a 및 d의 값은 도 7의 (a)에 나타내는 워크(WG2)와 동일하다. 워크(WG3)에는 그 외에, 원형의 표시(MG31)가 접하고 있지 않은 나머지의 두 변의 각각의 한 점(P32 및 P33)에 있어서 접하도록, 표시(MG31)와 동일한 치수를 갖는 원형의 표시(MG32)가 마킹되어 있다. 각 변의 일단이 되는 워크(WG3)의 모서리로부터 중점(P0)까지의 길이 a/2와 표시(MG31 및 MG32)의 직경 d 사이에는, d < a/2의 관계가 있다. 도 12의 워크(WG3)는, 그 좌측 상단의 모서리와 우측 하단의 모서리를 이은 우측 내림이 되는 제 3 직선(L3)에 관해서 선대칭이다.12 is a view showing the shape and dimensions of an original image generated by imaging a good work WG3 (hereinafter, the work WG3) and then extracting the work WG3 using the above template matching method. The work WG3 is a square with one side a, and at one point P30 of one side and one point P31 of the side adjacent to the side, a circular display MG31 in contact with each side has a diameter d. It is marked. Here, the values of a and d are the same as the work WG2 shown in Fig. 7A. In addition, the circular display MG32 having the same dimensions as the display MG31 so that the circular display MG31 is not in contact with the work WG3 at each point P32 and P33 of the remaining two sides. ) Is marked. There is a relationship of d < a / 2 between the length a / 2 from the edge of the work WG3 serving as one end of each side to the midpoint P0 and the diameter d of the marks MG31 and MG32. The work WG3 of FIG. 12 is line symmetrical with respect to the third straight line L3 which is the right lowering connecting the upper left corner and the lower right corner.

이 도 12에 나타내는 워크(WG3)를 도 8의 (a)와 마찬가지로 모델화한 원화상을 도 13의 (a)에 나타낸다. 도 13의 (a)에 있어서, (2,0) (3,0) (3,1)의 3개의 화소는, 도 12에 있어서의 표시(MG31)에 대응한다. 마찬가지로 도 13의 (a)에 있어서 (0,2) (0,3) (1,3)의 3개의 화소는, 도 12에 있어서의 표시(MG32)에 대응한다. 이들 6개의 화소값은 도 8의 (a)에 있어서의 (1,0) 및 (2,0)의 화소와 유사한 값이다. 그리고 도 13의 (a)에 있어서의 상기 6개 이외의 10개의 화소는, 도 8의 (a)에 있어서의 (1,0) 및 (2,0) 이외의 14개의 화소와 유사한 값이다. 여기서 도 13의 (a)의 화소의 배치는, 원화소의 좌측 상단과 우측 하단을 이은 우측 내림이 되는 제 3 직선(L3)을 대칭축으로 하는 선대칭인 것을 알 수 있다. 즉, 이 경우의 접음은 도 3에 있어서의 상하 접음 혹은 좌우 접음과 마찬가지의 표기를 하면, 우상좌하(右上左下) 접음이 된다.The original image in which the work WG3 shown in Fig. 12 is modeled similarly to Fig. 8A is shown in Fig. 13A. In Fig. 13A, three pixels (2,0) (3,0) (3,1) correspond to the display MG31 in Fig. 12. Similarly, three pixels of (0,2) (0,3) (1,3) in Fig. 13A correspond to the display MG32 in Fig. 12. These six pixel values are values similar to the pixels of (1,0) and (2,0) in Fig. 8A. The 10 pixels other than the 6 in Fig. 13A are similar values to the 14 pixels other than (1,0) and (2,0) in Fig. 8A. Here, it can be seen that the arrangement of the pixels in FIG. 13A is line symmetry in which the third straight line L3, which is the right lowering connecting the upper left and lower right of the original pixel, is a symmetric axis. In other words, the folding in this case is the upper, lower, left and right foldings if the same expressions as in the vertical folding or left and right folding in FIG. 3 are made.

이 도 13의 (a)의 원화소에 대해서 도 3과 마찬가지로 차분 산출 공정 및 차분 화상 생성 공정을 실행할 때에는, 역시 전술한 바와 같이 대칭축이 되는 제 3 직선(L3)의 일단 및 타단의 어드레스를 차분 산출 소프트웨어에 전달한다. 한편 이 제 3 직선(L3)의 경우에는, 예를 들면 도 3의 (a)에 있어서의 제 1 직선(L1)의 경우와 달리, 일단 및 타단의 어드레스가 원화소에 배치되는 화소의 어드레스와 중복된다. 구체적으로는, 도 13의 (a)에 있어서의 제 3 직선(L3)의 일단의 어드레스는 (0,0)이며, 타단의 어드레스는 (3,3)이다. 또한 도 13의 (a)로부터, 제 3 직선(L3)은 상기 일단 및 타단뿐만아니라, 그 이외의 통과 경로에 있어서도 (1,1) 및 (2,2)의 화소와 중복되어 있다. 이와 같이 대칭축이 지나가는 어드레스와 화소의 어드레스가 중복될 경우의 차분 산출 공정 및 차분 화상 생성 공정에 대해, 이하에 설명한다.When the difference calculation process and the difference image generation process are executed on the original pixel of Fig. 13A as in Fig. 3, the addresses of one end and the other end of the third straight line L3, which are also symmetrical axes, are different as described above. Pass to the output software. On the other hand, in the case of the third straight line L3, unlike in the case of the first straight line L1 in FIG. 3 (a), for example, the address of one end and the other end is the address of the pixel arranged in the original pixel. Overlap. Specifically, the address of one end of the third straight line L3 in Fig. 13A is (0,0), and the address of the other end is (3,3). 13 (a), the third straight line L3 overlaps the pixels of (1, 1) and (2, 2) not only in the one end and the other end, but also in other passages. The difference calculation process and the difference image generation process in the case where the address where the axis of symmetry passes and the address of the pixel overlap are described below.

먼저, 도 13의 (a)에 있어서 제 3 직선(L3)을 대칭축으로 했을 때에, 원화상이 제 3 직선에 의해 어떻게 우측 상단과 좌측 하단에 있어서 동일한 수의 화소로 분할되는지에 대해서 생각한다. 전술한 바와 같이 (0,0), (1,1), (2,2), (3,3)의 화소는 제 3 직선(L3) 상에 있다. 이 때문에, 이들 4개의 화소는 대칭축으로서의 제 3 직선에 의해 우측 상단과 좌측 하단으로 분할할 수 없다. 따라서, 이들 4개의 화소는 차분 산출 공정에 있어서 대상으로 하지 않는 것으로 한다. 구체적인 알고리즘에 있어서는, 이들 4개의 화소의 차분 화소값을 0으로 한다. 이 차분 화소값 0의 의미는, 화소를 차분 산출의 대상으로부터 제외하거나, 그 화소 자신과의 차분을 산출하는 것 중의 어느 하나의 결과인 것으로 생각하면 된다.First, when the third straight line L3 in Fig. 13A is a symmetric axis, it is considered how the original image is divided into the same number of pixels in the upper right and lower left by the third straight line. As described above, the pixels of (0,0), (1,1), (2,2), and (3,3) are on the third straight line L3. For this reason, these four pixels cannot be divided into the upper right and lower left by the third straight line as the axis of symmetry. Therefore, it is assumed that these four pixels are not targeted in the difference calculation process. In a specific algorithm, the difference pixel values of these four pixels are set to zero. The meaning of the difference pixel value 0 may be considered as a result of either excluding a pixel from the object of difference calculation or calculating a difference with the pixel itself.

도 13의 (a)에 있어서, 이들 제 3 직선(L3)과 중복되는 4개의 화소 이외의 12개의 화소에 대해서는, 제 3 직선의 우측 상단과 좌측 하단에 대칭 배치되어 있는 화소에 대해서 화소값의 차분을 산출한다. 예를 들면 (2,0)의 화소값은 (0,2)의 화소값과 차분을 산출하고, (2,1)의 화소값은 (1,2)의 화소값과 차분을 산출하면 된다. 이와 같이 해서 생성한 차분 화상을 도 13의 (b)에 나타낸다. 도 13의 (b)에 있어서, 전술한 바와 같이 (0,0), (1,1), (2,2), (3,3)의 화소값은 모두 0이며, 그 밖의 12개의 화소값은 제 3 직선(L3)에 관해서 대칭 배치로 되어 있기 때문에, 화소값은 극히 0에 가까운 값으로 되어 있다.In Fig. 13A, for 12 pixels other than the 4 pixels overlapping with the third straight line L3, the pixel values of the pixels arranged symmetrically at the upper right and lower left of the third straight line Calculate the difference. For example, a pixel value of (2,0) may calculate a difference from a pixel value of (0,2), and a pixel value of (2,1) may calculate a difference from a pixel value of (1,2). The difference image thus generated is shown in Fig. 13B. In Fig. 13B, the pixel values of (0,0), (1,1), (2,2), and (3,3) are all 0, as described above, and 12 other pixel values Since the is arranged symmetrically with respect to the third straight line L3, the pixel value is extremely close to zero.

(5) 본 발명의 결함 검사 방법(5) Defect inspection method of the present invention

지금까지 설명한 본 발명의 화상 처리 알고리즘을 이용한 워크의 결함 검사 방법에 대해서, 도 14 내지 도 31을 사용하여 이하에 설명한다.The defect inspection method of the work using the image processing algorithm of the present invention described so far will be described below with reference to Figs.

도 14는 본 발명의 화상 처리 알고리즘을 이용한 워크의 결함 검사 방법의 개략 플로우차트이다. 이 개략 플로우차트는 2개의 모드에 의해 구성된다. 도 14의 (a)는 임계값 설정 모드이며, 복수의 불량 워크의 원화상으로부터 본 발명의 화상 처리 알고리즘을 이용하여 차분 화상을 생성하고, 생성한 차분 화상을 이용하여 워크의 검사 대상 영역을 선출하기 위한 임계값을 설정하는 공정이다. 또한 도 14의 (b)는 검사 실행 모드이며, 검사 대상이 되는 워크의 원화상으로부터 임계값 설정 모드에서 설정한 임계값을 이용하여 검사 대상 영역을 선출한 뒤, 당해 영역에 대해서 결함 검사를 실행하는 공정이다. 임계값 설정 모드와 검사 실행 모드는, 도 14의 (a)의 최하부 및 도 14의 (b)의 최상부에 나타내는 번호 101의 결합자에 의해 접속되어 있다.14 is a schematic flowchart of a defect inspection method of a work using the image processing algorithm of the present invention. This schematic flowchart is composed of two modes. 14A is a threshold setting mode, and a differential image is generated using the image processing algorithm of the present invention from an original image of a plurality of defective workpieces, and an inspection target area of the work is selected using the generated differential image. This is the process of setting a threshold for doing so. 14B is an inspection execution mode, and an inspection target area is selected from the original image of the work to be inspected using the threshold set in the threshold setting mode, and then defect inspection is performed on the area. Process. The threshold setting mode and the test execution mode are connected by a combiner of the number 101 shown at the bottom of FIG. 14 (a) and the top of FIG. 14 (b).

도 15 내지 도 31은 본 발명의 화상 처리 알고리즘을 이용한 워크의 결함 검사 방법의 상세 플로우차트이다. 구체적으로는, 도 14에 나타나 있는 스텝 번호 S1 내지 S14의 정의 완료 처리의 상세한 스텝을 적은 것이다. 도 15 내지 도 31은 모두 도 14에 기재되는 정의 완료 처리의 공정명 및 스텝 번호를 최상부에 적고, 그 아래에 당해 정의 완료 처리의 입구를 나타내는 IN이라고 적힌 단자를 배치하고 있다. 다음으로 이 단자에 이어서 당해 정의 완료 처리의 상세한 스텝을 나타내고 있다. 그리고 전체 스텝을 종료하면, 당해 정의 완료 처리로부터 나와서 도 14에 나타내는 다음 정의 완료 처리로 진행되기 위한 출구를 나타내는, OUT이라고 적힌 단자를 최하부에 배치하고 있다.15 to 31 are detailed flowcharts of a defect inspection method of a work using the image processing algorithm of the present invention. Specifically, the detailed steps of the definition completion process of step numbers S1 to S14 shown in FIG. 14 are written. In Figs. 15 to 31, the process name and step number of the definition completion process described in Fig. 14 are written at the top, and a terminal labeled IN indicating the entrance of the definition completion process is disposed below it. Next, following this terminal, detailed steps of the definition completion process are shown. And when all the steps are completed, the terminal labeled OUT, which indicates an exit for exiting from the definition completion process and proceeding to the next definition completion process shown in Fig. 14, is placed at the bottom.

또, 도 15 내지 도 31에 있어서의 스텝 번호는, 도 14와의 대응을 나타내기 위해서 도 14에 있어서의 스텝 번호를 위 1자리 혹은 위 2자리에 할당하고, 거기에 이어지는 아래 2자리에 당해 상세 플로우차트 내의 스텝 번호를 01로부터 오름차순으로 할당하고 있다.In addition, the step numbers in FIGS. 15 to 31 are assigned the step numbers in FIG. 14 to the upper 1 digit or the upper 2 digits in order to indicate the correspondence with FIG. 14, and the details are assigned to the lower 2 digits that follow. Step numbers in the flowchart are assigned in ascending order from 01.

또한 후술하는 바와 같이, 본 발명의 화상 처리 알고리즘을 이용한 워크의 결함 검사 방법에 있어서는, 도 14에 나타내는 몇 개의 정의 완료 처리에 있어서 실행되는 공통의 처리를 서브루틴화하고 있다. 서브루틴은 Sub1 및 Sub2로 이루어지며, 도 20에 Sub1의 상세 플로우차트를 나타냄과 함께, 도 23에 Sub2의 상세 플로우차트를 나타낸다. 이들 상세 플로우차트에 있어서의 스텝 번호는, 도 20의 Sub1에 대해서는 위 2자리를 21로 하고, 도 23의 Sub2에 대해서는 위 2자리를 22로 하고 있다. 스텝 번호 아래 2자리에 대해서는, 도 20과 도 23에서 부여 방법이 서로 다르다. 도 20의 Sub1에 있어서는, 아래로부터 2자리째를 당해 스텝과 도 14의 (a)에 나타내는 스텝 S5 및 S6의 대응을 나타내는 숫자로서의 5 혹은 6으로 하고 있다. 그리고 가장 아래의 자릿수를 상기 스텝 S5 혹은 S6의 내부에 있어서의 스텝 번호로서, 1에서부터 오름차순으로 숫자를 할당하고 있다. 이에 대하여 도 23의 Sub2에 있어서는, Sub2가 도 14의 (a)에 나타내는 스텝 S7에만 대응하므로, 아래로부터 2자리째를 숫자 0으로 고정하고 있다. 그리고, 가장 아래의 자릿수를 스텝 S7의 내부에 있어서의 스텝 번호로서, 1에서부터 오름차순으로 숫자를 할당하고 있다.In addition, as will be described later, in the defect inspection method of a work using the image processing algorithm of the present invention, common processing executed in some defined completion processing shown in Fig. 14 is subrouted. The subroutine consists of Sub1 and Sub2, and FIG. 20 shows the detailed flowchart of Sub1, and FIG. 23 shows the detailed flowchart of Sub2. The step number in these detailed flowcharts is set to 21 in the upper 2 digits for Sub1 in FIG. 20 and 22 in the Sub2 in FIG. 23. For the two digits below the step number, the granting methods are different in Figs. In Sub1 in Fig. 20, the second digit from the bottom is set to 5 or 6 as a number indicating the correspondence between the step and S6 and S6 shown in Fig. 14 (a). Then, the lowest digit is assigned as a step number within the step S5 or S6, and numbers are assigned in ascending order from 1. On the other hand, in Sub2 in Fig. 23, since Sub2 corresponds only to Step S7 shown in Fig. 14A, the second digit from the bottom is fixed to the number 0. Then, the lowest digit is assigned as a step number in step S7 in the order from 1 to ascending order.

또, 이후의 도 15 내지 도 31에 나타내는 스텝 및 대응하는 설명에 있어서, 레지스터에 화상을 저장한다는 표기가 여러 번 사용된다. 이 화상을 저장한다고 하는 표기는, 도 2에 의해 정의되는 화소의 X 어드레스와 Y 어드레스 및 당해 화소의 화소값을 대응시켜서 하나의 배열(예를 들면 3차원 배열)로 정리하고, 화상을 구성하는 화소수에 일치하는 배열수로 이루어지는 배열군을 구성해서 레지스터에 저장한다는 것을 의미하고 있다.In addition, in the steps shown in FIGS. 15 to 31 and corresponding descriptions, the notation that an image is stored in a register is used several times. The notation of storing this image is organized into one array (for example, a three-dimensional array) by associating the X address and Y address of the pixel defined by FIG. 2 with the pixel values of the pixel, and constituting the image. This means that an array group consisting of an array number corresponding to the number of pixels is formed and stored in a register.

먼저 도 14의 (a) 및 도 15 내지 도 26을 사용하여, 임계값 설정 모드에 대해 설명한다.First, the threshold setting mode will be described with reference to FIGS. 14A and 15 to 26.

(5.1) 스텝 S1(5.1) Step S1

도 14의 (a)에 있어서 단자 START에 이어지는 스텝 S1은 기지(旣知) 워크 촬상 공정이다. 이것은 양품인 것, 혹은 불량인 것이 기지로 되어 있는 워크를 각각 복수 준비하고, 그것들을 촬상하는 공정이다. 기지 워크 촬상 공정(S1)의 상세 플로우차트를 도 15에 나타낸다.In Fig. 14A, step S1 following the terminal START is a known work imaging process. This is a process of preparing a plurality of workpieces each of which is known as a good product or a defective product, and imaging them. Fig. 15 shows a detailed flowchart of the known work imaging step (S1).

도 15의 스텝 S101에 있어서 A개의 양품 워크를 촬상해서 양품 화상을 얻는다. 이 A개의 워크는 양품인 것을 기지로 하고 있다. 다음으로 스텝 S102로 진행되고, 스텝 S101에 있어서 촬상한 양품 화상에 1에서 A까지의 번호를 부여한다. 이어서 스텝 S103에 있어서 B개의 불량 워크를 촬상해서 불량 화상을 얻는다. 이 B개의 워크는 불량인 것을 기지로 하고 있다. 다음으로 스텝 S104로 진행되고, 스텝 S103에 있어서 촬상한 불량 화상에 1에서 B까지의 번호를 부여한다. 이상의 스텝 S101 내지 S104에 의해, 각각 고유의 번호를 부여한 A개의 양품 화상 및 B개의 불량 화상이 얻어지게 된다.In step S101 of Fig. 15, A good-quality work product is imaged to obtain a good-quality image. It is assumed that these A pieces are good products. Next, it progresses to step S102, and the numbers from 1 to A are assigned to the quality goods image picked up in step S101. Subsequently, in step S103, B defective works are imaged to obtain a defective image. It is assumed that these B works are defective. Next, the flow proceeds to step S104, and the numbers 1 to B are assigned to the defective image captured in step S103. By the above steps S101 to S104, A good image and B bad images, each of which are assigned a unique number, are obtained.

스텝 S105 이후는, B개의 불량 화상에 대해서 도 14의 (a)의 스텝 S1에 이어지는 스텝 S2 내지 스텝 S7을 실행하기 위한 준비이다. 먼저 스텝 S105에 있어서, 상기 스텝 S2 내지 스텝 S7에서 처리를 실행중인 불량 화상의 번호를 기억하는 레지스터 J에 0을 저장하고, 레지스터 J를 초기화한다. 이어서 스텝 S106에 있어서, J의 값에 1을 가산한다. 그리고 스텝 S107에 있어서, 1에서 B까지의 번호를 부여한 불량 화상 중에서 J의 값으로 지정되는 번호의 화상을 취출한다. 여기서는 J=1이며, 취출한 화상은 불량 화상(1)이 된다. 그리고 스텝 S1을 종료해서 도 14의 (a)에 나타내는 스텝 S2로 진행된다.After step S105, preparations are made for the execution of steps S2 to S7 following step S1 in Fig. 14A for B defective images. First, in step S105, 0 is stored in the register J that stores the number of the defective images being processed in steps S2 to S7, and the register J is initialized. Next, in step S106, 1 is added to the value of J. Then, in step S107, an image of the number designated by the value of J is taken out of the defective images in which numbers from 1 to B are assigned. Here, J = 1, and the taken out image becomes the defective image 1. Then, step S1 is finished and the process proceeds to step S2 shown in Fig. 14A.

(5.2) 스텝 S2(5.2) Step S2

도 14의 (a)에 있어서 스텝 S2는 검사 대상 워크 추출 공정이다. 이것은 전술한 템플릿 매칭법을 이용하여, 촬상 화상으로부터 워크를 추출하는 공정이다. 검사 대상 워크 추출 공정(S2)의 상세 플로우차트를 도 16에 나타낸다.In Fig. 14A, step S2 is a work extraction process to be inspected. This is a step of extracting the work from the captured image using the template matching method described above. 16 shows a detailed flowchart of the work extraction process (S2) to be inspected.

도 16의 스텝 S201에 있어서 템플릿 매칭법을 이용하여, 워크의 최외측 가장자리를 탐색해서 확정한다. 다음으로, 스텝 S202에 있어서 워크의 최외측 가장자리 내를 검사 대상 워크의 화상으로 한다. 그리고 스텝 S2를 종료하고 도 14의 (a)에 나타내는 스텝 S3으로 진행된다.In step S201 of FIG. 16, using the template matching method, the outermost edge of the work is searched for and determined. Next, in step S202, the inside of the outermost edge of the work is taken as an image of the work to be inspected. Then, step S2 ends and the process proceeds to step S3 shown in Fig. 14A.

(5.3) 스텝 S3(5.3) Step S3

도 14의 (a)에 있어서 스텝 S3은 단색 화상 생성 공정이며, 스텝 S2에서 추출한 검사 대상 워크에 대해서 단색 화상을 생성하는 공정이다. 단색 화상 생성 공정(S3)의 상세 플로우차트를 도 17에 나타낸다.In (a) of FIG. 14, step S3 is a single color image generation process, and is a process of generating a single color image for the object to be examined extracted in step S2. 17 shows a detailed flowchart of the monochrome image generation process (S3).

도 17의 스텝 S301에 있어서, 검사 대상 워크의 화상이 컬러인지의 여부에 대해 판단한다. 판단 결과가 Yes인 경우 즉 컬러 화상인 경우에는 스텝 S302로 진행된다. 스텝 S302에 있어서, 컬러 화상인 검사 대상 워크의 화상으로부터 K개의 단색 화상을 생성한다. 여기에 K는 자연수이다. 예를 들면 전술한 바와 같이 컬러 화상을 R(빨강), G(초록), B(파랑)의 삼원색으로 분해해서 3개의 단색 화상을 생성하면, K=3이 된다. 또한 전술한 바와 같이 NTSC 신호를 얻기 전단계에서 사용되는 컴포넌트 신호인 YIQ 신호의 Y 성분을 생성하면, K=1이 된다. 스텝 S302에서 컬러 화상으로부터 K개의 단색 화상을 생성한 뒤, 다음 스텝 S303으로 진행된다.In step S301 of Fig. 17, it is determined whether or not the image of the work to be inspected is a color. If the determination result is Yes, that is, in the case of a color image, the process proceeds to step S302. In step S302, K monochromatic images are generated from images of the inspection target work, which are color images. Here, K is a natural number. For example, as described above, if three color images are generated by decomposing a color image into three primary colors of R (red), G (green), and B (blue), K = 3. In addition, when the Y component of the YIQ signal, which is the component signal used in the step before obtaining the NTSC signal, is generated as described above, K = 1. After generating K monochromatic images from the color images in step S302, the process proceeds to the next step S303.

스텝 S303에 있어서, 스텝 S302에서 생성한 K개의 단색 화상에, 미리 정한 기준에 의거하여 1로부터 K까지의 번호를 부여한다. 여기에, 미리 정하는 기준의 일례로서, 컬러 화상을 R(빨강), G(초록), B(파랑)의 삼원색으로 분해해서 3개의 단색 화상을 생성했을 경우에 대해 설명한다. 이 경우에는 R(빨강)에 의거하여 생성한 단색 화상에 1을 부여하고, G(초록)에 의거하여 생성한 단색 화상에 2를 부여하고, B(파랑)에 의거하여 생성한 단색 화상에 3을 부여하는 기준이 고려된다. 스텝 S303에 있어서 단색 화상에 번호를 부여한 뒤, 스텝 S304로 진행된다.In step S303, numbers from 1 to K are assigned to the K monochromatic images generated in step S302 according to a predetermined criterion. Here, as an example of a predetermined criterion, a case where three monochromatic images are generated by decomposing a color image into three primary colors of R (red), G (green), and B (blue) will be described. In this case, 1 is given to the monochrome image generated based on R (red), 2 is given to the monochrome image generated based on G (green), and 3 to the monochrome image generated based on B (blue). The criterion for granting is considered. After assigning a number to the monochrome image in step S303, the process proceeds to step S304.

스텝 S304 이후는, 불량 화상(1)에 대해서 도 14의 (a)의 스텝 S3에 이어지는 스텝 S4 내지 스텝 S7을 실행하기 위한 준비이다. 먼저 스텝 S304에 있어서, 상기 스텝 S4 내지 스텝 S7에서 처리를 실행중인 단색 화상의 번호를 기억하는 레지스터 N에 0을 저장하고, 레지스터 N을 초기화한다. 이어서 스텝 S305에 있어서, N의 값에 1을 가산한다. 그리고 스텝 S306에 있어서, 1에서 K까지의 번호를 부여한 단색 화상 중에서 N의 값으로 지정되는 번호의 단색 화상(이 경우에는 제 1 단색 화상)을, 원화상이라는 명칭의 레지스터에 저장한다. 그리고 스텝 S3을 종료하고 도 14의 (a)에 나타내는 스텝 S4로 진행된다.After step S304, preparations for executing steps S4 to S7 following step S3 in Fig. 14A are performed for the defective image 1. First, in step S304, 0 is stored in register N that stores the number of the monochrome image being processed in steps S4 to S7, and the register N is initialized. Next, in step S305, 1 is added to the value of N. In step S306, a monochromatic image numbered from 1 to K (a first monochromatic image in this case) of a number designated by the value of N is stored in a register named original image. Then, step S3 ends and the process proceeds to step S4 shown in Fig. 14A.

여기까지의 스텝 S302 내지 스텝 S306은, 상기 스텝 S301에 있어서 검사 대상 워크의 화상이 컬러 화상으로 판단되었을 경우에 실행된다. 만일 검사 대상 워크의 화상이 컬러 화상이 아니어서, 스텝 S301에 있어서의 판단이 No인 경우에는, 스텝 S301에 이어서 스텝 S307로 진행된다. 여기에, 검사 대상 워크의 화상이 컬러 화상이 아니다란 단색 화상이며, 검사 대상 워크로부터 생성되는 단색 화상은 검사 대상 워크의 화상 그 자체이다. 이것은, 단색 화상의 수 K=1인 것과 다름없다. 그래서 스텝 S307에 있어서는, 검사 대상 워크의 화상을 제 1 단색 화상으로 한다. 그리고 스텝308에 있어서 단색 화상의 수를 나타내는 레지스터 K에 1을 저장하고, 스텝 S309로 진행된다. 스텝 S309에 진행되면, 도 14의 (a)에 있어서 스텝 S3에 이어지는 스텝 S4 내지 스텝 S7에서 처리하는 단색 화상의 번호를 기억하는 레지스터 N에 1을 저장한다. 그리고, 스텝 S306으로 진행되어, 제 N 단색 화상 즉 제 1 단색 화상을, 원화상이라는 명칭의 레지스터에 저장한다. 그리고 스텝 S3을 종료하고 도 14의 (a)에 나타내는 스텝 S4로 진행된다.Steps S302 to S306 up to this point are executed when the image of the work to be inspected is judged to be a color image in step S301. If the image of the work to be inspected is not a color image, and the determination in Step S301 is No, then the procedure proceeds to Step S307 following Step S301. Here, it is a monochrome image that the image of the work to be inspected is not a color image, and the monochrome image generated from the work to be inspected is the image itself of the work to be inspected. This is equivalent to the number K = 1 of monochromatic images. Therefore, in step S307, the image of the work to be inspected is the first monochromatic image. Then, in step 308, 1 is stored in the register K indicating the number of monochrome images, and the process proceeds to step S309. If it progresses to step S309, 1 is stored in the register N which stores the number of the monochrome images processed by steps S4 to S7 following step S3 in FIG. 14A. Then, the process proceeds to step S306, where the Nth monochrome image, that is, the first monochrome image, is stored in a register named original image. Then, step S3 ends and the process proceeds to step S4 shown in Fig. 14A.

(5.4) 스텝 S4(5.4) Step S4

도 14의 (a)에 있어서 스텝 S4는 대칭성 판단 공정이며, 스텝 S3에서 생성한 단색 화상의 대칭성을 판단한다. 대칭성 판단 공정(S4)의 상세 플로우차트를 도 18에 나타낸다.In Fig. 14A, step S4 is a symmetry determination process, and the symmetry of the monochrome image generated in step S3 is judged. 18 shows a detailed flowchart of the symmetry determination step (S4).

도 18의 스텝 S401에 있어서, 도 17에 나타내는 단색 화상 생성 공정(S3)의 스텝 S306에 있어서 원화상이라는 명칭의 레지스터에 저장된 제 N 단색 화상을 취출하여, 대칭축을 가지는지 판단한다. 만일 대칭축을 갖고 있지 않을 경우에는, 판단은 No가 되어서 단자 END로 진행되고, 결함 검사를 종료한다. 원화상이 대칭축을 갖고 있지 않을 경우에 결함 검사를 종료하는 이유를, 이하에 설명한다. 도 14에 개략 플로우차트를 나타내는 결함 검사 방법은, 도 1 내지 도 6에 나타내는 본 발명의 화상 처리 알고리즘을 이용하고 있다. 그리고 본 발명의 화상 처리 알고리즘은 전술한 바와 같이, 1개 이상의 대칭축에 관해서 선대칭이 되는 영역을 갖는 원화상을 대상으로 하는 것이다. 이 때문에, 대칭축을 갖고 있지 않는 원화상에 대하여는, 본 발명의 화상 처리 알고리즘을 이용할 수 없으며, 그 때문에 결함 검사는 이 시점에서 종료하게 된다.In step S401 of Fig. 18, in step S306 of the monochromatic image generation step (S3) shown in Fig. 17, the Nth monochromatic image stored in the register named original image is taken out, and it is determined whether it has a symmetric axis. If it does not have a symmetry axis, the judgment is No and proceeds to the terminal END, and the defect inspection is finished. The reason why the defect inspection is finished when the original image does not have a symmetric axis will be described below. The defect inspection method showing the schematic flowchart in Fig. 14 uses the image processing algorithm of the present invention shown in Figs. In addition, as described above, the image processing algorithm of the present invention is directed to an original image having a region that is linearly symmetric with respect to one or more symmetric axes. For this reason, the image processing algorithm of the present invention cannot be used for an original image that does not have a symmetric axis, and therefore the defect inspection is terminated at this point.

한편, 스텝 S401에 있어서 제 N 단색 화상이 대칭축을 갖고 있을 경우에는, 판단은 Yes가 되어서 스텝 S402로 진행된다. 스텝 S402에 있어서는, 원화상이 가진 대칭축의 수를 레지스터 C에 저장한다.On the other hand, in step S401, when the Nth monochromatic image has a symmetry axis, the determination is Yes, and the procedure goes to step S402. In step S402, the number of symmetric axes of the original image is stored in the register C.

스텝 S403 이후는, 불량 화상(1)에 대해서 도 14의 (a)의 스텝 S4에 이어지는 스텝 S5 내지 스텝 S7을 실행하기 위한 준비이다. 먼저 스텝 S403에 있어서, 상기 스텝 S5 내지 스텝 S7에서 처리를 실행중인 단색 화상에 있어서의 대칭축의 번호를 기억하는 레지스터 M에 0을 저장하고, 레지스터 M을 초기화한다. 이어서 스텝 S404에 있어서, M의 값에 1을 가산한다. 다음으로 스텝 S405에 있어서, ONEM이라는 명칭의 레지스터에 제 M 대칭축의 일단의 좌표를 저장한다. 그리고 스텝 S406에 있어서, OTEM이라는 명칭의 레지스터에 제 M 대칭축의 타단의 좌표를 저장한다. 이 ONEM 및 OTEM은 도 3의 (a), 도 5의 (a) 및 도 13의 (a)를 사용하여 설명한 본 발명의 화상 처리 알고리즘에 있어서의 대칭축의 일단 및 타단의 좌표를 나타내는 인수로서, 후술하는 스텝 S5에 있어서 서브루틴 Sub1에 전달된다. 여기까지에 의해서 스텝 S4를 종료하고 도 14의 (a)에 나타내는 스텝 S5로 진행된다.After step S403, preparation for executing steps S5 to S7 following step S4 in Fig. 14A is performed on the defective image 1. First, in step S403, 0 is stored in register M that stores the number of symmetry axes in the monochrome image that is being processed in steps S5 to S7, and register M is initialized. Next, in step S404, 1 is added to the value of M. Next, in step S405, a set of coordinates of the Mth axis of symmetry is stored in a register named ONEM. Then, in step S406, the coordinates of the other end of the M-th axis of symmetry are stored in a register named OTEM. These ONEM and OTEM are factors representing the coordinates of one end and the other end of the symmetry axis in the image processing algorithm of the present invention described using Figs. 3A, 5A, and 13A. In step S5 which will be described later, it is delivered to the subroutine Sub1. Thus, step S4 is ended and the process proceeds to step S5 shown in Fig. 14A.

(5.5) 스텝 S5 및 S6(5.5) Step S5 and S6

도 14의 (a)에 있어서 스텝 S5는 차분 산출 공정이다. 그리고 그것에 이어지는 스텝 S6은 차분 화상 생성 공정이다. 이들 공정에는, 도 3 내지 도 6에 나타내는 본 발명의 화상 처리 알고리즘을 이용할 수 있다. 이 화상 처리 알고리즘은 후속의 공정에 있어서도 여러 번 이용되므로, 상세 플로우차트에 있어서는 이들 2개의 공정을 하나로 정리한 서브루틴 Sub1에 의해 정의되어 있다.In Fig. 14A, step S5 is a difference calculation process. And step S6 following it is a differential image generation process. For these processes, the image processing algorithm of the present invention shown in Figs. 3 to 6 can be used. Since this image processing algorithm is used multiple times in subsequent processes, it is defined by the subroutine Sub1 that summarizes these two processes into one in a detailed flowchart.

도 19에 차분 산출 공정(S5) 및 차분 화상 생성 공정(S6)을 나타낸다. 전술한 바와 같이, 이들 2개의 공정은 스텝 S21로서 정의되는 서브루틴 Sub1에 의해 구성된다. 스텝 S21에 나타내는 바와 같이, 서브루틴 Sub1의 인수는 원화상, 제 M 대상축의 일단의 좌표(ONEM), 제 M 대칭축의 타단의 좌표(OTEM)이다.19 shows the difference calculation process (S5) and the difference image generation process (S6). As described above, these two processes are constituted by the subroutine Sub1 defined as step S21. As shown in step S21, the factors of the subroutine Sub1 are the original image, the coordinates of one end of the M target axis (ONEM), and the coordinates of the other end of the M symmetric axis (OTEM).

1번째로 나타내는 인수로서의 원화상은, 메인 프로그램에 있어서의 도 14의 (a)의 스텝 S3에서, 상세하게는 도 17에 나타내는 스텝 S306에서 설정된 원화상 즉 제 N 단색 화상이다. 이 스텝 S306에서 설정된 원화상 즉 제 N 단색 화상에 대하여, 전술한 바와 같이 도 14의 (a)의 스텝 S4에서, 상세하게는 도 18에 나타내는 스텝 S401에 있어서 대칭성을 판단한다. 판단이 Yes인 경우에는 전술한 바와 같이 스텝 S402 내지 스텝 S406을 실행한다. 2번째로 나타내는 인수로서의 ONEM은 전술한 바와 같이, 스텝 S405에 있어서 제 M 대칭축의 일단의 좌표를 저장한 레지스터의 것이다. 마찬가지로 3번째로 나타내는 인수로서의 OTEM은 전술한 바와 같이, 스텝 S406에 있어서 제 M 대칭축의 타단의 좌표를 저장한 레지스터의 것이다.The original image as the first argument is the original image set in step S3 of FIG. 14A in the main program, specifically, the step N in FIG. 17, that is, the Nth monochrome image. For the original image set in step S306, that is, the N-th monochrome image, as described above, in step S4 of Fig. 14A, in detail, symmetry is determined in step S401 shown in Fig. 18. If the determination is Yes, steps S402 to S406 are executed as described above. As described above, ONEM as the second argument is a register that stores a set of coordinates of the Mth axis of symmetry in step S405. Likewise, as described above, the OTEM as the third argument is a register that stores the coordinates of the other end of the M-th axis of symmetry in step S406.

이들 3개의 인수로서의 원화상, ONEM, OTEM을 메인 프로그램으로부터 전달받은 서브루틴 Sub1은, 전술한 바와 같이 도 14의 (a)에 있어서의 스텝 S5(차분 산출 공정)와 그것에 이어지는 스텝 S6(차분 화상 생성 공정)을 실행한다.The subroutine Sub1 that received the original image, ONEM, and OTEM as the three arguments from the main program is as described above in step S5 (difference calculation process) in Fig. 14A and the step S6 (differential image) following it. Creation process).

서브루틴 Sub1의 상세 플로우차트를 도 20에 나타낸다. 도 20에 있어서 단자 Sub1(원화상, ONEM, OTEM)에 이어지는 스텝 S2151 내지 스텝 S2153은 도 14의 (a)에 있어서의 스텝 S5(차분 산출 공정)이다.Fig. 20 shows a detailed flowchart of the subroutine Sub1. In Fig. 20, steps S2151 to S2153 following the terminal Sub1 (original image, ONEM, OTEM) are steps S5 (difference calculation process) in Fig. 14A.

먼저 스텝 S2151에 있어서, ONEM과 OTEM을 직선에 의해 접속해서 대칭축을 생성한다. 이 공정에 의해 대칭축을 생성하는 것은, 이미 도 3의 (a), 도 5의 (a) 및 도 13의 (a)를 사용한 본 발명의 화상 처리 알고리즘의 설명에 있어서, 제 1 직선(L1), 제 2 직선(L2), 제 3 직선(L3)의 일단 및 타단의 좌표를 직선으로 접속하는 공정으로서 설명하고 있다. 도 20의 스텝 S2151에서 대칭축을 생성한 뒤, 스텝 S2152로 진행된다.First, in step S2151, ONEM and OTEM are connected by a straight line to generate a symmetric axis. Generating the axis of symmetry by this step is the first straight line L1 in the description of the image processing algorithm of the present invention, which has already been used in Figs. 3A, 5A and 13A. , It is described as a process of connecting the coordinates of one end and the other end of the second straight line L2 and the third straight line L3 in a straight line. After generating the axis of symmetry in step S2151 of FIG. 20, the process proceeds to step S2152.

스텝 S2152에서 원화상을 대칭축의 양측에 있어서 동일한 화소수로 2분할한다. 이 공정은, 예를 들면 도 5의 (a)에 나타내는 16개의 원화소를, 대칭축으로서의 제 1 직선(L1)의 상측에 위치하는 8개의 원화소와, 하측에 위치하는 8개의 원화소로 분할하는 것에 대응한다. 도 20의 스텝 S2152에 있어서 원화소를 2분할한 뒤, 스텝 S2153으로 진행된다.In step S2152, the original image is divided into two with the same number of pixels on both sides of the axis of symmetry. In this step, for example, the 16 original pixels shown in Fig. 5 (a) are divided into 8 original pixels located on the upper side of the first straight line L1 as the axis of symmetry, and 8 original pixels located on the lower side. Corresponds to doing. After dividing the original pixel into two at step S2152 of FIG. 20, it progresses to step S2153.

스텝 S2153에서 대칭축의 양측에 있어서 선대칭의 위치에 배치되는 원화소 PA와 PB에 대해서, 각각의 화소값 BA와 BB의 차분이 되는 차분 화소값 BAB를 산출한다. 이 공정은, 예를 들면 도 5의 (a)에 있어서 (0,0)에 위치하는 원화소(화소값 200)를 원화소 PA라고 하고, (0,3)에 위치하는 원화소(화소값 103)를 원화소 PB라고 했을 때에, 각각의 화소값 200 및 103의 차분을 200-103=97과 같이 산출하고, 그 값 97을 차분 화소값 BAB로 하는 것에 대응한다. 도 20의 스텝 S2153에 있어서 차분 화소값을 산출하면, 스텝 S5(차분 산출 공정)를 종료하고, 서브루틴 Sub1 내에서 도 14의 (a)에 있어서의 스텝 S6(차분 화상 생성 공정)으로 진행된다. 차분 화상 생성 공정은, 도 20에 나타내는 바와 같이 스텝 S2161로 이루어진다.In step S2153, the difference pixel values BAB, which are the differences between the pixel values BA and BB, are calculated for the original pixels PA and PB arranged at positions of line symmetry on both sides of the symmetry axis. In this step, for example, in FIG. 5 (a), the original pixel (pixel value 200) located at (0,0) is referred to as the original pixel PA, and the original pixel (pixel value) located at (0,3). When 103) is referred to as the original pixel PB, the difference between each pixel value 200 and 103 is calculated as 200-103 = 97, and this value corresponds to the difference pixel value BAB. If the difference pixel value is calculated in step S2153 of Fig. 20, step S5 (difference calculation process) ends, and the process proceeds to step S6 (difference image generation process) in Fig. 14A in subroutine Sub1. . The difference image generation process is composed of step S2161 as shown in FIG. 20.

스텝 S2161에 있어서, 차분 화소값 BAB를 갖는 차분 화소 PAB를 원화상에 있어서의 원화소 PA 및 PB의 위치에 배치해서 차분 화상을 생성한다. 이 공정은, 예를 들면 도 5의 (a)에 있어서 상기 (0,0)에 위치하는 원화소 PA와, 상기 (0,3)에 위치하는 원화소 PB에 의해 97이라는 차분 화소값 BAB가 생성되면, 도 5의 (b)의 (0,0) 및 (0,3)의 위치에 97이라는 화소값을 갖는 차분 화소를 배치하는 것에 대응한다. 도 20에 있어서 스텝 S2161을 종료하면, 스텝 S6(차분 화상 생성 공정)을 종료한다. 그리고 동시에, 도 19에 있어서의 스텝 S21로서의 서브루틴 Sub1을 종료하고 메인 프로그램으로 되돌아간다. 그 때에 도 20의 스텝 S2161에 있어서 생성한 차분 화상을 되돌림 값으로서 메인 프로그램에 전달한다. 도 20에 있어서, 이것을 스텝 S2161에 이어지는 단자 내에, Return(차분 화상)으로서 나타낸다. 메인 프로그램에의 되돌림처는, 도 14의 (a)에 있어서 스텝 S7로서 기재되는 임계값 범위 설정 공정의 입력이다.In step S2161, the difference pixel PAB having the difference pixel value BAB is arranged at the positions of the original pixels PA and PB in the original image to generate a difference image. In this step, for example, in FIG. 5 (a), the difference pixel value BAB of 97 is obtained by the original pixel PA positioned at (0,0) and the original pixel PB positioned at (0,3). When generated, it corresponds to disposing a difference pixel having a pixel value of 97 at the positions (0, 0) and (0, 3) in Fig. 5B. 20, when step S2161 ends, step S6 (differential image generation process) ends. Then, at the same time, the subroutine Sub1 as step S21 in Fig. 19 ends and returns to the main program. At that time, the difference image generated in step S2161 in Fig. 20 is transferred to the main program as a return value. In Fig. 20, this is indicated as Return (differential image) in the terminal following Step S2161. The return destination to the main program is the input of the threshold range setting process described as step S7 in Fig. 14A.

(5.6) 스텝 S7(5.6) Step S7

도 14의 (a)에 있어서 스텝 S7은 임계값 범위 설정 공정이다. 이것은 스텝 S6에서 생성한 차분 화상에 대해서, 전술한 본 발명의 화상 처리 알고리즘의 설명에 사용한 도 3의 (d)(e)나 도 5의 (d)(e)와 같은, 차분 화상에 있어서의 차분 화소값을 내림차순으로 나열해서 인접 차분 화소끼리의 차분값을 산출하고, 차분값이 최대가 되는 구간을 선출하는 공정이다.In Fig. 14A, step S7 is a threshold value range setting process. This is the difference image generated in step S6 in the difference image, such as (d) (e) of FIG. 3 or (d) (e) of FIG. 5 used in the description of the image processing algorithm of the present invention described above. It is a process of arranging the difference pixel values in descending order to calculate difference values between adjacent difference pixels, and selecting a section in which the difference value becomes the maximum.

임계값 범위 설정 공정(S7)의 상세 플로우차트를 도 21 내지 도 23에 나타낸다. 도 21에 있어서의 최초의 스텝 S701에 있어서, 도 20에 나타내는 서브루틴 Sub1에서 생성한 차분 화상을 차분 화상(NJ)이라는 명칭의 레지스터에 저장한다. 여기에, 차분 화상(NJ)이라는 레지스터 명칭에 사용되어 있는 2개의 번호로서의 J 및 N에 대해 설명한다.The detailed flowchart of the threshold value range setting process (S7) is shown in FIGS. 21-23. In the first step S701 in FIG. 21, the difference image generated in the subroutine Sub1 shown in FIG. 20 is stored in a register named difference image NJ. Here, J and N as two numbers used in the register name of the difference image NJ will be described.

이 명칭에 있어서의 J는, 도 15에 나타내는 기지 워크 촬상 공정(S1)의 스텝 S107에 있어서 취출한 불량 화상(J)의 J에 대응하는 번호이다. 그리고 전술한 바와 같이, 먼저 도 16에 나타내는 검사 대상 워크 추출 공정(S2)에 있어서, 불량 화상(J)으로부터 템플릿 매칭법을 이용하여 검사 대상 워크의 화상을 추출한 뒤, 다음에 도 17에 나타내는 단색 화상 생성 공정(S3)에 있어서, 검사 대상 워크의 화상으로부터 1개 이상의 단색 화상을 생성하고 있다. 그들 단색 화상에 1에서 K(K는 1 이상)까지의 번호를 부여하고(스텝 S302 및 S307), 스텝 S306에 있어서, 제 N 단색 화상을 원화상이라는 명칭의 레지스터에 저장하고 있다. 여기서, N은 전술한 바와 같이, 도 14의 (a)에 나타내는 스텝 S4 내지 스텝 S7에서 처리를 실행중인 단색 화상의 번호를 기억하는 레지스터 N의 값이다. 그리고 이 N은, 차분 화상(NJ)이라는 레지스터 명칭에 있어서의 N에 일치한다. 상기 스텝 S306에 있어서 제 N 단색 화상을 저장한 원화상은 전술한 바와 같이, 도 18에 나타내는 대칭성 판단 공정(S4)과 도 19에 나타내는 차분 산출 공정(S5) 및 차분 화상 생성 공정(S6)에 의해 순차적으로 처리되어서, 차분 화상이 생성된다. 이들을 정리하면, 차분 화상(NJ)이라는 레지스터에는, 불량 화상(J)을 기초로 생성한 제 N 단색 화상으로부터 생성한 차분 화상이 저장되게 된다.J in this name is a number corresponding to J of the defective image J taken out in step S107 of the known work imaging step S1 shown in FIG. 15. Then, as described above, first, in the work object extraction step (S2) shown in FIG. 16, the image of the work object to be inspected is extracted from the defective image J using the template matching method, and then the solid color shown in FIG. In the image generation step (S3), one or more monochrome images are generated from the image of the work to be inspected. The monochromatic images are numbered from 1 to K (K is 1 or more) (steps S302 and S307), and in step S306, the Nth monochromatic image is stored in a register named original image. Here, as described above, N is a value of the register N that stores the number of monochrome images being processed in steps S4 to S7 shown in Fig. 14A. And this N coincides with N in the register name called differential image NJ. In step S306, the original image in which the Nth monochrome image is stored is, as described above, in the symmetry determination step (S4) shown in FIG. 18, the difference calculating step (S5) shown in FIG. 19, and the difference image generating step (S6). By processing sequentially, a difference image is generated. In summary, in the register called differential image NJ, a differential image generated from the Nth monochrome image generated based on the defective image J is stored.

이상과 같이 스텝 S701에서 차분 화상을 차분 화상(NJ)에 저장한 뒤, 스텝 S22로 진행된다. 스텝 S22는 전술한 바와 같이, 도 14에 나타내는 몇 개의 스텝에 있어서 실행되는 공통의 처리이기 때문에, 서브루틴 Sub2로서 정의되어 있다. 서브루틴 Sub2는 차분 화상을 인수로 하고 있다. 여기에, 도 20에 나타내는 서브루틴 Sub1에 있어서, 스텝 S2161에서 생성한 차분 화상을 메인 프로그램에 되돌림 값으로서 되돌리고 있다. 서브루틴 Sub2는 그 차분 화상을 메인 프로그램으로부터 인수로서 수취한다. 그리고 수취한 차분 화상을 이용하여 전술한 본 발명의 화상 처리 알고리즘의 설명에 사용한 도 5의 (d)(e)와 같은, 차분 화상에 있어서의 차분 화소값을 내림차순으로 나열해서 인접 차분 화소끼리의 차분값을 산출하고, 차분값이 최대가 되는 구간을 선출하는 공정을 실행한다. 서브루틴 Sub2의 상세 플로우차트를 도 23에 나타낸다.As described above, after the difference image is stored in the difference image NJ in step S701, the process proceeds to step S22. Step S22 is defined as subroutine Sub2 because it is a common process executed in several steps shown in Fig. 14 as described above. The subroutine Sub2 takes the difference image as an argument. Here, in the subroutine Sub1 shown in Fig. 20, the difference image generated in step S2161 is returned to the main program as a return value. The subroutine Sub2 receives the difference image as an argument from the main program. Then, by using the received difference image, the difference pixel values in the difference image are arranged in descending order as shown in (d) (e) of FIG. 5 used in the description of the image processing algorithm of the present invention described above. The process of calculating the difference value and selecting the section where the difference value becomes the maximum is executed. The detailed flowchart of the subroutine Sub2 is shown in Fig. 23.

도 23에 있어서의 스텝 S2201은, 도 5의 (d)(e)에 있어서 상단에 표제로서 차분 화소값 내림차순으로 적혀 있는 공정에 대응한다. 즉, 스텝 S2201에 있어서 최초에 차분 화상을 구성하는 X개의 화소에 번호 1 내지 X를 부여한다. 다음으로 각 번호의 화소의 화소값 PV(1) 내지 PV(X)를, 최대값에서 최소값까지 내림차순으로 X개의 배열 AP(1) 내지 AP(X)에 저장한다. 이 AP(1)에서 AP(X)까지의 X개의 배열에 저장한 X개의 화소값 PV(1) 내지 PV(X)를 순서대로 좌측으로부터 우측으로 기록한 것이, 도 5의 (d)(e)에 있어서 상단에 배치된 숫자이다. 여기에 전술한 바와 같이, 도 5의 (d)의 상기 숫자는 도 5의 (a)에 있어서 제 1 직선(L1)을 대칭축으로 해서 생성한 차분 화상인 도 5의 (b)에 대응하고, 도 5의 (e)의 상기 숫자는 도 5의 (a)에 있어서 제 2 직선(L2)을 대칭축으로 해서 생성한 차분 화상인 도 5의 (c)에 대응하고 있다. 이와 같이 해서 스텝 S2201을 실행한 뒤, 스텝 S2202로 진행된다.Step S2201 in FIG. 23 corresponds to a process in which the pixel values are written in descending order as the heading in FIG. 5 (d) (e). That is, in step S2201, numbers 1 to X are first assigned to the X pixels constituting the difference image. Next, the pixel values PV (1) to PV (X) of the pixels of each number are stored in X array APs 1 to AP (X) in descending order from the maximum value to the minimum value. The X pixel values PV (1) to PV (X) stored in X arrays from the AP (1) to the AP (X) are sequentially recorded from left to right, as shown in FIG. 5 (d) (e). Is the number placed at the top. As described above, the number in Fig. 5 (d) corresponds to Fig. 5 (b) which is a difference image generated by using the first straight line L1 as the symmetry axis in Fig. 5 (a), The number in FIG. 5 (e) corresponds to FIG. 5 (c) which is a differential image generated by using the second straight line L2 as the axis of symmetry in FIG. 5 (a). After executing step S2201 in this way, the process proceeds to step S2202.

스텝 S2202에 있어서, 후술의 스텝 S2204에 있어서 처리하고 있는 화소의 번호를 저장하는 레지스터 S에 0을 저장하고, 초기화한다. 이어서 스텝 S2203에 있어서 레지스터 S에 저장되어 있는 수치에 1을 가산한다. 이 단계에서 레지스터 S의 수치는 1이 되며, 상기 S2201에 있어서 1번이 부여된 화소를 처리함을 나타낸다. 레지스터 S의 값이 확정되면, 다음으로 스텝 S2204로 진행된다.In step S2202, 0 is stored and initialized in the register S that stores the number of the pixel being processed in step S2204 described later. Next, in step S2203, 1 is added to the numerical value stored in the register S. In this step, the numerical value of the register S is 1, indicating that the pixel assigned to No. 1 in S2201 is processed. When the value of the register S is confirmed, the process proceeds to step S2204.

스텝 S2204는, 도 5의 (d)(e)에 있어서 중단에 표제로서 인접 차분 화소값의 차분값으로 적혀 있는 공정에 대응한다. 스텝 S2204에 있어서, 배열 AP(1)에 저장된 최대의 화소값으로부터 배열 AP(X)에 저장된 최소의 화소값까지를 이용하여, 2개의 인접 배열에 저장된 화소값간의 차분이 되는 차분 화소값(NP)을 순차적으로 산출한다. 즉, 상기 스텝 S2203에 있어서 확정된 레지스터 S의 값을 이용하여 표현하면, AP(S+1)-AP(S)을 연산하고, 그 결과를 NP(S)라는 명칭의 레지스터에 저장한다. 여기에, 전체 화소수가 X이기 때문에, S의 값은 1로부터 (X-1)까지 순차적으로 1씩 가산되어서 스텝 S2204에서 처리된다. 상기 차분의 연산 및 저장의 처리는, 스텝 S2204 중에 소프트웨어의 표기에 따라, NP(S)←AP(S+1)-AP(S)로 기재되어 있다. 스텝 S2204에 있어서 레지스터 NP(S)에 저장된 차분 화소값을, 도 5의 (d)(e)에 있어서 상단에 배치된 숫자와 화살표에 의해 대응시켜서 순차적으로 표시한 것이, 중단에 배치된 숫자이다. 스텝 S2204를 종료하면, 스텝 S2205로 진행된다.Step S2204 corresponds to a process in which a difference value of adjacent difference pixel values is written as a heading in the middle in FIG. 5 (d) (e). In step S2204, a difference pixel value (NP) that becomes a difference between pixel values stored in two adjacent arrays, from the maximum pixel value stored in the array AP 1 to the minimum pixel value stored in the array AP (X) ) Is sequentially calculated. That is, if expressed using the value of the register S determined in step S2203, AP (S + 1) -AP (S) is calculated and the result is stored in a register named NP (S). Here, since the total number of pixels is X, the value of S is sequentially added one by one from 1 to (X-1) and processed in step S2204. The processing of the difference calculation and storage is described as NP (S) ← AP (S + 1) -AP (S) in step S2204 according to the notation of the software. In step S2204, the difference pixel values stored in the register NP (S) are sequentially displayed in correspondence with numbers and arrows arranged at the top in FIG. 5 (d) (e). . When step S2204 ends, the process proceeds to step S2205.

스텝 S2205에 있어서, 스텝 S2204에서 처리한 화소의 번호 S가 전체 화소수보다 1만큼 작은 값인 (X-1)과 같은지의 여부에 대해서 판단한다. 즉, 차분 화상을 구성하는 X개의 전체 화소에 대하여 스텝 S2204의 처리를 완료했는지에 대해서 판단한다. 판단 결과가 No인 경우에는 스텝 S2203으로 되돌아가, 레지스터 S의 값에 1을 가산한다. 이에 따라, 스텝 S2204에 있어서 처리하는 화소의 번호가 1만큼 커진다. 그리고 다시 스텝 S2204에 있어서 이 번호가 1만큼 커진 화소에 대해서 처리를 실행한다. 이것을 반복해서 X개의 전체 화소에 대해 스텝 S2204에 있어서의 처리가 완료되면, 즉 S=X-1이 되면, 스텝 S2205의 판단 결과가 Yes로 된다. 그 경우에는 스텝 S2206으로 진행된다.In step S2205, it is determined whether or not the number S of pixels processed in step S2204 is equal to (X-1), which is a value smaller than the total number of pixels by one. That is, it is judged whether or not the processing of step S2204 has been completed for all X pixels constituting the difference image. If the determination result is No, the flow returns to step S2203, and 1 is added to the value of the register S. Accordingly, the number of pixels to be processed in step S2204 is increased by one. Then, in step S2204, a process is performed for the pixel whose number is increased by one. If the process in step S2204 is completed for all X pixels repeatedly, that is, S = X-1, the determination result in step S2205 is Yes. In that case, the process proceeds to step S2206.

스텝 S2206은, 도 5의 (d)(e)에 있어서 하단에 표제로서 차분값의 최대 구간에 있어서의 임계값으로 적혀 있는 공정 중, 최대 구간을 선출하는 공정에 대응한다. 임계값의 설정은 서브루틴 Sub2를 종료한 뒤, 되돌림 값으로서 후술하는 고하한값(高下限値) 및 저상한값(低上限値)을 메인 프로그램에 되돌리고 나서, 메인 프로그램에 있어서 실행한다. 스텝 S2206에 있어서, 스텝 S2204에서 생성한 NP(1)로부터 NP(X-1)까지의 (X-1)개의 차분 화소값 중에서, 최대 차분값(MXNP)을 선출한다. 이것은 도 5의 (b)에 있어서 중단에 적힌 인접 차분 화소값의 차분값 중에서 최대값 58을 선출하는 것, 혹은 도 5의 (c)에 있어서 중단에 적힌 인접 차분 화소값의 차분값 중에서 최대값 66을 선출하는 것에 대응한다. 이렇게 해서 스텝 S2206에 있어서 최대 차분값(MXNP)을 선출하면, 스텝 S2207로 진행된다.Step S2206 corresponds to a process of selecting the maximum section among the processes written as a threshold in the maximum section of the difference value as a heading at the bottom in FIG. 5 (d) (e). The threshold is set in the main program after the subroutine Sub2 is finished, and the high and low limit values (high lower limit values) and low upper limit values (hereinafter referred to as lower limit values) described later are returned to the main program as return values. In step S2206, among the (X-1) difference pixel values from NP (1) to NP (X-1) generated in step S2204, the maximum difference value MXNP is selected. This selects a maximum value of 58 among the difference values of adjacent difference pixel values written in the middle in Fig. 5B, or the maximum value among the difference values of adjacent difference pixel values written in the middle in Fig. 5C. Corresponds to the election of 66. In this way, if the maximum difference value MXNP is selected in step S2206, the process proceeds to step S2207.

스텝 S2207은, 도 5의 (d)(e)에 있어서 하단에 표제로서 차분값의 최대 구간에 있어서의 임계값으로 적혀 있는 공정 중, 임계값의 설정을 메인 프로그램에 있어서 실행하기 위한 준비가 되는 공정이다. 스텝 S2207에 있어서는, 스텝 S2206에서 선출한 최대 차분값(MXNP)의 산출에 사용한 2개의 인접하는 배열 AP(MX+1) 및 AP(MX)에 저장된 화소값 PV(MX+1) 및 PV(MX)를, 각각 고하한값(HBP) 및 저상한값(LTP)으로서 정의한다. 구체적으로는, HBP라는 명칭의 레지스터에 PV(MX+1)를 저장하고, 동시에 LTP라는 명칭의 레지스터에 PV(MX)를 저장한다. 이 저장의 처리는, 스텝 S2207 중에 소프트웨어의 표기에 따라, HBP←PV(MX+1) 및 LTP←PV(MX)로 기재되어 있다.Step S2207 is a preparation for executing the setting of the threshold value in the main program during the process written as a threshold value in the maximum section of the difference value as a heading at the bottom in FIG. 5 (d) (e). It is fair. In step S2207, the pixel values PV (MX + 1) and PV (MX) stored in two adjacent arrays AP (MX + 1) and AP (MX) used for calculating the maximum difference value (MXNP) selected in step S2206. ) Is defined as a high-limit value (HBP) and a low-limit value (LTP), respectively. Specifically, PV (MX + 1) is stored in a register named HBP, and PV (MX) is stored in a register named LTP at the same time. This storage processing is described in HBP ← PV (MX + 1) and LTP ← PV (MX) in step S2207 according to the notation of the software.

여기서, 도 5의 (d)(e)에 나타나 있는 바와 같이 단 하나의 차분 화상으로부터 생성한 임계값을 그대로 사용하는 것에 의해 생기는 문제, 및 이 문제를 해결하기 위한 공정에 대해서 설명한다.Here, as shown in Fig. 5 (d) (e), a problem caused by using the threshold value generated from only one difference image as it is, and a process for solving the problem will be described.

전술한 바와 같이, 도 5의 (d)(e)에 있어서 중단에 인접 차분 화소값의 차분값이 나타나 있다. 그리고 하단에 이 차분값의 최대 구간에 있어서 산출한 임계값이 나타나 있다. 이 하단의 임계값은 상단에 기재되는 차분 화소값 중에서 이간 화소값을 선출하기 위한 것이며, 상기 최대 구간의 양단의 차분 화소값(상단)의 중앙값을 산출해서 임계값으로 하고 있다. 구체적으로는, 도 5의 (d)의 경우에는 중단에 있어서 최대값을 갖는 구간으로서 58을 선출하고 있으므로, 하단에 있어서 당해 구간의 양단의 차분 화소값인 65와 7의 중앙값을 산출하고 있다. 그 중앙값은 36이며, 그러므로 임계값은 36이 된다. 도 5의 (e)에 관해서도 마찬가지로, 중단에 있어서 최대값을 갖는 구간인 66을 선출하고, 하단에 있어서 당해 구간의 양단의 차분 화소값인 71과 5의 중앙값을 산출하고 있다. 그 중앙값은 38이며, 그러므로 임계값은 38이 된다.As described above, in FIG. 5 (d) (e), the difference value of the adjacent difference pixel value is indicated at the middle. In addition, a threshold value calculated in the maximum section of the difference value is shown at the bottom. The threshold at the lower end is for selecting an inter-pixel value from the difference pixel values described at the upper end, and the median value of the differential pixel value (upper) at both ends of the maximum section is calculated to be a threshold value. Specifically, in the case of Fig. 5D, since 58 is selected as the section having the maximum value in the middle, the median values of 65 and 7, which are differential pixel values at both ends of the section, are calculated at the lower end. The median is 36, so the threshold is 36. Similarly to Fig. 5E, 66, which is the section having the maximum value at the middle, is selected, and the median values of 71 and 5, which are differential pixel values at both ends of the section, are calculated at the lower end. The median is 38, so the threshold is 38.

한편, 이 도 5의 (d)(e)는 본 발명의 화상 처리 알고리즘의 설명도이며, 원화상은 도 5의 (a)에 나타내는 하나만이다. 그러나, 도 23에 나타내는 서브루틴 Sub2가 처리하는 차분 화상은, 이하의 공정을 거쳐서 생성되고 있으므로 복수 존재한다. 차분 화상을 생성하는 공정에 있어서, 처음에 전술한 바와 같이 B개의 불량 화상(도 15의 스텝 S103)의 중 하나로서의 불량 화상(J)을 기초로(도 15의 스텝 S107) 하나 이상의 단색 화상을 생성한다(도 17의 스텝 S302 혹은 S307). 다음으로 이들 하나 이상(K개)의 단색 화상 중에서 제 N 단색 화상을 원화상으로 하여(도 17의 스텝 S306), 그 원화상으로부터 차분 화상을 생성한다(도 20의 스텝 S2151 내지 S2161).On the other hand, Fig. 5 (d) (e) is an explanatory diagram of the image processing algorithm of the present invention, and the original image is only one shown in Fig. 5 (a). However, since the difference image processed by the subroutine Sub2 shown in Fig. 23 is generated through the following steps, there are multiple. In the process of generating a differential image, as described above, one or more single-color images based on the defective image J as one of the B defective images (step S103 in FIG. 15) (step S107 in FIG. 15) are initially described. It is created (step S302 or S307 in Fig. 17). Next, among the one or more (K) monochrome images, the Nth monochrome image is used as the original image (step S306 in FIG. 17), and a differential image is generated from the original image (steps S2151 to S2161 in FIG. 20).

이렇게 해서 생성된 차분 화상이, 도 23에 나타내는 서브루틴 Sub2의 상세 플로우차트의 최상부에 위치하는 단자 Sub2에 인수로서 기재되어 있다. 즉 서브루틴 Sub2는, 동일한 불량 화상(J)을 기초로 생성한 단색 화상이 2개 이상일 경우에는, 제 1 단색 화상으로부터 제 K 단색 화상까지의 복수의 단색 화상의 각각으로부터 생성한 차분 화상을 모두 처리한다. 그리고, 이들 K개의 단색 화상을 생성하기 위한 불량 화상(J)의 개수는, 하나가 아니라 복수(B개)이다.The difference image thus generated is described as an argument in the terminal Sub2 located at the top of the detailed flowchart of the subroutine Sub2 shown in FIG. 23. That is, in the case of two or more single-color images generated based on the same defective image (J), the sub-routine Sub2 includes all the difference images generated from each of the plurality of single-color images from the first monochrome image to the K-th monochrome image. Process. The number of defective images J for generating these K monochromatic images is not one, but plural (B).

이들 점으로부터 명확한 바와 같이, 서브루틴 Sub2는 복수의 차분 화상에 대해서 차례차례 처리를 실행해 간다. 그들 복수의 차분 화상은 전술한 바와 같이, 전부해서 B개인 불량 화상에 의거하여 각각 생성되어 있다. 이 때문에, B개의 불량 화상에 있어서의 화소값의 편차에 대응하여, 서브루틴 Sub2가 처리하는 차분 화상의 화소값도 또한 편차가 생긴다. 즉 도 5의 (d)(e)에 있어서, 상단에 나타내는 차분 화소값이 차분 화상마다 편차가 생긴다. 이것에 기인하여, 중단에 나타내는 인접 차분 화소값의 차분값도 또한 차분 화상마다 편차가 생긴다. 따라서, 하단에 나타내는 임계값이 차분 화상마다 편차가 생겨서, 하나로 정해지지 않는다는 문제가 생긴다. 이것이「제 1 문제」이다. 이 제 1 문제를 해결하기 위해서는, 상기 차분 화상마다의 차분값의 편차를 해소하여, 모든(B개의) 불량 화상으로부터 생성한 복수의 차분 화상에 대하여 단 하나의 임계값을 설정할 수 있게 하는 것이 필요하다.As is clear from these points, the subroutine Sub2 sequentially processes a plurality of difference images. As described above, these plural difference images are respectively generated based on the B individual defect images. For this reason, the pixel value of the difference image processed by the subroutine Sub2 also deviates in response to the deviation of the pixel value in the B defective images. That is, in (d) (e) of FIG. 5, the difference pixel value shown at the upper end varies for each difference image. Due to this, a difference between the difference values of adjacent difference pixel values indicated in the middle also occurs for each difference image. Therefore, there arises a problem that the threshold value shown at the lower end is deviated for each difference image and is not determined as one. This is the "first problem." In order to solve this first problem, it is necessary to solve the difference in the difference values for each difference image, so that only one threshold value can be set for a plurality of difference images generated from all (B) defective images. Do.

또한 전술한 바와 같이, 서브루틴 Sub2가 처리하는 차분 화상은, 1개의 불량 화상(J)으로부터 복수(K개) 생성된 단색 화상의 각각으로부터 생성되어 있다. 예를 들면 전술한 바와 같이 컬러 화상인 불량 화상(J)을 R(빨강), G(초록), B(파랑)의 삼원색으로 분해해서 3개의 단색 화상을 생성했을 경우에는, 전부해서 3개(K=3)의 단색 화상이 생성된다. 그리고, 이들 3개의 단색 화상은 전술한 바와 같이, 컬러 화상에 있어서의 상기 삼원색의 각각의 성분 비율에 대응해서, 각 성분의 화소값을 그레이 스케일로 표현한 것이다.In addition, as described above, the difference image processed by the subroutine Sub2 is generated from each of a plurality of (K) monochromatic images generated from one defective image J. For example, as described above, if three defective monochrome images are generated by dividing a defective image (J), which is a color image, into three primary colors of R (red), G (green), and B (blue), three ( A monochrome image of K = 3) is generated. In addition, as described above, these three monochromatic images represent the pixel values of each component in a gray scale corresponding to the ratio of each component of the three primary colors in the color image.

그리고, 각각의 단색 화상으로부터 생성한 전체 3종류의 차분 화상을 서브루틴 Sub2로 차례차례 처리하게 된다. 그 경우에, 도 5의 (d)(e)의 중단에 나타내는 인접 차분 화소값의 차분값의 최대 구간이, 각각의 차분 화상에 대응해서 모두 동일하게 될 보장은 없다. 그 이유는, 전술한 바와 같이 불량 화상(J)의 각 화소에 있어서의 상기 R(빨강), G(초록), B(파랑)의 삼원색의 성분 비율이, 모든 화소에 대해 다르기 때문이다.Then, all three kinds of difference images generated from each single color image are sequentially processed by subroutine Sub2. In that case, there is no guarantee that the maximum section of the difference value of the adjacent difference pixel values shown in the middle of Fig. 5D (e) will be the same corresponding to each difference image. This is because, as described above, the component ratios of the three primary colors of the R (red), G (green), and B (blue) in each pixel of the defective image J are different for all pixels.

이것에 기인하여, K개의 차분 화상에 있어서 동일한 위치에 배치되는 화소의 화소값은, 상기 성분 비율에 의존해서 각각 다르다. 따라서, 동일한 불량 화상(J)으로부터 생성한 K개의 차분 화상의 각각에 대해서, 도 5의 (d)(e)의 상단에 나타내는 차분 화소값이 달라진다. 그러므로, 중단에 나타내는 인접 차분 화소값의 차분값을 산출했을 경우에도 또한, 그 산출 결과는 K개의 차분 화상의 각각에 대해서 전혀 다른 값으로 될 수 있다. 즉, 복수의 단색 화상의 각각으로부터 생성한 차분 화상에 대응하는 인접 차분 화소값의 차분값의 최대 구간은, 단색 화상에 대응해서 전혀 별개의 구간이 될 수 있다. 그 경우, 차분값의 최대 구간을 이용하여 임계값을 설정할 때에, 임계값 설정용의 단색 화상을 선출하는 기준이 필요하게 된다는 문제가 생긴다. 이것이「제 2 문제」이다. 이 제 2 문제를 해결하기 위해서는, 상기 선출하는 기준을 명확화하여, 1개의 불량 화상을 기초로 생성한 복수의 단색 화상 중에서, 임계값을 설정하는데 최적인 단색 화상을 선출하는 것이 필요하다.Due to this, the pixel values of the pixels arranged at the same position in the K difference images are different depending on the component ratio. Therefore, for each of the K difference images generated from the same defective image J, the difference pixel values shown at the top of Fig. 5 (d) (e) are different. Therefore, even when the difference value of the adjacent difference pixel value indicated in the middle is calculated, the result of the calculation can be a completely different value for each of the K difference images. That is, the maximum period of the difference value of the adjacent difference pixel values corresponding to the difference image generated from each of the plurality of monochrome images may be a completely separate section corresponding to the monochrome image. In that case, when setting the threshold value using the maximum section of the difference value, a problem arises that a criterion for selecting a monochrome image for threshold setting is required. This is the "second problem." In order to solve this second problem, it is necessary to clarify the selection criteria and select a monochrome image that is optimal for setting a threshold among a plurality of monochrome images generated based on one defective image.

도 21 내지 도 23에 나타내는 임계값 범위 설정 공정(S7)에 있어서는, 이들 문제를 해결하기 위해서 이하의 공정에 의해, 차분 화상의 처리를 행한다. 먼저, 도 23에 나타내는 스텝 S2207에 있어서, 전술한 바와 같이 화소값 PV(MX+1) 및 PV(MX)를, 각각 고하한값(HBP) 및 저상한값(LTP)으로서 정의한다. 그리고, 도 23의 최하부의 단자 Return에 기재된 바와 같이, 상기 고하한값(HBP) 및 저상한값(LTP)을 도 21에 나타내는 임계값 범위 설정 공정(S7)의 메인 프로그램에 되돌림 값으로서 전달한다.In the threshold value range setting step (S7) shown in Figs. 21 to 23, in order to solve these problems, the difference image is processed by the following steps. First, in step S2207 shown in Fig. 23, as described above, the pixel values PV (MX + 1) and PV (MX) are defined as the high-low limit value HBP and the low-high limit value LTP, respectively. Then, as described in the terminal return at the bottom of FIG. 23, the high-low limit value HBP and the low-high limit value LTP are transmitted as a return value to the main program of the threshold range setting process S7 shown in FIG.

도 21에 있어서, 메인 프로그램은 스텝 S22의 서브루틴 Sub2로부터 상기 되돌림 값을 수취하여, 후술의 스텝 S702 이후에 있어서 처리를 실행한다. 이 방법에 의해, 모든(B개의) 불량 화상으로부터 생성한 복수의 차분 화상에 대하여, 단 하나의 임계값을 설정할 수 있게 한다. 그리고, 모든(B개의) 불량 화상으로부터 생성되는 모든 단색 화상(불량 화상마다 K개씩)의 각각에 대응하는 K개의 차분 화상 중에서, 기준에 의거하여 상기 임계값을 설정하는데 최적인 차분 화상을 선출한다. 이 최적인 차분 화상의 선출은, 최적인 단색 화상의 선출과 다름없다.In Fig. 21, the main program receives the return value from the subroutine Sub2 in step S22, and executes the process in step S702 onwards described later. By this method, it is possible to set only one threshold value for a plurality of differential images generated from all (B) defective images. Then, among the K difference images corresponding to each of all the monochrome images (K for each defective image) generated from all (B) defective images, a difference image that is optimal for setting the threshold value based on a standard is selected. . The selection of the optimal difference image is the same as the selection of the optimal monochrome image.

이하에 도 21 및 도 22를 사용하여, 모든 불량 화상으로부터 생성한 복수의 차분 화상에 대하여, 단 하나의 임계값을 설정할 수 있게 하는 공정과, 모든 불량 화상으로부터 생성되는 모든 단색 화상의 각각에 대응하는 차분 화상 중에서, 상기 임계값을 설정하는데 최적인 차분 화상을 선출하는 공정에 대하여 설명한다.21 and 22, the process of enabling a single threshold value to be set for a plurality of differential images generated from all defective images, and corresponding to each of all monochrome images generated from all defective images A process of selecting a difference image that is optimal for setting the threshold among the difference images to be described will be described.

도 21에 나타내는 임계값 범위 설정 공정(S7)의 스텝 S702에 있어서, 스텝 S22 즉 도 23에 나타내는 서브루틴 Sub2로부터, 되돌림 값으로서의 고하한값(HBP) 및 저상한값(LTP)(도 23의 스텝 S2207 및 최하부의 단자 Return)을 수취한다. 그리고 이들 되돌림 값 중 고하한값(HBP)을 고하한값(HBPMNJ)이라는 명칭의 레지스터에 저장한다. 마찬가지로 되돌림 값 중 저상한값(LTP)을 저상한값(LTPMNJ)이라는 명칭의 레지스터에 저장한다. 이 저장의 처리는, 스텝 S702 중에 소프트웨어의 표기에 따라, 고하한값(HBPMNJ)←고하한값 및 저상한값(LTPMNJ)←저상한값으로 기재되어 있다.In step S702 of the threshold value range setting step (S7) shown in FIG. 21, from step S22, i.e., from the subroutine Sub2 shown in FIG. 23, the lower limit value HBP and the lower limit value LTP as the return value (step S2207 in FIG. 23) And the bottom terminal Return). Then, the lower limit value HBP of these return values is stored in a register named the lower limit value HBPMNJ. Similarly, the low limit value (LTP) among the return values is stored in a register named low limit value (LTPMNJ). In step S702, the storage processing is described as a high-limit value (HBPMNJ) ← a high-limit value and a low-limit value (LTPMNJ) ← low-limit value in accordance with the software notation.

여기서, 고하한값(HBPMNJ) 및 저상한값(LTPMNJ)이라는 레지스터 명칭에 사용되어 있는 3개의 번호로서의 J, N 및 M에 대해서 설명한다. 이 명칭에 있어서의 2번째 및 3번째의 번호 N 및 J는, 스텝 S701에 기재된 차분 화상(NJ)이라는 레지스터 명칭의 N 및 J와 같다. 이들 N 및 J에 대해서는 이미 설명되어 있으므로, 상세한 설명은 생략한다. 결론만을 기재하면, 불량 화상(J)을 기초로 생성한 제 N 단색 화상으로부터 생성한 차분 화상의 고하한값(HBP) 및 저상한값(LTP)이라는 의미이다.Here, J, N, and M as three numbers used in the register names of the high-low limit value (HBPMNJ) and the low-high limit value (LTPMNJ) will be described. The 2nd and 3rd numbers N and J in this name are the same as N and J in the register name called the difference image NJ described in step S701. Since these N and J have already been described, a detailed description is omitted. If only the conclusion is described, it means that the lower limit value (HBP) and the lower limit value (LTP) of the difference image generated from the Nth monochrome image generated based on the defective image J are.

다음으로, 이 레지스터 명칭에 있어서의 1번째의 번호 M에 대해서, 이하에 설명한다. 전술한 바와 같이 도 18에 나타내는 대칭성 판단 공정(S4)에 있어서의 스텝 S401에 있어서, 제 N 단색 화상(원화상)이 대칭축을 갖고 있는지에 대해서 판단한다. 그 판단 결과가 Yes인 경우에, 스텝 S402에 있어서 원화상이 가진 대칭축의 수를 레지스터 C에 저장한다. 그리고 스텝 S403에 있어서, 레지스터 M에 0을 저장하고 초기화한다. 다음으로 스텝 S404에 있어서, 레지스터 M에 1을 가산한다. 여기에 레지스터 M은, 후공정이 되는 도 14의 (a)의 스텝 S5(차분 산출 공정) 내지 스텝 S7(임계값 범위 설정 공정)에 의해 처리하는 원화상이 갖는, 상기 대칭축의 번호 C를 기억하는 레지스터이다. 그리고 스텝 S405 및 S406에 있어서, 상기 레지스터 M에 대응하는 제 M 대칭축의 일단 및 타단의 좌표를 레지스터 ONEM 및 OTEM에 저장한다.Next, the first number M in this register name will be described below. As described above, in step S401 in the symmetry determination step S4 shown in Fig. 18, it is determined whether the Nth monochrome image (original image) has a symmetry axis. When the determination result is Yes, the number of symmetric axes of the original image in step S402 is stored in the register C. Then, in step S403, 0 is stored in register M and initialized. Next, in step S404, 1 is added to the register M. Here, the register M stores the number C of the axis of symmetry of the original image to be processed by steps S5 (difference calculation process) to step S7 (threshold range setting process) of Fig. 14 (a) which becomes a post process. Is a register to do. Then, in steps S405 and S406, the coordinates of one end and the other end of the Mth symmetric axis corresponding to the register M are stored in the registers ONEM and OTEM.

그리고, 도 14의 (a)에 나타내는 스텝 S7(임계값 범위 설정 공정)의 상세 플로우차트로서의 도 21 내지 도 23으로부터 명확한 바와 같이, 상기 레지스터 M은 도 23에 나타내는 서브루틴 Sub2가 처리한 대칭축의 번호를 나타낸다. 이상을 정리하면, 고하한값(HBPMNJ) 및 저상한값(LTPMNJ)은 각각, 불량 화상(J)을 기초로 생성한 제 N 단색 화상으로부터, 제 M 대칭축에 의거하여 생성한 차분 화상이 갖는 고하한값(HBP) 및 저상한값(LTP)이라는 의미이다.Then, as is clear from Figs. 21 to 23 as a detailed flowchart of step S7 (threshold range setting process) shown in Fig. 14A, the register M is the symmetry axis processed by the subroutine Sub2 shown in Fig. 23. Number. Summarizing the above, the high-limit value (HBPMNJ) and the low-limit value (LTPMNJ) are the high-limit values of the differential images generated on the basis of the M symmetry axis from the N-th monochrome image generated based on the defective image J, respectively. HBP) and Low Upper Limit (LTP).

이상과 같이 도 21에 나타내는 스텝 S702에 있어서, 고하한값(HBPMNJ) 및 저상한값(LTPMNJ)의 각 레지스터의 내용을 설정한 뒤, 스텝 S703으로 진행된다. 스텝 S703에 있어서, 레지스터 M에 저장한 대칭축의 번호가 대칭축의 수인 C에 도달했는지의 여부에 대해 판단한다. 레지스터 M은 도 18에 나타내는 대칭성 판단 공정(S4)의 스텝 S404에 있어서 1씩 가산된다. 이 가산된 레지스터 M의 값에 대응하는 원화상은, 전술한 바와 같이 도 19 내지 도 23에 의해 처리된다. 그리고 도 21의 스텝 S702에 있어서, 고하한값(HBPMNJ) 및 저상한값(LTPMNJ)의 각 레지스터의 내용이 설정된다.As described above, in step S702 shown in Fig. 21, after setting the contents of each register of the high-low limit value HBPMNJ and the low-high limit value LTPMNJ, the process proceeds to step S703. In step S703, it is determined whether the number of symmetric axes stored in the register M has reached C, the number of symmetric axes. The register M is added one by one in step S404 of the symmetry determination step (S4) shown in FIG. The original image corresponding to the added register M value is processed by FIGS. 19 to 23 as described above. In step S702 of FIG. 21, the contents of each register of the high-low limit value HBPMNJ and the low-high limit value LTPMNJ are set.

도 21의 스텝 S703에 있어서의 판단은, 제 N 단색 화상이 가진 C개의 대칭축의 전부에 대응하여, 고하한값(HBPMNJ) 및 저상한값(LTPMNJ)의 각 레지스터의 내용이 설정되었는지의 여부의 판단과 다름없다. 이 판단 결과가 No인 경우에는, 모든 대칭축에 대응하는 이들 레지스터의 내용이 설정되어 있지 않으므로, 도약처 번호 204가 기재되는 결합자(結合子)를 경유해서 도 18(대칭성 판단 공정(S4))의 스텝 S404로 점프한다. 이 스텝 S404에 있어서는, 대칭축의 수를 저장하는 레지스터 M의 값에 1을 가산한다. 그리고, 지금까지의 설명과 마찬가지로, M의 값이 1만큼 커진 상태에서 도 18의 스텝 S405 및 S406과 도 19 내지 도 23에 기재된 공정을 재차 실행한다. M의 값에 대한 1의 가산을 반복하면, 도 21(임계값 범위 설정 공정(S7))의 스텝 S703의 판단 결과가 Yes로 된다. 그 경우에는 스텝 S704로 진행된다.The determination in step S703 of Fig. 21 is to determine whether or not the contents of each register of the high-low limit value (HBPMNJ) and low-high limit value (LTPMNJ) are set corresponding to all of the C symmetry axes of the Nth monochrome image. It is no different. If the result of this judgment is No, since the contents of these registers corresponding to all the axes of symmetry are not set, Fig. 18 (symmetry determination step (S4)) via a joiner in which the jump destination number 204 is described. Jump to step S404. In this step S404, 1 is added to the value of the register M that stores the number of symmetry axes. Then, similarly to the description so far, steps S405 and S406 in Fig. 18 and steps shown in Figs. 19 to 23 are executed again in a state where the value of M is increased by one. If the addition of 1 to the value of M is repeated, the determination result in step S703 of Fig. 21 (threshold range setting process (S7)) becomes Yes. In that case, the process proceeds to step S704.

스텝 S704에 있어서, 레지스터 N에 저장한 단색 화상의 번호가 단색 화상의 수인 K에 도달했는지의 여부에 대해 판단한다. 레지스터 N은 도 17에 나타내는 단색 화상 생성 공정(S3)의 스텝 S305에 있어서 1씩 가산된다. 이 가산된 레지스터 N의 값에 대응하는 원화상은, 전술한 바와 같이 도 18 내지 도 23에 의해 처리된다. 그리고 도 21의 스텝 S702에 있어서, 고하한값(HBPMNJ) 및 저상한값(LTPMNJ)의 각 레지스터의 내용이 설정된다. 도 21의 스텝 S704에 있어서의 판단은, J번째의 불량 화상을 기초로 생성된 전부해서 K개인 단색 화상의 모두에 대응하여, 고하한값(HBPMNJ) 및 저상한값(LTPMNJ)의 각 레지스터의 내용이 설정되었는지의 여부의 판단과 다름없다. 이 판단 결과가 No인 경우에는, 모든 단색 화상에 대응하는 이들 레지스터의 내용이 설정되어 있지 않으므로, 도약처 번호 203이 기재되는 결합자를 경유해서 도 17(단색 화상 생성 공정(S3))의 스텝 S305로 점프한다. 이 스텝 S305에 있어서는, 단색 화상의 수를 저장하는 레지스터 N의 값에 1을 가산한다. 그리고, 지금까지의 설명과 마찬가지로 N의 값이 1만큼 커진 상태에서 도 17의 스텝 S306 및 도 18 내지 도 23에 기재된 공정을 재차 실행한다. N의 값에 대한 1의 가산을 반복하면, 도 21(임계값 범위 설정 공정(S7))의 스텝 S704의 판단 결과가 Yes로 된다. 그 경우에는 스텝 S705로 진행된다.In step S704, it is judged whether or not the number of monochrome images stored in the register N has reached K, which is the number of monochrome images. The register N is added one by one in step S305 of the monochrome image generation process (S3) shown in FIG. The original image corresponding to the added register N value is processed by FIGS. 18 to 23 as described above. In step S702 of FIG. 21, the contents of each register of the high-low limit value HBPMNJ and the low-high limit value LTPMNJ are set. In step S704 of FIG. 21, the contents of each register of the lower limit value HBPMNJ and the lower limit value LTPMNJ correspond to all of the K single-color images generated based on the J-th defective image. It is no different from whether or not it has been set. If the result of this judgment is No, since the contents of these registers corresponding to all the monochrome images are not set, step S305 in FIG. 17 (monochrome image generation step (S3)) via a combiner in which the jump destination number 203 is described. To jump. In this step S305, 1 is added to the value of the register N that stores the number of monochrome images. Then, as in the description so far, the steps S306 in Fig. 17 and the processes described in Figs. 18 to 23 are again performed in a state where the value of N is increased by one. If the addition of 1 to the value of N is repeated, the determination result in step S704 in FIG. 21 (threshold range setting step (S7)) becomes Yes. In that case, the process proceeds to step S705.

스텝 S705에 있어서, 레지스터 J에 저장한 불량 화상의 번호가 불량 화상의 수인 B에 도달하였는지의 여부에 대해 판단한다. 레지스터 J는 도 15에 나타내는 기지 워크 촬상 공정(S1)의 스텝 S106에 있어서 1씩 가산된다. 이 가산된 레지스터 J의 값에 대응하는 불량 화상은, 전술한 바와 같이 도 16 내지 도 23에 의해 처리된다. 그리고 도 21의 스텝 S702에 있어서, 고하한값(HBPMNJ) 및 저상한값(LTPMNJ)의 각 레지스터의 내용이 설정된다. 도 21의 스텝 S705에 있어서의 판단은, B개의 불량 화상의 전부에 대응하여, 고하한값(HBPMNJ) 및 저상한값(LTPMNJ)의 각 레지스터의 내용이 설정되었는지의 여부의 판단과 다름없다. 이 판단 결과가 No인 경우에는, 모든 불량 화상에 대응하는 이들 레지스터의 내용이 설정되어 있지 않으므로, 도약처 번호 202가 기재되는 결합자를 경유해서 도 15(기지 워크 촬상 공정(S1))의 스텝 S106으로 점프한다. 이 스텝 S106에 있어서는, 불량 화상의 수를 저장하는 레지스터 J의 값에 1을 가산한다. 그리고, 지금까지의 설명과 마찬가지로 J의 값이 1만큼 커진 상태에서 도 15의 스텝 S107 및 도 16 내지 도 23에 기재된 공정을 재차 실행한다. J의 값에 대한 1의 가산을 반복하면, 도 21(임계값 범위 설정 공정(S7))의 스텝 S705의 판단 결과가 Yes로 된다. 그 경우에는 스텝 S706으로 진행된다.In step S705, it is judged whether or not the number of defective images stored in the register J has reached B, the number of defective images. The register J is added one by one in step S106 of the known work imaging step (S1) shown in FIG. 15. The defective image corresponding to the value of the added register J is processed by FIGS. 16 to 23 as described above. In step S702 of FIG. 21, the contents of each register of the high-low limit value HBPMNJ and the low-high limit value LTPMNJ are set. The determination in step S705 of FIG. 21 is equivalent to the determination as to whether or not the contents of each register of the high and low limit values HBPMNJ and LTPMNJ are set corresponding to all of the B defective images. If the result of this judgment is No, since the contents of these registers corresponding to all the defective images are not set, step S106 in Fig. 15 (base work imaging step (S1)) via a combiner in which the jump destination number 202 is described. To jump. In this step S106, 1 is added to the value of the register J that stores the number of defective images. Then, similarly to the description so far, in the state where the value of J is increased by 1, the steps described in step S107 of FIG. 15 and the steps of FIGS. 16 to 23 are executed again. If the addition of 1 to the value of J is repeated, the determination result of step S705 in Fig. 21 (threshold range setting step (S7)) becomes Yes. In that case, the process proceeds to step S706.

이상의 설명으로부터 명확한 바와 같이, 도 21에 있어서의 스텝 S703 내지 S705의 3종류의 판단은, 이하의 3가지의 판단이다. 먼저 스텝 S703에 있어서, 서브루틴 Sub2로부터의 되돌림 값으로서의 고하한값(HBP) 및 저상한값(LTP)은 단색 화상이 가진 모든 대칭축에 대해서 생성되어 있는지의 여부를 판단한다. 다음으로 스텝 S704에 있어서, 서브루틴 Sub2로부터의 상기 되돌림 값은 불량 화상을 기초로 생성한 모든 단색 화상에 대해서 생성되어 있는지의 여부를 판단한다. 그리고 스텝 S705에 있어서, 서브루틴 Sub2로부터의 상기 되돌림 값은 모든 불량 화상에 대해서 생성되어 있는지의 여부를 판단한다.As is clear from the above description, the three kinds of judgments in steps S703 to S705 in Fig. 21 are the following three judgments. First, in step S703, it is determined whether or not the lower limit value HBP and the lower limit value LTP as the return value from the subroutine Sub2 are generated for all symmetry axes of the monochrome image. Next, in step S704, it is determined whether or not the return value from subroutine Sub2 is generated for all the monochrome images generated based on the defective image. Then, in step S705, it is determined whether or not the return value from subroutine Sub2 is generated for all the defective images.

이들 3가지의 판단 결과가 모두 Yes로 되는 것에 의해, 상기 레지스터 고하한값(HBPMNJ) 및 저상한값(LTPMNJ)의 명칭에 사용되어 있는 3개의 번호로서의 J, N 및 M에 대해서, 모든 번호에 관계되는 처리를 완료하게 된다. 즉, 여기까지의 공정에 의해 레지스터 고하한값(HBPMNJ) 및 저상한값(LTPMNJ)에는, 불량 화상을 기초로 생성된 모든 단색 화상에 대해서, 당해 단색 화상이 가진 모든 대칭축에 관계되는 차분 화상의 고하한값(HBP) 및 저상한값(LTP)이, 전체 불량 화상에 대하여 생성되어서 저장되게 된다.When all of these three judgment results are Yes, all three numbers are used for J, N, and M as three numbers used in the names of the register high-low limit value (HBPMNJ) and low-high limit value (LTPMNJ). The processing is completed. That is, the lower limit of the register (HBPMNJ) and the lower limit of the limit (LTPMNJ) by the steps up to this point, for all the monochrome images generated based on the defective image, the lower limit of the difference image related to all symmetry axes of the monochrome image (HBP) and a low upper limit value (LTP) are generated and stored for the entire defective image.

이어서 도 21의 스텝 S706 및 S707에 있어서, 다시 대칭축의 번호를 저장하는 레지스터 M을 초기화한 뒤, 그 값에 1을 가산한다. 그리고 도약처 번호 206이 기재되는 결합자를 경유해서 도 22(임계값 범위 설정 공정(S7))의 스텝 S708로 점프한다.Next, in steps S706 and S707 of Fig. 21, the register M for storing the number of symmetry axes is initialized again, and 1 is added to the value. Then, it jumps to step S708 in Fig. 22 (threshold range setting process (S7)) via a combiner in which the jump destination number 206 is described.

도 22에 나타내는 임계값 범위 설정 공정(S7)은, 상기의 도 21에 있어서의 스텝 S702에서 레지스터 고하한값(HBPMNJ) 및 저상한값(LTPMNJ)에 저장한 복수의 고하한값 및 저상한값에 대한 처리를 실행하는 공정이다. 이 공정은 전술한 바와 같이, 2개의 목적을 갖고 있다. 제 1 목적은, 모든(B개의) 불량 화상으로부터 생성한 복수의 차분 화상에 대하여, 단 하나의 임계값을 설정할 수 있게 하는 것이다. 제 2 목적은, 모든(B개의) 불량 화상으로부터 생성되는 모든 단색 화상(불량 화상마다 K개씩)의 각각에 대응하는 K개의 차분 화상 중에서, 상기 임계값을 설정하는데 최적인 차분 화상을 선출하는 것이다.The threshold value range setting process (S7) shown in FIG. 22 processes the plurality of high and low limit values stored in the register high and low limit values (HBPMNJ) and the low and high limit values (LTPMNJ) in step S702 in FIG. It is a process to be executed. As described above, this process has two purposes. The first object is to enable a single threshold value to be set for a plurality of differential images generated from all (B) defective images. The second object is to select a difference image that is optimal for setting the threshold among K difference images corresponding to each of all monochrome images (K for each bad image) generated from all (B) bad images. .

도 22에 있어서의 최초의 스텝 S708에서, 불량 화상(1)으로부터 불량 화상(B)까지의 각 불량 화상에 대응하는 K개의 단색 화상의 각각으로부터, 제 M 대칭축에 의거하여 생성한 차분 화상을 이용하여 산출한 (B×C)개의 고하한값(HBPMNJ)(1≤N≤K가 되는 N의 각각에 대해서 1≤M≤C, 1≤J≤B) 중에서, 최소값이 되는 최소하한값(MNBMN)을 선출한다.In the first step S708 in Fig. 22, the difference image generated based on the Mth axis of symmetry is used from each of the K monochromatic images corresponding to each defective image from the defective image 1 to the defective image B. The minimum lower limit value (MNBMN), which is the minimum among (B × C) calculated high limit values (HBPMNJ) (1≤M≤C, 1≤J≤B for each of N where 1≤N≤K), is calculated. Elect.

다음에 스텝 S709로 진행되고, 불량 화상(1)로부터 불량 화상(B)까지의 각 불량 화상에 대응하는 K개의 단색 화상의 각각으로부터, 제 M 대칭축에 의거하여 생성한 차분 화상을 이용하여 산출한 B개의 저상한값(LTPMNJ)(1≤N≤K가 되는 N의 각각에 대해서 1≤M≤C, 1≤J≤B) 중에서, 최대값이 되는 최대상한값(MXTMN)을 선출한다.Next, the process proceeds to step S709, and the difference images generated based on the M symmetry axis are calculated from each of the K monochrome images corresponding to each defective image from the defective image 1 to the defective image B. A maximum upper limit value MXTMN that becomes the maximum value is selected from among the B lower limit values LTPMNJ (1 ≤ M ≤ C and 1 ≤ J ≤ B for each of N having 1 ≤ N ≤ K).

이와 같이, 스텝 S708에 있어서 (B×C)개의 고하한값(HBPMNJ)(1≤N≤K가 되는 N의 각각에 대해서 1≤M≤C, 1≤J≤B) 중에서 최소값을 선출하고, 스텝 S709에 있어서 B개의 저상한값(LTPMNJ)(1≤N≤K가 되는 N의 각각에 대해서 1≤M≤C, 1≤J≤B) 중에서 최대값을 선출한다는 것의 의미를, 이하에 설명한다.In this way, in step S708, a minimum value is selected from among (B × C) high-limit values (HBPMNJ) (1≤M≤C, 1≤J≤B for each of N, where 1≤N≤K), and then step The meaning of selecting the maximum value among the B low upper limit values LTPMNJ (1 ≤ M ≤ C and 1 ≤ J ≤ B for each of N having 1 ≤ N ≤ K) in S709 will be described below.

고하한값(HBP)은, 도 23에 나타내는 서브루틴 Sub2의 스텝 S2206 및 S2207에 있어서 생성되고 있다. 그리고 전술한 바와 같이 스텝 S2206은, 도 5의 (d)(e)에 있어서 하단에 표제로서 차분값의 최대 구간에 있어서의 임계값으로 적혀 있는 공정 중, 최대 구간을 선출하는 공정에 대응한다. 이 최대 구간은, 예를 들면 도 5의 (d)의 경우에는 중단에 있어서 최대 차분값으로서의 58이 생성되는 구간, 즉 상단에 있어서 차분 화소값 65 및 7을 인접 차분 화소값으로 하는 구간이다. 그리고 도 23에 있어서의 스텝 S2207에서, 최대 차분값(MXNP)의 산출에 사용한 2개의 인접하는 배열 AP(MX+1) 및 AP(MX)에 저장된 화소값 PV(MX+1) 및 PV(MX)를, 각각 고하한값(HBP) 및 저상한값(LTP)으로 하고 있다. 이 스텝 S2207의 처리와 도 5의 (d)를 대응시키면, 도 5의 (d)의 상단에 기재된 차분 화소값 중 65가 고하한값(HBP)이며, 7이 저상한값(LTP)이다.The lower limit value HBP is generated in steps S2206 and S2207 of the subroutine Sub2 shown in FIG. 23. Then, as described above, step S2206 corresponds to a process of selecting the maximum section among the processes written as a threshold in the maximum section of the difference value as a title at the bottom in FIG. 5 (d) (e). This maximum section is, for example, in the case of Fig. 5D, a section in which 58 as the maximum difference value is generated in the middle of interruption, that is, a section in which difference pixel values 65 and 7 are used as adjacent difference pixel values at the upper end. Then, in step S2207 in Fig. 23, two adjacent arrays AP (MX + 1) and the pixel values PV (MX + 1) and PV (MX) stored in the two adjacent arrays AP (MX + 1) used to calculate the maximum difference value (MXNP). ) Are respectively set as the high-limit value (HBP) and the low-limit value (LTP). When the process of step S2207 is correlated with Fig. 5D, 65 of the difference pixel values described at the top of Fig. 5D are the lower limit value HBP and 7 is the lower limit value LTP.

여기서 전술한 바와 같이, B개의 불량 화상의 각각의 화소값에는 편차가 있다. 이 때문에 각 불량 화상으로부터 생성하는 K개의 단색 화상의 화소값에도 불량 화상에 대응해서 편차가 존재한다. 이것에 기인하여, 각 단색 화상으로부터 차분 화상을 생성하면, 각 차분 화상의 기초로 되어 있는 불량 화상이 갖는 화소값의 편차에 대응하여, 차분 화상의 화소값에도 편차가 존재하게 된다. 이들 편차가 생긴 복수의 차분 화상을 도 23의 서브루틴 Sub2에 의해 처리하면, 각 차분 화상으로부터 생성되는 고하한값(HBP) 및 저상한값(LTP)은 편차가 생긴다. 즉, 도 5의 (a)에 나타내는 원화상 즉 제 N 단색 화상(도 17의 스텝 S306)이 B개의 불량 화상에 대응해서 변화되면, 도 5의 (d)(e)의 각 단의 수치에 편차가 생긴다. 그 결과, 도 23의 스텝 S2207에 있어서 생성되는 고하한값(HBP) 및 저상한값(LTP)은, B개의 불량 화상의 화소값의 편차에 대응해서 편차가 생긴다.As described above, there are variations in the pixel values of each of the B defective images. For this reason, variations exist in the pixel values of the K monochromatic images generated from each defective image corresponding to the defective image. Due to this, when a difference image is generated from each monochromatic image, a variation exists in the pixel value of the difference image in response to the variation in the pixel value of the defective image that is the basis of each difference image. When a plurality of difference images in which these deviations are generated is processed by the subroutine Sub2 in Fig. 23, deviations are generated between the lower limit value HBP and the lower limit value LTP generated from each difference image. That is, if the original image shown in Fig. 5 (a), that is, the Nth monochrome image (step S306 in Fig. 17) is changed corresponding to the B defective images, the value of each stage in Fig. 5 (d) (e) There are deviations. As a result, the high-low limit value HBP and the low-high limit value LTP generated in step S2207 in Fig. 23 are in correspondence with the deviation of the pixel values of the B defective images.

이와 같이 차분 화상마다 고하한값(HBP) 및 저상한값(LTP)에 편차가 생기는 것에 기인하여, 도 5의 (d)(e)의 하단에 기재되는 바와 같이 임계값을 설정하면, 그 임계값은 차분 화상마다 편차가 생긴다.Due to variations in the high and low limit values HBP and LTP for each difference image, if the threshold value is set as described at the bottom of FIG. 5 (d) (e), the threshold value is Differences occur for each difference image.

그래서, 전체 B개로 이루어지는 불량 화상 중의 어느 것으로부터 생성한 제 N 단색 화상이어도, 그 제 N 단색 화상으로부터 생성한 차분 화상에 대하여 동일한 임계값을 설정하는 것이 가능해지도록 하기 위한 공정이 필요하다. 그 공정으로서, 도 22에 있어서의 스텝 S708 및 S709의 공정을 실시하고 있다.Therefore, even if it is an N-th monochrome image generated from any of the B defective images, a process for making it possible to set the same threshold value for the difference image generated from the N-th monochrome image is necessary. As the process, steps S708 and S709 in Fig. 22 are performed.

스텝 S708의 공정에 있어서 처리되는 고하한값(HBPMNJ)은, 도 5의 (d)의 중단에 기재한 인접 차분 화소값의 차분값의 최대 구간에 대응하는 상단의 차분 화소값 중, 좌측에 위치하는 큰 화소값에 대응한다. 이후 이 화소값을 최대 구간 대(大)화소값이라고 명명한다.The lower limit value HBPMNJ processed in the process of step S708 is located on the left of the upper difference pixel value corresponding to the maximum section of the difference value of the adjacent difference pixel values described in the middle of Fig. 5D. It corresponds to a large pixel value. This pixel value is hereinafter referred to as a maximum section large pixel value.

마찬가지로 스텝 S709의 공정에 있어서 처리되는 저상한값(LTPMNJ)은, 도 5의 (d)의 중단에 기재한 인접 차분 화소값의 차분값의 최대 구간에 대응하는 상단의 차분 화소값 중, 우측에 위치하는 작은 화소값에 대응한다. 이후 이 화소값을 최대 구간 소(小)화소값이라고 명명한다.Similarly, the low upper limit value LTPMNJ processed in the process of step S709 is located on the right side of the upper difference pixel value corresponding to the maximum section of the difference value of the adjacent difference pixel values described in the middle of Fig. 5D. Corresponds to a small pixel value. This pixel value is hereinafter referred to as a maximum section small pixel value.

즉 스텝 S708에 있어서는, 최대 구간 대화소값 중에서 최소값이 되는 최소하한값(MNBMN)을 선출하고 있다. 이 최소하한값(MNBMN)은, B개의 불량 화상에 대응하는 K개의 단색 화상의 각각으로부터, 제 M 대칭축에 의거하여 생성한 차분 화상을 이용하여 산출했던 (B×C)개의 최대 구간 대화소값 중에서, 대응하는 최대 구간 소화소값에 가장 가까운 값이 된다.That is, in step S708, the minimum lower limit value (MNBMN) that becomes the minimum value among the maximum interval conversation element values is selected. The minimum lower limit value (MNBMN) is calculated from each of the K monochrome images corresponding to the B defective images, using the difference image generated based on the Mth axis of symmetry, among the (B × C) maximum interval dialog values, It becomes the value closest to the corresponding maximum section digester value.

아울러 스텝 S709에 있어서는, 최대 구간 소화소값 중에서 최대값이 되는 최대상한값(MXTMN)을 선출하고 있다. 이 최대상한값(MXTMN)은, B개의 불량 화상에 대응하는 K개의 단색 화상의 각각으로부터, 제 M 대칭축에 의거하여 생성한 차분 화상을 이용하여 산출한 (B×C)개의 최대 구간 소화소값 중에서, 대응하는 최대 구간 대화소값에 가장 가까운 값이 된다.In addition, in step S709, the maximum upper limit value MXTMN that becomes the maximum value among the maximum section digest factor values is selected. The maximum upper limit value MXTMN is calculated from each of the K monochrome images corresponding to the B defective images, using the difference image generated based on the Mth axis of symmetry, among the (B x C) maximum section digest factor values, It becomes the value closest to the corresponding maximum interval conversation element value.

즉 최소하한값(MNBMN) 및 최대상한값(MXTMN)의 조합은, 도 5의 (d)(e)에 있어서 중단에 나타내는 인접 차분 화소값의 차분값의 최대 구간에 있어서의 차분값을, 최소값으로 하는 조합과 다름없다. 이와 같이 차분값이 최소값이 된다는 것의 의미는, 제 N 단색 화상으로부터 생성되는 모든 차분 화상에 대하여, 제 N 단색 화상마다 임계값을 설정하는 범위가 공통이 되도록 최소화되었다는 것이다. 따라서 최소하한값(MNBMN) 및 최대상한값(MXTMN)의 조합에 의해 구성되는 구간은, 상기 (B×C)개의 차분 화상의 모두에 대하여 확실하게 임계값을 설정하는 것이 가능해지는 구간이다. 이렇게 해서 최소하한값(MNBMN) 및 최대상한값(MXTMN)을 선출한 뒤, 스텝 S710으로 진행된다.That is, the combination of the minimum lower limit value MNBMN and the maximum upper limit value MXTMN makes the difference value in the maximum section of the difference value of the adjacent difference pixel value indicated in the middle in FIG. 5 (d) (e) the minimum value. It's like a combination. In this way, the meaning of the difference value being the minimum value is that the range in which the threshold value is set for each Nth monochrome image is common to all the differential images generated from the Nth monochrome image. Therefore, the section constituted by the combination of the minimum lower limit value MNBMN and the maximum upper limit value MXTMN is a section in which it is possible to reliably set a threshold value for all of the (B × C) difference images. In this way, after selecting the minimum lower limit value MNBMN and the maximum upper limit value MXTMN, the process proceeds to step S710.

스텝 S710에 있어서, K개의 단색 화상 각각에 대응하는 최소하한값(MNBMN) 및 최대상한값(MXTMN)에 대해서, 차분이 되는 범위(RN)=최소하한값(MNBMN)-최대상한값(MXTMN)을 산출한다. 이 범위(RN)는 전술한 바와 같이, B개의 불량 화상에 대응하는 K개의 단색 화상의 각각으로부터, 제 M 대칭축에 의거하여 생성한 차분 화상을 이용하여 산출했던 (B×C)개의 차분 화상의 모두에 대해서, 인접 차분 화소값의 차분값의 최대 구간(예를 들면 도 5의 (d)의 중단에 있어서 차분값 58을 갖는 구간)에 확실하게 임계값을 설정하는 것이 가능해지는 구간의 차분값이다. 스텝 S710에 있어서 범위(RN)를 산출하면, 스텝 S7을 종료하고 도 14의 (a)에 나타내는 스텝 S8로 진행된다.In step S710, the difference range (RN) = minimum lower limit value (MNBMN)-maximum upper limit value (MXTMN) is calculated for the minimum lower limit value (MNBMN) and the maximum upper limit value (MXTMN) corresponding to each of the K monochrome images. This range (RN) is as described above of (B × C) difference images calculated from each of the K monochrome images corresponding to the B defective images using the difference image generated based on the Mth axis of symmetry. For all, the difference value of the section in which it is possible to reliably set the threshold value in the maximum section of the difference value of the adjacent difference pixel value (for example, the section having the difference value 58 in the middle of Fig. 5D) to be. If the range RN is calculated in step S710, step S7 ends, and the process proceeds to step S8 shown in Fig. 14A.

(5.7) 스텝 S8(5.7) Step S8

도 14의 (a)에 있어서 스텝 S8은 임계값 화상 생성 공정이며, 검사 대상 영역을 선출하기 위한 임계값을 설정하는데 최적인 임계값 화상을 선출해서 임계값을 설정한다. 임계값 화상 생성 공정(S8)의 상세 플로우차트를 도 24에 나타낸다.In Fig. 14A, step S8 is a threshold image generation process, and an optimal threshold image is selected for setting a threshold for selecting an inspection subject area, and a threshold is set. 24 shows a detailed flowchart of the threshold image generation process (S8).

도 24의 스텝 S801에 있어서, 불량 화상으로부터 생성한 단색 화상의 수인 K가 2 이상인지의 여부에 대해 판단한다. 이것은 도 17(단색 화상 생성 공정(S3))에 나타내는 스텝 S301에 있어서, 검사 대상 워크의 화상은 컬러 화상인지의 여부 판단을 하고 있는 것과 동일한 내용이다. 즉 도 24의 스텝 S801에 있어서, 검사 대상 워크의 화상이 컬러 화상이면 단색 화상의 수 K는 2 이상이며, 검사 대상 워크의 화상이 컬러 화상이 아니면 단색 화상의 수 K는 1이어서, 이것은 2미만이 된다. 스텝 S801의 판단 결과가 Yes, 즉 불량 화상을 기초로 생성한 단색 화상의 수가 2 이상인 경우에는 스텝 S802로 진행된다.In step S801 of Fig. 24, it is determined whether or not K, which is the number of monochrome images generated from the defective images, is 2 or more. This is the same content as in step S301 shown in Fig. 17 (single color image generation step S3), in which it is determined whether or not the image of the work to be inspected is a color image. That is, in step S801 of Fig. 24, if the image of the workpiece to be inspected is a color image, the number K of monochrome images is 2 or more, and if the image of the workpiece to be inspected is not a color image, the number K of monochrome images is 1, which is less than 2 It becomes. If the determination result in step S801 is Yes, that is, the number of monochrome images generated based on the defective image is 2 or more, the process proceeds to step S802.

스텝 S802에 있어서, 전체 단색 화상으로부터 산출된 K개의 범위(RN)(1≤N≤K) 중에서 최대값을 선출하고, 이 최대값이 되는 범위(RN)를 갖는 차분 화상을 제 M 임계값 화상으로서 선출한다. 이 제 M 임계값 화상의 번호 M은 전술한 바와 같이, 원화상 즉 제 N 단색 화상이 가진 제 M 대칭축의 번호 M의 것이다. 즉, 대칭축의 번호에 대응한 임계값 화상을 선출하게 된다.In step S802, a maximum value is selected from among K ranges (RN) (1≤N≤K) calculated from all monochromatic images, and a difference image having a range (RN) that becomes the maximum value is the Mth threshold image. As elected. As described above, the number M of the Mth threshold image is the number M of the Mth axis of symmetry of the original image, that is, the Nth monochrome image. That is, a threshold image corresponding to the number of symmetry axes is selected.

여기서, 최대값이 되는 범위(RN)를 갖는 차분 화상을 제 M 임계값 화상으로서 선출한다는 것의 의미를 설명한다. 범위(RN)는 전술한 바와 같이, B개의 불량 화상을 기초로 생성한 제 N 단색 화상으로부터 생성한 차분 화상의 모두((B×C)개)에 대하여, 확실하게 임계값을 설정하는 것이 가능해지는 구간의 차분값이다. 이것이, 전술한 제 1 문제 즉 임계값이 차분 화상마다 편차가 생겨서, 하나로 정해지지 않는다는 문제를 해결하기 위한 수단에 해당한다. 또한, 이와 같이 산출한 범위(RN) 중에서 최대값을 선출하는 것은, 최소의 차분값으로서의 범위(RN)를 비교하여, 그것들 중에서 가장 임계값을 용이하게 설정하는 것이 가능해지는 최대값을 선출하는 것과 다름없다. 이 최대값이 되는 범위(RN)를 갖는 차분 화상의 선출이, 전술한 제 2 문제 즉 임계값 설정용의 단색 화상을 선출하는 기준이 필요한 문제를 해결하기 위한, 기준 설정에 해당한다.Here, the meaning of selecting the difference image having the range RN to be the maximum value as the Mth threshold image is explained. As described above, as described above, it is possible to reliably set a threshold value for all ((B x C)) differential images generated from the Nth monochrome image generated based on the B defective images. It is the difference value of the decreasing section. This corresponds to the means for solving the above-described first problem, that is, the threshold value is not determined by one because of the variation in each difference image. In addition, selecting the maximum value from the range RN calculated in this way compares the range RN as the minimum difference value, and selects the maximum value from which it is possible to easily set the most critical value among them. It is no different. The selection of the difference image having the range RN which becomes the maximum value corresponds to the reference setting for solving the above-described second problem, that is, a problem that requires a criterion for selecting a monochrome image for threshold setting.

이상을 정리하면, 도 5의 (d)(e)의 하단에 나타내는 임계값이 차분 화상마다 편차가 생기고, 하나로 정해지지 않는다는 전술한 제 1 문제를 해결하기 위해서, 도 22의 스텝 S710에 있어서 범위(RN)를 산출하고 있다. 이에 따라, 상기 차분 화상마다의 차분값의 편차를 해소하여, B개의 불량 화상을 기초로 생성한 제 N 단색 화상으로부터 생성한 차분 화상의 모두((B×C)개)에 대하여 단 하나의 임계값을 설정할 수 있게 된다. 또한, 임계값 설정용의 단색 화상을 선출하는 기준이 필요하게 된다는 상기의 제 2 문제를 해결하기 위해서, 도 24의 스텝 S802에 있어서 단색 화상의 수인 K에 대응하는 K개의 범위(RN) 중에서 최대값을 선출하고, 이 최대값이 되는 범위(RN)를 갖는 차분 화상을 제 M 임계값 화상으로서 선출하고 있다. 이에 따라, 상기 선출하는 기준을 명확화하여, 1개의 불량 화상을 기초로 생성한 복수의 단색 화상 중에서, 임계값을 설정하는데 최적인 단색 화상을 후속의 스텝 S803에 있어서 선출할 수 있다.Summarizing the above, in order to solve the above-mentioned first problem that the threshold value shown at the bottom of FIG. 5 (d) (e) is deviated for each difference image and is not determined as one, the range in step S710 of FIG. 22 ( RN). Accordingly, the difference in the difference value for each difference image is resolved, and only one threshold is set for all ((B × C)) difference images generated from the Nth monochrome images generated based on the B defective images. The value can be set. In addition, in order to solve the above-mentioned second problem that a criterion for selecting a monochrome image for threshold setting is necessary, in step S802 of FIG. 24, the maximum of K ranges (RN) corresponding to K, which is the number of monochrome images, A value is selected, and a difference image having a range RN that becomes the maximum value is selected as the Mth threshold image. Accordingly, the selection criteria are clarified, and among the plurality of monochromatic images generated based on one defective image, a monochromatic image optimal for setting a threshold can be selected in a subsequent step S803.

한편, 스텝 S801의 판단 결과가 No, 즉 불량 화상을 기초로 생성한 단색 화상의 수가 1인 경우에는 스텝 S804로 진행된다. 스텝 S804에 있어서는, 하나의 단색 화상으로부터 생성한 차분 화상을 제 M 임계값 화상으로 한다. 이와 같이 제 M 임계값 화상을 선출한 뒤, 스텝 S803으로 진행된다.On the other hand, when the determination result of step S801 is No, that is, the number of monochrome images generated based on the defective image is 1, the process proceeds to step S804. In step S804, a difference image generated from one single color image is taken as the Mth threshold image. After selecting the Mth threshold image in this way, the process proceeds to step S803.

스텝 S803에 있어서, 제 M 임계값 화상을 생성한 단색 화상을 제 M 임계값용 단색 화상으로서 선출한다. 이 제 M 임계값용 단색 화상은, 원화상이 가지는 제 M 대칭축에 대하여 도 5의 (d)(e)의 하단에 나타내는 이간 화소값 선출용의 임계값을 산출하기 위해서 사용하는 단색 화상이다. 제 M 임계값용 단색 화상을 선출한 뒤, 스텝 S805로 진행된다.In step S803, a monochrome image generating the Mth threshold image is selected as a monochrome image for the Mth threshold. This monochromatic image for the M threshold value is a monochromatic image used to calculate the threshold value for selecting the separated pixel values shown at the bottom of Fig. 5D (e) with respect to the Mth axis of symmetry of the original image. After selecting the monochrome image for the Mth threshold value, the process proceeds to step S805.

스텝 S805에서 제 M 임계값 화상에 있어서, 범위(RN)의 중앙값=(최소하한값(MNBMN)+최대상한값(MXTMN))/2을 산출하고, 그 값을 검사 대상 영역 선출용 임계값으로서의 제 M 검사 임계값으로 한다. 이 스텝 S805에 있어서 산출한 제 M 검사 임계값이, 도 5의 (d)(e)의 하단에 나타내는 차분값의 최대 구간에 있어서의 임계값에 대응한다. 이렇게 해서 제 M 검사 임계값을 설정한 뒤, 스텝 S806으로 진행된다.In step S805, in the Mth threshold image, the median value of the range RN = (minimum lower limit value (MNBMN) + maximum upper limit value (MXTMN)) / 2 is calculated, and the value is used as the threshold value for selecting an inspection target area Let it be the inspection threshold. The Mth inspection threshold value calculated in step S805 corresponds to the threshold value in the maximum section of the difference value shown at the bottom of Fig. 5D (e). After setting the Mth inspection threshold in this way, the process proceeds to step S806.

스텝 S806에 있어서, 레지스터 M에 저장한 대칭축의 번호가 대칭축의 수인 C에 도달하였는지의 여부에 대해 판단한다. 레지스터 M은 도 21에 나타내는 임계값 범위 설정 공정(S7)의 스텝 S707에 있어서 1씩 가산된다. 이 가산된 레지스터 M의 값에 대응하는 원화상은, 전술한 바와 같이 도 22 및 도 24에 의해 처리된다. 그리고 도 24의 스텝 S805에 있어서, 제 M 검사 임계값이 설정된다. 도 24의 스텝 S806에 있어서의 판단은, 제 N 단색 화상이 가지는 C개의 대칭축의 전부에 대응해서 제 M 검사 임계값이 설정되었는지의 여부의 판단과 다름없다. 이 판단 결과가 No인 경우에는, 모든 대칭축에 대응하는 제 M 검사 임계값이 설정되어 있지 않으므로, 도약처 번호 205가 기재되는 결합자를 경유해서 도 21(임계값 범위 설정 공정(S7))의 스텝 S707로 점프한다. 이 스텝 S707에 있어서는, 대칭축의 수를 저장하는 레지스터 M의 값에 1을 가산한다. 그리고, 지금까지의 설명과 마찬가지로, M의 값이 1만 커진 상태에서 도 22 및 도 24의 처리를 재차 실행한다. M의 값에 대한 1의 가산을 반복하면, 도 24(임계값 화상 생성 공정(S8))의 스텝 S806의 판단 결과가 Yes로 된다. 그 경우에는 스텝 S8을 종료하고 도 14의 (a)에 나타내는 스텝 S9로 진행된다.In step S806, it is determined whether the number of symmetric axes stored in the register M has reached C, the number of symmetric axes. The register M is added one by one in step S707 of the threshold value range setting process (S7) shown in FIG. The original image corresponding to the added register M value is processed by Figs. 22 and 24 as described above. Then, in step S805 of Fig. 24, the Mth inspection threshold is set. The determination in step S806 of Fig. 24 is nothing more than a determination as to whether or not the Mth inspection threshold is set corresponding to all of the C symmetry axes of the Nth monochrome image. When the determination result is No, since the Mth inspection threshold value corresponding to all the symmetry axes is not set, the step of FIG. 21 (threshold range setting process (S7)) via the combiner in which the jump destination number 205 is described. Jump to S707. In this step S707, 1 is added to the value of the register M that stores the number of symmetry axes. Then, as in the description so far, the processes of Figs. 22 and 24 are executed again with the value of M being increased by 10,000. If the addition of 1 to the value of M is repeated, the determination result in step S806 of Fig. 24 (threshold image generation process (S8)) becomes Yes. In that case, step S8 is terminated and the process proceeds to step S9 shown in Fig. 14A.

(5.8) 스텝 S9(5.8) Step S9

도 14의 (a)에 있어서 스텝 S9는 임계값 확인 공정이다. 이것은 양품 화상으로부터 생성한 차분 화상의 전체 화소의 화소값이 상기 제 M 검사 임계값보다 작은 것, 즉 양품 화상에 대하여 제 M 검사 임계값을 적용해도, 도 6의 (c)에 이중 테두리로 나타내는 바와 같은 결함 검사를 행해야 할 검사 대상 영역을 선출할 수 없는 것을 확인하는 공정이다. 임계값 확인 공정(S9)의 상세 플로우차트를 도 25및 도 26에 나타낸다.In Fig. 14A, step S9 is a threshold value confirmation process. This indicates that the pixel values of all the pixels of the difference image generated from the good image are smaller than the Mth inspection threshold, that is, even if the Mth inspection threshold is applied to the good image, it is represented by a double frame in Fig. 6C. It is a process of confirming that the inspection target area to which defect inspection as described above cannot be selected. 25 and 26 show detailed flowcharts of the threshold checking process (S9).

도 25에 있어서 스텝 S901 및 S902는, 도 15에 나타내는 기지 워크 촬상 공정(S1)에 나타내는 스텝 S101에 있어서 얻은 A개의 양품 화상에 대해서, 임계값 확인 공정을 실행하기 위한 준비이다. 먼저 스텝 S901에 있어서, 임계값 확인 공정에서 처리를 실행중인 양품 화상의 번호를 기억하는 레지스터 I에 0을 저장하고, 레지스터 I를 초기화한다. 이어서 스텝 S902에 있어서, I의 값에 1을 가산한다.In FIG. 25, steps S901 and S902 are preparations for performing a threshold value confirmation process with respect to the A quality goods images obtained in step S101 shown in the known work imaging process S1 shown in FIG. First, in step S901, 0 is stored in the register I that stores the number of a good product image that is being processed in the threshold checking process, and the register I is initialized. Next, in step S902, 1 is added to the value of I.

그리고 스텝 S903에 있어서, 1에서 A까지의 번호를 부여한 양품 화상 중에서 I의 값으로 지정되는 번호의 화상을 취출한다. 여기서는 I=1이다. 그리고 스텝 S904로 진행된다.Then, in step S903, an image of a number designated by the value of I is taken out of a quality product image numbered from 1 to A. Here, I = 1. Then, the process proceeds to step S904.

스텝 S904 및 S905는 각각, 도 16에 나타내는 검사 대상 워크 추출 공정(S2)의 스텝 S201 및 S202와 동일하다. 즉 스텝 S904 및 S905에 있어서, 양품 화상(1)으로부터 템플릿 매칭법을 이용하여 검사 대상 워크의 화상을 생성하고 있다. 이렇게 해서 검사 대상 워크의 화상을 생성한 뒤, 스텝 S906으로 진행된다.Steps S904 and S905 are the same as steps S201 and S202 of the work object extraction step (S2) shown in Fig. 16, respectively. That is, in steps S904 and S905, the image of the work to be inspected is generated from the good product image 1 using the template matching method. After the image of the work to be inspected is thus generated, the process proceeds to step S906.

스텝 S906 및 S907은, 양품 화상(1)을 기초로 생성한 단색 화상으로부터 생성한 차분 화상에 대하여, 임계값 확인 공정에 있어서의 후속의 스텝을 실행하기 위한 준비이다. 먼저 스텝 S906에 있어서, 임계값 확인 공정에서의 후속의 스텝에서 처리를 실행중인 단색 화상에 있어서의 대칭축의 번호를 기억하는 레지스터 M에 0을 저장하고, 레지스터 M을 초기화한다. 이어서 스텝 S907에 있어서, M의 값에 1을 가산한다.Steps S906 and S907 are preparations for executing a subsequent step in the threshold value confirmation process for the difference image generated from the monochrome image generated based on the good product image 1. First, in step S906, 0 is stored in the register M that stores the number of symmetry axes in the monochrome image that is being processed in a subsequent step in the threshold checking process, and the register M is initialized. Next, in step S907, 1 is added to the value of M.

다음으로 스텝 S908로 진행되고, 검사 대상 워크의 화상이 컬러인지의 여부에 대해서 판단한다. 판단이 Yes인 경우 즉 컬러 화상의 경우에는 스텝 S909로 진행된다. 스텝 S909에 있어서, 컬러 화상인 검사 대상 워크의 화상으로부터 K개의 단색 화상을 생성한다. 이 스텝 S909는 도 17에 나타내는 단색 화상 생성 공정(S3)에 있어서의 스텝 S302와 동일하다. K개의 단색 화상을 생성한 뒤, 스텝 S910으로 진행된다.Next, the process proceeds to step S908, and it is determined whether or not the image of the work to be inspected is a color. If the judgment is Yes, that is, in the case of a color image, the process proceeds to step S909. In step S909, K monochromatic images are generated from the image of the work to be inspected, which is a color image. This step S909 is the same as step S302 in the monochrome image generation process S3 shown in FIG. 17. After generating K monochromatic images, the process proceeds to step S910.

스텝 S910에 있어서, 생성한 단색 화상 중에서, 제 M 임계값 화상을 생성한 단색 화상에 대응하는 단색 화상을 제 M 임계값용 단색 화상으로 한다. 여기에서 전술한 바와 같이, 제 M 임계값 화상을 생성한 단색 화상을 제 M 임계값용 단색 화상으로서 선출하고 있는 것은, 도 24에 나타내는 임계값 화상 생성 공정(S8)의 스텝 S803이다. 즉, 스텝 S803에 있어서 선출한 제 M 임계값용 단색 화상과, 스텝 S910에 있어서 선출하는 제 M 임계값용 단색 화상을 대응시키고 있다는 것이다. 이와 같이 대응시키는 목적은, 제 M 임계값용 단색 화상을 이용하여 설정한 제 M 검사 임계값을 양품 화상에 대하여 적용해도, 전술한 바와 같이 도 6의 (c)에 이중 테두리로 나타내는 바와 같은 검사 대상 영역을 선출할 수 없는 것을 확인하기 위해서이다.In step S910, among the generated monochrome images, a monochrome image corresponding to the monochrome image that generated the Mth threshold image is taken as a monochrome image for the Mth threshold. As described above, it is step S803 of the threshold image generation process (S8) shown in FIG. 24 that the monochrome image for generating the Mth threshold image is selected as the monochrome image for the Mth threshold value. That is, the monochromatic image for the M threshold value selected in step S803 and the monochromatic image for the M threshold value selected in step S910 are correlated. The purpose of this correspondence is that, even if the Mth inspection threshold set using the monochrome image for the Mth threshold is applied to a good product image, the inspection subject as shown by the double border in FIG. This is to confirm that an area cannot be elected.

한편, 스텝 S908에 있어서의 판단이 No인 경우 즉 검사 대상 워크의 화상이 단색 화상인 경우에는, 스텝 S911로 진행된다. 스텝 911에 있어서, 상기 단색 화상 즉 검사 대상 워크의 화상을 제 M 임계값용 단색 화상으로 한다. 이렇게 해서, 스텝 S910 혹은 S911에 있어서 제 M 임계값용 화상을 선출하면, 도약처 번호 209가 기재되는 결합자를 경유해서 도 26의 스텝 S912로 점프한다.On the other hand, when the determination in step S908 is No, that is, when the image of the work to be inspected is a monochrome image, the process proceeds to step S911. In step 911, the monochromatic image, that is, the image of the work to be inspected is regarded as a monochromatic image for the Mth threshold. In this way, if the image for the Mth threshold value is selected in step S910 or S911, the process jumps to step S912 in Fig. 26 via a combiner in which the destination number 209 is described.

도 26의 스텝 S912에 있어서, 제 M 임계값용 단색 화상을 원화상이라고 하는 명칭의 레지스터에 저장한다. 다음으로 스텝 S913으로 진행되고, ONEM이라고 하는 명칭의 레지스터에 제 M 대칭축의 일단의 좌표를 저장한다. 이 스텝 S913은, 도 18에 나타내는 대칭성 판단 공정(S4)의 스텝 S405와 동일한 공정이다. 다음으로 스텝 S914로 진행되고, OTEM이라고 하는 명칭의 레지스터에 제 M 대칭축의 타단의 좌표를 저장한다. 이 스텝 S914는, 도 18에 나타내는 대칭성 판단 공정(S4)의 스텝 S406과 동일한 공정이다. 그리고, 스텝 S21로 진행되고, 도 20에 나타내는 서브루틴 Sub1을 실행한다. 서브루틴 Sub1에 대해서는 이미 설명하고 있으므로, 여기서는 상세한 설명은 생략한다.In step S912 of Fig. 26, a monochrome image for the Mth threshold value is stored in a register named original image. Next, the process proceeds to step S913, and a set of coordinates of the Mth axis of symmetry is stored in a register named ONEM. This step S913 is the same step as step S405 of the symmetry determination step S4 shown in FIG. 18. Next, the process proceeds to step S914, and the coordinates of the other end of the M-th axis of symmetry are stored in a register named OTEM. This step S914 is the same step as step S406 of the symmetry determination step S4 shown in FIG. 18. Then, the process proceeds to step S21, and the subroutine Sub1 shown in Fig. 20 is executed. Since the subroutine Sub1 has already been described, a detailed description is omitted here.

이 도 26에 있어서 스텝 S912 내지 스텝 S21(서브루틴 Sub1)을 실행함으로써, 도 25의 스텝 S910 혹은 S911에 있어서 선출한 제 M 임계값용 화상과 그 대칭축의 일단 및 타단의 좌표를 메인 프로그램으로부터 서브루틴 Sub1에 인수로서 전달하고, 서브루틴 Sub1이 이 제 M 임계값용 화상으로부터 생성한 차분 화상을, 메인 프로그램은 되돌림 값으로서 수취한다.By executing steps S912 to S21 (subroutine Sub1) in FIG. 26, the image for the Mth threshold value selected in step S910 or S911 in FIG. 25 and the coordinates of one end and the other end of the symmetry axis are subroutines from the main program. It is passed as an argument to Sub1, and the main program receives the difference image generated by the subroutine Sub1 from this Mth threshold image as a return value.

스텝 S21을 실행한 뒤, 되돌림 값으로서의 차분 화상에 대하여 스텝 S915를 실행한다. 스텝 S915에 있어서, 차분 화상의 전체 화소의 화소값이 제 M 검사 임계값보다 작은지의 여부를 판단한다. 이 판단 결과가 Yes인 경우에는, 이 차분 화상에 대하여 전술한 바와 같이, 도 6의 (c)에 이중 테두리로 나타내는 바와 같은 검사 대상 영역을 선출할 수 없는 것을 확인하게 된다. 그 경우에는, 스텝 S916으로 진행된다.After executing step S21, step S915 is executed for the difference image as the return value. In step S915, it is determined whether or not the pixel values of all the pixels of the difference image are smaller than the Mth inspection threshold. When the determination result is Yes, it is confirmed that the inspection target region cannot be selected as indicated by the double border in FIG. 6C as described above for this difference image. In that case, the process proceeds to step S916.

스텝 S916에 있어서, 레지스터 M에 저장한 대칭축의 번호가 대칭축의 수인 C에 도달했는지의 여부에 대해서 판단한다. 레지스터 M은 도 25의 스텝 S907에 있어서 1씩 가산된다. 이 가산된 레지스터 M의 값에 대응하는 원화상은, 전술한 바와 같이 스텝 S912 내지 스텝 S21에 의해 처리되어서 차분 화상이 생성된다. 그리고 스텝 S915에 있어서, 차분 화상의 전체 화소의 화소값이 제 M 검사 임계값보다 작은지의 여부를 판단한다. 스텝 S916에 있어서의 판단은, 검사 대상 워크의 화상이 가지는 C개의 대칭축의 전부에 대응하여, 상기 스텝 S915의 판단이 행해졌는지의 여부의 판단과 다름없다. 이 스텝 S916의 판단 결과가 No인 경우에는, 모든 대칭축에 대응하는 차분 화상에 대하여 스텝 S915의 판단이 행해지고 있지 않으므로, 도약처 번호 208이 기재되는 결합자를 경유해서 도 25의 스텝 S907로 점프한다. 이 스텝 S907에 있어서는, 대칭축의 수를 저장하는 레지스터 M의 값에 1을 가산한다. 그리고, 지금까지의 설명과 마찬가지로, M의 값이 1만큼 커진 상태에서 도 25의 스텝 S908 내지 도 26의 스텝 S915를 재차 실행한다. M의 값에 대한 1의 가산을 반복하면, 스텝 S916의 판단 결과가 Yes로 된다. 그 경우에는 스텝 S917로 진행된다.In step S916, it is determined whether or not the number of symmetric axes stored in the register M has reached C, the number of symmetric axes. Register M is added one by one in step S907 of FIG. The original image corresponding to the added value of the register M is processed in steps S912 to S21 as described above to generate a difference image. In step S915, it is determined whether or not the pixel values of all the pixels of the difference image are smaller than the Mth inspection threshold. The determination in step S916 is equivalent to the determination as to whether or not the determination in step S915 has been made corresponding to all of the C symmetric axes of the image of the work to be inspected. When the determination result of Step S916 is No, since the determination of Step S915 is not made on the difference images corresponding to all the symmetry axes, the process jumps to Step S907 of Fig. 25 via the coupler described in the jump destination number 208. In this step S907, 1 is added to the value of the register M that stores the number of symmetry axes. Then, as in the description so far, the steps S908 to 26 of FIG. 25 are executed again while the value of M is increased by one. If the addition of 1 to the value of M is repeated, the determination result in step S916 is Yes. In that case, the process proceeds to step S917.

스텝 S917에 있어서, 레지스터 I에 저장한 양품 화상의 번호가 양품 화상의 수인 A에 도달했는지의 여부에 대해 판단한다. 레지스터 I는 도 25의 스텝 S902에 있어서 1씩 가산된다. 이 가산된 레지스터 I의 값에 대응하는 양품 화상은, 전술한 바와 같이 도 25의 스텝 S903 내지 도 26의 스텝 S916에 의해 처리된다. 그리고 당해의 양품 화상의 모든 대칭축에 대응하는 차분 화상의 전체 화소의 화소값이, 제 M 검사 임계값보다 작은지의 여부를 판단하고 있다. 스텝 S917에 있어서의 판단은, A개의 양품 화상의 전부에 대해서, 모든 대칭축에 대응하는 차분 화상의 전체 화소의 화소값이 제 M 검사 임계값보다 작은 것을 확인했는지의 여부의 판단과 다름없다. 이 스텝 S917의 판단 결과가 No인 경우에는, A개의 양품 화상의 전부에 대해서, 모든 대칭축에 대응하는 차분 화상의 전체 화소의 화소값이 제 M 검사 임계값보다 작은 것을 확인하고 있지 않다. 이 때문에, 도약처 번호 207이 기재되는 결합자를 경유해서 도 25의 스텝 S902로 점프한다. 이 스텝 S902에 있어서는, 양품 화상의 수를 저장하는 레지스터 I의 값에 1을 가산한다.In step S917, it is judged whether or not the number of the good product images stored in the register I has reached A, which is the number of good product images. Register I is added one by one in step S902 of FIG. A good product image corresponding to the added register I value is processed by step S903 in Fig. 25 to step S916 in Fig. 26 as described above. Then, it is judged whether or not the pixel values of all the pixels of the difference image corresponding to all the symmetry axes of the good product image are smaller than the Mth inspection threshold. The determination in step S917 is nothing more than a determination as to whether or not all of the A good-quality images have been confirmed to have the pixel values of all the pixels of the difference image corresponding to all symmetry axes smaller than the Mth inspection threshold. When the determination result of Step S917 is No, it is not confirmed that the pixel values of all the pixels of the difference image corresponding to all the symmetry axes are smaller than the Mth inspection threshold value for all of the A good quality images. For this reason, it jumps to step S902 of FIG. 25 via the combiner in which the jump destination number 207 is described. In this step S902, 1 is added to the value of the register I that stores the number of good products images.

그리고, 지금까지의 설명과 마찬가지로 I의 값이 1만큼 커진 상태에서, 도 25의 스텝 S903 내지 도 26의 스텝 S916의 공정을 재차 실행한다. I의 값에 대한 1의 가산을 반복하면, 도 26의 스텝 S917의 판단 결과가 Yes로 된다. 그 경우에는 스텝 S9를 종료하고, 도 14의 (a)의 최하부에 나타내는 도약처 번호 101이 기재되는 결합자를 경유해서 도 14의 (b)의 스텝 S10으로 점프한다. 한편 전술한 바와 같이 도 14의 (a)는 임계값 설정 모드이며, 도 14의 (b)는 검사 실행 모드이다. 따라서, 스텝 S9를 종료한 단계에서 임계값 설정 모드를 종료하고, 검사 실행 모드를 시작하게 된다.Then, in the state that the value of I is increased by 1, as in the previous description, the steps of Step S903 in FIG. 25 to Step S916 in FIG. 26 are executed again. If the addition of 1 to the value of I is repeated, the determination result of step S917 in Fig. 26 is Yes. In that case, step S9 is ended, and jump is made to step S10 in Fig. 14B via a combiner in which the jump destination number 101 shown at the bottom of Fig. 14A is described. Meanwhile, as described above, FIG. 14 (a) is a threshold setting mode, and FIG. 14 (b) is a test execution mode. Therefore, the threshold setting mode is ended in the step where step S9 is ended, and the inspection execution mode is started.

한편, 도 26에 있어서 스텝 S915의 판단 결과가 No인 경우는, 양품 화상에 대하여 제 M 검사 임계값을 적용하면, 검사 대상 영역이 선출되는 것을 의미한다. 그래서 스텝 S918로 진행되고, 검사 대상 영역이 선출되는 원인을 조사해서 당해 원인을 제거하는 대책을 행한다. 대책을 행한 뒤, 도약처 번호 201이 기재되는 결합자를 경유해서 도 15의 기지 워크 촬상 공정(S1)의 스텝 S103으로 점프한다. 그리고 재차 도 14의 (a)에 나타내는 임계값 설정 모드를 실행한다. 이 재차 실행에 있어서, 도 24의 임계값 화상 생성 공정(S8)에 있어서의 스텝 S802 내지 S805에서 제 M 임계값 화상, 제 M 임계값용 단색 화상을 선출하여, 제 M 검사 임계값을 설정한다. 그리고 다시 도 26의 스텝 S915에 있어서, 차분 화상의 전체 화소의 화소값이 제 M 검사 임계값보다 작은지의 여부를 판단한다. 이 판단 결과가 Yes로 될 때까지, 스텝 S918의 원인 조사 및 대책과, 임계값 설정 모드의 재차 실행을 반복한다. 판단 결과가 Yes로 되면, 전술한 바와 같이 스텝 S916의 판단 및 스텝 S917의 판단이 함께 Yes로 될 때까지, 임계값 확인 공정(S9)을 실행한다. S917의 판단 결과가 Yes로 되면, 전술한 바와 같이 스텝 S9를 종료하고 임계값 설정 모드를 종료한다. 그리고 도 14의 (b)에 나타내는 검사 실행 모드의 스텝 S10으로 점프한다.On the other hand, when the determination result in step S915 is No in Fig. 26, it means that the inspection target region is selected when the Mth inspection threshold is applied to the good image. Therefore, the process proceeds to step S918, and the cause of the selection of the region to be inspected is investigated, and countermeasures to eliminate the cause are taken. After taking countermeasures, the process jumps to step S103 of the known work imaging step (S1) of FIG. 15 via a combiner in which the destination number 201 is described. Then, the threshold setting mode shown in Fig. 14A is executed again. In this execution again, the Mth threshold image and the monochrome image for the Mth threshold value are selected in steps S802 to S805 in the threshold image generation process (S8) of FIG. 24 to set the Mth inspection threshold. In step S915 of FIG. 26 again, it is determined whether or not the pixel values of all the pixels of the difference image are smaller than the Mth inspection threshold. Until the determination result is Yes, the cause investigation and countermeasure in step S918 and the execution of the threshold setting mode are repeated again. If the determination result is Yes, as described above, until the determination of step S916 and the determination of step S917 together become Yes, the threshold checking process (S9) is executed. If the determination result of S917 is Yes, as described above, step S9 ends and the threshold setting mode ends. Then, the process jumps to step S10 in the test execution mode shown in Fig. 14B.

이어서 도 14의 (b) 및 도 27 내지 도 31을 사용하여, 검사 실행 모드에 대해 설명한다.Next, the test execution mode will be described with reference to Figs. 14B and 27 to 31.

(5.9) 스텝 S10(5.9) Step S10

도 14의 (b)에 있어서 스텝 S10은 피검사 워크 촬상 공정이며, 피검사 워크를 촬상한다. 피검사 워크 촬상 공정(S10)의 상세 플로우차트를 도 27에 나타낸다.In FIG. 14B, step S10 is an imaging process of the inspection object, and imaging the inspection object. 27 shows a detailed flowchart of the inspection work imaging step (S10).

도 27에 나타내는 스텝 S1001에 있어서, 피검사 워크를 촬상한다. 스텝 S1001을 종료하면 스텝 S10을 종료하고, 도 14의 (b)에 나타내는 스텝 S2로 진행된다. 도 14의 (b)에 있어서 스텝 S2는 검사 대상 워크 추출 공정이며, 도 14의 (a)에 나타내는 스텝 S2와 동일한 공정이다. 즉, 피검사 워크의 화상으로부터 템플릿 매칭법을 이용하여 워크의 최외측 가장자리를 탐색해서 확정하고, 검사 대상 워크의 화상을 생성한다. 스텝 S2를 종료하면, 도 14의 (b)에 나타내는 스텝 S11로 진행된다.In step S1001 shown in Fig. 27, the work to be inspected is imaged. When step S1001 ends, step S10 ends, and the process proceeds to step S2 shown in Fig. 14B. In FIG. 14 (b), step S2 is a work extraction process to be inspected, and is the same process as step S2 shown in FIG. 14 (a). That is, the outermost edge of the work is searched and determined from the image of the work to be inspected using a template matching method, and an image of the work to be inspected is generated. When step S2 ends, the process proceeds to step S11 shown in Fig. 14B.

(5.10) 스텝 S11(5.10) Step S11

도 14의 (b)에 있어서 스텝 S11은 피검사 단색 화상 생성 공정이며, 스텝 S2에서 생성한 검사 대상 워크의 화상으로부터 단색 화상을 생성한다. 피검사 단색 화상 생성 공정(S11)의 상세 플로우차트를 도 28에 나타낸다.In FIG. 14B, step S11 is a process of generating a single object image to be inspected, and a single image is generated from the image of the work to be inspected generated in step S2. 28 shows a detailed flowchart of the inspection subject monochrome image generation process (S11).

도 28에 나타내는 스텝 S1101에 있어서, 레지스터 M에 0을 저장하고, 레지스터 M을 초기화한다. 여기에 레지스터 M은, 후속의 스텝 S1102 이후의 피검사 단색 화상 생성 공정 및 도 14의 (b)에 나타내는 후속의 스텝 S12 및 S13에서 처리를 실행중인 단색 화상에 있어서의 대칭축의 번호를 기억하는 레지스터이다. 이 대칭축의 번호는, 예를 들면 이전 공정인 도 14의 (a)의 임계값 설정 모드에 있어서의 스텝 S4(대칭성 판단 공정)에 있어서 설정되어 있다. 구체적으로는, 도 18에 나타내는 대칭성 판단 공정(S4)의 스텝 S402에 있어서, 레지스터 C에 대칭축의 수를 저장하고 있다. 이 레지스터 C의 값은, 이 스텝 S402에 있어서 설정된 뒤, 그대로의 값이다.In step S1101 shown in Fig. 28, 0 is stored in the register M, and the register M is initialized. Here, the register M is a register that stores the number of symmetry axes in the monochrome image generating process to be inspected after step S1102 and subsequent steps S12 and S13 shown in Fig. 14B. to be. The number of the axis of symmetry is set in step S4 (symmetry determining step) in the threshold setting mode of Fig. 14A, which is the previous step, for example. Specifically, in step S402 of the symmetry determination step (S4) shown in Fig. 18, the number of symmetry axes is stored in the register C. The value of this register C is the same value after being set in step S402.

다음으로 스텝 S1102에 있어서, 검사 대상 워크의 화상의 전체 화소에 대해서, 화소값을 최대 화소값으로 치환한 화상을, 이전 화상이라는 명칭의 레지스터에 저장한다. 이 레지스터 이전 화상의 작용에 대해, 이하에 설명한다.Next, in step S1102, for all the pixels of the image of the work to be inspected, the image in which the pixel value is replaced with the maximum pixel value is stored in a register named the previous image. The operation of the image before this register will be described below.

본 발명의 화상 처리 알고리즘에 대해서, 이미 도 5를 사용하여 설명하고 있다. 그 설명에 있어서, 도 5의 (a)에 나타내는 2개의 대칭축으로서의 제 1 직선(L1) 및 제 2 직선(L2)을 정의하고 있다. 이들 대칭축에 대응하는 차분 화상이 도 5의 (b) 및 도 5의 (c)이다. 그리고, 각각의 차분 화상인 도 5의 (b) 및 도 5의 (c)의 전체 화소 중에서 선출한 이간 화소를, 도 6의 (a) 및 도 6의 (b)에 화소값을 이중 테두리로 둘러싸는 것에 의해 표시하고 있다. 이들 이간 화소를 선출한 뒤, 도 6의 (a) 및 도 6의 (b)에 나타내는 이간 화소의 공통 부분을 선출하고, 이 공통 부분을 검사 대상 영역으로 하고 있다. 이 도 6에 있어서의 이간 화소의 공통 부분의 선출은, 복수의 대칭축에 대응하는 차분 화상을 동시에 생성하고, 각 차분 화상으로부터 이간 화소를 선출한 뒤, 각각의 이간 화소의 공통 부분을 선출하는 개념으로 되어 있다. 그러나, 소프트웨어를 이용하여 복수의 대칭축에 대응하는 처리를 동시에, 즉 병렬로 실행하는 것은 현실적이지 않다. 그 이유는, 이러한 병렬 처리를 행하기 위해서는, 복수의 차분 화상의 전체 화소값을 기억하기 위한 방대한 기억 영역을 확보하고, 또한 그 기억 영역에의 화소값의 기입 및 판독을 행하는 스텝이 필요하기 때문이다. 이 때문에 본 발명의 화상 처리 알고리즘을 이용한 결함 검사 방법에 있어서는, 도 5의 (b) 내지 도 6의 (c)의 공정을 소프트웨어에 의해 실행하기 위해서, 이하의 방법을 취하는 것으로 했다.The image processing algorithm of the present invention has already been described with reference to FIG. 5. In the description, the first straight line L1 and the second straight line L2 as two symmetrical axes shown in Fig. 5A are defined. The differential images corresponding to these symmetry axes are shown in Figs. 5 (b) and 5 (c). Then, the separated pixels selected from all the pixels in Figs. 5 (b) and 5 (c) which are the difference images, and the pixel values are doubled in Figs. 6 (a) and 6 (b). It is indicated by surrounding. After the separation pixels are selected, a common portion of the separation pixels shown in Figs. 6A and 6B is selected, and this common portion is used as an inspection target region. The concept of selecting the common portion of the interstitial pixels in FIG. 6 is to generate differential images corresponding to a plurality of symmetry axes at the same time, select the interstitial pixels from each differential image, and then select a common portion of each interstitial pixel. It is made. However, it is not practical to execute processing corresponding to a plurality of symmetry axes simultaneously, ie in parallel, using software. The reason is that in order to perform such parallel processing, steps to secure a large storage area for storing all pixel values of a plurality of difference images and to write and read pixel values to the storage area are necessary. to be. For this reason, in the defect inspection method using the image processing algorithm of the present invention, it is assumed that the following method is taken in order to execute the steps of Figs. 5 (b) to 6 (c) by software.

먼저 도 20에 나타내는 서브루틴 Sub1에, 메인 프로그램으로부터 인수로서 원화상(검사 대상 워크의 화상으로부터 생성한 단색 화상)과 제 1 대칭축의 일단(ONEM) 및 타단(OTEM)의 좌표를 전달한다. 서브루틴 Sub1은 원화상을 기초로 제 1 대칭축에 대응하는 차분 화상을 생성하고, 메인 프로그램에 되돌림 값으로서 되돌린다. 메인 프로그램은 수취한 차분 화상에 대하여, 임계값 설정 모드에서 설정한 제 M 검사 임계값을 이용하여 이간 화소를 선출한다. 이 이간 화소의 배치되는 위치가, 제 1 대칭축에 대응하는 검사 대상 영역이 된다.First, to the subroutine Sub1 shown in Fig. 20, the coordinates of the original image (a monochrome image generated from the image of the workpiece to be inspected) and one end (ONEM) and the other end (OTEM) of the first axis of symmetry are transmitted as arguments from the main program. The subroutine Sub1 generates a difference image corresponding to the first symmetry axis based on the original image, and returns it as a return value to the main program. The main program selects the separated pixels using the Mth inspection threshold set in the threshold setting mode for the received difference image. The position where the spaced pixels are arranged becomes an inspection target area corresponding to the first axis of symmetry.

다음으로 대칭축의 번호를 저장하고 있는 레지스터 M에 1을 가산함으로써 M=2로 한다. 이에 따라, 다음에 서브루틴 Sub1에 메인 프로그램으로부터 전달하는 인수는 제 2 대칭축에 관한 것이 된다. 그리고 마찬가지로 서브루틴 Sub1에 있어서, 원화상을 기초로 제 2 대칭축에 대응하는 차분 화상의 생성을 행한다. 그리고 마찬가지로 메인 프로그램에 있어서, 제 2 대칭축에 대응하는 검사 대상 영역의 선출을 행한다.Next, let M = 2 by adding 1 to the register M storing the number of symmetry axes. Accordingly, the argument that is then passed from the main program to the subroutine Sub1 is related to the second axis of symmetry. And similarly, in subroutine Sub1, a differential image corresponding to the second axis of symmetry is generated based on the original image. In the same way, in the main program, an inspection target area corresponding to the second axis of symmetry is selected.

그리고 제 2 대칭축에 대응하는 검사 대상 영역과, 앞에서 선출한 제 1 대칭축에 대응하는 검사 대상 영역의 공통 부분을 새로운 검사 대상 영역으로 한다. 즉, 제 (M+1) 대칭축 및 제 M 대칭축에 대응하는 2개의 검사 대상 영역의 공통 부분을 새로운 검사 대상 영역으로 한다. 이러한 공정을 생각하면, 제 (M+1) 대칭축에 대응하는 검사 대상 영역을 선출하기 까지의 동안에, 제 M 대칭축에 대응하는 검사 대상 영역을 레지스터에 저장해 둘 필요가 있다. 이 레지스터를 이전 화상이라는 명칭으로 미리 확보하고, 거기에 초기값으로서 검사 대상 워크의 화상을 저장하고 있는 것이, 상기의 스텝 S1102이다. 여기에, 스텝 S1102에 있어서 검사 대상 워크의 화상의 전체 화소에 대해서, 화소값을 최대 화소값으로 치환한 화상을 저장하고 있다. 그 이유를 이하에 기술한다.In addition, a common part of the inspection target area corresponding to the second symmetric axis and the inspection target area corresponding to the first symmetric axis previously selected is taken as a new inspection target area. That is, the common portion of the two inspection target regions corresponding to the (M + 1) symmetry axis and the M symmetry axis is taken as a new inspection target region. Considering such a process, it is necessary to store the inspection target area corresponding to the M-th symmetry axis in a register while selecting an inspection target area corresponding to the (M + 1) -th axis of symmetry. It is said step S1102 that this register is secured in advance under the name of the previous image, and the image of the work to be inspected is stored therein as an initial value. Here, in step S1102, an image in which the pixel value is replaced with the maximum pixel value is stored for all the pixels of the image of the work to be inspected. The reason is described below.

전술한 바와 같이 검사 대상 영역이란, 검사 대상 워크의 화상에 있어서 결함이 존재할 가능성이 있는 영역 즉 결함 검사를 행해야 할 영역이다. 이 때문에, 검사 대상 워크의 화상에 대하여 결함 검사를 행할 때의 참조용 화상으로서, 검사 대상 영역과 그 이외의 영역을 명확하게 식별하는 것이 가능한 화상을 생성할 필요가 있다. 그래서 본 발명에 있어서는, 상기 참조용 화상으로서 검사용 화상을 생성하는 것으로 했다. 검사용 화상은 검사 대상 영역에 최대 화소값을 갖는 화소를 배치하고, 검사 대상 영역 이외의 영역에 최소 화소값을 갖는 화소를 배치한 화상으로서 생성한다. 이것에 대응하기 위해서, 검사 대상 워크의 화상에 있어서 모든 영역이 검사 대상 영역이 되는 화상을, 이전 화상의 초기값(이하, 초기 이전 화상)으로서 최초에 생성해 둔다. 이것이 도 28의 스텝 S1102에 있어서 레지스터 이전 화상에 저장된다. 그리고 전술한 바와 같이, 후속의 스텝에 있어서 검사 대상 워크의 화상이 가지는 대칭축(C개) 중 제 1 대칭축에 대응하는 검사 대상 영역으로서의 이간 화소를 선출한다.As described above, the inspection target area is an area where defects may be present in an image of a work to be inspected, that is, an area where defect inspection is to be performed. For this reason, it is necessary to generate an image capable of clearly discriminating the inspection target area and other areas as a reference image when performing defect inspection on the image of the work to be inspected. Therefore, in the present invention, it is assumed that an inspection image is generated as the reference image. The inspection image is generated as an image in which pixels having a maximum pixel value are arranged in an inspection target area, and pixels having a minimum pixel value are arranged in an area other than the inspection target area. To cope with this, an image in which all areas in the image of the work to be inspected becomes the inspection subject area is first generated as an initial value of the previous image (hereinafter, the initial previous image). This is stored in the image before the register in step S1102 in Fig. 28. Then, as described above, in the subsequent step, an intersecting pixel is selected as a region to be inspected corresponding to the first axis of symmetry among the axis of symmetry (C) of the image of the workpiece to be inspected.

다음으로 이 제 1 대칭축에 대응하는 검사 대상 영역과 초기 이전 화상에 있어서의 검사 대상 영역의 공통 부분을 선출한다. 그리고 이 공통 부분을 검사 대상 영역으로서 가지는 새로운 이전 화상을 생성한다. 이후에, 이 새로운 이전 화상의 생성을 이전 화상의 갱신이라고 부른다. 여기서, 제 1 대칭축에 대응하는 이전 화상의 갱신 시에는, 제 1 대칭축에 대응하는 검사 대상 영역과 초기 이전 화상의 검사 대상 영역에 대해서, 반드시 공통 부분을 선출하는 것이 가능하지 않으면 안된다. 그 조건은, 초기 이전 화상의 모든 영역이 검사 대상 영역으로 되는 것이다. 이 때문에, 스텝 S1102에 있어서 레지스터 이전 화상에 저장하는 초기 이전 화상은, 모든 영역이 검사 대상 영역이 되도록 전체 화소값을 최대 화소값으로 하고 있다. 그리고 제 1 대칭축에 대응해서 이전 화상을 갱신한 뒤, 대칭축의 번호를 저장한 레지스터 M에 1을 가산해서 마찬가지의 공정을 실행한다. 이것을 레지스터 M이 상기 대칭축의 수 C에 도달할 때까지 반복한다. 그리고 C에 도달한 시점에서, 최후에 갱신한 이전 화상을 검사용 화상으로 하면 된다.Next, a common portion of the inspection target area corresponding to the first symmetry axis and the inspection target area in the initial previous image is selected. Then, a new previous image having this common portion as an inspection target area is generated. Hereinafter, the creation of this new previous image is called updating of the previous image. Here, when updating the previous image corresponding to the first axis of symmetry, it is necessary to be able to select a common portion for the inspection target area corresponding to the first axis of symmetry and the inspection target area of the initial previous image. The condition is that all areas of the initial previous image become the inspection target area. For this reason, in step S1102, the initial previous image stored in the previous image of the register is set to the maximum pixel value so that all regions are the inspection target region. Then, after updating the previous image corresponding to the first axis of symmetry, the same process is performed by adding 1 to the register M storing the number of the axis of symmetry. This is repeated until the register M reaches the number C of said symmetry axes. Then, at the point of reaching C, the previous image that was updated last may be used as the inspection image.

이렇게 해서 도 28의 스텝 S1102에서 레지스터 이전 화상의 초기화를 행한 뒤, 스텝 S1103으로 진행된다. 스텝 S1103에 있어서, 대칭축의 번호를 저장한 레지스터 M의 값에 1을 가산한다. 이어서 스텝 S1104 내지 S1108에 있어서, 피검사 단색 화상을 생성해서 레지스터 원화상에 저장한다. 이들 스텝 중 스텝 S1104 내지 스텝 S1107은, 각각 도 25에 나타내는 임계값 확인 공정(S9)에 있어서의 스텝 S908 내지 S911과 동일하다. 따라서, 상세한 설명은 생략한다. 스텝 S1108에 있어서, 피검사 단색 화상을 레지스터 원화상에 저장하면 스텝 S11을 종료하고, 도 14의 (b)에 나타내는 스텝 S5로 진행된다.In this way, after initializing the image before the register in step S1102 in Fig. 28, the process proceeds to step S1103. In step S1103, 1 is added to the value of the register M storing the number of symmetry axes. Next, in steps S1104 to S1108, a monochrome image to be inspected is generated and stored in the original register image. Among these steps, steps S1104 to S1107 are the same as steps S908 to S911 in the threshold value confirmation process (S9) shown in FIG. 25, respectively. Therefore, detailed description is omitted. In step S1108, if the monochromatic image to be inspected is stored in the register original image, step S11 ends, and the process proceeds to step S5 shown in Fig. 14B.

도 14의 (b)에 있어서 스텝 S5는 차분 산출 공정이며, 거기에 이어지는 스텝 S6은 차분 화상 생성 공정이다. 이들 공정은 전술한 바와 같이 도 19 및 도 20의 서브루틴 Sub1을 사용하여, 상기 도 28의 스텝 S1108에서 설정한 원화상으로부터 차분 화상을 생성한다. 따라서, 상세한 설명은 생략한다. 도 14의 (b)에 있어서 스텝 S5 및 스텝 S6을 종료하면, 스텝 S12로 진행된다.In FIG. 14B, step S5 is a difference calculation process, and step S6 following it is a difference image generation process. These steps use the subroutine Sub1 in Figs. 19 and 20 as described above to generate a difference image from the original image set in step S1108 in Fig. 28 above. Therefore, detailed description is omitted. When step S5 and step S6 are completed in Fig. 14B, the process proceeds to step S12.

(5.11) 스텝 S12(5.11) Step S12

도 14의 (b)에 있어서 스텝 S12는 검사 영역 선출 공정이며, 스텝 S6에 있어서 생성한 차분 화상을 이용하여, 검사 대상 영역의 후보가 되는 영역을 갖는 영역 후보 화상을 생성한다. 검사 영역 선출 공정(S12)의 상세 플로우차트를 도 29에 나타낸다.In FIG. 14B, step S12 is an inspection area selection process, and using the difference image generated in step S6, an area candidate image having an area to be a candidate for the inspection target area is generated. 29 shows a detailed flowchart of the inspection region selection process (S12).

도 29의 스텝 S1201에 있어서, 차분 화상의 전체 화소 중에서 제 M 검사 임계값보다 큰 화소값을 갖는 화소를, 검사 영역 화소로서 선출한다. 이 공정은, 차분 화상의 전체 화소 중에서 도 5의 (d)(e)에 나타내는 이간 화소를 선출하는 것과 동일한 내용이다. 단, 이 스텝 S1201은 검사 대상 영역을 선출하기 위한 준비로서의 공정이기 때문에, 선출한 화소의 명칭을 검사 영역 화소라고 하고 있다. 스텝 S1201에 있어서 검사 영역 화소를 선출한 뒤, 스텝 S1202로 진행된다.In step S1201 of FIG. 29, a pixel having a pixel value greater than the Mth inspection threshold value among all pixels of the difference image is selected as the inspection area pixel. This step is the same as selecting the distant pixels shown in Fig. 5 (d) (e) among all the pixels of the difference image. However, since this step S1201 is a process as preparation for selecting an inspection target area, the name of the selected pixel is referred to as an inspection area pixel. After selecting the inspection area pixel in step S1201, the process proceeds to step S1202.

스텝 S1202는, 전술한 검사 대상 영역과 그 이외의 영역을 명확하게 식별하는 화상, 즉 검사용 화상을 생성하기 위한 이전 공정이다. 먼저, 차분 화상을 검사 영역 화소와 검사 영역 화소 이외의 화소로 구분한다. 다음으로, 검사 영역 화소의 위치에 최대 화소값을 갖는 영역 지정 화소를 배치하는 동시에, 검사 영역 화소 이외의 화소의 위치에 최소 화소값을 갖는 검사외 화소를 배치하고, 영역 후보 화상을 생성한다. 이 공정에 의해 생성된 영역 후보 화상은, 검사 영역 화소의 화소값과 검사외 화소의 화소값의 대비에 의해, 검사 대상 영역과 그 이외의 영역을 명확하게 식별하는 것이 가능해진다. 스텝 S1202에서 영역 후보 화상을 생성하면 스텝 S12를 종료하고, 도 15의 (b)에 나타내는 스텝 S13으로 진행된다.Step S1202 is a previous process for generating an image that clearly identifies the above-described inspection target region and other regions, that is, an inspection image. First, the difference image is divided into pixels other than the inspection area pixel and the inspection area pixel. Next, an area designating pixel having a maximum pixel value is placed at the position of the inspection area pixel, and an non-exam pixel having a minimum pixel value is placed at a position other than the inspection area pixel, and an area candidate image is generated. The region candidate image generated by this process can clearly identify the region to be inspected and other regions by contrasting the pixel values of the inspection region pixels with the pixel values of the non-inspection pixels. If an area candidate image is generated in step S1202, step S12 ends, and the process proceeds to step S13 shown in Fig. 15B.

(5.12) 스텝 S13(5.12) Step S13

스텝 S13은 검사용 화상 생성 공정이며, 스텝 S12에서 생성한 영역 후보 화상에 의거하여 검사용 화상을 생성한다. 검사용 화상 생성 공정(S13)의 상세 플로우차트를 도 30에 나타낸다.Step S13 is an inspection image generation process, and an inspection image is generated based on the area candidate image generated in step S12. 30 shows a detailed flowchart of the inspection image generation process (S13).

도 30의 스텝 S1301에서 이전 화상과 영역 후보 화상에 대해서, 영역 지정 화소의 공통 부분이 되는 공통 지정 화소를 선출한다. 이 공정은 전술한 바와 같이, 대칭축에 대응해서 검사 대상 영역을 생성할 때마다, 이 생성한 검사 대상 영역과 이전 화상의 공통 부분을 선출하고, 이전 화상을 갱신하기 위한 것이다. 이 스텝 S1301에 있어서 공통 지정 화소 즉 공통 부분을 선출한 뒤, 스텝 S1302로 진행된다.In step S1301 of FIG. 30, a common designated pixel that becomes a common part of the area designated pixel is selected for the previous image and the area candidate image. As described above, this process is for selecting a common portion of the generated inspection target region and the previous image whenever the inspection target region is generated corresponding to the axis of symmetry, and updating the previous image. After selecting a common designated pixel, that is, a common portion in step S1301, the process proceeds to step S1302.

스텝 S1302에 있어서는 공통 지정 화소의 위치에 최대 화소값을 갖는 공통 지정 화소를 배치하는 동시에, 공통 지정 화소 이외의 화소의 화소값을 최소 화소값으로 하여, 갱신 후보 화상을 생성한다. 이 스텝 S1302에서는, 이전 화상에 있어서 최대 화소값을 갖는 화소가 배치되어 있었던 위치에 무관하게, 스텝 S1301에서 선출한 공통 지정 화소 이외의 화소의 화소값을 최소 화소값으로 한다. 즉, 이전 화상에 있어서 최대 화소값을 갖는 화소가 배치되어 있는 위치여도, 스텝 S1301에서 선출한 공통 지정 화소가 당해 위치에 배치되지 않을 때에는, 당해 위치에 배치되는 화소의 화소값은 최소 화소값으로 갱신된다. 이렇게 해서 이전 화상의 갱신이 완료되고, 갱신 후의 화상은 갱신 후보 화상이 된다. 스텝 S1302에 있어서 갱신 후보 화상을 생성한 뒤, 스텝 S1303으로 진행된다.In step S1302, a common designated pixel having a maximum pixel value is placed at a position of the common designated pixel, and an update candidate image is generated by setting a pixel value of a pixel other than the common designated pixel as a minimum pixel value. In this step S1302, the pixel value of a pixel other than the common designated pixel selected in step S1301 is set as the minimum pixel value, regardless of the position where the pixel having the maximum pixel value is disposed in the previous image. That is, even if the pixel having the maximum pixel value is disposed in the previous image, when the common designated pixel selected in step S1301 is not disposed at the location, the pixel value of the pixel disposed at the location is the minimum pixel value. Is updated. In this way, the update of the previous image is completed, and the image after the update becomes an update candidate image. After the update candidate image is generated in step S1302, the process proceeds to step S1303.

스텝 S1303에 있어서, 갱신 후보 화상을 레지스터 이전 화상에 저장한다. 다음으로 스텝 S1304에 있어서, 레지스터 M에 저장한 대칭축의 번호가 대칭축의 수인 C에 도달했는지의 여부에 대해 판단한다. 레지스터 M은 도 28에 나타내는 피검사 단색 화상 생성 공정(S11)의 스텝 S1103에 있어서 1씩 가산된다. 이 가산된 레지스터 M의 값에 대응하는 원화상은, 전술한 바와 같이 도 28의 스텝 S1104 내지 스텝 S1108과 도 29 및 도 30의 스텝 S1301 내지 스텝 S1303에 의해 처리된다. 그리고 도 30의 스텝 S1303에 있어서, 이전 화상이 갱신된다. 스텝 S1304에 있어서의 판단은, 피검사 단색 화상이 가지는 C개의 대칭축의 전부에 대응해서, 이전 화상의 갱신이 행해졌는지의 여부의 판단과 다름없다. 이 판단 결과가 No인 경우에는, 모든 대칭축에 대응하는 이전 화상의 갱신이 행해지고 있지 않으므로, 도약처 번호 210이 기재되는 결합자를 경유해서 도 28(피검사 단색 화상 생성 공정(S11))의 스텝 S1103으로 점프한다.In step S1303, the update candidate image is stored in the image before the register. Next, in step S1304, it is determined whether the number of symmetric axes stored in the register M has reached C, the number of symmetric axes. The register M is added one by one in step S1103 of the inspection subject monochrome image generation process (S11) shown in FIG. The original image corresponding to the added register M value is processed by steps S1104 to S1108 in Fig. 28 and steps S1301 to S1303 in Figs. 29 and 30 as described above. And in step S1303 of Fig. 30, the previous image is updated. The determination in step S1304 is equivalent to the determination as to whether or not the previous image has been updated corresponding to all of the C symmetric axes of the monochromatic image to be inspected. If the result of this judgment is No, since the previous image corresponding to all the axes of symmetry is not updated, step S1103 in Fig. 28 (monochromatic monochrome image generation process (S11)) via the combiner to which the jump destination number 210 is described. To jump.

이 스텝 S1103에 있어서는, 대칭축의 수를 저장하는 레지스터 M의 값에 1을 가산한다. 그리고 지금까지의 설명과 마찬가지로, M의 값이 1만큼 커진 상태에서 도 28의 스텝 S1104 내지 스텝 S1108과 도 29 및 도 30의 스텝 S1301 내지 스텝 S1303에 기재된 공정을 재차 실행한다. M의 값에 대한 1의 가산을 반복하면, 도 30(검사용 화상 생성 공정(S13))의 스텝 S1304의 판단 결과가 Yes로 된다. 그 경우에는 스텝 S1305로 진행된다.In this step S1103, 1 is added to the value of the register M that stores the number of symmetry axes. Then, similarly to the description so far, the steps described in Steps S1104 to S1108 in Fig. 28 and Steps S1301 to S1303 in Figs. 29 and 30 are again executed in a state where the value of M is increased by one. If the addition of 1 to the value of M is repeated, the judgment result of Step S1304 in Fig. 30 (inspection image generation step S13) is Yes. In that case, the process proceeds to step S1305.

이 스텝 S1305에 있어서, 갱신 후보 화상을 검사용 화상이라는 명칭의 레지스터에 저장한다. 이에 따라, 검사용 화상의 생성이 완료된다. 그리고 스텝 S13을 종료하고, 도 14의 (b)에 나타내는 스텝 S14로 진행된다.In step S1305, the update candidate image is stored in a register named inspection image. Thus, generation of the inspection image is completed. Then, step S13 ends, and the process proceeds to step S14 shown in Fig. 14B.

(5.13) 스텝 S14(5.13) Step S14

도 14의 (b)에 있어서 스텝 S14는 검사 실행 공정이며, 스텝 S13에서 생성한 검사용 화상에 의거하여, 검사 대상 워크의 화상에 대한 결함 검사를 실행한다. 검사 실행 공정(S14)의 상세 플로우차트를 도 31에 나타낸다.In FIG. 14B, step S14 is an inspection execution step, and based on the inspection image generated in step S13, defect inspection is performed on the image of the work to be inspected. The detailed flowchart of the inspection execution process (S14) is shown in FIG. 31.

도 31의 스텝 S1401에 있어서, 검사 대상 워크의 화상을 취출하고, 검사용 화상의 검사 대상 영역을 참조하면서, 당해 영역에 대하여 결함 검사를 행한다. 구체적으로는, 검사용 화상에 있어서 최대 화소값이 배치되어 있는 영역을, 검사 대상 워크에 있어서의 검사 대상 영역으로 한다. 그리고, 이 영역에 대하여 결함 검사를 실행한다. 결함 검사에 있어서 적용하는 방법은, 작업자에 있어서 기지인 임의의 방법을 이용하여도 된다.In step S1401 in FIG. 31, an image of a work to be inspected is taken out, and a defect inspection is performed on the area while referring to the inspection target area of the inspection image. Specifically, an area in which the maximum pixel value is arranged in the inspection image is an inspection target area in the inspection target work. Then, defect inspection is performed on this area. The method applied in the defect inspection may be any method known to the operator.

전술한 본 발명에 있어서의 화상 처리 알고리즘을 이용한 결함 검사 방법은, 종래 기술에 의한 결함 검사 방법에 비해서, 이하의 점에서 우수하다. 먼저, 작업자가 촬상 화상을 목시해서 판단하는 항목이 극히 적으며, 또한 그 판단 기준이 작업자의 숙련을 전제로 하고 있지 않다는 것이다.The defect inspection method using the image processing algorithm in the present invention described above is superior to the defect inspection method according to the prior art in the following points. First, there are very few items for the operator to visually judge the captured image, and the judgment criteria do not assume the skill of the operator.

종래 기술에 의한 결함 검사 방법에 있어서, 작업자는 결함 검사의 대상이 되는 워크의 화상을 목시한다. 그리고, 화상에 있어서 결함 검사의 대상이 되는 검사 대상 영역과, 결함 검사의 대상이 되지 않는 제외 영역을 확인한다. 그리고 각 영역의 배치에 대해 상호 관계를 확인하고, 아울러 각 영역을 구성하는 화소의 화소값에 대해서 대소 관계를 확인한다. 다음으로 상기 배치의 상호 관계 및 화소값의 대소 관계를 고려한 상태에서, 검사 대상 영역과 제외 영역을 선별하기 위한 임계값을 설정해서 검사 대상 영역을 선별한다. 또한, 컬러 화상으로부터 복수의 단색 화상을 생성했을 경우에는, 작업자가 각 단색 화상을 목시한다. 그리고 상기 각 영역간의 밝기를 비교하여, 가장 결함을 명료하게 식별할 수 있는 것으로 판단한 하나의 단색 화상을 선택한다. 그리고 이 선택한 단색 화상에 대하여, 상기 임계값의 설정 및 검사 대상 영역의 선별을 행한다.In the defect inspection method according to the prior art, an operator sees an image of a work subject to defect inspection. Then, in the image, an inspection target area that is a target for defect inspection and an excluded area that is not target for defect inspection are identified. Then, the mutual relationship is checked with respect to the arrangement of each region, and the magnitude of the pixel values of the pixels constituting each region are confirmed. Next, in consideration of the interrelationship of the arrangement and the relationship between the pixel values and the size of the pixels, the inspection target area is selected by setting a threshold for selecting the inspection target area and the exclusion area. In addition, when a plurality of monochrome images are generated from color images, the operator visually observes each monochrome image. Then, by comparing the brightness between the respective areas, one single color image determined to be able to clearly identify the most defective is selected. Then, for the selected monochrome image, the threshold value is set and the region to be inspected is selected.

이에 대하여 본 발명의 화상 처리 알고리즘 및 그것을 이용한 결함 검사 방법은, 워크의 화상이 특정의 직선에 관해서 선대칭이 될 경우에 사용하는 것이다. 먼저 대칭축에 관해서 대상 위치에 배치되는 화소의 화소값의 차분을 취하여, 차분 화상을 생성한다. 다음으로 차분 화상을 구성하는 화소의 화소값 중에서, 미리 설정된 임계값보다 큰 화소값을 갖는 화소를 선출하고, 당해 화소가 배치되는 개소를 검사 대상 영역으로서 선출한다. 대칭축이 복수인 경우에는, 각각의 대칭축에 대응하는 검사 대상 영역의 공통 부분을 최종적인 검사 대상 영역으로 한다. 또한, 컬러 화상으로부터 복수의 단색 화상을 생성했을 경우에는, 각 단색 화상으로부터 생성한 차분 화상의 화소에 대해서, 미리 결정된 연산을 화소값에 대하여 실행한다. 그리고 각 차분 화상의 연산 결과를 비교하여, 임계값을 설정하는데 최적인 하나의 단색 화상을 선출한다. 이 단색 화상을 이용하여, 상기의 미리 설정된 임계값을 설정한다.On the other hand, the image processing algorithm of the present invention and the defect inspection method using the same are used when the image of a work becomes line symmetric with respect to a specific straight line. First, with respect to the axis of symmetry, the difference between the pixel values of the pixels arranged at the target position is taken to generate a difference image. Next, among the pixel values of the pixels constituting the difference image, pixels having a pixel value larger than a preset threshold value are selected, and a location where the pixel is disposed is selected as an inspection target area. When there are a plurality of axes of symmetry, the common portion of the region to be examined corresponding to each axis of symmetry is the final region to be examined. In addition, when a plurality of monochrome images are generated from color images, a predetermined operation is performed on the pixel values for the pixels of the difference image generated from each monochrome image. Then, the calculation results of each difference image are compared, and a single monochrome image optimal for setting a threshold value is selected. Using the monochromatic image, the preset threshold value is set.

이 알고리즘 및 그것을 이용한 결함 검사 방법은, 작업자가 워크의 화상을 목시해서 어떠한 판단을 행하는 공정이 거의 존재하지 않는다. 이 때문에, 종래 기술에 의한 결함 검사 방법과 같이 작업자에 대하여 숙련이 요구될 일이 없어, 작업자의 부담이 적어진다. 또한 알고리즘을 소프트웨어에 의해 자동화해서 결함 검사를 실행하는 것이 용이하기 때문에, 종래 기술에 의한 결함 검사에 비해서 검사 속도가 각별히 향상하는 동시에, 작업자의 숙련도의 차이에 영향을 받지 않는다.In this algorithm and the defect inspection method using the same, there is almost no process in which the operator makes any judgment by visually viewing the image of the work. For this reason, as in the defect inspection method according to the prior art, there is no need for skill for the operator, and the burden on the worker is reduced. In addition, since it is easy to perform defect inspection by automating the algorithm by software, the inspection speed is significantly improved compared to defect inspection according to the prior art, and it is not affected by the difference in operator skill.

WD1, WD2···불량 워크
MD1, MD2···표시
D1, D2, Da, Db···결함
WG1···양품 워크
MG1···표시
B1···배경
F1, F2···둘레 테두리
L1··· 제 1 직선
L2··· 제 2 직선
L3··· 제 3 직선
WD1, WD2 ... bad work
MD1, MD2 ... display
D1, D2, Da, Db ... defect
WG1 ...
MG1 ... indication
B1 ... Background
F1, F2 ... circumference
L1 ... 1st straight line
L2 ... 2nd straight line
L3 ... 3rd straight line

Claims (8)

기준 직선에 대하여 선대칭이 되는 제 1 및 제 2 영역을 갖는 단색의 원(原)화상을, 상기 기준 직선에 의해 상기 제 1 및 제 2 영역으로 분할하고, 상기 제 1 및 제 2 영역 내에서 상기 기준 직선에 대하여 선대칭의 위치에 배치되는 2개의 원(原)화소의 각 페어(pair)에 대해서, 상기 2개의 원화소의 화소값의 차분이 되는 차분 화소값을 산출하는 차분 산출 공정과,
상기 차분 화소값을 갖는 차분 화소를 배치해서 차분 화상을 생성하는 차분 화상 생성 공정으로서, 상기 제 1 영역 내의 제 1 위치의 원화소와 상기 제 2 영역 내의 제 2 위치의 원화소의 페어를 이용하여 산출된 상기 차분 화소값을 갖는 차분 화소를, 상기 차분 화상의 상기 제 1 및 제 2 위치에 배치해서 상기 차분 화상을 생성하는 차분 화상 생성 공정
을 구비하는 화상 처리 방법을 이용하여 피검사물에 대하여 결함 검사를 행하는 결함 검사 방법으로서,
양품(良品)임이 기지(旣知)인 복수의 피검사물을 촬상해서 얻어지는 촬상 화상으로부터 생성되는 단색 화상을 제 1 원화상으로 하여, 생성된 복수의 제 1 원화상으로부터 상기 화상 처리 방법을 이용하여 복수의 양품 차분 화상을 생성하는 제 1 공정과,
불량임이 기지인 복수의 피검사물을 촬상해서 얻어지는 촬상 화상으로부터 생성되는 단색 화상을 제 2 원화상으로 하여, 생성된 복수의 제 2 원화상으로부터 상기 화상 처리 방법을 이용하여 복수의 불량 차분 화상을 생성하는 제 2 공정
을 구비하는 임계값 설정 모드로서,
상기 복수의 불량 차분 화상의 차분 화소 중에서, 차분 화소값이 다른 차분 화소값으로부터 소정값 이상으로 이간하는 동시에 각 불량 차분 화상에 있어서 동일한 위치에 배치되는 이간 화소를 선출하는 것이 가능하며, 또한, 상기 복수의 양품 차분 화상의 차분 화소 중에서 상기 이간 화소와 동일한 위치에 배치되는 차분 화소를 상기 이간 화소로서 선출하지 않도록 하는 것이 가능한 하나의 검사 영역 임계값을 설정하는 임계값 설정 모드와,
결함 검사 대상인 피검사물을 촬상해서 얻어지는 촬상 화상으로부터 생성되는 단색 화상을 제 3 원화상으로 하여, 생성된 제 3 원화상으로부터 상기 화상 처리 방법을 이용하여 차분 화상을 생성하고, 상기 차분 화상과 상기 검사 영역 임계값을 이용하여 상기 제 3 원화상에 있어서의 검사 대상 영역을 선출하고, 상기 검사 대상 영역에 대하여 결함 검사를 실행하는 검사 실행 모드
를 구비하는 것을 특징으로 하는 결함 검사 방법.
A monochromatic circular image having first and second regions that are line-symmetric with respect to the reference straight line is divided into the first and second regions by the reference straight line, and the first and second regions are divided into the first and second regions. A difference calculation step of calculating a difference pixel value that is a difference between the pixel values of the two original pixels for each pair of two original pixels arranged at a line symmetry position with respect to a reference straight line,
A difference image generation process in which a difference pixel having the difference pixel value is arranged to generate a difference image, using a pair of an original pixel at a first position in the first area and an original pixel at a second position in the second area A difference image generation process for generating the difference image by arranging difference pixels having the calculated difference pixel values at the first and second positions of the difference image.
A defect inspection method for performing defect inspection on an inspected object using an image processing method comprising:
A monochromatic image generated from a captured image obtained by imaging a plurality of inspected objects, which are known to be good products, is used as a first original image, and the image processing method is used from the plurality of first original images generated. A first step of generating a plurality of quality difference images,
A plurality of defective difference images are generated by using the image processing method from a plurality of generated second original images, using a monochromatic image generated from a captured image obtained by imaging a plurality of inspected objects having known defects as the second original image. The second process to do
As a threshold setting mode having a,
Among the difference pixels of the plurality of defective difference images, it is possible to select the difference pixels arranged at the same position in each defective difference image while the difference pixel values are separated from other difference pixel values by a predetermined value or more. A threshold setting mode for setting a threshold value of one inspection area capable of preventing the difference pixels arranged at the same position as the separation pixels from among the difference pixels of the plurality of quality difference images;
A monochrome image generated from a captured image obtained by imaging an object to be inspected as a defect inspection is used as a third original image, and a differential image is generated from the generated third original image using the image processing method, and the differential image and the inspection are performed. An inspection execution mode in which an inspection target area in the third original image is selected using an area threshold and a defect inspection is performed on the inspection target area
Defect inspection method comprising a.
제 1 항에 있어서,
상기 기준 직선은, 상기 원화상을, 동일한 수의 원화소를 포함하는 상반분(上半分)의 상기 제 1 영역과 하반분(下半分)의 상기 제 2 영역으로 분할하는 제 1 직선인 것을 특징으로 하는 결함 검사 방법.
According to claim 1,
The reference straight line is a first straight line dividing the original image into the first region in the upper half and the second region in the lower half containing the same number of original pixels. Defect inspection method.
제 1 항에 있어서,
상기 기준 직선은, 상기 원화상을, 동일한 수의 원화소를 포함하는 좌반분(左半分)의 상기 제 1 영역과 우반분(右半分)의 상기 제 2 영역으로 분할하는 제 2 직선인 것을 특징으로 하는 결함 검사 방법.
According to claim 1,
The reference straight line is a second straight line dividing the original image into the first region in the left half and the second region in the right half containing the same number of original pixels. Defect inspection method.
제 1 항에 있어서,
상기 차분 화상 생성 공정에서는, 동일한 상기 원화상으로부터 상기 차분 화상으로서, 제 1 차분 화상과, 상기 제 1 차분 화상과 다른 제 2 차분 화상을 생성하고,
상기 제 1 차분 화상과 상기 제 2 차분 화상을 이용하여, 상기 원화상에 있어서의 검사 대상 영역을 선출하는 검사 영역 선출 공정을 더 구비하는 것을 특징으로 하는 결함 검사 방법.
According to claim 1,
In the difference image generation step, a first difference image and a second difference image different from the first difference image are generated from the same original image as the difference image,
And an inspection region selection step of selecting an inspection target region in the original image using the first difference image and the second difference image.
제 1 항에 있어서,
상기 촬상 화상은 비(非)컬러 화상이며,
각 촬상 화상으로부터 생성되는 단색 화상은 하나인 것을 특징으로 하는 결함 검사 방법.
According to claim 1,
The captured image is a non-color image,
A defect inspection method characterized in that there is only one monochrome image generated from each captured image.
제 1 항에 있어서,
상기 촬상 화상은 컬러 화상이고,
각 촬상 화상으로부터 생성되는 단색 화상은 2개 이상이며,
상기 임계값 설정 모드의 상기 제 1 공정에서는, 각 단색 화상을 상기 제 1 원화상으로 하여, 생성된 복수의 제 1 원화상으로부터 상기 복수의 양품 차분 화상을 생성하고,
상기 임계값 설정 모드의 상기 제 2 공정에서는, 각 단색 화상을 상기 제 2 원화상으로 하여, 생성된 복수의 제 2 원화상으로부터 상기 복수의 불량 차분 화상을 생성하고,
상기 임계값 설정 모드에서는, 상기 검사 영역 임계값의 설정 가능 범위가 가장 넓은 단색 화상을 하나 선출하고, 선출한 단색 화상에 대하여 상기 검사 영역 임계값을 설정하고,
상기 검사 실행 모드에서는, 상기 결함 검사 대상인 피검사물을 촬상해서 얻어지는 상기 촬상 화상으로부터 생성되는 2개 이상의 단색 화상 중에서, 상기 임계값 설정 모드에서 선출된 단색 화상과 같은 종류의 단색 화상을 선출해서 상기 제 3 원화상으로 하여, 생성된 상기 제 3 원화상으로부터 상기 차분 화상을 생성하고, 상기 차분 화상과 상기 검사 영역 임계값을 이용하여 상기 검사 대상 영역을 선출하고, 상기 검사 대상 영역에 대하여 결함 검사를 실행하는
것을 특징으로 하는 결함 검사 방법.
According to claim 1,
The captured image is a color image,
Two or more monochrome images generated from each captured image,
In the first step of the threshold setting mode, each of the monochrome images is the first original image, and the plurality of good difference images are generated from the plurality of first original images generated,
In the second step of the threshold setting mode, each of the monochromatic images is used as the second original image, and the plurality of defective difference images are generated from the plurality of generated second original images,
In the threshold setting mode, a single monochrome image having the largest settable range of the inspection region threshold is selected, and the inspection region threshold is set for the selected monochrome image,
In the inspection execution mode, among two or more monochrome images generated from the captured images obtained by imaging the inspected object to be inspected for defects, a monochrome image of the same kind as the monochrome image selected in the threshold setting mode is selected to obtain the second image. With the three original images, the difference image is generated from the generated third original image, the inspection target area is selected using the difference image and the inspection area threshold, and defect inspection is performed on the inspection target area Running
Defect inspection method characterized in that.
제 1 항에 있어서,
상기 제 3 원화상 중에서 템플릿 매칭법을 이용하여 상기 결함 검사 대상인 피검사물을 추출하는 피검사물 추출 공정을 더 구비하는 것을 특징으로 하는 결함 검사 방법.
According to claim 1,
Defect inspection method characterized in that it further comprises a test object extraction process for extracting the object to be inspected for defects using a template matching method from the third original image.
삭제delete
KR1020180069570A 2017-06-28 2018-06-18 Image processing method and defect inspection method KR102090568B1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JPJP-P-2017-126674 2017-06-28
JP2017126674A JP6879841B2 (en) 2017-06-28 2017-06-28 Image processing method and defect inspection method

Publications (2)

Publication Number Publication Date
KR20190001914A KR20190001914A (en) 2019-01-07
KR102090568B1 true KR102090568B1 (en) 2020-03-18

Family

ID=64802353

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020180069570A KR102090568B1 (en) 2017-06-28 2018-06-18 Image processing method and defect inspection method

Country Status (4)

Country Link
JP (1) JP6879841B2 (en)
KR (1) KR102090568B1 (en)
CN (1) CN109146839B (en)
TW (1) TWI695165B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111754504B (en) * 2020-07-01 2024-03-19 华能国际电力股份有限公司大连电厂 Chemical mixed bed layering detection method based on machine vision

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010025708A (en) * 2008-07-17 2010-02-04 Fujifilm Corp Method and device for inspecting imaging element

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1583946B1 (en) * 2003-01-15 2006-11-08 Micronic Laser Systems Ab A method to detect a defective pixel
JP4766897B2 (en) * 2004-12-13 2011-09-07 株式会社東京精密 Image defect inspection method, image defect inspection apparatus, and appearance inspection apparatus
US7969488B2 (en) * 2005-08-03 2011-06-28 Micron Technologies, Inc. Correction of cluster defects in imagers
JP2008003063A (en) * 2006-06-26 2008-01-10 Seiko Epson Corp Shading correction method, defect detection method, and defect detector and control method program thereof
JP4192975B2 (en) * 2006-07-26 2008-12-10 ソニー株式会社 Image processing apparatus and method, program, and recording medium
CN101609500B (en) * 2008-12-01 2012-07-25 公安部第一研究所 Quality estimation method of exit-entry digital portrait photos
JP5310247B2 (en) * 2009-05-13 2013-10-09 ソニー株式会社 Image processing apparatus and method, and program
KR20140087606A (en) * 2012-12-31 2014-07-09 엘지디스플레이 주식회사 Method and apparatus of inspecting mura of flat display
JP2014137468A (en) * 2013-01-17 2014-07-28 Sony Corp Imaging apparatus and imaging method
JP6344593B2 (en) * 2013-06-19 2018-06-20 株式会社 東京ウエルズ Defect inspection method
JP6251647B2 (en) * 2014-07-15 2017-12-20 株式会社ニューフレアテクノロジー Mask inspection apparatus and mask inspection method

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010025708A (en) * 2008-07-17 2010-02-04 Fujifilm Corp Method and device for inspecting imaging element

Also Published As

Publication number Publication date
TW201905443A (en) 2019-02-01
TWI695165B (en) 2020-06-01
KR20190001914A (en) 2019-01-07
JP6879841B2 (en) 2021-06-02
CN109146839B (en) 2022-03-08
CN109146839A (en) 2019-01-04
JP2019008739A (en) 2019-01-17

Similar Documents

Publication Publication Date Title
CN110274908B (en) Defect inspection apparatus, defect inspection method, and computer-readable recording medium
JP6924413B2 (en) Data generator, data generation method and data generation program
US10830755B2 (en) Board lumber grading using deep learning semantic segmentation techniques
US10776909B2 (en) Defect inspection apparatus, defect inspection method, and non-transitory computer readable medium
JP6869490B2 (en) Defect inspection equipment, defect inspection methods, and their programs
US8401274B2 (en) Image processing apparatus and method
US20180330193A1 (en) Image processing device, non-transitory computer readable storage medium, and image processing system
CN103324927A (en) Image processing apparatus and character recognition method
CN101149837B (en) Color processing method for identification of areas within an image corresponding to monetary banknotes
US20230024820A1 (en) Analysis device and analysis method
KR102090568B1 (en) Image processing method and defect inspection method
JP2002251603A (en) Image processing program formation method and system for it
JP2010008159A (en) Visual inspection processing method
JP7337557B2 (en) Information processing device, system, information processing method and program
CN113016023B (en) Information processing method and computer-readable non-transitory recording medium
JP7154786B2 (en) Image processing device, image processing method and program
JP2014032553A (en) Long object counting device, long object counting method, and computer program
CN115546141A (en) Small sample Mini LED defect detection method and system based on multi-dimensional measurement
CN115222705A (en) Chemical fiber spinning cake appearance defect detection method based on improved YOLOV5
JP2021156879A (en) Fracture surface analysis device, fracture surface analysis method, and machine learning data set generation method
Melnyk et al. Detection of defects in printed circuit boards by flood-fill algorithm and distributed cumulative histogram
WO2023188803A1 (en) Automatic defect classification device
JP7142825B1 (en) Image judgment method and image judgment system
KR102621884B1 (en) Deep learning-based image analysis method for selecting defective products and a system therefor
EP0380090A2 (en) Image processing system

Legal Events

Date Code Title Description
A201 Request for examination
E902 Notification of reason for refusal
E701 Decision to grant or registration of patent right
GRNT Written decision to grant