JP3661635B2 - Image processing method and apparatus - Google Patents

Image processing method and apparatus Download PDF

Info

Publication number
JP3661635B2
JP3661635B2 JP2001360985A JP2001360985A JP3661635B2 JP 3661635 B2 JP3661635 B2 JP 3661635B2 JP 2001360985 A JP2001360985 A JP 2001360985A JP 2001360985 A JP2001360985 A JP 2001360985A JP 3661635 B2 JP3661635 B2 JP 3661635B2
Authority
JP
Japan
Prior art keywords
line segment
line
label
image processing
extracted
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.)
Expired - Lifetime
Application number
JP2001360985A
Other languages
Japanese (ja)
Other versions
JP2002230562A (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.)
Omron Corp
Original Assignee
Omron 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 Omron Corp filed Critical Omron Corp
Priority to JP2001360985A priority Critical patent/JP3661635B2/en
Publication of JP2002230562A publication Critical patent/JP2002230562A/en
Application granted granted Critical
Publication of JP3661635B2 publication Critical patent/JP3661635B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Images

Landscapes

  • Image Analysis (AREA)

Description

【0001】
【発明の属する技術分野】
この発明は、コンピュータにより濃淡画像データを処理する分野に属するもので、特に、輪郭に直線部分を含む物体を観測対象として、その物体の輪郭の直線部分を抽出したり、それを利用して物体の位置や向きなどを計測したり、輪郭形状に欠陥が生じていないかを検査するなどの処理を行う方法および装置に関連する。
【0002】
【従来の技術】
濃淡画像上で対象物の位置や向きを観測したり、輪郭上の欠陥を検査する上で、対象物の輪郭の直線部分を抽出したい場合がある。従来より、対象物の輪郭を抽出するときには、2値化処理による方法、濃度勾配の大きさに基づく方法、膨張画像および収縮画像を利用する方法などが用いられる。
【0003】
2値化処理による方法では、濃淡画像を所定のしきい値によって白画素領域と黒画素領域に2値化し、これらの領域の境界に位置する画素によって輪郭線を構成する。濃度勾配の大きさに基づく方法では、濃淡画像を構成する各画素における濃度勾配の大きさが所定のしきい値を超える場合にその画素を輪郭線を構成する画素とする。膨張画像および収縮画像を利用する方法では、原画像の明るい領域を拡張させた膨張画像と原画像の明るい領域を収縮させた収縮画像とを作成し、膨張画像と収縮画像との差分画像を作成することにより輪郭線を抽出する。
【0004】
【発明が解決しようとする課題】
これらいずれの方法によっても、抽出されるのは輪郭線の全体であって、輪郭線の直線部分のみを抽出することはできない。輪郭線の直線部分を抽出するためには、別途輪郭線を構成する画素の連結パターンを評価して直線とみなせる部分を特定することが考えられる。例えば、輪郭線を構成する画素に順に着目していき、これらの連結方向が一定である範囲を直線とみなすような方法である。しかし、連結方向の分解能を高めようとすると、数画素にわたる範囲での連結方向の平均をとる必要があるので、直線を中断する微小な欠陥があっても無視される傾向がある。また、輪郭線に複数画素分の線幅があるときには、直線抽出の適切なアルゴリズムを設定すること自体が困難である。
【0005】
さらに、2値化による方法、濃度勾配の大きさに基づく方法、膨張画像および収縮画像を利用する方法のいずれによっても、画像の状態(例えば画像の背景部分と対象物部分との濃度差、照明の均一さなど)の相違により輪郭線の状態(輪郭線の線幅、位置、微小な凹凸の大きさなど)が変動するのであるが、このような変動にかかわらず安定して輪郭線の直線部分を抽出することは、画素の連結パターンの評価に基づく方法では困難である。
【0006】
この発明は上記問題点に着目してなされたもので、濃淡画像において対象物の輪郭の直線部分を的確に抽出することを目的とする。
この発明の他の目的は、濃淡画像の状態にかかわらず、特に背景部分と対象物部分との濃度差が小さい場合や照明が均一でない場合でも、対象物の輪郭の直線部分を的確に抽出することである。
さらにこの発明の他の目的は、抽出した対象物の輪郭の直線部分に基づいて、対象物の位置や向きを計測したり、対象物の輪郭上の欠陥を抽出する処理を行うことである。
【0007】
【課題を解決するための手段】
この発明による濃淡画像を処理する方法は、濃淡画像に表される対象物像の輪郭に直線部分が含まれるときに、その直線の方向毎に個別のラベルを設定するラベル設定ステップと、濃淡画像に含まれるエッジ画素であってそのエッジ画素の方向が前記直線の方向のいずれかと一致するようなエッジ画素に対して、その一致した方向に対応するラベルを割り当てる画素ラベル付けステップと、同一のラベルが割り当てられた複数のエッジ画素を前記濃淡画像上で連続しているとみなし得るエッジ画素の集合毎にグループ分けし、各集合をそれぞれ独立した線分として抽出する線分抽出ステップとを順に実行するものである。
【0008】
エッジ画素とは、濃淡画像において対象物の輪郭線を構成する画素である。なお、輪郭線の線幅は1画素に限らず、複数画素分の線幅であってよい。
エッジ画素を抽出するための好ましい具体的処理として、濃度勾配の大きさが所定の値より大きい画素をエッジ画素とする処理を採用することができる。また、この処理によって抽出された画素のすべてをエッジ画素とすることに限らず、この処理に続けて細線化処理のような対象画素を絞り込む処理を実行した後に残った画素をエッジ画素とすることもできる。一方、具体的な処理過程において濃度勾配の大きさに着目しないことも可能であり、例えば2値化した画像の輪郭線に対応する画素をエッジ画素とすることができる。しかしいずれの処理によっても、結果的には濃度勾配の大きさが相対的に大きな画素が抽出される。
【0009】
エッジ画素の方向とは、通常の定義によれば、エッジ画素における濃度勾配の方向に直交する方向である。エッジ画素の方向をこのように定義するのは、あるエッジ画素が対象物像の輪郭の直線部分に含まれている場合にそのエッジ画素の方向とその直線の方向とが同じ方向として示されるようにする必要があるからである。したがって実際の処理においては、例えば直線の方向を通常の意味とは相違して直線の法線方向によって定義し、かつ、エッジ画素の方向をエッジ画素における濃度勾配の方向によって定義する場合のように、直線の方向およびエッジ画素の方向の間の関係が上記通常の定義による場合と等価になるような直線の方向およびエッジ画素の方向の定義を採用して本発明を実施することもできる。
エッジ画素の方向と直線の方向との一致は、厳密に一致する場合に限らず、方向の差が画像処理の目的に応じて設定された所定の範囲内である場合を含む。
【0010】
2つのエッジ画素が連続しているとみなすことができるのは、必ずしもそれらの画素の間に他の画素が介在していない場合に限らず、そこで採用している連続判定方法において連続しているとする判定基準を各画素が満たす状態にあればよい。着目画素に対して上下左右の4近傍やこれに斜め方向を加えた8近傍において判定対象の画素があれば画素が連続していると判定する方法が用いられることが多いが、近傍の範囲をさらに大きく設定することもできる。
【0011】
この発明によれば、輪郭線を構成するエッジ画素においては濃度勾配の大きさが相対的に大きいためにエッジ画素の方向を誤差小さく求めることができることに着目し、エッジ画素の方向に対応してエッジ画素に割り当てられたラベルが共通することおよびエッジ画素が連続していることを条件として抽出したエッジ画素の集合によって線分を表すようにしたので、対象物の輪郭の直線部分を的確に抽出することができる。また、濃淡画像の状態にかかわらず、特に背景部分と対象物部分との濃度差が小さい場合や照明が均一でない場合でも、エッジ画素の方向は安定して求めることができるので、このような場合でも対象物の輪郭の直線部分を的確に抽出することができる。
【0012】
この発明の各ステップは、濃淡画像の全体を対象として実行してもよいし、濃淡画像の一部に計測領域を設定して、計測領域についてのみ実行してもよい。
【0013】
この発明による画像処理方法の一実施態様によれば、前記ラベル設定ステップは、エッジ画素の方向毎にエッジ画素の数の度合を示すヒストグラムを作成するヒストグラム作成ステップと、そのヒストグラム上の極大値を抽出して、極大値に対応するエッジ画素の方向毎に個別のラベルを設定するピークラベル設定ステップとを実行することにより、対象物像の輪郭に含まれる直線の方向毎に個別のラベルを設定するものとすることができる。さらに、前記画素ラベル付けステップは、ピークラベル設定ステップにより設定されたラベルを各ラベルに対応するエッジ画素の方向を有するエッジ画素に割り当てることにより、前記ラベルの割当を行うものとすることができる。
【0014】
エッジ画素の方向毎のエッジ画素の数の度合としては、エッジ画素の方向毎のエッジ画素の数そのもの(いわゆる度数)を採用することができ、また、エッジ画素の数そのものに代えて、各エッジ画素における濃度勾配の大きさで重み付けした(例えば濃度勾配の大きさを乗じた)エッジ画素の数を採用することもできる。
【0015】
極大値に対応するエッジ画素の方向としては、その極大値が属するヒストグラムの区分に該当するエッジ画素の方向を採用することができ、さらに極大値が属する区分に隣接する区分も含めた複数の区分に該当するエッジ画素の方向を採用することもできる。
【0016】
この実施態様によれば、対象物の輪郭線の直線部分の方向がいずれの方向であっても、またその方向があらかじめわかっていなくても、輪郭線の直線部分を抽出することができる。
【0017】
なお、この実施態様においては、ヒストグラムの極大値を抽出する際に、その抽出のための条件を設定してもよい。たとえば大きいほうから所定の数までの極大値、所定の値よりも大きい極大値などの条件を設定することができる。
【0018】
さらに前記線分抽出ステップにおいて抽出された線分の中に線分間の方向ずれ量が所定範囲内であり、かつ、線分間の位置ずれ量が所定範囲内である線分の組があるとき、これらの線分を1本の線分に統合する線分統合ステップをさらに実行するようにしてもよい。
このようにすれば、対象物の輪郭に欠けや突出などの欠陥があるために線分が分断されている場合でも、分断された線分を統合することができるので、欠陥がある対象物についても、位置や向きを精度よく計測することが可能となる。
【0019】
また前記線分抽出ステップにおいて抽出された線分または前記線分統合ステップにおいて統合された線分の中から所定の条件を満たす線分を選択する線分選択ステップをさらに実行するようにしてもよい。このようにすれば、その画像処理の具体的目的に適合する線分を選択することができる。
線分を抽出する条件としては、線分の長さの範囲、基準方向に対する角度の範囲、位置の範囲、また、2つの線分の端点間の距離の範囲、2つの線分がなす角度の範囲、線分の長さの順位などを採用することができる。
【0020】
また前記線分選択ステップにおいて選択された線分の位置または選択された複数の線分の延長線上の交点の位置を前記濃淡画像上で識別可能に表示する表示ステップをさらに実行するようにしてもよい。このようにすれば、線分の抽出および選択の状況をユーザーに提示することができる。ユーザーはこの表示を見て、対象物の角などの意図したとおりの箇所が正しく計測対象となっているかどうかの確認をすることができる。
【0021】
この発明による画像処理方法の他の実施態様によれば、前記線分抽出ステップにおける線分の抽出状態を用いて対象物の輪郭の直線部分における欠陥の有無を判別する欠陥判別ステップをさらに実行することができる。この実施態様によれば、エッジ画素の方向が同一とみなせるようなエッジ画素の連続性に基づいて線分を抽出しているところ、輪郭の欠陥が数画素程度の大きさの微小なものであってもエッジ画素の方向は大きく変動するため、このような微小な欠陥も高い確度で検出される。
【0022】
具体的には、前記欠陥判別ステップは、前記線分抽出ステップで抽出された線分の中に線分間の方向ずれ量が所定範囲内であり、かつ、線分間の位置ずれ量が所定範囲内である線分の組があるとき、これら線分の間に欠陥が存在すると判別するものとすることができる。
また、前記欠陥判別ステップは、前記線分抽出ステップで抽出された線分の数を所定の基準値と比較し、両者の値が異なるときに対象物の輪郭の直線部分に欠陥が存在すると判別するものとしてもよい。
【0023】
つぎに、この発明による画像処理方法の他の実施態様によれば、前記ラベル設定ステップは、対象物の輪郭における直線部分の方向として想定される方向毎に個別のラベルを設定するものとし、前記画素ラベル付けステップは、そのエッジ画素の方向がそのような想定される方向のいずれかと一致するようなエッジ画素に対して、その一致した方向に対応する前記ラベルを割り当てるものとすることができる。
【0024】
対象物の向きが決まっているなど、あらかじめ輪郭の直線部分の方向が想定できるときは、そのような方向毎に個別のラベルを設定することにより、処理の対象とする濃淡画像毎に前述のヒストグラムを作成しなくてすむので、処理を高速化することが可能となる。
また、この実施態様の方法を対象物の合格判定や分類判定のために利用することもできる。すなわち、対象物の輪郭に想定される方向の直線部分があるかどうかで対象物の合格不合格や種類を判定するのである。
なお、先に説明した線分統合ステップ、線分選択ステップおよび欠陥判別ステップは、この実施態様においても採用することができる。
【0025】
この発明による濃淡画像を処理する装置は、濃淡画像を入力する手段と、前記濃淡画像に含まれるエッジ画素を抽出する手段と、前記各エッジ画素におけるエッジ画素の方向を求める手段と、前記濃淡画像に表される対象物像の輪郭の直線部分につき、その直線の方向を設定する方向設定手段と、前記方向設定手段により設定された直線の方向毎に個別のラベルを設定するラベル設定手段と、前記濃淡画像に含まれるエッジ画素であってそのエッジ画素の方向が前記直線の方向のいずれかと一致するようなエッジ画素に対して、その一致した方向に対応する前記ラベルを割り当てる画素ラベル付け手段と、同一の前記ラベルが割り当てられた複数のエッジ画素を前記濃淡画像上で連続するとみなし得るエッジ画素の集合毎にグループ分けし、各集合をそれぞれ独立した線分として抽出する線分抽出手段とを具備して成るものである。
【0026】
この発明による画像処理装置によれば、入力した濃淡画像を対象としてエッジ画素が抽出されるとともにエッジ画素の方向が求められ、一方で濃淡画像に表される対象物像の輪郭の直線部分の方向毎に個別のラベルが設定され、エッジ画素の方向が直線の方向のいずれかと一致するようなエッジ画素に対して、一致した方向に対応するラベルが割り当てられる。さらに同一のラベルが割り当てられており、かつ、濃淡画像上で連続しているとみなし得るエッジ画素の集合が線分として抽出される。このようにして、対象物の輪郭の抽出部分を的確に抽出することができる。
【0027】
濃淡画像を入力する手段は、例えば、カメラやスキャナなどの画像生成手段に接続され、これらの手段より生成された濃淡画像を取り込む手段であって、インターフェイス回路、A/D変換回路などにより構成される。ただし画像を入力するための構成は、これに限らず、通信により伝送された画像を受け付ける回路、所定の記録媒体に保存された画像を読み出す読取り装置などによって構成することも可能である。
【0028】
エッジ画素を抽出する手段から線分抽出手段にいたる各手段および後述の付加的またはより具体化された各手段は、コンピュータのハードウェアとそこで動作するソフトウェアとして実現することができるし、それぞれのまたはいくつかの手段をASIC(Application Specific Integrated Circuit)などの回路ブロックで実現し、各回路ブロックの連携動作をコンピュータで制御することにより実現することもできる。
【0029】
エッジ画素を抽出する手段およびエッジ画素の方向を求める手段としては、ソーベルフィルタなどのエッジ抽出フィルタを使用することができる。エッジ画素を抽出する手段としては、これに限らず、コンピュータの画像メモリ上で先に説明した種々の輪郭抽出方法を実行してもよい。
【0030】
この発明による画像処理装置の一実施態様によれば、前記方向設定手段は、エッジ画素の方向毎にエッジ画素の数の度合を示すヒストグラムを作成するヒストグラム作成手段と、そのヒストグラム上の極大値を抽出して、極大値に対応するエッジ画素の方向を直線の方向として設定するピーク方向設定手段とを含むものとすることができる。また前記ラベル設定手段は、ピーク方向設定手段により設定された方向毎に個別のラベルを設定するものとし、前記画素ラベル付け手段は、前記ラベル設定手段により設定されたラベルを各ラベルに対応するエッジ画素の方向を有するエッジ画素に割り当てるものとすることができる。
【0031】
この実施態様において、前記線分抽出手段によって抽出された線分の中に線分間の方向ずれ量が所定範囲内であり、かつ、線分間の位置ずれ量が所定範囲内である線分の組があるとき、これらの線分を1本の線分に統合する線分統合手段をさらに具備してもよい。
【0032】
また、前記線分抽出手段によって抽出された線分または前記線分統合手段によって統合された線分の中から所定の条件を満たす線分を選択する線分選択手段とをさらに具備してもよい。この線分を選択するための所定の条件は、これを入力するための入力手段をさらに設けて外部から入力してもよいし、これを予め記憶しておくための記憶手段をさらに設けてこの記憶手段から与えてもよい。
また、前記線分選択手段によって選択された線分の位置または選択された複数の線分の延長線上の交点の位置を前記濃淡画像上で識別可能に表示するための表示制御手段をさらに具備してもよい。
【0033】
この発明による画像処理装置の他の実施態様によれば、前記線分抽出手段によって抽出された線分の抽出状態を用いて対象物の輪郭の直線部分における欠陥の有無を判別する欠陥判別手段をさらに具備するものとすることができる。
具体的には、前記欠陥判別手段は、前記線分抽出手段によって抽出された線分の中に線分間の方向ずれ量が所定範囲内であり、かつ、線分間の位置ずれ量が所定範囲内である線分の組があるとき、これら線分の間に欠陥が存在すると判別するものとすることができる。
また、前記欠陥判別手段は、前記線分抽出手段によって抽出された線分の数を所定の基準値と比較し、両者の値が異なるときに対象物の輪郭の直線部分に欠陥が存在すると判別するものとすることができる。
【0034】
この発明による画像処理装置の他の実施態様によれば、前記方向設定手段は、対象物の輪郭における直線部分の想定される方向を入力するものとし、前記ラベル設定手段は、方向設定手段によって入力された方向毎に個別のラベルを設定するものとし、前記画素ラベル付け手段は、そのエッジ画素の方向が方向設定手段によって入力された方向のいずれかと一致するようなエッジ画素に対して、その一致した方向に対応するラベルを割り当てるものとすることができる。
さらに、先に説明した線分統合手段、線分選択手段および欠陥判別手段は、この実施態様においても採用することができる。
【0035】
【発明の実施の形態】
図1は、この発明の一実施例にかかる画像処理装置の構成を示す。
この画像処理装置1は、ディジタル濃淡画像上において、対象物の輪郭の直線部分やその直線部分が複数あるときのそれらの延長上の交点を抽出するためのもので、画像入力部2,画像メモリ3,画像出力部4,タイミング制御部5,キャラクタ・グラフィックメモリ6,文字メモリ7,制御部8,モニタ9,I/Oポート10などにより構成される。
【0036】
画像入力部2は、図示しないアナログカメラからの濃淡画像信号を取り込むためのインターフェイス回路,前記濃淡画像信号をディジタル変換するためのA/D変換回路,ノイズカット用のフィルタ回路などにより構成される。なお前記カメラはアナログカメラに限らず、ディジタルカメラを用いてもよい。
【0037】
前記画像メモリ3は、画像入力部2により取り込まれ、A/D変換されたディジタル量の濃淡画像データ(以下単に、「画像」という。)を取り込んで保存する。キャラクタ・グラフィックメモリ6には、後記するエッジコードヒストグラム、処理結果画像、線分の抽出条件の設定画面などを表示するのに必要な画像データが格納される。
文字メモリ7には、検査結果などの文字情報を表示するためのテキストデータやその表示位置などが格納される。これらメモリ3,6,7は、それぞれアドレス/データバス11を介して制御部8に接続され、制御部8からの指示に応じたデータを、タイミング制御部5からのタイミング信号に応じて画像出力部4またはアドレス/データバス11に出力する。
【0038】
前記制御部8は、CPU12,ROM13,RAM14を主体とし、このほかに検査のための処理手順を示す制御プログラムがインストールされたハードディスク15を具備する。CPU12は、ハードディスク15内の制御プログラムに基づき、アドレス/データバス11を介して各メモリに対する情報の読書きを行いつつ目的とする計測処理を実行する。
【0039】
前記画像出力部4は、モニタ9に対し、計測対象の物体の画像のほか、前記ヒストグラム,処理結果画像,ならびに検査結果を示す文字情報などを単独または合成した状態で与え、画面上に表示させる。I/Oポート10は、キーボード,マウスなどの入力部や、外部記憶装置,伝送部のような出力部に接続され、入力部からの各種設定データを入力したり、検査結果を外部に出力する際に用いられる。
【0040】
この実施例の画像処理装置1では、入力された画像上に計測対象の物体を含むような計測領域を設定するとともに、計測対象の物体の輪郭を構成する線分を抽出するための条件として、前記線分の特徴を示すデータの入力をI/Oポート10から受け付けるようにしている。なお、計測領域は、あらかじめ設定された条件に基づいて設定されるが、これに限らず、画像を入力する都度、ユーザーの設定操作に応じて任意の位置に任意の大きさの計測領域を設けてもよい。また入力画像全体を計測領域としてもよい。
【0041】
図2は、画像処理装置1における一連の計測処理の流れ(ST1〜10)を示す。以下、図3〜14を順に参照しながら、図2の流れに沿って、計測処理の詳細を説明する。
【0042】
まずST1では、前記計測領域内のエッジ画素を抽出する。
このエッジ画素の抽出処理では、画像上に図3に示すような3×3マスクを走査しつつ、走査位置毎に、マスク内の各画素の濃度値Iをつぎの(1)〜(3)式にあてはめることにより、中央の画素g(座標位置(x,y)にある画素)について、x,yの各軸方向毎の濃度勾配Ex(x,y),Ey(x、y)、およびその濃度勾配の大きさ(以下「エッジ強度」という。)Ei(x,y)を算出する。このエッジ強度Ei(x,y)が所定値を越えるとき、着目画素gはエッジ画素として認定される。
【0043】
【数1】

Figure 0003661635
【0044】
【数2】
Figure 0003661635
【0045】
【数3】
Figure 0003661635
【0046】
また、高速演算に適した簡易な方式とするときは、(3)式は次の(4)式によって代用することができる。
Ei(x,y)=Ex(x,y)+Ey(x,y) ・・・(4)
【0047】
なおこの実施例では、後記するように、ソフトウェア処理によりマスクを走査してエッジ画素の抽出処理を行っているが、これに限らず、専用の微分回路により画像メモリ3への画像入力と並行させてエッジ画素の抽出処理を行い、その結果を用いて以下の処理を行うようにしてもよい。
【0048】
前記濃度勾配Ex(x,y),Ey(x,y)は、着目画素gにおける濃度の変化量をx,yの各軸方向毎に示したものである。エッジ強度Ei(x,y)は、これら濃度勾配Ex(x,y),Ey(x,y)の示すベクトルの合成ベクトルの長さに相当するもので、前述のようにこのエッジ強度Ei(x,y)が所定値を越えるとき、着目画素gはエッジ画素として認定される。
またこの合成ベクトルの示す方向によって、着目画素gにおいて濃度が変化する方向(すなわち濃度勾配の方向)が示されることになる。
【0049】
つぎのST2では、ST1で抽出された各エッジ画素につき、順に、エッジ画素の方向を表す角度(以下、この角度を示す数値データを「エッジコード」という。)を求めるとともに、計測領域内のエッジ画素の数をエッジコードの値毎に計数したヒストグラム(以下、このヒストグラムを「エッジコードヒストグラム」という。)を作成する。
【0050】
図4は、対象物の輪郭部分の一部を拡大してエッジコードの表し方を示したものである。
図中、Eは、前記(1)〜(3)式により抽出されたエッジ画素である。この実施例では、濃度の高い方から低い方へと向かうベクトルFをエッジ画素Eにおける濃度勾配の方向とし、このベクトルFに直交するベクトルCを、エッジコードによって表される方向としている。なお、図示例は、対象物の濃度が背景よりも小さい場合(すなわち対象物が背景よりも暗い場合)の例であり、対象物と背景との濃度の関係が逆になる場合は、ベクトルF,Cの向きは反転する。
【0051】
この実施例では、エッジ画素Eからx軸の正方向に向かうベクトルBを基準として、ベクトルCをベクトルBから反時計回り方向に見たときの角度Ec(x,y)を、前記エッジコードとしている。
【0052】
前記ベクトルFは、前記(1)(2)式により得た濃度勾配Ex(x,y),Ey(x,y)の合成ベクトルであり、ベクトルCはベクトルFに直交するベクトルであるから、エッジコードEc(x,y)は、濃度勾配Ex(x,y),Ey(x,y)の値に応じて下記▲1▼〜▲5▼のいずれかの式によって求められる。
【0053】
▲1▼ Ex(x,y)>0 および Ey(x,y)≧0のとき、
Ec(x,y)=atan(Ey(x,y)/Ex(x,y))
▲2▼ Ex(x,y)>0 および Ey(x,y)<0のとき、
Ec(x,y)=360+atan(Ey(x,y)/Ex(x,y))
▲3▼ Ex(x,y)<0のとき、
Ec(x,y)=180+atan(Ey(x,y)/Ex(x,y))
▲4▼ Ex(x,y)=0 および Ey(x,y)>0のとき、
Ec(x,y)=0
▲5▼ Ex(x,y)=0 および Ey(x,y)<0のとき、
Ec(x,y)=180
【0054】
前記エッジコードヒストグラムを作成するには、計測領域内の各エッジ画素につき、前記▲1▼〜▲5▼を用いてエッジコードEc(x,y)を算出しつつ、算出されたエッジコードEc(x,y)の値に対応する度数を1ずつ加算するか、または着目中のエッジ画素のエッジ強度Ei(x,y)による重みを付けた度数を加算する。
なお、この実施例では、前記エッジコードヒストグラム上の角度を1度単位で設定するようにしている。さらにすべてのエッジ画素についてのエッジコードの算出と度数加算処理とが終了した時点で、ノイズ除去のためにヒストグラムの平滑化処理を実施している。
【0055】
またこの実施例では、計測領域内のエッジ画素を抽出し終えてからエッジコードヒストグラムの作成を行っているが、これに限らず、計測領域内を順にサーチして、エッジ画素を抽出する毎に、エッジコードの算出および度数加算処理を続けて行うようにしてもよい。
【0056】
画像上において、線分を構成する各エッジ画素のエッジコードは、すべて前記線分の傾きに相当する値をとるはずである。したがって計測領域内に線分が存在する場合には、前記エッジコードヒストグラムでは、線分の傾きに対応する角度付近にピークが出現する。また計測領域内に傾きの異なる複数の線分が存在する場合には、エッジコードヒストグラム上の各線分の傾きに対応する角度位置に、それぞれピークが現れる。
【0057】
図5(1)は、処理対象の濃淡画像を示す。同図において、16は対象物の画像であり、背景よりも濃度が低く、直交する4方向に分類可能な線分を組み合わせた十字型の輪郭形状を具備している。
図5(2)は、前記図5(1)の対象物について作成されたエッジコードヒストグラムを示すもので、前記輪郭形状の4方向に相当する4つのピークP1〜P4が現れている。
【0058】
ST3では、このヒストグラム上で前記ピークに対応する角度を抽出する。 ピークを抽出するには、たとえば前記エッジコードヒストグラムの角度毎の度数を、角度の小さい方から順に比較して(ただしエッジコードが359度のときの度数は0度のときの度数と比較する。)、所定大きさ以上の山状の度数変化を抽出し、このピークに対応する角度を決定する。
【0059】
こうしてピークに対応する角度が求められると、つぎのST4では、これらピークに対応する角度(以下、「ピーク角度」という。)にそれぞれ個別のラベルを設定する。さらに続くST5では、前記計測領域において、各ピーク角度に対応するエッジコードを有するエッジ画素に、それぞれ対応するピーク角度に設定されたラベルを割り当てる。なお、いずれかのピーク角度に対応するラベルが割り当てられなかったエッジ画素やエッジ画素ではない画素には、処理対象のデータではないことを示すラベル(たとえば"null")が割り当てられる。
【0060】
またST5では、ピーク角度だけでなく、ピーク角度を中心として、前記山状の度数分布の範囲に相当する角度範囲内(例えば、ヒストグラムの高さが所定の値を超える部分に対応する角度範囲内やピーク角度を中心としてその前後所定の角度範囲内など)に対応するエッジコードを有するエッジ画素に、前記ピーク角度に設定されたラベルを割り当てるのが好ましい。
図5(2)では、前記各ピークP1〜P4について、それぞれピークP1〜P4を中心とする比較的高い度数が得られる角度範囲を抽出し、これら角度範囲に含まれる各角度に、ラベルθ1〜θ4を対応づけている。
【0061】
図6(1)は、前記図5(1)の画像のエッジ画素抽出結果に前記ラベルθ1〜θ4を割り当てた例を示す。
図示例によれば、線分を構成するエッジ画素のエッジコードは、エッジコードヒストグラムの前記ピークP1〜P4のいずれかに対応するから、各線分には、θ1〜θ4のいずれかのラベルが対応づけられることになる。
【0062】
図6(1)の状態では、画像上に同一のエッジコードに対応する線分が複数存在すると、これらの線分には同じラベルが割り当てられる。すなわちST5のラベリング処理のみでは、画像上の各線分を完全に切り分けることはできない。
そこでつぎのST6では、独立した線分毎に個別のラベルが付与されるように、ラベルの付け直しを行う。(以下、ST5の処理を「仮ラベリング処理」と呼び、ST6の処理を「本ラベリング処理」と呼ぶ。)
【0063】
本ラベリング処理では、ST5の仮ラベリング処理により割り当てられた同じラベルを有し、かつ、連続するエッジ画素の集合を抽出し、こうして抽出したエッジ画素の集合毎に個別のラベルを割り当て直す。
【0064】
図6(2)は、前記図6(1)の仮ラベリング処理の結果に本ラベリング処理を行った結果を示すもので、前記ラベルθ1が割り当てられた3つの線分は、それぞれθ11,θ12,θ13の各ラベルにより切り分けられている。同様に、前記ラベルθ2が割り当てられた3つの線分には、θ21,θ22,θ23の各ラベルが、前記ラベルθ3が割り当てられた3つの線分には、θ31,θ32,θ33の各ラベルが、前記ラベルθ4が割り当てられた3つの線分には、θ41,θ42,θ43の各ラベルが、それぞれ割り当てられて、各線分が切り分けられている。
【0065】
このような2段階のラベリング処理により、各線分をラベル毎に切り分けて認識することが可能となる。ST7では、この状態下において、ラベル毎に、それぞれそのラベルが付与されたエッジ画素の集合(以下これを「ラベル集合」という。)を用いて、つぎのA〜Fに示す演算を実行することにより、各線分の特徴量を算出する。
なお、A,BにおけるΣ演算は、いずれも1つのラベル集合に含まれる各エッジ画素についての算出結果の総和を求めることを意味するもので、また(xn,yn)はラベル集合内の1つのエッジ画素の座標を示し、Ei(xn,yn)、Ec(xn,yn)はそれぞれ座標(xn,yn)に位置するエッジ画素についてのエッジ強度、エッジコードを示す。
【0066】
A. 濃淡重心:GX,GY
ラベル集合の示す線分の重心位置の座標を算出するもので、ラベル集合内の各エッジ画素のエッジ強度Ei(xn,yn)を重みとしたつぎの(a)−1,(a)−2の各式により求められる。
GX=Σ{Ei(xn,yn)・xn}/{Ei(xn,yn)}・・・(a)−1
GY=Σ{Ei(xn,yn)・yn}/{Ei(xn,yn)}・・・(a)−2
【0067】
B. 方向和:SCX,SCY
ラベル集合に属する各エッジのエッジコードをx軸,y軸の各軸方向の成分に分解した値の総和であって、つぎの(b)−1,(b)−2の各式により求められる。
SCX=Σcos{Ec(xn,yn)} ・・・(b)−1
SCY=Σsin{Ec(xn,yn)} ・・・(b)−2
【0068】
C. 方向平均:EC
ラベル集合の示す線分の傾きに相当する特徴量であって、前記方向和SCX,SCYの大小関係に基づき、つぎの(c)−1〜(c)−5式のいずれかにより求められる。
SCX>0 かつ SCY≧0のとき
EC=atan(SCY/SCX) ・・・(c)−1
SCX>0 かつ SCY<0のとき
EC=360+atan(SCY/SCX) ・・・(c)−2
SCX<0のとき
EC=180+atan(SCY/SCX) ・・・(c)−3
SCX=0 かつ SCY>0のとき
EC=0 ・・・(c)−4
SCX=0 かつ SCY<0のとき
EC=180 ・・・(c)−5
【0069】
D. 直線の方程式
ラベル集合の示す線分を通る直線P(図7に示す。)を示すもので、前記方向和SCX,SCY,および濃淡重心GX,GYを用いて、つぎの(d)式により表される。
SCY・x+SCX・y−(SCY・GX+SCX・GY)=0・・・(d)
【0070】
E. 端点座標:(x1,y1)(x2,y2)
前記線分の各端点の座標であるが、この実施例では、計測処理のばらつきを考慮して前記直線P上に位置する端点の座標を求めるために、つぎのような演算を実行している。
まず処理対象のエッジ集合のx座標、y座標の中から、それぞれ最大値xmax,ymax,および最小値xmin,yminを抽出し、これらの座標により線分の仮端点の座標(x1´,y1´)(x2´,y2´)を設定する。
なお、各仮端点のx座標は、 x1´=xmin ,x2´=xmaxとなり、
y座標は、SCY・SCX≧0のときは
y1´=ymin y2´=ymax
SCY・SCX<0のときは
y1´=ymax y2´=yminとなる。
【0071】
このようにして仮端点(x1´,y1´),(x2´,y2´)を求めると、これらの座標と前記(d)の直線の方程式とを用いて、各仮端点から直線に下ろした垂線の足の座標を求め、その座標を端点の座標(x1,y1)(x2,y2)とする。
【0072】
F. 線分の長さL
前記線分の端点間の距離に相当するもので、各端点の座標を距離の算出式にあてはめることにより求められる。
【0073】
図7は、上記A〜Fの処理により求められる特徴量のうち、前記濃淡重心(GX,GY),線分を通る直線P,線分の長さL,線分の端点(x1,y1)(x2,y2)を示す。つぎのST8,9では、これらの特徴量や直線の式を用いた演算処理を実行する。
【0074】
ST8では、前記線分毎の特徴量を用いて、1本の線分として統合可能な線分の組があるか否かを判別する。そして統合が可能な線分の組が見つかると、これら線分を構成するエッジ画素をひとまとめにした新たなラベル集合を形成し、その集合に新しいラベルを設定する。さらにこの新しいラベル集合についても、前記A〜Fに示した各特徴量や直線の式が求められる。
なお、統合前の各ラベル集合およびその特徴量も、消去されずに維持される。
【0075】
図8は、前記線分の統合が可能か否かを判別するための具体的な手順を示し、図9は、この判別処理に用いられるパラメータの概念を示す。
なお、図9中、A,Bは着目中の線分、P1,P2は、これら線分A,Bを通る直線、Cは線分A,Bを統合した場合の統合後の線分である。この図示例では、パラメータをわかりやすく示すために、各線分A,Bの傾きの差や線分間の位置ずれ量を大きく示している。
【0076】
図8の手順は、計測領域内のすべての線分の組合せ(ここでは、2本の線分による組合せをいう。)に対して実行される。
まずST8−1では、着目中の線分A,Bについて、傾き(前記した方向平均EC)の差δを求め、このδが所定のしきい値以下であるか否かを判定する。
【0077】
つぎのST8−2では、各線分A,Bの向かい合う端点(図9の点a2,b1)間の距離dを算出し、これが所定のしきい値以下であるか否かを判定する。
【0078】
ST8−3では、統合後の線分Cの長さL3を求め、この長さが各線分A,Bの長さの和(L1+L2)以上であるか否かを判定する。なお統合後の線分の長さL3は、各線分A,Bの向かい合わない端点(図9の端点a1とb2)間の距離として算出される。
【0079】
ST8−4では、線分間の位置ずれ量を求め、この位置ずれ量が所定のしきい値以下であるか否かを判定する。なおこの位置ずれ量は、前記向かい合う端点間のずれ量として表されるもので、この実施例では、一方の線分(図示例では線分B)を通る直線(図示例ではP2)に対し、他方の線分(図示例では線分A)の線分B側の端点a1から下した垂線の長さhと定義している。
【0080】
上記ST8−1〜8−4の判定処理が順に行われて、いずれの判定結果も「YES」となると、ST8−5に進み、前記線分A,Bの統合が可能であると判定する。他方、ST8−1〜8−4のいずれかの判定処理で「NO」の判定がなされた場合は、ST8−6に進み、前記A、Bの統合は不可能であると判定する。
【0081】
なお各判定処理に用いるしきい値のうち、端点間の距離dに対するしきい値は、比較的大きな値に設定してよいが、方向平均の差δならびに線分間の位置ずれ量hに対するしきい値は、極力小さな値にするのが望ましい。
方向平均の差δおよび線分間の位置ずれ量hに対するしきい値を小さな値にすべきであるのは、対象物の輪郭の一つの直線部分が分断されて複数の線分が生じた場合には、これらの線分間の傾きの差や線分間の位置ずれ量は小さくなるはずであるからである。これに対し、対象物の輪郭の一つの直線部分が大きな欠陥により分断されることにより複数の線分が抽出されると、各線分の向かい合う端点間の距離dの値は大きくなることがあるから、端点間の距離dに対する許容値はある程度大きくすることができる。
【0082】
図10は、前記線分が統合されるケースと統合されないケースとの違いを例示したもので、図中の(1)(2)では、いずれも傾きに差のない2つの線分A,Bを示している。図10(1)では、各線分A,Bの向かい合う端点a,b間の距離dは大きいが、線分A,B間の位置ずれ量hは線分の幅範囲内であるから、各線分A,Bは統合可能と判断される。
これに対し、図10(2)の例では、端点a,b間の距離dは図10(1)よりも小さいが、位置ずれ量hは線分の幅範囲を越えており、各線分A,Bの統合は不可能と判断される。
【0083】
前記した直線の統合処理によれば、図11に示すように、統合可能な線分の組が複数組ある場合(図示例では直線AとB,直線BとDとの2組)には、各組毎に統合処理を行って新たな線分C,Eを設定した後、さらにこれらの線分C,Eを統合して、各線分を1本の線分Fに統合することも可能となる。
なお統合された線分C,E,Fには、それぞれ個別のラベルが設定され、統合前の各線分A,B,Dのラベルもそのまま維持するのが望ましい。
【0084】
図2に戻って、上記のようにして計測領域内に存在する各線分を個別に抽出し、統合可能な線分を統合する処理が完了すると、ST9では、これら線分の中から抽出条件を満たす線分を抽出する。
前記抽出条件は、線分の長さ、傾きなど、1本の線分を抽出するための条件としてもよいが、対象物の位置や方向を計測するためには、複数本の線分を抽出するための条件を設定するのが望ましい。
【0085】
図12は、前記直線の抽出条件として、対象物の輪郭の隣り合う2辺を構成する線分を抽出するように設定されている場合の抽出方法を示す。この場合も前記統合処理と同様に、計測領域内の線分の組を順に検索し、各組毎に、処理対象の線分A,Bの長さL1,L2が対象物の大きさに応じた長さであるかどうかを判定する。また抽出条件として、各線分のなす角度が指定されている場合は、各線分A,Bを通る直線P1,P2の方程式から、各直線のなす角αを求め、このαを抽出条件と比較する。
【0086】
図13は、前記抽出条件として、平行な線分の組を抽出することが設定された場合の線分の抽出方法を示す。この場合の具体的な抽出処理では、計測領域内の各線分の組合せ毎に線分間の傾きの差をとり、この差がゼロに近い値をとる組合せを抽出する。さらに線分間の距離も抽出条件に含まれている場合は、平行と認定された線分A,Bを通る直線P1,P2の方程式から線分間の距離を求め、これを条件と比較する。また図12の例と同様に、各線分の長さを抽出条件とすることもできる。
なおこの図13の方法において、抽出すべき線分間の距離をきわめて小さく設定すれば、パッケージ上に生じた直線キズのような微小な幅の対象物を抽出することができる。
【0087】
図14は、前記抽出条件として、所定大きさの長方形を構成する線分を抽出することが設定された場合の線分の抽出方法を示す。この場合は、まず図14(1)に示すように、長方形の向かい合う辺に相当する2組の平行な線分(図示例では線分AとB、線分CとD)を抽出する。なお、各線分の組の抽出は、前記図13と同様の方法により行われるもので、図中のE,F,Gは、平行な線分としての条件にあてはまらなかった線分である。
さらに抽出された各組間での線分の傾き(方向平均)の差が90度に近似していることを確認した上で、図14(2)に示すように、各線分の重心g1〜g4(前記濃淡重心の座標(GX,GY)を用いる。)を結ぶ領域rおよび平行な線分の組毎の重心を結ぶ直線m1,m2を設定する。このとき各直線m1,m2の交点Mが領域r内にあれば、各線分θ1〜θ4が長方形を構成する線分であると判定する。
【0088】
このようにして抽出条件に適合する線分が見つかると、ST10では、抽出された線分をたとえば所定の色彩または輝度で識別する処理結果画像を生成する。生成された処理結果画像は、前記モニタ9に与えられて表示される。
なお前記図12に示すように、抽出された各線分を通る直線の方程式から、線分または直線の交点(cx,cy)を求めると、この交点位置を所定のマークで示すような処理結果画像を生成して表示することもできる。
【0089】
上記実施例によれば、濃淡画像上のエッジ画素を用いた計測を行うので、照明の変動などにより画像の明るさが変化しても、計測結果に狂いが生じにくく、安定した計測を行うことができる。また対象物の大きさや方向が変化する可能性がある場合は、線分の長さや傾きについての抽出条件を緩やかに設定したり、他の抽出条件を設定することにより、目的とする線分を抽出できるので、精度が高い計測処理を簡単かつ高速に行うことができる。
【0090】
なお、この実施例では、計測領域から対象物の輪郭線を構成する線分を抽出して、その抽出結果を表示するにとどめているが、これに限らず、抽出結果を用いて対象物の位置や向きを計測するようにしてもよい。
たとえば、前記図14のような長方形状の輪郭を具備する対象物を計測対象とする場合、抽出された各線分A〜Dを通る直線の方程式を用いて対象物に対応する画像領域を特定した後にその領域内の重心位置を求め、その値を対象物の位置として特定することができる。また対象物の向きは、いずれか一方の線分の組(例えば長い方の線分A,B)の傾きによって表すことができる。
【0091】
さらに前記図8,9に示した線分の統合判定処理によれば、欠陥により分断された輪郭線を統合の対象として抽出できるから、前記統合判定処理を輪郭上に生じた欠陥を抽出する用途に適用することも可能である。
また単に欠陥の有無を判別するだけでよい場合は、あらかじめ良品モデルによる計測を行って、計測領域内での線分の適正な抽出数を求めておき、検査対象の画像により得られた線分の抽出数が前記適正な抽出数になるか否かをチェックすればよい。
【0092】
なお、上記の実施例では、対象物が回転ずれする場合を想定してエッジコードヒストグラムを作成し、線分に相当するピークを抽出しているが、対象物を位置ずれのない安定した状態下で撮像できるのであれば、あらかじめ濃淡画像上における対象物の輪郭の向きをI/Oポート10から入力しておくことにより、対象物の輪郭の向きに対応する方向をエッジコードとするエッジ画素にラベル付を行って、前記輪郭の向きに対応する線分を抽出することができる。またエッジコードヒストグラムを作成した上での計測処理と、エッジコードヒストグラムの作成を行わない計測処理とを適宜切り替えられるように構成しても良い。
【0093】
【発明の効果】
この発明によれば、輪郭線を構成するエッジ画素においては濃度勾配の大きさが相対的に大きいためにエッジ画素の方向を誤差小さく求めることができることに着目し、エッジ画素の方向に対応してエッジ画素に割り当てられたラベルが共通することおよびエッジ画素が連続していることを条件として抽出したエッジ画素の集合によって線分を表すようにしたので、対象物の輪郭の直線部分を的確に抽出することができる。また、濃淡画像の状態にかかわらず、特に背景部分と対象物部分との濃度差が小さい場合や照明が均一でない場合でも、エッジ画素の方向は安定して求めることができるので、このような場合でも対象物の輪郭の直線部分を的確に抽出することができる。
【図面の簡単な説明】
【図1】この発明の一実施例にかかる画像処理装置の構成を示すブロック図である。
【図2】画像処理の手順を示すフローチャートである。
【図3】エッジ抽出処理に用いるマスクを示す説明図である。
【図4】エッジコードの表し方を示す説明図である。
【図5】対象物の濃淡画像およびこの画像のエッジ抽出結果を処理して得たエッジコードヒストグラムを示す説明図である。
【図6】図5の画像についての仮ラベリング処理および本ラベリング処理の結果を示す説明図である。
【図7】線分の特徴量の概念を示す説明図である。
【図8】線分の統合判定に関する処理手順を示すフローチャートである。
【図9】線分の統合判定に用いるパラメータを説明する図である。
【図10】線分の統合が可能と判定された例および不可能と判定された例を示す説明図である。
【図11】複数の線分を統合した例を示す説明図である。
【図12】線分の抽出処理の具体例を示す説明図である。
【図13】線分の抽出処理の具体例を示す説明図である。
【図14】線分の抽出処理の具体例を示す説明図である。
【符号の説明】
1 画像処理装置
2 画像入力部
4 画像出力部
7 制御部
9 モニタ
11 CPU[0001]
BACKGROUND OF THE INVENTION
The present invention belongs to the field of processing grayscale image data by a computer. In particular, an object including a straight line portion in the contour is observed, and a straight line portion of the contour of the object is extracted, or an object using the object is extracted. The present invention relates to a method and an apparatus for performing processing such as measuring the position and orientation of the image and inspecting whether there is a defect in the contour shape.
[0002]
[Prior art]
When observing the position and orientation of an object on a grayscale image or inspecting a defect on the outline, there are cases where it is desired to extract a straight line portion of the outline of the object. Conventionally, when extracting the contour of an object, a method using a binarization process, a method based on the magnitude of a density gradient, a method using an expanded image and a contracted image, and the like are used.
[0003]
In the binarization method, a grayscale image is binarized into a white pixel area and a black pixel area with a predetermined threshold, and a contour line is formed by pixels located at the boundary between these areas. In the method based on the magnitude of the density gradient, when the magnitude of the density gradient in each pixel constituting the grayscale image exceeds a predetermined threshold value, that pixel is used as a pixel constituting the contour line. In the method using the dilated image and the deflated image, a dilated image in which the bright area of the original image is expanded and a deflated image in which the bright area of the original image is deflated are created, and a difference image between the dilated image and the deflated image is created. By doing so, the contour line is extracted.
[0004]
[Problems to be solved by the invention]
In any of these methods, the entire contour line is extracted, and only the straight line portion of the contour line cannot be extracted. In order to extract a straight line portion of the contour line, it is conceivable to separately evaluate a connection pattern of pixels constituting the contour line and specify a portion that can be regarded as a straight line. For example, this is a method in which attention is paid to the pixels constituting the contour line in order, and a range in which the connecting direction is constant is regarded as a straight line. However, in order to increase the resolution in the connecting direction, it is necessary to take an average of the connecting direction over a range of several pixels. Therefore, even if there is a minute defect that interrupts the straight line, there is a tendency to be ignored. Further, when the outline has a line width corresponding to a plurality of pixels, it is difficult to set an appropriate algorithm for line extraction.
[0005]
Furthermore, the state of the image (for example, the density difference between the background portion of the image and the object portion, illumination, etc.) can be obtained by any of the binarization method, the method based on the magnitude of the density gradient, and the method using the dilation image and the contraction image. The contour state (contour line width, position, minute unevenness size, etc.) fluctuates due to the difference in uniformity, etc., but the contour straight line is stable regardless of such fluctuations. It is difficult to extract a portion by a method based on evaluation of a pixel connection pattern.
[0006]
The present invention has been made paying attention to the above problems, and an object thereof is to accurately extract a straight line portion of the contour of an object in a grayscale image.
Another object of the present invention is to accurately extract a straight line portion of the contour of an object, particularly when the density difference between the background portion and the object portion is small or the illumination is not uniform, regardless of the state of the grayscale image. That is.
Still another object of the present invention is to perform processing for measuring the position and orientation of an object or extracting a defect on the outline of an object based on a straight line portion of the extracted object outline.
[0007]
[Means for Solving the Problems]
  The method for processing a grayscale image according to the present invention includes a label setting step for setting individual labels for each direction of a straight line when the outline of an object image represented in the grayscale image includes a straight line portion; The same label as the pixel labeling step of assigning a label corresponding to the matching direction to the edge pixel whose edge pixel matches one of the directions of the straight line ButA plurality of assigned edge pixels;Edge pixels that can be considered continuous on a grayscale imageGroup by set, and each set as an independent line segmentThe line segment extraction steps to be extracted are sequentially executed.
[0008]
An edge pixel is a pixel that forms an outline of an object in a grayscale image. The line width of the contour line is not limited to one pixel, and may be a line width for a plurality of pixels.
As a preferable specific process for extracting an edge pixel, a process in which a pixel whose density gradient is larger than a predetermined value is used as an edge pixel can be employed. Moreover, not only all the pixels extracted by this process are used as edge pixels, but the pixels remaining after executing the process of narrowing down the target pixels such as the thinning process subsequent to this process are used as edge pixels. You can also. On the other hand, it is possible not to pay attention to the magnitude of the density gradient in a specific processing process, and for example, a pixel corresponding to a binarized image outline can be set as an edge pixel. However, in any processing, as a result, pixels having a relatively large density gradient are extracted.
[0009]
The direction of the edge pixel is a direction orthogonal to the direction of the density gradient in the edge pixel according to a normal definition. The direction of the edge pixel is defined in this manner so that when a certain edge pixel is included in the straight line portion of the contour of the object image, the direction of the edge pixel and the direction of the straight line are indicated as the same direction. It is necessary to make it. Therefore, in actual processing, for example, the direction of the straight line is defined by the normal direction of the straight line, which is different from the normal meaning, and the direction of the edge pixel is defined by the direction of the density gradient in the edge pixel. The present invention can also be implemented by adopting the definition of the direction of the straight line and the direction of the edge pixel so that the relationship between the direction of the straight line and the direction of the edge pixel is equivalent to the case of the above-mentioned normal definition.
The coincidence between the direction of the edge pixel and the direction of the straight line is not limited to the exact coincidence, but includes a case where the difference in the direction is within a predetermined range set according to the purpose of the image processing.
[0010]
Two edge pixels can be considered to be continuous not only when there are no other pixels between them, but they are continuous in the continuous determination method adopted there. It suffices if each pixel satisfies the determination criterion. In many cases, a method of determining that a pixel is continuous is used if there are pixels to be determined in four neighborhoods of up, down, left, and right with respect to the pixel of interest and eight neighborhoods obtained by adding an oblique direction thereto. It can also be set larger.
[0011]
According to the present invention, attention is paid to the fact that the edge pixel direction can be obtained with a small error because of the relatively large density gradient in the edge pixels constituting the contour line. The line segment is represented by a set of edge pixels extracted on the condition that the labels assigned to the edge pixels are common and the edge pixels are continuous, so that the straight line portion of the contour of the object is accurately extracted. can do. In addition, regardless of the state of the grayscale image, the edge pixel direction can be obtained stably even when the density difference between the background portion and the object portion is small or the illumination is not uniform. However, the straight line portion of the contour of the object can be accurately extracted.
[0012]
Each step of the present invention may be executed for the entire gray image, or may be executed only for the measurement region by setting a measurement region in a part of the gray image.
[0013]
According to an embodiment of the image processing method of the present invention, the label setting step includes a histogram creating step for creating a histogram indicating the degree of the number of edge pixels for each direction of the edge pixels, and a maximum value on the histogram. By extracting and executing a peak label setting step for setting individual labels for each direction of the edge pixel corresponding to the maximum value, individual labels are set for each direction of the straight line included in the contour of the object image. Can be. Further, in the pixel labeling step, the label is assigned by assigning the label set in the peak label setting step to the edge pixel having the direction of the edge pixel corresponding to each label.
[0014]
As the degree of the number of edge pixels for each edge pixel direction, the number of edge pixels per edge pixel direction itself (so-called frequency) can be adopted, and each edge can be replaced with the number of edge pixels itself. The number of edge pixels weighted by the magnitude of the density gradient in the pixel (for example, multiplied by the magnitude of the density gradient) can also be employed.
[0015]
As the direction of the edge pixel corresponding to the maximum value, the direction of the edge pixel corresponding to the section of the histogram to which the maximum value belongs can be adopted, and a plurality of sections including the section adjacent to the section to which the maximum value belongs are included. It is also possible to adopt the direction of the edge pixel corresponding to.
[0016]
According to this embodiment, the straight line portion of the contour line can be extracted regardless of the direction of the straight line portion of the contour line of the target object, even if the direction is not known in advance.
[0017]
In this embodiment, when extracting the maximum value of the histogram, a condition for the extraction may be set. For example, conditions such as a maximum value from a larger value to a predetermined number and a maximum value larger than a predetermined value can be set.
[0018]
Further, when there is a set of line segments in which the direction deviation amount of the line segment is within a predetermined range in the line segments extracted in the line segment extraction step, and the positional deviation amount of the line segment is within the predetermined range, A line integration step for integrating these line segments into one line segment may be further executed.
In this way, even if the line segments are divided due to defects such as chipping or protrusions in the contour of the target object, the divided line segments can be integrated. However, it is possible to accurately measure the position and orientation.
[0019]
Further, a line segment selection step for selecting a line segment satisfying a predetermined condition from the line segments extracted in the line segment extraction step or the line segments integrated in the line segment integration step may be further executed. . In this way, it is possible to select a line segment that matches the specific purpose of the image processing.
The conditions for extracting a line segment include the range of the length of the line segment, the range of the angle with respect to the reference direction, the range of the position, the range of the distance between the end points of the two line segments, and the angle formed by the two line segments. Range, line segment length order, etc. can be employed.
[0020]
Further, a display step of displaying the position of the line segment selected in the line segment selection step or the position of the intersection point on the extension line of the selected plurality of line segments so as to be identifiable on the grayscale image may be further executed. Good. In this way, the line segment extraction and selection status can be presented to the user. The user can check this display and confirm whether or not the intended part such as a corner of the object is correctly measured.
[0021]
According to another embodiment of the image processing method of the present invention, the defect determination step of determining the presence or absence of a defect in the straight line portion of the contour of the object using the line segment extraction state in the line segment extraction step is further executed. be able to. According to this embodiment, when the line segment is extracted based on the continuity of the edge pixels so that the edge pixels can be regarded as having the same direction, the outline defect is a minute one having a size of several pixels. However, since the direction of the edge pixel largely fluctuates, such a minute defect is detected with high accuracy.
[0022]
Specifically, in the defect determination step, the direction deviation amount of the line segment in the line segment extracted in the line segment extraction step is within a predetermined range, and the position deviation amount of the line segment is within the predetermined range. When there is a set of line segments, it can be determined that a defect exists between these line segments.
The defect determination step compares the number of line segments extracted in the line segment extraction step with a predetermined reference value, and determines that a defect exists in the straight line portion of the contour of the object when the two values are different. It is good to do.
[0023]
Next, according to another embodiment of the image processing method according to the present invention, the label setting step sets an individual label for each direction assumed as the direction of the straight line portion in the contour of the object, The pixel labeling step may assign the label corresponding to the coincident direction to an edge pixel whose direction of the edge pixel coincides with any of the assumed directions.
[0024]
When the direction of the object is determined, and the direction of the straight line portion of the contour can be assumed in advance, an individual label is set for each such direction, so that the above-described histogram is obtained for each grayscale image to be processed. Therefore, it is possible to speed up the processing.
Moreover, the method of this embodiment can also be utilized for the pass determination and classification determination of a target object. That is, the pass / fail or type of the object is determined based on whether or not there is a straight line portion in the assumed direction in the contour of the object.
Note that the above-described line segment integration step, line segment selection step, and defect determination step can also be employed in this embodiment.
[0025]
  An apparatus for processing a grayscale image according to the present invention comprises: means for inputting a grayscale image; means for extracting an edge pixel included in the grayscale image; means for determining a direction of an edge pixel in each edge pixel; and the grayscale image Of the contour of the object image represented byThe direction of the straight lineDirection setting means for settingSet by the direction setting meansLabel setting means for setting individual labels for each direction of the straight line;Edge pixels included in the grayscale image,Pixel labeling means for assigning the label corresponding to the coincident direction to an edge pixel whose direction of the edge pixel coincides with one of the directions of the straight line, and the same labelAssign multiple edge pixelsEdge pixels that can be considered continuous on the grayscale imageGroup by set, and each set as an independent line segmentLine segment extracting means for extracting.
[0026]
According to the image processing device of the present invention, edge pixels are extracted and the direction of the edge pixels is obtained for the input grayscale image, while the direction of the straight line portion of the contour of the target image represented in the grayscale image is obtained. An individual label is set for each, and a label corresponding to the matching direction is assigned to an edge pixel whose edge pixel direction matches one of the straight line directions. Furthermore, a set of edge pixels that are assigned the same label and can be considered to be continuous on the grayscale image are extracted as line segments. In this way, it is possible to accurately extract the extracted part of the contour of the object.
[0027]
The means for inputting a grayscale image is a means connected to an image generation means such as a camera or a scanner, for example, and takes in the grayscale image generated by these means, and is constituted by an interface circuit, an A / D conversion circuit, etc. The However, the configuration for inputting an image is not limited to this, and it may be configured by a circuit for receiving an image transmitted by communication, a reading device for reading an image stored in a predetermined recording medium, or the like.
[0028]
Each means from the means for extracting the edge pixel to the line segment extracting means and each of the additional or more specific means to be described later can be realized as computer hardware and software operating therewith. Some means may be realized by a circuit block such as an ASIC (Application Specific Integrated Circuit), and the cooperative operation of each circuit block may be controlled by a computer.
[0029]
An edge extraction filter such as a Sobel filter can be used as the means for extracting the edge pixel and the means for obtaining the direction of the edge pixel. The means for extracting the edge pixels is not limited to this, and various contour extraction methods described above may be executed on the image memory of the computer.
[0030]
According to an embodiment of the image processing apparatus of the present invention, the direction setting means includes a histogram creation means for creating a histogram indicating the degree of the number of edge pixels for each edge pixel direction, and a local maximum value on the histogram. Peak direction setting means for extracting and setting the direction of the edge pixel corresponding to the maximum value as the direction of a straight line can be included. The label setting means sets an individual label for each direction set by the peak direction setting means, and the pixel labeling means uses the label set by the label setting means as an edge corresponding to each label. It can be assigned to an edge pixel having a pixel direction.
[0031]
In this embodiment, a set of line segments in which the direction deviation amount of the line segment is within a predetermined range and the positional deviation amount of the line segment is within the predetermined range in the line segment extracted by the line segment extracting means. When there is, there may be further provided line segment integration means for integrating these line segments into one line segment.
[0032]
The image processing apparatus may further include a line segment selection unit that selects a line segment satisfying a predetermined condition from the line segments extracted by the line segment extraction unit or the line segments integrated by the line segment integration unit. . The predetermined condition for selecting the line segment may be input from the outside by further providing an input means for inputting the line segment, or further provided by a storage means for storing this in advance. You may give from a memory | storage means.
The image processing apparatus further includes display control means for displaying the position of the line segment selected by the line segment selection means or the position of the intersection on the extension line of the selected plurality of line segments so as to be identifiable on the grayscale image. May be.
[0033]
According to another embodiment of the image processing apparatus of the present invention, the defect determining means for determining the presence or absence of a defect in the straight line portion of the contour of the object using the extracted state of the line segment extracted by the line segment extracting means. It can further comprise.
Specifically, the defect discriminating means has a line segment direction deviation amount within a predetermined range in the line segment extracted by the line segment extraction means, and a line segment positional deviation amount within the predetermined range. When there is a set of line segments, it can be determined that a defect exists between these line segments.
The defect determining means compares the number of line segments extracted by the line segment extracting means with a predetermined reference value, and determines that there is a defect in the straight line portion of the contour of the object when the two values are different. Can be.
[0034]
According to another embodiment of the image processing apparatus of the present invention, the direction setting means inputs an assumed direction of a straight line portion in the contour of the object, and the label setting means is input by the direction setting means. An individual label is set for each direction, and the pixel labeling unit matches the edge pixel whose edge pixel matches one of the directions input by the direction setting unit. A label corresponding to the selected direction can be assigned.
Furthermore, the line segment integration means, line segment selection means, and defect determination means described above can also be employed in this embodiment.
[0035]
DETAILED DESCRIPTION OF THE INVENTION
  FIG. 1 shows the configuration of an image processing apparatus according to an embodiment of the present invention.
  thisImage processing device1 is for extracting a straight line portion of the contour of an object on the digital grayscale image and an intersection point on the extension when there are a plurality of straight line portions. The image input unit 2, the image memory 3, and the image output 4 includes a timing control unit 5, a character / graphic memory 6, a character memory 7, a control unit 8, a monitor 9, an I / O port 10, and the like.
[0036]
The image input unit 2 includes an interface circuit for capturing a grayscale image signal from an analog camera (not shown), an A / D conversion circuit for digitally converting the grayscale image signal, a filter circuit for noise cut, and the like. The camera is not limited to an analog camera, and a digital camera may be used.
[0037]
The image memory 3 captures and stores digital grayscale image data (hereinafter simply referred to as “image”) that has been captured by the image input unit 2 and A / D converted. The character / graphic memory 6 stores image data necessary to display an edge code histogram, a processing result image, a line segment extraction condition setting screen, and the like, which will be described later.
The character memory 7 stores text data for displaying character information such as inspection results and the display position thereof. These memories 3, 6, and 7 are connected to the control unit 8 via the address / data bus 11, respectively, and data corresponding to an instruction from the control unit 8 is output as an image according to a timing signal from the timing control unit 5. Output to the unit 4 or the address / data bus 11.
[0038]
The control unit 8 includes a CPU 12, a ROM 13, and a RAM 14 as main components, and a hard disk 15 in which a control program indicating a processing procedure for inspection is installed. Based on a control program in the hard disk 15, the CPU 12 executes a target measurement process while reading / writing information from / to each memory via the address / data bus 11.
[0039]
The image output unit 4 gives the monitor 9 the image of the object to be measured, the histogram, the processing result image, and the character information indicating the inspection result alone or in combination, and displays them on the screen. . The I / O port 10 is connected to an input unit such as a keyboard and a mouse, and an output unit such as an external storage device and a transmission unit, and inputs various setting data from the input unit and outputs test results to the outside. Used when.
[0040]
In the image processing apparatus 1 of this embodiment, a measurement region that includes an object to be measured is set on the input image, and a condition for extracting a line segment that forms the contour of the object to be measured is as follows. Data input indicating the characteristics of the line segment is received from the I / O port 10. The measurement area is set based on preset conditions. However, the measurement area is not limited to this, and each time an image is input, a measurement area of an arbitrary size is provided at an arbitrary position according to a user's setting operation. May be. The entire input image may be used as the measurement area.
[0041]
FIG. 2 shows a flow of a series of measurement processes (ST1 to ST10) in the image processing apparatus 1. Hereinafter, the details of the measurement process will be described along the flow of FIG. 2 with reference to FIGS.
[0042]
First, in ST1, edge pixels in the measurement area are extracted.
In this edge pixel extraction processing, the 3 × 3 mask as shown in FIG. 3 is scanned on the image, and the density value I of each pixel in the mask is changed to the following (1) to (3) for each scanning position. By applying the equation, the density gradient Ex (x, y), Ey (x, y) for each of the x and y axes in the center pixel g (the pixel at the coordinate position (x, y)), and The magnitude of the concentration gradient (hereinafter referred to as “edge strength”) Ei (x, y) is calculated. When the edge intensity Ei (x, y) exceeds a predetermined value, the target pixel g is recognized as an edge pixel.
[0043]
[Expression 1]
Figure 0003661635
[0044]
[Expression 2]
Figure 0003661635
[0045]
[Equation 3]
Figure 0003661635
[0046]
In addition, when a simple method suitable for high-speed computation is used, equation (3) can be substituted by the following equation (4).
Ei (x, y) = Ex (x, y) + Ey (x, y) (4)
[0047]
In this embodiment, as will be described later, the mask pixel is scanned by software processing to perform edge pixel extraction processing. However, the present invention is not limited to this, and a dedicated differentiation circuit is used in parallel with image input to the image memory 3. Then, edge pixel extraction processing may be performed, and the following processing may be performed using the result.
[0048]
The density gradients Ex (x, y) and Ey (x, y) indicate the amount of change in density at the pixel of interest g for each of the x and y axis directions. The edge strength Ei (x, y) corresponds to the length of the combined vector of the vectors indicated by these density gradients Ex (x, y) and Ey (x, y). As described above, the edge strength Ei ( When x, y) exceeds a predetermined value, the target pixel g is recognized as an edge pixel.
The direction indicated by the composite vector indicates the direction in which the density changes in the pixel of interest g (that is, the direction of the density gradient).
[0049]
In the next ST2, for each edge pixel extracted in ST1, an angle indicating the direction of the edge pixel (hereinafter, numerical data indicating this angle is referred to as “edge code”) is obtained, and an edge in the measurement region is obtained. A histogram in which the number of pixels is counted for each edge code value (hereinafter, this histogram is referred to as an “edge code histogram”) is created.
[0050]
FIG. 4 shows how the edge code is expressed by enlarging a part of the contour portion of the object.
In the figure, E is an edge pixel extracted by the equations (1) to (3). In this embodiment, the vector F going from the higher density to the lower density is the direction of the density gradient in the edge pixel E, and the vector C orthogonal to the vector F is the direction represented by the edge code. The illustrated example is an example when the density of the object is smaller than the background (that is, when the object is darker than the background). When the density relationship between the object and the background is reversed, the vector F , C are reversed.
[0051]
In this embodiment, an angle Ec (x, y) when the vector C is viewed from the vector B in the counterclockwise direction with the vector B heading from the edge pixel E in the positive direction of the x-axis as a reference is used as the edge code. Yes.
[0052]
Since the vector F is a combined vector of density gradients Ex (x, y) and Ey (x, y) obtained by the equations (1) and (2), and the vector C is a vector orthogonal to the vector F. The edge code Ec (x, y) is obtained by any one of the following formulas (1) to (5) according to the values of the density gradients Ex (x, y) and Ey (x, y).
[0053]
(1) When Ex (x, y)> 0 and Ey (x, y) ≧ 0,
Ec (x, y) = atan (Ey (x, y) / Ex (x, y))
(2) When Ex (x, y)> 0 and Ey (x, y) <0,
Ec (x, y) = 360 + atan (Ey (x, y) / Ex (x, y))
(3) When Ex (x, y) <0,
Ec (x, y) = 180 + atan (Ey (x, y) / Ex (x, y))
(4) When Ex (x, y) = 0 and Ey (x, y)> 0,
Ec (x, y) = 0
(5) When Ex (x, y) = 0 and Ey (x, y) <0,
Ec (x, y) = 180
[0054]
In order to create the edge code histogram, for each edge pixel in the measurement region, the edge code Ec (x, y) is calculated using the above (1) to (5), and the calculated edge code Ec ( The frequency corresponding to the value of x, y) is added one by one, or the frequency weighted by the edge intensity Ei (x, y) of the edge pixel under consideration is added.
In this embodiment, the angle on the edge code histogram is set in units of 1 degree. Further, at the time when the calculation of the edge codes and the frequency addition processing for all the edge pixels are completed, the histogram smoothing processing is performed for noise removal.
[0055]
In this embodiment, the edge code histogram is created after the extraction of the edge pixels in the measurement area. However, the present invention is not limited to this. The edge code calculation and the frequency addition process may be performed continuously.
[0056]
On the image, the edge codes of the edge pixels constituting the line segment should all take a value corresponding to the slope of the line segment. Accordingly, when a line segment exists in the measurement region, a peak appears in the vicinity of an angle corresponding to the slope of the line segment in the edge code histogram. Further, when there are a plurality of line segments having different inclinations in the measurement region, a peak appears at each angular position corresponding to the inclination of each line segment on the edge code histogram.
[0057]
FIG. 5A shows a grayscale image to be processed. In the figure, reference numeral 16 denotes an image of an object, which has a cross-shaped contour shape that combines line segments that are lower in density than the background and can be classified into four orthogonal directions.
FIG. 5 (2) shows an edge code histogram created for the object of FIG. 5 (1), and four peaks P1 to P4 corresponding to the four directions of the contour shape appear.
[0058]
In ST3, an angle corresponding to the peak is extracted on the histogram. In order to extract the peak, for example, the frequency for each angle of the edge code histogram is compared in order from the smallest angle (however, the frequency when the edge code is 359 degrees is compared with the frequency when the edge code is 0 degrees. ), A mountain-shaped frequency change of a predetermined size or more is extracted, and an angle corresponding to this peak is determined.
[0059]
When the angles corresponding to the peaks are obtained in this way, in the next ST4, individual labels are set for the angles corresponding to these peaks (hereinafter referred to as “peak angles”). In ST5, a label set to the corresponding peak angle is assigned to each edge pixel having an edge code corresponding to each peak angle in the measurement region. Note that a label (for example, “null”) indicating that it is not data to be processed is assigned to an edge pixel that is not assigned a label corresponding to any peak angle or a pixel that is not an edge pixel.
[0060]
In ST5, not only the peak angle but also within the angle range corresponding to the range of the mountain-shaped frequency distribution around the peak angle (for example, within the angle range corresponding to the portion where the height of the histogram exceeds a predetermined value). It is preferable that a label set to the peak angle is assigned to an edge pixel having an edge code corresponding to a peak angle and a predetermined angle range before and after the peak angle.
In FIG. 5 (2), for each of the peaks P1 to P4, an angle range in which a relatively high frequency centering on the peaks P1 to P4 is obtained, and labels θ1 to θ1 are attached to the angles included in these angle ranges. θ4 is associated.
[0061]
FIG. 6A shows an example in which the labels θ1 to θ4 are assigned to the edge pixel extraction result of the image of FIG.
According to the illustrated example, since the edge code of the edge pixel constituting the line segment corresponds to one of the peaks P1 to P4 of the edge code histogram, any one of the labels θ1 to θ4 corresponds to each line segment. Will be attached.
[0062]
In the state of FIG. 6A, if there are a plurality of line segments corresponding to the same edge code on the image, the same label is assigned to these line segments. That is, each line segment on the image cannot be completely separated only by the labeling process of ST5.
Therefore, in the next ST6, the labels are reattached so that individual labels are given for each independent line segment. (Hereafter, the process of ST5 is referred to as “temporary labeling process”, and the process of ST6 is referred to as “main labeling process”.)
[0063]
In this labeling process, a set of continuous edge pixels having the same label assigned by the temporary labeling process of ST5 is extracted, and an individual label is reassigned for each set of edge pixels thus extracted.
[0064]
FIG. 6 (2) shows the result of performing the main labeling process on the result of the provisional labeling process of FIG. 6 (1). The three line segments to which the label θ1 is assigned are represented by θ11, Θ12, Θ13It is carved by each label. Similarly, three line segments to which the label θ2 is assigned include θtwenty one, Θtwenty two, Θtwenty threeEach of the three line segments to which the label θ3 is assigned has θ31, Θ32, Θ33Each of the three line segments to which the label θ4 is assigned has θ41, Θ42, Θ43Each label is assigned to each line segment.
[0065]
Such a two-step labeling process makes it possible to recognize each line segment by separating it for each label. In ST7, under this state, for each label, the following operations A to F are executed using a set of edge pixels to which the label is assigned (hereinafter referred to as “label set”). Thus, the feature amount of each line segment is calculated.
Note that the Σ operations in A and B both mean obtaining the sum of the calculation results for each edge pixel included in one label set, and (xn, Yn) Indicates the coordinates of one edge pixel in the label set, and Ei (xn, Yn), Ec (xn, Yn) Are the coordinates (xn, YnThe edge strength and edge code for the edge pixel located at) are shown.
[0066]
A. Gravity center of gravity: GX, GY
The coordinates of the barycentric position of the line segment indicated by the label set are calculated, and the edge strength Ei (xn, Yn) As weights, the following equations (a) -1 and (a) -2 are used.
GX = Σ {Ei (xn, Yn) Xn} / {Ei (xn, Yn)} ... (a) -1
GY = Σ {Ei (xn, Yn) ・ Yn} / {Ei (xn, Yn)} ... (a) -2
[0067]
B. Direction sum: SCX, SCY
The sum of the values obtained by decomposing the edge code of each edge belonging to the label set into components in the x-axis and y-axis directions, and is obtained by the following equations (b) -1 and (b) -2. .
SCX = Σcos {Ec (xn, Yn)} (B) -1
SCY = Σsin {Ec (xn, Yn)} (B) -2
[0068]
C. Directional average: EC
It is a feature amount corresponding to the slope of the line segment indicated by the label set, and is obtained from any of the following formulas (c) -1 to (c) -5 based on the magnitude relation of the direction sums SCX, SCY.
When SCX> 0 and SCY ≧ 0
EC = atan (SCY / SCX) (c) -1
When SCX> 0 and SCY <0
EC = 360 + atan (SCY / SCX) (c) -2
When SCX <0
EC = 180 + atan (SCY / SCX) (c) -3
When SCX = 0 and SCY> 0
EC = 0 (c) -4
When SCX = 0 and SCY <0
EC = 180 (c) -5
[0069]
D. Linear equation
This indicates a straight line P (shown in FIG. 7) passing through the line segment indicated by the label set, and is expressed by the following equation (d) using the direction sums SCX and SCY and the density centroids GX and GY.
SCY * x + SCX * y- (SCY * GX + SCX * GY) = 0 (d)
[0070]
E. End point coordinates: (x1, y1) (x2, y2)
In this embodiment, in order to obtain the coordinates of the end points located on the straight line P in consideration of variations in measurement processing, the following calculation is performed. .
First, the maximum value x is selected from the x and y coordinates of the edge set to be processed.max, Ymax, And minimum value xmin, YminAre extracted, and the coordinates (x1 ′, y1 ′) (x2 ′, y2 ′) of the temporary end points of the line segment are set by these coordinates.
The x coordinate of each temporary end point is x1 ′ = xmin  , X2 ′ = xmaxAnd
y-coordinate is SCY / SCX ≧ 0
y1 '= ymin  y2 '= ymax
When SCY / SCX <0
y1 '= ymax  y2 '= yminIt becomes.
[0071]
When the temporary end points (x1 ′, y1 ′) and (x2 ′, y2 ′) were obtained in this way, the coordinates were lowered from each temporary end point to a straight line using these coordinates and the straight line equation (d). The coordinates of the foot of the perpendicular are obtained, and the coordinates are set as the coordinates (x1, y1) (x2, y2) of the end points.
[0072]
F. Line length L
This corresponds to the distance between the end points of the line segment, and is obtained by fitting the coordinates of each end point to a distance calculation formula.
[0073]
FIG. 7 is a graph showing the density centroids (GX, GY), the straight line P passing through the line segment, the length L of the line segment, and the end points (x1, y1) of the line segment among the feature quantities obtained by the processes A to F. (X2, y2) is shown. In the next ST8, ST9, arithmetic processing using these feature values and straight line expressions is executed.
[0074]
In ST8, it is determined whether or not there is a set of line segments that can be integrated as one line segment using the feature amount for each line segment. When a set of line segments that can be integrated is found, a new label set is formed by grouping edge pixels constituting these line segments, and a new label is set for the set. Furthermore, for this new label set, the feature quantities and straight line expressions shown in A to F are obtained.
Each label set and its feature value before integration are also maintained without being erased.
[0075]
FIG. 8 shows a specific procedure for determining whether or not the line segments can be integrated, and FIG. 9 shows a concept of parameters used for this determination processing.
In FIG. 9, A and B are line segments under attention, P1 and P2 are straight lines passing through these line segments A and B, and C is a line segment after integration when the line segments A and B are integrated. . In this illustrated example, in order to show the parameters in an easy-to-understand manner, the difference between the inclinations of the line segments A and B and the positional deviation amount between the line segments are shown greatly.
[0076]
The procedure of FIG. 8 is executed for all line segment combinations in the measurement region (here, a combination of two line segments).
First, in ST8-1, a difference δ in inclination (the above-mentioned direction average EC) is obtained for the line segments A and B under consideration, and it is determined whether or not δ is equal to or less than a predetermined threshold value.
[0077]
In the next ST8-2, the distance d between the opposite end points (points a2 and b1 in FIG. 9) of the line segments A and B is calculated, and it is determined whether or not this is below a predetermined threshold value.
[0078]
In ST8-3, the length L3 of the line segment C after integration is obtained, and it is determined whether or not this length is equal to or greater than the sum of the lengths of the line segments A and B (L1 + L2). Note that the length L3 of the line segments after integration is calculated as the distance between the end points (end points a1 and b2 in FIG. 9) of the line segments A and B that do not face each other.
[0079]
In ST8-4, the amount of positional deviation between the line segments is obtained, and it is determined whether or not the amount of positional deviation is equal to or less than a predetermined threshold value. Note that this positional shift amount is expressed as a shift amount between the opposite end points, and in this embodiment, with respect to a straight line (P2 in the illustrated example) passing through one line segment (line segment B in the illustrated example). It is defined as the length h of the perpendicular line drawn from the end point a1 on the line segment B side of the other line segment (the line segment A in the illustrated example).
[0080]
When the determination processes of ST8-1 to 8-4 are sequentially performed and both determination results are “YES”, the process proceeds to ST8-5, where it is determined that the line segments A and B can be integrated. On the other hand, if “NO” is determined in any of the determination processes of ST8-1 to 8-4, the process proceeds to ST8-6, and it is determined that the integration of A and B is impossible.
[0081]
Of the threshold values used for each determination process, the threshold value for the distance d between the end points may be set to a relatively large value, but the threshold value for the direction average difference δ and the positional deviation amount h of the line segment. It is desirable to make the value as small as possible.
The threshold value for the direction average difference δ and the positional deviation amount h between the line segments should be set to a small value when one straight line portion of the contour of the object is divided and a plurality of line segments are generated. This is because the difference in inclination between the line segments and the amount of positional deviation between the line segments should be small. On the other hand, when a plurality of line segments are extracted by dividing one straight line portion of the contour of the object by a large defect, the value of the distance d between the opposite end points of each line segment may increase. The tolerance for the distance d between the end points can be increased to some extent.
[0082]
FIG. 10 illustrates the difference between the case where the line segments are integrated and the case where the line segments are not integrated. In (1) and (2) in the figure, two line segments A and B which have no difference in inclination. Is shown. In FIG. 10 (1), since the distance d between the end points a and b of the line segments A and B is large, the positional deviation amount h between the line segments A and B is within the width range of the line segments. It is determined that A and B can be integrated.
On the other hand, in the example of FIG. 10 (2), the distance d between the end points a and b is smaller than that of FIG. 10 (1), but the positional deviation amount h exceeds the width range of the line segment. , B cannot be integrated.
[0083]
According to the above-described straight line integration processing, as shown in FIG. 11, when there are a plurality of sets of line segments that can be integrated (in the example shown, two sets of straight lines A and B and straight lines B and D), After the integration process is performed for each group and new line segments C and E are set, these line segments C and E can be further integrated so that each line segment can be integrated into one line segment F. Become.
It should be noted that individual labels are set for the integrated line segments C, E, and F, respectively, and it is desirable to maintain the labels of the respective line segments A, B, and D before the integration.
[0084]
Returning to FIG. 2, when each line segment existing in the measurement region is individually extracted as described above and the process of integrating the line segments that can be integrated is completed, in ST9, the extraction condition is selected from these line segments. Extract the line segments that meet.
The extraction condition may be a condition for extracting one line segment, such as the length and inclination of the line segment, but in order to measure the position and direction of the object, a plurality of line segments are extracted. It is desirable to set conditions for doing so.
[0085]
FIG. 12 shows an extraction method when the straight line extraction condition is set so as to extract line segments constituting two adjacent sides of the contour of the object. Also in this case, as in the integration process, the line segments in the measurement area are searched in order, and the lengths L1 and L2 of the line segments A and B to be processed correspond to the size of the object for each group. It is determined whether it is the length. When the angle formed by each line segment is specified as the extraction condition, the angle α formed by each straight line is obtained from the equations of the straight lines P1 and P2 passing through the line segments A and B, and this α is compared with the extraction condition. .
[0086]
FIG. 13 shows a line segment extraction method in the case where extraction of a set of parallel line segments is set as the extraction condition. In a specific extraction process in this case, a difference in slope between line segments is taken for each combination of line segments in the measurement region, and a combination in which this difference takes a value close to zero is extracted. Further, when the distance between line segments is also included in the extraction condition, the distance between line segments is obtained from the equations of the straight lines P1 and P2 passing through the line segments A and B that are recognized as parallel, and this is compared with the condition. Similarly to the example of FIG. 12, the length of each line segment can be used as the extraction condition.
In the method of FIG. 13, if the distance between the line segments to be extracted is set to be extremely small, an object having a minute width such as a linear scratch generated on the package can be extracted.
[0087]
FIG. 14 shows a line segment extraction method in the case where it is set as the extraction condition that a line segment constituting a rectangle having a predetermined size is extracted. In this case, first, as shown in FIG. 14A, two sets of parallel line segments (line segments A and B and line segments C and D in the illustrated example) corresponding to opposite sides of the rectangle are extracted. It should be noted that each line segment set is extracted by the same method as in FIG. 13, and E, F, and G in the figure are line segments that do not meet the condition of parallel line segments.
Furthermore, after confirming that the difference in the slope (direction average) of the line segments between the extracted groups approximates 90 degrees, as shown in FIG. A straight line m1 and m2 connecting the region r connecting the g4 (using the coordinates (GX, GY) of the density centroid) and the centroid of each set of parallel line segments are set. At this time, if the intersection M of the straight lines m1 and m2 is within the region r, it is determined that each of the line segments θ1 to θ4 is a line segment constituting a rectangle.
[0088]
When a line segment matching the extraction condition is found in this way, in ST10, a processing result image for identifying the extracted line segment with, for example, a predetermined color or brightness is generated. The generated processing result image is given to the monitor 9 and displayed.
As shown in FIG. 12, when the intersection (cx, cy) of a line segment or a straight line is obtained from the equation of the straight line passing through each extracted line segment, a processing result image in which this intersection position is indicated by a predetermined mark Can also be generated and displayed.
[0089]
According to the above embodiment, since measurement is performed using edge pixels on a grayscale image, even if the brightness of the image changes due to fluctuations in illumination or the like, the measurement result is less likely to be distorted and stable measurement is performed. Can do. If there is a possibility that the size or direction of the object may change, set the extraction condition for the length or inclination of the line segment gently, or set another extraction condition to change the target line segment. Since extraction is possible, highly accurate measurement processing can be performed easily and at high speed.
[0090]
In this embodiment, the line segment constituting the contour line of the object is extracted from the measurement region and the extraction result is displayed. However, the present invention is not limited to this, and the extraction result is used for the object. You may make it measure a position and direction.
For example, when an object having a rectangular outline as shown in FIG. 14 is to be measured, an image region corresponding to the object is specified using an equation of a straight line passing through each extracted line segment A to D. Later, the position of the center of gravity in the region can be obtained, and the value can be specified as the position of the object. The direction of the object can be expressed by the inclination of any one of the line segments (for example, the longer line segments A and B).
[0091]
Further, according to the integrated determination processing of the line segments shown in FIGS. 8 and 9, since the contour line divided by the defect can be extracted as an integration target, the integrated determination processing is used to extract the defect generated on the contour. It is also possible to apply to.
If it is only necessary to determine the presence or absence of defects, measurement with a good product model is performed in advance to obtain the appropriate number of line segments in the measurement area, and line segments obtained from the image to be inspected are obtained. What is necessary is just to check whether the extraction number of becomes the said appropriate extraction number.
[0092]
In the above embodiment, the edge code histogram is created assuming that the object is rotationally displaced and the peak corresponding to the line segment is extracted. If the image can be picked up in advance, the direction of the contour of the object on the grayscale image is input in advance from the I / O port 10, so that the direction corresponding to the direction of the contour of the object is set as an edge pixel having an edge code. Labeling can be performed to extract a line segment corresponding to the direction of the contour. Further, it may be configured such that the measurement process after creating the edge code histogram and the measurement process without creating the edge code histogram can be switched as appropriate.
[0093]
【The invention's effect】
According to the present invention, attention is paid to the fact that the edge pixel direction can be obtained with a small error because of the relatively large density gradient in the edge pixels constituting the contour line. The line segment is represented by a set of edge pixels extracted on the condition that the labels assigned to the edge pixels are common and the edge pixels are continuous, so that the straight line portion of the contour of the object is accurately extracted. can do. In addition, regardless of the state of the grayscale image, the edge pixel direction can be obtained stably even when the density difference between the background portion and the object portion is small or the illumination is not uniform. However, the straight line portion of the contour of the object can be accurately extracted.
[Brief description of the drawings]
FIG. 1 is a block diagram showing a configuration of an image processing apparatus according to an embodiment of the present invention.
FIG. 2 is a flowchart illustrating a procedure of image processing.
FIG. 3 is an explanatory diagram showing a mask used for edge extraction processing;
FIG. 4 is an explanatory diagram showing how to represent an edge code.
FIG. 5 is an explanatory diagram showing a grayscale image of an object and an edge code histogram obtained by processing an edge extraction result of the image.
6 is an explanatory diagram showing the results of a temporary labeling process and a main labeling process for the image of FIG. 5. FIG.
FIG. 7 is an explanatory diagram showing a concept of feature quantities of line segments.
FIG. 8 is a flowchart showing a processing procedure regarding line segment integration determination;
FIG. 9 is a diagram illustrating parameters used for line segment integration determination;
FIG. 10 is an explanatory diagram illustrating an example where it is determined that integration of line segments is possible and an example where it is determined that integration is not possible;
FIG. 11 is an explanatory diagram showing an example in which a plurality of line segments are integrated.
FIG. 12 is an explanatory diagram illustrating a specific example of line segment extraction processing;
FIG. 13 is an explanatory diagram illustrating a specific example of line segment extraction processing;
FIG. 14 is an explanatory diagram illustrating a specific example of line segment extraction processing;
[Explanation of symbols]
1 Image processing device
2 Image input section
4 Image output unit
7 Control unit
9 Monitor
11 CPU

Claims (24)

濃淡画像を処理する方法であって、
前記濃淡画像に表される対象物像の輪郭に直線部分が含まれるときに、その直線の方向毎に個別のラベルを設定するラベル設定ステップと、
前記濃淡画像に含まれるエッジ画素であってそのエッジ画素の方向が前記直線の方向のいずれかと一致するようなエッジ画素に対して、その一致した方向に対応する前記ラベルを割り当てる画素ラベル付けステップと、
同一の前記ラベルが割り当てられた複数のエッジ画素を前記濃淡画像上で連続しているとみなし得るエッジ画素の集合毎にグループ分けし、各集合をそれぞれ独立した線分として抽出する線分抽出ステップとを、順に実行する画像処理方法。
A method of processing grayscale images,
A label setting step for setting an individual label for each direction of the straight line when a straight line portion is included in the contour of the object image represented in the grayscale image;
A pixel labeling step of assigning the label corresponding to the coincident direction to an edge pixel which is included in the grayscale image and whose edge pixel coincides with one of the straight line directions; ,
A line segment extraction step of grouping a plurality of edge pixels assigned the same label into groups of edge pixels that can be regarded as continuous on the grayscale image, and extracting each set as an independent line segment Are sequentially executed.
前記ラベル設定ステップは、
エッジ画素の方向毎にエッジ画素の数の度合を示すヒストグラムを作成するヒストグラム作成ステップと、
前記ヒストグラム上の極大値を抽出して、極大値に対応するエッジ画素の方向毎に個別のラベルを設定するピークラベル設定ステップとを実行することにより、対象物像の輪郭に含まれる直線の方向毎に個別のラベルを設定するものであり、
前記画素ラベル付けステップは、前記ピークラベル設定ステップにより設定されたラベルを各ラベルに対応するエッジ画素の方向を有するエッジ画素に割り当てることにより、前記ラベルの割当を行うものである請求項1に記載された画像処理方法。
The label setting step includes
A histogram creation step for creating a histogram indicating the degree of the number of edge pixels for each direction of the edge pixels;
The direction of the straight line included in the contour of the object image is extracted by extracting the local maximum value on the histogram and performing a peak label setting step for setting individual labels for each direction of the edge pixel corresponding to the local maximum value. Each one has its own label,
2. The label assignment step performs the assignment of the label by assigning the label set in the peak label setting step to an edge pixel having a direction of an edge pixel corresponding to each label. Image processing method.
前記線分抽出ステップにおいて抽出された線分の中に線分間の方向ずれ量が所定範囲内であり、かつ、線分間の位置ずれ量が所定範囲内となる線分の組があるとき、これらの線分を1本の線分に統合する線分統合ステップをさらに実行する請求項2に記載された画像処理方法。When the line segment extracted in the line segment extraction step has a pair of line segments whose direction deviation amount is within a predetermined range and whose positional deviation amount is within the predetermined range, these The image processing method according to claim 2, further comprising a line segment integration step of integrating the line segments into one line segment. 前記線分抽出ステップにおいて抽出された線分または前記線分統合ステップにおいて統合された線分の中から所定の条件を満たす線分を選択する線分選択ステップをさらに実行する請求項2または3に記載された画像処理方法。The line segment selection step of further selecting a line segment that satisfies a predetermined condition from the line segments extracted in the line segment extraction step or the line segments integrated in the line segment integration step. The described image processing method. 前記線分選択ステップにおいて選択された線分の位置または選択された複数の線分の延長線上の交点の位置を前記濃淡画像上で識別可能に表示する表示ステップをさらに実行する請求項4に記載された画像処理方法。5. The display step of further displaying the position of the line segment selected in the line segment selection step or the position of the intersection point on the extension line of the selected plurality of line segments in an identifiable manner on the gray image. Image processing method. 前記線分抽出ステップにおける線分の抽出状態を用いて対象物の輪郭の直線部分における欠陥の有無を判別する欠陥判別ステップをさらに実行する請求項2に記載された画像処理方法。The image processing method according to claim 2, further comprising a defect determination step of determining presence / absence of a defect in a straight line portion of the contour of the object using the line segment extraction state in the line segment extraction step. 前記欠陥判別ステップは、前記線分抽出ステップで抽出された線分の中に線分間の方向ずれ量が所定範囲内であり、かつ、線分間の位置ずれ量が所定範囲内である線分の組があるとき、これら線分の間に欠陥が存在すると判別するものである請求項6に記載された画像処理方法。The defect determination step includes a line segment in which the direction deviation amount of the line segment is within a predetermined range in the line segment extracted in the line segment extraction step, and the positional deviation amount of the line segment is within the predetermined range. The image processing method according to claim 6, wherein when there is a set, it is determined that a defect exists between the line segments. 前記欠陥判別ステップは、前記線分抽出ステップで抽出された線分の数を所定の基準値と比較し、両者の値が異なるときに対象物の輪郭の直線部分に欠陥が存在すると判別するものである請求項6に記載された画像処理方法。In the defect determination step, the number of line segments extracted in the line segment extraction step is compared with a predetermined reference value, and when both values are different, it is determined that a defect exists in the straight line portion of the contour of the object. The image processing method according to claim 6. 前記ラベル設定ステップは、対象物の輪郭における直線部分の方向として想定される方向毎に個別のラベルを設定するものであり、
前記画素ラベル付けステップは、そのエッジ画素の方向が前記想定される方向のいずれかと一致するようなエッジ画素に対して、その一致した方向に対応する前記ラベルを割り当てるものである、請求項1に記載された画像処理方法。
In the label setting step, an individual label is set for each direction assumed as the direction of the straight line portion in the contour of the object,
2. The pixel labeling step assigns the label corresponding to the coincident direction to an edge pixel whose direction of the edge pixel coincides with any of the assumed directions. The described image processing method.
前記線分抽出ステップにおいて抽出された線分の中に線分間の方向ずれ量が所定範囲内であり、かつ、線分間の位置ずれ量が所定範囲内である線分の組があるとき、これらの線分を1本の線分に統合する線分統合ステップをさらに実行する請求項9に記載された画像処理方法。When the line segment extracted in the line segment extraction step has a set of line segments whose direction deviation amount is within a predetermined range and whose positional deviation amount is within the predetermined range. The image processing method according to claim 9, further comprising a line segment integration step of integrating the line segments into one line segment. 前記線分抽出ステップにおいて抽出された線分または前記線分統合ステップにおいて統合された線分の中から所定の条件を満たす線分を選択する線分選択ステップをさらに実行する請求項9または10に記載された画像処理方法。The line segment selection step of selecting a line segment satisfying a predetermined condition from the line segments extracted in the line segment extraction step or the line segments integrated in the line segment integration step is further executed. The described image processing method. 前記線分抽出ステップにおける線分の抽出状態を用いて対象物の輪郭の直線部分における欠陥の有無を判別する欠陥判別ステップをさらに実行する請求項9に記載された画像処理方法。The image processing method according to claim 9, further comprising a defect determination step of determining presence / absence of a defect in a straight line portion of a contour of an object using a line segment extraction state in the line segment extraction step. 濃淡画像を入力する手段と、
前記濃淡画像に含まれるエッジ画素を抽出する手段と、
前記各エッジ画素におけるエッジ画素の方向を求める手段と、
前記濃淡画像に表される対象物像の輪郭の直線部分につき、その直線の方向を設定する方向設定手段と、
前記方向設定手段により設定された直線の方向毎に個別のラベルを設定するラベル設定手段と、
前記濃淡画像に含まれるエッジ画素であってそのエッジ画素の方向が前記直線の方向のいずれかと一致するようなエッジ画素に対して、その一致した方向に対応する前記ラベルを割り当てる画素ラベル付け手段と、
同一の前記ラベルが割り当てられた複数のエッジ画素を前記濃淡画像上で連続しているとみなし得るエッジ画素の集合毎にグループ分けし、各集合をそれぞれ独立した線分として抽出する線分抽出手段とを具備して成る画像処理装置。
Means for inputting a grayscale image;
Means for extracting edge pixels contained in the grayscale image;
Means for determining the direction of the edge pixel in each edge pixel;
Direction setting means for setting the direction of the straight line for the straight line portion of the contour of the object image represented in the grayscale image;
Label setting means for setting individual labels for each direction of the straight line set by the direction setting means;
Pixel labeling means for assigning the label corresponding to the coincident direction to the edge pixel which is included in the grayscale image and whose edge pixel coincides with one of the straight line directions; ,
Line segment extraction means for grouping a plurality of edge pixels assigned the same label into groups of edge pixels that can be regarded as continuous on the grayscale image, and extracting each set as an independent line segment An image processing apparatus comprising:
前記方向設定手段は、
エッジ画素の方向毎にエッジ画素の数の度合を示すヒストグラムを作成するヒストグラム作成手段と、
前記ヒストグラム上の極大値を抽出して、極大値に対応するエッジ画素の方向を直線の方向として設定するピーク方向設定手段とを含み、
前記ラベル設定手段は、前記ピーク方向設定手段により設定された方向毎に個別のラベルを設定するものであり、
前記画素ラベル付け手段は、前記ラベル設定手段により設定されたラベルを各ラベルに対応するエッジ画素の方向を有するエッジ画素に割り当てるものである請求項13に記載された画像処理装置。
The direction setting means includes
Histogram creation means for creating a histogram indicating the degree of the number of edge pixels for each edge pixel direction;
A peak direction setting means for extracting a local maximum value on the histogram and setting a direction of an edge pixel corresponding to the local maximum value as a direction of a straight line;
The label setting means sets an individual label for each direction set by the peak direction setting means,
The image processing apparatus according to claim 13, wherein the pixel labeling unit assigns a label set by the label setting unit to an edge pixel having a direction of an edge pixel corresponding to each label.
前記線分抽出手段によって抽出された線分の中に線分間の方向ずれ量が所定範囲内であり、かつ、線分間の位置ずれ量が所定範囲内である線分の組があるとき、これらの線分を1本の線分に統合する線分統合手段をさらに具備して成る請求項14に記載された画像処理装置。When the line segment extracted by the line segment extracting means has a set of line segments whose direction deviation amount is within a predetermined range and whose positional deviation amount is within the predetermined range. The image processing apparatus according to claim 14, further comprising line segment integration means for integrating the line segments into one line segment. 前記線分抽出手段によって抽出された線分または前記線分統合手段によって統合された線分の中から所定の条件を満たす線分を選択する線分選択手段とをさらに具備して成る請求項14または15に記載された画像処理装置。The line segment selection means for selecting a line segment satisfying a predetermined condition from the line segments extracted by the line segment extraction means or the line segments integrated by the line segment integration means. Or the image processing apparatus described in 15. 前記線分選択手段によって選択された線分の位置または選択された複数の線分の延長線上の交点の位置を前記濃淡画像上で識別可能に表示するための表示制御手段をさらに具備して成る請求項16に記載された画像処理装置。Display control means for displaying the position of the line segment selected by the line segment selection means or the position of the intersection point on the extension line of the selected plurality of line segments in a distinguishable manner on the grayscale image. The image processing apparatus according to claim 16. 前記線分抽出手段によって抽出された線分の抽出状態を用いて対象物の輪郭の直線部分における欠陥の有無を判別する欠陥判別手段をさらに具備して成る請求項13に記載された画像処理装置。The image processing apparatus according to claim 13, further comprising a defect determination unit that determines the presence / absence of a defect in a straight line portion of the contour of the object using the line segment extraction state extracted by the line segment extraction unit. . 前記欠陥判別手段は、前記線分抽出手段によって抽出された線分の中に線分間の方向ずれ量が所定範囲内であり、かつ、線分間の位置ずれ量が所定範囲内である線分の組があるとき、これら線分の間に欠陥が存在すると判別するものである請求項18に記載された画像処理装置。The defect discriminating means includes a line segment in which the direction deviation amount of the line segment is within a predetermined range in the line segment extracted by the line segment extraction means, and the positional deviation amount of the line segment is within the predetermined range. The image processing apparatus according to claim 18, wherein when there is a set, it is determined that a defect exists between the line segments. 前記欠陥判別手段は、前記線分抽出手段によって抽出された線分の数を所定の基準値と比較し、両者の値が異なるときに対象物の輪郭の直線部分に欠陥が存在すると判別するものである請求項18に記載された画像処理装置。The defect discriminating unit compares the number of line segments extracted by the line segment extracting unit with a predetermined reference value, and discriminates that a defect exists in the straight line portion of the contour of the object when the two values are different. The image processing apparatus according to claim 18. 前記方向設定手段は、対象物の輪郭における直線部分の想定される方向を入力するものであり、
前記ラベル設定手段は、前記方向設定手段によって入力された方向毎に個別のラベルを設定するものであり、
前記画素ラベル付け手段は、そのエッジ画素の方向が前記方向設定手段によって入力された方向のいずれかと一致するようなエッジ画素に対して、その一致した方向に対応する前記ラベルを割り当てるものである、請求項13に記載された画像処理装置。
The direction setting means inputs an assumed direction of a straight line portion in the contour of the object,
The label setting means sets an individual label for each direction input by the direction setting means,
The pixel labeling means assigns the label corresponding to the coincident direction to an edge pixel whose direction of the edge pixel coincides with any of the directions input by the direction setting means. The image processing apparatus according to claim 13.
前記線分抽出手段によって抽出された線分の中に線分間の方向ずれ量が所定範囲内であり、かつ、線分間の位置ずれ量が所定範囲内である線分の組があるとき、これらの線分を1本の線分に統合する線分統合手段をさらに具備して成る請求項21に記載された画像処理装置。When the line segment extracted by the line segment extracting means has a set of line segments whose direction deviation amount is within a predetermined range and whose positional deviation amount is within the predetermined range. The image processing apparatus according to claim 21, further comprising line segment integration means for integrating the line segments into one line segment. 前記線分抽出手段によって抽出された線分または前記線分統合手段によって統合された線分の中から所定の条件を満たす線分を選択する線分選択手段をさらに具備して成る請求項21または22に記載された画像処理装置。The line segment selecting means for selecting a line segment satisfying a predetermined condition from the line segments extracted by the line segment extracting means or the line segments integrated by the line segment integrating means. 22. The image processing apparatus described in 22. 前記線分抽出手段によって抽出された線分の抽出状態を用いて対象物の輪郭の直線部分における欠陥の有無を判別する欠陥判別手段をさらに具備して成る請求項21に記載された画像処理装置。The image processing apparatus according to claim 21, further comprising a defect determination unit that determines the presence or absence of a defect in a straight line portion of the contour of the object using the line segment extraction state extracted by the line segment extraction unit. .
JP2001360985A 2000-11-29 2001-11-27 Image processing method and apparatus Expired - Lifetime JP3661635B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2001360985A JP3661635B2 (en) 2000-11-29 2001-11-27 Image processing method and apparatus

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
JP2000362159 2000-11-29
JP2000-362159 2000-11-29
JP2001360985A JP3661635B2 (en) 2000-11-29 2001-11-27 Image processing method and apparatus

Publications (2)

Publication Number Publication Date
JP2002230562A JP2002230562A (en) 2002-08-16
JP3661635B2 true JP3661635B2 (en) 2005-06-15

Family

ID=26604767

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2001360985A Expired - Lifetime JP3661635B2 (en) 2000-11-29 2001-11-27 Image processing method and apparatus

Country Status (1)

Country Link
JP (1) JP3661635B2 (en)

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4206723B2 (en) 2002-10-11 2009-01-14 オムロン株式会社 Image processing method and image processing apparatus
JP2007192752A (en) * 2006-01-20 2007-08-02 Horon:Kk Method and apparatus for edge detection
KR101517004B1 (en) * 2008-04-14 2015-05-06 삼성전자주식회사 Image Processing
US8559746B2 (en) * 2008-09-04 2013-10-15 Silicon Image, Inc. System, method, and apparatus for smoothing of edges in images to remove irregularities
JP5376906B2 (en) * 2008-11-11 2013-12-25 パナソニック株式会社 Feature amount extraction device, object identification device, and feature amount extraction method
JP5085573B2 (en) * 2009-01-13 2012-11-28 新日本製鐵株式会社 Defect inspection method and defect inspection apparatus
JP5152231B2 (en) 2010-03-12 2013-02-27 オムロン株式会社 Image processing method and image processing apparatus
JP5885532B2 (en) * 2012-02-17 2016-03-15 オリンパス株式会社 Edge direction discrimination device, edge direction discrimination method, and edge direction discrimination program
CN109671052B (en) * 2018-11-16 2023-03-24 华南理工大学 Through hole detection method of flexible IC packaging substrate based on circular contour extraction
JP7311832B2 (en) * 2018-12-27 2023-07-20 ブラザー工業株式会社 Image processing device, reading device and computer program
CN112164060B (en) * 2020-10-22 2024-02-06 江苏科技大学 Diamond saw wire fracture prediction method based on image processing
CN113588654B (en) * 2021-06-24 2024-02-02 宁波大学 Three-dimensional visual detection method for engine heat exchanger interface
CN118314124B (en) * 2024-06-05 2024-09-17 陕西林科智机械设备有限公司 Speed reducer fault positioning method based on augmented reality technology

Also Published As

Publication number Publication date
JP2002230562A (en) 2002-08-16

Similar Documents

Publication Publication Date Title
US6954550B2 (en) Image processing method and apparatus
US20240161265A1 (en) Information processing device, information processing method, and storage medium
US9858659B2 (en) Pattern inspecting and measuring device and program
US8115169B2 (en) Method and apparatus of pattern inspection and semiconductor inspection system using the same
JP5953842B2 (en) Image inspection method and inspection area setting method
US8515153B2 (en) System and method of image processing, and scanning electron microscope
US8422759B2 (en) Image processing method and image processing device
JP3661635B2 (en) Image processing method and apparatus
US20040155877A1 (en) Image processing apparatus
US20090052765A1 (en) Pattern shape evaluation method, pattern shape evaluation device, pattern shape evaluating data generation device and semiconductor shape evaluation system using the same
JP4206723B2 (en) Image processing method and image processing apparatus
JP5852919B2 (en) Crack detection method
EP3358526A1 (en) System and method for scoring color candidate poses against a color image in a vision system
CN115239700A (en) Spine Cobb angle measurement method, device, equipment and storage medium
JP2002140713A (en) Image processing method and image processor
CN116703912B (en) Mini-host network port integrity visual detection method
JP4670994B2 (en) Color image processing method and image processing apparatus
JP5486403B2 (en) Image processing apparatus, image processing method, and computer program
JP4513394B2 (en) Color image processing method and image processing apparatus
CN115452845A (en) LED screen surface damage detection method based on machine vision
US20230005157A1 (en) Pattern-edge detection method, pattern-edge detection apparatus, and storage medium storing program for causing a computer to perform pattern-edge detection
JP4670995B2 (en) Color image processing method and image processing apparatus
JP4670993B2 (en) Color image processing method and image processing apparatus
JP2004094427A (en) Slip image processor and program for realizing the same device
CN110751158A (en) Digital identification method and device in therapeutic bed display and storage medium

Legal Events

Date Code Title Description
A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20041122

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20041130

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20050128

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: 20050301

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20050314

R150 Certificate of patent or registration of utility model

Ref document number: 3661635

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

Free format text: JAPANESE INTERMEDIATE CODE: R150

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20090401

Year of fee payment: 4

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20100401

Year of fee payment: 5

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20110401

Year of fee payment: 6

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20130401

Year of fee payment: 8

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20130401

Year of fee payment: 8

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20140401

Year of fee payment: 9

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

EXPY Cancellation because of completion of term