【0001】
【発明の属する技術分野】
本発明は、フィルム、紙、鉄鋼等の被検査体の表面欠陥を光学的に検出する技術に関するものである。
【0002】
【従来の技術】
工業製品の表面に生じる欠陥を光学的方法で検出する方法として、例えば、特開平8−82604号公報にあるように、撮像によって得られた画像信号に対し、例えば欠陥幅、欠陥部面積、縦横比、最大強度等の各種特徴量によるツリー型の論理により欠陥の分類を行う方法が知られている。
【0003】
また特開平8−189904号公報には、画像データまたは微分画像データに、あらかじめ表面欠陥に対応するようにあらかじめ設計しておいたテンプレートを作用させ特徴量を抽出する方法が提案されている。さらには、同公報には、画像データまたは微分画像データに対して濃度共起行列を生成し、そこから特徴量を求める方法の提案もなされている。
【0004】
【発明が解決しようとする課題】
しかしながら、前述の各特許方法に開示されている技術をはじめとして、従来の技術は、いずれも被検査対象物の表面欠陥を精度良く検出するには不十分であった。
【0005】
たとえば、特開平8−82604号公報に記載される技術は、欠陥種類または有害度を分類するために重要な因子である欠陥画像の形態とそのテクスチャーの方向性について、有効な特徴量を得る手段がなく分類は不完全であった。画像のテクスチャーの方向性を知る方法については例えば画像信号に2次元のフーリエ変換を施しスペクトル解析を行う方法が知られていたが、画像信号が全域にわたって同じテクスチャーの方向性を持っておらず、評価対象とすべき欠陥画像が局在している場合は有効な結果を得ることができなかった。
【0006】
また、特開平8−189904号公報に記載される技術では、判断すべき欠陥種類および有害度は多岐にわたっているため、すくなくとも200種類以上のテンプレートを設計する必要があり、しかもそれぞれについて最適設計を行うにあたって明確な指針がない。さらに、画像データまたは微分画像データに対して濃度共起行列を生成し、そこから特徴量を求める方法では、画像信号が全域にわたって同じテクスチャーの方向性を持っておらず、評価対象とすべき欠陥画像が局在している場合は有効な結果を得ることができなかった。また特定の方向でのテクスチャーの特徴量を抽出するだけであり、もっと複雑な形態を構造要素とするような幾何学的な特徴量抽出することができないという問題点があった。
【0007】
また欠陥の自動検出においては輝度むらのある画像信号の正規化のため、2値化前にシェーディング処理が使われるが、大きな正極性欠陥の信号の立ち下がりの部分が反対の負極性の信号となったり、また大きな負極性欠陥の信号の立ち上がりの部分が、反対の正極性の信号となり、その結果、欠陥でないものを欠陥として頻繁に誤検出することがある。
【0008】
これは前方の複数ラインで移動平均をとり対象ラインに対して引き算または割り算をしているため、処理後に正極性欠陥信号の立ち下がり部分が中心輝度より低いレベルとなり負極性の信号、負極性欠陥信号のたちあがり部分が中心輝度より高いレベルとなり正極性の信号となってしまうためである。欠陥信号の極性を見極めるのが有害欠陥の自動検出において重要であるのに対して、従来から知られているシェーディング手法など微分的な処理は上のような本質的な欠陥をもっている。
【0009】
さらに、欠陥の分類について考えると、撮像によって得られた画像信号に対し従来は欠陥幅、欠陥部面積、縦横比、最大強度等の各種特徴量によるツリー型の論理により欠陥の分類をおこなってきた。しかしながら例えば対象とする欠陥画像の形態について長手方向に広がっているか、幅方向に広がっているか、斜め方向に広がっているか、あるいはもっと複雑な輝度分布をしているか、その形態について欠陥の有害性は異なる。
【0010】
例えば長手方向において急峻な変化を有し、幅方向に広がった欠陥信号が特に重要で、このような信号のみを抽出しなければならないといった要求が場合には、有効な手段がなかった。
【0011】
この欠陥の有害性を分類するために重要な因子である欠陥の形態について特定のもののみを抽出する手段がなく、しばしば過検出がおこっていた。例えばロール疵に起因する周期性欠陥の多くは長手方向に狭く鋭い信号として現れるため、このような形態を選択的に抽出し出力する必要があるが、これについても有効な手段がなかった。
【0012】
本発明は、こうした状況に鑑みてなされたもので、撮像によって得られた画像信号を新規な方法で処理することにより、欠陥の検出や種類の判別を精度よく行うことができる表面欠陥検出方法を提供することを課題とする。
【0013】
【課題を解決するための手段】
前記課題を解決するための第1の手段は、被検査対象物の表面を撮像してグレー画像を得る工程と、得られた画像信号の少なくとも一部に対しグレースケールのモルフォロジーにおける、特定の陰影を持つ単一または複数の構造要素を使用したトップハット変換の演算を行い、その結果得られた画像から欠陥の抽出を行う工程を有することを特徴とする表面欠陥検出方法(請求項1)である。
【0014】
後に発明の実施の形態で詳しく説明するように、モルフォロジーにおける特定の構造要素を使用してトップハット変換を行うと、画像における緩やかな変化を取り除き、急峻な変化のみを抽出することができる。よって、表面欠陥をノイズと区別して抽出しやすくなる。また、構造要素の特性を変えることにより、抽出される欠陥の種類を変えることができる。さらに、構造要素を複数使用してトップハット変換を行い、その結果得られた変換画像を比較することにより、欠陥の有無をより正確に検出することができる。
【0015】
前記課題を解決するための第2の手段は、前記第1の手段であって、「その結果得られた画像から欠陥の抽出を行う工程」が、その結果得られた画像を2値化し、2値化画像を基に欠陥の抽出を行う工程であることを特徴とするもの(請求項2)である。
【0016】
本手段においては、トップハット変換の結果得られた画像を、所定の閾値で2値化し、得られた2値化画像を基に欠陥の抽出を行う。よって、簡単な方法により欠陥の検出が可能となる。
【0017】
前記課題を解決するための第3の手段は、前記第2の手段であって、複数の構造要素を使用してトップハット変換の演算を行うものであり、「2値化画像を基に欠陥の抽出を行う工程」が、得られた複数の構造要素に対応する2値化画像の演算を行うことにより、欠陥の抽出を行う工程であることを特徴とするもの(請求項3)である。
【0018】
本手段においては、複数の構造要素を使用してトップハット変換の演算を行い、その結果を2値化して、得られた複数の構造要素に対応する2値化画像の論理演算を行うことにより、欠陥の抽出を行っている。よって、欠陥の有無をより正確に検出することができる。
【0019】
前記課題を解決するための第4の手段は、前記第1の手段であって、複数の構造要素を使用してトップハット変換の演算を行うものであり、その結果得られた画像から欠陥の抽出を行う工程が、各トップハット変換により得られた画素の値の最大値又は最小値からなる画像に基づいて、欠陥の抽出を行う工程であることを特徴とするもの(請求項4)である。
【0020】
本手段においては、複数の構造要素を使用してトップハット変換の演算を行い、各トップハット変換により得られた画素の値の最大値又は最小値からなる画像に基づいて欠陥の抽出を行う。
【0021】
このようにすると、欠陥を最も検出しやすい構造要素によるトップハット変換に基づいて欠陥の抽出が行われることになり、欠陥の有無を正確に検出することができる。例えば、一つの欠陥がうねりを有するような場合に、方向性を有する構造要素一つのみで検出しようとすると、欠陥の一部を見逃してしまう場合があるが、本手段においては、このような複雑な形状の欠陥も一つの欠陥として正確に認識することが可能となる。
【0022】
前記課題を解決するための第5の手段は、前記第1の手段であって、複数の構造要素を使用してトップハット変換の演算を行うものであり、その結果得られた画像から欠陥の抽出を行う工程が、得られた各トップハット変換結果の線形結合によって得られる画像に基づいて、欠陥の抽出を行う工程であることを特徴とするもの(請求項5)である。
【0023】
本手段においては、得られた各トップハット変換結果の線形結合によって得られる画像に基づいて欠陥の抽出を行っているので、線形結合の係数を変化させることにより、目的とする形状の欠陥を強調して検出したり、所定の形状を有する欠陥の全てを精度良く検出したりすることが可能となる。
【0024】
前記課題を解決するための第6の手段は、被検査対象物の表面を撮像してグレー画像を得る工程と、得られた画像信号の少なくとも一部に対しグレースケールのモルフォロジーにおける、特定の陰影を持つ複数の構造要素を使用したトップハット変換の演算を行い、その結果得られた複数の構造要素に対応するトップハット変換後の画像画像から、欠陥の分類、欠陥の程度判別の少なくとも一方を行う工程を有することを特徴とする表面欠陥検出方法(請求項6)である。
【0025】
本手段においては、構造要素の特性を変えることにより、抽出される欠陥の種類を変えることができる。さらに、構造要素を複数使用してトップハット変換を行い、その結果得られた変換画像を比較することにより、欠陥の種類やその程度、種類を正確に検出することができる。
【0026】
前記課題を解決するための第7の手段は、前記第6の手段であって、トップハット変換後の画像画像を2値化し、2値化画像から、欠陥の分類、欠陥の程度判別の少なくとも一方を行う工程を有することを特徴とするもの(請求項7)である。
【0027】
本手段においては、トップハット変換の結果得られた画像を、所定の閾値で2値化し、得られた2値化画像を基に欠陥の抽出を行う。よって、簡単な方法により欠陥の分類、欠陥の程度判別の少なくとも一方が可能となる。
【0028】
前記課題を解決するための第8の手段は、被検査対象物の表面を撮像してグレー画像を得る工程と、得られた画像信号の少なくとも一部に対しグレースケールのモルフォロジーにおける、方向性のある特定の陰影を持つ複数の構造要素を使用したトップハット変換の演算を行い、その結果得られた複数の構造要素に対応するトップハット変換後の画像画像を2値化して残存画素を計算し、これらの比率から情報のエントロピーを計算し、エントロピーの値から欠陥の方向性の偏りを定量的に評価する工程を有することを特徴とする表面欠陥検出方法(請求項8)である。
【0029】
本手段においては、方向性のある特定の陰影を持つ複数の構造要素を使用したトップハット変換を行い、得られた画像を2値化して残存画素を計算する。そして、その比率からエントロピーを計算する。そしてエントロピーの値が大きい場合は欠陥に方向性が少ない判断し、エントロピーの値が小さい場合は、方向性のある欠陥であると判断できる。
【0030】
前記課題を解決するための第9の手段は、前記第1の手段から第8の手段のいずれかであって、被検査対象物の表面を撮像してグレー画像を得る工程の後に、別の方法により欠陥の候補となる部分とその欠陥の特性を求め、欠陥の候補となる部分毎に、その欠陥の特性に対応した構造要素を使用して、トップハット変換の演算を行うことを特徴とするもの(請求項9)である。
【0031】
本手段においては、たとえば従来の任意の方法で、大まかな欠陥の特性を求めておき、それに応じた構造要素を使用してトップハット変換の演算を行うようにしているので、個々の欠陥に適当な構造要素を選択して使用することができ、全構造要素を使用するのに比して演算時間を短縮することができる。また、欠陥の候補となる部分が予め定められているので、トップハット変換を行う領域が少なくて済む。
【0032】
前記課題を解決するための第10の手段は、前記第9の手段であって、別の方法が、撮像によって得られた画像信号に対しまずシェーディング処理と2値化を施して欠陥候補を抽出し、2値化画像から欠陥の候補となる部分とその欠陥の特性を求めるものであることを特徴とするもの(請求項10)である。
【0033】
本手段においては、撮像によって得られた画像信号に対しまずシェーディング処理と2値化を施して欠陥候補を抽出し、2値化画像から欠陥の候補となる部分とその欠陥の特性を求め、その結果に応じて構造要素を使い分けている。よって、簡単な前処理によって、構造要素を使い分けることができる。
【0034】
前記課題を解決するための第11の手段は、前記第10の手段であって、2値化画像から欠陥の候補となる部分とその欠陥の特性を求める方法が、2値化画像中の画素の、2値化前の中心輝度、ランレングスの少なくとも一つに基づいて求める方法であることを特徴とするもの(請求項11)である。
【0035】
本手段においては、2値化画像が欠陥のおおよその範囲を示す。そして、その範囲における2値化前の画素の中心輝度は、欠陥の深さを代表するものであり、ランレングスは、欠陥の長さを代表するものである。よって、これらの少なくとも一方を基準にして構造要素を選ぶことにより、欠陥深さ、欠陥長さの少なくとも一方を基準にして、適当な構造要素を選ぶことができる。
【0036】
前記課題を解決するための第12の手段は、被検査対象物の表面を撮像してグレー画像を得る工程と、得られた画像信号の少なくとも一部に対しグレースケールのモルフォロジーにおける、特定の陰影を持つ単一または複数の構造要素対を使用したclosing演算又はopening演算を行ってその差分を求め、その結果得られた画像から欠陥の抽出を行う工程を有することを特徴とする表面欠陥検出方法(請求項12)である。
【0037】
前記課題を解決するための第13の手段は、前記第12の手段であって、その結果得られた画像から欠陥の抽出を行う工程が、その結果得られた画像を2値化し、2値化画像を基に欠陥の抽出を行う工程であることを特徴とするもの(請求項13)である。
【0038】
前記課題を解決するための第14の手段は、前記第13の手段であって、複数の構造要素対を使用してclosing演算又はopening演算の差分を求めるものであり、2値化画像を基に欠陥の抽出を行う工程が、得られた複数の構造要素対に対応する2値化画像の演算を行うことにより、欠陥の抽出を行う工程であることを特徴とするもの(請求項14)である。
【0039】
前記課題を解決するための第15の手段は、前記第12の手段であって、複数の構造要素対を使用してclosing演算又はopening演算の差分を求めるものであり、その結果得られた画像から欠陥の抽出を行う工程が、各closing演算又はopening演算の差分により得られた画素の値の最大値又は最小値からなる画像に基づいて、欠陥の抽出を行う工程であることを特徴とするもの(請求項15)である。
【0040】
前記課題を解決するための第16の手段は、前記第12の手段であって、複数の構造要素対を使用してclosing演算又はopening演算の演算の差分を求めるものであり、その結果得られた画像から欠陥の抽出を行う工程が、得られた各closing演算又はopening演算の差分の線形結合によって得られる画像に基づいて、欠陥の抽出を行う工程であることを特徴とするもの(請求項16)である。
【0041】
前記課題を解決するための第17の手段は、被検査対象物の表面を撮像してグレー画像を得る工程と、得られた画像信号の少なくとも一部に対しグレースケールのモルフォロジーにおける、特定の陰影を持つ複数の構造要素対を使用したclosing演算又はopening演算の差分の演算を行い、その結果得られた複数の構造要素対に対応するclosing演算又はopening演算の差分の画像画像から、欠陥の分類、欠陥の程度判別の少なくとも一方を行う工程を有することを特徴とする表面欠陥検出方法(請求項17)である。
【0042】
前記課題を解決するための第18の手段は、前記第17の手段であって、closing演算又はopening演算の差分の演算後の画像画像を2値化し、2値化画像から、欠陥の分類、欠陥の程度判別の少なくとも一方を行う工程を有することを特徴とする表面欠陥検出方法(請求項18)である。
【0043】
前記課題を解決するための第19の手段は、被検査対象物の表面を撮像してグレー画像を得る工程と、得られた画像信号の少なくとも一部に対しグレースケールのモルフォロジーにおける、方向性のある特定の陰影を持つ複数の構造要素対を使用したclosing演算又はopening演算の差分の演算を行い、その結果得られた複数の構造要素対に対応するclosing演算又はopening演算の差分の画像を2値化して残存画素を計算し、これらの比率から情報のエントロピーを計算し、欠陥の方向性の偏りを定量的に評価する工程を有することを特徴とする表面欠陥検出方法(請求項19)である。
【0044】
前記課題を解決するための第20の手段は、前記第12の手段から第19の手段のいずれかであって、被検査対象物の表面を撮像してグレー画像を得る工程の後に、別の方法により欠陥の候補となる部分とその欠陥の特性を求め、欠陥の候補となる部分毎に、その欠陥の特性に対応した構造要素対を使用して、closing演算又はopening演算を行うことを特徴とするもの(請求項20)である。
【0045】
前記課題を解決するための第21の手段は、前記第20の手段であって、別の方法が、撮像によって得られた画像信号に対しまずシェーディング処理と2値化を施して欠陥候補を抽出し、2値化画像から欠陥の候補となる部分とその欠陥の特性を求めるものであることを特徴とするもの(請求項21)である。
【0046】
前記課題を解決するための第22の手段は、前記第21の手段であって、2値化画像から欠陥の候補となる部分とその欠陥の特性を求める方法が、2値化画像中の画素の、2値化前の中心輝度、ランレングスの少なくとも一つに基づいて求める方法であることを特徴とするもの(請求項22)である。
【0047】
これら、第12の手段から第22の手段は、それぞれ前記第1の手段から第12の手段に対応するものである。前記第1の手段から第12の手段においては、構造要素を使用したトップハット変換を使用していたのに対し、第13の手段から第24の手段は、構造要素の対を使用し、各々の構造要素を使用したclosing演算又はopening演算の結果の差分を演算し、その差分演算の結果に基づいて以後の演算を行い、其の結果に基づいて欠陥の検出を行っている点が異なっている。
【0048】
構造要素の対によるclosing演算又はopening演算の差分をとることにより、両者の構造要素の中間の大きさを有する欠陥を強調して抽出することができる。例えば、大きな構造要素と小さな構造要素を対とし、大きな構造要素が輝度ムラのような緩やかな変化に追随できるようにし、小さな構造要素が微小ノイズに追随できないようにしておけば、緩やかな変化には両方の構造要素が追随でき、微小ノイズには両方の構造要素が追随できないので、差分をとれば、これらのものは検出されなくなる。そして、大きな構造要素が追随できず、小さな構造要素が追随できるような大きさの欠陥のみを抽出することができる。
【0049】
【発明の実施の形態】
以下、本発明の実施の形態の例を、図を用いて説明する。最初に、例えば光源とカメラ等を用いた撮像系で被検査対象物の表面の画像を画像メモリに記憶する。本実施の形態では得られた画像信号に対しシェーディングを施し、当該画像にグレースケールのモルフォロジーにおける、特定の陰影を持つ構造要素を使用したトップハット変換を行い、その結果得られた画像から、欠陥の抽出を行う。
【0050】
先ず画像メモリに採取された画像データに対して、光学系に起因する輝度ムラを除去するためにシェーディング補正を行う。このときシェーディング補正による規格化は従来からよく知られているとおり、注目ラインの前後の決められた範囲で移動平均をとり注目ラインの信号から引き算または割り算を行うことによって行われる。このシェーディング補正後の画像は例えば256階調のグレースケールとされているので、所定値の閾値を用いて2値化処理を行い、2値化画像を得ることができる。
【0051】
この2値化画像から欠陥候補を求める。すなわち、例えば2値化画像で画素の値が「1」となっている領域を欠陥候補とする。この欠陥候補にはシェーディング補正の副作用である影の部分など欠陥信号以外も含まれている。
【0052】
次にモルフォロジー処理の1例と知られるトップハット変換により、欠陥候補から真の欠陥信号を見つける。すなわち、欠陥候補とその近傍の画素の画像を切り出して、注目する欠陥信号の形態に応じた特定の構造要素をトップハット変換に使用して処理を行う。この処理に使用する画像信号は、シェーディング補正前のグレースケール画像である。
【0053】
トップハット変換に使用する構造要素は、特定の1種類でもよいが、まず、2値化画像を、その長さや縦横比、長さ方向等を基にいくつかのパターンにより分類し、分類毎に別の構造要素を用いるようにしてもよい。構造要素の例としては、例えば簡単のため ̄/|\の方向性と特定のスケールを持つ複数の構造要素を使用してもよい。各線の方向は、その方向に長い形状を有する構造要素を表す。なお各構造要素はこれに限定されるものではなく更に複雑な形態を採用してもよい。
【0054】
各構造要素にてトップハット変換後得られた複数の処理後画像S ̄(x、y)、S/(x、y)、S|(x、y)、S\(x、y)の最大値
Dmax(x、y)=max{S ̄(x、y),S/(x、y),S|(x、y),S\(x、y)}
を求めれば各方向に直角な方向に長い線状の欠陥を中心として抽出することができる。
【0055】
また処理後画像の各画素での係数A ̄、A/、A\、A|で重みづけられた線形結合
Dlinear(x、y)
=A ̄・S ̄(x、y)+ A/・S/(x、y)+ A|・S|(x、y)+ A\・S\(x、y)
をとってもよい。このとき例えばA ̄<A/=A\<A|ととっておけば横方向の線状の欠陥について特に敏感になり縦方向の線状の欠陥に対して重み付ができる。また得られた複数の画像をそれぞれ所定の閾値で2値化して論理和や論理積などの演算を実行し、真の有害欠陥の抽出を行うことも可能である。
【0056】
グレースケールのモルフォロジーについては例えば「モルフォロジー」(コロナ社)に詳しい。モルフォロジーは例えば乳癌のX線による検診など医療画像の解析に応用されつつある新しい画像処理技術であり、あらかじめ設定した構造要素を使用した集合論的操作によって、元画像から特定の幾何学的構造をもった要素のみを選択的に抽出するものである。
【0057】
濃淡画像へのモルフォロジー処理は構造要素と呼ばれる画像を移動させる要素とMinkowski和とMinkowski差と呼ばれる演算を基礎としており、代表的な処理にdilation演算とerosion 演算また、それらの組み合わせのopening演算とclosing演算がある。
【0058】
処理する2次元画像の濃淡値を2次元空間の定義域Fで関数f(X)、構造要素の濃淡値を2次元空間の定義域Gで構造関数g(X)と表現すると(Xは2次元変数、以下に現われるUも2次元変数である)、離散データの場合にまずMinkowski和は、
【0059】
【数1】
【0060】
またMinkowski差は
【0061】
【数2】
【0062】
と定義される。なお、Minkowski差を定義する記号には、通常○の中に−を入れた記号が使用されるが、フォントの制約上こうした記号が使用できないので、Θで代用することにする。更にdilation(ずらし重ね)演算はMinkowski和のg(X)を対称なgs(X)=g(−X)で置き換えて、
【0063】
【数3】
【0064】
またerosion(掻き取り)演算はMinkowski和のg(X)をgs(X)で置き換えて、
【0065】
【数4】
【0066】
で定義される。関数f(X)に対してg(U)を平行移動し、両者の垂直方向の対応点同士の和の最大値をとればdilation演算であり、差の最小値をとればerosion演算になる。
ここでopening演算はMinkowski和とerosion演算を組み合わせて
【0067】
【数5】
【0068】
closing演算はMinkowski差とdilation演算を組み合わせて
【0069】
【数6】
【0070】
となる。
【0071】
図1に、1次元関数f(x)に対して、半円状の構造関数g1(x)にてopening演算を行った結果と、半円状の構造関数g2(x)にてclosing演算を行った結果を示す。この場合、opening演算は下からの平滑化処理、closing演算は上からの平滑処理に対応する。
【0072】
opening演算による下からの平滑化処理を行った画素の値を、元画素の値からから引き算をすれば下からのトップハット変換、closing演算による上からの平滑処理を行った画素の値を、元画素の値からから引き算をすれば上からのトップハット変換となる。画像からの欠陥信号抽出の観点で言えば下からのトップハット変換は正極性欠陥信号の抽出、上からのトップハット変換は負極性欠陥信号の抽出を意味している。
【0073】
上からのトップハット変換について図2で1次元信号の場合を例にとって説明する。関数の値がゆるやかに変化しているところでは、球はそれを正確になぞっていくことができるが、負のパルスがあると、その部分には球が入れないために、トレース可能な範囲からはずれることになる。よって、球の軌跡としては、(b)に示すように、滑らかな曲線が得られることになる。この球の軌跡を元信号から引き算すれば鋭い負極性信号のみ抽出することができる(c)。
【0074】
図2から明らかなように、どのような信号を抽出するかは構造要素の形態によって決定される。また2次元の場合についても図3のような構造要素を用いることにより、鋭い変化を有する欠陥信号のみを抽出できることは、容易に想像できる。
【0075】
図3においては、(a)に示すように、構造要素として下に凸な楕円球の形状をしたものでトップハット変換を行っている。(b)が変換前の画像(グレー画像であるが、出願書類に制約のため2値化画像となっている)であり、緩やかな階調の変化の中に、鋭い階調の変化を有する2つの欠陥が存在している。実際の構造要素の大きさは、(b)の下側に示される大きさである。(c)がトップハット変換後のグレー画像であり、欠陥のみが抽出されていることが分かる。
【0076】
更に真の有害欠陥の抽出をするのみならず、欠陥の種類および有害度について分類を行うとき、複数の構造要素にてトップハット変換を行うことが考えられる。以下の例では、簡単のため ̄/|\の方向性と特定のスケールを持つ複数の構造要素を使用する場合について説明するが、これに限定されるものではなく更に複雑な形態を構造要素として採用してもかまわない。
【0077】
このように、構造要素を用いてトップハット変換を行い、トップハット変換後の画像に基づいて欠陥の検出、程度判別、種類判別を行うのが本発明の特徴部であり、トップハット変換後の画像に基づいて欠陥の検出、程度判別、種類判別の方法は特に規定せず、従来用いられているものを適宜使用してもよいし、極端な場合には人間がトップハット変換後の画像を見てこれらのことを行ってもよい。
【0078】
以下、欠陥の種別判定の例を説明する。最初に、欠陥が方向性を有するか、方向性のない欠陥かを判別する方法について説明する。
【0079】
まず各構造要素にてトップハット変換後S ̄(x、y)、S/(x、y)、S|(x、y)、S\(x、y)を得て、適当な閾値により複数の2値化を行い、各残存画素数を算出する。この例では ̄/|\の方向性と特定のスケールを持つ4つの構造要素を使用して行い図7に示したとおり4つの画像の各残存画素数を得る。このとき複数の処理後画像S ̄(x、y)、S/(x、y)、S|(x、y)、S\(x、y)から得られる特徴量は2値化後の各残存画素数に限られるものではなく例えば適当な閾値を越える最大輝度などを用いてもかまわない。
【0080】
計算された特徴量を4次元ベクトルU=(u1,u2,u3,u4)で表し、特徴量パターンと呼ぶ。今回の例では前述の ̄での残存画素数u1、/での残存画素数u2|での残存画素数u3、\での残存画素数u4を特徴量とする。
【0081】
更にそれぞれの残存画素数の比率から情報のエントロピーを計算することにより欠陥のテクスチャーの偏りを定量的に評価して新たな特徴量として扱ってもよい。エントロピーは事象の予測しやすさを表現する量であり事象lの生成確率をPl(ただし
【0082】
【数7】
【0083】
総和は起こる事象全てについてとる)とすると
【0084】
【数8】
【0085】
(総和は起こる全ての事象についてとる)
という式で表される。全ての事象が同じ確率で起こる最も予測しにくいとき情報のエントロピーは最大となり、ある事象だけが起こり(すなわちその生成確率1)他の事象が全く起こらない最も予測しやすいとき(すなわちその生成確率0)情報のエントロピーは最低値(0)になる。
【0086】
ここではテクスチャーの方向性がランダムな場合は情報のエントロピーが大きく、テクスチャーの方向性が偏っている場合は情報のエントロピーが小さくなる。それぞれの残存画素数u1、u2、u3、u4が与えられたとき、
【0087】
【数9】
【0088】
のように
【0089】
【数10】
【0090】
(総和は全てのカテゴリについてとる。すなわち、上記の場合、m=1〜4))となるよう規格化してから上式で情報のエントロピーu5=Hを計算して新たな特徴量としてもよい。このようにして、エントロピーを計算することにより、特定の方向性を持った欠陥か、方向性の無い欠陥かを判別することができる。
【0091】
次に得られた各残存画素数から欠陥の種類および有害度について分類するための方法として、例えばベイズの定理に基づいた最尤決定を用いた方法の例を説明する。
【0092】
まず、前述のように、欠陥について特徴量u1,u2,u3,u4からなるベクトルである特徴量パターンUを求める。今回は4次元の特徴量パターンからC種類の欠陥種別又は欠陥程度を分類する
分類すべき欠陥種類または欠陥程度等をそれぞれカテゴリと呼ぶこととする。特徴量パターンU=(u1,u2,u3,u4)が観測されたとき、その欠陥のカテゴリがjである確率をP(j|U)、カテゴリj(カテゴリ数C)が特徴量パターンUを生起する確率をP(U|j)、カテゴリjの生起確率をP(j)、特徴量パターンUの生起確率をP(U)とすれば、ベイズの定理により
P(j|U)={P(U|j)P(j)}/P(U)
【0093】
ここでP(U|j)、P(j)はあらかじめ多数のサンプルを集めて求めておくことができる。またP(U)は、通常はカテゴリによらないとする。そして、この式でjを変えてP(j|U)が最大となるカテゴリiを、欠陥のカテゴリ(欠陥種類または欠陥程度等)とすればよい。
【0094】
実際には、U=(u1,u2,u3,u4)は無限に存在するので、u1,u2,u3,u4のそれぞれについて、0から所定の最大値までの間を所定数Kに区分し、その区分毎にUを決定する。このようにすれば、UはK4個だけについて考慮すればよい。
【0095】
あらかじめ、特徴量パターンUとそのカテゴリ(欠陥種類または欠陥程度等)との対応の分かっている多量の学習用サンプルから教師付学習を行っておく。カテゴリjの生成確率P(j)を求め、また、カテゴリjに分類された特徴量パターンV(V⊆Z、Zは考えられるパターン全体の集合)のそれぞれの要素vk(k=1〜4)のkごとの平均値mk、と分散σkk 2、さらにvkとvlの共分散σkl 2=σlk 2(k≠l)を計算しておく(k=1,2,3,4、l=1,2,3,4)。平均ベクトルをMj=(m1,m2,m3,m4)T,4×4の共分散行列を
【0096】
【数11】
【0097】
と表す。ここで、
m1:学習用サンプルでの ̄を構造要素としたときの残存画素数の平均
m2:学習用サンプルでの/を構造要素としたときの残存画素数の平均
m3:学習用サンプルでの|を構造要素としたときの残存画素数の平均
m4:学習用サンプルでの\を構造要素としたときの残存画素数の平均
σ11 2:学習用サンプルでの ̄を構造要素としたときの残存画素数の分散
σ22 2:学習用サンプルでの/を構造要素としたときの残存画素数の分散
σ33 2:学習用サンプルでの|を構造要素としたときの残存画素数の分散
σ44 2:学習用サンプルでの\を構造要素としたときの残存画素数の分散
σ12 2=σ21 2:学習用サンプルでの ̄を構造要素としたときの残存画素数と/を構造要素としたときの残存画素数の共分散
σ23 2=σ32 2:学習用サンプルでの/を構造要素としたときの残存画素数と|を構造要素としたときの残存画素数の共分散
σ34 2=σ34 2:学習用サンプルでの|を構造要素としたときの残存画素数と\を構造要素としたときの残存画素数の共分散
σ13 2=σ31 2:学習用サンプルでの ̄を構造要素としたときの残存画素数と|を構造要素としたときの残存画素数の共分散
σ24 2=σ42 2:学習用サンプルでの/を構造要素としたときの残存画素数と\を構造要素としたときの残存画素数の共分散
σ14 2=σ41 2:学習用サンプルでの ̄を構造要素としたときの残存画素数と\を構造要素としたときの残存画素数の共分散
である。
これらの平均ベクトルと分散行列は、全てのカテゴリjについて計算しておく。
【0098】
カテゴリjを生起する確率が特徴量パターンUのn次元(今回の場合はn=4)正規分布に従うと仮定すると、ベイズの定理からの計算により、尤度関数は|Σj|をΣjの行列式として
【0099】
【数12】
【0100】
となる。
【0101】
ある検査で、特徴量パターンW(W⊆Z)が検出されたとき、jを変えて、この尤度関数g(j|W)が最大となるカテゴリiを探せば、このiでP(j|W)(特徴量パターンWが観測されたときそれがカテゴリjである確率)も最大となり、カテゴリiに欠陥種類または欠陥程度を分類することができる。
【0102】
ここでは本発明の手法から得られる情報以外に欠陥信号の面積、輝度積算値、半値幅等の従来から使われてきた各種特徴量をも含めて認識してもよいので一般的にはn次元でのベイズの定理に基づいた最尤決定が考えられる。
【0103】
すなわち ̄での残存画素数u1、/での残存画素数u2、|での残存画素数u3、\での残存画素数u4、情報のエントロピーu5、欠陥信号の面積u6、輝度積算値u7、半値幅u8・・・を要素とするベクトルを特徴量パターンUとして考える。各残存画素数からのパターン認識には上記したベイズの定理に基づいた最尤決定の他にツリー型の論理や最近傍決定則(nearest neighbor rule)あるいはニューラルネットワークの手法などさまざまなものが考えられる。
【0104】
以上の実施の形態は、特定形態欠陥の抽出または欠陥種類または欠陥程度の分類に主眼をおいて書かれているが、同様の原理から生産工程における処理むら等の無害な信号を欠陥候補から除外するために用いてもよい。
【0105】
以上の実施の形態は、単独の構造要素を用いたトップハット変換により、ノイズを除去する方法であった。この方法によると、画像の濃淡のように大きなうねりをもった大きなノイズを効果的に除去し、微小な欠陥を効果的に検出することができる。
【0106】
しかしながら、実際の表面欠陥を検出する場合には、微小ではあるが急峻な信号変化を持ったノイズが存在することがある。たとえば、受光素子であるCCDの素子の感度むらに起因する画質の荒れなどがこのようなノイズに相当する。このような場合には、照明系に起因する緩やかな輝度斑と画質の荒れなどの急峻で細かいノイズ要素の両者を除去し、これらに対して中間的な急峻さの信号変化でを有する欠陥信号のみを抽出する必要がある。
【0107】
このような要望に適えるためには、サイズの異なる構造要素の対{g+(x), g−(x)}を使用し、それぞれのclosing演算またはopening演算の差分を求めて中心輝度を通常128(即ち最大信号の半分の信号)にし、バンドパスフィルターにように中間的な信号変化をもつ欠陥のみを選択的に抽出すればよい。
【0108】
図12に大きな半円状の構造要素g+(x)と小さな半円状の構造要素g−(x)を対としてclosing演算を行い、その差分により欠陥検出を行う方法を1次元の例として説明する。
【0109】
図12において(a)は元信号であり、図に示すように大きなうねりの中に、中程度のx軸方向の大きさと傾斜を有する欠陥と、x軸方向の大きさは小さいが、急峻な傾斜を有するノイズとが混在している。
【0110】
これに対して、大きな半円状の構造要素g+(x)を用いてclosing演算を行うと、半円状の構造要素g+(x)は、欠陥信号の中にもノイズ信号に中にも入り込めず、(b)に示すような軌跡をたどるので、結局、構造要素g+(x)によるclosing演算の結果は(c)のようになる。
【0111】
また、小さな半円状の構造要素g−(x)を用いてclosing演算を行うと、半円状の構造要素g−(x)は、欠陥信号の中には入り込めるがノイズ信号の中には入り込めず、(d)に示すような軌跡をたどるので、結局構造要素g−(x)によるclosing演算の結果は(e)のようになる。
【0112】
よって、(d)と(e)との差分をとるとその結果は(f)のようになり、ノイズ信号と大きなうねりが除去され、欠陥信号が強調されて残る。図12では模式的に1次元の負極性欠陥の例で説明したが、正極性の場合も、2次元の場合も、これから容易に想像できるとおりである。2次元の場合に使用する構造要素の対の例を図13に示す。図13において、数字は深さを示す。
【0113】
【実施例】
<実施例1>
以下、本発明を鉄鋼分野の鋼板の表面検査における有害欠陥抽出に適用した第1の例について述べる。
【0114】
画像処理装置内での信号処理の流れを図4に沿って説明する。先ずステップS11において画像データを採取して入力する。次に、ステップS12〜S15において、それぞれ―、/、|、\方向に長い構造要素(例えば、図3の構造要素2のように長手方向に延びた楕円状の形態を有する構造要素)によりトップハット変換S ̄(x、y)、S/(x、y)、S|(x、y)、S\(x、y)を行い、それぞれについてトップハット変換後の変換画像を得る。
【0115】
輝度の小さい欠陥を抽出したい場合は上からのトップハット変換、輝度の大きな欠陥を抽出したい場合は、下からのトップハット変換、両者を抽出したい場合は、両方のトップハット変換を行い、それぞれに変換後の変換画像を得る。上記のような構造要素によるトップハット変換により、構造要素の長手方向に急峻な信号変化をもつもののみを強調し、他の陰影をならした画像信号が得られる。
【0116】
次に、ステップS16において、前述の計算によりDmax(x、y)とDlinear(x、y)を求める。そして、ステップS17においてDmax(x、y)とDlinear(x、y)で形成されるグレースケール画像を出力し、ステップS18でそれから2値化画像を得る。このときトップハット変換により注目する信号変化以外は慣らされ規格化することができるため適当な固定の閾値により、シェーディング補正を経た画像の場合と同様に容易に2値化を行うことができる。この段階で、人間が2値化画像を見て、欠陥を判別するようにしてもよい。
 ̄/|\それぞれの構造要素を使用してトップハット変換後に2値化した画像の例を図5に示す。
【0117】
また、方向性を有する構造要素を、0〜180°に亘って、45°おきに回転させて、それぞれトップハット変換を行い、Dmax(x、y)を求めた画像を図6に、Dlinear(x、y)を求めた画像を図7に示す。Dlinear(x、y)において、各構造要素のトップハット変換に対する重み係数は、横(−)方向の信号を出しやすくするため、A−<A/=A\<A|のように調整してある。
【0118】
図6、図7のいずれにおいても、複雑な方向性を有する欠陥画像が、背景(ノイズ)に対して強調されて抽出されていることが分かる。
【0119】
この実施の形態では、その濃度積算値等の特徴量を求める。まず、ステップS19で、2値化画像のうち、不要な孤立点を除去したうえで残存する画素を欠陥候補とする。次に、ステップS20で、欠陥候補中の濃度(グレースケール値)の積算値、最低値(又は最高値)を求め、これらより欠陥の程度を判定する。また、欠陥候補と判定された2値化画像の面積より欠陥の大きさを求める。
【0120】
この実施の形態では、元画像にシェーディング補正をかけることは行っていない。シェーディング補正をかけると、その段階では欠陥の形状についての評価がおこわれてないため、鋼板上の大きな冷却水の流れなどを拾って過検出をおこしてしまう。またシェーディング処理においては、前述のように大きな正極性欠陥の信号のたちさがりの部分が反対の負極性の信号となり、正極性信号の影の部分を検出してしまうことになる。欠陥分類のための代表的なパラメータである濃度積算値は欠陥の領域で各画素の輝度を積算したものであるが、シェーディング処理によればこの特徴量を誤って計算してしまうことになる。
【0121】
よって、シェーディング補正を行わず、そこで元画像に対して欠陥より大きい適当な形の構造要素を使った下からのトップハット変換・上からのトップハット変換により負極性信号と正極性信号をそれぞれ抽出し、濃度積算値を求めれば適切な値が求められる。
【0122】
<実施例2>
以下、本発明を鉄鋼分野の鋼板の表面検査における有害欠陥抽出に適用した第2の例について述べる。
【0123】
画像処理装置内での信号処理の流れを図8に沿って説明する。先ずステップS21において画像データを採取して入力する。次にステップS22で、光学系に起因する輝度ムラを除去するためにシェーディング補正を行い、ステップS23で2値化処理をおこなって欠陥候補を求める。そして、この欠陥候補のランレングスと中心輝度(2値化前)を求める。
【0124】
欠陥候補が挙げられると元画像に戻って、ステップS26において、欠陥候補の近傍の画像を切り出す。これは、欠陥候補を含む画素と、その周辺の特定範囲の画素(例えば周囲の、x、y方向特定数の範囲の画素)を切り出すことによって求められる。そして、ステップS28で、前述のようなグレースケールのモルフォロジーにおける、特定の形態を持つ構造要素を使用したトップハット変換の演算を行うが、本実施例においては、それに先立ち、ステップS27において使用する構造要素を、ステップS25で求められたランレングスと中心輝度とを使用して、図9に示すような表により求めている。
【0125】
すなわち、本実施例においては、ステップS25で求められたランレングスと中心輝度を利用して予想される欠陥の形状を求め、その欠陥を有効に抽出できるような構造要素を、図9に示すような表から求めている。これにより、多種類の欠陥について、最適な構造要素でトップハット変換を行うことができる。
【0126】
ステップS28でのトップハット変換で求められた画像について、ステップS29で2値化処理を行い、2値化画像を得る。そして、ステップS30で、2値化された残存画素数を算出し、ステップS31で残存画素数が閾値以上であるかどうかを算出する。
【0127】
残存画素数が閾値以上の場合は、ステップS32で欠陥として出力する。ステップS26〜S32は、抽出された欠陥候補の全てについて実施する。
【0128】
トップハット変換はシェーディング補正のかわりに元画像全体にわたっておこなってもよいが、処理速度を上げるため、本実施例では欠陥候補の近傍において行うこととする。このようにトップハット変換を施す領域を狭めても広い領域での移動平均が必要となるシェーディング補正と異なり、構造要素より充分に大きい面積であれば、その正規化の能力を弱めることはない。
【0129】
また、本手段においては、欠陥候補の特性に応じて構造要素を選択して適用しているので、元画像全体に亘って全ての構造要素を使用してトップハット変換を行う場合に比して、大幅に処理時間を短縮できる。
【0130】
<実施例3>
以下、本発明を鉄鋼分野の鋼板の表面検査における有害欠陥分類に適用した例について述べる。
【0131】
例えば冷間圧延の工程において例えば通常の欠陥が流れ方向と垂直につくのに対してロールの圧下による欠陥は鋼板の流れ方向につく傾向があり、鋼板の表面検査においてはこのようなロールマークを特定する必要がある。このように欠陥の分類において形態およびテクスチャーの評価は重要である。
【0132】
この処理の流れを図10のフローチャートに従って説明する。まず先ずステップS41において画像データを採取して入力する。次に、ステップS32〜S53において、 ̄/|\の方向性と特定のスケールを持つ複数の構造要素を使用してトップハット変換を行い、それぞれ、S ̄(x、y)、S/(x、y)、S|(x、y)、S\(x、y)の画像を得て、適当な閾値により2値化することにより各残存画素数を算出し比較する。
【0133】
図11に、構造要素の例を示す。各構造要素中の数字は、紙面に垂直な方向の深さに対応する。(a)はほぼ球状の構造要素であり、方向性を有しない欠陥の抽出に適している。(b)はやや横長の楕円球状の構造要素であり、横長の欠陥を除外し、縦長の欠陥を検出するのに適している。(c)は縦に長い角錐台状の構造要素であり、縦長の欠陥を除外し、横長の欠陥を検出するのに適している。個の実施例では、(c)に示すような構造要素を使用した。|の方向性をもった構造要素は、(c)に対応するが、他の方向性をもった構造要素については、これを所定角度傾けたものとすればよい。 ̄/|\それぞれの構造要素を使用してトップハット変換後に2値化した画像の例を図5に示す。
【0134】
各残存画素数を比較して欠陥の種類および有害度について分類するためには、ステップS54においてベイズの定理に基づいた最尤(maximum likelihood)決定を行う。そして、その結果(欠陥分類結果)をステップS55において出力する。
【0135】
<実施例4>
本発明を,鉄鋼分野の鋼板の表面検査における有害欠陥抽出に適用した第3の例について述べる。これは構造要素対を使用した例である。画像処理装置内での信号処理の流れを図14に沿って説明する。先ず画像データを入力する(ステップS61)、次に構造要素g−(x,y)を使用し、画像データに対してclosing演算を行い、その結果として演算画像S−(x,y)を得る(ステップS62)。
【0136】
続いて、構造要素g−(x,y)とはサイズの異なる構造要素g+(x,y)を使用し、画像データに対してclosing演算を行、その結果として演算画像S+(x,y)を得る(ステップS63)。そして、ステップS64において演算画像S−(x,y)とS+(x,y)の差分画像D(x,y)を求める。この際、256階調のグレースケールを有する差分画像に対して、128のバイアスをはかせ、差分画像のグレースケールが中央値近傍にくるようにする(ステップS64)。
【0137】
次に、この画像信号を固定の閾値によって2値化し(ステップ65)不要な孤立点を除去したうえで残存する画素を欠陥候補とする(ステップS66)。このとき上記処理により注目する信号変化以外は慣らされ規格化することができるため適当な固定の閾値により、シェーディング補正を経た画像の場合と同様に容易に2値化を行うことができる。
【0138】
【発明の効果】
以上説明したように、本発明によれば、撮像によって得られた画像信号を新規な方法で処理することにより、欠陥の検出や種類の判別を精度よく行うことができる表面欠陥検出方法を提供することができる。
【図面の簡単な説明】
【図1】1次元関数f(x)に対して、半円状の構造関数g1(x)にてopening演算を行った結果と、半円状の構造関数g2(x)にてclosing演算を行った結果を示す図である。
【図2】上からのトップハット変換について、1次元信号の場合を例にとって説明する図である。
【図3】トップハット変換に使用する構造要素の例と、トップハット変換の結果を示す図である。
【図4】本発明の第1の実施例における処理のフローを示すフローチャートである。
【図5】 ̄/|\それぞれの構造要素を使用してトップハット変換後に2値化した画像の例を示す図である。
【図6】方向性を有する構造要素を、0〜180°に亘って、45°おきに回転させて、それぞれトップハット変換を行って求めた、Dmax(x、y)を示す画像である。
【図7】方向性を有する構造要素を、0〜180°に亘って、45°おきに回転させて、それぞれトップハット変換を行って求めた、Dlinear(x、y)を示す画像である。
【図8】本発明の第2の実施例における処理のフローを示すフローチャートである。
【図9】ランレングスと中心輝度からトップハット変換に使用する構造要素を決定する表の1例を示す図である。
【図10】本発明の第3の実施例における処理のフローを示すフローチャートである。
【図11】構造要素の例を示す図である。
【図12】図12に大きな半円状の構造要素g+(x)と小さな半円状の構造要素g−(x)を対としてclosing演算を行い、その差分により欠陥検出を行う方法を説明する図である。
【図13】2次元の場合に使用する構造要素の対の例を示す図である。
【図14】構造要素の対を使用した処理における画像処理装置内での信号処理の流れを説明する図である。[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a technology for optically detecting a surface defect of a test object such as a film, paper, and steel.
[0002]
[Prior art]
As a method of optically detecting a defect generated on the surface of an industrial product, for example, as disclosed in Japanese Patent Application Laid-Open No. 8-82604, an image signal obtained by imaging is subjected to, for example, a defect width, a defect area, and a vertical and horizontal direction. There is known a method of classifying defects by a tree-type logic based on various characteristic amounts such as a ratio and a maximum intensity.
[0003]
Japanese Patent Application Laid-Open No. 8-189904 proposes a method of extracting a feature by causing a template designed in advance to correspond to a surface defect to act on image data or differential image data. Furthermore, the publication also proposes a method of generating a density co-occurrence matrix for image data or differential image data and obtaining a feature amount therefrom.
[0004]
[Problems to be solved by the invention]
However, all of the conventional techniques, including the techniques disclosed in the above-mentioned patent methods, are insufficient to accurately detect the surface defect of the inspection object.
[0005]
For example, a technique described in Japanese Patent Application Laid-Open No. 8-82604 is a means for obtaining an effective feature amount for a defect image form and its texture directionality, which are important factors for classifying a defect type or a harmfulness. The classification was incomplete without any. As for the method of knowing the directionality of the texture of an image, for example, a method of performing a two-dimensional Fourier transform on the image signal and performing spectrum analysis has been known, but the image signal does not have the same texture directionality over the entire area, An effective result could not be obtained when the defect image to be evaluated was localized.
[0006]
Further, in the technology described in Japanese Patent Application Laid-Open No. 8-189904, since the types of defects and the harmfulness to be judged are various, it is necessary to design at least 200 or more types of templates, and an optimum design is performed for each template. There is no clear guideline. Furthermore, in a method of generating a density co-occurrence matrix for image data or differential image data and calculating a feature amount from the density co-occurrence matrix, the image signal does not have the same texture directionality over the entire area, and a defect to be evaluated. Effective results could not be obtained when the image was localized. In addition, there is a problem that only a feature amount of a texture in a specific direction is extracted, and a geometric feature amount in which a more complicated form is used as a structural element cannot be extracted.
[0007]
In automatic defect detection, shading processing is used before binarization to normalize an image signal having uneven brightness. However, the falling part of the signal of a large positive defect is replaced with the opposite negative signal. In addition, a rising portion of the signal of a large negative polarity defect becomes a signal of the opposite positive polarity, and as a result, a non-defective signal is frequently erroneously detected as a defect.
[0008]
In this method, the moving average is calculated for a plurality of lines ahead and subtraction or division is performed on the target line, so that the falling portion of the positive polarity defect signal becomes a level lower than the center luminance after processing, and the negative polarity signal, the negative polarity defect This is because the rising portion of the signal has a level higher than the center luminance and becomes a signal of positive polarity. While it is important to determine the polarity of the defect signal in the automatic detection of the harmful defect, the differential processing such as a conventionally known shading method has the above-mentioned essential defects.
[0009]
Furthermore, regarding the classification of defects, defect classification is conventionally performed on image signals obtained by imaging using tree-type logic based on various characteristic amounts such as defect width, defect area, aspect ratio, and maximum intensity. . However, for example, regarding the form of the target defect image, whether it extends in the longitudinal direction, spreads in the width direction, spreads in the oblique direction, or has a more complicated luminance distribution, the harmfulness of the defect for that form is different.
[0010]
For example, there is no effective means when a defect signal having a steep change in the longitudinal direction and spreading in the width direction is particularly important, and there is a demand that only such a signal must be extracted.
[0011]
There is no means to extract only a specific form of the defect, which is an important factor for classifying the harmfulness of the defect, and overdetection often occurred. For example, many periodic defects caused by roll flaws appear as narrow and sharp signals in the longitudinal direction. Therefore, it is necessary to selectively extract and output such a form. However, there is no effective means for this.
[0012]
The present invention has been made in view of such circumstances, and provides a surface defect detection method that can accurately detect defects and determine the type by processing image signals obtained by imaging using a novel method. The task is to provide.
[0013]
[Means for Solving the Problems]
A first means for solving the above-mentioned problem is a step of obtaining a gray image by imaging a surface of an object to be inspected, and a method of obtaining a gray-scale morphology for at least a part of the obtained image signal. A surface defect detection method (claim 1) comprising a step of performing a top hat transform operation using a single or a plurality of structural elements having the following, and extracting a defect from an image obtained as a result. is there.
[0014]
As will be described later in detail in the embodiments of the present invention, when the top-hat transform is performed using a specific structural element in morphology, it is possible to remove a gradual change in an image and extract only a steep change. Therefore, it becomes easy to distinguish the surface defect from noise and extract it. Further, by changing the characteristics of the structural element, the type of the defect to be extracted can be changed. Furthermore, by performing top-hat conversion using a plurality of structural elements and comparing the converted images obtained as a result, the presence or absence of a defect can be more accurately detected.
[0015]
A second means for solving the above-mentioned problem is the first means, wherein “the step of extracting a defect from the resulting image” is performed by binarizing the resulting image, This is a step of extracting a defect based on the binarized image (claim 2).
[0016]
In the present means, an image obtained as a result of the top hat transformation is binarized with a predetermined threshold value, and a defect is extracted based on the obtained binarized image. Therefore, the defect can be detected by a simple method.
[0017]
A third means for solving the above-mentioned problem is the second means, wherein a top hat transform operation is performed using a plurality of structural elements. Is a step of extracting defects by calculating binary images corresponding to a plurality of obtained structural elements (claim 3). .
[0018]
In this means, a top hat transform operation is performed using a plurality of structural elements, the result is binarized, and a logical operation is performed on the binarized image corresponding to the obtained plurality of structural elements. , Defect extraction. Therefore, the presence or absence of a defect can be detected more accurately.
[0019]
A fourth means for solving the above-mentioned problem is the first means, wherein a top hat transform operation is performed using a plurality of structural elements, and a defect image is obtained from the resulting image. The step of extracting is a step of extracting a defect based on an image composed of a maximum value or a minimum value of pixel values obtained by each top hat transform (claim 4). is there.
[0020]
In the present means, a top hat transform operation is performed using a plurality of structural elements, and a defect is extracted based on an image consisting of the maximum or minimum pixel value obtained by each top hat transform.
[0021]
In this way, the defect is extracted based on the top hat transform using the structural element in which the defect is most easily detected, and the presence or absence of the defect can be accurately detected. For example, in the case where one defect has undulation, if an attempt is made to detect only one directional structural element, a part of the defect may be missed. A defect having a complicated shape can be accurately recognized as one defect.
[0022]
A fifth means for solving the above-mentioned problem is the first means, wherein a top hat transform operation is performed using a plurality of structural elements. The step of extracting is a step of extracting defects based on an image obtained by a linear combination of the obtained top hat transform results (claim 5).
[0023]
In this means, the defect is extracted based on the image obtained by the linear combination of the obtained top hat transform results, so that the defect of the target shape is emphasized by changing the coefficient of the linear combination. It is possible to accurately detect all the defects having a predetermined shape.
[0024]
A sixth means for solving the above-mentioned problems is a step of obtaining a gray image by imaging the surface of the object to be inspected, and a method of obtaining a gray-scale morphology for at least a part of the obtained image signal. Performs a top-hat transformation operation using a plurality of structural elements having the above, and performs at least one of defect classification and defect degree determination from the resulting image image of the top-hat transformation corresponding to the plurality of structural elements. A method for detecting a surface defect, comprising the step of:
[0025]
In this means, the type of the defect to be extracted can be changed by changing the characteristic of the structural element. Furthermore, by performing top-hat conversion using a plurality of structural elements and comparing the converted images obtained as a result, it is possible to accurately detect the type, degree, and type of the defect.
[0026]
A seventh means for solving the above-mentioned problem is the sixth means, wherein the image image after the top hat conversion is binarized, and the binarized image is used for at least classification of defects and determination of the degree of defects. The present invention is characterized in that the method includes a step of performing one of them.
[0027]
In the present means, an image obtained as a result of the top hat transformation is binarized with a predetermined threshold value, and a defect is extracted based on the obtained binarized image. Therefore, at least one of defect classification and defect degree determination can be performed by a simple method.
[0028]
Eighth means for solving the above-mentioned problems includes a step of obtaining a gray image by imaging the surface of the object to be inspected, and a directional property in a grayscale morphology for at least a part of the obtained image signal. Performs a top-hat transform operation using a plurality of structural elements having a specific shade, binarizes the resulting image image of the top-hat transform corresponding to the plurality of structural elements, and calculates remaining pixels. A method for calculating the entropy of information from these ratios and quantitatively evaluating the deviation in the directionality of the defect from the value of the entropy (claim 8).
[0029]
In this means, top hat transformation is performed using a plurality of structural elements having a specific directional shading, and the obtained image is binarized to calculate the remaining pixels. Then, entropy is calculated from the ratio. When the value of the entropy is large, it can be determined that the defect has less directivity, and when the value of the entropy is small, it can be determined that the defect is directional.
[0030]
A ninth means for solving the above-mentioned problem is any of the first means to the eighth means, wherein after a step of imaging a surface of the inspection object to obtain a gray image, another A method for determining a candidate portion of a defect and characteristics of the defect by the method, and performing a top-hat transform operation using a structural element corresponding to the characteristic of the defect for each candidate portion of the defect. (Claim 9).
[0031]
In this means, for example, the characteristics of the rough defect are obtained by an arbitrary conventional method, and the calculation of the top-hat transformation is performed using the structural element corresponding to the rough defect characteristic. It is possible to select and use various structural elements, and it is possible to reduce the operation time as compared with using all the structural elements. In addition, since a portion that is a candidate for a defect is determined in advance, the area for performing the top-hat conversion can be reduced.
[0032]
A tenth means for solving the above problem is the ninth means, wherein another method first performs shading processing and binarization on an image signal obtained by imaging to extract a defect candidate. Further, the present invention is characterized in that a part which is a candidate for a defect and a characteristic of the defect are obtained from the binarized image (claim 10).
[0033]
In this means, first, a shading process and binarization are performed on an image signal obtained by imaging to extract a defect candidate, and a defect candidate portion and the characteristic of the defect are obtained from the binarized image. Structural elements are used depending on the result. Therefore, structural elements can be properly used by simple preprocessing.
[0034]
An eleventh means for solving the above-mentioned problem is the tenth means, wherein a method for obtaining a candidate portion of a defect from the binarized image and a characteristic of the defect is performed by using a pixel in the binarized image. (Claim 11). The method according to claim 11, wherein the method is based on at least one of the center luminance and the run length before binarization.
[0035]
In this means, the binarized image indicates the approximate range of the defect. The central luminance of the pixel before binarization in that range represents the depth of the defect, and the run length represents the length of the defect. Therefore, by selecting a structural element based on at least one of them, an appropriate structural element can be selected based on at least one of the defect depth and the defect length.
[0036]
A twelfth means for solving the above-mentioned problems is a step of obtaining a gray image by imaging the surface of the object to be inspected, and a method of obtaining a gray-scale morphology for at least a part of the obtained image signal. A surface defect detection method comprising: performing a closing operation or an opening operation using a single or a plurality of structural element pairs having a difference to obtain a difference between the pairs; and extracting a defect from an image obtained as a result. (Claim 12).
[0037]
A thirteenth means for solving the above-mentioned problem is the twelfth means, wherein the step of extracting a defect from the obtained image is performed by binarizing the obtained image into a binary image. This is a step of extracting a defect based on the structured image (claim 13).
[0038]
A fourteenth means for solving the above-mentioned problem is the thirteenth means, wherein a difference between a closing operation or an opening operation is obtained by using a plurality of pairs of structural elements, and based on the binarized image. The step of extracting a defect is a step of extracting a defect by calculating a binary image corresponding to a plurality of obtained structural element pairs (claim 14). It is.
[0039]
A fifteenth means for solving the above-mentioned problem is the twelfth means, wherein a difference between a closing operation or an opening operation is obtained by using a plurality of pairs of structural elements, and an image obtained as a result is obtained. The step of extracting a defect from the image is a step of extracting a defect based on an image composed of a maximum value or a minimum value of pixel values obtained by a difference between each closing operation or opening operation. (Claim 15).
[0040]
A sixteenth means for solving the above-mentioned problem is the twelfth means, wherein a difference between operations of a closing operation or an opening operation is obtained by using a plurality of pairs of structural elements. The step of extracting a defect from the obtained image is a step of extracting a defect based on an image obtained by a linear combination of the obtained differences of each closing operation or opening operation. 16).
[0041]
A seventeenth means for solving the above-mentioned problems includes a step of obtaining a gray image by imaging the surface of the object to be inspected, and a method of obtaining a gray-scale morphology for at least a part of the obtained image signal. Classification of defects from a difference image of a closing operation or an opening operation corresponding to a plurality of structural element pairs obtained as a result of performing a difference operation of a closing operation or an opening operation using a plurality of structure element pairs having And a step of performing at least one of a defect degree determination and a surface defect detection method (claim 17).
[0042]
An eighteenth means for solving the above-mentioned problem is the seventeenth means, wherein the image image after the calculation of the difference of the closing operation or the opening operation is binarized, and the classification of the defect is performed from the binarized image. A surface defect detection method (claim 18), comprising a step of performing at least one of defect degree determination.
[0043]
A nineteenth means for solving the above problems is a step of obtaining a gray image by imaging the surface of the object to be inspected, and a method of obtaining a gray scale morphology for at least a part of the obtained image signal. A difference operation of a closing operation or an opening operation using a plurality of structural element pairs having a specific shading is performed, and the resulting difference image of the closing operation or the opening operation corresponding to the plurality of structural element pairs is represented by 2 A surface defect detection method (claim 19) comprising the steps of: calculating a residual pixel by calculating a value; calculating an entropy of information from these ratios; and quantitatively evaluating a bias of the directionality of the defect. is there.
[0044]
A twentieth means for solving the above-mentioned problem is any one of the twelfth means to the nineteenth means, wherein after a step of imaging a surface of the inspection object to obtain a gray image, another A method comprising: obtaining a candidate part of a defect and characteristics of the defect by a method; and performing a closing operation or an opening operation for each candidate part using a structural element pair corresponding to the characteristic of the defect. (Claim 20).
[0045]
A twenty-first means for solving the above-mentioned problem is the twentieth means, wherein another method first performs shading processing and binarization on an image signal obtained by imaging to extract a defect candidate. Further, the present invention is characterized in that a part which is a candidate for a defect and a characteristic of the defect are obtained from the binarized image (claim 21).
[0046]
A twenty-second means for solving the above-mentioned problem is the twenty-first means, wherein the method for obtaining a candidate portion of a defect from the binarized image and a characteristic of the defect is performed by using a method for determining a pixel in the binarized image. (Claim 22). The method according to claim 22, wherein the method is based on at least one of the center luminance and the run length before binarization.
[0047]
These twelfth to twenty-second means correspond to the first to twelfth means, respectively. In the first to twelfth means, the top-hat transform using a structural element is used, whereas in the thirteenth to twenty-fourth means, a pair of structural elements is used. The difference is that the difference of the result of the closing operation or the opening operation using the structural element of is calculated, the subsequent operation is performed based on the result of the difference operation, and the defect is detected based on the result. I have.
[0048]
By calculating the difference between the closing operation or the opening operation using the pair of structural elements, a defect having an intermediate size between the two structural elements can be emphasized and extracted. For example, if a large structural element and a small structural element are paired so that a large structural element can follow a gradual change such as luminance unevenness and a small structural element cannot follow a minute noise, Since both structural elements can follow the small noise and neither structural element can follow the minute noise, if a difference is obtained, these elements will not be detected. Then, it is possible to extract only a defect whose size is such that a large structural element cannot follow and a small structural element can follow.
[0049]
BEST MODE FOR CARRYING OUT THE INVENTION
Hereinafter, embodiments of the present invention will be described with reference to the drawings. First, an image of the surface of the object to be inspected is stored in an image memory by an imaging system using a light source and a camera, for example. In the present embodiment, the obtained image signal is subjected to shading, the image is subjected to a top-hat transformation using a structuring element having a specific shading in a grayscale morphology, and a defect is determined from the resulting image. Is extracted.
[0050]
First, shading correction is performed on the image data collected in the image memory in order to remove luminance unevenness caused by the optical system. At this time, the normalization by shading correction is performed by taking a moving average in a predetermined range before and after the line of interest and subtracting or dividing from the signal of the line of interest, as is well known in the art. Since the image after the shading correction has a gray scale of, for example, 256 gradations, a binarization process can be performed by using a predetermined threshold value to obtain a binarized image.
[0051]
A defect candidate is obtained from the binarized image. That is, for example, an area where the pixel value is “1” in the binarized image is set as a defect candidate. The defect candidate includes a signal other than the defect signal such as a shadow portion which is a side effect of the shading correction.
[0052]
Next, a true defect signal is found from the defect candidates by a top-hat transformation known as an example of the morphological processing. That is, an image of a defect candidate and pixels in the vicinity thereof is cut out, and processing is performed using a specific structural element corresponding to the form of the defect signal of interest for top-hat transformation. The image signal used for this processing is a grayscale image before shading correction.
[0053]
The structural element used for the top-hat transformation may be one specific type. First, the binarized image is classified according to several patterns based on its length, aspect ratio, length direction, and the like. Other structural elements may be used. As an example of the structural element, for example, a plurality of structural elements having a direction of {/ |} and a specific scale may be used for simplicity. The direction of each line represents a structural element having a long shape in that direction. Each structural element is not limited to this, and may adopt a more complicated form.
[0054]
A plurality of processed images S obtained after the top hat transform for each structural element ̄(X, y), S/(X, y), S|(X, y), S\Maximum value of (x, y)
Dmax(X, y) = max {S ̄(X, y), S/(X, y), S|(X, y), S\(X, y)}
, A linear defect long in a direction perpendicular to each direction can be extracted as a center.
[0055]
Also, the coefficient A for each pixel of the processed image ̄, A/, A\, A|Weighted linear combination
Dlinear(X, y)
= A ̄・ S ̄(X, y) + A/・ S/(X, y) + A|・ S|(X, y) + A\・ S\(X, y)
May be taken. At this time, for example, A ̄<A/= A\<A|In particular, a horizontal linear defect becomes particularly sensitive, and a vertical linear defect can be weighted. Further, it is also possible to binarize the obtained plurality of images with a predetermined threshold value and execute an operation such as a logical sum or a logical product to extract a true harmful defect.
[0056]
The morphology of the gray scale is described in detail in, for example, “Morphology” (Corona). Morphology is a new image processing technology that is being applied to the analysis of medical images, such as breast cancer X-ray screening, and uses a set-theoretic operation that uses preset structural elements to extract a specific geometric structure from an original image. This is to selectively extract only the elements that have.
[0057]
The morphological processing on the grayscale image is based on an element called a structural element that moves the image and an operation called Minkowski sum and Minkowski difference. Typical operations include a dilation operation and an erosion operation, and an opening operation and a closing operation of a combination thereof. There is an operation.
[0058]
When the gray value of the two-dimensional image to be processed is expressed as a function f (X) in a domain F of a two-dimensional space, and the gray value of a structural element is expressed as a structure function g (X) in a domain G of a two-dimensional space (X is 2 Dimensional variable, U appearing below is also a two-dimensional variable), and in the case of discrete data, first the Minkowski sum is
[0059]
(Equation 1)
[0060]
The Minkowski difference is
[0061]
(Equation 2)
[0062]
Is defined as Note that, as a symbol for defining the Minkowski difference, a symbol in which-is inserted in a circle is usually used. However, such a symbol cannot be used due to font restrictions. Further, the dilation operation is performed by converting g (X) of the Minkowski sum to a symmetric gs(X) = g (−X)
[0063]
(Equation 3)
[0064]
In addition, the erosion (scraping) operation is g (X) of the Minkowski sum to gs(X)
[0065]
(Equation 4)
[0066]
Is defined by The g (U) is translated in parallel with the function f (X), and the maximum value of the sum of the corresponding points in the vertical direction is a dilation operation, and the minimum value of the difference is an erosion operation.
Here, the opening operation is the combination of the Minkowski sum and the erosion operation.
[0067]
(Equation 5)
[0068]
The closing operation combines the Minkowski difference and the dilation operation.
[0069]
(Equation 6)
[0070]
It becomes.
[0071]
FIG. 1 shows a result obtained by performing an opening operation on a one-dimensional function f (x) using a semicircular structure function g1 (x) and a result obtained by performing a closing operation using a semicircular structure function g2 (x). The results obtained are shown. In this case, the opening operation corresponds to a smoothing process from below, and the closing operation corresponds to a smoothing process from above.
[0072]
If the value of the pixel subjected to the smoothing process from the bottom by the opening operation is subtracted from the value of the original pixel, the value of the pixel subjected to the top-hat transformation from the bottom and the value of the pixel subjected to the smoothing process from the top by the closing operation is Subtraction from the value of the original pixel results in top-hat transformation from above. From the viewpoint of extracting a defect signal from an image, top-hat conversion from below means extraction of a positive defect signal, and top-hat conversion from above means extraction of a negative defect signal.
[0073]
The top-hat transform from above will be described with reference to FIG. 2 using a one-dimensional signal as an example. Where the value of the function changes slowly, the sphere can trace it exactly, but if there is a negative pulse, the sphere will not be able to enter that part, so it will be out of the traceable range It will be off. Therefore, a smooth curve is obtained as the trajectory of the sphere, as shown in FIG. If the trajectory of the sphere is subtracted from the original signal, only a sharp negative polarity signal can be extracted (c).
[0074]
As apparent from FIG. 2, what kind of signal to extract is determined by the form of the structural element. Also in the two-dimensional case, it can be easily imagined that only the defect signal having a sharp change can be extracted by using the structural element as shown in FIG.
[0075]
In FIG. 3, as shown in FIG. 3A, a top-hat transform is performed on a structural element having a shape of a downwardly convex elliptical sphere. (B) is an image before conversion (a gray image, which is a binarized image due to restrictions in application documents), and has a sharp gradation change among gentle gradation changes. There are two defects. The actual size of the structural element is the size shown on the lower side of (b). (C) shows the gray image after the top hat conversion, and it can be seen that only the defect is extracted.
[0076]
Furthermore, when classifying the types and harmfulness of defects as well as extracting true harmful defects, it is conceivable to perform top-hat conversion with a plurality of structural elements. In the following example, for the sake of simplicity, a case will be described in which a plurality of structural elements having a direction of {/ |} and a specific scale are used. However, the present invention is not limited to this, and a more complicated form may be used as a structural element. You may adopt it.
[0077]
As described above, the top hat transformation is performed using the structural element, and the detection, the degree determination, and the type determination of the defect are performed based on the image after the top hat transformation. The method of detecting the defect, determining the degree, and determining the type based on the image is not particularly limited, and a conventionally used method may be appropriately used, or in an extreme case, the image after the top hat conversion may be used by a human. You may look and do these things.
[0078]
Hereinafter, an example of defect type determination will be described. First, a method of determining whether a defect has directivity or non-directionality will be described.
[0079]
First, after top-hat transformation in each structural element, S ̄(X, y), S/(X, y), S|(X, y), S\(X, y) is obtained, a plurality of binarizations are performed using an appropriate threshold, and the number of remaining pixels is calculated. In this example, four structural elements having the directionality of {/ |} and a specific scale are used to obtain the number of remaining pixels of each of the four images as shown in FIG. At this time, a plurality of processed images S ̄(X, y), S/(X, y), S|(X, y), S\The feature amount obtained from (x, y) is not limited to the number of remaining pixels after binarization, and for example, a maximum luminance exceeding an appropriate threshold may be used.
[0080]
The calculated feature amount is converted into a four-dimensional vector U = (u1, U2, U3, U4) And is called a feature amount pattern. In this example, the number of remaining pixels u1, / Remaining number of pixels u2| The number of remaining pixels u3, 残存 the number of remaining pixels u4Is a feature amount.
[0081]
Further, the bias of the texture of the defect may be quantitatively evaluated by calculating the entropy of information from the ratio of the number of remaining pixels, and may be treated as a new feature amount. Entropy is a quantity expressing the predictability of an event, and the generation probability of an event l is represented by Pl(However,
[0082]
(Equation 7)
[0083]
The sum is taken for all events that occur)
[0084]
(Equation 8)
[0085]
(Sum is taken for all events that occur)
It is expressed by the formula. The entropy of information is greatest when all events occur with the same probability and is the least predictable, and when only one event occurs (ie its generation probability 1) and when no other events occur most easily (ie its generation probability 0) ) The entropy of the information becomes the lowest value (0).
[0086]
Here, when the directionality of the texture is random, the entropy of the information is large, and when the directionality of the texture is uneven, the entropy of the information is small. Each remaining pixel number u1, U2, U3, U4Is given,
[0087]
(Equation 9)
[0088]
like
[0089]
(Equation 10)
[0090]
(The sum is obtained for all categories; that is, in the above case, m = 1 to 4)), and then the information entropy u5= H may be calculated as a new feature value. By calculating the entropy in this manner, it is possible to determine whether the defect has a specific direction or not.
[0091]
Next, an example of a method using maximum likelihood determination based on Bayes' theorem will be described as a method for classifying the type and harmfulness of a defect from the obtained numbers of remaining pixels.
[0092]
First, as described above, the feature amount u1, U2, U3, U4A feature amount pattern U, which is a vector composed of In this case, the C defect types or defect degrees are classified from the four-dimensional feature pattern.
The type of defect or the degree of defect to be classified is called a category. Feature amount pattern U = (u1, U2, U3, U4) Is observed, P (j | U) is the probability that the category of the defect is j, P (U | j) is the probability that category j (the number of categories C) will generate a feature pattern U, and category j Is P (j) and the probability of occurrence of the feature pattern U is P (U), the Bayes theorem gives
P (j | U) = {P (U | j) P (j)} / P (U)
[0093]
Here, P (U | j) and P (j) can be obtained by collecting a large number of samples in advance. It is assumed that P (U) does not normally depend on the category. Then, by changing j in this equation, the category i that maximizes P (j | U) may be set as the defect category (defect type or defect degree, etc.).
[0094]
In practice, U = (u1, U2, U3, U4) Is infinite, so u1, U2, U3, U4Are divided into a predetermined number K from 0 to a predetermined maximum value, and U is determined for each of the divisions. In this way, U becomes K4You only need to consider the individual.
[0095]
In advance, supervised learning is performed from a large number of learning samples in which the correspondence between the feature amount pattern U and its category (defect type or defect degree, etc.) is known. The generation probability P (j) of the category j is obtained, and each element v of the feature amount pattern V (V⊆Z, Z is a set of all possible patterns) classified into the category j is obtained.kAverage value m for each k of (k = 1 to 4)k, And variance σkk 2And vkAnd vlCovariance σ ofkl 2= Σlk 2(K ≠ l) is calculated (k = 1, 2, 3, 4; l = 1, 2, 3, 4). Average vector is Mj= (M1, M2, M3, M4)T, 4 × 4 covariance matrix
[0096]
[Equation 11]
[0097]
It expresses. here,
m1: Average number of remaining pixels when  ̄ in the learning sample is a structural element
m2: Average number of remaining pixels when / is used as a structural element in the learning sample
m3: Average number of remaining pixels when | is a structural element in the learning sample
m4: Average number of remaining pixels when \ in the learning sample is a structural element
σ11 2: Variance of the number of remaining pixels when  ̄ in the training sample is a structural element
σ22 2: Variance of the number of remaining pixels when / is used as a structural element in the learning sample
σ33 2: Variance of the number of remaining pixels when | is a structural element in the learning sample
σ44 2: Variance of the number of remaining pixels when \ in the training sample is a structural element
σ12 2= Σ21 2: Covariance of the number of remaining pixels when  ̄ is a structural element and the number of remaining pixels when / is a structural element in the learning sample
σ23 2= Σ32 2: Covariance between the number of remaining pixels in the learning sample when / is a structural element and the number of remaining pixels when | is a structural element
σ34 2= Σ34 2: Covariance between the number of remaining pixels when | is a structural element and the number of remaining pixels when \ is a structural element in the learning sample
σ13 2= Σ31 2: The covariance of the number of remaining pixels when  ̄ is a structural element and the number of remaining pixels when | is a structural element in the learning sample
σ24 2= Σ42 2: Covariance of the number of remaining pixels in the learning sample when / is a structural element and the number of remaining pixels when と き is a structural element
σ14 2= Σ41 2: The covariance of the number of remaining pixels when と し た is a structural element and the number of remaining pixels when \ is a structural element in the learning sample
It is.
The average vector and the variance matrix are calculated for all the categories j.
[0098]
Assuming that the probability of occurrence of the category j follows the n-dimensional (n = 4 in this case) normal distribution of the feature pattern U, the likelihood function becomes | Σ by calculation from Bayes' theorem.j|jAs the determinant of
[0099]
(Equation 12)
[0100]
It becomes.
[0101]
When a feature amount pattern W (W⊆Z) is detected in a certain inspection, if j is changed to find a category i in which the likelihood function g (j | W) is maximized, P (j | W) (the probability that the feature amount pattern W is category j when it is observed) is also maximum, and the defect type or defect degree can be classified into category i.
[0102]
Here, in addition to the information obtained from the method of the present invention, various types of conventionally used features such as the area of the defect signal, the integrated luminance value, and the half width may be recognized. The maximum likelihood decision based on Bayes' theorem in is considered.
[0103]
That is, the number of remaining pixels u in  ̄1, / Remaining number of pixels u2, | The number of remaining pixels u3, 残存 the number of remaining pixels u4, Entropy of information u5, The area u of the defect signal6, Integrated luminance value u7, Half width u8.. Are considered as feature amount patterns U. For the pattern recognition from each number of remaining pixels, various methods such as a tree-type logic, a nearest neighbor rule (nearest @ neighbor @ rule), or a neural network method can be considered in addition to the maximum likelihood determination based on Bayes' theorem described above. .
[0104]
Although the above embodiment has been described with an emphasis on the extraction of specific form defects or the classification of defect types or defects, harmless signals such as uneven processing in the production process are excluded from defect candidates based on the same principle. May be used to do so.
[0105]
The above-described embodiment is a method of removing noise by top-hat transformation using a single structural element. According to this method, it is possible to effectively remove a large noise having a large undulation such as a shading of an image, and to effectively detect a minute defect.
[0106]
However, when an actual surface defect is detected, there is a case where noise having a small but sharp signal change exists. For example, rough image quality due to uneven sensitivity of a CCD element serving as a light receiving element corresponds to such noise. In such a case, both a gentle luminance unevenness due to the illumination system and a steep and fine noise element such as a rough image quality are removed, and a defect signal having an intermediate steep signal change with respect to these is removed. Only need to extract.
[0107]
In order to meet such a demand, a pair of structural elements having different sizes is required.+(X), g−(X) Using 輝 度, find the difference between each closing operation or opening operation to set the center luminance to normally 128 (ie, half the maximum signal), and to have a defect with an intermediate signal change like a band pass filter. Only what is necessary is to extract only.
[0108]
FIG. 12 shows a large semicircular structural element g.+(X) and small semicircular structural element g−A method of performing a closing operation using (x) as a pair and detecting a defect based on the difference will be described as a one-dimensional example.
[0109]
In FIG. 12, (a) is an original signal, as shown in the figure, a defect having a medium size and inclination in the x-axis direction and a small size in the x-axis direction, Noise having a slope is mixed.
[0110]
On the other hand, a large semicircular structural element g+When a closing operation is performed using (x), a semicircular structural element g+(X) cannot enter into the defect signal nor the noise signal, and follows the trajectory as shown in (b).+The result of the closing operation by (x) is as shown in (c).
[0111]
Also, a small semicircular structural element g−When a closing operation is performed using (x), a semicircular structural element g−(X) can enter into the defect signal but cannot enter into the noise signal, and follows the trajectory shown in (d).−The result of the closing operation by (x) is as shown in (e).
[0112]
Therefore, when the difference between (d) and (e) is obtained, the result is as shown in (f), the noise signal and the large swell are removed, and the defective signal remains emphasized. Although FIG. 12 schematically illustrates an example of a one-dimensional negative defect, both positive and two-dimensional defects can be easily imagined from now on. FIG. 13 shows an example of a pair of structural elements used in the two-dimensional case. In FIG. 13, the numbers indicate the depth.
[0113]
【Example】
<Example 1>
Hereinafter, a first example in which the present invention is applied to the extraction of harmful defects in the surface inspection of a steel sheet in the steel field will be described.
[0114]
The flow of signal processing in the image processing device will be described with reference to FIG. First, in step S11, image data is collected and input. Next, in steps S12 to S15, each of the structural elements is elongated in the −, /, |, and \ directions (for example, a structural element having an elliptical shape extending in the longitudinal direction like the structural element 2 in FIG. 3). Hat transformation S ̄(X, y), S/(X, y), S|(X, y), S\(X, y) is performed to obtain a converted image after the top hat conversion for each.
[0115]
If you want to extract defects with low brightness, perform top-hat conversion from the top.If you want to extract defects with high brightness, perform top-hat conversion from the bottom.If you want to extract both, perform top-hat conversion for both. Obtain a converted image after conversion. By the above-described top-hat transform using the structural element, only an image signal having a steep signal change in the longitudinal direction of the structural element is emphasized, and an image signal in which another shading is smoothed is obtained.
[0116]
Next, in step S16, Dmax(X, y) and Dlinear(X, y) is obtained. Then, in step S17, Dmax(X, y) and DlinearA grayscale image formed by (x, y) is output, and a binary image is obtained therefrom in step S18. At this time, except for the signal change of interest by the top-hat transformation, it can be used and standardized, so that binarization can be easily performed with an appropriate fixed threshold value in the same manner as in the case of an image that has undergone shading correction. At this stage, a human may look at the binarized image and determine the defect.
FIG. 5 shows an example of an image binarized after the top hat transform using each of the structural elements {/ |}.
[0117]
Further, the directional structural elements are rotated every 45 ° from 0 ° to 180 ° to perform a top-hat transformation, and DmaxThe image for which (x, y) was determined is shown in FIG.linearFIG. 7 shows an image obtained for (x, y). DlinearIn (x, y), the weighting factor for the top hat transform of each structural element is A−<A/= A\<A|It has been adjusted as follows.
[0118]
6 and 7, it can be seen that a defect image having a complicated directionality is extracted with emphasis on the background (noise).
[0119]
In this embodiment, a characteristic amount such as an integrated value of the density is obtained. First, in step S19, pixels remaining after removing unnecessary isolated points from the binarized image are determined as defect candidates. Next, in step S20, the integrated value and the minimum value (or the maximum value) of the density (gray scale value) in the defect candidate are obtained, and the degree of the defect is determined based on these values. Further, the size of the defect is obtained from the area of the binarized image determined as the defect candidate.
[0120]
In this embodiment, shading correction is not performed on the original image. When the shading correction is performed, since the shape of the defect is not evaluated at that stage, a large flow of cooling water on the steel plate is picked up and overdetection is performed. In the shading process, as described above, the portion of the signal of the large positive polarity defect becomes the opposite negative polarity signal, and the shadow portion of the positive polarity signal is detected. The integrated density value, which is a typical parameter for defect classification, is obtained by integrating the luminance of each pixel in the defect area. However, according to the shading processing, this feature amount is erroneously calculated.
[0121]
Therefore, the shading correction is not performed, and the negative and positive signals are respectively extracted by top-hat conversion from the bottom and top-hat conversion from the top using a structural element of an appropriate shape larger than the defect in the original image. Then, if an integrated value of the concentration is obtained, an appropriate value can be obtained.
[0122]
<Example 2>
Hereinafter, a second example in which the present invention is applied to the extraction of harmful defects in the surface inspection of a steel sheet in the steel field will be described.
[0123]
The flow of signal processing in the image processing apparatus will be described with reference to FIG. First, in step S21, image data is collected and input. Next, in step S22, shading correction is performed to remove luminance unevenness caused by the optical system, and in step S23, binarization processing is performed to obtain defect candidates. Then, the run length and center luminance (before binarization) of the defect candidate are obtained.
[0124]
If a defect candidate is given, the process returns to the original image, and in step S26, an image near the defect candidate is cut out. This is obtained by cutting out a pixel including a defect candidate and a pixel in a specific range around the pixel (for example, surrounding pixels in a specific number range in the x and y directions). Then, in step S28, a top-hat transformation operation using a structural element having a specific form in the above-described gray scale morphology is performed. In the present embodiment, prior to this, the structure used in step S27 is used. Elements are obtained from a table as shown in FIG. 9 using the run length and the center luminance obtained in step S25.
[0125]
That is, in the present embodiment, as shown in FIG. 9, structural elements that can be used to determine the shape of an expected defect by using the run length and the center luminance obtained in step S25 and effectively extract the defect are shown in FIG. From a simple table. As a result, the top hat transformation can be performed on the various types of defects using the optimal structural elements.
[0126]
The image obtained by the top-hat transformation in step S28 is subjected to a binarization process in step S29 to obtain a binarized image. Then, in step S30, the binarized number of remaining pixels is calculated, and in step S31, it is calculated whether the number of remaining pixels is equal to or greater than a threshold.
[0127]
If the number of remaining pixels is equal to or larger than the threshold value, it is output as a defect in step S32. Steps S26 to S32 are performed for all of the extracted defect candidates.
[0128]
The top-hat conversion may be performed over the entire original image instead of the shading correction. However, in order to increase the processing speed, in this embodiment, the top-hat conversion is performed near the defect candidate. Unlike shading correction, which requires a moving average over a wide area even when the area to be subjected to the top hat transform is narrowed in this way, if the area is sufficiently larger than the structural element, the normalization ability is not reduced.
[0129]
Further, in the present means, since the structural element is selected and applied according to the characteristics of the defect candidate, it is compared with the case where the top hat transform is performed using all the structural elements over the entire original image. , Can greatly reduce the processing time.
[0130]
<Example 3>
Hereinafter, an example in which the present invention is applied to the classification of harmful defects in the surface inspection of a steel sheet in the steel field will be described.
[0131]
For example, in the process of cold rolling, for example, normal defects are attached perpendicular to the flow direction, whereas defects caused by roll reduction tend to be attached in the flow direction of the steel sheet. Need to be identified. Thus, evaluation of morphology and texture is important in defect classification.
[0132]
The flow of this processing will be described with reference to the flowchart of FIG. First, in step S41, image data is collected and input. Next, in steps S32 to S53, a top-hat transformation is performed using a plurality of structural elements having the directionality of {/ |} and a specific scale. ̄(X, y), S/(X, y), S|(X, y), S\An image of (x, y) is obtained and binarized by an appropriate threshold to calculate and compare the number of remaining pixels.
[0133]
FIG. 11 shows an example of a structural element. The number in each structural element corresponds to the depth in the direction perpendicular to the plane of the paper. (A) is a substantially spherical structural element, which is suitable for extracting a defect having no directivity. (B) is a slightly horizontally long elliptical spherical structural element, which is suitable for detecting a vertically long defect while excluding a horizontally long defect. (C) is a vertically long truncated pyramid-shaped structural element, which is suitable for detecting a horizontally long defect while excluding a vertically long defect. In the examples, a structural element as shown in (c) was used. A structural element having a direction of | corresponds to (c), but a structural element having another direction may be inclined at a predetermined angle. FIG. 5 shows an example of an image binarized after the top hat transform using each of the structural elements {/ |}.
[0134]
In order to compare the numbers of remaining pixels and classify the types and harmfulness of defects, a maximum likelihood (maximum likelihood) determination is performed in step S54 based on Bayes' theorem. Then, the result (defect classification result) is output in step S55.
[0135]
<Example 4>
A third example in which the present invention is applied to the extraction of harmful defects in the surface inspection of a steel sheet in the steel field will be described. This is an example using a structural element pair. The flow of signal processing in the image processing apparatus will be described with reference to FIG. First, image data is input (step S61), and then the structural element g−Using (x, y), a closing operation is performed on the image data, and as a result, the operation image S−(X, y) is obtained (step S62).
[0136]
Then, the structural element g−Structural element g different in size from (x, y)+Using (x, y), a closing operation is performed on the image data, and as a result, the operation image S+(X, y) is obtained (step S63). Then, in step S64, the calculated image S−(X, y) and S+A difference image D (x, y) of (x, y) is obtained. At this time, a bias of 128 is applied to the difference image having the gray scale of 256 gradations, so that the gray scale of the difference image is close to the median (step S64).
[0137]
Next, the image signal is binarized using a fixed threshold (step 65), and unnecessary pixels are removed, and the remaining pixels are determined as defect candidates (step S66). At this time, except for the signal change of interest by the above processing, it can be used and standardized, so that binarization can be easily performed with an appropriate fixed threshold value in the same manner as in the case of an image that has undergone shading correction.
[0138]
【The invention's effect】
As described above, according to the present invention, there is provided a surface defect detection method capable of accurately detecting a defect and determining a type by processing an image signal obtained by imaging by a novel method. be able to.
[Brief description of the drawings]
FIG. 1 shows a result obtained by performing an opening operation on a one-dimensional function f (x) using a semicircular structure function g1 (x) and a result obtained by performing a closing operation using a semicircular structure function g2 (x). It is a figure showing the result of having performed.
FIG. 2 is a diagram illustrating top-hat transformation from above, taking a one-dimensional signal as an example;
FIG. 3 is a diagram illustrating an example of a structural element used for a top-hat transformation and a result of the top-hat transformation.
FIG. 4 is a flowchart illustrating a processing flow according to the first embodiment of the present invention.
FIG. 5 is a diagram showing an example of an image binarized after top-hat transformation using each of the structural elements {/ |}.
FIG. 6 is a graph showing a D obtained by rotating a structural element having directionality every 45 ° from 0 ° to 180 °, and performing a top-hat transformation, respectively.maxIt is an image showing (x, y).
FIG. 7 is a diagram showing a D obtained by rotating a structural element having directionality every 45 ° from 0 ° to 180 ° and performing a top-hat transformation, respectively.linearIt is an image which shows (x, y).
FIG. 8 is a flowchart illustrating a flow of processing according to a second embodiment of the present invention.
FIG. 9 is a diagram showing an example of a table for determining a structural element used for a top hat transform from a run length and a center luminance.
FIG. 10 is a flowchart illustrating a flow of processing according to a third embodiment of the present invention.
FIG. 11 is a diagram showing an example of a structural element.
FIG. 12 shows a large semicircular structural element g+(X) and small semicircular structural element g−FIG. 9 is a diagram illustrating a method of performing a closing operation with (x) as a pair and performing defect detection based on the difference.
FIG. 13 is a diagram showing an example of a pair of structural elements used in a two-dimensional case.
FIG. 14 is a diagram illustrating a flow of signal processing in the image processing apparatus in processing using a pair of structural elements.