JP5769559B2 - Image processing apparatus, image processing program, robot apparatus, and image processing method - Google Patents

Image processing apparatus, image processing program, robot apparatus, and image processing method Download PDF

Info

Publication number
JP5769559B2
JP5769559B2 JP2011195285A JP2011195285A JP5769559B2 JP 5769559 B2 JP5769559 B2 JP 5769559B2 JP 2011195285 A JP2011195285 A JP 2011195285A JP 2011195285 A JP2011195285 A JP 2011195285A JP 5769559 B2 JP5769559 B2 JP 5769559B2
Authority
JP
Japan
Prior art keywords
edge
image processing
detection target
image
feature
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 - Fee Related
Application number
JP2011195285A
Other languages
Japanese (ja)
Other versions
JP2013058036A (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.)
Canon Inc
Original Assignee
Canon Inc
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 Canon Inc filed Critical Canon Inc
Priority to JP2011195285A priority Critical patent/JP5769559B2/en
Publication of JP2013058036A publication Critical patent/JP2013058036A/en
Application granted granted Critical
Publication of JP5769559B2 publication Critical patent/JP5769559B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、画像処理によってエッジを検出するための画像処理装置、画像処理プログラム、ロボット装置及び画像処理方法に関するものである。   The present invention relates to an image processing apparatus, an image processing program, a robot apparatus, and an image processing method for detecting an edge by image processing.

画像処理の分野において、画像から物体の端面等を知るための方法としてエッジ抽出がよく知られている。エッジを抽出する方法(画像処理方法)としては、ソーベルフィルタやラプラシアンフィルタ等が一般的に知られている。この手法として、以下のエッジ抽出装置を用いる画像処理方法が知られている。なお、エッジとは、濃淡画像内で輝度(画素値)が急激に変化している部分を意味する。   In the field of image processing, edge extraction is well known as a method for knowing an end face of an object from an image. As a method for extracting an edge (image processing method), a Sobel filter, a Laplacian filter, or the like is generally known. As this technique, an image processing method using the following edge extraction apparatus is known. Note that the edge means a portion where the luminance (pixel value) changes rapidly in the grayscale image.

このエッジ抽出装置(画像処理装置)は、画像からエッジ強度を算出してエッジ検出を行うエッジ検出部と、エッジ検出部が検出したエッジをラベリング処理し、かつエッジの長さを求めるラベリング処理部とを備えている。さらに、エッジ抽出装置は、ラベリング処理部が求めたエッジの長さとエッジ検出部が算出したエッジ強度とを対応付けた値によってエッジの強調処理を行うエッジ強調処理部を備えている。そして、エッジ抽出装置は、エッジ強調処理部によって強調された画像の値に対して、調整可能とされる閾値(しきい値)により2値化処理を施し、所定のエッジを抽出するエッジ抽出部を備えている(特許文献1参照)。   The edge extraction device (image processing device) includes an edge detection unit that calculates edge strength from an image and detects an edge, and a labeling processing unit that performs a labeling process on the edge detected by the edge detection unit and calculates an edge length And. Further, the edge extraction apparatus includes an edge enhancement processing unit that performs edge enhancement processing using a value in which the edge length obtained by the labeling processing unit is associated with the edge strength calculated by the edge detection unit. Then, the edge extraction device performs binarization processing on the value of the image emphasized by the edge enhancement processing unit using a threshold value (threshold value) that can be adjusted, and extracts a predetermined edge. (See Patent Document 1).

即ち、特許文献1に記載のエッジ検出装置では、エッジを検出する際にエッジの強度(濃淡変化の急峻さ)と長さとを基準にして、エッジ強度が弱く且つ短いエッジに関してはノイズエッジと判断することで、細かいノイズエッジを除去する。   That is, in the edge detection device described in Patent Document 1, when detecting an edge, the edge strength (steepness of shading change) and length are used as a reference, and an edge having a weak edge strength and a short edge is determined as a noise edge. To remove fine noise edges.

また、エッジ抽出システムを用いた別の画像処理方法が知られている。このエッジ抽出システムは、画像を入力する画像入力手段と、画像入力手段から出力される入力画像から画像のエッジを抽出するエッジ抽出手段と、エッジ抽出手段で抽出されたエッジ抽出画像を取り込むエッジ抽出画像出力手段とを備えている。エッジ抽出手段は、画像入力手段から出力される入力画像の中から切り出した領域のデータを入力データとし該領域の特定画素がエッジか否かを示すデータを教師データとして画像のエッジ抽出処理を学習するエッジ抽出学習部を備えている。さらに、エッジ抽出学習部で学習した学習結果に基づいて、画像入力手段から出力される入力画像から画像のエッジを抽出するエッジ抽出部を備えている(特許文献2参照)。   Another image processing method using an edge extraction system is known. The edge extraction system includes an image input unit that inputs an image, an edge extraction unit that extracts an edge of an image from an input image output from the image input unit, and an edge extraction that captures an edge extraction image extracted by the edge extraction unit Image output means. The edge extraction means learns the edge extraction processing of the image using the data of the area cut out from the input image output from the image input means as the input data and the data indicating whether or not the specific pixel of the area is an edge. An edge extraction learning unit is provided. Furthermore, an edge extraction unit that extracts an edge of an image from an input image output from the image input unit based on a learning result learned by the edge extraction learning unit is provided (see Patent Document 2).

即ち、特許文献2に記載のエッジ抽出システムでは、図15(a)に示すように、入力画像の比較対象となる、ワークの参照画像33から領域を設定する。さらに、検出対象となるエッジを含む検出対象領域34のデータと、検出対象となるエッジを含まない非検出対象の非検出対象領域35のデータとを予め記憶しておく。検出対象領域34には、検出対象が真である(例えば1)と関連付け、非検出対象領域35には、検出対象が否(例えば0)と関連付けることにより、予め検出領域を学習させておく。   That is, in the edge extraction system described in Patent Document 2, as shown in FIG. 15A, an area is set from a reference image 33 of a workpiece to be compared with an input image. Further, the data of the detection target region 34 including the detection target edge and the data of the non-detection target non-detection region 35 that does not include the detection target edge are stored in advance. The detection target area 34 is associated with a true detection target (for example, 1), and the non-detection target area 35 is associated with a detection target for a negative (for example, 0) to learn the detection area in advance.

そして、図15(b)に示すように、参照画像33とは別に撮像したワークの入力画像36に対して領域を走査していき、学習結果より、入力画像36における領域37は非検出領域であり、入力画像36における領域38は検出対象領域であると判断する。つまり、参照画像33の中から切り出した領域データの特定画素がエッジか否かを示すデータを教師データとして、画像のエッジ抽出処理を学習することにより、図15(c)に示すように任意のエッジを検出する。   Then, as shown in FIG. 15B, the area is scanned with respect to the input image 36 of the work imaged separately from the reference image 33. From the learning result, the area 37 in the input image 36 is a non-detection area. Yes, it is determined that the region 38 in the input image 36 is a detection target region. That is, by learning the edge extraction process of the image using the data indicating whether or not the specific pixel of the area data cut out from the reference image 33 is an edge as shown in FIG. Detect edges.

特開2009−282928号公報JP 2009-282929 A 特開平5−46764号公報Japanese Patent Laid-Open No. 5-46764

図16(a)の画像に対し、従来の一般的なエッジ抽出を行った結果を以下に示す。つまり、図16(a)の画像に対して行う一般的なエッジ抽出のみでは、図16(b)に示すように背景や物体の傷、照明の輝度ムラ等が原因でノイズが多く出るため、このことが、エッジを使用した位置計測を行う場合などには誤差の要因になる。   The result of performing conventional general edge extraction on the image of FIG. 16A is shown below. That is, since only the general edge extraction performed on the image of FIG. 16A causes a lot of noise due to background and object scratches, uneven brightness of illumination, and the like as shown in FIG. This causes an error when performing position measurement using edges.

ここで、上記特許文献1記載のエッジ検出装置を用いた画像処理方法によると、図16(b)に示すような細かいノイズエッジを除去することは可能である。しかし、図16(c)に示すような二重円形部分を有する画像に対してエッジ抽出した場合には、図16(d)に示すように、円環部の内径と外径とでエッジが夫々に抽出される。なお、図16(d)における符号31は、検出したい検出対象エッジである内径のエッジを示し、符号32は、検出対象ではない非検出対象エッジである外径のエッジを示す。   Here, according to the image processing method using the edge detection apparatus described in Patent Document 1, it is possible to remove fine noise edges as shown in FIG. However, when edge extraction is performed on an image having a double circular portion as shown in FIG. 16C, an edge is formed by the inner and outer diameters of the annular portion as shown in FIG. Extracted to each. Note that reference numeral 31 in FIG. 16D indicates an inner diameter edge that is a detection target edge to be detected, and reference numeral 32 indicates an outer diameter edge that is a non-detection target edge that is not a detection target.

このような画像の場合、内径にも外径にも同様に、強度が強く且つ長いエッジが取れるため、任意の内径エッジのみを検出することは困難である。非検出対象エッジが検出対象エッジに対して形状の相違を持つのであれば、両者を形状の特徴に基づいて分離することは容易である。しかし、非検出対象エッジと検出対象エッジとが類似の形状を示すような場合は、特に検出対象エッジのみを検出することは困難となる。つまり図16(d)に示すように、検出対象エッジ31及び非検出対象エッジ32の双方がともに円形の一部を示すような形状であるため、形状特徴による分離が難しい。   In the case of such an image, both the inner diameter and the outer diameter are similarly strong and have long edges, so that it is difficult to detect only an arbitrary inner diameter edge. If the non-detection target edge has a shape difference with respect to the detection target edge, it is easy to separate the two based on the shape characteristics. However, when the non-detection target edge and the detection target edge show similar shapes, it is particularly difficult to detect only the detection target edge. That is, as shown in FIG. 16D, since both the detection target edge 31 and the non-detection target edge 32 have a circular shape, it is difficult to separate by shape features.

また、上記特許文献2記載のエッジ抽出システムを用いた画像処理方法によると、図16(c)に示すような画像に対しても、予め参照画像に基づいて検出対象のエッジか否かを学習することで、検出対象エッジ31のみを検出することは可能である。しかし、この画像処理方法では、カメラの撮像に用いられる照明装置が劣化するなどで照明条件に変化が生じた場合には、入力画像の輝度変動が大きくなる。そして、予め学習しておいたエッジか否かを示す教師データと入力画像のエッジ領域データとで、輝度変動による差異が生じる。そのため、検出対象エッジ31の検出が不安定になるという不都合を生じる。   Further, according to the image processing method using the edge extraction system described in Patent Document 2, it is learned in advance whether or not the edge is the detection target edge based on the reference image even for the image as shown in FIG. By doing so, it is possible to detect only the detection target edge 31. However, in this image processing method, when the illumination conditions change due to deterioration of the illumination device used for imaging by the camera, the luminance variation of the input image becomes large. Then, a difference due to luminance fluctuation occurs between the teacher data indicating whether the edge has been learned in advance and the edge area data of the input image. For this reason, the detection of the detection target edge 31 becomes unstable.

本発明は、検出対象エッジに対して類似形状の非検出対象エッジを持つような状況下で照明の変化が起こっても、検出対象エッジのみを安定して検出することが可能な画像処理装置、画像処理プログラム、ロボット装置及び画像処理方法を提供することを目的とする。   The present invention relates to an image processing apparatus capable of stably detecting only a detection target edge even when a change in illumination occurs in a situation where the detection target edge has a non-detection target edge having a similar shape to the detection target edge, An object is to provide an image processing program, a robot apparatus, and an image processing method.

本発明は、予めワークを撮像した参照画像上の複数のエッジのそれぞれについて算出された、エッジに対して一定の位置関係にあるサンプリング領域の輝度値からなる特徴量の大小関係を記憶する記憶部と、取得した入力画像上のワークのエッジを抽出するエッジ抽出部と、前記エッジ抽出部によって抽出された各エッジについて前記特徴量を算出する特徴量算出部と、算出された前記入力画像上の各エッジの特徴量から輝度値及び頻度の度数分布を示すヒストグラムを作成し、このヒストグラムの分布状態に基づいて求められた閾値により区分される特徴量の範囲により、前記エッジ抽出工程にて抽出されたエッジを区分するエッジ区分部と、前記閾値によって区分された特徴量の範囲の大小関係と前記記憶部に記憶された特徴量の大小関係とを比較して、対応する大小関係にある特徴量の範囲内の入力画像上のエッジと前記参照画像上でのエッジとを対応付けるエッジ関係設定部と、を備えたことを特徴とする画像処理装置にある。   The present invention stores a magnitude relationship of feature amounts composed of luminance values of a sampling area having a fixed positional relationship with respect to an edge, calculated for each of a plurality of edges on a reference image obtained by imaging a workpiece in advance. An edge extraction unit that extracts an edge of a workpiece on the acquired input image, a feature amount calculation unit that calculates the feature amount for each edge extracted by the edge extraction unit, and a calculated on the input image A histogram showing the frequency distribution of luminance values and frequencies is created from the feature values of each edge, and extracted by the edge extraction step based on the feature value range divided by the threshold value obtained based on the distribution state of the histogram. An edge classifying unit that classifies the detected edge, a magnitude relationship between the range of the feature quantity segmented by the threshold value, and a magnitude relation of the feature quantity stored in the storage unit And an edge relationship setting unit that associates an edge on the input image within the range of the corresponding feature quantity with an edge on the reference image, and an image processing comprising: In the device.

本発明は、コンピュータを、前記画像処理装置として機能させることを特徴とする画像処理プログラムにある。   The present invention resides in an image processing program that causes a computer to function as the image processing apparatus.

本発明は、ワークを照らす照明装置と、前記照明装置に照らされたワークを撮像するカメラと、前記画像処理装置と、前記カメラが撮像した入力画像に基づいて前記画像処理装置が算出した位置情報に基づいて、ワークに対して所定の処理を施す作動アームと、を備えたことを特徴とするロボット装置にある。   The present invention relates to an illumination device that illuminates a workpiece, a camera that captures a workpiece illuminated by the illumination device, the image processing device, and positional information calculated by the image processing device based on an input image captured by the camera. And a working arm that performs a predetermined process on the workpiece.

本発明は、画像処理装置が、予めワークを撮像した参照画像上の複数のエッジのそれぞれについて算出された、エッジに対して一定の位置関係にあるサンプリング領域の輝度値からなる特徴量の大小関係を記憶する記憶工程と、前記画像処理装置が、取得した入力画像上のワークのエッジを抽出するエッジ抽出工程と、前記画像処理装置が、前記エッジ抽出工程にて抽出された各エッジについて前記特徴量を算出する特徴量算出工程と、前記画像処理装置が、算出された前記入力画像上の各エッジの特徴量から輝度値及び頻度の度数分布を示すヒストグラムを作成し、このヒストグラムの分布状態に基づいて求められた閾値により区分される特徴量の範囲により、前記エッジ抽出部によって抽出されたエッジを区分するエッジ区分工程と、前記画像処理装置が、前記閾値によって区分された特徴量の範囲の大小関係と前記記憶工程にて記憶された特徴量の大小関係とを比較して、対応する大小関係にある特徴量の範囲内の入力画像上のエッジと前記参照画像上でのエッジとを対応付けるエッジ関係設定工程と、を備えたことを特徴とする画像処理方法にある。   According to the present invention, the magnitude relationship of the feature amount including the luminance value of the sampling area having a fixed positional relationship with respect to the edge, which is calculated for each of the plurality of edges on the reference image obtained by capturing an image of the workpiece in advance by the image processing apparatus. A storage step for storing the image, an edge extraction step in which the image processing device extracts an edge of a work on the acquired input image, and the image processing device performs the feature for each edge extracted in the edge extraction step. A feature amount calculating step for calculating the amount, and the image processing apparatus creates a histogram indicating the frequency distribution of the luminance value and the frequency from the calculated feature amount of each edge on the input image. An edge segmentation step for segmenting the edge extracted by the edge extraction unit according to a range of feature quantities segmented by the threshold value obtained based on the threshold value; The image processing apparatus compares the size relationship between the feature amount ranges classified by the threshold and the feature relationship stored in the storing step, and determines whether the feature amount range is in the corresponding feature amount range. An image processing method comprising an edge relationship setting step for associating an edge on an input image with an edge on the reference image.

本発明によれば、閾値によって区分された特徴量の範囲の大小関係と、記憶部に記憶された特徴量の大小関係とを比較して、対応する大小関係にある特徴量の範囲内の入力画像上のエッジと、参照画像上でのエッジとを対応付けることができる。そのため、検出対象エッジに対して類似形状の非検出対象エッジを持つような状況下で照明の変化が起こった場合であっても、検出対象のエッジのみを安定して検出することが可能になる。   According to the present invention, the magnitude relationship between the ranges of the feature quantities classified by the threshold value is compared with the magnitude relation of the feature quantities stored in the storage unit, and the input within the corresponding feature quantity range is compared. An edge on the image can be associated with an edge on the reference image. Therefore, even when a change in illumination occurs in a situation where the detection target edge has a non-detection target edge having a similar shape, it is possible to stably detect only the detection target edge. .

(a),(b)は本発明に係る実施の形態の画像処理装置を備えたロボット装置を説明するための図である。(A), (b) is a figure for demonstrating the robot apparatus provided with the image processing apparatus of embodiment concerning this invention. 本実施の形態におけるハード構成を示すブロック図である。It is a block diagram which shows the hardware constitutions in this Embodiment. 本実施の形態における画像処理装置の画像処理部の構成を詳細に示すブロック図である。It is a block diagram which shows in detail the structure of the image processing part of the image processing apparatus in this Embodiment. (a),(b)は本実施の形態を説明するための図である。(A), (b) is a figure for demonstrating this Embodiment. (a),(b),(c),(d)は本実施の形態を説明するための図である。(A), (b), (c), (d) is a figure for demonstrating this Embodiment. (a),(b),(c),(d)は本実施の形態を説明するための図である。(A), (b), (c), (d) is a figure for demonstrating this Embodiment. (a),(b)は本実施の形態を説明するための図である。(A), (b) is a figure for demonstrating this Embodiment. (a),(b)は本実施の形態を説明するための図である。(A), (b) is a figure for demonstrating this Embodiment. (a),(b)は本実施の形態を説明するための図である。(A), (b) is a figure for demonstrating this Embodiment. 本実施の形態を説明するための図である。It is a figure for demonstrating this Embodiment. (a),(b),(c)は本実施の形態を説明するための図である。(A), (b), (c) is a figure for demonstrating this Embodiment. (a),(b)は本実施の形態を説明するための図である。(A), (b) is a figure for demonstrating this Embodiment. 本実施の形態を説明するためのフローチャート図である。It is a flowchart figure for demonstrating this Embodiment. 本実施の形態を説明するためのフローチャート図である。It is a flowchart figure for demonstrating this Embodiment. (a),(b),(c)は従来技術を説明するための図である。(A), (b), (c) is a figure for demonstrating a prior art. (a),(b),(c),(d)は従来技術を説明するための図である。(A), (b), (c), (d) is a figure for demonstrating a prior art.

以下、図面に沿って、本発明に係る実施形態について説明する。まず、図1(a),(b)を参照して、本発明に係る画像処理装置及びこの画像処理装置を備えるロボット装置について説明するが、本発明に係る画像処理方法については、画像処理装置及びロボット装置の説明を通して説明されるものとする。なお、図1(a)は画像処理装置を備えるロボット装置100におけるカメラ1及び画像処理部2を用いて載置部4上の検出対象ワーク3からエッジを検出する際の概略構成図であり、図1(b)はロボット装置100の全体を示す斜視図である。   Hereinafter, embodiments according to the present invention will be described with reference to the drawings. First, an image processing apparatus according to the present invention and a robot apparatus including the image processing apparatus will be described with reference to FIGS. 1A and 1B. The image processing method according to the present invention is described below. And the explanation of the robot apparatus. FIG. 1A is a schematic configuration diagram when an edge is detected from the workpiece 3 to be detected on the placement unit 4 using the camera 1 and the image processing unit 2 in the robot apparatus 100 including the image processing apparatus. FIG. 1B is a perspective view showing the entire robot apparatus 100.

図1(a),(b)に示すように、ロボット装置100は、検出対象ワーク(ワーク)3を照らす照明装置105と、照明装置105に照らされた検出対象ワーク3を撮像するカメラ1とを備えている。更に、ロボット装置100は、コンピュータ19により構成される画像処理装置と、カメラ1が撮像した入力画像に基づいて画像処理装置が算出した位置情報に基づいて、検出対象ワーク3に対して所定の処理を施す作動アーム102とを備えている。   As shown in FIGS. 1A and 1B, the robot apparatus 100 includes a lighting device 105 that illuminates a detection target work (work) 3, and a camera 1 that images the detection target work 3 illuminated by the lighting device 105. It has. Furthermore, the robot apparatus 100 performs predetermined processing on the detection target workpiece 3 based on an image processing apparatus configured by the computer 19 and position information calculated by the image processing apparatus based on an input image captured by the camera 1. And an actuating arm 102 for applying

即ち、ロボット装置100は、複数の枠部材104によって形成されたブース103と、ブース103の下部中央に配置された架台101とを備えている。さらに、架台101上部に配置された作動アーム102と、作動アーム102に対向する位置に配置された状態で検出対象ワーク3を載置する載置部4とを備えている。架台101内には、画像処理部2等を有するコンピュータ19が配設されている。ブース103における作動アーム102の上方には、撮像手段としてのカメラ1と、このカメラ1の両隣りに配置された照明装置105とが配設されている。作動アーム102は、多関節シリアルリンクロボットから成り、その各関節は、コンピュータ19に基づくモータ駆動によりアーム先端部102aの位置及び姿勢が制御される。   In other words, the robot apparatus 100 includes a booth 103 formed by a plurality of frame members 104 and a gantry 101 disposed at the lower center of the booth 103. Furthermore, an operating arm 102 disposed on the top of the gantry 101 and a mounting unit 4 for mounting the workpiece 3 to be detected in a state of being disposed at a position facing the operating arm 102 are provided. A computer 19 having an image processing unit 2 and the like is disposed in the gantry 101. Above the operation arm 102 in the booth 103, a camera 1 as an imaging unit and an illumination device 105 arranged on both sides of the camera 1 are disposed. The operating arm 102 is composed of an articulated serial link robot, and the position and posture of the arm tip 102 a are controlled by a motor drive based on the computer 19.

カメラ1は、不図示のレンズにより光像を形成し、不図示の撮像素子により光像を撮像信号に変換し、この撮像信号を、エッジの検出対象である入力画像として画像処理部2に提供する撮像手段を構成している。   The camera 1 forms an optical image with a lens (not shown), converts the optical image into an imaging signal with an imaging element (not shown), and provides the imaging signal to the image processing unit 2 as an input image that is an edge detection target. The imaging means to perform is comprised.

図1(a)に示すように、アーム先端部102aに取り付けられたハンド部102bは、検出対象ワーク(ワーク)3を把持及び解放し得るように構成されている。ハンド部102bは、把持した検出対象ワーク3の位置・姿勢を修正するのに十分な範囲においての、手首に相当する関節での回転機構や多関節指機構等の制御機構を備えている。このようなハンド部102bを有する作動アーム102の駆動制御は、カメラ1からの撮像データに基づく画像処理部2、及びこの画像処理部2からのデータを用いるコンピュータ19によって実現される。   As shown in FIG. 1A, the hand portion 102b attached to the arm tip portion 102a is configured to be able to grip and release the workpiece 3 to be detected (workpiece). The hand unit 102b includes a control mechanism such as a rotation mechanism at a joint corresponding to the wrist or a multi-joint finger mechanism within a range sufficient to correct the position / posture of the gripped detection target workpiece 3. Such drive control of the operating arm 102 having the hand unit 102b is realized by the image processing unit 2 based on the imaging data from the camera 1 and the computer 19 using the data from the image processing unit 2.

図2に示すように、コンピュータ19のコンピュータ本体19aには、CPU5を主体として機能する画像処理部2等が収納されている。CPU5には、画像処理部2の他に、RAM29及びROM30等がバス7を介して接続されている。RAM29には、CPU5に対する作業領域が確保される。ROM30には、コンピュータ19の基本制御に必要なプログラムが格納されている。画像処理部2は、後述する画像処理機能の他、CPU5からの描画指示に応じて液晶等のディスプレイ40を制御して所定の画像を表示させる機能を備える。コンピュータ19における上記ROM30には、コンピュータ19を画像処理装置として機能させるための画像処理プログラムが格納されている。   As shown in FIG. 2, a computer main body 19a of a computer 19 houses an image processing unit 2 and the like that mainly function as a CPU 5. In addition to the image processing unit 2, a RAM 29 and a ROM 30 are connected to the CPU 5 via the bus 7. A working area for the CPU 5 is secured in the RAM 29. The ROM 30 stores a program necessary for basic control of the computer 19. The image processing unit 2 has a function of displaying a predetermined image by controlling the display 40 such as a liquid crystal according to a drawing instruction from the CPU 5 in addition to an image processing function described later. The ROM 30 in the computer 19 stores an image processing program for causing the computer 19 to function as an image processing apparatus.

CPU5には、バス7に接続された入力インターフェース(インターフェイス)41を介して、入力装置としてのキーボード42及びマウス43が接続されており、エッジ検出等に必要な指定情報、メニュー選択指示、あるいはその他の指示の入力を可能としている。また、CPU5には、バス7に接続された入力インターフェース47を介して、カメラ1が接続されている。そして、バス7には、記録ディスク読取装置44が接続されており、種々の情報を記録した記録媒体45を読み込み、例えばROM30に格納できるようになっている。また、バス7には、通信装置46が接続されており、上述のような記録媒体45を使用せずに、通信装置46を介してインターネット等から配信される種々の情報をダウンロード可能に構成されている。   A keyboard 42 and a mouse 43 as input devices are connected to the CPU 5 via an input interface (interface) 41 connected to the bus 7. Specification information necessary for edge detection and the like, menu selection instructions, and others It is possible to input instructions. In addition, the camera 1 is connected to the CPU 5 via an input interface 47 connected to the bus 7. A recording disk reader 44 is connected to the bus 7 so that a recording medium 45 on which various information is recorded can be read and stored in, for example, the ROM 30. In addition, a communication device 46 is connected to the bus 7 so that various information distributed from the Internet or the like via the communication device 46 can be downloaded without using the recording medium 45 as described above. ing.

ここで、図3を参照して、コンピュータ19内の画像処理部2の詳細について説明する。即ち、図3に示すように、画像処理部2は、特徴量相対関係記憶部8、入力画像記憶部9、エッジ画像記憶部10、エッジ特徴量記憶部51、特徴量ヒストグラム記憶部11、及びエッジ‐特徴量対応記憶部12を有している。エッジ‐特徴量対応記憶部12は、選択部12aと位置算出部12bとを有している。   Here, the details of the image processing section 2 in the computer 19 will be described with reference to FIG. That is, as shown in FIG. 3, the image processing unit 2 includes a feature amount relative relationship storage unit 8, an input image storage unit 9, an edge image storage unit 10, an edge feature amount storage unit 51, a feature amount histogram storage unit 11, and An edge-feature quantity correspondence storage unit 12 is provided. The edge-feature amount correspondence storage unit 12 includes a selection unit 12a and a position calculation unit 12b.

このような画像処理部2では、カメラ1から提供された入力画像が入力画像記憶部9に記憶され、またCPU5は、バス7を介して各記憶部8〜12,51に適時アクセスして各処理を実行する。   In such an image processing unit 2, the input image provided from the camera 1 is stored in the input image storage unit 9, and the CPU 5 accesses each storage unit 8 to 12, 51 via the bus 7 in a timely manner and Execute the process.

CPU5及び特徴量相対関係記憶部8により、記憶部が構成されている。記憶部は、予め検出対象ワーク3を撮像した参照画像上の複数のエッジ(14,15)の夫々について算出された、エッジに対して一定の位置関係にあるサンプリング領域20〜22(図5参照)の輝度値kからなる特徴量K,N1,N2の大小関係を記憶する。   The CPU 5 and the feature amount relative relationship storage unit 8 constitute a storage unit. The storage unit is calculated for each of the plurality of edges (14, 15) on the reference image obtained by capturing the detection target workpiece 3 in advance, and sampling regions 20 to 22 having a fixed positional relationship with respect to the edges (see FIG. 5). ) Is stored in the magnitude relationship between the feature values K, N1, and N2.

即ち、特徴量相対関係記憶部8は、CPU5の指示に従って、参照画像13から、検出対象の検出対象エッジ14と検出対象以外の非検出対象エッジ15とに対し一定の位置関係にあるサンプリング領域20,21,22の輝度値kを算出する。そして、後述の特徴量算出部で算出された特徴量K、特徴量N1,N2として記憶する。その際、検出対象エッジ14の特徴量Kと非検出対象エッジ15の特徴量N1,N2との大小関係を記憶する。つまり、特徴量相対関係記憶部8は、CPU5の指示に従って、照明状態で撮像された検出対象ワーク3の参照画像13から、上記エッジ14,15に対して一定の位置関係にあるサンプリング領域20〜22毎の平均輝度値(k)をそれぞれ算出する。そして、検出対象エッジ14に対応する特徴量Kと非検出対象エッジ15に対応する特徴量N1,N2として設定すると共に、それら特徴量K,N1,N2の大小関係を記憶する。特徴量相対関係記憶部8は、大小関係を、例えば後述の大小関係フラグ(flag)の「1」「2」「3」として記憶する。   In other words, the feature amount relative relationship storage unit 8 follows the instruction of the CPU 5 from the reference image 13 to the sampling region 20 having a fixed positional relationship with respect to the detection target edge 14 as the detection target and the non-detection target edge 15 other than the detection target. , 21 and 22 are calculated. And it memorize | stores as the feature-value K calculated by the feature-value calculation part mentioned later, and feature-value N1, N2. At that time, the magnitude relationship between the feature value K of the detection target edge 14 and the feature values N1 and N2 of the non-detection target edge 15 is stored. That is, the feature amount relative relationship storage unit 8 is based on the sampling region 20 to the sampling region 20 to a certain positional relationship with respect to the edges 14 and 15 from the reference image 13 of the detection target work 3 imaged in the illumination state according to the instruction of the CPU 5. An average luminance value (k) for every 22 is calculated. Then, the feature quantity K corresponding to the detection target edge 14 and the feature quantities N1 and N2 corresponding to the non-detection target edge 15 are set, and the magnitude relation between the feature quantities K, N1 and N2 is stored. The feature amount relative relationship storage unit 8 stores the size relationship as, for example, “1”, “2”, and “3” of a size relationship flag (flag) described later.

入力画像記憶部9は、CPU5の指示に従って、カメラ1から提供された入力画像を記憶する。CPU5は、カメラ1から提供された入力画像から、検出対象の画像の比較対象となるワーク画像である参照画像13(図4参照)を作成して、入力画像記憶部9に記憶させる。   The input image storage unit 9 stores an input image provided from the camera 1 in accordance with an instruction from the CPU 5. The CPU 5 creates a reference image 13 (see FIG. 4), which is a work image to be compared with the detection target image, from the input image provided from the camera 1 and stores the reference image 13 in the input image storage unit 9.

CPU5及びエッジ画像記憶部10により、取得した入力画像上の検出対象ワーク3のエッジを抽出するエッジ抽出部が構成されている。即ち、エッジ画像記憶部10は、CPU5の指示に従って、検出対象画像や参照画像からエッジを検出してその画像を記憶する。   The CPU 5 and the edge image storage unit 10 constitute an edge extraction unit that extracts the edge of the detection target workpiece 3 on the acquired input image. That is, the edge image storage unit 10 detects an edge from the detection target image or the reference image in accordance with an instruction from the CPU 5 and stores the image.

CPU5及びエッジ特徴量記憶部51により、上記エッジ抽出部(5,10)によって抽出された各エッジについて特徴量K、特徴量N1,N2を算出する特徴量算出部が構成されている。即ち、エッジ特徴量記憶部51は、CPU5の指示に従って、抽出された各エッジにおける特徴量K、特徴量N1,N2を算出する。   The CPU 5 and the edge feature amount storage unit 51 constitute a feature amount calculation unit that calculates the feature amount K and the feature amounts N1 and N2 for each edge extracted by the edge extraction unit (5, 10). That is, the edge feature amount storage unit 51 calculates the feature amount K and the feature amounts N1 and N2 at each extracted edge in accordance with an instruction from the CPU 5.

CPU5及び特徴量ヒストグラム記憶部11により、エッジ区分部が構成されている。エッジ区分部は、算出された入力画像上の各エッジの特徴量から輝度値及び頻度の度数分布を示す特徴量ヒストグラムを作成し、このヒストグラムの分布状態に基づき求められた閾値で区分される特徴量の範囲により、エッジ抽出部にて抽出されたエッジを区分する。   The CPU 5 and the feature amount histogram storage unit 11 constitute an edge division unit. The edge segmentation unit creates a feature amount histogram indicating the frequency distribution of the luminance value and frequency from the calculated feature amount of each edge on the input image, and is classified by the threshold value obtained based on the distribution state of the histogram. The edges extracted by the edge extraction unit are classified according to the amount range.

即ち、特徴量ヒストグラム記憶部11は、上記特徴量算出部(5,51)によって得られたエッジの特徴量K,N1,N2に基づき、CPU5の指示に従って特徴量ヒストグラムを作成する。そして、このヒストグラムから閾値を決定(設定)して記憶すると共に、この閾値により区分される特徴量の範囲により、上記エッジ抽出部で抽出されたエッジを区分する。   That is, the feature amount histogram storage unit 11 creates a feature amount histogram according to instructions from the CPU 5 based on the edge feature amounts K, N1, and N2 obtained by the feature amount calculation unit (5, 51). Then, the threshold value is determined (set) from the histogram and stored, and the edge extracted by the edge extraction unit is classified according to the range of the feature amount classified by the threshold value.

CPU5及びエッジ‐特徴量対応記憶部12により、エッジ関係設定部が構成されている。エッジ関係設定部は、上記閾値によって区分された特徴量の範囲の大小関係と、上記記憶部(5,8)に記憶された特徴量K,N1,N2の大小関係(特徴相対関係)とを比較する。そして、対応する大小関係にある特徴量の範囲内の入力画像上のエッジと、参照画像13上でのエッジ(14,15)とを対応付ける。   The CPU 5 and the edge-feature amount correspondence storage unit 12 constitute an edge relationship setting unit. The edge relationship setting unit calculates the size relationship between the ranges of the feature amounts classified by the threshold value and the size relationship (feature relative relationship) of the feature amounts K, N1, and N2 stored in the storage unit (5, 8). Compare. Then, the edge on the input image within the range of the corresponding feature quantity in the size relationship is associated with the edge (14, 15) on the reference image 13.

即ち、エッジ‐特徴量対応記憶部12は、CPU5の指示に従って、エッジ‐特徴量の対応表(図8(b)参照)を記憶し、検出対象エッジ14の特徴量範囲と非検出対象エッジ15の特徴量範囲とを分離し区別する。そして、検出対象エッジ14の特徴量範囲内の特徴量を持つエッジを検出対象のエッジとして選択する。つまり、エッジ‐特徴量対応記憶部12は、今回検出するべき検出対象ワーク3の検出対象エッジ14の特徴量Kの範囲を決定する。   That is, the edge-feature amount correspondence storage unit 12 stores an edge-feature amount correspondence table (see FIG. 8B) in accordance with an instruction from the CPU 5, and the feature amount range of the detection target edge 14 and the non-detection target edge 15. The feature amount range is separated and distinguished. Then, an edge having a feature amount within the feature amount range of the detection target edge 14 is selected as the detection target edge. That is, the edge-feature amount correspondence storage unit 12 determines the range of the feature amount K of the detection target edge 14 of the detection target workpiece 3 to be detected this time.

上記選択部12aは、上記エッジ関係設定部(5,12)によって設定されたエッジの対応関係に基づいて、検出対象の検出対象エッジ14を入力画像上にて選択する。また、上記位置算出部12bは、選択部12aによって選択されたエッジから検出対象ワーク3の位置情報を算出する。   The selection unit 12a selects the detection target edge 14 to be detected on the input image based on the edge correspondence set by the edge relationship setting unit (5, 12). The position calculation unit 12b calculates the position information of the detection target workpiece 3 from the edge selected by the selection unit 12a.

以下、図13及び図14を参照して、本実施形態の詳細について説明する。図13は、本実施の形態におけるメインフローを示すフローチャートであり、図14は、ステップS2のエッジ特徴量大小関係処理のサブルーチンを示すフローチャートである。   Hereinafter, details of the present embodiment will be described with reference to FIGS. 13 and 14. FIG. 13 is a flowchart showing a main flow in the present embodiment, and FIG. 14 is a flowchart showing a subroutine of the edge feature quantity magnitude relation processing in step S2.

まず、図13において処理がスタートすると、オフラインで教示を行う。つまり、予めカメラ1で検出対象ワーク3を撮像した参照画像13を入力する。そして、画像処理部2に接続されたディスプレイ40に表示した状態で、オペレータは、検出したい検出対象エッジ14のみを選択するための教示の操作を、マウス43を使用して行う(ステップS1)。   First, when the process starts in FIG. 13, teaching is performed offline. That is, the reference image 13 obtained by capturing the detection target workpiece 3 with the camera 1 in advance is input. Then, in the state displayed on the display 40 connected to the image processing unit 2, the operator performs a teaching operation using the mouse 43 to select only the detection target edge 14 desired to be detected (step S1).

ステップS2では、CPU5及び特徴量相対関係記憶部8により、エッジ特徴量K、N1、N2の大小関係を判定する。エッジ特徴量大小関係の判定処理は、図14におけるステップS2-1において、特徴量の計算に用いるエッジを参照画像13から選択し、ステップS2-2において、検出対象エッジ14の特徴量をK、非検出対象エッジ15の特徴量をN1,N2として計算する。つまり、上記特徴量算出部(5,51)が、上記エッジ抽出部(5,10)によって抽出された各エッジについて特徴量K、特徴量N1,N2を算出する。   In step S2, the CPU 5 and the feature quantity relative relationship storage unit 8 determine the magnitude relation between the edge feature quantities K, N1, and N2. In step S2-1 in FIG. 14, the edge feature amount magnitude determination process selects an edge to be used for calculating the feature amount from the reference image 13, and in step S2-2, sets the feature amount of the detection target edge 14 to K, The feature amounts of the non-detection target edge 15 are calculated as N1 and N2. That is, the feature quantity calculation unit (5, 51) calculates the feature quantity K and the feature quantities N1, N2 for each edge extracted by the edge extraction unit (5, 10).

即ち、図4(a),(b)に示すように、参照画像13において検出したいエッジを最内径の検出対象エッジ14とし、その他の検出を望まないエッジを非検出対象エッジ15とする。教示は、オペレータがディスプレイ40の画面を見ながらマウス43を使用して行うが、その具体的な方法は下記に示す。   That is, as shown in FIGS. 4A and 4B, the edge to be detected in the reference image 13 is set as the detection target edge 14 having the innermost diameter, and the other edge that is not desired to be detected is set as the non-detection target edge 15. Teaching is performed using the mouse 43 while the operator looks at the screen of the display 40, and a specific method thereof will be described below.

まず、ステップS2-1において、ディスプレイ40に表示された図4(a)の参照画像13に対し、次のように操作する。つまり、図4(b)のように検出対象エッジ14上の適宜の点17と、非検出対象エッジ15上の適宜の点18、及び、中心付近の一点である点16の各位置を、夫々マウスポインタにより設定する。このマウスポインタによる設定とは、マウスポインタが指している参照画像13上の座標情報(x,y)を画像処理部2に送信することを意味する。   First, in step S2-1, the reference image 13 shown in FIG. 4A displayed on the display 40 is operated as follows. That is, as shown in FIG. 4B, the respective positions of the appropriate point 17 on the detection target edge 14, the appropriate point 18 on the non-detection target edge 15, and the point 16 that is one point near the center are respectively set. Set with the mouse pointer. This setting with the mouse pointer means that coordinate information (x, y) on the reference image 13 pointed to by the mouse pointer is transmitted to the image processing unit 2.

そしてステップS2-2では、参照画像13に対して設定した上記の位置(点16,17,18)から一定の位置関係にある領域の輝度値をサンプリングし、その領域の輝度値の平均を算出する。一定の位置関係にある領域については以下に示す。   In step S2-2, the luminance value of a region having a certain positional relationship is sampled from the above-described position (points 16, 17, and 18) set with respect to the reference image 13, and the average of the luminance values of the region is calculated. To do. A region having a certain positional relationship is shown below.

まず、図5(a)に示すように、前記設定した中心付近の点16を基準点とし、この基準点(16)と前記設定したエッジ上の点17とを結ぶ直線と、参照画像13のy軸(図の上下方向)とで成す角度θを求める。   First, as shown in FIG. 5A, a point 16 near the set center is set as a reference point, a straight line connecting the reference point (16) and the point 17 on the set edge, and a reference image 13 An angle θ formed with the y-axis (vertical direction in the figure) is obtained.

ついで、図5(b)に示すように、前記エッジ上の点17が矩形の底辺の中心となる位置に、マウスを用いて矩形のサンプリング領域20を設定する。そして図5(c)のように、エッジ上の点17を固定点として求めた直線の角度θだけ、矩形のサンプリング領域20を時計方向に回転させ、非検出対象エッジ15上の点18(図4(b))に対しても、図5(d)のようにサンプリング領域21,22を設定する。そして、上記と同様に点18を固定点として求めた直線の角度だけ、矩形のサンプリング領域21,22を図の時計方向に回転させる。   Next, as shown in FIG. 5B, a rectangular sampling region 20 is set using a mouse at a position where the point 17 on the edge is the center of the bottom of the rectangle. Then, as shown in FIG. 5C, the rectangular sampling region 20 is rotated clockwise by the angle θ of the straight line obtained with the point 17 on the edge as a fixed point, and a point 18 on the non-detection target edge 15 (FIG. 4 (b)), sampling areas 21 and 22 are set as shown in FIG. Similarly to the above, the rectangular sampling areas 21 and 22 are rotated in the clockwise direction in the drawing by the angle of the straight line obtained with the point 18 as a fixed point.

このように、本実施形態では、サンプリング領域20,21,22を、検出対象エッジ14及び非検出対象エッジ15の一方側においてそのエッジ(14,15)の接線に接する位置関係となるように設定する。つまり、検出対象ワーク3が円形のエッジで構成される場合、上記矩形のサンプリング領域21,22において、次のように処理する。まず、抽出された各エッジ上の任意の一点を選択し、検出対象ワーク3における中心付近の一点16を基準点として、基準点(16)と各エッジ上の任意の一点とを結ぶ直線とで成す角度θを求める。さらに、各エッジ上の任意の一点に設定した領域を角度θに相当する角度だけ回転させることで、隣接する検出対象エッジ14の領域と非検出対象エッジ15の領域とが交差しないように設定する。   As described above, in this embodiment, the sampling regions 20, 21, and 22 are set so as to be in a positional relationship in contact with the tangent line of the edge (14, 15) on one side of the detection target edge 14 and the non-detection target edge 15. To do. That is, when the workpiece 3 to be detected is configured with a circular edge, the following processing is performed in the rectangular sampling areas 21 and 22. First, an arbitrary one point on each extracted edge is selected, and a straight line connecting the reference point (16) and any one point on each edge with the one point 16 near the center of the workpiece 3 to be detected as a reference point. The formed angle θ is obtained. Furthermore, by rotating an area set at an arbitrary point on each edge by an angle corresponding to the angle θ, the area of the adjacent detection target edge 14 and the area of the non-detection target edge 15 are set so as not to intersect. .

なお、ここまでは、検出対象のエッジが円形の場合について説明したが、検出対象のエッジが直線である場合には、下記の方法により、一定の位置関係にある領域を求めることができる。   Up to this point, the case where the detection target edge is circular has been described. However, when the detection target edge is a straight line, an area having a certain positional relationship can be obtained by the following method.

即ち、検出対象である計測対象ワークのエッジが、図6(a)に示すように直線的なエッジで構成される場合、例えば正方形を構成するような場合も、上記と同様に処理する。つまり、検出対象エッジ23上の点23a、非検出対象エッジ24上の点24a、及び、中心付近の一点である点25の位置を、それぞれマウスポインタで設定する。そして、図6(b)の破線で示すように設定したエッジ23,24上の各点23a,24aを中心とした領域のエッジを抽出し、そのエッジの画像のx軸(図の左右方向)に対する角度を求める。   That is, when the edge of the workpiece to be measured, which is the detection target, is configured with a straight edge as shown in FIG. That is, the positions of the point 23a on the detection target edge 23, the point 24a on the non-detection target edge 24, and the point 25, which is one point near the center, are respectively set with the mouse pointer. Then, the edge of the area centered on each point 23a, 24a on the edge 23, 24 set as shown by the broken line in FIG. 6B is extracted, and the x-axis of the image of the edge (the horizontal direction in the figure) Find the angle to.

つまり、エッジ上の点23a,24aが矩形の底辺の中心となる位置に矩形のサンプリング領域を設定し(図6(a))、この領域の大きさを、検出対象エッジに対して作成した矩形のサンプリング領域が隣接する非検出対象エッジと交差しないように設定する。例えば、検出対象エッジと隣接する非検出対象エッジ間の幅がLピクセル程度である場合は、矩形の一辺の大きさをL/2とする。また、設定する領域は、矩形のサンプリング領域に限らず円領域や楕円領域でもよい。   That is, a rectangular sampling region is set at a position where the points 23a and 24a on the edge are the center of the bottom of the rectangle (FIG. 6A), and the size of this region is a rectangle created for the detection target edge. Are set so as not to intersect the adjacent non-detection target edge. For example, when the width between the non-detection target edges adjacent to the detection target edge is about L pixels, the size of one side of the rectangle is set to L / 2. The area to be set is not limited to the rectangular sampling area, but may be a circular area or an elliptical area.

さらに、上記設定した矩形のサンプリング領域を、図6(c)に示すように前記エッジ上の点23a,24aを固定点として、前記求めたエッジの角度分だけ回転させる。この回転をさせる際に、図6(d)に示すように、矩形のサンプリング領域の上辺の中心位置28が基準位置26から遠ざかる方向へ回転させる。   Further, as shown in FIG. 6 (c), the set rectangular sampling area is rotated by the determined edge angle with the points 23a and 24a on the edge as fixed points. When this rotation is performed, the center position 28 of the upper side of the rectangular sampling area is rotated in a direction away from the reference position 26 as shown in FIG.

図6(d)のような場合は、エッジの角度がx軸に対して90度であるため、回転方向がプラス90度とマイナス90度の2つが考えられる。右周りの方向をプラスとすると、矩形のサンプリング領域の上辺の中心位置(中心点)28が基準位置(基準点)26から遠ざかるのはプラス90度方向であるため、プラス90度回転させる。実際の判断は、両方の回転を行い、基準位置26と上辺中心位置28との距離を計算し、距離が長いほうの回転方向を採用することにより行う。   In the case of FIG. 6D, the angle of the edge is 90 degrees with respect to the x-axis, so two rotation directions of plus 90 degrees and minus 90 degrees are conceivable. Assuming that the clockwise direction is plus, the center position (center point) 28 of the upper side of the rectangular sampling area is away from the reference position (reference point) 26 in the plus 90 degree direction, so that it is rotated plus 90 degrees. The actual judgment is made by performing both rotations, calculating the distance between the reference position 26 and the upper side center position 28, and adopting the rotation direction with the longer distance.

このように、検出対象ワーク3が直線的なエッジで構成される場合、矩形のサンプリング領域において、抽出された各エッジ上の任意の一点を選択し、選択した前記任意の一点の近傍のエッジ角度を求める。さらに、各エッジ上の任意の一点に設定した領域をエッジ角度に相当する角度分だけ回転させることで、隣接する検出対象エッジ14の領域と非検出対象エッジ15の領域とが交差しないように設定する。   In this way, when the detection target workpiece 3 is composed of straight edges, an arbitrary point on each extracted edge is selected in a rectangular sampling area, and an edge angle near the selected arbitrary point is selected. Ask for. Further, the region set to an arbitrary point on each edge is rotated by an angle corresponding to the edge angle so that the region of the adjacent detection target edge 14 and the region of the non-detection target edge 15 do not cross each other. To do.

領域を設定した後、前述したように参照画像から設定した各領域内の輝度平均値を算出する。この輝度平均値は、一領域内の輝度値の総和を領域の面積で割ることによって算出することができる。前記算出した検出対象エッジの領域と、非検出対象エッジの領域との輝度平均値を、それぞれのエッジの特徴量とする。特徴量とする値は、領域の輝度平均値に限らず、領域の輝度の中央値、領域の中心一画素の輝度値(代表画素の輝度値)とすることもできる。   After the area is set, the luminance average value in each area set from the reference image is calculated as described above. The average luminance value can be calculated by dividing the total luminance value in one area by the area of the area. The calculated luminance average value of the detection target edge region and the non-detection target edge region is used as the feature amount of each edge. The value as the feature amount is not limited to the average luminance value of the region, but may be a median value of the luminance of the region or a luminance value of one central pixel of the region (a luminance value of the representative pixel).

この後、ステップS2-3において、特徴量K>特徴量N1>特徴量N2である場合には、大小関係フラグ(flag)=1と設定し、特徴量相対関係記憶部8に記憶する(ステップS2-6)。   After that, in step S2-3, if feature quantity K> feature quantity N1> feature quantity N2, the magnitude relation flag (flag) = 1 is set and stored in the feature quantity relative relationship storage unit 8 (step S2-3). S2-6).

また、ステップS2-4において、特徴量N1>特徴量K>特徴量N2である場合には、大小関係フラグ(flag)=2と設定し、特徴量相対関係記憶部8に記憶する(ステップS2-7)。   In step S2-4, if feature quantity N1> feature quantity K> feature quantity N2, the magnitude relation flag (flag) = 2 is set and stored in the feature quantity relative relationship storage unit 8 (step S2). -7).

また、ステップS2-5において、特徴量N1>特徴量N2>特徴量Kである場合には、大小関係フラグ(flag)=3として設定し、特徴量相対関係記憶部8に記憶する(ステップS2-8)。   In step S2-5, if feature quantity N1> feature quantity N2> feature quantity K, the magnitude relation flag (flag) = 3 is set and stored in the feature quantity relative relationship storage unit 8 (step S2). -8).

以上のステップS2-3〜S2-8では、検出対象エッジ14の特徴量と非検出対象エッジ15の特徴量との大小関係を算出して特徴量相対関係記憶部8に記憶する処理を行った。つまり、画像の輝度値が大きいと白に近く、小さいと黒くなる。このため、本実施形態では、図5(d)に示す検出対象エッジ14の領域の特徴量Kが非検出対象エッジ15の矩形のサンプリング領域21,22の特徴量N1,N2より大きいという旨を、特徴量相対関係記憶部8に記憶しておく。言い換えると、検出対象エッジ14の特徴量K>非検出対象エッジ15の特徴量N1>非検出対象エッジ15の特徴量N2、であるという旨を特徴量相対関係記憶部8に記憶しておく。   In the above steps S2-3 to S2-8, the size relationship between the feature amount of the detection target edge 14 and the feature amount of the non-detection target edge 15 is calculated and stored in the feature amount relative relationship storage unit 8. . That is, when the luminance value of the image is large, it is close to white, and when it is small, the image becomes black. For this reason, in the present embodiment, the feature quantity K of the area of the detection target edge 14 shown in FIG. 5D is larger than the feature quantities N1 and N2 of the rectangular sampling areas 21 and 22 of the non-detection target edge 15. And stored in the feature quantity relative relationship storage unit 8. In other words, the feature amount relative relationship storage unit 8 stores that the feature amount K of the detection target edge 14> the feature amount N1 of the non-detection target edge 15> the feature amount N2 of the non-detection target edge 15.

具体的には、特徴量の大小関係は、下記3通りの第1〜第3の状態(1)〜(3)が考えられる。
(1)検出対象エッジ14の特徴量Kが最も大きいとき、即ち、検出対象エッジ14の特徴量K>非検出対象エッジ15の特徴量N1>非検出対象エッジ15の特徴量N2、であるとき。
(2)検出対象エッジ14の特徴量Kが2番目に大きいとき、即ち、非検出対象エッジ15の特徴量N1>検出対象エッジ14の特徴量K>非検出対象エッジ15の特徴量N2、であるとき。
(3)検出対象エッジ14の特徴量Kが最も小さいとき、即ち、非検出対象エッジ15の特徴量N1>非検出対象エッジ15の特徴量N2>検出対象エッジ14の特徴量K、であるとき。
Specifically, the following three first to third states (1) to (3) can be considered as the magnitude relationship of the feature amounts.
(1) When the feature quantity K of the detection target edge 14 is the largest, that is, when the feature quantity K of the detection target edge 14> feature quantity N1 of the non-detection target edge 15> feature quantity N2 of the non-detection target edge 15 .
(2) When the feature value K of the detection target edge 14 is the second largest, that is, the feature value N1 of the non-detection target edge 15> the feature value K of the detection target edge 14> the feature value N2 of the non-detection target edge 15 One day.
(3) When the feature quantity K of the detection target edge 14 is the smallest, that is, when the feature quantity N1 of the non-detection target edge 15> feature quantity N2 of the non-detection target edge 15> feature quantity K of the detection target edge 14 .

上記3通りの内のどの状態かを記憶しておく。そのため、特徴量相対関係記憶部8には、第1の状態(1)の場合はフラグ1を(S2-3,S2-6)、第2の状態(2)の場合はフラグ2を(S2-4,S2-7)、第3の状態(3)の場合はフラグ3を(S2-5,S2-8)を格納しておくだけでよい。つまり、特徴量相対関係記憶部8は、参照画像13を入力として特徴量の算出を行い、特徴量K,N1,N2の大小関係を表した値(フラグの1、2、3のいずれか)を出力とする。   One of the above three states is stored. Therefore, the feature quantity relative relationship storage unit 8 stores the flag 1 in the first state (1) (S2-3, S2-6), and the flag 2 in the second state (2) (S2). -4, S2-7), and in the third state (3), it is only necessary to store the flag 3 in (S2-5, S2-8). That is, the feature quantity relative relationship storage unit 8 calculates a feature quantity using the reference image 13 as an input, and represents a magnitude relationship between the feature quantities K, N1, and N2 (any one of flags 1, 2, and 3). Is output.

以上のようなエッジ特徴量の大小関係処理の後、ステップS3において、検出対象の画像を入力する。つまり、ステップS3は、検出対象となる検出対象ワーク3の入力画像に対して、実際にオンラインで行う検出工程であり、このステップS3にて、カメラ1により検出対象となる検出対象ワーク3の画像を入力し、入力画像記憶部9に記憶しておく。   After the edge feature amount magnitude relation processing as described above, an image to be detected is input in step S3. That is, step S3 is a detection process that is actually performed online with respect to the input image of the detection target work 3 that is the detection target. In step S3, the image of the detection target work 3 that is the detection target by the camera 1 Is stored in the input image storage unit 9.

そして、ステップS4において、CPU5及びエッジ画像記憶部10からなるエッジ抽出部により、エッジを抽出する。つまり、このステップS4にて、エッジ抽出部は、ステップS3で入力された検出対象ワーク3の入力画像に対し、例えば代表的な手法であるソーベル(SobeL)フィルタを使用して、エッジの抽出を行う。エッジ抽出フィルタとしては様々なものが知られているが、SobeLフィルタ以外のものを使用しても良い。   In step S4, an edge is extracted by an edge extraction unit including the CPU 5 and the edge image storage unit 10. That is, in this step S4, the edge extraction unit extracts edges by using, for example, a Sobel (SobeL) filter which is a typical technique for the input image of the workpiece 3 to be detected input in step S3. Do. Various edge extraction filters are known, but filters other than the SobeL filter may be used.

エッジ抽出では、物体の輪郭を抽出することができる。つまり、図7(a)に示す入力画像をエッジ抽出すると、図7(b)に示すような画像となる。また、実際の画像では、背景やワークの傷、照明のムラ等、様々な原因により細かなノイズエッジが出てくる。しかし、図7(b)に示すエッジ抽出後の画像は、エッジの長さを基準にして、短いエッジをノイズエッジとして除去した後のエッジ画像として、エッジ画像記憶部10に記憶される。   In edge extraction, the contour of an object can be extracted. That is, when the edge of the input image shown in FIG. 7A is extracted, an image as shown in FIG. 7B is obtained. In an actual image, fine noise edges appear due to various causes such as scratches on the background and work, uneven illumination, and the like. However, the image after edge extraction shown in FIG. 7B is stored in the edge image storage unit 10 as an edge image after removing a short edge as a noise edge on the basis of the length of the edge.

細かいノイズエッジの除去方法としては、様々なものが知られているため、長さによる除去に限定されるものではない。また、抽出したエッジは、近傍での連結性があるものを1つのエッジとしてまとめるラべリング処理を行い、それぞれの連結したエッジに番号を振り分け識別できるようにして(図8(b)のエッジ番号1,2,・・)、エッジ‐特徴量対応記憶部12に記憶される。   Since various methods for removing fine noise edges are known, they are not limited to removal by length. In addition, the extracted edges are subjected to a labeling process in which those having connectivity in the vicinity are combined as one edge so that numbers can be assigned to each connected edge so as to be identified (edges in FIG. 8B). No. 1, 2,...) And the edge-feature amount correspondence storage unit 12.

さらに、ステップS5において、CPU5及びエッジ特徴量記憶部51からなる特徴量算出部により、全エッジの特徴量を計算(算出)する。つまり、このステップS5では、特徴量算出部は、前記エッジ抽出部で取得したエッジ画像から、各エッジ上の或る一点の位置を選択する。この或る一点とは、エッジの中心に位置する点、もしくは任意の点でよい。   Further, in step S5, the feature amount calculation unit including the CPU 5 and the edge feature amount storage unit 51 calculates (calculates) the feature amounts of all the edges. That is, in this step S5, the feature amount calculation unit selects a position of a certain point on each edge from the edge image acquired by the edge extraction unit. This certain point may be a point located at the center of the edge or an arbitrary point.

そして図8(a)に示すように、その各点の位置をエッジ上の点として、特徴量相対関係記憶部8と同様に、一定の位置関係に矩形のサンプリング領域を設定する。その際、基準点となるワークの中心位置は、検出対象ワーク3がカメラ1に対して毎回一定の位置に来る場合には、特徴量相対関係記憶部8の参照画像13で使用した基準位置をそのまま使用してもよい。一方、検出対象ワーク3の中心位置が毎回ずれるような場合には、パターンマッチング等により検出対象ワーク3の概略中心位置を予め求めておく必要がある。   Then, as shown in FIG. 8A, a rectangular sampling region is set in a fixed positional relationship, like the feature amount relative relationship storage unit 8, with the position of each point as a point on the edge. At this time, the center position of the work serving as the reference point is the reference position used in the reference image 13 of the feature amount relative relationship storage unit 8 when the detection target work 3 comes to a certain position with respect to the camera 1 each time. It may be used as it is. On the other hand, when the center position of the detection target workpiece 3 is shifted every time, the approximate center position of the detection target workpiece 3 needs to be obtained in advance by pattern matching or the like.

そして、各サンプリング領域(矩系領域)20,21,22に位置する前記入力画像の輝度値を取得して、矩形のサンプリング領域毎に平均輝度値を算出し、算出した平均輝度値を各エッジの特徴量とする。また各エッジの特徴量を記憶するため、CPU5及びエッジ画像記憶部10からなるエッジ抽出部で求めたエッジ番号(図8(b)参照)と、そのエッジの特徴量との対応がわかるエッジ‐特徴量の対応表を作成し、エッジ‐特徴量対応記憶部12に記憶しておく。   Then, the luminance value of the input image located in each sampling region (rectangular region) 20, 21, 22 is acquired, an average luminance value is calculated for each rectangular sampling region, and the calculated average luminance value is calculated for each edge. Feature amount. In addition, since the feature values of each edge are stored, the edge number (see FIG. 8B) obtained by the edge extraction unit including the CPU 5 and the edge image storage unit 10 and the edge that indicates the correspondence between the feature values of the edge- A feature quantity correspondence table is created and stored in the edge-feature quantity correspondence storage unit 12.

さらに、ステップS6において、CPU5及び特徴量ヒストグラム記憶部11からなるエッジ区分部が、CPU5及びエッジ特徴量記憶部51からなる特徴量算出部で得られた全エッジの特徴量K,N1,N2に基づき、特徴量ヒストグラムを作成する。さらに、ステップS7において、上記エッジ区分部が、特徴量ヒストグラムから閾値を決定して記憶する。   Furthermore, in step S6, the edge segmentation unit composed of the CPU 5 and the feature amount histogram storage unit 11 is converted into the feature amounts K, N1, N2 of all edges obtained by the feature amount calculation unit composed of the CPU 5 and the edge feature amount storage unit 51. Based on this, a feature amount histogram is created. Further, in step S7, the edge classification unit determines and stores a threshold value from the feature amount histogram.

上記ステップS6〜ステップS7の処理工程は、上記エッジ区分部によって実行される。このエッジ区分部は、まず、前記算出した特徴量(平均輝度値)を、図9(b)に示すような横軸に平均の輝度値をとり且つ縦軸に頻度をとったヒストグラムを作成し、特徴量ヒストグラム記憶部11に記憶する。実際には、ヒストグラムの作成は、図9(a)に示すように0〜255の256個のテーブルを用意しておき、テーブル値と一致する前記平均輝度値がいくつあるかを記憶していく。例えば、平均輝度値30が2つある場合は、テーブル値30に「2」を入力する。そして、作成したヒストグラムから閾値(しきい値)を求める。閾値の求め方を以下に示す。   The processing steps from Step S6 to Step S7 are executed by the edge segmentation unit. The edge segmentation unit first creates a histogram of the calculated feature value (average luminance value) with the average luminance value on the horizontal axis and the frequency on the vertical axis as shown in FIG. 9B. And stored in the feature amount histogram storage unit 11. Actually, the histogram is created by preparing 256 tables of 0 to 255 as shown in FIG. 9A and storing how many average luminance values match the table values. . For example, when there are two average luminance values 30, “2” is input to the table value 30. Then, a threshold value (threshold value) is obtained from the created histogram. The method for obtaining the threshold is shown below.

前記特徴量ヒストグラムより輝度値kのときの頻度をH[k]とすると、まず、下記式(1)に示す加重移動平均法により、HWMA[k]を求める。 Assuming that the frequency at the luminance value k is H [k] from the feature amount histogram, first, H WMA [k] is obtained by the weighted moving average method shown in the following equation (1).

Figure 0005769559
Figure 0005769559

上記式(1)において、nは平均化する区間を表し、nの値が大きければ平滑化を強くすることができ、小さければ平滑化を弱くすることができる。図9(b)のヒストグラムをn=3で平滑化したヒストグラムを、図10の折れ線によるヒストグラム29として示す。   In the above formula (1), n represents an interval to be averaged, and if the value of n is large, smoothing can be strengthened, and if it is small, smoothing can be weakened. A histogram obtained by smoothing the histogram of FIG. 9B with n = 3 is shown as a broken line 29 in FIG.

次に、下記式(2)に示す条件式を満たすHWMA[k]を探索する。ただし、式(2)では、kの値が小さいほうの閾値を閾値1、もう一方を閾値2とする。本実施の形態では、図4に示すような画像の場合に2種類の非検出対象エッジ15が出るため、このように2つの極小値を、閾値1、2として設定する。 Next, H WMA [k] that satisfies the conditional expression shown in the following expression (2) is searched. However, in equation (2), the threshold with the smaller value of k is threshold 1 and the other is threshold 2. In the present embodiment, since two types of non-detection target edges 15 appear in the case of an image as shown in FIG. 4, the two minimum values are set as the threshold values 1 and 2 in this way.

Figure 0005769559
Figure 0005769559

平滑化後の上記ヒストグラム29が極小値となる位置を見つけ、その値を閾値として設定する。極小値の探索方法は、HWMA[k]のkを0〜255まで変化させてゆく。そして、現在のHWMA[k]に対し、前後のヒストグラム(頻度)の値HWMA[k−1]、HWMA[k+1]がHWMA[k]より大きければ、前記作成したヒストグラムの極小値とみなす。 A position where the histogram 29 after smoothing becomes a minimum value is found, and that value is set as a threshold value. In the minimum value search method, k of H WMA [k] is changed from 0 to 255. Then, for the current H WMA [k], the value H WMA before and after the histogram (frequency) [k-1], if H WMA [k + 1] is greater than H WMA [k], the minimum value of the histogram that the created It is considered.

ステップS8では、ステップS2で特徴量相対関係記憶部8に記憶された、特徴量K,N1,N2の大小関係を表した値(フラグ1、2、3の何れか)に基づき、大小関係のフラグ=1であるか否かを判断する。そして、大小関係フラグ=1である場合はステップS11に進み、そうでなければ、ステップS9に進む。ステップS11では、検出対象エッジ14の特徴量K>閾値2(非検出対象エッジ15のN1)、を満たすエッジを選択して、ステップS14に進む。ステップS14では、次の画像が有るか否かを判断し、有る場合にはステップS3に戻って検出対象の画像を入力し、次の画像が無い場合には処理を終了する。   In step S8, based on the value (any one of flags 1, 2 and 3) representing the magnitude relationship between the feature quantities K, N1, and N2 stored in the feature quantity relative relationship storage unit 8 in step S2, It is determined whether or not flag = 1. If the magnitude relation flag = 1, the process proceeds to step S11. Otherwise, the process proceeds to step S9. In step S11, an edge satisfying the feature amount K of the detection target edge 14> the threshold 2 (N1 of the non-detection target edge 15) is selected, and the process proceeds to step S14. In step S14, it is determined whether or not there is a next image. If there is, the process returns to step S3 to input an image to be detected. If there is no next image, the process ends.

また、ステップS9では、大小関係のフラグ=2であるか否かを判断し、大小関係フラグ=2である場合はステップS12に進み、そうでなければ、ステップS10に進む。ステップS12では、閾値2(N1)>特徴量K>閾値1(N2)、を満たすエッジを選択して、ステップS14に進む。   In step S9, it is determined whether or not the magnitude relation flag = 2. If the magnitude relation flag = 2, the process proceeds to step S12. Otherwise, the process proceeds to step S10. In step S12, an edge that satisfies threshold value 2 (N1)> feature value K> threshold value 1 (N2) is selected, and the process proceeds to step S14.

ステップS10では、大小関係のフラグ=3であるか否かを判断し、大小関係フラグ=3である場合はステップS13に進む。ステップS13では、閾値1(N2)>特徴量K、を満たすエッジを選択して、ステップS14に進む。   In step S10, it is determined whether or not the magnitude relation flag = 3. If the magnitude relation flag = 3, the process proceeds to step S13. In step S13, an edge satisfying threshold 1 (N2)> feature quantity K is selected, and the process proceeds to step S14.

以上のステップS8〜S13の処理工程は、CPU5及びエッジ‐特徴量対応記憶部12からなるエッジ関係設定部によって実行される。つまり、エッジ関係設定部は、特徴量相対関係記憶部8に記憶しておいた値(フラグ)が「1」であれば、閾値2(非検出対象エッジ15のN1)以上の特徴量Kを持つエッジが検出対象であると判断する(S8,S11)。   The processing steps in steps S8 to S13 are executed by the edge relationship setting unit including the CPU 5 and the edge-feature amount correspondence storage unit 12. That is, if the value (flag) stored in the feature amount relative relationship storage unit 8 is “1”, the edge relationship setting unit sets a feature amount K equal to or greater than the threshold value 2 (N1 of the non-detection target edge 15). It is determined that the held edge is the detection target (S8, S11).

また、エッジ関係設定部は、特徴量相対関係記憶部8の値が「2」であれば、閾値1(非検出対象エッジ15のN2)以上且つ閾値2(非検出対象エッジ15のN1)以下の特徴量Kを持つエッジが検出対象であると判断する(S9,S12)。さらに、特徴量相対関係記憶部8の値が「3」であれば、閾値1(非検出対象エッジ15のN2)以下の特徴量を持つエッジが検出対象であると判断する(S10,S13)。   Further, when the value of the feature quantity relative relationship storage unit 8 is “2”, the edge relationship setting unit is equal to or greater than the threshold 1 (N2 of the non-detection target edge 15) and equal to or less than the threshold 2 (N1 of the non-detection target edge 15). It is determined that the edge having the feature quantity K is a detection target (S9, S12). Further, if the value in the feature quantity relative relationship storage unit 8 is “3”, it is determined that an edge having a feature quantity equal to or less than the threshold value 1 (N2 of the non-detection target edge 15) is a detection target (S10, S13). .

以上のように本実施の形態では、前記2つの閾値1、2と、予め記憶しておいた特徴量の大小関係フラグ1(特徴量K>特徴量N1>特徴量N2)とにより、閾値2以上の特徴量Kを持つエッジが検出対象であると判断できる。すると、エッジ関係設定部は、前記作成したエッジ‐特徴量対応表(図8(b))に基づいて、閾値2以上の特徴量Kを持つエッジのみを選択する。エッジ関係設定部は、CPU5及びエッジ画像記憶部10からなるエッジ抽出部によって抽出された全エッジの中から、検出対象エッジと判断したエッジのみを残したエッジ画像を生成して、出力する。   As described above, in the present embodiment, the threshold value 2 is determined based on the two threshold values 1 and 2 and the magnitude relation flag 1 (feature quantity K> feature quantity N1> feature quantity N2) stored in advance. It can be determined that an edge having the above feature amount K is a detection target. Then, the edge relationship setting unit selects only edges having a feature quantity K equal to or greater than the threshold value 2 based on the created edge-feature quantity correspondence table (FIG. 8B). The edge relationship setting unit generates and outputs an edge image in which only the edge determined as the detection target edge is left out of all the edges extracted by the edge extraction unit including the CPU 5 and the edge image storage unit 10.

また、図11(a),(b),(c)に示す参照画像48の場合のように、非検出対象エッジ50が1種類しか出なければ、作成したヒストグラム(図12(a))から、判別分析法によって閾値を求めることができる。下記にその方法を示す。   Also, as in the case of the reference image 48 shown in FIGS. 11A, 11B, and 11C, if only one type of non-detection target edge 50 appears, the created histogram (FIG. 12A) is used. The threshold value can be obtained by discriminant analysis. The method is shown below.

即ち、輝度値kのときの頻度をH[k]とし、仮の閾値をtとする。ここで、図12(b)における符号30は、閾値tを示している。この閾値tで、ヒストグラムを分割したときの左側をクラス1、右側をクラス2とし、クラス1内のエッジ数(頻度の総和)をω、輝度値の平均をm、分散をσとする。一方、クラス2内のエッジ数(頻度の総和)をω、輝度値の平均をm、分散をσとすると、下記式(3)により、クラス1、クラス2におけるクラス内分散σが求まる。 That is, the frequency at the luminance value k is H [k], and the temporary threshold is t. Here, reference numeral 30 in FIG. 12B indicates a threshold value t. When the histogram is divided at this threshold t, the left side is class 1 and the right side is class 2. The number of edges (total frequency) in class 1 is ω 1 , the average of luminance values is m 1 , and the variance is σ 1 . To do. On the other hand, assuming that the number of edges in class 2 (the sum of frequencies) is ω 2 , the average luminance value is m 2 , and the variance is σ 2 , the intra-class variance σ W in class 1 and class 2 according to the following equation (3) Is obtained.

Figure 0005769559
Figure 0005769559

次に、ヒストグラム全体の平均輝度値をmとすると、下記式(4)によりクラス1とクラス2のクラス間分散σが求まる。 Next, when the average brightness value of the entire histogram and m t, the following equation (4) Class 1 and Class 2 interclass variance sigma b is obtained.

Figure 0005769559
Figure 0005769559

そして、下記式(5)を分離度として、仮の閾値tを0から255まで変更し、分離度が最大のときのtを閾値として設定する。   Then, the following equation (5) is used as the degree of separation, the temporary threshold t is changed from 0 to 255, and t when the degree of separation is maximum is set as the threshold.

Figure 0005769559
Figure 0005769559

上記エッジ関係設定部は、閾値によって区分された特徴量の範囲の大小関係と上記記憶部(5,8)に記憶された特徴量K,N1,N2の大小関係とを比較する。そして、対応する大小関係にある特徴量の範囲内の入力画像上のエッジと参照画像13上でのエッジ(14,15)とを対応付ける。つまり、エッジ関係設定部は、上記閾値と、予め記憶しておいた輝度値の相対関係(検出対象エッジ近傍の輝度値>非検出対象エッジ近傍の輝度値)より、閾値以上の特徴量を持つエッジが検出対象であると判断できる。   The edge relationship setting unit compares the size relationship between the ranges of the feature amounts classified by the threshold and the size relationship between the feature amounts K, N1, and N2 stored in the storage units (5, 8). Then, the edge on the input image and the edge (14, 15) on the reference image 13 in the range of the corresponding feature quantity range are associated with each other. That is, the edge relationship setting unit has a feature amount equal to or greater than the threshold value based on the relative relationship between the threshold value and the previously stored luminance value (brightness value near the detection target edge> brightness value near the non-detection target edge). It can be determined that the edge is a detection target.

上記処理フローが、入力画像1枚に対する本発明の画像処理方法(エッジ検出方法)である。連続して次の画像を入力して本画像処理方法を行う場合は、上述のように、ステップS3に戻って、新たに検出対象となる次の検出対象ワーク3の画像を入力する(ステップS14)。   The above processing flow is the image processing method (edge detection method) of the present invention for one input image. When the next image is continuously input and this image processing method is performed, the process returns to step S3 as described above, and an image of the next detection target workpiece 3 to be newly detected is input (step S14). ).

以上のように、参照画像13から予め算出しておいた検出対象エッジ14周辺の輝度値と、非検出対象エッジ15周辺の輝度値との相対関係と、順次送られてくる検出対象ワーク3の入力画像毎に算出する閾値とを用いて、必要な検出対象エッジのみを選択できる。つまり、照明装置105の照明状態に変化が生じた場合、この変化に応じて閾値を動的に変更できるので、予め算出した特徴量の相対関係が変わらない限り、照明装置105の照明状態に拘わらず、検出対象エッジのみをロバストに検出することができる。   As described above, the relative relationship between the luminance value around the detection target edge 14 calculated in advance from the reference image 13 and the luminance value around the non-detection target edge 15, and the detection target workpiece 3 sent sequentially. Only necessary detection target edges can be selected using a threshold value calculated for each input image. That is, when a change occurs in the lighting state of the lighting device 105, the threshold value can be dynamically changed in accordance with this change. Therefore, as long as the relative relationship between the feature amounts calculated in advance does not change, the lighting state of the lighting device 105 is affected. Instead, only the detection target edge can be detected robustly.

以上の本実施形態では、参照画像13から、予め検出対象エッジ14と非検出対象エッジ15とに対して一定の位置関係にある領域の輝度値kを特徴量Kとして算出する。そして、検出対象エッジ14の特徴量Kと非検出対象エッジ15の特徴量N1,N2との大きさを比較し、その大小関係を記憶しておく。そして、検出対象となる入力画像からエッジを抽出し、抽出した全エッジの特徴量K,N1,N2を算出し、その特徴量のヒストグラムを作成する。   In the present embodiment described above, the luminance value k of a region having a certain positional relationship with respect to the detection target edge 14 and the non-detection target edge 15 is calculated from the reference image 13 as the feature amount K in advance. Then, the magnitudes of the feature quantity K of the detection target edge 14 and the feature quantities N1 and N2 of the non-detection target edge 15 are compared, and the magnitude relationship is stored. Then, an edge is extracted from the input image to be detected, feature amounts K, N1, and N2 of all the extracted edges are calculated, and a histogram of the feature amount is created.

さらに、作成したヒストグラムから閾値を求め、求めた閾値と、参照画像13から予め算出しておいた特徴量K,N1,N2の大小関係とにより、検出対象エッジ14の特徴量範囲と非検出対象エッジ15の特徴量範囲とを分離し、区別することができる。そして、検出対象エッジ14の特徴量範囲内の特徴量を持つエッジのみを選択することで、照明装置105の明るさの変化に拘わらず、入力画像から検出対象エッジ14のみを的確に検出することができる。   Further, a threshold value is obtained from the created histogram, and the feature amount range of the detection target edge 14 and the non-detection target are determined based on the obtained threshold value and the magnitude relationship between the feature amounts K, N1, and N2 calculated in advance from the reference image 13. The feature amount range of the edge 15 can be separated and distinguished. Then, by selecting only edges having a feature amount within the feature amount range of the detection target edge 14, it is possible to accurately detect only the detection target edge 14 from the input image regardless of changes in the brightness of the illumination device 105. Can do.

このように、検出対象の検出対象ワーク3の入力画像に対して、毎回エッジ特徴量を計算し、検出対象エッジ14と非検出対象エッジ15とを分離するための特徴量の閾値を動的に計算することができる。また、その特徴量は、サンプリング領域の輝度値に基づいて計算される。そのため、照明装置105の劣化等が原因で入力画像内の輝度変動が大きくなった場合でも、参照画像13から予め求めておいた検出対象エッジ14と非検出対象エッジ15の各特徴量の大小関係が変わらない限り、両エッジ14,15を安定に分離できる。   As described above, the edge feature amount is calculated every time for the input image of the detection target workpiece 3 to be detected, and the threshold value of the feature amount for separating the detection target edge 14 and the non-detection target edge 15 is dynamically set. Can be calculated. The feature amount is calculated based on the luminance value of the sampling area. For this reason, even when the luminance fluctuation in the input image increases due to deterioration of the lighting device 105 or the like, the magnitude relationship between the feature amounts of the detection target edge 14 and the non-detection target edge 15 obtained in advance from the reference image 13. As long as does not change, both edges 14 and 15 can be stably separated.

また、特徴量を算出するためのエッジに対して一定の位置関係にある領域を求める際に、各エッジ上の一点を選択する。そして、検出対象物体(検出対象ワーク3)が円形の場合には、中心付近の一点16を基準点として、基準点(16)と各エッジ上の点17,21,22との角度を求める。一方、検出対象物体が直線的な場合には、選択した点上のエッジ23,24の角度を求める。   Further, when obtaining a region having a certain positional relationship with respect to the edge for calculating the feature amount, one point on each edge is selected. Then, when the detection target object (detection target workpiece 3) is circular, the angle between the reference point (16) and the points 17, 21, 22 on each edge is obtained with one point 16 near the center as the reference point. On the other hand, when the detection target object is linear, the angles of the edges 23 and 24 on the selected point are obtained.

そして、図5(b)及び図6(a)に示すように、エッジ上の点に設定しておいた領域を求めた角度分だけ回転させる。これにより、円形の場合にはエッジの接線に沿わせ、直線的な場合にはエッジの長さ方向に沿わせることで、各エッジと、設定した領域とが交差する不都合をなくする。そのため、領域の輝度値に基づいてエッジの特徴量を求める場合に、誤った特徴量を算出することを確実に防ぐことができる。   Then, as shown in FIGS. 5B and 6A, the region set at the point on the edge is rotated by the calculated angle. This eliminates the inconvenience of crossing each edge with the set area by following the edge tangent in the case of a circle and along the length of the edge in the case of a straight line. Therefore, it is possible to reliably prevent an erroneous feature amount from being calculated when the edge feature amount is obtained based on the luminance value of the region.

オペレータは、参照画像13により、検出対象エッジ14の特徴量Kと非検出対象エッジ15の特徴量N1,N2との大小関係を教示する。その際に、検出対象エッジ14上の任意の一点17、対象以外の各エッジ上の任意の一点(21,22)、検出対象物体の中心付近の一点16を、マウスポインタ等を使用して教示してやるだけでよい。前記角度、特徴量の計算や大小関係の記憶等は、各点16,17(21,22)の位置さえ分かれば、プログラムにより自動で設定できるため、上記のように簡易的な教示で済むことになる。   The operator uses the reference image 13 to teach the magnitude relationship between the feature quantity K of the detection target edge 14 and the feature quantities N1 and N2 of the non-detection target edge 15. At that time, an arbitrary point 17 on the detection target edge 14, an arbitrary point (21, 22) on each edge other than the target, and a point 16 near the center of the detection target object are taught using a mouse pointer or the like. Just do it. The calculation of the angle, feature amount, the storage of the magnitude relationship, etc. can be automatically set by a program as long as the position of each point 16, 17 (21, 22) is known, so simple teaching as described above is sufficient. become.

1…カメラ、3…ワーク(検出対象ワーク)、5,8…記憶部(CPU,特徴量相対関係記憶部)、5,10…エッジ抽出部(CPU,エッジ画像記憶部)、5,11…エッジ区分部(CPU,特徴量ヒストグラム記憶部)、5,12…エッジ関係設定部(CPU,エッジ‐特徴量対応記憶部)、5,51…特徴量算出部(CPU,エッジ特徴量記憶部)、13…参照画像、14…エッジ(検出対象エッジ)、15…エッジ(非検出対象エッジ)、19…コンピュータ、20,21,22…サンプリング領域(矩形領域)、105…照明装置、K,N1,N2…特徴量 DESCRIPTION OF SYMBOLS 1 ... Camera, 3 ... Work (detection object work), 5, 8 ... Memory | storage part (CPU, feature-value relative relationship memory | storage part), 5, 10 ... Edge extraction part (CPU, edge image memory | storage part), 5, 11 ... Edge classification unit (CPU, feature amount histogram storage unit), 5, 12... Edge relationship setting unit (CPU, edge-feature amount correspondence storage unit), 5, 51... Feature amount calculation unit (CPU, edge feature amount storage unit) , 13 ... Reference image, 14 ... Edge (detection target edge), 15 ... Edge (non-detection target edge), 19 ... Computer, 20, 21, 22 ... Sampling area (rectangular area), 105 ... Illumination device, K, N1 , N2 ... features

Claims (6)

予めワークを撮像した参照画像上の複数のエッジのそれぞれについて算出された、エッジに対して一定の位置関係にあるサンプリング領域の輝度値からなる特徴量の大小関係を記憶する記憶部と、
取得した入力画像上のワークのエッジを抽出するエッジ抽出部と、
前記エッジ抽出部によって抽出された各エッジについて前記特徴量を算出する特徴量算出部と、
算出された前記入力画像上の各エッジの特徴量から輝度値及び頻度の度数分布を示すヒストグラムを作成し、このヒストグラムの分布状態に基づいて求められた閾値により区分される特徴量の範囲により、前記エッジ抽出部によって抽出されたエッジを区分するエッジ区分部と、
前記閾値によって区分された特徴量の範囲の大小関係と前記記憶部に記憶された特徴量の大小関係とを比較して、対応する大小関係にある特徴量の範囲内の入力画像上のエッジと前記参照画像上でのエッジとを対応付けるエッジ関係設定部と、を備えた、
ことを特徴とする画像処理装置。
A storage unit that stores a magnitude relationship of feature amounts including brightness values of a sampling area that is calculated with respect to each of the plurality of edges on a reference image obtained by imaging a workpiece in advance and in a fixed positional relationship with the edges;
An edge extraction unit for extracting the edge of the workpiece on the acquired input image;
A feature amount calculation unit that calculates the feature amount for each edge extracted by the edge extraction unit;
A histogram showing the frequency distribution of the luminance value and frequency is created from the calculated feature value of each edge on the input image, and the feature value range divided by the threshold obtained based on the distribution state of this histogram, An edge segmentation unit that segments the edges extracted by the edge extraction unit;
By comparing the magnitude relation of the range of the feature quantity divided by the threshold and the magnitude relation of the feature quantity stored in the storage unit, an edge on the input image within the corresponding feature quantity range and An edge relationship setting unit that associates an edge on the reference image,
An image processing apparatus.
前記サンプリング領域は、エッジの一方側においてそのエッジの接線に接する位置関係となるように設定される、
請求項1記載の画像処理装置。
The sampling region is set so as to be in a positional relationship in contact with the tangent of the edge on one side of the edge.
The image processing apparatus according to claim 1.
前記エッジ関係設定部によって設定されたエッジの対応関係に基づいて、検出対象のエッジを前記入力画像上にて選択する選択部と、
前記選択部によって選択されたエッジからワークの位置情報を算出する位置算出部と、を備えた、
請求項1又は2記載の画像処理装置。
A selection unit that selects an edge to be detected on the input image based on the correspondence between the edges set by the edge relationship setting unit;
A position calculation unit that calculates position information of the workpiece from the edge selected by the selection unit,
The image processing apparatus according to claim 1 or 2.
コンピュータを、請求項1乃至3のいずれか1項記載の画像処理装置として機能させる、
ことを特徴とする画像処理プログラム。
Allowing a computer to function as the image processing apparatus according to any one of claims 1 to 3;
An image processing program characterized by that.
ワークを照らす照明装置と、
前記照明装置に照らされたワークを撮像するカメラと、
請求項3記載の画像処理装置と、
前記カメラが撮像した入力画像に基づいて前記画像処理装置が算出した位置情報に基づいて、ワークに対して所定の処理を施す作動アームと、を備えた、
ことを特徴とするロボット装置。
A lighting device for illuminating the workpiece;
A camera for imaging a workpiece illuminated by the illumination device;
An image processing apparatus according to claim 3,
An actuating arm that performs a predetermined process on the workpiece based on position information calculated by the image processing device based on an input image captured by the camera.
A robot apparatus characterized by that.
画像処理装置が、予めワークを撮像した参照画像上の複数のエッジのそれぞれについて算出された、エッジに対して一定の位置関係にあるサンプリング領域の輝度値からなる特徴量の大小関係を記憶する記憶工程と、
前記画像処理装置が、取得した入力画像上のワークのエッジを抽出するエッジ抽出工程と、
前記画像処理装置が、前記エッジ抽出工程にて抽出された各エッジについて前記特徴量を算出する特徴量算出工程と、
前記画像処理装置が、算出された前記入力画像上の各エッジの特徴量から輝度値及び頻度の度数分布を示すヒストグラムを作成し、このヒストグラムの分布状態に基づいて求められた閾値により区分される特徴量の範囲により、前記エッジ抽出工程にて抽出されたエッジを区分するエッジ区分工程と、
前記画像処理装置が、前記閾値によって区分された特徴量の範囲の大小関係と前記記憶工程にて記憶された特徴量の大小関係とを比較して、対応する大小関係にある特徴量の範囲内の入力画像上のエッジと前記参照画像上でのエッジとを対応付けるエッジ関係設定工程と、を備えた、
ことを特徴とする画像処理方法。
A memory for storing a magnitude relationship of feature amounts composed of luminance values of a sampling area having a fixed positional relationship with respect to an edge, which is calculated for each of a plurality of edges on a reference image obtained by imaging a workpiece in advance. Process,
An edge extraction step in which the image processing apparatus extracts an edge of a workpiece on the acquired input image;
A feature amount calculating step in which the image processing apparatus calculates the feature amount for each edge extracted in the edge extraction step;
The image processing apparatus creates a histogram indicating a frequency distribution of luminance values and frequencies from the calculated feature values of each edge on the input image, and is classified by threshold values obtained based on the distribution state of the histogram. An edge division step of dividing the edge extracted in the edge extraction step according to a range of feature amounts;
The image processing apparatus compares the size relationship of the feature amount range classified by the threshold value with the feature amount stored in the storing step, and within the corresponding feature amount range. An edge relationship setting step for associating an edge on the input image with an edge on the reference image,
An image processing method.
JP2011195285A 2011-09-07 2011-09-07 Image processing apparatus, image processing program, robot apparatus, and image processing method Expired - Fee Related JP5769559B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2011195285A JP5769559B2 (en) 2011-09-07 2011-09-07 Image processing apparatus, image processing program, robot apparatus, and image processing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2011195285A JP5769559B2 (en) 2011-09-07 2011-09-07 Image processing apparatus, image processing program, robot apparatus, and image processing method

Publications (2)

Publication Number Publication Date
JP2013058036A JP2013058036A (en) 2013-03-28
JP5769559B2 true JP5769559B2 (en) 2015-08-26

Family

ID=48133889

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2011195285A Expired - Fee Related JP5769559B2 (en) 2011-09-07 2011-09-07 Image processing apparatus, image processing program, robot apparatus, and image processing method

Country Status (1)

Country Link
JP (1) JP5769559B2 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11361249B2 (en) * 2017-03-14 2022-06-14 Nec Corporation Image processing device for machine learning and setting of a teaching signal in accordance with detection and target regions, image processing method for machine learning and setting of a teaching signal, and storage medium

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6415066B2 (en) 2014-03-20 2018-10-31 キヤノン株式会社 Information processing apparatus, information processing method, position and orientation estimation apparatus, robot system
JP6964031B2 (en) * 2018-03-27 2021-11-10 Tasmit株式会社 Pattern edge detection method
JP6985210B2 (en) * 2018-05-29 2021-12-22 株式会社 日立産業制御ソリューションズ Inspection function diagnostic device, inspection function diagnosis method and inspection function diagnosis program
JP2020170323A (en) * 2019-04-02 2020-10-15 キヤノン株式会社 Processing method, article manufacturing method, processing apparatus, robot apparatus, program and recording media

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004272885A (en) * 2003-02-21 2004-09-30 Shinko Electric Ind Co Ltd Device and method for edge extraction
JP2010113466A (en) * 2008-11-05 2010-05-20 Toshiba Corp Object tracking apparatus, object tracking program, and method
JP5290864B2 (en) * 2009-05-18 2013-09-18 キヤノン株式会社 Position and orientation estimation apparatus and method

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11361249B2 (en) * 2017-03-14 2022-06-14 Nec Corporation Image processing device for machine learning and setting of a teaching signal in accordance with detection and target regions, image processing method for machine learning and setting of a teaching signal, and storage medium

Also Published As

Publication number Publication date
JP2013058036A (en) 2013-03-28

Similar Documents

Publication Publication Date Title
JP4137969B2 (en) Eye detection device, eye detection method, and program
JP5699788B2 (en) Screen area detection method and system
US8073233B2 (en) Image processor, microscope system, and area specifying program
JP4871144B2 (en) Image processing apparatus, method, and program
JP5769559B2 (en) Image processing apparatus, image processing program, robot apparatus, and image processing method
JP5351673B2 (en) Appearance inspection device, appearance inspection method
JP6557943B2 (en) Image collation device, image sensor, processing system, and image collation method
US8780223B2 (en) Automatic determination of compliance of a part with a reference drawing
CN112352149A (en) System and method for automatically analyzing air samples
JP2020502490A (en) System and method for performing automatic analysis of air samples
CN107085850B (en) The method and book scanning method that masking acquires the marked body of foreign matter in image, identifies foreign matter marked body in image
JP6727228B2 (en) Lead tip position image recognition method and lead tip position image recognition system
JP2008192100A (en) Eyelid detector and program
US10373021B2 (en) Object detection device, object detection method, and recording medium
JP5939775B2 (en) Image processing apparatus, image processing program, robot apparatus, and image processing method
CN106504262A (en) A kind of small tiles intelligent locating method of multiple features fusion
CN112025693B (en) Pixel-level target capture detection method and system of asymmetric three-finger grabber
JP2007188407A (en) Image processing device and image processing program
JP5960433B2 (en) Image processing apparatus and image processing method
JP6264008B2 (en) Image processing apparatus, image processing method, and image processing program
JP2006163662A (en) Device and method for recognizing number of fingers
JP7380332B2 (en) Image processing device, control method and program for the image processing device
JP5921190B2 (en) Image processing apparatus and image processing method
JPH07121713A (en) Pattern recognition method
JP5812284B2 (en) Belt-like structure detecting device, method and program

Legal Events

Date Code Title Description
RD04 Notification of resignation of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7424

Effective date: 20130228

A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20140903

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20150521

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20150623

R151 Written notification of patent or utility model registration

Ref document number: 5769559

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R151

LAPS Cancellation because of no payment of annual fees