JPH0962838A - High-speed pattern matching method - Google Patents

High-speed pattern matching method

Info

Publication number
JPH0962838A
JPH0962838A JP7237937A JP23793795A JPH0962838A JP H0962838 A JPH0962838 A JP H0962838A JP 7237937 A JP7237937 A JP 7237937A JP 23793795 A JP23793795 A JP 23793795A JP H0962838 A JPH0962838 A JP H0962838A
Authority
JP
Japan
Prior art keywords
image
template
inspection object
templates
calculated
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.)
Withdrawn
Application number
JP7237937A
Other languages
Japanese (ja)
Inventor
Masaaki Yasumoto
雅昭 安本
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.)
Nachi Fujikoshi Corp
Original Assignee
Nachi Fujikoshi 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 Nachi Fujikoshi Corp filed Critical Nachi Fujikoshi Corp
Priority to JP7237937A priority Critical patent/JPH0962838A/en
Publication of JPH0962838A publication Critical patent/JPH0962838A/en
Withdrawn legal-status Critical Current

Links

Landscapes

  • Image Analysis (AREA)

Abstract

(57)【要約】 【課題】 入力画像の情報を欠落させることなく演算量
を従来のものより減少させることにより、あらゆる性質
の画像に対して高速かつ高精度のパターンマッチングを
実現させるための方法を提供する。 【解決手段】 参照画像を複数のテンプレートに分割
し、この中の任意の1つを基準テンプレートとして選択
し、基準テンプレートのみを検査対象物画像上に走査さ
せながら各走査位置における基準テンプレートと検査対
象物画像との相関係数を算出する。基準テンプレートの
相関係数が予め設定された閾値以上の場合のみ、他のテ
ンプレートについても相関係数を算出し、全テンプレー
トの相関係数が全て閾値以上の場合、このときの参照画
像の位置を候補の1つとして記憶し、走査終了後全候補
の相関係数に基づいて検査対象物の有無及び存在位置を
認識する。
(57) Abstract: A method for realizing high-speed and high-accuracy pattern matching for images of all properties by reducing the amount of calculation as compared with the conventional one without losing the information of the input image. I will provide a. A reference image is divided into a plurality of templates, any one of them is selected as a reference template, and only the reference template is scanned on the inspection object image while the reference template and the inspection object at each scanning position are scanned. The correlation coefficient with the object image is calculated. Only when the correlation coefficient of the reference template is equal to or greater than a preset threshold value, the correlation coefficient is calculated for other templates, and when the correlation coefficients of all templates are equal to or greater than the threshold value, the position of the reference image at this time is set. It is stored as one of the candidates, and the presence / absence and the position of the inspection object are recognized based on the correlation coefficients of all the candidates after the scanning.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【発明の属する技術分野】本発明は、パターンマッチン
グによる検査対象物の検出及び位置決めを高速に行うた
めに好適なパターンマッチング方法に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a pattern matching method suitable for high speed detection and positioning of an inspection object by pattern matching.

【0002】[0002]

【従来の技術】画像処理技術は計測・検査などの自動化
の手段として近年広く利用されるようになった。これ
は、画像処理は2次元データを扱うため非常に大量のデ
ータを処理する必要があるが、近年のコンピュータの処
理速度の向上により、大量のデータを短時間に処理する
ことが可能になってきたことによるものである。しか
し、現在最も入手しやすいカメラの解像度は 500×500
画素程度であるが、この場合でも1画面は25万個もの膨
大な画素からなっているため、仮に1画素当たり1マイ
クロ秒の処理性能を持った比較的高速なコンピュータを
使用した場合でも、すべての画素に対して処理を行うに
は0.25秒を要することになる。実際には画像データの入
力時間や処理データの出力時間等がこれに加わるため、
全体の処理時間は0.25秒を超えることになり、移動する
検査対象物に対して処理を行うような場合には問題とな
る。このため、高速な画像処理を行うためには、コンピ
ュータの性能向上とともに、処理結果の信頼性を損なう
ことなく処理量を減少させることができるような画像処
理のアルゴリズムを開発することが必須となっている。
2. Description of the Related Art Image processing technology has been widely used in recent years as a means for automating measurement and inspection. This is because image processing handles two-dimensional data, and therefore it is necessary to process a very large amount of data, but recent improvements in the processing speed of computers have made it possible to process a large amount of data in a short time. It is due to that. However, the resolution of the most accessible camera at present is 500 x 500
Although it is about pixels, even in this case, one screen consists of 250,000 huge pixels, so even if a relatively high-speed computer with a processing performance of 1 microsecond per pixel is used, It takes 0.25 seconds to process the pixel of. Actually, since the input time of image data and the output time of processed data are added to this,
The total processing time exceeds 0.25 seconds, which is a problem when processing a moving inspection object. Therefore, in order to perform high-speed image processing, it is essential to develop an image processing algorithm that can improve the performance of the computer and reduce the processing amount without impairing the reliability of the processing result. ing.

【0003】画像処理アルゴリズムの代表的なものとし
て、パターンマッチングと呼ばれる手法が知られてい
る。この手法は見つけたい物体の全体または一部の画像
即ち参照画像を予め記憶しておき、検査対象物を撮影し
て得られた画像即ち検査対象画像から参照画像と同じ画
像領域を見つけだすものである。
As a typical image processing algorithm, a method called pattern matching is known. In this method, the whole or part of the object to be found, that is, the reference image is stored in advance, and the same image area as the reference image is found from the image obtained by photographing the inspection object, that is, the inspection object image. .

【0004】従来のパターンマッチング方法のほとんど
は参照画像の特徴、例えば明るい領域の大きさや中心位
置などを予め計算しておき、この特徴に近い画像を検査
対象画像から探すというものである。この方法は画像の
特徴という代用特性に置き換えるため処理量を大幅に低
減できるので、処理速度が速いなどの利点があり広く用
いられてきた。しかし、この方法では、検出能力が参照
画像の特徴の選び方によって大きく影響されるため、画
像処理の経験が豊富なエンジニアでないと実用的な検査
装置を作ることができないという欠点があった。
Most of the conventional pattern matching methods are such that the characteristics of the reference image, for example, the size and center position of the bright area are calculated in advance, and an image close to this characteristic is searched for from the inspection target image. This method has been widely used because of its advantages such as high processing speed because the processing amount can be greatly reduced because it is replaced with a substitute characteristic called an image feature. However, this method has a drawback in that the detection ability is greatly affected by how the features of the reference image are selected, and therefore a practical inspection apparatus cannot be manufactured unless the engineer has extensive image processing experience.

【0005】他の手法として、参照画像をそのまま記憶
しておき、参照画像と同じ画像を検査対象画像から探し
出すものがある。テンプレートマッチングと呼ばれるこ
の方法の特徴は、参照画像を予め登録しておくだけで、
あとは画像処理装置が設定されたアルゴリズムにしたが
って参照画像に近い画像領域を検査対象画像の中から自
動的に見つけてくれるため、ほとんど専門的な知識が必
要でない点である。しかし、後で述べるように、この手
法は計算量が膨大となるため、処理時間が非常に長くな
るという欠点があった。
Another method is to store the reference image as it is and search for the same image as the reference image from the inspection target image. The feature of this method called template matching is that you only need to register the reference image in advance.
After that, since the image processing apparatus automatically finds an image region close to the reference image from the inspection target image according to the set algorithm, almost no specialized knowledge is required. However, as will be described later, this method has a drawback that the processing time becomes very long because the amount of calculation becomes enormous.

【0006】最近、コンピュータの性能が向上し、また
テンプレートマッチングの高速化手法がいろいろ考案さ
れて、一部で実用化されてきた。テンプレートマッチン
グの方法として現在最も認識能力が高いと言われている
正規化相関係数を用いた方法を説明する。正規化相関係
数φは次に示す式(1)で表わされる。
Recently, the performance of computers has improved, and various techniques for speeding up template matching have been devised and partially put into practical use. As a template matching method, a method using a normalized correlation coefficient, which is said to have the highest recognition ability at present, will be described. The normalized correlation coefficient φ is expressed by the following equation (1).

【0007】[0007]

【数1】 [Equation 1]

【0008】ここで、T(i,j)はテンプレート、F(i,j)は
入力画像の各画素の値である。式(1)の演算を例えば
500X500画素で構成される入力画像に対して 50X50画素
の大きさのテンプレートを使用して正規化相関演算を実
行させる場合は、50億回の四則演算を行う必要がある。
この場合、仮に50MIPSの高速演算プロセッサを使用して
も演算には 250秒も必要とする。このように従来の正規
化相関係数を用いたテンプレートマッチングは、画像の
明るさが変動しても安定に認識できるという利点以上
に、演算処理には膨大な時間が必要となるという大きな
問題点があり、実用的ではなかった。
Here, T (i, j) is a template and F (i, j) is a value of each pixel of the input image. For example, the calculation of equation (1)
When using a template with a size of 50X50 pixels to perform a normalized correlation operation on an input image composed of 500X500 pixels, it is necessary to perform four arithmetic operations five billion times.
In this case, even if a 50MIPS high-speed arithmetic processor is used, it takes 250 seconds for calculation. As described above, the conventional template matching using the normalized correlation coefficient has a big problem that an enormous amount of time is required for the arithmetic processing in addition to the advantage that the image can be stably recognized even when the brightness of the image changes. There was not practical.

【0009】そこで、この演算処理時間の問題を解決す
るために、演算処理を高速に行わせる数々の手法が考え
出されている。その中で最も一般的かつ簡単な方法とし
て知られているのが、入力画像からある一定の間隔で画
素データを間引いて抽出し、この間引いて抽出した画素
データにより正規化相関演算を行う方法である。式
(1)で示される正規化相関係数の計算は自乗項で構成
されるため、間引き法と呼ばれるこの方法では、演算す
る画素数が減少すると演算時間も急速に短縮することが
できる。例えば、4画素おきに抽出するとすれば、演算
量は16分の1に減少するため、演算時間が短縮化され
る。
Therefore, in order to solve the problem of the arithmetic processing time, various methods for performing arithmetic processing at high speed have been devised. The most common and simplest method among them is to extract pixel data by thinning out pixel data from the input image at certain intervals, and perform a normalized correlation operation using the thinned out pixel data. is there. Since the calculation of the normalized correlation coefficient represented by the equation (1) is composed of the square term, this method called the decimation method can reduce the calculation time rapidly when the number of pixels to be calculated decreases. For example, if every four pixels are extracted, the amount of calculation is reduced to 1/16, and the calculation time is shortened.

【0010】また、他の方法として、特開平5−189
570号公報では、通常は2次元で表されるテンプレー
トを、独立な2軸であるX方向とY方向のそれぞれに画
素の濃度を加算して2つの1次元テンプレートに変換
し、入力画像にも同様の変換を施した後、1次元のウィ
ンドウを走査し、1次元の類似度計算を行い、この2つ
の1次元テンプレートで算出された類似度を合成するこ
とにより、X、Y両方向で高いマッチング精度が得られ
るとしている。この方法では、正規化相関演算の演算量
は1次元の演算処理程度に減少されるため、ハードウェ
アは小規模な回路で実現でき、演算時間についてもかな
り短縮される。
Another method is disclosed in Japanese Patent Laid-Open No. 5-189.
According to Japanese Patent Laid-Open No. 570, a template, which is normally represented in two dimensions, is converted into two one-dimensional templates by adding pixel densities in each of two independent X-directions and Y-directions and converting the template into an input image. After performing the same conversion, the one-dimensional window is scanned, the one-dimensional similarity calculation is performed, and the similarities calculated by these two one-dimensional templates are combined to achieve high matching in both the X and Y directions. The accuracy is said to be obtained. In this method, the amount of normalized correlation calculation is reduced to the extent of one-dimensional calculation processing, so that the hardware can be realized with a small-scale circuit and the calculation time can be considerably shortened.

【0011】[0011]

【発明が解決しようとする課題】しかし、前者の方法で
は、抽出された画像が入力画像に比して情報が欠落した
ものとなってしまうため、対象画像の輪郭形状が複雑な
場合は、画像情報の欠落により高精度なマッチングでき
なくなる恐れが生じる。また、後者の方法では、前者の
方法のように画素の情報が欠落してしまうことはない
が、濃度加算は微妙な濃度変化を打ち消してしまうとい
う欠点があるため、画像の濃度が急激に変動するような
画像では、高いマッチング精度が得られないという問題
がある。
However, in the former method, the extracted image has a lack of information as compared with the input image. Therefore, when the contour shape of the target image is complicated, There is a possibility that highly accurate matching may not be possible due to the lack of information. In the latter method, the pixel information is not lost as in the former method, but since the density addition cancels a slight density change, the density of the image suddenly changes. Such an image has a problem that high matching accuracy cannot be obtained.

【0012】本発明の課題は、正規化相関演算を用いた
パターンマッチング方法において、入力画像の情報を欠
落させることなく、演算量を従来のものより減少させる
ことにより、画像の濃度が急激に変動するような画像も
含めたあらゆる性質の画像に対して、高速かつ高精度の
パターンマッチングを実現させるための方法を提供する
ことにある。
An object of the present invention is to reduce the amount of calculation as compared with the conventional one in the pattern matching method using the normalized correlation calculation without losing the information of the input image, so that the density of the image changes rapidly. An object of the present invention is to provide a method for realizing high-speed and high-accuracy pattern matching for images of all properties including such images.

【0013】[0013]

【課題を解決するための手段】これらの課題を解決する
ために、本発明では、マスターとなる対象物を撮影して
得た参照画像を複数のテンプレートに分割し、これら複
数のテンプレートの中の任意の1つを基準テンプレート
として選択し、この基準テンプレートのみを検査対象物
を撮影して得た検査対象物画像上に走査させながら、各
走査位置における基準テンプレートと検査対象物画像と
の類似度を算出するための正規化相関演算を行い、相関
係数を逐次算出する。
In order to solve these problems, in the present invention, a reference image obtained by photographing an object to be a master is divided into a plurality of templates. While selecting any one of the reference templates and scanning only this reference template on the inspection object image obtained by photographing the inspection object, the similarity between the reference template and the inspection object image at each scanning position The normalized correlation calculation for calculating is performed and the correlation coefficient is sequentially calculated.

【0014】この走査の過程において、算出された基準
テンプレートの相関係数が予め設定された閾値以上の場
合のみ、基準テンプレート以外のテンプレートについて
も、このときの基準テンプレートの位置に対応する各テ
ンプレートの位置における相関係数をそれぞれ算出し、
かつ算出された全テンプレートの相関係数が全て閾値以
上の場合、このときの全テンプレートの位置すなわち参
照画像の位置を検査対象物が存在する位置の候補の1つ
として記憶する。
In the process of scanning, only when the calculated correlation coefficient of the reference template is equal to or more than a preset threshold value, even for templates other than the reference template, the template corresponding to the position of the reference template at this time is also used. Calculate the correlation coefficient at each position,
If the calculated correlation coefficients of all the templates are all equal to or greater than the threshold value, the positions of all the templates at this time, that is, the positions of the reference images are stored as one of the candidates for the position where the inspection object exists.

【0015】そして、基準テンプレートが検査対象物画
像上を全て走査し終えたとき、候補が1つもなかった場
合は参照画像に類似する検査対象物は存在しないものと
判定し、また候補が1つだけ存在した場合はこの候補に
検査対象物が存在するものと判定し、さらに候補が複数
個存在した場合は各候補毎に算出された全テンプレート
の相関係数についてその合計値を算出し、この合計値が
最大となる候補に前記検査対象物が存在するものと判定
する。
Then, when the reference template has completely scanned over the inspection object image, if there is no candidate, it is determined that there is no inspection object similar to the reference image, and there is one candidate. If there is only one, it is determined that the inspection object exists in this candidate, and if there are more than one candidate, the total value is calculated for the correlation coefficient of all templates calculated for each candidate. It is determined that the inspection object exists in the candidate having the maximum total value.

【0016】[0016]

【発明の実施の形態】本発明の一実施の形態を図面に基
づいて説明する。図1は本発明が適用される画像処理装
置を用いた対象物体の位置姿勢認識システムの概略図を
示したものである。検査対象物4をカメラ1により撮影
し、この画像を画像処理装置2に取り込み、所定の画像
処理を行い、判定結果をモニタ3に表示させる。図示し
ないロボットシステムに適用する場合は、カメラ1をロ
ボットアームの先端に保持させ、画像処理後のデータを
画像処理装置2からの出力信号としてロボットのコント
ローラに送信し、ロボットを制御する位置データや姿勢
データを補正する。なお、図1において、モニタ3に映
し出されている検査対象物の周囲に描かれている四角形
の枠は、ウィンドウと呼ばれる画像処理領域を表してい
る。
DESCRIPTION OF THE PREFERRED EMBODIMENTS One embodiment of the present invention will be described with reference to the drawings. FIG. 1 is a schematic diagram of a position / orientation recognition system for a target object using an image processing apparatus to which the present invention is applied. The inspection object 4 is photographed by the camera 1, the image is taken into the image processing device 2, predetermined image processing is performed, and the determination result is displayed on the monitor 3. When applied to a robot system (not shown), the camera 1 is held at the tip of the robot arm, and the data after image processing is transmitted to the controller of the robot as an output signal from the image processing device 2 to obtain position data for controlling the robot. Correct the attitude data. In FIG. 1, a rectangular frame drawn around the inspection object displayed on the monitor 3 represents an image processing area called a window.

【0017】以下、本実施形態の処理フローについて記
述するが、記述中「(ステップ**)」の語句は、図5
に示す本発明のテンプレートマッチングの処理フローを
示すフローチャートの各処理ステップに相当する。
The processing flow of this embodiment will be described below. The term "(step **)" in the description is shown in FIG.
It corresponds to each processing step of the flowchart showing the processing flow of the template matching of the present invention shown in FIG.

【0018】まず、本発明における参照画像の教示につ
いて説明する。一般にテンプレートマッチングにおける
参照画像の教示過程では、図1に示したモニタ3に示さ
れているウィンドウをマスターとなる対象物に対して設
定し、このマスターとなる対象物の画像データを参照画
像として画像処理装置内の記憶装置に記憶させている。
本発明ではさらに、記憶された参照画像をテンプレート
と呼ばれる複数の小領域に分割し、このテンプレートを
画像処理装置内の記憶装置に記憶させる(ステップ3
2)。このように本発明では、マスターとなる対象物全
体を撮影して得られた画像データを参照画像と称し、参
照画像を複数の小領域に分割して得られた画像データを
テンプレートと称することにする。
First, the teaching of the reference image in the present invention will be described. Generally, in the process of teaching a reference image in template matching, a window shown on the monitor 3 shown in FIG. 1 is set for a master object, and image data of the master object is used as a reference image. It is stored in the storage device in the processing device.
In the present invention, the stored reference image is further divided into a plurality of small areas called templates, and the templates are stored in the storage device in the image processing apparatus (step 3).
2). As described above, in the present invention, image data obtained by photographing the entire master object is referred to as a reference image, and image data obtained by dividing the reference image into a plurality of small areas is referred to as a template. To do.

【0019】本実施形態では、図2に示すように、参照
画像を4個のテンプレートに等分割する。この場合、画
像処理装置内の記憶装置には図3に示すようなテンプレ
ート1乃至テンプレート4の4個のテンプレートの画像
データが記憶されることになる。なお、本発明において
は1つのテンプレートを中心に処理が行われるので、分
割された複数のテンプレートの中の任意の1つをこの処
理の中心となる基準テンプレートとして設定することに
する。本実施形態では、テンプレート1を基準テンプレ
ートとして設定する。
In the present embodiment, as shown in FIG. 2, the reference image is equally divided into four templates. In this case, the storage device in the image processing apparatus stores the image data of the four templates 1 to 4 as shown in FIG. It should be noted that in the present invention, the processing is performed centering on one template, so any one of the plurality of divided templates is set as the reference template which is the center of this processing. In this embodiment, the template 1 is set as the reference template.

【0020】次に、本発明における検査対象物と参照画
像とのマッチングについて説明する。図4に実際の検査
対象物を撮影したモニタ画面の例を示す。なお、本発明
においては、この検査対象物を撮影したモニタ画面上の
画像を検査対象物画像と称する。参照画像と検査対象物
画像とのマッチングにおいては、まず、基準テンプレー
トとして設定したテンプレート1と検査対象物画像のマ
ッチングを行わせることから始まる。具体的には、検査
対象物画像の最も左上にテンプレート1を置き(ステッ
プ33)、この位置におけるテンプレート1と検査対象
物画像との間で式(1)の演算を行い相関係数を求める
(ステップ35)。ここで算出された相関係数は0以上
1以下の値をとり、0で一致度0%、1で一致度100
%を表すことになる。通常はノイズ等の画像への微妙な
影響のため、実際にはテンプレート1と検査対象物画像
が完全に一致している状態でも相関係数は1に達するこ
とはない。一般には相関係数が0.9以上ならばかなり
高い一致度を示していることになる。
Next, matching between the inspection object and the reference image in the present invention will be described. FIG. 4 shows an example of a monitor screen imaged of an actual inspection object. In addition, in the present invention, the image on the monitor screen obtained by photographing the inspection object is referred to as an inspection object image. In the matching between the reference image and the inspection object image, first, the template 1 set as the reference template and the inspection object image are matched. Specifically, the template 1 is placed at the upper left of the inspection object image (step 33), and the correlation coefficient is calculated by performing the calculation of the equation (1) between the template 1 and the inspection object image at this position ( Step 35). The correlation coefficient calculated here takes a value of 0 or more and 1 or less, where 0 is 0% matching and 1 is 100 matching.
Will represent%. Normally, due to a slight influence of noise or the like on the image, the correlation coefficient does not reach 1 even in the state where the template 1 and the inspection object image completely match. Generally, if the correlation coefficient is 0.9 or more, it means that the degree of coincidence is quite high.

【0021】次に、算出されたテンプレート1の相関係
数を予め設定された閾値と比較する。このように、テン
プレートの任意の位置でのテンプレートと検査対象物画
像との相関係数の算出と、算出された相関係数と閾値と
の比較を、本発明ではテンプレートのマッチングと称す
る。閾値の値は相関係数と同様に0以上1以下の値を設
定することになる。しかし、先に述べたようにテンプレ
ートと検査対象物画像が完全に一致している状態でも相
関係数は1には達しないから、閾値の値を極度に高く設
定すると一致する箇所が1つもないということが起こり
うるし、逆に閾値の値を極度に低く設定すると一致する
箇所が多数現れてしまい、判定での処理時間が長くなっ
てしまうので、閾値の設定では検査対象物の性質に応じ
た値を適宜設定することになる。
Next, the calculated correlation coefficient of the template 1 is compared with a preset threshold value. As described above, the calculation of the correlation coefficient between the template and the image of the inspection object at an arbitrary position of the template and the comparison between the calculated correlation coefficient and the threshold are referred to as template matching in the present invention. As with the correlation coefficient, the threshold value is set to a value of 0 or more and 1 or less. However, as described above, the correlation coefficient does not reach 1 even when the template and the image of the inspection object completely match, and therefore, if the threshold value is set extremely high, there is no match. On the contrary, if the threshold value is set extremely low, many matching points will appear, and the processing time for judgment will be long. Therefore, the threshold setting depends on the nature of the inspection object. The value will be set appropriately.

【0022】算出された相関係数と閾値との比較におい
て、相関係数が閾値以下の場合は(ステップ36N)、
この位置にテンプレート1の画像データに対応する検査
対象物の画像データは存在しないものと判定し、テンプ
レート1を入力画像に対して1画素右にずらして(ステ
ップ45)、再度前述と同様にマッチングを行う(ステ
ップ35)。このようにマッチングの過程においてテン
プレートを1画素ずつずらす操作をテンプレートの走査
と呼ぶ。走査方法としてはいろいろあるが、最も一般的
に行われている方法では、まず検査対象物画像の最も左
上にテンプレートを置き、次いで1画素ずつテンプレー
トを右方向に移動させ、テンプレートが検査対象物画像
の右端まで到達した後は、テンプレートを検査対象物画
像の左端に戻した上さらに1画素下にずらし、再度右方
向に移動させ、最終的にテンプレートが検査対象物画像
の最も右下まで移動するまでこれを繰り返す。
In the comparison between the calculated correlation coefficient and the threshold value, if the correlation coefficient is less than or equal to the threshold value (step 36N),
It is determined that the image data of the inspection object corresponding to the image data of the template 1 does not exist at this position, the template 1 is shifted to the right by one pixel with respect to the input image (step 45), and the matching is performed again as described above. Is performed (step 35). The operation of shifting the template by one pixel in the matching process is called template scanning. There are various scanning methods, but in the most commonly used method, the template is first placed at the upper left of the inspection object image, and then the template is moved right by one pixel so that the template is the inspection object image. After reaching the right end of the, the template is returned to the left end of the inspection object image, further shifted by one pixel below, moved to the right again, and finally the template moves to the rightmost bottom of the inspection object image. Repeat this until.

【0023】一方、基準テンプレートとしたテンプレー
ト1の走査の途中において、このテンプレート1の相関
係数が閾値より大きくなった場合は(ステップ36
Y)、基準テンプレート以外のテンプレート、すなわち
テンプレート2以降のテンプレートについてもマッチン
グを行う。ここで、基準テンプレート以外のテンプレー
トの基準テンプレートに対する相対的な位置は、参照画
像を複数のテンプレートに分割した段階で決まっている
ため、基準テンプレート以外のテンプレートについては
基準テンプレートのように走査を行わせる必要はなく、
マッチングは各テンプレートの基準テンプレートに対す
る相対的な位置においてのみ行えばよいことになる(ス
テップ39)。
On the other hand, if the correlation coefficient of the template 1 becomes larger than the threshold value during the scanning of the template 1 used as the reference template (step 36).
Y), templates other than the reference template, that is, templates 2 and subsequent templates are also matched. Here, since the relative position of the template other than the reference template to the reference template is determined at the stage when the reference image is divided into a plurality of templates, the template other than the reference template is scanned like the reference template. No need to
Matching may be performed only in the position of each template relative to the reference template (step 39).

【0024】すなわち、本実施形態では図3に示すよう
に参照画像を分割したのであるから、テンプレート2の
基準テンプレート(テンプレート1)に対する相対的な
位置はテンプレート1の右隣ということになり、この位
置でのみテンプレート2のマッチングを行う。テンプレ
ート3及びテンプレート4についても同様に順次マッチ
ングを行っていく。この場合、テンプレート3はテンプ
レート1の下隣、テンプレート4はテンプレート1の右
下すなわちテンプレート3の右隣に配置することにな
る。
That is, in this embodiment, since the reference image is divided as shown in FIG. 3, the relative position of the template 2 to the reference template (template 1) is to the right of the template 1. The template 2 is matched only at the position. Similarly, the matching is sequentially performed for the template 3 and the template 4. In this case, the template 3 is arranged under the template 1, and the template 4 is arranged under the template 1 on the lower right side, that is, on the right side of the template 3.

【0025】4つのテンプレート全てに対して相関係数
が閾値以上であった場合は、この位置を検査対象物が存
在する位置の候補の一つとしてカウントし、画像処理装
置内の記憶装置に記憶する(ステップ43)。なお、検
査対象物の形状や閾値の設定によっては候補が複数存在
することもあり得るので、通常は処理の途中で候補が見
つかってもさらに処理を続行し、全ての候補を抽出す
る。
If the correlation coefficient is greater than or equal to the threshold value for all four templates, this position is counted as one of the candidates for the position where the inspection object exists, and is stored in the storage device in the image processing apparatus. (Step 43). Since there may be a plurality of candidates depending on the shape of the inspection object and the setting of the threshold value, normally, even if a candidate is found in the middle of the processing, the processing is further continued and all the candidates are extracted.

【0026】そして、画面全体の走査が終了した時点
で、抽出された全ての候補の中から、各候補の相関係数
に基づいて検査対象物が存在する位置を判定する。具体
的には、候補が1つもない場合は(ステップ46N)、
参照画像に類似する検査対象物は存在しないものと判定
し(ステップ48)、また候補が1つだけ存在した場合
は(ステップ46Y)、この候補に検査対象物が存在す
るものと判定し、さらに候補が複数個存在した場合は
(ステップ46Y)、各候補毎に算出された全テンプレ
ートの相関係数についてその合計値を算出し、この合計
値が最大となる候補に検査対象物が存在するものと判定
する(ステップ47)。
Then, when the scanning of the entire screen is completed, the position where the inspection object is present is determined from all the extracted candidates based on the correlation coefficient of each candidate. Specifically, when there are no candidates (step 46N),
It is determined that there is no inspection object similar to the reference image (step 48), and if there is only one candidate (step 46Y), it is determined that the inspection object exists in this candidate, and When there are a plurality of candidates (step 46Y), the total value of the correlation coefficients of all the templates calculated for each candidate is calculated, and the candidate having the maximum total value has the inspection object. (Step 47).

【0027】本実施形態によれば、参照画像を4個のテ
ンプレートに等分割しているため、テンプレート1個の
面積は参照画像に比べて1/4となっている。式(1)
に示されるように、相関係数の演算量はテンプレートの
面積の自乗で利いてくるため、この場合は演算量が1/
16に減少するので、相関係数の演算自体に要する処理
時間も1/16で済むことになる。複数の存在候補の中
から検査対象物が存在する位置を絞り込むための演算時
間を含めた判定に要する処理時間を加えても、全体の処
理時間は参照画像の全領域でマッチングを行うものと比
較して1/10以下に短縮される。
According to this embodiment, since the reference image is equally divided into four templates, the area of one template is 1/4 of that of the reference image. Equation (1)
As shown in, the calculation amount of the correlation coefficient is obtained by the square of the area of the template, and in this case, the calculation amount is 1 /
Since it is reduced to 16, the processing time required for calculating the correlation coefficient itself can be reduced to 1/16. Even if the processing time required for the determination including the calculation time for narrowing down the position where the inspection object exists is selected from among multiple existence candidates, the total processing time is compared with that for matching in all areas of the reference image. It is shortened to 1/10 or less.

【0028】このように本実施形態によれば、従来の参
照画像の全領域についてマッチングを行うものと比較し
て処理時間が大幅に短縮されるにも係わらず、検査対象
物が存在すると判定された位置においては、結局、参照
画像を分割することによって生成された4つのテンプレ
ート全てについてマッチングを行ったことになるので、
認識精度は参照画像の全領域についてマッチングを行っ
たものと全く同じとなる。
As described above, according to the present embodiment, it is determined that the inspection object is present, though the processing time is significantly shortened as compared with the conventional matching for the entire area of the reference image. At all the positions, since all four templates generated by dividing the reference image have been matched,
The recognition accuracy is exactly the same as that obtained by performing matching on the entire area of the reference image.

【0029】なお、先に述べたように、本実施形態で
は、基準テンプレートとしたテンプレート1の相関係数
が閾値より大きくなった場合のみ、基準テンプレート以
外のテンプレート、すなわちテンプレート2乃至4のテ
ンプレートについてマッチングを行うとしているが、4
つのテンプレート全てに対して相関係数が閾値以上であ
った場合のみこの位置を検査対象物が存在する位置の候
補の一つとして記憶するようにしているので、テンプレ
ート2乃至4のマッチングの過程でも、これら全てのテ
ンプレートについてマッチングを行う必要はなく、例え
ば、テンプレート2のマッチングにおいてこのテンプレ
ート2の相関係数が閾値より小さくなった場合は、この
位置は検査対象物が存在する位置の候補ではないという
ことになるから、残りのテンプレート3及び4について
はマッチングを行わないようにしてもよい(ステップ4
1N)。
As described above, in the present embodiment, the templates other than the reference template, that is, the templates of templates 2 to 4 are used only when the correlation coefficient of the template 1 as the reference template becomes larger than the threshold value. It is supposed to be matched, but 4
This position is stored as one of the candidates for the position where the inspection object exists only when the correlation coefficient is greater than or equal to the threshold value for all of the two templates. Therefore, even in the process of matching the templates 2 to 4, It is not necessary to perform matching on all of these templates. For example, when the correlation coefficient of this template 2 becomes smaller than the threshold value in the matching of template 2, this position is not a candidate for the position where the inspection object exists. Therefore, matching may not be performed on the remaining templates 3 and 4 (step 4).
1N).

【0030】このようにすれば、参照画像の分割数を多
く設定した場合や、あるいは閾値を低く設定したために
相関係数が閾値以上となる基準テンプレートが多くなっ
たりした場合など、基準テンプレート以外のテンプレー
トの演算量が多くなったときに、不必要なマッチング処
理がなくなり、処理時間の一層の短縮が図れるものとな
る。
In this way, when the number of divisions of the reference image is set to a large number, or when the threshold value is set low, the number of reference templates whose correlation coefficient is greater than or equal to the threshold value increases, other than the reference template. When the calculation amount of the template becomes large, unnecessary matching processing is eliminated, and the processing time can be further shortened.

【0031】なお、本実施形態においては、参照画像を
4個のテンプレートに等分割したが、これに限定され
ず、テンプレートの分割数や形状は使用形態に合わせて
任意に設定してよい。しかし、分割数については、これ
が多いほど候補の絞り込みが確実にでき、この結果認識
精度が向上するが、あまり多すぎると処理時間の増加を
招くことになるので、使用するハードウェアの性能や検
査対象物の性質に応じた値を適宜設定することが望まし
いと言える。
In the present embodiment, the reference image is equally divided into four templates, but the present invention is not limited to this, and the number of divisions and the shape of the template may be set arbitrarily according to the usage form. However, with regard to the number of divisions, the more divisions there are, the more reliably candidates can be narrowed down, and as a result the recognition accuracy improves. However, if there are too many divisions, processing time will increase. It can be said that it is desirable to appropriately set a value according to the property of the object.

【0032】また、本実施形態においては、各候補毎に
算出された4個の相関係数を合計し、この合計値が最大
となる候補の位置に検査対象物が存在するものと判定し
たが、これに限定されず、各候補毎に算出された4個の
相関係数の平均値を算出し、この平均値が最大となる候
補の位置に検査対象物が存在するものと判定してもよい
し、また、各候補毎に算出された4個の相関係数の最小
値を抽出し、この最小値が最大となる候補の位置に検査
対象物が存在するものと判定してもよい。
Further, in the present embodiment, the four correlation coefficients calculated for each candidate are summed up, and it is determined that the inspection object exists at the position of the candidate having the maximum total value. However, the present invention is not limited to this, and even if the average value of the four correlation coefficients calculated for each candidate is calculated and it is determined that the inspection target object exists at the position of the candidate having the maximum average value. Alternatively, the minimum value of the four correlation coefficients calculated for each candidate may be extracted, and it may be determined that the inspection target object exists at the position of the candidate having the maximum minimum value.

【0033】さらに、本実施形態においては、分割され
た全てのテンプレートについて閾値を1つ設定するよう
にしたが、これに限定されず、各テンプレートに対応し
た閾値をそれぞれ設定するようにしてもよい。
Further, in this embodiment, one threshold value is set for all the divided templates, but the present invention is not limited to this, and threshold values corresponding to each template may be set respectively. .

【0034】[0034]

【発明の効果】このように本発明は、教示された参照画
像を複数のテンプレートに分割し、この中から任意に1
個のテンプレートを基準テンプレートとして選択し、最
初にこの基準テンプレートにおいてマッチングを行い相
関係数が予め設定された閾値以上になった位置におい
て、更に残りのテンプレートにおいても同様に順次マッ
チングを行うようにしたので、マッチングのためのテン
プレートの相関係数の演算は基準テンプレートの相関係
数の演算にほとんど費やされることになり、参照画像の
全領域でマッチングを行わせる従来の方法と比較して著
しく処理時間が短縮される。
As described above, according to the present invention, the taught reference image is divided into a plurality of templates, and one of them is arbitrarily selected.
Each template is selected as a reference template, and matching is first performed in this reference template, and at the position where the correlation coefficient is equal to or more than a preset threshold value, the remaining templates are also sequentially matched in the same manner. Therefore, the calculation of the correlation coefficient of the template for matching is mostly spent on the calculation of the correlation coefficient of the standard template, which is significantly slower than the conventional method that performs matching in the entire area of the reference image. Is shortened.

【0035】また、検査対象物が存在すると判定された
位置においては、結局、全てのテンプレートについてマ
ッチングを行うことになるため、参照画像の全領域でマ
ッチングを行った場合と全く同じ精度の結果が得られ
る。
In addition, at the position where the inspection object is determined to exist, matching is eventually performed for all the templates, so that the result with exactly the same precision as when matching is performed for the entire area of the reference image is obtained. can get.

【0036】このように、本発明によれば、認識精度に
ついては参照画像の全領域においてマッチングを行わせ
る従来の方法と同レベルに維持しつつ、処理時間につい
ては大幅に短縮することができるので、検査対象物の画
像情報を欠落させたり変換させることなく、高速かつ高
精度のパターンマッチングを実現させることが可能とな
った。
As described above, according to the present invention, the recognition accuracy can be maintained at the same level as the conventional method for performing matching in the entire area of the reference image, while the processing time can be greatly shortened. It has become possible to realize high-speed and high-precision pattern matching without missing or converting image information of the inspection object.

【図面の簡単な説明】[Brief description of drawings]

【図1】本発明が適用される画像処理装置を用いた対象
物体の位置姿勢認識システムの概略図を示したものであ
る。
FIG. 1 is a schematic diagram of a position / orientation recognition system for a target object using an image processing apparatus to which the present invention is applied.

【図2】本発明の一実施の形態において、参照画像を4
つのテンプレートに等分割したものを示したものであ
る。
FIG. 2 shows a case where a reference image is 4
This shows the one template divided equally.

【図3】本発明の一実施の形態において、分割された4
つのテンプレートの画像例を表したものである。
FIG. 3 is a diagram illustrating a case where a divided 4 is used in an embodiment of the present invention.
It shows an example image of one template.

【図4】マッチング時のモニタの画像例である。FIG. 4 is an example of a monitor image at the time of matching.

【図5】本発明のテンプレートマッチングの処理フロー
を示すフローチャートである。
FIG. 5 is a flowchart showing a processing flow of template matching of the present invention.

【符号の説明】[Explanation of symbols]

2 画像処理装置 4 検査対象物 2 Image processing device 4 Inspection object

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】 検査対象物を撮影して得られた検査対象
物画像上に予め記憶された参照画像を走査させ、両画像
の類似度を算出するための正規化相関演算を行い、該正
規化相関演算により算出された両画像の相関係数に基づ
いて前記検査対象物画像のうち前記参照画像と類似した
画像領域を抽出する画像処理装置のパターンマッチング
方法において、前記参照画像を任意の形状を持つ複数の
テンプレートに分割し、該複数のテンプレートの中の任
意の1つを基準テンプレートとして選択し、該基準テン
プレートのみを前記検査対象物画像上に走査させながら
各走査位置における基準テンプレートと検査対象物画像
との相関係数を逐次算出し、該相関係数が予め設定され
た閾値以上の場合のみ前記基準テンプレート以外のテン
プレートについても相関係数を算出し、かつ算出された
全テンプレートの相関係数が全て前記閾値以上の場合こ
のときの全テンプレートの位置すなわち前記参照画像の
位置を前記検査対象物が存在する位置の候補として記憶
し、前記基準テンプレートが前記検査対象物画像上を全
て走査し終えたとき、前記候補が1つもない場合は前記
参照画像に類似する前記検査対象物は存在しないものと
判定し、かつ前記候補が1つだけ存在した場合はこの候
補に前記検査対象物が存在するものと判定し、かつ前記
候補が複数個存在した場合は各候補毎に算出された全テ
ンプレートの相関係数についてその合計値を算出し該合
計値が最大となる候補に前記検査対象物が存在するもの
と判定するようにしたことを特徴とする高速パターンマ
ッチング方法。
1. An inspection target image obtained by photographing an inspection target is scanned with a reference image stored in advance, and a normalized correlation operation for calculating the similarity between the two images is performed, and the normalization is performed. In the pattern matching method of the image processing device for extracting an image region similar to the reference image in the inspection object image based on the correlation coefficient of both images calculated by the generalized correlation calculation, the reference image has an arbitrary shape. Divided into a plurality of templates each having, and selecting any one of the plurality of templates as a reference template, and scanning only the reference template on the inspection object image while inspecting the reference template at each scanning position. Sequentially calculating the correlation coefficient with the object image, and only when the correlation coefficient is greater than or equal to a preset threshold value When the correlation coefficients are calculated and the calculated correlation coefficients of all the templates are all equal to or more than the threshold value, the positions of all the templates at this time, that is, the positions of the reference images are stored as candidates for the position where the inspection object exists. However, when the reference template finishes scanning all over the inspection object image, it is determined that the inspection object similar to the reference image does not exist when there is no candidate, and the candidate is When there is only one, it is determined that the inspection object exists in this candidate, and when there are a plurality of candidates, the total value of the correlation coefficients of all templates calculated for each candidate is calculated. A high-speed pattern matching method, characterized in that it is determined that the inspection object is present in the candidate having the maximum total value calculated.
JP7237937A 1995-08-24 1995-08-24 High-speed pattern matching method Withdrawn JPH0962838A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP7237937A JPH0962838A (en) 1995-08-24 1995-08-24 High-speed pattern matching method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP7237937A JPH0962838A (en) 1995-08-24 1995-08-24 High-speed pattern matching method

Publications (1)

Publication Number Publication Date
JPH0962838A true JPH0962838A (en) 1997-03-07

Family

ID=17022677

Family Applications (1)

Application Number Title Priority Date Filing Date
JP7237937A Withdrawn JPH0962838A (en) 1995-08-24 1995-08-24 High-speed pattern matching method

Country Status (1)

Country Link
JP (1) JPH0962838A (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005346283A (en) * 2004-06-01 2005-12-15 Sharp Corp Screen determination apparatus and screen determination method
JP2008152555A (en) * 2006-12-18 2008-07-03 Olympus Corp Image recognition method and image recognition device
JP2010079513A (en) * 2008-09-25 2010-04-08 Nec Corp Pattern recognition device, and method and program thereof
JP2011123737A (en) * 2009-12-11 2011-06-23 Canon Inc Object recognition device, object recognition method, and program
JP2012053653A (en) * 2010-09-01 2012-03-15 Nippon Hoso Kyokai <Nhk> Image feature point detection device and image feature point detection program
JP2012226616A (en) * 2011-04-20 2012-11-15 Canon Inc Pattern recognition device, pattern recognition method and program
JP2014048258A (en) * 2012-09-04 2014-03-17 Plex International Design Co Ltd Method and apparatus for inspecting cloth piece
WO2021090650A1 (en) * 2019-11-06 2021-05-14 パナソニックIpマネジメント株式会社 Tool system, reference pixel generation method, and program
CN114723605A (en) * 2022-03-14 2022-07-08 武汉维他智联科技有限公司 Image stitching method, device, equipment and medium for slide scanning system

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005346283A (en) * 2004-06-01 2005-12-15 Sharp Corp Screen determination apparatus and screen determination method
JP2008152555A (en) * 2006-12-18 2008-07-03 Olympus Corp Image recognition method and image recognition device
JP2010079513A (en) * 2008-09-25 2010-04-08 Nec Corp Pattern recognition device, and method and program thereof
JP2011123737A (en) * 2009-12-11 2011-06-23 Canon Inc Object recognition device, object recognition method, and program
JP2012053653A (en) * 2010-09-01 2012-03-15 Nippon Hoso Kyokai <Nhk> Image feature point detection device and image feature point detection program
JP2012226616A (en) * 2011-04-20 2012-11-15 Canon Inc Pattern recognition device, pattern recognition method and program
JP2014048258A (en) * 2012-09-04 2014-03-17 Plex International Design Co Ltd Method and apparatus for inspecting cloth piece
WO2021090650A1 (en) * 2019-11-06 2021-05-14 パナソニックIpマネジメント株式会社 Tool system, reference pixel generation method, and program
CN114723605A (en) * 2022-03-14 2022-07-08 武汉维他智联科技有限公司 Image stitching method, device, equipment and medium for slide scanning system

Similar Documents

Publication Publication Date Title
US20060029276A1 (en) Object image detecting apparatus, face image detecting program and face image detecting method
JPH0264783A (en) Shape recognition system
US7340089B2 (en) Geometric pattern matching using dynamic feature combinations
JP2002230549A (en) Image processing method and apparatus
JP2007072620A (en) Image recognition apparatus and method
WO2020230244A1 (en) Training method, training program, and training device
JPH0962838A (en) High-speed pattern matching method
CN111415370A (en) A real-time tracking method and system for infrared complex scene target based on embedded
CN116386089B (en) Human body posture estimation method, device, equipment and storage medium under motion scene
CN116895040B (en) Person re-identification method, person re-identification system, and computer-readable recording medium containing person re-identification program.
WO2005041128A1 (en) Face image candidate area search method, face image candidate area search system, and face image candidate area search program
JP2005293334A (en) Template matching device
JPH0664614B2 (en) Hierarchical structured template matching method
So et al. Implementation of a High-speed Template Matching System for Wafer-vision Alignment Using FPGA.
JP2019200527A (en) Information processing device, information processing method, and program
JP2001060265A (en) Image processing apparatus and method, and medium
JP3164835B2 (en) Pre-processing method and post-processing method in human image recognition
JPH1063842A (en) Template matching method
JPH06160047A (en) Pattern matching method
CN113705430B (en) Form detection method, device, equipment and storage medium based on detection model
KR0158416B1 (en) Method of judging position of object by contraction of image data
CN115471715B (en) Image recognition method
EP4682825A1 (en) Time shift determination unit and method for determining time shifts
CN113780319B (en) Closed loop detection method and device, and computer storable medium
JP3447717B2 (en) Image processing device

Legal Events

Date Code Title Description
A300 Withdrawal of application because of no request for examination

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 20021105