JP5595247B2 - Mahalanobis reference space generation method and inspection device - Google Patents

Mahalanobis reference space generation method and inspection device Download PDF

Info

Publication number
JP5595247B2
JP5595247B2 JP2010267768A JP2010267768A JP5595247B2 JP 5595247 B2 JP5595247 B2 JP 5595247B2 JP 2010267768 A JP2010267768 A JP 2010267768A JP 2010267768 A JP2010267768 A JP 2010267768A JP 5595247 B2 JP5595247 B2 JP 5595247B2
Authority
JP
Japan
Prior art keywords
value
luminance
defective
inspection
product
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
JP2010267768A
Other languages
Japanese (ja)
Other versions
JP2012117907A (en
Inventor
靖之 井上
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ricoh Elemex Corp
Original Assignee
Ricoh Elemex Corp
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 Ricoh Elemex Corp filed Critical Ricoh Elemex Corp
Priority to JP2010267768A priority Critical patent/JP5595247B2/en
Publication of JP2012117907A publication Critical patent/JP2012117907A/en
Application granted granted Critical
Publication of JP5595247B2 publication Critical patent/JP5595247B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Description

本発明は、マハラノビス・タグチ法(MT法)を利用して、製品の外観検査を行う技術に関する。   The present invention relates to a technique for inspecting the appearance of a product using the Mahalanobis Taguchi method (MT method).

従来、製品の外観検査は人手に頼る部分が大きく、この場合、検査員が目視でその検査を実施する。しかし、最終ユーザからの検査品質向上要求、人海戦術検査による人件費増大対策から、近年、市場では画像認識技術を利用した製品の外観検査の自動化が求められている。外観検査を自動的に行う検査装置は、先ずカメラや照明などの撮像機器によって検査品の外観を撮像する。そして、その撮像した検査画像に対して所定の画像処理を行うアルゴリズムにより検査品の良否判定を行う。ここで、そのアルゴリズムの一つに、MT法を利用した方法が従来知られている(例えば特許文献1参照)。   Conventionally, the appearance inspection of products is largely dependent on human hands, and in this case, the inspector performs the inspection visually. However, in recent years, there has been a demand for automation of visual inspection of products using image recognition technology in response to demands for improving inspection quality from end users and measures for increasing labor costs due to human tactical inspection. An inspection apparatus that automatically performs an appearance inspection first images the appearance of an inspection product using an imaging device such as a camera or illumination. Then, the quality of the inspection product is determined by an algorithm that performs predetermined image processing on the captured inspection image. Here, a method using the MT method is conventionally known as one of the algorithms (see, for example, Patent Document 1).

このMT法は、多数の情報をマハラノビス距離という一つの尺度に集約し、このマハラノビス距離の大小によって、良否を判定する方法である。具体的には、良品の外観を撮像した良品画像から特徴量を抽出して、マハラノビス距離を算出するための基準空間(以下、マハラノビス基準空間とも言う)を生成する。次いで、検査品の外観を撮像した検査画像の特徴量と基準空間とに基づいて、マハラノビス距離を算出する。そして、そのマハラノビス距離の大小に基づいて検査品の良否判定を行うというものである。   This MT method is a method in which a large number of pieces of information are collected on one scale called Mahalanobis distance, and the quality is determined based on the magnitude of the Mahalanobis distance. Specifically, a feature amount is extracted from a non-defective image obtained by capturing the appearance of a non-defective product, and a reference space (hereinafter also referred to as a Mahalanobis reference space) for calculating the Mahalanobis distance is generated. Next, the Mahalanobis distance is calculated based on the feature amount of the inspection image obtained by imaging the appearance of the inspection product and the reference space. The quality of the inspection product is determined based on the Mahalanobis distance.

ここで、従来のマハラノビス基準空間の生成方法について説明する。図16は、従来のマハラノビス基準空間の生成手順を示したフローチャートである。先ず、マハラノビス基準空間を生成するために、評価の基準となる正常な画像サンプル(良品画像)を取得する(S101)。次いで、S101で取得したサンプル画像を所定の大きさごとに(例えば640×480)に切り取っていく(S102)。次いで、切り取った画像について、そのR、G、Bの輝度(8bit:0〜255)データから、それぞれ0〜15、16〜31、32〜47、・・・、240〜255の16段階(R、G、Bでは48段階)の輝度範囲にある画素数をカウントし、R、G、Bの輝度分布データを計算する(S103)。次いで、S103で計算した輝度分布データを良品画像の特徴量とし、その特徴量に基づいてマハラノビス基準空間を生成する(S104)。   Here, a conventional Mahalanobis reference space generation method will be described. FIG. 16 is a flowchart showing a conventional procedure for generating a Mahalanobis reference space. First, in order to generate a Mahalanobis reference space, a normal image sample (non-defective image) serving as a reference for evaluation is acquired (S101). Next, the sample image acquired in S101 is cut into a predetermined size (for example, 640 × 480) (S102). Next, for the cropped image, 16 levels (R to 0 to 15, 16 to 31, 32 to 47,..., 240 to 255) are obtained from the R, G, and B brightness (8 bits: 0 to 255) data. , G, and B are counted in 48 steps), and the R, G, and B luminance distribution data are calculated (S103). Next, the luminance distribution data calculated in S103 is used as a feature amount of a non-defective image, and a Mahalanobis reference space is generated based on the feature amount (S104).

特開2005−252451号公報JP-A-2005-252451

ところで、上記のようにして生成した基準空間を検査時に利用する場合には、被検査対象となる検査画像に対しても、上述のS102のように切り取る処理を行って、切り取った画像ごとに輝度分布データを求める必要がある。しかし、その切り取った画像の範囲が例えば640×480のような大きな範囲になると、640×480=307200の画素に対して演算が必要になる。さらに、この方法を検査画像のサイズ(フレームサイズ)で行う必要があるので、切り取る画像の枚数も多くなり、演算時間がさらに増加する。MT法では数値計算をする必要があるが、製品の外観を撮像する近年のCCDカメラでは分解能UPの要求から数百万画素単位で取り込めるものが汎用的になってきつつあり、数百万からなる画素を処理するためには、上記の従来方法では計算量が多くなってしまい、その結果、検査時間が長くなってしまうという問題がある。   By the way, when the reference space generated as described above is used at the time of inspection, the inspection image to be inspected is also subjected to the cutting process as in the above-described S102, and the brightness of each cut image is determined. It is necessary to obtain distribution data. However, when the range of the clipped image becomes a large range such as 640 × 480, an operation is required for 640 × 480 = 307200 pixels. Furthermore, since this method needs to be performed with the size of the inspection image (frame size), the number of images to be cut increases and the calculation time further increases. Although it is necessary to perform numerical calculations in the MT method, in recent CCD cameras that capture the appearance of products, what can be captured in units of millions of pixels is becoming more and more versatile due to the demand for higher resolution. In order to process the pixels, the above-described conventional method has a problem that the calculation amount increases, and as a result, the inspection time becomes long.

また、従来の方法では、検査の際、画像が予期せぬ写り方をする場合がある。具体的には、例えば、画像全体が暗くまたは明るく写った場合や、画像処理で切り取った画像の一部が暗く、一部が明るかったりする場合がある。なお、画像が暗く写ったり明るく写ったりする原因としては例えば以下の(1)〜(3)の場合が考えられる。
(1)外乱などの影響で偶発する場合
(2)照明を長い期間にわたり使用し続ける(照明の劣化による)場合
(3)検査品の表面形状や材質の影響で、検査品の表面に均一な光を照射することが難しい場合
In the conventional method, an image may appear unexpectedly at the time of inspection. Specifically, for example, there are cases where the entire image appears dark or bright, or where a part of the image cut out by image processing is dark and part is bright. Note that the following (1) to (3) can be considered as causes for the image to appear dark or bright.
(1) When accidental due to disturbances, etc. (2) When lighting is used for a long period of time (due to deterioration of lighting) (3) Due to the influence of the surface shape and material of the inspection product, the surface of the inspection product is uniform. When it is difficult to irradiate light

このように画像が予期せぬ写り方をした場合、その画像に不良とされる領域が写っている、写っていないに関わらず、画像全体の輝度のシフトが起こる。その輝度のシフトに伴って、輝度分布データもシフトするために、その画像が良品、不良品に関わらずマハラノビス距離(MD値)の増大を招く。この場合、検査装置の過検出(良品を不良と判断すること)に繋がるという問題がある。   When an image is unexpectedly reflected in this way, a shift in the brightness of the entire image occurs regardless of whether or not an area considered to be defective is reflected in the image. As the luminance shifts, the luminance distribution data also shifts, so that the Mahalanobis distance (MD value) increases regardless of whether the image is good or defective. In this case, there is a problem that it leads to over-detection of the inspection device (determining a non-defective product as defective).

本発明は上記問題に鑑みてなされたものであり、MT法を利用して検査品の良否判定を行う技術に関して、画像の暗い、明るいといった写り具合に関わらず精度良く良否判定を行うことを第一の課題とする。また、良否判定をするための処理時間を短縮することを第二の課題とする。   The present invention has been made in view of the above problems, and relates to a technique for determining pass / fail of an inspection product using the MT method, wherein the pass / fail determination is performed with high accuracy regardless of whether the image is dark or bright. One issue. A second problem is to shorten the processing time for determining pass / fail.

上記課題を解決するために、本発明に係るマハラノビス基準空間の生成方法は、良品か否かの区別が付きにくい領域である良品グレー領域を含む良品画像を取得する良品画像取得ステップと、
その良品画像取得ステップで取得した前記良品画像に含まれる前記良品グレー領域を認識する認識ステップと、
前記良品画像の領域のうち前記認識ステップで認識した前記良品グレー領域のエッジに隣接した所定の大きさの領域である周辺領域の輝度情報を取得する輝度取得ステップと、
その輝度取得ステップで取得した前記周辺領域の輝度情報を基準とした前記良品グレー領域の輝度情報の特徴量を算出する特徴量算出ステップと、
前記良品画像のうちの前記良品グレー領域の前記特徴量のみに基づいて、マハラノビス距離を算出するための基準空間を生成する生成ステップと、を含むことを特徴とする。
In order to solve the above problems, the method for generating the Mahalanobis reference space according to the present invention is a non-defective image acquisition step for acquiring a non-defective image including a non-defective gray region, which is a region where it is difficult to distinguish whether it is a non-defective product,
A recognition step for recognizing the non-defective gray region included in the non-defective image acquired in the non-defective image acquisition step;
A luminance acquisition step of acquiring luminance information of a peripheral region that is a region of a predetermined size adjacent to an edge of the non- defective gray region recognized in the recognition step in the non-defective image region;
A feature amount calculating step for calculating a feature amount of the luminance information of the non-defective gray region based on the luminance information of the peripheral region acquired in the luminance acquiring step;
Generating a reference space for calculating a Mahalanobis distance based only on the feature amount of the non-defective gray region of the non-defective image .

これによれば、良品画像に含まれる良品グレー領域に着目して基準空間を生成する。ここで、現状、目視検査員による検査は、不良領域だけを見て不良と判定しているわけではなく、不良領域と、不良の周りの領域を相対的に比較することによって区別している。つまり、対象が確かに不良だと判定するためには、対象の周りの情報が必要になる。この点、本発明では、良品グレー領域の周辺領域の輝度情報を基準とした良品グレー領域の輝度情報の特徴量を算出しているので、良品画像の写り具合の影響が考慮された特徴量を得ることができる。そして、その特徴量に基づいて基準空間を生成しているので、良品画像の写り具合の影響が考慮された精度の良い基準空間を得ることができる。よって、検査品の良否判定をする際にこの基準空間を利用することで、画像の写り具合に関わらず精度良くその良否判定を行うことができる。また、良品画像全体ではなく良品グレー領域から基準空間を生成しているので、その基準空間を生成するための処理時間や、その基準空間を利用して検査品の良否判定をするための処理時間を短縮することができる。   According to this, the reference space is generated by paying attention to the non-defective gray region included in the non-defective image. Here, at present, the inspection by the visual inspector does not determine the defect by looking only at the defective area, but distinguishes the defective area from the area around the defect relatively. That is, in order to determine that the target is definitely defective, information around the target is required. In this regard, in the present invention, since the feature amount of the luminance information of the non-defective gray region is calculated based on the luminance information of the peripheral region of the non-defective gray region, the feature amount considering the influence of the non-defective image reflection is calculated. Can be obtained. Since the reference space is generated based on the feature amount, it is possible to obtain a highly accurate reference space in consideration of the influence of the quality of the non-defective image. Therefore, by using this reference space when determining the quality of an inspection product, it is possible to accurately determine the quality regardless of how the image is reflected. In addition, since the reference space is generated from the non-defective gray area instead of the entire non-defective image, the processing time for generating the reference space and the processing time for determining the quality of the inspection product using the reference space Can be shortened.

また、本発明における前記特徴量算出ステップは、前記周辺領域の輝度情報を代表する代表値を設定する代表値設定ステップと、
その代表値設定ステップで設定した前記代表値を基準とした前記良品グレー領域の輝度情報の分布を示した輝度分布データを前記特徴量として算出する輝度分布算出ステップと、を含むことを特徴とする。
Further, the feature amount calculating step in the present invention includes a representative value setting step of setting a representative value representative of luminance information of the peripheral area,
A luminance distribution calculating step of calculating, as the feature amount, luminance distribution data indicating a luminance information distribution of the non-defective gray region based on the representative value set in the representative value setting step. .

これによれば、代表値設定ステップで、周辺領域の輝度情報の代表値を設定しているので、周辺領域の輝度情報が分布している場合であってもその周辺領域の輝度情報が反映された値(代表値)を得ることができる。そして、輝度分布算出ステップで、代表値を基準とした輝度分布データを算出しているので、周辺領域の輝度情報を基準とした良品グレー領域の特徴量を得ることができる。   According to this, since the representative value of the luminance information of the peripheral area is set in the representative value setting step, the luminance information of the peripheral area is reflected even when the luminance information of the peripheral area is distributed. Value (representative value) can be obtained. In the luminance distribution calculating step, the luminance distribution data based on the representative value is calculated, so that the feature amount of the non-defective gray region based on the luminance information of the peripheral region can be obtained.

ここで、その輝度分布算出ステップは、前記良品グレー領域の各画素の輝度値のうち前記代表値より大きい各輝度値と前記代表値との差分値をそれぞれ算出し、それら差分値の合計値と、前記良品グレー領域の各画素の輝度値のうち前記代表値より小さい各輝度値と前記代表値との差分値をそれぞれ算出し、それら差分値の合計値の少なくとも一方を前記輝度分布データとして算出するステップとすることができる。   Here, the luminance distribution calculating step calculates a difference value between each of the luminance values greater than the representative value among the luminance values of the pixels in the non-defective gray region and the representative value, and calculates a total value of the difference values. The difference value between each of the luminance values smaller than the representative value and the representative value among the luminance values of the pixels in the non-defective gray region is calculated, and at least one of the total values of the difference values is calculated as the luminance distribution data. Step.

これによれば、輝度分布算出ステップで、良品グレー領域の各画素の輝度値のうち代表値より大きい各輝度値と代表値との差分値の合計値を算出するので、周辺領域に対してグレー領域がどの程度明るくされているのかを示した特徴量を得ることができる。また、その輝度分布算出ステップでは、上記の合計値に代えて、又は上記の合計値と共に、良品グレー領域の各画素の輝度値のうち代表値より小さい各輝度値と代表値との差分値の合計値を算出するので、周辺領域に対してグレー領域がどの程度暗くされているのかを示した特徴量を得ることができる。   According to this, in the luminance distribution calculation step, the total value of the difference values between the luminance values greater than the representative value and the representative value among the luminance values of the pixels in the non-defective gray region is calculated. A feature value indicating how bright the area is can be obtained. In addition, in the luminance distribution calculation step, instead of the total value or together with the total value, the difference value between each luminance value smaller than the representative value and the representative value among the luminance values of each pixel in the non-defective gray region is calculated. Since the total value is calculated, it is possible to obtain a feature amount indicating how dark the gray area is with respect to the surrounding area.

また、輝度分布算出ステップは、前記良品グレー領域の各画素のうち前記代表値より大きい輝度値の画素の数と前記代表値より小さい輝度値の画素の数の少なくとも一方を前記輝度分布データとして算出するステップとすることもできる。   The luminance distribution calculating step calculates, as the luminance distribution data, at least one of the number of pixels having a luminance value greater than the representative value and the number of pixels having a luminance value smaller than the representative value among the pixels of the non-defective gray region. It can also be a step to do.

これによれば、グレー領域のうち、周辺領域より明るくされている領域がどの程度含まれているかを示した特徴量と周辺領域より暗くされている領域がどの程度含まれているかを示した特徴量の一方又は両方を得ることができる。   According to this, a feature amount indicating how much of the gray area is brighter than the surrounding area and a feature indicating how much of the area darker than the surrounding area is included. One or both of the quantities can be obtained.

また、輝度分布算出ステップは、前記良品グレー領域の各画素の輝度値のうち前記代表値より大きい各輝度値と前記代表値との各差分値の合計値、前記良品グレー領域の各画素の輝度値のうち前記代表値より小さい各輝度値と前記代表値との各差分値の合計値、前記良品グレー領域の各画素のうち前記代表値より大きい輝度値の画素の数、及び前記良品グレー領域の各画素のうち前記代表値より小さい輝度値の画素の数の少なくともいずれか一つを前記輝度分布データとして算出するステップであるとしてもよい。これにより、上記の4つの特徴量の中から選択される1又は複数の特徴量を得ることができる。   In addition, the luminance distribution calculating step includes the sum of the difference values between the luminance values greater than the representative value and the representative value among the luminance values of the pixels of the non-defective gray region, and the luminances of the pixels of the non-defective gray region. A total value of difference values between the luminance values smaller than the representative value and the representative value among the values, the number of pixels having a luminance value larger than the representative value among the pixels of the good gray region, and the good gray region In this step, at least one of the number of pixels having a luminance value smaller than the representative value among the respective pixels may be calculated as the luminance distribution data. Thereby, one or a plurality of feature amounts selected from the above four feature amounts can be obtained.

また、本発明における前記特徴量算出ステップは、
前記良品グレー領域の各画素の輝度値を輝度値の大きさの順に並び替える並替ステップと、
その並替ステップで並び替えた輝度値間の変化特性を示した変化特性値を前記特徴量として算出する変化特性値算出ステップと、をさらに含むことを特徴とする。
In the present invention, the feature amount calculating step includes:
A rearrangement step of rearranging the luminance value of each pixel of the non-defective gray region in the order of the luminance value;
And a change characteristic value calculating step of calculating a change characteristic value indicating a change characteristic between the luminance values rearranged in the rearrangement step as the feature amount.

これによれば、並替ステップで、良品グレー領域の各画素の輝度値を輝度値の大きさの順に並び替え、変化特性値算出ステップで、その並び替えた輝度値間の変化特性を示した変化特性値を算出しているので、良品グレー領域の輝度がどのように変化しているかを示した特徴量を得ることができる。これにより、良品グレー領域の特徴をより一層反映した基準空間を得ることができる。   According to this, the luminance value of each pixel in the non-defective gray area is rearranged in order of the magnitude of the luminance value in the rearrangement step, and the change characteristic between the rearranged luminance values is shown in the change characteristic value calculation step. Since the change characteristic value is calculated, it is possible to obtain a feature amount indicating how the luminance of the non-defective gray region is changing. Thereby, a reference space that further reflects the characteristics of the non-defective gray region can be obtained.

ここで、その変化特性値算出ステップは、前記並替ステップで並び替えた輝度値から、大きさが隣り合う二つの輝度値の差分値である隣接変化値を算出し、その隣接変化値の特性を示した隣接変化特性値を前記変化特性値として算出するステップとすることができる。   Here, the change characteristic value calculation step calculates an adjacent change value that is a difference value between two luminance values adjacent to each other from the luminance value rearranged in the rearrangement step, and the characteristic of the adjacent change value The step of calculating the adjacent change characteristic value indicating the change characteristic value can be used.

これにより、隣り合う二つの輝度値が、どの程度輝度変化しているかを示した特徴量を得ることができる。   As a result, it is possible to obtain a feature value indicating how much the brightness changes between two adjacent brightness values.

また、変化特性値算出ステップは、前記並替ステップで並び替えた輝度値間の変化を近似した近似式を算出し、その近似式の特性を示した近似式特性値を前記変化特性値として算出するステップとしてもよい。   The change characteristic value calculating step calculates an approximate expression approximating a change between the luminance values rearranged in the rearranging step, and calculates an approximate expression characteristic value indicating the characteristic of the approximate expression as the change characteristic value. It is good also as a step to do.

これによれば、変化特性値算出ステップで算出される近似式特性値は、輝度値間の変化を近似した近似式の特性を示しているので、グレー領域の輝度が各画素間でどのように変化しているかを示した特徴量を得ることができる。   According to this, since the approximate expression characteristic value calculated in the change characteristic value calculating step shows the characteristic of the approximate expression that approximates the change between the luminance values, how the luminance of the gray region is changed between the pixels. It is possible to obtain a feature amount indicating whether or not it is changing.

また、本発明における前記代表値設定ステップは、良品グレー領域ごとに互いに値が異なる複数の前記代表値を設定するステップであり、
前記輝度分布算出ステップは、前記複数の代表値のそれぞれごとに、各代表値を基準とした前記輝度分布データを算出するステップであることを特徴とする。
In the present invention, the representative value setting step is a step of setting a plurality of representative values having different values for each good gray region,
The luminance distribution calculating step is a step of calculating the luminance distribution data based on each representative value for each of the plurality of representative values.

これによれば、代表値設定ステップで、互いに値が異なる複数の代表値を設定するので、良品グレー領域ごとの、周辺領域の輝度情報がより一層反映された値(代表値)を得ることができる。そして、輝度分布算出ステップでは、複数の代表値のそれぞれごとに、各代表値を基準とした輝度分布データを算出しているので、良品グレー領域ごとの、周辺領域の輝度情報がより一層反映された輝度分布データを得ることができる。これにより、より一層精度の良い基準空間を得ることができる。   According to this, since a plurality of representative values having different values are set in the representative value setting step, it is possible to obtain a value (representative value) in which the luminance information of the peripheral area is further reflected for each non-defective gray area. it can. In the luminance distribution calculation step, luminance distribution data based on each representative value is calculated for each of the plurality of representative values, so that the luminance information of the peripheral area for each non-defective gray area is further reflected. Brightness distribution data can be obtained. Thereby, a reference space with higher accuracy can be obtained.

また、本発明における代表値設定ステップは、前記周辺領域の輝度値の平均値、最小値、最大値、中央値又は偏差に基づいて前記代表値を設定するステップとすることができる。   In the present invention, the representative value setting step may be a step of setting the representative value based on an average value, a minimum value, a maximum value, a median value, or a deviation of the luminance values in the peripheral area.

これによれば、平均値、最小値、最大値、中央値又は偏差は、複数の輝度値を考慮して初めて決定できるものであるので、それらに基づいて代表値を設定することで、精度の良い代表値を得ることができる。   According to this, since the average value, the minimum value, the maximum value, the median value, or the deviation can be determined for the first time in consideration of a plurality of luminance values, the accuracy can be improved by setting the representative value based on them. A good representative value can be obtained.

本発明に係る検査装置は、請求項1〜10のいずれか1項に記載のマハラノビス基準空間の生成方法で生成された前記基準空間が記憶された記憶手段と、
検査品の画像である検査画像を取得する検査画像取得手段と、
その検査画像取得手段が取得した前記検査画像に、良品か否かの区別が付きにくい領域である検査品グレー領域が含まれているか否かを判断するグレー領域判断手段と、
そのグレー領域判断手段が前記検査品グレー領域が含まれていると判断した場合に、前記検査画像の領域のうち前記検査品グレー領域のエッジに隣接した所定の大きさの領域である周辺領域の輝度情報を取得する検査品輝度取得手段と、
その検査品輝度取得手段が取得した前記周辺領域の輝度情報を基準とした前記検査品グレー領域の輝度情報の特徴量である検査品特徴量を算出する検査品特徴量算出手段と、
その検査品特徴量算出手段が算出した前記検査品特徴量と前記記憶手段に記憶された前記基準空間とに基づいて、マハラノビス距離を算出するマハラノビス距離算出手段と、
そのマハラノビス距離算出手段が算出した前記マハラノビス距離に基づいて前記検査品の良否判断を行う良否判断手段と、を備えることを特徴とする。
An inspection apparatus according to the present invention includes a storage unit that stores the reference space generated by the Mahalanobis reference space generation method according to any one of claims 1 to 10;
Inspection image acquisition means for acquiring an inspection image which is an image of an inspection product;
A gray region determination unit that determines whether or not the inspection image acquired by the inspection image acquisition unit includes an inspection product gray region that is a region that is difficult to distinguish whether it is a non-defective product;
When the gray area determining means determines that the inspection product gray area is included , a peripheral area that is a predetermined size area adjacent to an edge of the inspection product gray area in the inspection image area. Inspection product brightness acquisition means for acquiring brightness information;
An inspection product feature amount calculating means for calculating an inspection product feature amount that is a feature amount of the luminance information of the inspection product gray region based on the luminance information of the peripheral region acquired by the inspection product luminance acquisition unit;
Mahalanobis distance calculating means for calculating a Mahalanobis distance based on the inspection product feature value calculated by the inspection product feature value calculating means and the reference space stored in the storage means;
And a pass / fail judgment means for judging pass / fail of the inspection product based on the Mahalanobis distance calculated by the Mahalanobis distance calculation means.

これによれば、検査品の良品判断を行うために、良品か否かの区別が付きにくい検査品グレー領域のマハラノビス距離を算出するので、検査画像全体のマハラノビス距離を算出する場合に比べて、処理時間を短縮することができる。また、検査品グレー領域の周辺領域の輝度情報を基準とした検査品グレー領域の輝度情報の特徴量を算出しているので、検査画像の写り具合の影響が考慮された精度の良い特徴量を得ることができる。そして、良品画像の写り具合の影響が考慮された上記基準空間と、検査画像の写り具合の影響が考慮されたその特徴量とに基づいてマハラノビス距離を算出しているので、画像の写り具合に影響されない精度の良いマハラノビス距離を得ることができる。これにより、画像の写り具合に関わらず、検査品の良否判定を精度良く行うことができる。   According to this, in order to determine the non-defective product of the inspection product, the Mahalanobis distance of the inspection product gray region that is difficult to distinguish whether it is non-defective product is calculated, so compared to the case of calculating the Mahalanobis distance of the entire inspection image, Processing time can be shortened. In addition, since the feature value of the brightness information of the inspection product gray area is calculated based on the brightness information of the peripheral area of the inspection product gray area, a highly accurate feature value that takes into account the influence of the appearance of the inspection image is taken into account. Can be obtained. The Mahalanobis distance is calculated based on the above-mentioned reference space in which the influence of the quality of the non-defective image is taken into consideration and the feature amount in which the influence of the appearance of the inspection image is taken into account. An accurate Mahalanobis distance that is not affected can be obtained. As a result, it is possible to accurately determine the quality of the inspection product regardless of the image appearance.

また、本発明におけるマハラノビス距離算出手段は、前記検査品特徴量を正規化する正規化手段を含み、その正規化手段が正規化した前記検査品特徴量と前記基準空間とに基づいて、前記マハラノビス距離を算出するものであることを特徴とする。   Further, the Mahalanobis distance calculating means in the present invention includes a normalizing means for normalizing the inspection product feature value, and the Mahalanobis distance based on the inspection product feature value and the reference space normalized by the normalization means. It is characterized by calculating a distance.

これによれば、正規化手段が検査品特徴量を正規化し、マハラノビス距離算出手段は、その正規化された検査品特徴量を使用してマハラノビス距離を算出するので、精度の良いマハラノビス距離を得ることができる。   According to this, the normalization means normalizes the inspection product feature value, and the Mahalanobis distance calculation means calculates the Mahalanobis distance using the normalized inspection product feature value, so that an accurate Mahalanobis distance is obtained. be able to.

また、本発明の検査装置は、前記グレー領域判断手段が前記検査品グレー領域が含まれていないと判断した場合に、前記検査品を良品と判断する良品判断手段を備えることを特徴とする。   The inspection apparatus of the present invention is characterized by comprising non-defective product determining means for determining that the inspection product is a non-defective product when the gray region determining device determines that the inspection product gray region is not included.

これによれば、検査画像に検査品グレー領域が含まれていない場合には、良品判断手段によってその検査品が良品と判断されるので、その検査画像に対してマハラノビス距離を算出する処理を省略することができる。よって、検査品の良否判定の処理時間を短縮することができる。   According to this, when the inspection image does not include the inspection product gray area, the non-defective product determination unit determines that the inspection product is a non-defective product, and thus the process of calculating the Mahalanobis distance for the inspection image is omitted. can do. Therefore, it is possible to shorten the processing time for determining the quality of the inspection product.

検査装置1の全体構成を示した図である。1 is a diagram illustrating an overall configuration of an inspection apparatus 1. FIG. マハラノビス基準空間の生成手順を示したフローチャートである。It is the flowchart which showed the production | generation procedure of Mahalanobis reference space. 図2のS2の詳細手順を示したフローチャートである。It is the flowchart which showed the detailed procedure of S2 of FIG. 図3の画像処理の出力結果を例示した図である。It is the figure which illustrated the output result of the image processing of FIG. 図2のS3の詳細手順を示したフローチャートである。It is the flowchart which showed the detailed procedure of S3 of FIG. 図5のS31の詳細手順を示したフローチャートである。It is the flowchart which showed the detailed procedure of S31 of FIG. 図6の各処理ステップの過程における良品画像62を示した図である。FIG. 7 is a diagram illustrating a non-defective image 62 in the process of each processing step in FIG. 6. 図5のS32の詳細手順を示したフローチャートである。It is the flowchart which showed the detailed procedure of S32 of FIG. 良品グレー領域621を示した図である。FIG. 6 is a diagram showing a non-defective gray region 621. 図8のS322の積分特性、S323の画素数特性の算出方法を説明する図である。It is a figure explaining the calculation method of the integral characteristic of S322 of FIG. 8, and the pixel number characteristic of S323. 図8のS325の詳細手順を示したフローチャートである。It is the flowchart which showed the detailed procedure of S325 of FIG. 図8のS326の詳細手順を示したフローチャートである。It is the flowchart which showed the detailed procedure of S326 of FIG. 図2のS4の詳細手順を示したフローチャートである。It is the flowchart which showed the detailed procedure of S4 of FIG. 検査品の良否判定手順を示したフローチャートである。It is the flowchart which showed the quality determination procedure of the inspection goods. 検査品の複数のサンプルA〜Iの画像71〜79を示した図である。It is the figure which showed the images 71-79 of the some sample AI of a test | inspection goods. 従来のマハラノビス基準空間の生成手順を示したフローチャートである。It is the flowchart which showed the production | generation procedure of the conventional Mahalanobis reference space.

以下、本発明に係るマハラノビス基準空間の生成方法及び検査装置の実施形態を図面を参照しながら説明する。図1は、本実施形態の検査装置1の全体構成を示した図である。その検査装置1は、例えば切削加工した金属部品等の製品の表面にあるムラ、埃、傷、バリ等の有無を検査することで、その製品の外観の良否判定をする装置である。図1に示すように、検査装置1は、画像処理用PC10、報知器20、カメラ30、及び検査台50を備えている。検査台50は、マハラノビス基準空間を生成するための良品サンプル60(図1参照)や、被検査対象となる検査品70(図1参照)が載置される台である。カメラ30は、レンズ31を有し、そのレンズ31を介して検査台50に載置された良品サンプル60や検査品70を撮像するものである。そのカメラ30として、例えばCCDイメージセンサやデジタルスチルカメラを用いることができる。なお、良品サンプル60や検査品70をカメラ30で良好に撮像できるようにするために、良品サンプル60や検査品70に光を照射する照明(図示外)が適宜設けられる。   DESCRIPTION OF EMBODIMENTS Hereinafter, embodiments of a method for generating a Mahalanobis reference space and an inspection apparatus according to the present invention will be described with reference to the drawings. FIG. 1 is a diagram illustrating an overall configuration of an inspection apparatus 1 according to the present embodiment. The inspection device 1 is a device that determines the quality of the appearance of the product by inspecting the surface of the product such as a cut metal part for unevenness, dust, scratches, burrs, and the like. As shown in FIG. 1, the inspection apparatus 1 includes an image processing PC 10, a notification device 20, a camera 30, and an inspection table 50. The inspection table 50 is a table on which a non-defective product sample 60 (see FIG. 1) for generating the Mahalanobis reference space and an inspection product 70 (see FIG. 1) to be inspected are placed. The camera 30 has a lens 31, and images the non-defective sample 60 and the inspection product 70 placed on the inspection table 50 through the lens 31. As the camera 30, for example, a CCD image sensor or a digital still camera can be used. In order to allow the camera 30 to image the good product sample 60 and the inspection product 70 satisfactorily, illumination (not shown) for irradiating the good product sample 60 and the inspection product 70 with light is appropriately provided.

カメラ30で撮像された画像はケーブル40(図1参照)を介して、画像処理用PC10に送信される。画像処理用PC10は、検査品70の画像である検査画像に対して所定の画像処理を施しつつ、MT法を利用してその検査画像の良品判定、すなわち検査品70の良否判定を行うコンピュータである。また、画像処理用PC10は、検査画像の良否判定を行うのに先だって、良品サンプル60の画像である良品画像に基づいて、MT法で使用するマハラノビス基準空間を生成するコンピュータでもある。なお、検査品70を検査するコンピュータとマハラノビス基準空間を生成するコンピュータとを別々にしてもよい。   An image captured by the camera 30 is transmitted to the image processing PC 10 via the cable 40 (see FIG. 1). The image processing PC 10 is a computer that performs predetermined image processing on an inspection image, which is an image of the inspection product 70, and uses the MT method to determine non-defectiveness of the inspection image, that is, pass / fail determination of the inspection product 70. is there. The image processing PC 10 is also a computer that generates a Mahalanobis reference space used in the MT method based on a non-defective image, which is an image of the non-defective sample 60, prior to determining the quality of an inspection image. The computer that inspects the inspection product 70 and the computer that generates the Mahalanobis reference space may be separated.

画像処理用PC10は、より詳細には、CPU11及びメモリ12を有しており、CPU11がメモリ12に記憶された制御プログラムにしたがった処理を実行することで、マハラノビス基準空間を生成したり、検査品70の良否判定を行ったりする。なお、それらの詳細は後述する。メモリ12は、CPU11が実行する制御プログラムが記憶されたROMやフラッシュメモリ等の記憶装置である。また、本実施形態では、メモリ12には、画像処理用PC10が生成したマハラノビス基準空間も記憶される。   More specifically, the image processing PC 10 includes a CPU 11 and a memory 12. The CPU 11 executes a process according to a control program stored in the memory 12, thereby generating a Mahalanobis reference space or performing an inspection. The quality of the product 70 is judged. Details thereof will be described later. The memory 12 is a storage device such as a ROM or a flash memory in which a control program executed by the CPU 11 is stored. In the present embodiment, the memory 12 also stores the Mahalanobis reference space generated by the image processing PC 10.

報知器20は、画像処理用PC10によって行われた検査結果(検査品70の良否判定結果)を報知するものである。その報知器20として、例えば音で報知するスピーカや表示で報知するディスプレイを用いることができる。   The notification device 20 notifies an inspection result (a result of quality determination of the inspection product 70) performed by the image processing PC 10. As the notification device 20, for example, a speaker for notification by sound or a display for notification by display can be used.

次に、画像処理用PC10が実行するマハラノビス基準空間の生成方法について詳細に説明する。なお、画像処理用PC10がマハラノビス基準空間を生成するタイミングとしては、検査品70を検査する前であればどのタイミングでもよい。ここで、図2は、マハラノビス基準空間の生成手順を示したフローチャートである。先ず、図2を参照してマハラノビス基準空間の生成手順を大まかに説明し、その後、図2の各手順の詳細を説明する。なお、この図2の処理は、例えば、所定の開始スイッチ(図示外)がユーザに操作された場合に開始される。   Next, a method for generating the Mahalanobis reference space executed by the image processing PC 10 will be described in detail. The timing at which the image processing PC 10 generates the Mahalanobis reference space may be any timing as long as the inspection product 70 is not inspected. Here, FIG. 2 is a flowchart showing a procedure for generating the Mahalanobis reference space. First, the procedure for generating the Mahalanobis reference space will be roughly described with reference to FIG. 2, and then the details of each procedure in FIG. 2 will be described. Note that the processing in FIG. 2 is started, for example, when a predetermined start switch (not shown) is operated by the user.

図2において、先ず、良品と予め解っている良品サンプル、すなわち、目視検査員が良品と判断した良品サンプルが検査台50(図1参照)に載置されて、その良品サンプルをカメラ30で撮像してその画像(良品画像)を取得(収集)する(S1)。この際、複数の良品サンプルの良品画像を取得するようにする。次いで、S1で取得した各良品画像に対して、所定の画像処理が施されて、各良品画像に含まれた、良品か否かの区別が付きにくい領域である良品グレー領域を検出する(S2)。次いで、検出された良品グレー領域の輝度情報の特徴量を算出する(S3)。次いで、S3で算出された特徴量に基づいて、マハラノビス基準空間を生成する(S4)。その後、図2のフローチャートの処理を終了する。   In FIG. 2, first, a non-defective product sample that is known as a non-defective product, that is, a non-defective sample that the visual inspector has determined to be non-defective is placed on the inspection table 50 (see FIG. 1). Then, the image (good product image) is acquired (collected) (S1). At this time, non-defective images of a plurality of non-defective samples are acquired. Next, predetermined image processing is performed on each non-defective image acquired in S1, and a non-defective gray region that is difficult to distinguish whether it is non-defective or not included in each non-defective image is detected (S2). ). Next, the feature amount of the luminance information of the detected non-defective gray region is calculated (S3). Next, a Mahalanobis reference space is generated based on the feature amount calculated in S3 (S4). Thereafter, the processing of the flowchart of FIG.

このように、本発明では、良品画像の全体からマハラノビス基準空間を生成するのではなく、良品画像のうちの良品グレー領域からそれを生成している。ただし、良品グレー領域だけを考慮してマハラノビス基準空間を生成しているわけではなく、その良品グレー領域の周辺領域も考慮してマハラノビス基準空間を生成している。以下、図2の各手順を詳細に説明する。   As described above, in the present invention, the Mahalanobis reference space is not generated from the entire non-defective image, but is generated from the non-defective gray region of the non-defective image. However, the Mahalanobis reference space is not generated considering only the non-defective gray region, and the Mahalanobis reference space is generated considering the peripheral region of the good gray region. Hereinafter, each procedure of FIG. 2 will be described in detail.

図3は、図2の良品グレー領域を検出する画像処理(S2)の詳細手順を示したフローチャートである。具体的には、図2のS1で取得された良品画像に対して2値化処理(S21)、平滑処理(S22)、差分処理(S23)の順に画像処理を施す。なお、2値化処理、平滑処理、差分処理は当業者であれば説明の必要がないほど汎用的なので、各処理の詳細の説明は省略する。S21〜S23の画像処理によって検出された領域を良品か否かの区別が付きにくい良品グレー領域とする。次いで、その良品グレー領域とS21〜S23の画像処理が施される前の元の良品画像との両方を出力する(S24)。その後、図3のフローチャートの処理を終了する。   FIG. 3 is a flowchart showing a detailed procedure of the image processing (S2) for detecting the non-defective gray region in FIG. Specifically, the image processing is performed in the order of binarization processing (S21), smoothing processing (S22), and difference processing (S23) on the non-defective product image acquired in S1 of FIG. The binarization process, the smoothing process, and the difference process are general enough that those skilled in the art do not need to explain them, so the detailed description of each process is omitted. The region detected by the image processing of S21 to S23 is a non-defective gray region that is difficult to distinguish whether it is a non-defective product. Next, both the non-defective gray region and the original non-defective image before the image processing of S21 to S23 is output (S24). Then, the process of the flowchart of FIG. 3 is complete | finished.

この図3での画像処理の目的は、不良をほぼ全て検出できるように処理することであり、良品の過検出については問わない。すなわち、一般的に、過検出率と不良流出率はトレードオフの関係であるが、ここでの画像処理は、過検出を行ってもよいので、不良の可能性が少しでもあるものは、全て検出するように画像処理をしている。つまり、その不良の可能性が少しでもあるものを、ここでの良品グレー領域としている。なお、不良をほぼ全て検出できるようにするために、あらかじめ目視検査員が判断した、不良とわかっているサンプルを収集し、それらが全て検出できるように画像処理、つまりS21〜S23の各画像処理の条件(例えば2値化処理をする際の閾値)を決定している。   The purpose of the image processing in FIG. 3 is to perform processing so that almost all defects can be detected. In other words, in general, the overdetection rate and the defect outflow rate are in a trade-off relationship, but since the image processing here may perform overdetection, Image processing is performed to detect. That is, the non-defective gray region here is the one having the possibility of the defect even a little. In addition, in order to be able to detect almost all of the defects, samples that are known to be defective, which are determined in advance by a visual inspector, are collected, and image processing is performed so that all of them can be detected, that is, each image processing of S21 to S23. (For example, a threshold value when performing binarization processing) is determined.

なお、良品グレー領域を検出するための画像処理は、図3の処理手順(2値化処理→平滑処理→差分処理)のアルゴリズムに関わらず、既存として存在するアルゴリズムの中で、不良流出を極力防ぐように構成されたアルゴリズムであれば、当業者で利用しているものでも、それを利用することができる。   It should be noted that the image processing for detecting the non-defective gray region is performed as much as possible out of the existing algorithms, regardless of the algorithm of the processing procedure of FIG. 3 (binarization processing → smoothing processing → difference processing). Any algorithm that is configured to prevent may be used by those skilled in the art.

ここで、図4は、図3の画像処理の出力結果を例示した図であり、より厳密には、複数の良品サンプルA〜Eの入力画像61〜65と、それら入力画像61〜65に対する出力とを示している。なお、2値化処理、平滑処理及び差分処理は当業者であれば説明の必要がないほど汎用的なので、図4では、上記処理の途中経過については省略している。図4に示すように、ここでは、5つの良品サンプルA〜Eを用意し、図2のS1において、それら良品サンプルA〜Eの良品画像61〜65が取得される。そして、各良品画像61〜65が、図3の画像処理をするための入力画像とされる。良品サンプルAの良品画像61と良品サンプルDの良品画像64は汚れやムラの無いきれいな画像であることを想定している、また、良品サンプルBはその表面にムラがあることを想定しており、そのためにその良品画像62にはムラを示した良品グレー領域621が含まれている。同様に、良品サンプルEはその表面にムラがあることを想定しており、そのためにその良品画像65にはムラを示した良品グレー領域651が含まれている。また、良品サンプルCはその表面に埃が載っていることを想定しており、そのためにその良品画像63には埃を示した良品グレー領域631が含まれている。   Here, FIG. 4 is a diagram illustrating an output result of the image processing of FIG. 3, and more strictly, input images 61 to 65 of a plurality of non-defective samples A to E and outputs to these input images 61 to 65. It shows. Since the binarization process, the smoothing process, and the difference process are general enough that those skilled in the art need not to explain them, the intermediate process of the above process is omitted in FIG. As shown in FIG. 4, here, five good samples A to E are prepared, and good images 61 to 65 of these good samples A to E are acquired in S1 of FIG. Then, the non-defective images 61 to 65 are input images for performing the image processing of FIG. The good image 61 of the non-defective sample A and the non-defective image 64 of the good sample D are assumed to be clean images with no dirt or unevenness, and the good sample B is assumed to have unevenness on the surface. Therefore, the non-defective product image 62 includes a non-defective product gray region 621 showing unevenness. Similarly, it is assumed that the non-defective product sample E has unevenness on the surface thereof, and therefore, the non-defective product image 65 includes a non-defective product gray region 651 showing unevenness. Further, it is assumed that the non-defective sample C has dust on its surface, and therefore the non-defective image 63 includes a non-defective gray region 631 showing dust.

これら良品画像61〜65に対して、図3のS21〜S23の画像処理を施すことで、S24において、図4の下欄の出力画像が出力される。具体的には、良品サンプルBの良品画像62に対しては、その良品画像62に含まれる良品グレー領域621及び良品画像62が出力される。また、良品サンプルCの良品画像63に対しては、その良品画像63に含まれる良品グレー領域631及び良品画像63が出力される。また、良品サンプルEの良品画像65に対しては、その良品画像65に含まれる良品グレー領域651及び良品画像65が出力される。なお、良品サンプルA及び良品サンプルDは良品グレー領域が含まれていない良品であるので、図3のS24においては何も出力されない。なお、ムラや埃を良品とするか、不良とするかどうかは、検出要件によって異なるが、図4の例では、ムラや埃はただのノイズとして、良品と扱う事を前提にしている。そのため、図3のS21〜S23の画像処理においては、良品画像62、63、65に対して過検出をしている状況とされる。   By performing the image processing of S21 to S23 in FIG. 3 on these non-defective images 61 to 65, the output image in the lower column of FIG. 4 is output in S24. Specifically, for the good product image 62 of the good product sample B, the good product gray area 621 and the good product image 62 included in the good product image 62 are output. For the good product image 63 of the good product sample C, the good product gray region 631 and the good product image 63 included in the good product image 63 are output. For the good product image 65 of the good product sample E, the good product gray region 651 and the good product image 65 included in the good product image 65 are output. Since the non-defective sample A and the non-defective sample D are non-defective products that do not include the non-defective gray region, nothing is output in S24 of FIG. Whether unevenness or dust is a good product or defective depends on the detection requirements, but in the example of FIG. 4, it is assumed that the unevenness and dust are treated as good products as just noise. Therefore, in the image processing of S21 to S23 in FIG. 3, it is assumed that overdetection is performed on the non-defective images 62, 63, and 65.

次に、図2のS3の特徴量算出処理の詳細を説明する。ここで、図5はその特徴量算出処理の詳細手順を示したフローチャートである。本発明では、良品グレー領域の特徴量として、良品グレー領域の周辺領域の輝度情報を基準とした良品グレー領域の輝度分布データを算出する。具体的には、先ず、良品グレー領域の周辺領域の輝度情報を基準とするために、その周辺領域の輝度情報を代表する閾値THを設定する(S31)。なお、その閾値THが本発明の「代表値」に相当する。図6は、その閾値設定の詳細手順を示したフローチャートである。なお、ここでは、図4のサンプルBの良品画像62及びその良品グレー領域621を図6の処理の対象として説明する。また、図7は、図6の各処理ステップの過程における良品画像62を示した図である。   Next, details of the feature amount calculation processing in S3 of FIG. 2 will be described. Here, FIG. 5 is a flowchart showing a detailed procedure of the feature amount calculation processing. In the present invention, the luminance distribution data of the non-defective gray region is calculated as the feature amount of the non-defective gray region based on the luminance information of the peripheral region of the non-defective gray region. Specifically, first, in order to use the luminance information of the peripheral area of the non-defective gray area as a reference, a threshold value TH representing the luminance information of the peripheral area is set (S31). The threshold value TH corresponds to the “representative value” of the present invention. FIG. 6 is a flowchart showing a detailed procedure for setting the threshold. Here, the non-defective product image 62 and the non-defective gray region 621 of the sample B in FIG. 4 will be described as the processing target in FIG. FIG. 7 is a diagram showing a non-defective image 62 in the process of each processing step in FIG.

先のS2で検出した良品グレー領域621及びそれが含まれた良品画像62(図7(a)参照)が入力されて、先ず、良品画像62に含まれた良品グレー領域621の領域を拡大する領域拡大処理を実行する(S311)。具体的には、図7(b)に示すように、先のS2で検出した良品グレー領域621について、良品グレー領域621のエッジ621b全周に渡ってその良品グレー領域621を特定範囲大きくした領域622を、原画像である良品画像62から取得する(S311)。本実施形態では、良品グレー領域621の拡大率を、そのエッジ621b+1pixcel(図7(b)参照)に設定している。   The non-defective product gray area 621 detected in the previous S2 and the non-defective product image 62 (see FIG. 7A) including the same are input. First, the non-defective product gray area 621 included in the non-defective image 62 is enlarged. An area enlargement process is executed (S311). Specifically, as shown in FIG. 7B, for the non-defective gray region 621 detected in S2, the non-defective gray region 621 is enlarged by a specific range over the entire periphery of the edge 621b of the non-defective gray region 621. 622 is acquired from the non-defective image 62 which is the original image (S311). In the present embodiment, the enlargement ratio of the non-defective gray region 621 is set to the edge 621b + 1pixel (see FIG. 7B).

次いで、差分処理を施して、良品グレー領域621と拡大領域622との差分領域623を抽出する(S312、図7(c)参照)。この差分領域623は、(拡大領域622)−(良品グレー領域621)を行うことで抽出できる。なお、この差分領域623が、良品グレー領域621の周辺領域とされる。以下、差分領域623を周辺領域と言う。   Next, a difference process is performed to extract a difference area 623 between the non-defective gray area 621 and the enlarged area 622 (S312; see FIG. 7C). The difference area 623 can be extracted by performing (enlarged area 622) − (non-defective gray area 621). This difference area 623 is set as a peripheral area of the non-defective gray area 621. Hereinafter, the difference area 623 is referred to as a peripheral area.

次いで、周辺領域623の各画素の輝度値を取得する(S313)。ここで、説明簡略のために、図7(d)に示すように、周辺領域623の画素数を15画素としてS313の処理の具体例を説明する。S313では、周辺領域623の各画素623aに順番に番号を割り振っていく。ここでは、図7(d)に示すように、図7(d)の紙面左上にいくほど小さい番号になるよう、言い換えると紙面右下にいくほど大きい番号になるように、各画素623aに対して1番から順番に番号を割り振っていく。この場合、15番まで番号が割り振られることになる。また、各画素623aに番号を割り振るのと並行して、各画素623aの輝度値を取得していく。これによって得られた輝度データを次の表1に示す。なお、表1では、割り振られた番号順に輝度値を示している。   Next, the luminance value of each pixel in the peripheral area 623 is acquired (S313). Here, for the sake of brevity, a specific example of the processing of S313 will be described assuming that the number of pixels in the peripheral region 623 is 15 as shown in FIG. In S313, numbers are sequentially assigned to the respective pixels 623a in the peripheral area 623. Here, as shown in FIG. 7D, each pixel 623a has a smaller number as it goes to the upper left side of FIG. 7D, in other words, a higher number that goes to the lower right side of the page. Numbers are assigned in order from the first. In this case, numbers up to 15 are allocated. In parallel with assigning a number to each pixel 623a, the luminance value of each pixel 623a is acquired. The luminance data thus obtained is shown in Table 1 below. In Table 1, luminance values are shown in order of assigned numbers.

次いで、表1の各輝度値の最小値(本実施形態の場合は1番:輝度値35)と、各輝度値の平均値を取得する(S314)。ただし、輝度値は整数で表されるものであるので、求めた平均値(41.067)の小数点以下は切り捨てて、平均輝度値は41として取得する。   Next, the minimum value of each luminance value in Table 1 (1 in the present embodiment: luminance value 35) and the average value of each luminance value are acquired (S314). However, since the luminance value is represented by an integer, the calculated average value (41.067) is rounded down to obtain 41 as the average luminance value.

次いで、それら輝度値の最小値、平均値に基づいて、周辺領域623の輝度情報を代表する閾値THを設定する(S315)。具体的には、求めた最小値と平均値の間の範囲で複数の閾値THを設定するようにする。ここでは、良品グレー領域621の特徴量を算出するための閾値THとして、35(最小値)〜41(平均値)の範囲で、35、37、39、41というように設定している。最小値と平均値の間の範囲でどのように閾値THを設定するかは、例えば、設定する閾値THの数が予め定められており、その閾値THの数で最小値と平均値の間の範囲を等分したときにおける各等分点の値を閾値THとして設定する。なお、良品グレー領域621以外の良品グレー領域631、651(図4参照)についても、前述と同様の処理を行って、それぞれの領域631、651について閾値THを設定する。   Next, a threshold value TH representing the luminance information of the peripheral area 623 is set based on the minimum value and the average value of the luminance values (S315). Specifically, a plurality of threshold values TH are set in a range between the obtained minimum value and average value. Here, the threshold TH for calculating the feature amount of the non-defective gray region 621 is set to 35, 37, 39, 41 in the range of 35 (minimum value) to 41 (average value). The threshold TH is set in the range between the minimum value and the average value. For example, the number of threshold values TH to be set is determined in advance. The value of each equally dividing point when the range is equally divided is set as the threshold value TH. Note that the non-defective gray regions 631 and 651 (see FIG. 4) other than the non-defective gray region 621 are also subjected to the same processing as described above, and the threshold value TH is set for each of the regions 631 and 651.

なお、本実施形態では、輝度の最小値、平均値に基づいて閾値THを設定しているが、例えば輝度値の偏差、中央値、最大値などを利用することもできる。例えば最小値と偏差を利用する場合には、最小値±3σ(σ=標準偏差)の範囲で、任意に閾値THを設定することや、最大値±3σの範囲で閾値THを設定することもできる。このように、閾値THを設定する方法はいくらでも存在するが、本発明の特徴は、この閾値THを、良品グレー領域の周辺領域の輝度情報から決めていることにある。   In the present embodiment, the threshold value TH is set based on the minimum value and the average value of the luminance. However, for example, a deviation of the luminance value, a median value, a maximum value, and the like can be used. For example, when using the minimum value and the deviation, the threshold TH may be arbitrarily set within the range of the minimum value ± 3σ (σ = standard deviation), or the threshold TH may be set within the range of the maximum value ± 3σ. it can. As described above, there are any number of methods for setting the threshold value TH, but the feature of the present invention is that the threshold value TH is determined from the luminance information of the peripheral region of the non-defective gray region.

S315で閾値THを設定した後、図6のフローチャートの処理を終了して、図5の処理に戻る。次いで、S31で設定した閾値THに基づいて、良品グレー領域の輝度分布データを算出する(S32)。ここで、図8は、その輝度分布データの算出の詳細手順を示したフローチャートである。なお、ここでも、図4のサンプルBの良品画像62を図8の処理の対象として説明する。また、良品画像62に含まれる良品グレー領域621の画素数が11画素として説明する。先ず、良品画像62に含まれる良品グレー領域621の各画素の輝度値を取得する(S321)。ここで、図9は、良品グレー領域621を示した図である。S321では、良品グレー領域621の各画素621a(図9参照)に順番に番号を割り振っていく。ここでは、先に説明した周辺領域の場合と同様に、図9の紙面左上にいくほど、言い換えると紙面右下にいくほど大きい番号になるように、各画素621aに対して1番から11番まで順番に番号を割り振っていく。また、各画素621aに番号を割り振るのと並行して、各画素621aの輝度値を取得していく。これによって得られた輝度データを次の表2に示す。なお、表2では、割り振られた番号順に輝度値を示している。   After setting the threshold value TH in S315, the process of the flowchart of FIG. 6 is terminated, and the process returns to the process of FIG. Next, the luminance distribution data of the non-defective gray region is calculated based on the threshold value TH set in S31 (S32). FIG. 8 is a flowchart showing a detailed procedure for calculating the luminance distribution data. Here, the non-defective product image 62 of the sample B in FIG. 4 will be described as the processing target in FIG. Further, the description will be made assuming that the number of pixels of the non-defective gray region 621 included in the non-defective image 62 is 11 pixels. First, the luminance value of each pixel of the non-defective gray region 621 included in the non-defective image 62 is acquired (S321). Here, FIG. 9 is a diagram showing a non-defective gray region 621. In S321, numbers are sequentially assigned to the respective pixels 621a (see FIG. 9) in the non-defective gray region 621. Here, as in the case of the peripheral area described above, the numbers from 1 to 11 are assigned to each pixel 621a so that the number increases as it goes to the upper left in FIG. 9, in other words, to the lower right. Numbers are assigned in order. In parallel with assigning a number to each pixel 621a, the luminance value of each pixel 621a is acquired. The luminance data thus obtained is shown in Table 2 below. In Table 2, the luminance values are shown in the order of the assigned numbers.

次いで、表2の各輝度値及び先の図5のS31で設定した閾値THに基づいて、その閾値THを基準とした良品グレー領域621の輝度分布データを算出する(S322、S323)。具体的には、先ず、良品グレー領域621の輝度分布データとして、良品グレー領域621がその周辺領域623(図7参照)に対してどの程度明るくされているかを示した積分特性を算出する(S322)。ここで、図10(a)は、その積分特性の算出方法を説明する図であり、具体的には、横軸が画素番号、縦軸が輝度値のグラフを示している。また、図10(a)のグラフは、表2の各輝度値が点でプロットされている。なお、それら各輝度値の点をP1〜P11で示している。また、図10(a)では、先で設定した閾値THのラインL1(図10(a)では、閾値TH=35のラインL1)が引かれている。   Next, based on each luminance value in Table 2 and the threshold value TH set in S31 of FIG. 5, the luminance distribution data of the non-defective gray region 621 with reference to the threshold value TH is calculated (S322, S323). Specifically, first, as the luminance distribution data of the non-defective gray region 621, an integral characteristic indicating how bright the non-defective gray region 621 is with respect to the peripheral region 623 (see FIG. 7) is calculated (S322). ). Here, FIG. 10A is a diagram for explaining a method of calculating the integral characteristic. Specifically, the horizontal axis represents a pixel number and the vertical axis represents a luminance value graph. In the graph of FIG. 10A, each luminance value in Table 2 is plotted with dots. Note that the points of the respective luminance values are indicated by P1 to P11. Further, in FIG. 10A, the line L1 with the threshold TH set earlier (the line L1 with the threshold TH = 35 in FIG. 10A) is drawn.

積分特性の算出をするために、輝度値P1〜P11のうち閾値THのラインL1より高い輝度値P3、P5、P6、P9、P10、P11から閾値THを引いたときの値を、各輝度値P3、P5、P6、P9、P10、P11ごとに算出する。輝度値Pと閾値THの差分値をΔPとすると、図10(a)では、画素番号3の差分値ΔP3、画素番号5の差分値ΔP5、画素番号6の差分値ΔP6、画素番号9の差分値ΔP9、画素番号10の差分値ΔP10及び画素番号11の差分値ΔP11を示している。なお、閾値THより小さい輝度値に対する差分値ΔPに関しては、ΔP=0として計算する。そして、各差分値ΔPの合計値(=Σ(輝度値−閾値TH))を積分特性として算出する。図10(a)では、閾値TH=35の例を示しているが、S322では、他の閾値TH(=37、39、41)に対しても、それぞれ積分特性を算出する。   In order to calculate the integral characteristic, a value obtained by subtracting the threshold value TH from the luminance values P3, P5, P6, P9, P10, and P11 higher than the line L1 of the threshold value TH among the luminance values P1 to P11 is set to each luminance value. Calculation is performed for each of P3, P5, P6, P9, P10, and P11. Assuming that the difference value between the luminance value P and the threshold value TH is ΔP, in FIG. 10A, the difference value ΔP3 of the pixel number 3, the difference value ΔP5 of the pixel number 5, the difference value ΔP6 of the pixel number 6, and the difference of the pixel number 9 A value ΔP9, a difference value ΔP10 of the pixel number 10 and a difference value ΔP11 of the pixel number 11 are shown. Note that the difference value ΔP for the luminance value smaller than the threshold value TH is calculated as ΔP = 0. Then, the total value of each difference value ΔP (= Σ (luminance value−threshold value TH)) is calculated as an integral characteristic. FIG. 10A shows an example in which the threshold value TH = 35, but in S322, the integral characteristics are calculated for other threshold values TH (= 37, 39, 41), respectively.

なお、今回の説明では、閾値THより上側(大きい)にある輝度値を対象としているが、逆に、閾値THより下側(小さい)部分の輝度値の面積に相当する積分特性(=Σ(閾値TH−輝度値))を算出してもよい。この場合には、良品グレー領域がその周辺領域に対してどの程度暗くされているかを示した特徴量を得ることができる。また、複数設定した閾値THの一部を上側にある輝度値を対象とし、別の閾値THは下側にある輝度値を対象にしてもよい。   In this description, the luminance value above (larger) the threshold value TH is targeted, but conversely, the integral characteristic (= Σ (= (())) corresponding to the area of the luminance value below (smaller) the threshold value TH. Threshold value TH-luminance value)) may be calculated. In this case, it is possible to obtain a feature amount indicating how dark the non-defective gray area is with respect to the surrounding area. Further, a part of the plurality of threshold values TH may be targeted for the luminance value on the upper side, and another threshold value TH may be targeted for the luminance value on the lower side.

図8の説明に戻り、S322で積分特性を算出した後、次いで、良品グレー領域621の輝度分布データとして、良品グレー領域621のうち、その周辺領域623(図7参照)より明るくされている領域がどの程度含まれているかを示した画素数特性を算出する(S323)。ここで、図10(b)は、その画素数特性の算出方法を説明する図であり、具体的には、図10(a)と同様に、横軸が画素番号、縦軸が輝度値のグラフに、各輝度値をプロットした点P1〜P11、閾値THのラインL1を示した図である。画素数特性として、閾値TH以上の輝度値Pを持つ画素の数をカウントしていく。図10(b)に示すように、閾値TH以上の輝度値Pは、輝度値P3、P4、P5、P6、P9、P10、P11とされる。よって、閾値TH=35の場合、画素数特性=7(画素)となる。図10(b)では、閾値TH=35の例を示しているが、S323では、他の閾値TH(=37、39、41)に対しても、それぞれ画素数特性を算出する。   Returning to the description of FIG. 8, after calculating the integral characteristics in S <b> 322, the area that is brighter than the peripheral area 623 (see FIG. 7) in the non-defective gray area 621 as the luminance distribution data of the non-defective gray area 621. The pixel number characteristic indicating how much is included is calculated (S323). Here, FIG. 10B is a diagram for explaining the calculation method of the pixel number characteristic. Specifically, as in FIG. 10A, the horizontal axis represents the pixel number and the vertical axis represents the luminance value. It is the figure which showed the line L1 of the points P1-P11 and threshold value TH which plotted each luminance value on the graph. As the pixel number characteristic, the number of pixels having the luminance value P equal to or higher than the threshold value TH is counted. As shown in FIG. 10B, the luminance values P equal to or higher than the threshold value TH are set as luminance values P3, P4, P5, P6, P9, P10, and P11. Therefore, when the threshold value TH = 35, the pixel number characteristic = 7 (pixels). FIG. 10B shows an example in which the threshold value TH = 35. However, in S323, the pixel number characteristics are calculated for other threshold values TH (= 37, 39, 41).

なお、画素数特性の算出に関しても、閾値TH以上の輝度値を持つ画素の数をカウントするのとは逆に、閾値THより小さい輝度値を持つ画素の数をカウントするようにしてもよい。この場合には、グレー領域のうち、その周辺領域より暗くされている領域がどの程度含まれているかを示した特徴量を得ることができる。また、複数設定した閾値THの一部を閾値TH以上の輝度値を持つ画素を対象とし、別の閾値THは閾値THより小さい輝度値を持つ画素を対象にしてもよい。なお、S322の処理とS323の処理は、どちらの処理を先に実行もよく、また並列して同時に実行してもよい。   Regarding the calculation of the pixel number characteristic, the number of pixels having a luminance value smaller than the threshold TH may be counted contrary to counting the number of pixels having a luminance value equal to or higher than the threshold TH. In this case, it is possible to obtain a feature amount indicating how much of the gray area is darker than the surrounding area. Further, a part of the plurality of threshold values TH may be targeted for pixels having a brightness value equal to or higher than the threshold value TH, and another threshold value TH may be targeted for pixels having a brightness value smaller than the threshold value TH. Note that either the process of S322 or the process of S323 may be executed first, or may be executed simultaneously in parallel.

S322及びS323によって得られた輝度分布データを次の表3に示す。なお、表3では、説明の対象とした良品グレー領域621の輝度分布データを示している。また、表3に示す閾値THは、良品グレー領域621に限った値であり、良品グレー領域の情報が変われば、それに伴って、周辺領域の輝度情報が変わるため、閾値THは変わる。つまり、良品グレー領域ごとに、閾値THが設定される。   The luminance distribution data obtained in S322 and S323 is shown in Table 3 below. Table 3 shows the luminance distribution data of the non-defective gray region 621 that is the subject of the description. The threshold value TH shown in Table 3 is a value limited to the non-defective gray region 621. If the information on the non-defective gray region is changed, the luminance information of the peripheral region is changed accordingly, and thus the threshold value TH is changed. That is, the threshold value TH is set for each good gray region.

S322及びS323にて算出した良品グレー領域の輝度分布データだけでもマハラノビス基準空間を生成するための十分条件であるが、さらに精度の良いマハラノビス基準空間を生成するために、他の特徴量を算出するようにしてもよい。そこで、図8のS323の処理の後、マハラノビス基準空間の良否判別精度を向上させるか否かを判断する(S324)。この判断は、例えば、マハラノビス基準空間の良否判別精度を向上させるか否かをユーザに確認し、そのユーザからの確認結果に基づいて、行う。ここで、マハラノビス基準空間の良否判別精度を向上させないと判断した場合には(S324:No)、図8のフローチャートの処理を終了する。この場合には、他の特徴量の算出が行われないので、基準空間を生成するための処理時間を短縮することができる。これに対し、マハラノビス基準空間の良否判別精度を向上させると判断した場合には(S324:Yes)、処理をS325に進める。   Only the luminance distribution data of the non-defective gray area calculated in S322 and S323 is a sufficient condition for generating the Mahalanobis reference space, but in order to generate a more accurate Mahalanobis reference space, other feature amounts are calculated. You may do it. Therefore, after the process of S323 in FIG. 8, it is determined whether or not the quality determination accuracy of the Mahalanobis reference space is to be improved (S324). This determination is made, for example, by confirming with the user whether or not to improve the pass / fail judgment accuracy of the Mahalanobis reference space, and based on the confirmation result from the user. Here, when it is determined that the quality determination accuracy of the Mahalanobis reference space is not improved (S324: No), the processing of the flowchart of FIG. 8 is terminated. In this case, since no other feature amount is calculated, the processing time for generating the reference space can be shortened. On the other hand, if it is determined to improve the pass / fail determination accuracy of the Mahalanobis reference space (S324: Yes), the process proceeds to S325.

S325では、先のS321にて取得した良品グレー領域の各画素の輝度値を、輝度値の大きさの順に並び替える並替処理を実行する。ここで、図11は、S325の並替処理の詳細手順を示したフローチャートである。なお、ここでは、上記表2の良品グレー領域621の輝度値に対して、図11の処理を適用した場合について説明する。先ず、表2の輝度値に対して昇順ソートを施して昇順に並び替える(S331)。このときの結果を次の表4に示す。   In S325, a rearrangement process is performed in which the luminance values of the pixels in the non-defective gray area acquired in S321 are rearranged in the order of the luminance values. Here, FIG. 11 is a flowchart showing a detailed procedure of the reordering process of S325. Here, the case where the processing of FIG. 11 is applied to the luminance value of the non-defective gray region 621 in Table 2 will be described. First, the luminance values in Table 2 are sorted in ascending order and rearranged in ascending order (S331). The results at this time are shown in Table 4 below.

次いで、表4の各画素の画素番号が順番になるように画素番号の再セットを行う(S332)。このときの結果を次の表5に示す。その後、図11のフローチャートの処理を終了する。   Next, the pixel numbers are reset so that the pixel numbers of the respective pixels in Table 4 are in order (S332). The results at this time are shown in Table 5 below. Then, the process of the flowchart of FIG. 11 is complete | finished.

図8の説明に戻り、次いで、S326〜S328にて、S325で並び替えた輝度値間の変化特性を示した変化特性値を算出する。具体的には、先ず、並び替えた輝度値に対して、大きさが隣り合う二つの輝度値間の変化特性を示した隣接変化特性値を算出する(S326)。ここで、図12は、そのS326の処理の詳細手順を示したフローチャートである。このフローチャートの処理では、iを1、2、3として、3回のループ処理が行われるようになっている。先ず、変数を初期化するために、nを1に、counterを0に設定する(S341、S342)。次いで、S325で並び替えたデータ(表5参照)から、n番目の画素の輝度値X(n)を取得し(S343)、n+1番目の画素の輝度値X(n+1)を取得する(S344)。ただし、nは、1、2、3、4・・・、Nmax(=良品グレー領域の画素数−1)とされる。表5の場合では11画素なので、nは1〜10までとされる。   Returning to the description of FIG. 8, next, in S326 to S328, a change characteristic value indicating a change characteristic between the luminance values rearranged in S325 is calculated. Specifically, first, an adjacent change characteristic value indicating a change characteristic between two luminance values whose sizes are adjacent to each other is calculated for the rearranged luminance values (S326). Here, FIG. 12 is a flowchart showing a detailed procedure of the processing of S326. In the process of this flowchart, i is 1, 2, and 3, and the loop process is performed three times. First, in order to initialize variables, n is set to 1 and counter is set to 0 (S341, S342). Next, the luminance value X (n) of the nth pixel is acquired from the data rearranged in S325 (see Table 5) (S343), and the luminance value X (n + 1) of the n + 1th pixel is acquired (S344). . However, n is 1, 2, 3, 4,..., Nmax (= the number of pixels in the non-defective gray region−1). In the case of Table 5, since 11 pixels, n is set to 1 to 10.

次いで、それら輝度値X(n)、X(n+1)の差分値ΔX(=X(n+1)−X(n))を算出する(S345)。次いで、その差分値ΔXが変数i以上とされているか否かを判断する(S346)。差分値ΔXが変数i以上の場合は(S346:Yes)、変数counterに1を加える(S347)。これに対して、差分値ΔXが変数i未満の場合には(S346:No)、現状の変数counterに保持する。次いで、変数nがNmax(=良品グレー領域の画素数−1)に達したか否かを判断する(S348)。未だ達していなければ(S348:No)、nに1を加えて(S349)、S343の処理に戻る。この場合、画素番号が前回から1大きくした隣り合う輝度値X(n)、X(n+1)に対して、上記と同じ処理が繰り返される(S343〜S348)。このように、変数nがNmaxに達するまでは、変数i以上とされる差分値ΔXの個数が変数counterとしてカウントされることになる。   Next, a difference value ΔX (= X (n + 1) −X (n)) between the luminance values X (n) and X (n + 1) is calculated (S345). Next, it is determined whether or not the difference value ΔX is greater than or equal to the variable i (S346). If the difference value ΔX is greater than or equal to the variable i (S346: Yes), 1 is added to the variable counter (S347). On the other hand, when the difference value ΔX is less than the variable i (S346: No), it is held in the current variable counter. Next, it is determined whether or not the variable n has reached Nmax (= the number of pixels in the non-defective gray region−1) (S348). If not reached yet (S348: No), 1 is added to n (S349), and the process returns to S343. In this case, the same processing as described above is repeated for adjacent luminance values X (n) and X (n + 1) whose pixel numbers are increased by 1 from the previous time (S343 to S348). In this way, until the variable n reaches Nmax, the number of difference values ΔX that are greater than or equal to the variable i is counted as the variable counter.

S348において、変数nがNmaxに達した場合には(S348:Yes)、counterの現在の値を取得するとともに(S350)、変数iに1を加えて、その新しい変数iに対して上記の処理(S341〜S349)が繰り返される。そして、変数i=3のときに、変数nがNmaxに達した場合に(S348:Yes、S350)、図12のフローチャートの処理を終了する。   If the variable n reaches Nmax in S348 (S348: Yes), the current value of counter is acquired (S350), and 1 is added to the variable i, and the above processing is performed for the new variable i. (S341 to S349) are repeated. When the variable i reaches Nmax when the variable i = 3 (S348: Yes, S350), the process of the flowchart of FIG.

なお、本実施形態では、ループ数を3回としたが、特にループ数は限定するものではない。また、差分値ΔXが変数i以上の場合にcounterを1加算するとしていたが(S346、S347)、S346の閾値についても変数i以上に限定されるものではない。例えば、変数i×2を閾値としたり、変数iに拘ることなく単に1、3、5、7というように数値を閾値としたりしてもよい。   In the present embodiment, the number of loops is three, but the number of loops is not particularly limited. Further, although the counter is incremented by 1 when the difference value ΔX is greater than or equal to the variable i (S346, S347), the threshold value of S346 is not limited to the variable i or more. For example, the variable i × 2 may be set as a threshold, or a numerical value such as 1, 3, 5, 7 may be set as a threshold regardless of the variable i.

ここで、変数i=1の場合について具体的な数値を用いて、図12の処理を説明する。なお、ここでは上記の表5の数値を用いて説明する。表5において、変数n=1の場合、1番目の輝度値X(n)=30、2番目の輝度値X(n+1)=31であるので、それら差分値ΔXは31−30=1と算出される。この差分値ΔX=1は、変数iの値である1以上であるので、counterに1が加算される。その後、変数nが2になって、2番目の輝度値X(n)=31、3番目の輝度値X(n+1)=31であるので、それら差分値ΔX=0と算出される。よって、counterの値は保持されて、変数nに1が加算される。これを繰り返していき、最終的に変数nが10になった段階で、変数i=1の場合の処理が完了する。良品グレー領域621について、変数iが1、2、3の場合のそれぞれのcounterの値を次の表6に示す。   Here, the processing of FIG. 12 will be described using specific numerical values in the case of the variable i = 1. In addition, it demonstrates using the numerical value of said Table 5 here. In Table 5, when the variable n = 1, since the first luminance value X (n) = 30 and the second luminance value X (n + 1) = 31, the difference value ΔX is calculated as 31-30 = 1. Is done. Since the difference value ΔX = 1 is 1 or more which is the value of the variable i, 1 is added to the counter. Thereafter, the variable n becomes 2, and the second luminance value X (n) = 31 and the third luminance value X (n + 1) = 31, so that the difference value ΔX = 0 is calculated. Therefore, the value of counter is retained and 1 is added to the variable n. This process is repeated, and at the stage when the variable n finally becomes 10, the process for the variable i = 1 is completed. Table 6 below shows the counter values when the variable i is 1, 2, and 3 for the non-defective gray region 621.

このように、S326の処理では、隣接変化特性値としてcounterの値が算出される。この隣接変化特性値は、不良の比較的急峻に変化する輝度(輝度の最小値と最大値の差が大きい)と、不良でないノイズの比較的なだらかな輝度変化(輝度の最小値と最大値の差が小さい)の差を抽出する役割を果たしている。   Thus, in the process of S326, the value of counter is calculated as the adjacent change characteristic value. This adjacent change characteristic value is a relatively gentle change in luminance (minimum and maximum values of luminance) between a relatively steeply changing luminance (a large difference between the minimum and maximum luminance values) and non-defective noise. It plays the role of extracting the difference (small difference).

図8の説明に戻り、S326の処理の後、S325で並び替えられた輝度値を近似式で表した場合におけるその近似式の特性を示した近似式特性値を算出する(S327、S328)。本実施形態では、各輝度値を最小二乗法にてy=ax+bの直線で近似をする場合におけるその直線の傾きaと切片bを、近似式特性値として算出する。n個(表5の場合はn=11)の輝度値(x1、y1)、(x2、y2)、・・・、(xn、yn)の場合、先ず、次の式1によって、傾きaを算出する(S327)。なお、nは画素数、xは画素番号、yは輝度値である。   Returning to the description of FIG. 8, after the process of S326, approximate expression characteristic values indicating characteristics of the approximate expression when the luminance values rearranged in S325 are expressed by an approximate expression are calculated (S327, S328). In the present embodiment, when the luminance values are approximated by a line of y = ax + b by the method of least squares, the slope a and intercept b of the line are calculated as approximate expression characteristic values. In the case of n luminance values (x1, y1), (x2, y2),..., (xn, yn) of n (in Table 5, n = 11), first, the slope a is calculated by the following equation 1. Calculate (S327). Note that n is the number of pixels, x is a pixel number, and y is a luminance value.

次いで、次の式2によって、切片bを算出する(S328)。その後、図8のフローチャートの処理を終了する。   Next, the intercept b is calculated by the following equation 2 (S328). Thereafter, the process of the flowchart of FIG.

良品グレー領域621の場合(表5の場合)における傾きa及び切片bを次の表7に示す。   The slope a and the intercept b in the case of the non-defective gray region 621 (in the case of Table 5) are shown in Table 7 below.

このように、傾きa及び切片bは、各画素の輝度値を近似した近似式の特性を示したものであるので、良品グレー領域の輝度が各画素間でどのように変化しているかの特徴量を得ることができる。なお、S327、S328における近似式は直線近似でなくてもよく、例えば、y=ax+bにおけるxを対数にすることで、対数関数としての傾きaや切片bを、特徴量として求めてもよい。   As described above, since the slope a and the intercept b indicate characteristics of an approximate expression that approximates the luminance value of each pixel, the characteristics of how the luminance of the non-defective gray region changes between the pixels. The quantity can be obtained. Note that the approximation formulas in S327 and S328 do not have to be linear approximation. For example, the slope a or the intercept b as a logarithmic function may be obtained as a feature quantity by using x in y = ax + b as a logarithm.

以上説明した図8の処理によって算出された、良品グレー領域621の輝度分布データの結果を次の表8に示す。   Table 8 below shows the result of the luminance distribution data of the non-defective gray region 621 calculated by the processing of FIG. 8 described above.

以降、本明細書では、積分特性や画素数特性、輝度変化などを「項目」と記載し、それぞれの項目から得られた輝度分布データを総括して「特徴量」と記載する。なお、表8において、積分特性と画素数特性の項目で設定している閾値THは、良品グレー領域621に対するものなので、他の良品グレー領域631、651(図4参照)の特徴量を算出する場合には、各良品グレー領域ごとの閾値THが設定される。   Hereinafter, in this specification, integration characteristics, pixel number characteristics, luminance changes, and the like are referred to as “items”, and luminance distribution data obtained from each item is collectively referred to as “features”. In Table 8, since the threshold value TH set in the items of the integral characteristic and the pixel number characteristic is for the non-defective gray region 621, the feature amounts of the other non-defective gray regions 631 and 651 (see FIG. 4) are calculated. In this case, a threshold value TH is set for each good gray area.

説明を図5に戻り、S32によって輝度分布データを算出した後、図5のフローチャートの処理を終了して、図2のフローチャートの処理に戻る。図2において、次いで、S3で算出した特徴量に基づいて、マハラノビス基準空間を生成する(S4)。ここで、図13は、S4の処理の詳細手順を示したフローチャートである。以下、説明を簡略化するために、S3で算出した特徴量を次の表9の記号に置き換えて、マハラノビス基準空間の生成方法について説明する。なお、表9では、図4の良品グレー領域621、631、651のそれぞれについて、各項目に対する特徴量を記号Xで示している。また、各特徴量Xの添え字nは良品グレー領域のサンプル数を示しており、添え字kは項目数を示している。   Returning to FIG. 5, after calculating the luminance distribution data in S <b> 32, the process of the flowchart of FIG. 5 is terminated and the process returns to the process of the flowchart of FIG. 2. In FIG. 2, next, a Mahalanobis reference space is generated based on the feature amount calculated in S3 (S4). Here, FIG. 13 is a flowchart showing a detailed procedure of the process of S4. Hereinafter, in order to simplify the description, the method of generating the Mahalanobis reference space will be described by replacing the feature amount calculated in S3 with the symbols in Table 9 below. In Table 9, for each of the non-defective gray regions 621, 631, and 651 in FIG. In addition, the subscript n of each feature quantity X indicates the number of samples in the non-defective gray region, and the subscript k indicates the number of items.

マハラノビス基準空間の生成方法としては幾つか手法が確立されているが、本実施形態では、その中でも頻繁に利用される計算方法で生成を行っている。なお、生成の過程で、上記表9のnとkの関係は少なくともn>=kである必要がある。表9では、良品グレー領域621、631、651のみ特徴量Xを示しているが、実際は、その他にも沢山のサンプル数nが確保されている。なお、表9の場合には、積分特性と画素数特性の計算において、良品グレー領域621、631、651ごとに閾値THが決まるが、以降は簡略化のために、閾値THと、輝度変化、傾き、切片を省略して説明していく。   Several methods have been established as a method for generating the Mahalanobis reference space, but in the present embodiment, generation is performed by a frequently used calculation method. In the generation process, the relationship between n and k in Table 9 needs to be at least n> = k. In Table 9, the feature amount X is shown only for the non-defective gray regions 621, 631, and 651, but in fact, many other sample numbers n are secured. In the case of Table 9, the threshold value TH is determined for each of the non-defective gray regions 621, 631, and 651 in the calculation of the integral characteristic and the pixel number characteristic. However, for the sake of simplification, the threshold value TH, the luminance change, The explanation will be made with the inclination and intercept omitted.

図13において、先ず、次の式3によって特徴量Xの正規化を行う(S41)。なお、式3において、Xj(式3ではオーバーバー付)はj番目の項目の平均値であり、σjはj番目の項目の標準偏差である。   In FIG. 13, first, the feature quantity X is normalized by the following expression 3 (S41). In Equation 3, Xj (with overbar in Equation 3) is the average value of the jth item, and σj is the standard deviation of the jth item.

式3で正規化した後のデータxを次の表10に示す。   Data x after normalization with Equation 3 is shown in Table 10 below.

次いで、次の式4によって相関係数rpqを算出する(S42)。その後、各相関係数r11〜rkkから構成された相関行列Rを生成する(S42)。   Next, the correlation coefficient rpq is calculated by the following equation 4 (S42). Thereafter, a correlation matrix R composed of the correlation coefficients r11 to rkk is generated (S42).

次いで、次の式5で示すように、相関行列Rの逆行列Aを算出する(S43)。その逆行列Aをマハラノビス基準空間とする。   Next, as shown in the following Expression 5, an inverse matrix A of the correlation matrix R is calculated (S43). Let the inverse matrix A be the Mahalanobis reference space.

その後、図13のフローチャートの処理を終了して、図2のフローチャートの処理に戻る。そして、S4の処理の後、図2のフローチャートの処理を終了する。以上のようにして、本発明におけるマハラノビス基準空間が生成される。その生成したマハラノビス基準空間は、検査品の良否判定を行う際に使用するために、メモリ12(図1参照)に記憶される。   Thereafter, the process of the flowchart of FIG. 13 is terminated, and the process returns to the process of the flowchart of FIG. Then, after the process of S4, the process of the flowchart of FIG. As described above, the Mahalanobis reference space in the present invention is generated. The generated Mahalanobis reference space is stored in the memory 12 (see FIG. 1) for use in determining whether the inspection product is good or bad.

次に、画像処理用PC10が実行する検査品の良否判定の方法について詳細に説明する。ここで、図14は、その方法の手順を示したフローチャートである。なお、図14のフローチャートの処理は、例えば、所定の開始スイッチ(図示外)がユーザに操作された場合に開始される。   Next, a method for determining pass / fail of an inspection product executed by the image processing PC 10 will be described in detail. FIG. 14 is a flowchart showing the procedure of the method. Note that the processing of the flowchart of FIG. 14 is started, for example, when a predetermined start switch (not shown) is operated by the user.

先ず、検査台50(図1参照)に載置された検査品をカメラ30で撮像して、その撮像画像である検査画像を取得する(S51)。次いで、その検査画像に対して所定の画像処理を施して、その検査画像に含まれるグレー領域(検査品グレー領域)を検出する(S52)。このS52の処理の詳細は、先に説明した基準空間を生成するときの処理(図3の処理)と同じである。また、このときの画像処理(図3の2値化処理、平滑処理、差分処理)の条件は、良品画像の良品グレー領域を検出したときの条件と同じに設定する。つまり、検査品グレー領域は、良品グレー領域と同様に、良品か否かの区別が付きにくい領域とされ、換言すると不良の可能性のある領域とされる。   First, an inspection product placed on the inspection table 50 (see FIG. 1) is imaged by the camera 30, and an inspection image which is a captured image is acquired (S51). Next, predetermined image processing is performed on the inspection image to detect a gray region (inspection product gray region) included in the inspection image (S52). The details of the process of S52 are the same as the process (process of FIG. 3) when generating the reference space described above. Further, the conditions of the image processing (binarization processing, smoothing processing, difference processing in FIG. 3) at this time are set to be the same as the conditions when the non-defective gray region of the non-defective image is detected. That is, the inspection product gray region is a region where it is difficult to distinguish whether it is a non-defective product, in other words, a non-defective product gray region.

次いで、S52の処理によって検査品グレー領域が検出されたか否かを判断する(S53)。これは、S52の処理によって検査品グレー領域が検出された場合にはその検査品グレー領域が出力されるので、検査品グレー領域の出力の有無によってS53の判断を行う。検査品グレー領域が検出されなかった場合には(S53:No)、その検査品は良品であると判断し(S61)、図14のフローチャートを終了する。これに対し、検査品グレー領域が検出された場合には(S53:Yes)、処理をS54に進める。   Next, it is determined whether or not an inspection product gray area is detected by the process of S52 (S53). This is because when the inspection product gray area is detected by the processing of S52, the inspection product gray area is output, and therefore the determination of S53 is performed based on whether or not the inspection product gray area is output. If the inspection product gray area is not detected (S53: No), it is determined that the inspection product is a non-defective product (S61), and the flowchart of FIG. 14 ends. On the other hand, when the inspection product gray area is detected (S53: Yes), the process proceeds to S54.

S54では、その検査品グレー領域の輝度分布データ(特徴量)を算出する(S54)。このS54の処理の詳細は、先に説明した基準空間を生成するときの処理(図2のS3の処理)と同じである。すなわち、検査品グレー領域の周辺領域を基準とした輝度分布データを算出する。次いで、上記の式3と同様の式によって、その輝度分布データである特徴量を正規化する(S55)。なお、正規化の際に用いる平均値と標準偏差は、上記式3の良品画像の平均値Xj(式3ではオーバーバー付き)及び標準偏差σjを用いる。次いで、メモリ12(図1参照)に記憶されたマハラノビス基準空間を読み出す(S56)。   In S54, luminance distribution data (feature amount) of the inspection product gray area is calculated (S54). The details of the process of S54 are the same as the process (S3 of FIG. 2) for generating the reference space described above. That is, luminance distribution data based on the peripheral region of the inspection product gray region is calculated. Next, the feature quantity, which is the luminance distribution data, is normalized by the same expression as Expression 3 above (S55). As the average value and standard deviation used in normalization, the average value Xj (with overbar in Expression 3) and the standard deviation σj of Expression 3 are used. Next, the Mahalanobis reference space stored in the memory 12 (see FIG. 1) is read (S56).

次いで、そのマハラノビス基準空間に基づいて、検査画像、厳密には検査画像に含まれた検査品グレー領域のマハラノビス距離(MD値)を算出する(S57)。具体的には、マハラノビス基準空間(上記式5参照)と、S55で正規化した特徴量のデータ(x11〜xik、ただしkは項目数、iはi=1、2、3、・・・、識別したい検査品グレー領域の数)とを、次の式6、式7に代入することにより、MD値を算出する。   Next, based on the Mahalanobis reference space, the Mahalanobis distance (MD value) of the inspection image, strictly speaking, the gray area of the inspection product included in the inspection image is calculated (S57). Specifically, the Mahalanobis reference space (see Equation 5 above) and the feature data normalized in S55 (x11 to xik, where k is the number of items, i is i = 1, 2, 3,... The MD value is calculated by substituting (the number of inspection product gray regions to be identified) into the following expressions 6 and 7.

例えば、検査品グレー領域が5箇所検出された場合には、各検査品グレー領域にi=1番から5番までの番号を振ったときに、上記式6、式7によって、1番(i=1)におけるMD値〜5番(i=5)におけるMD値の全部で5つのMD値が算出される。   For example, if five inspection product gray areas are detected, when the number from i = 1 to 5 is assigned to each inspection product gray area, the number 1 (i = 1) to five MD values in total from the MD value in No. 5 to the MD value in No. 5 (i = 5).

次いで、そのMD値が予め設定された閾値以上であるか否かを判断する(S58)。MD値が閾値より小さい場合には(S58:No)、その検査品は良品であると判断する(S60)。これに対し、MD値が閾値以上の場合には(S58:Yes)、その検査品は不良品であると判断する(S59)。なお、閾値の設定方法についてはいくつかの方法が考えられるが、以下にその1例をあげる。すなわち、予め良品か不良か解っている被検査対象のMD値をそれぞれ求め、テスト用閾値を設定し、誤判定した場合の損失を求める。テスト用閾値を複数変更した場合に、一番損失が少なくなる閾値を、S58で使用する閾値に設定する。なお、不良流出を可能な限り防ぐ場合には、予め不良と解っている被検査対象のMD値を複数求め、求めたMD値の最小値よりも小さい値で閾値を設定する。   Next, it is determined whether or not the MD value is greater than or equal to a preset threshold value (S58). If the MD value is smaller than the threshold value (S58: No), it is determined that the inspection product is a non-defective product (S60). On the other hand, if the MD value is equal to or greater than the threshold value (S58: Yes), it is determined that the inspection product is defective (S59). There are several methods for setting the threshold, and one example is given below. That is, the MD value of the object to be inspected, which is known to be a good product or a defective product, is obtained, a test threshold value is set, and a loss in the case of erroneous determination is obtained. When a plurality of test threshold values are changed, the threshold value with the smallest loss is set as the threshold value used in S58. In order to prevent defective outflow as much as possible, a plurality of MD values to be inspected that are known to be defective in advance are obtained, and a threshold value is set with a value smaller than the minimum value of the obtained MD values.

その後、良品(S60)、不良(S59)に関わらず報知器20(ディスプレイなど)で報知する(S62)。特に不良判定の場合には、検査員などがそれを認識できるように、ディスプレイ上で強調したり、音を出したりするなどして、報知の度合いを強くする(S62)。その後、図14のフローチャートの処理を終了する。   Thereafter, the notification device 20 (display or the like) notifies whether the product is good (S60) or defective (S59) (S62). Particularly in the case of defect determination, the degree of notification is increased by emphasizing on the display or making a sound so that the inspector can recognize it (S62). Then, the process of the flowchart of FIG.

次に、具体的な検査品のサンプルを挙げて、本実施形態の検査装置1(図1参照)による良否判定を行った場合について説明する。ここで、図15は、検査品の複数のサンプルA〜Iの画像71〜79を示している。図15の上段に示したサンプルA〜Fは、目視検査員が良品と判断した良品サンプルとされる。ただし、良品サンプルA、B、Dにはそれぞれムラが存在し、それら画像71、72、74にはムラを示した領域(検査品グレー領域)711、721、741が含まれている。また、良品サンプルCには埃が存在し、そのためにその画像73には埃を示した領域(検査品グレー領域)731が含まれている。また、良品サンプルE、Fはきれいな良品であり、そのためにそれら画像75、76には検査品グレー領域が含まれていない。一方、図15の下段に示したサンプルG〜Iは、目視検査員が不良と判断した不良サンプルである。各不良サンプルG〜Iには不良の原因とされる欠陥が存在し、そのためにそれら画像77〜79には欠陥を示した領域(検査品グレー領域)771〜791が含まれている。   Next, the case where the quality determination by the inspection apparatus 1 (refer FIG. 1) of this embodiment is performed is given, giving a sample of a specific inspection product. Here, FIG. 15 shows images 71 to 79 of a plurality of samples A to I of the inspection product. Samples A to F shown in the upper part of FIG. 15 are good samples that the visual inspector has determined to be good. However, the non-defective samples A, B, and D have unevenness, and the images 71, 72, and 74 include areas (inspected product gray areas) 711, 721, and 741 that show unevenness. In addition, dust is present in the non-defective sample C, and therefore the image 73 includes a region 731 (inspected product gray region) showing dust. Further, the non-defective samples E and F are clean non-defective products, and therefore, the images 75 and 76 do not include the inspection product gray region. On the other hand, samples G to I shown in the lower part of FIG. 15 are defective samples that the visual inspector determines to be defective. Each of the defective samples G to I has a defect that causes the defect. For this reason, the images 77 to 79 include areas (inspected product gray areas) 771 to 791 indicating the defects.

また、これらの画像71〜79を得る際には撮像する時間帯を変更している。具体的には、サンプルB、E、Iの画像72、75、79は夜の時間帯に撮像したものであり、そのためにそれら画像72、75、79は全体的に暗くされている。また、サンプルD、F、Gの画像74、76、77は朝の時間帯に撮像したものであり、そのためにそれら画像74、76、77は全体的に明るくされている。また、サンプルA、C、Hの画像71、73、78は昼の時間帯に撮像したものであり、そのためにそれら画像71、73、78は通常の明るさ(朝の撮像時の明るさと夜の撮像時の明るさの中間)とされている。   Further, when obtaining these images 71 to 79, the time zone for imaging is changed. Specifically, the images 72, 75, and 79 of the samples B, E, and I are taken in the night time zone, and therefore, the images 72, 75, and 79 are darkened as a whole. Further, the images 74, 76, and 77 of the samples D, F, and G are taken in the morning time zone, and for this reason, the images 74, 76, and 77 are brightened as a whole. In addition, the images 71, 73, and 78 of the samples A, C, and H are taken during the daytime period. For this reason, the images 71, 73, and 78 have normal brightness (the brightness at the time of imaging in the morning and the night time). (Brightness at the time of imaging).

これらの画像71〜79に対して、検査装置1で良否判定を実施した結果例を次の表11に示す。   Table 11 below shows an example of the results of the pass / fail determination performed on the images 71 to 79 by the inspection apparatus 1.

表11に示すように、画像75、76(良品サンプルE、F)には検査品グレー領域が含まれていないので、それら画像75、76に対してはMD値は算出されない。また、検査品グレー領域を含む良品サンプルA、B、C、Dに対しては、1.2〜1.8のMD値が算出されている。また、不良サンプルG〜Iの画像77〜79に対しては、14.4〜23.5のMD値が算出されている。このように、検査装置1では、画像の写り方(明暗)によって変化する周辺領域の輝度情報を取得して、画像処理で検出したグレー領域の特徴量を得るための閾値を設定しているため、画像の写り方に影響されずに、特徴量を計算することができる。よって、良品と不良のMD値について、充分なMD値の差を得ることができる。   As shown in Table 11, since the images 75 and 76 (non-defective samples E and F) do not include the inspection product gray region, MD values are not calculated for the images 75 and 76. In addition, MD values of 1.2 to 1.8 are calculated for the non-defective samples A, B, C, and D including the inspection product gray region. In addition, MD values of 14.4 to 23.5 are calculated for the images 77 to 79 of the defective samples G to I. As described above, the inspection apparatus 1 sets the threshold value for obtaining the feature value of the gray area detected by the image processing by acquiring the luminance information of the peripheral area that changes depending on how the image is captured (brightness and darkness). The feature amount can be calculated without being affected by how the image is captured. Therefore, a sufficient difference in MD value can be obtained for the non-defective product and the defective MD value.

以上説明したように、本実施形態では、画像全体ではなく、良品か否かの区別が付きにくい検査品グレー領域のMD値に基づいて、検査品の良否判定を行っているので、その判定を行うための処理時間を短縮することができる。また、検査品に検査品グレー領域が含まれていない場合には、MD値を算出しないで良品と判定しているので、迅速にその判定をすることができる。また、グレー領域(良品グレー領域、検査品グレー領域)の周辺領域の輝度情報を基準として、そのグレー領域の特徴量を得ているので、画像の写り方に影響されないマハラノビス基準空間やMD値を算出することができる。よって、画像の写り方に関わらず良否判定を精度良く行うことができる。   As described above, in the present embodiment, the quality of the inspection product is determined based on the MD value of the inspection product gray area, which is difficult to distinguish whether it is a non-defective product, not the entire image. The processing time for performing can be shortened. Further, when the inspection product does not include the inspection product gray area, it is determined as a good product without calculating the MD value, so that the determination can be made quickly. Also, since the feature value of the gray area is obtained based on the luminance information of the peripheral area of the gray area (non-defective gray area, inspection gray area), the Mahalanobis reference space and MD values that are not affected by the way the image is captured are obtained. Can be calculated. Therefore, the quality determination can be performed with high accuracy regardless of the way the image is captured.

なお、上記実施形態において、図2のS1の処理が本発明の「良品画像取得ステップ」に相当する。図2のS2の処理が本発明の「認識ステップ」に相当する。図6のS311〜S313の処理が本発明の「輝度取得ステップ」に相当する。図2のS3の処理が本発明の「特徴量算出ステップ」に相当する。図2のS4の処理が本発明の「生成ステップ」に相当する。図6のS314及びS315の処理が本発明の「代表値設定ステップ」に相当する。図8のS321〜S323の処理が本発明の「輝度分布算出ステップ」に相当する。図8のS325の処理が本発明の「並替ステップ」に相当する。図8のS326〜S328の処理が本発明の「変化特性値算出ステップ」に相当する。メモリ12が本発明の「記憶手段」に相当する。図14のS51の処理を実行する画像処理用PC10が本発明の「検査画像取得手段」に相当する。図14のS52及びS53の処理を実行する画像処理用PC10が本発明の「グレー領域判断手段」に相当する。図14のS54の処理を実行する画像処理用PC10が本発明の「検査品輝度取得手段」及び「検査品特徴量算出手段」に相当する。図14のS55〜S57の処理を実行する画像処理用PC10が本発明の「マハラノビス距離算出手段」に相当する。図14のS55の処理を実行する画像処理用PC10が本発明の「正規化手段」に相当する。図14のS58〜S60の処理を実行する画像処理用PC10が本発明の「良否判断手段」に相当する。図14のS61の処理を実行する画像処理用PC10が本発明の「良品判断手段」に相当する。   In the above embodiment, the process of S1 in FIG. 2 corresponds to the “non-defective image acquisition step” of the present invention. The process of S2 in FIG. 2 corresponds to the “recognition step” of the present invention. The processing of S311 to S313 in FIG. 6 corresponds to the “luminance acquisition step” of the present invention. The process of S3 in FIG. 2 corresponds to the “feature amount calculating step” of the present invention. The process of S4 in FIG. 2 corresponds to the “generation step” of the present invention. The processes of S314 and S315 in FIG. 6 correspond to the “representative value setting step” of the present invention. The processing of S321 to S323 in FIG. 8 corresponds to the “luminance distribution calculating step” of the present invention. The process of S325 in FIG. 8 corresponds to the “rearrangement step” of the present invention. The process of S326 to S328 in FIG. 8 corresponds to the “change characteristic value calculation step” of the present invention. The memory 12 corresponds to the “storage means” of the present invention. The image processing PC 10 that executes the process of S51 of FIG. 14 corresponds to the “inspection image acquisition unit” of the present invention. The image processing PC 10 that executes the processing of S52 and S53 in FIG. 14 corresponds to the “gray area determination means” of the present invention. The image processing PC 10 that executes the process of S54 in FIG. 14 corresponds to the “inspection product luminance acquisition unit” and the “inspection product feature value calculation unit” of the present invention. The image processing PC 10 that executes the processes of S55 to S57 in FIG. 14 corresponds to the “Mahalanobis distance calculating means” of the present invention. The image processing PC 10 that executes the process of S55 of FIG. 14 corresponds to the “normalization means” of the present invention. The image processing PC 10 that executes the processes of S58 to S60 in FIG. 14 corresponds to the “good / bad determination means” of the present invention. The image processing PC 10 that executes the process of S61 in FIG. 14 corresponds to the “non-defective product determination unit” of the present invention.

1 検査装置
10 画像処理用PC
11 CPU
12 メモリ
20 報知器
30 カメラ
61〜65 良品画像
621、631、651 良品グレー領域
623 周辺領域
71〜79 検査画像
711、721、731、741、771、781、791 検査品グレー領域
1 Inspection device 10 Image processing PC
11 CPU
12 Memory 20 Alarm 30 Camera 61-65 Good product image 621, 631, 651 Good product gray region 623 Peripheral region 71-79 Inspection image 711, 721, 731, 741, 771, 781, 791 Inspection product gray region

Claims (13)

良品か否かの区別が付きにくい領域である良品グレー領域を含む良品画像を取得する良品画像取得ステップと、
その良品画像取得ステップで取得した前記良品画像に含まれる前記良品グレー領域を認識する認識ステップと、
前記良品画像の領域のうち前記認識ステップで認識した前記良品グレー領域のエッジに隣接した所定の大きさの領域である周辺領域の輝度情報を取得する輝度取得ステップと、
その輝度取得ステップで取得した前記周辺領域の輝度情報を基準とした前記良品グレー領域の輝度情報の特徴量を算出する特徴量算出ステップと、
前記良品画像のうちの前記良品グレー領域の前記特徴量のみに基づいて、マハラノビス距離を算出するための基準空間を生成する生成ステップと、を含むことを特徴とするマハラノビス基準空間の生成方法。
A non-defective image acquisition step for acquiring a non-defective image including a non-defective gray region, which is an area where it is difficult to distinguish whether or not it is a non-defective product,
A recognition step for recognizing the non-defective gray region included in the non-defective image acquired in the non-defective image acquisition step;
A luminance acquisition step of acquiring luminance information of a peripheral region that is a region of a predetermined size adjacent to an edge of the non- defective gray region recognized in the recognition step in the non-defective image region;
A feature amount calculating step for calculating a feature amount of the luminance information of the non-defective gray region based on the luminance information of the peripheral region acquired in the luminance acquiring step;
A generating step of generating a reference space for calculating a Mahalanobis distance based only on the feature quantity of the non-defective gray region in the non-defective product image .
前記特徴量算出ステップは、前記周辺領域の輝度情報を代表する代表値を設定する代表値設定ステップと、
その代表値設定ステップで設定した前記代表値を基準とした前記良品グレー領域の輝度情報の分布を示した輝度分布データを前記特徴量として算出する輝度分布算出ステップと、を含むことを特徴とする請求項1に記載のマハラノビス基準空間の生成方法。
The feature amount calculating step includes a representative value setting step of setting a representative value representing luminance information of the peripheral area;
A luminance distribution calculating step of calculating, as the feature amount, luminance distribution data indicating a luminance information distribution of the non-defective gray region based on the representative value set in the representative value setting step. The method for generating the Mahalanobis reference space according to claim 1.
前記輝度分布算出ステップは、前記良品グレー領域の各画素の輝度値のうち前記代表値より大きい各輝度値と前記代表値との差分値をそれぞれ算出し、それら差分値の合計値と、前記良品グレー領域の各画素の輝度値のうち前記代表値より小さい各輝度値と前記代表値との差分値をそれぞれ算出し、それら差分値の合計値の少なくとも一方を前記輝度分布データとして算出するステップであることを特徴とする請求項2に記載のマハラノビス基準空間の生成方法。   The luminance distribution calculating step calculates a difference value between each of the luminance values larger than the representative value and the representative value among the luminance values of the pixels of the non-defective gray region, and calculates a total value of the difference values and the good product Calculating a difference value between each luminance value smaller than the representative value among the luminance values of each pixel in the gray area and the representative value, and calculating at least one of the total values of the difference values as the luminance distribution data; The method of generating a Mahalanobis reference space according to claim 2, wherein: 前記輝度分布算出ステップは、前記良品グレー領域の各画素のうち前記代表値より大きい輝度値の画素の数と前記代表値より小さい輝度値の画素の数の少なくとも一方を前記輝度分布データとして算出するステップであることを特徴とする請求項2に記載のマハラノビス基準空間の生成方法。   In the luminance distribution calculating step, at least one of the number of pixels having a luminance value larger than the representative value and the number of pixels having a luminance value smaller than the representative value among the pixels of the non-defective gray region is calculated as the luminance distribution data. The method of generating a Mahalanobis reference space according to claim 2, wherein the method is a step. 前記輝度分布算出ステップは、前記良品グレー領域の各画素の輝度値のうち前記代表値より大きい各輝度値と前記代表値との各差分値の合計値、前記良品グレー領域の各画素の輝度値のうち前記代表値より小さい各輝度値と前記代表値との各差分値の合計値、前記良品グレー領域の各画素のうち前記代表値より大きい輝度値の画素の数、及び前記良品グレー領域の各画素のうち前記代表値より小さい輝度値の画素の数の少なくともいずれか一つを前記輝度分布データとして算出するステップであることを特徴とする請求項2に記載のマハラノビス基準空間の生成方法。   The luminance distribution calculating step includes the sum of the difference values between the luminance values greater than the representative value and the representative values among the luminance values of the pixels in the good gray region, and the luminance values of the pixels in the good gray region. Of the luminance values smaller than the representative value and the difference value between the representative values, the number of pixels having a luminance value larger than the representative value among the pixels of the good gray region, and the good gray region 3. The method of generating a Mahalanobis reference space according to claim 2, wherein at least one of the number of pixels having a luminance value smaller than the representative value among the pixels is calculated as the luminance distribution data. 前記特徴量算出ステップは、
前記良品グレー領域の各画素の輝度値を輝度値の大きさの順に並び替える並替ステップと、
その並替ステップで並び替えた輝度値間の変化特性を示した変化特性値を前記特徴量として算出する変化特性値算出ステップと、をさらに含むことを特徴とする請求項2〜5のいずれか1項に記載のマハラノビス基準空間の生成方法。
The feature amount calculating step includes:
A rearrangement step of rearranging the luminance value of each pixel of the non-defective gray region in the order of the luminance value;
The change characteristic value calculation step of calculating a change characteristic value indicating a change characteristic between luminance values rearranged in the rearrangement step as the feature amount, further comprising: The method for generating the Mahalanobis reference space described in item 1.
前記変化特性値算出ステップは、前記並替ステップで並び替えた輝度値から、大きさが隣り合う二つの輝度値の差分値である隣接変化値を算出し、その隣接変化値の特性を示した隣接変化特性値を前記変化特性値として算出するステップであることを特徴とする請求項6に記載のマハラノビス基準空間の生成方法。   The change characteristic value calculation step calculates an adjacent change value that is a difference value between two luminance values adjacent to each other from the luminance values rearranged in the rearrangement step, and shows the characteristics of the adjacent change value. The method of generating a Mahalanobis reference space according to claim 6, which is a step of calculating an adjacent change characteristic value as the change characteristic value. 前記変化特性値算出ステップは、前記並替ステップで並び替えた輝度値間の変化を近似した近似式を算出し、その近似式の特性を示した近似式特性値を前記変化特性値として算出するステップであることを特徴とする請求項6又は7に記載のマハラノビス基準空間の生成方法。   The change characteristic value calculation step calculates an approximate expression that approximates a change between the luminance values rearranged in the rearrangement step, and calculates an approximate expression characteristic value indicating the characteristic of the approximate expression as the change characteristic value. The method of generating a Mahalanobis reference space according to claim 6 or 7, wherein the method is a step. 前記代表値設定ステップは、互いに値が異なる複数の前記代表値を設定するステップであり、
前記輝度分布算出ステップは、前記複数の代表値のそれぞれごとに、各代表値を基準とした前記輝度分布データを算出するステップであることを特徴とする請求項2〜8のいずれか1項に記載のマハラノビス基準空間の生成方法。
The representative value setting step is a step of setting a plurality of representative values having different values.
9. The luminance distribution calculating step according to claim 2, wherein the luminance distribution calculating step is a step of calculating the luminance distribution data with reference to each representative value for each of the plurality of representative values. A method of generating the described Mahalanobis reference space.
前記代表値設定ステップは、前記周辺領域の輝度値の平均値、最小値、最大値、中央値又は偏差に基づいて前記代表値を設定するステップであることを特徴とする請求項2〜9のいずれか1項に記載のマハラノビス基準空間の生成方法。   10. The representative value setting step is a step of setting the representative value based on an average value, a minimum value, a maximum value, a median value, or a deviation of luminance values in the peripheral area. The method for generating the Mahalanobis reference space according to any one of the above items. 請求項1〜10のいずれか1項に記載のマハラノビス基準空間の生成方法で生成された前記基準空間が記憶された記憶手段と、
検査品の画像である検査画像を取得する検査画像取得手段と、
その検査画像取得手段が取得した前記検査画像に、良品か否かの区別が付きにくい領域である検査品グレー領域が含まれているか否かを判断するグレー領域判断手段と、
そのグレー領域判断手段が前記検査品グレー領域が含まれていると判断した場合に、前記検査画像の領域のうち前記検査品グレー領域のエッジに隣接した所定の大きさの領域である周辺領域の輝度情報を取得する検査品輝度取得手段と、
その検査品輝度取得手段が取得した前記周辺領域の輝度情報を基準とした前記検査品グレー領域の輝度情報の特徴量である検査品特徴量を算出する検査品特徴量算出手段と、
その検査品特徴量算出手段が算出した前記検査品特徴量と前記記憶手段に記憶された前記基準空間とに基づいて、マハラノビス距離を算出するマハラノビス距離算出手段と、
そのマハラノビス距離算出手段が算出した前記マハラノビス距離に基づいて前記検査品の良否判断を行う良否判断手段と、を備えることを特徴とする検査装置。
Storage means for storing the reference space generated by the method for generating the Mahalanobis reference space according to any one of claims 1 to 10,
Inspection image acquisition means for acquiring an inspection image which is an image of an inspection product;
A gray region determination unit that determines whether or not the inspection image acquired by the inspection image acquisition unit includes an inspection product gray region that is a region that is difficult to distinguish whether it is a non-defective product;
When the gray area determining means determines that the inspection product gray area is included , a peripheral area that is a predetermined size area adjacent to an edge of the inspection product gray area in the inspection image area. Inspection product brightness acquisition means for acquiring brightness information;
An inspection product feature amount calculating means for calculating an inspection product feature amount that is a feature amount of the luminance information of the inspection product gray region based on the luminance information of the peripheral region acquired by the inspection product luminance acquisition unit;
Mahalanobis distance calculating means for calculating a Mahalanobis distance based on the inspection product feature value calculated by the inspection product feature value calculating means and the reference space stored in the storage means;
An inspection device, comprising: quality determination means for determining quality of the inspection product based on the Mahalanobis distance calculated by the Mahalanobis distance calculation means.
前記マハラノビス距離算出手段は、前記検査品特徴量を正規化する正規化手段を含み、その正規化手段が正規化した前記検査品特徴量と前記基準空間とに基づいて、前記マハラノビス距離を算出するものであることを特徴とする請求項11に記載の検査装置。   The Mahalanobis distance calculating means includes a normalizing means for normalizing the inspection product feature quantity, and calculates the Mahalanobis distance based on the inspection product feature quantity normalized by the normalization means and the reference space. The inspection apparatus according to claim 11, wherein the inspection apparatus is a thing. 前記グレー領域判断手段が前記検査品グレー領域が含まれていないと判断した場合に、前記検査品を良品と判断する良品判断手段を備えることを特徴とする請求項11又は12に記載の検査装置。   13. The inspection apparatus according to claim 11, further comprising: a non-defective product determining unit that determines that the inspection product is a non-defective product when the gray region determining unit determines that the inspection product gray region is not included. .
JP2010267768A 2010-11-30 2010-11-30 Mahalanobis reference space generation method and inspection device Active JP5595247B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2010267768A JP5595247B2 (en) 2010-11-30 2010-11-30 Mahalanobis reference space generation method and inspection device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2010267768A JP5595247B2 (en) 2010-11-30 2010-11-30 Mahalanobis reference space generation method and inspection device

Publications (2)

Publication Number Publication Date
JP2012117907A JP2012117907A (en) 2012-06-21
JP5595247B2 true JP5595247B2 (en) 2014-09-24

Family

ID=46500911

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2010267768A Active JP5595247B2 (en) 2010-11-30 2010-11-30 Mahalanobis reference space generation method and inspection device

Country Status (1)

Country Link
JP (1) JP5595247B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103885216A (en) * 2014-02-10 2014-06-25 北京京东方显示技术有限公司 Substrate detecting device and method

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4429640B2 (en) * 2003-06-11 2010-03-10 古河電気工業株式会社 Appearance inspection method for weld marks
JP5181912B2 (en) * 2008-08-06 2013-04-10 新日鐵住金株式会社 Surface defect inspection method, surface defect inspection apparatus, steel sheet manufacturing method, and steel sheet manufacturing apparatus

Also Published As

Publication number Publication date
JP2012117907A (en) 2012-06-21

Similar Documents

Publication Publication Date Title
JP6403261B2 (en) Classifier generation device, visual inspection device, classifier generation method, and program
JP6900581B1 (en) Focus-weighted machine learning classifier error prediction for microscope slide images
EP3610986B1 (en) Apparatus and method for shot peening evaluation
JP5956814B2 (en) Appearance inspection apparatus, appearance inspection method, and computer program
JP2007114843A (en) Quality deciding device
KR20120088750A (en) Method for analysing the quality of a glass panel
CN113469971B (en) Image matching method, detection device and storage medium
JP2003085558A (en) Method of pattern inspection and inspection device
JP2020187656A (en) Image inspection device
JP6643856B2 (en) Classification method, inspection method, inspection device, and program
EP3270102A1 (en) Shape inspection method, shape inspection device, and program
JP5305002B2 (en) Appearance inspection device
JP2018048979A (en) Surface property inspection apparatus, surface property insection method, and program
JP5595247B2 (en) Mahalanobis reference space generation method and inspection device
JP2006292615A (en) Visual examination apparatus, visual inspection method, program for making computer function as visual inspection apparatus, and recording medium
JP5479309B2 (en) Mahalanobis reference space generation method, inspection method and inspection apparatus
CN110441315B (en) Electronic component testing apparatus and method
CN115018829A (en) Glass flaw positioning method and device
JP2008190880A (en) Determination device, determination system, determination method and computer program
JP4956077B2 (en) Defect inspection apparatus and defect inspection method
JP6182024B2 (en) Unevenness measuring method and unevenness measuring apparatus
JP6114559B2 (en) Automatic unevenness detector for flat panel display
JP2017223512A (en) Surface state diagnosis device
JP2006260410A (en) Evaluation apparatus and method for image processing algorithm, producing system and method, program for making computer function as evaluation system, and program for making computer function as producing system
EP4010873B1 (en) Use of an hdr image in a visual inspection process

Legal Events

Date Code Title Description
RD02 Notification of acceptance of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7422

Effective date: 20121016

A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20131003

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20140115

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20140115

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20140310

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20140804

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20140805

R150 Certificate of patent or registration of utility model

Ref document number: 5595247

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250