JP2015232487A - Image inspection device, image inspection method, image inspection program and computer readable recording medium, and apparatus having image inspection program recorded therein - Google Patents

Image inspection device, image inspection method, image inspection program and computer readable recording medium, and apparatus having image inspection program recorded therein Download PDF

Info

Publication number
JP2015232487A
JP2015232487A JP2014119139A JP2014119139A JP2015232487A JP 2015232487 A JP2015232487 A JP 2015232487A JP 2014119139 A JP2014119139 A JP 2014119139A JP 2014119139 A JP2014119139 A JP 2014119139A JP 2015232487 A JP2015232487 A JP 2015232487A
Authority
JP
Japan
Prior art keywords
illumination
image
inspection apparatus
workpiece
image inspection
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.)
Granted
Application number
JP2014119139A
Other languages
Japanese (ja)
Other versions
JP6395456B2 (en
Inventor
典正 眞弓
Norimasa Mayumi
典正 眞弓
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.)
Keyence Corp
Original Assignee
Keyence 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 Keyence Corp filed Critical Keyence Corp
Priority to JP2014119139A priority Critical patent/JP6395456B2/en
Publication of JP2015232487A publication Critical patent/JP2015232487A/en
Application granted granted Critical
Publication of JP6395456B2 publication Critical patent/JP6395456B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

PROBLEM TO BE SOLVED: To provide an image inspection device that applies a photometric stereo method enabling accurate and quick estimation of the azimuth and zenith angle of illumination, and a method of detecting an illumination direction.SOLUTION: An image inspection device includes: imaging means including imaging means 11 for photographing a workpiece WK from a fixed direction; illumination means including first illumination means 21 to fourth illumination means 24 for illuminating the workpiece WK from different directions at least three times; illumination control means for lighting the first illumination means 21 to the fourth illumination means 24 one by one in order; source image creation means for creating a plurality of source images by driving the imaging means 11 at respective illumination timings; and illumination direction estimation means 41g for detecting illumination directions that best match the actual illumination directions of the first illumination means 21 to the fourth illumination means 24, from the plurality of source images SP based on the plurality of source images created by the source image creation means.

Description

本発明は、フォトメトリックステレオ法を用いた画像検査装置、画像検査方法、画像検査プログラム及びコンピュータで読み取り可能な記録媒体又は記録した機器に関する。   The present invention relates to an image inspection apparatus, an image inspection method, an image inspection program, and a computer-readable recording medium or recorded apparatus using a photometric stereo method.

ワーク(検査対象物や被写体)の表面の傷の有無や外観形状、印字された文字の読み取りといった検査を行う画像検査装置が利用されている。このような画像検査装置は、ワークに対して必要な照明を行い、画像を撮像し、得られた画像データに対してエッジ検出等、画像処理を行い、その結果に基づいて良否判定等の判断を行っていた。   2. Description of the Related Art Image inspection apparatuses that perform inspections such as the presence or absence of scratches on the surface of a workpiece (inspection object or subject), appearance shape, and reading of printed characters are used. Such an image inspection apparatus performs necessary illumination on a workpiece, captures an image, performs image processing such as edge detection on the obtained image data, and determines pass / fail judgment based on the result. Had gone.

しかしながらこのような画像検査装置では、ワークの種類によっては照明の種類や当てる方向によって見えやすさが変わるケースがあった。このため、このようなワークに対して適切な検査を行うには、十分な知識や経験が必要であった。   However, in such an image inspection apparatus, depending on the type of work, there are cases in which the visibility changes depending on the type of illumination and the direction of application. For this reason, sufficient knowledge and experience are required to perform an appropriate inspection on such a workpiece.

また、従来の画像検査装置では、照明条件や設置条件等が少し変わっただけで誤検出が起きやすく、安定的に検出することが困難であるという問題もあった。さらに、ワークの外観検査においては、傷、縁等のワークの形状に関する情報、言い換えると立体的な情報と、印字、シミ等の平面的な情報の両方が検査の対象になるところ、お互いが干渉し合う結果、上手く検出できないことがあるという問題もあった。   Further, in the conventional image inspection apparatus, there is a problem that erroneous detection is likely to occur only when the illumination condition, installation condition, and the like are slightly changed, and it is difficult to detect stably. Furthermore, in the appearance inspection of workpieces, both information on the shape of the workpiece such as scratches and edges, in other words, three-dimensional information, and planar information such as printing and stains are subject to inspection. As a result, there was a problem that it could not be detected well.

このような問題を解決するための技術として、フォトメトリックステレオ法を用いて高さ情報を取得する画像処理装置が知られている(例えば、特許文献1を参照。)。ここでフォトメトリックステレオ法(photometric stereo)とは、照度差ステレオ法とも呼ばれ、異なる複数の照明方向から照明した画像を撮像して、その陰影情報からワークの法線ベクトルを求める三次元計測の手法の一つである。このようなフォトメトリックステレオ法を用いた画像処理装置は、法線ベクトル(傾き画像に相当)からX軸やY軸の成分を輝度値に置き換えた画像や、反射率画像(アルベド画像に相当)を作成して、画像検査に応用している。ここでは、フォトメトリックステレオ法で三次元計測を精度よく行うために、主として、照明機器の設置方法や照明光の照射方法に関する検討がなされている。   As a technique for solving such a problem, an image processing apparatus that acquires height information using a photometric stereo method is known (see, for example, Patent Document 1). The photometric stereo method (photometric stereo) is also called illuminance difference stereo method, which is a three-dimensional measurement method that captures images illuminated from different illumination directions and calculates the normal vector of the workpiece from the shadow information. One of the methods. An image processing apparatus using such a photometric stereo method is an image obtained by replacing the X-axis and Y-axis components with luminance values from a normal vector (equivalent to an inclination image), or a reflectance image (equivalent to an albedo image). Is applied to image inspection. Here, in order to accurately perform the three-dimensional measurement by the photometric stereo method, studies are mainly made on the installation method of the illumination device and the illumination light irradiation method.

特開2007−206797号公報JP 2007-206797 A

フォトメトリックステレオ法では、ワーク(被写体)表面の傾きやアルベド(反射率)等を決定するために、複数の照明で互いに異なる照明方向から複数の撮像を実施する必要がある。ここで照明方向は、被写体に対する方位角(図12B)、天頂角(図12A)で表すことができる。よってフォトメトリックステレオ法は、通常、撮像した複数の画像のそれぞれの照明方向が既知であることを前提として処理が行われる。   In the photometric stereo method, in order to determine the inclination of the workpiece (subject) surface, albedo (reflectance), and the like, it is necessary to perform a plurality of images from a plurality of illumination directions with different illumination directions. Here, the illumination direction can be represented by an azimuth angle (FIG. 12B) and a zenith angle (FIG. 12A) with respect to the subject. Therefore, in the photometric stereo method, processing is normally performed on the assumption that the illumination directions of each of a plurality of captured images are known.

ここで特許文献1に開示される画像処理装置は、フォトメトリックステレオ法に使用するカメラと照明とが分離できない一体型である。ここで、カメラと照明とを分離させた場合、設置の位置関係によってカメラに対する照明方向を自由に変化させることができる。また分離させることによって設置自由度が増し、被写体が被写体以外の障害物によって物理的に干渉を受けないように照明を設置できるようになる。また、結果に悪影響を与える鏡面反射光がカメラに入射しない天頂角や方位角を選ぶことも可能となる。   Here, the image processing apparatus disclosed in Patent Document 1 is an integral type in which the camera and illumination used in the photometric stereo method cannot be separated. Here, when the camera and the illumination are separated, the illumination direction with respect to the camera can be freely changed according to the positional relationship of the installation. Also, the separation increases the degree of freedom of installation, and the illumination can be installed so that the subject is not physically interfered by obstacles other than the subject. It is also possible to select a zenith angle or azimuth angle at which specular reflection light that adversely affects the results does not enter the camera.

しかしながら、前述のように、フォトメトリックステレオ法を応用した技術は、照明方向が既知であることを前提として実装されている。ここで、それぞれの照明方向の方位角は異なるが、天頂角は大きく変わらないと見なせる場合を考える。   However, as described above, the technique using the photometric stereo method is implemented on the assumption that the illumination direction is known. Here, a case is considered in which the azimuth angles of the respective illumination directions are different, but the zenith angle can be regarded as not largely changing.

フォトメトリックステレオ処理に与える天頂角に実際の値との相違がある場合、得られる面の傾きは実際の値に一定の比を掛けた値となる。それに対して、天頂角が一定の条件下で、フォトメトリックステレオ処理に与える方位角に実際の値との相違がある場合、単純な比例関係の変化ではなくなり、実際の被写体表面の傾きと得られる面の傾きとの相関は大きくずれる。   When the zenith angle given to the photometric stereo processing is different from the actual value, the obtained inclination of the surface is a value obtained by multiplying the actual value by a certain ratio. On the other hand, if the azimuth angle given to the photometric stereo processing is different from the actual value under a condition where the zenith angle is constant, it is not a simple change in proportional relationship, and the actual subject surface inclination is obtained. The correlation with the inclination of the surface is greatly deviated.

以上のことから、フォトメトリックステレオ法は、それぞれの天頂角がほぼ一定となるように照明を設置した場合、天頂角に対する精度は悪くてもワークの表面形状の認識性能に与える影響は少ないが、方位角に対する精度が悪ければ表面形状の認識性能に大きく悪影響を与えるという特性を持つ。すなわち、予め設定した照明方向と実際の照明方向とが大きく異なる場合は、被写体表面の形状を誤認する虞がある。   From the above, the photometric stereo method has little influence on the recognition performance of the surface shape of the workpiece even if the accuracy for the zenith angle is poor, when the illumination is installed so that each zenith angle is almost constant, If the accuracy with respect to the azimuth is poor, the surface shape recognition performance is greatly adversely affected. That is, when the preset illumination direction and the actual illumination direction are significantly different, there is a possibility that the shape of the subject surface is mistaken.

そこで、従来のフォトメトリックステレオ法を応用した技術は、ユーザに、被写体に対する方位角や天頂角を照明毎に個別に設定させるという方法がとられていた。   Therefore, a technique using a conventional photometric stereo method is a method in which the user individually sets the azimuth angle and zenith angle with respect to the subject for each illumination.

しかしながら、ユーザに、被写体に対する方位角や天頂角を照明方向が多数存在する照明毎に個別に設定させることは、煩雑な設定操作を強いることになり、開発コストを掛けて複雑な設定UI(User Interface)を実装しても、設定ミスを招来する可能性は否定できず、実際の被写体表面の形状を誤認する虞が依然あった。特に、被写体の表面の特徴は、設定が多少誤っていても表出するため、ユーザがその間違いに気付くことは困難である。   However, if the user individually sets the azimuth angle and the zenith angle with respect to the subject for each illumination having a large number of illumination directions, a complicated setting operation is imposed due to a complicated development operation. Even if (Interface) is implemented, the possibility of causing a setting error cannot be denied, and there is still a possibility that the actual shape of the subject surface is mistaken. In particular, since the feature of the surface of the subject is displayed even if the setting is slightly wrong, it is difficult for the user to notice the mistake.

この問題を解決するために、設定操作をユーザに強いることなく、設置した照明の方向を自動的に推定する手法が考えられる。しかしながら、フォトメトリックステレオ法をFA機器で想定される種々の検査に応用しようと考えた場合、異なる照明方向から撮像した複数の画像を元にすることに起因して計算量が膨大となり、全体での処理が遅延する虞があり、リアルタイム検査が困難となる。また、FA(Factory Automation)機器に適用する上でのカメラや照明の設置の拘束条件に適うように、方向推定の処理速度や精度を向上させることも求められる。   In order to solve this problem, a method of automatically estimating the direction of installed illumination without forcing the user to perform a setting operation can be considered. However, when the photometric stereo method is considered to be applied to various inspections assumed in FA equipment, the calculation amount becomes enormous due to the fact that it is based on a plurality of images taken from different illumination directions. This process may be delayed, making real-time inspection difficult. In addition, it is also required to improve the direction estimation processing speed and accuracy so as to meet the constraints of installation of cameras and lighting when applied to FA (Factory Automation) equipment.

本発明は、このような事情に鑑みてなされたものであり、その主な目的は、照明の方位角や天頂角を精度良く高速に推定することを可能にするフォトメトリックステレオ法を応用した画像検査装置、画像検査方法、画像検査プログラム及びコンピュータで読み取り可能な記録媒体又は記録した機器を提供することにある。   The present invention has been made in view of such circumstances, and its main purpose is an image applying a photometric stereo method that makes it possible to accurately estimate the azimuth angle and zenith angle of illumination at high speed. It is an object to provide an inspection apparatus, an image inspection method, an image inspection program, and a computer-readable recording medium or recorded device.

課題を解決するための手段及び発明の効果Means for Solving the Problems and Effects of the Invention

本発明の第1の側面に係る画像検査装置によれば、ワークの外観検査を行うための画像検査装置であって、ワークを互いに異なる実際の照明方向から照明するための三以上の照明手段と、前記三以上の照明手段を一ずつ所定の点灯順に点灯させるための照明制御手段と、前記照明制御手段により各照明手段を点灯させる照明タイミングにて、ワークを一定の方向から撮像することにより、実際の照明方向が異なる複数の部分照明画像を撮像するための撮像手段と、前記撮像手段によって撮像された複数の部分照明画像同士で、対応関係にある画素毎の画素値を用いて、フォトメトリックステレオ法に基づき、照明方向を仮定した仮定照明方向におけるワークの表面のソース画像を、複数の異なる仮定照明方向毎に生成するためのソース画像生成手段と、前記ソース画像生成手段によって仮定照明方向毎に生成された複数のソース画像に基づき、前記照明手段における実際の照明方向と最も整合する推定照明方向を検出するための照明方向推定手段とを備えることができる。上記構成により、実際の照明方向が画像検査装置側で不明な場合であっても、仮定照明方向の異なる複数のソース画像に基づいて、実際の照明方向を推定照明方向として推定することが可能となる。この結果、照明手段の配置を厳格に行わずともフォトメトリックステレオ法に基づく画像検査が可能となり、従来手間のかかっていた照明手段の設置作業を大幅に簡素化できる利点が得られる。特に、ユーザが設置した実際の照明方向を自動的に推定することができるので、ユーザが画像検査を行う際に、撮像手段や照明手段をラフに設置したとしても、細かな設定操作を強いられることなく、最適な照明条件で画像検査を行うことができる。   According to the image inspection apparatus according to the first aspect of the present invention, there is provided an image inspection apparatus for inspecting the appearance of a work, and three or more illumination means for illuminating the work from different actual illumination directions. The lighting control means for turning on the three or more lighting means one by one in a predetermined lighting order, and the lighting timing at which each lighting means is turned on by the lighting control means, to image the workpiece from a certain direction, Photometric using pixel values for each pixel having a correspondence relationship between an imaging unit for capturing a plurality of partial illumination images with different actual illumination directions and a plurality of partial illumination images captured by the imaging unit Based on the stereo method, a source image is generated to generate a source image of the workpiece surface in the assumed illumination direction assuming the illumination direction for each of a plurality of different assumed illumination directions. And an illumination direction estimating means for detecting an estimated illumination direction that most closely matches an actual illumination direction in the illumination means based on a plurality of source images generated for each assumed illumination direction by the source image generation means. Can be provided. With the above configuration, even when the actual illumination direction is unknown on the image inspection apparatus side, the actual illumination direction can be estimated as the estimated illumination direction based on a plurality of source images with different assumed illumination directions. Become. As a result, it is possible to perform image inspection based on the photometric stereo method without strictly arranging the illumination means, and there is an advantage that the installation work of the illumination means, which has conventionally been troublesome, can be greatly simplified. In particular, since the actual illumination direction installed by the user can be automatically estimated, even when the user performs image inspection, even if the imaging means and illumination means are roughly installed, a fine setting operation is forced. Therefore, it is possible to perform image inspection under optimum illumination conditions.

また、第2の側面に係る画像検査装置によれば、前記三以上の照明手段が、一体的に構成されており、かつ前記撮像手段の光軸を中心とした仮想回転面上に実際の照明方向を有しており、前記照明方向推定手段が、仮想回転面上に位置すると仮定された複数の仮定照明方向の中から、推定照明方向を推定することができる。上記構成により、仮想回転面上に取り得る実際の照明方向を、照明方向推定手段でもって推定することが可能となる。   Further, according to the image inspection apparatus according to the second aspect, the three or more illuminating units are integrally configured, and the actual illuminating is performed on the virtual rotation plane centered on the optical axis of the imaging unit. The illumination direction estimation means can estimate an estimated illumination direction from a plurality of assumed illumination directions assumed to be located on the virtual rotation plane. With the above configuration, the actual illumination direction that can be taken on the virtual rotation surface can be estimated by the illumination direction estimation means.

さらに、第3の側面に係る画像検査装置によれば、前記三以上の照明手段が、互いに独立して配置可能に構成されており、かつ前記撮像手段の光軸を中心とした仮想回転面上に実際の照明方向を有しており、前記照明方向推定手段が、仮想回転面上に位置すると仮定された複数の仮定照明方向の中から、推定照明方向を推定すると共に、前記三以上の照明手段のそれぞれの設置位置を推定可能に構成できる。上記構成により、複数の照明手段を入れ替えて配置しているような場合であっても、各照明手段の配置位置と実際の照明方向とを、照明方向推定手段でもって推定することが可能となる。   Furthermore, according to the image inspection apparatus according to the third aspect, the three or more illumination units are configured to be arranged independently of each other, and on a virtual rotation plane centered on the optical axis of the imaging unit. The illumination direction estimating means estimates the estimated illumination direction from a plurality of assumed illumination directions assumed to be located on the virtual rotation plane, and the three or more illuminations Each installation position of the means can be estimated. With the above configuration, even when a plurality of illumination means are replaced and arranged, the arrangement position of each illumination means and the actual illumination direction can be estimated by the illumination direction estimation means. .

さらにまた、第4の側面に係る画像検査装置によれば、前記照明方向推定手段は、ワークの表面形状を凸状と仮定して照明照明方向を推定できる。   Furthermore, according to the image inspection apparatus according to the fourth aspect, the illumination direction estimating means can estimate the illumination illumination direction assuming that the surface shape of the workpiece is convex.

さらにまた、第5の側面に係る画像検査装置によれば、前記ソース画像生成手段は、前記複数のソース画像を、照明方向を特定する天頂角及び方位角を変数として生成するものであり、前記照明方向推定手段は、前記ソース画像生成手段でもって生成されたソース画像のうち、実際の照明方向によるソース画像との整合の度合いを示す第1評価関数に従い、最も上位と評価されるソース画像を選択し、該ソース画像における天頂角及び方位角の変数値を推定照明方向として推定できる。上記構成により、最も上位と評価されるソース画像を選択し、該ソース画像における天頂角及び方位角の変数値を実際の照明方向として検出することができる。   Still further, according to the image inspection apparatus according to the fifth aspect, the source image generation means generates the plurality of source images using a zenith angle and an azimuth angle that specify an illumination direction as variables, The illumination direction estimation means determines a source image evaluated as the highest in accordance with a first evaluation function indicating a degree of matching with the source image in the actual illumination direction among the source images generated by the source image generation means. Once selected, the zenith angle and azimuth variable values in the source image can be estimated as the estimated illumination direction. With the above configuration, it is possible to select the source image that is evaluated as the highest rank, and to detect the zenith angle and azimuth angle variable values in the source image as the actual illumination direction.

さらにまた、第6の側面に係る画像検査装置によれば、前記第1評価関数は、天頂角及び方位角を変数として算出されて生成されたソース画像から、天頂角及び方位角に対して、前記ソース画像におけるワークの表面形状とソース画像にした実際の表面形状とのズレの大きさを数値化した関数とできる。上記構成により、第1評価関数の値が最小となるとき、実際の照明方向によるソース画像との整合の度合いが最大となるため、このときのソース画像における天頂角及び方位角の変数値を実際の照明方向として検出することができる。   Furthermore, according to the image inspection apparatus according to the sixth aspect, the first evaluation function is calculated from the source image calculated by using the zenith angle and the azimuth as variables, with respect to the zenith angle and the azimuth. A function obtained by quantifying the amount of deviation between the surface shape of the workpiece in the source image and the actual surface shape in the source image can be obtained. With the above configuration, when the value of the first evaluation function is minimized, the degree of matching with the source image in the actual illumination direction is maximized. Therefore, the variable values of the zenith angle and azimuth angle in the source image at this time are actually Can be detected as the illumination direction.

さらにまた、第7の側面に係る画像検査装置によれば、前記ソース画像生成手段は、前記複数のソース画像を、照明方向を特定する天頂角及び方位角のうち、天頂角を定数とし、方位角を変数として生成するものであり、前記照明方向推定手段は、前記ソース画像生成手段でもって生成されたソース画像のうち、実際の照明方向によるソース画像との整合の度合いを示す第2評価関数によって、最も上位と評価されるソース画像を選択し、該ソース画像における方位角の変数値と天頂角の定数値を推定照明方向として推定できる。上記構成により、最も上位と評価されるソース画像を選択し、該ソース画像における天頂角及び方位角の変数値を実際の照明方向として検出することができる。また、天頂角の違いはソース画像に大きく反映されないため、定数値と仮定することで、高精度に、高速に、照明方向の方位角や天頂角を推定し、フォトメトリックステレオ処理を高速に行うことが可能となる。   Furthermore, according to the image inspection apparatus according to the seventh aspect, the source image generation means uses the zenith angle as a constant among the zenith angle and the azimuth angle that specify the illumination direction. A second evaluation function that indicates a degree of matching with the source image according to an actual illumination direction among the source images generated by the source image generation unit; Thus, it is possible to select the source image evaluated as the highest rank and estimate the azimuth angle variable value and the zenith angle constant value in the source image as the estimated illumination direction. With the above configuration, it is possible to select the source image that is evaluated as the highest rank, and to detect the zenith angle and azimuth angle variable values in the source image as the actual illumination direction. Also, since the difference in zenith angle is not greatly reflected in the source image, assuming a constant value, the azimuth angle and zenith angle of the illumination direction are estimated with high accuracy and high speed, and photometric stereo processing is performed at high speed. It becomes possible.

さらにまた、第8の側面に係る画像検査装置によれば、前記第2評価関数は、天頂角を定数とし、方位角を変数として算出されて生成されたソース画像から、方位角に対して、ワークの表面の凸凹の凸成分の表出割合を数値化した関数とできる。上記構成により、第2評価関数の値が最大となるとき、実際の照明方向によるソース画像との整合の度合いが最大となるため、このときのソース画像における天頂角及び方位角の変数値を実際の照明方向として検出することができる。   Furthermore, according to the image inspection apparatus according to the eighth aspect, the second evaluation function has a zenith angle as a constant and a azimuth angle as a variable. The expression ratio of the convex / concave component of the workpiece surface can be expressed as a function. With the above configuration, when the value of the second evaluation function is maximized, the degree of matching with the source image in the actual illumination direction is maximized. Therefore, the variable values of the zenith angle and azimuth angle in the source image at this time are actually Can be detected as the illumination direction.

さらにまた、第9の側面に係る画像検査装置によれば、変数としての方位角は、予め定められた組み合わせの中から値が設定できる。上記構成により、予め定められた組み合わせの中から変数としての方位角を設定するので、フォトメトリックステレオ処理をより高速に行うことが可能となる。   Furthermore, according to the image inspection apparatus according to the ninth aspect, the azimuth angle as a variable can be set from a predetermined combination. With the above configuration, the azimuth angle as a variable is set from predetermined combinations, so that photometric stereo processing can be performed at higher speed.

さらにまた、第10の側面に係る画像検査装置によれば、変数としての方位角は、均等の角度巾で値を設定できる。上記構成により、均等の角度巾で変数としての方位角を設定するので、フォトメトリックステレオ処理をより高速に行うことが可能となる。   Furthermore, according to the image inspection apparatus according to the tenth aspect, the azimuth angle as a variable can be set with a uniform angular width. With the above configuration, the azimuth angle as a variable is set with a uniform angular width, so that photometric stereo processing can be performed at higher speed.

さらにまた、第11の側面に係る画像検査装置によれば、前記照明方向推定手段は、ワークを、鏡面反射成分を含む半球状と推定し、さらに前記ソース画像毎に、ワークのソース画像中での中心座標を基点として、ワークからの鏡面反射成分の画像での中心にあるハレーション座標のベクトルを求め、前記ベクトルの方向を、前記ソース画像を生成した際の照明方向の方位角として算出し、前記ベクトルの画素数とワークの大きさの画素数との比から、前記ソース画像を生成した際の照明方向の天頂角を算出できる。上記構成により、フォトメトリックステレオ法を利用した計算処理を経ずに、簡単なアルゴリズムによる計算処理で済むため、高精度に、高速に、照明方向の方位角や天頂角を推定することができ、その後のフォトメトリックステレオ処理に迅速に移行することができる。   Furthermore, according to the image inspection apparatus according to the eleventh aspect, the illumination direction estimating means estimates the workpiece as a hemisphere including a specular reflection component, and further, for each source image, in the source image of the workpiece. From the center coordinates of the base point, obtain a vector of halation coordinates in the center of the specular reflection component image from the workpiece, calculate the direction of the vector as the azimuth of the illumination direction when generating the source image, From the ratio of the number of pixels of the vector and the number of pixels of the workpiece size, the zenith angle in the illumination direction when the source image is generated can be calculated. With the above configuration, calculation processing using a simple algorithm is sufficient without performing calculation processing using the photometric stereo method, so the azimuth angle and zenith angle of the illumination direction can be estimated with high accuracy and high speed. The subsequent photometric stereo processing can be quickly transferred.

さらにまた、第12の側面に係る画像検査装置によれば、前記照明方向推定手段は、ワークの高さを既知として、前記ソース画像毎に、ワークのソース画像での中心座標を基点として、ワークのソース画像での影の先端にある影座標のベクトルを求め、前記ベクトルの方向を、前記ソース画像を生成した際の照明方向の方位角として算出し、前記ベクトルの画素数とワークの高さの画素数との比から、前記ソース画像を生成した際の照明方向の天頂角を算出できる。上記構成により、フォトメトリックステレオ法を利用した計算処理を経ずに、簡単なアルゴリズムによる計算処理で済むため、高精度に、高速に、照明方向の方位角や天頂角を推定することができ、その後のフォトメトリックステレオ処理に迅速に移行することができる。   Still further, according to the image inspection apparatus according to the twelfth aspect, the illumination direction estimating means sets the workpiece height as known, and for each source image, uses the center coordinates in the source image of the workpiece as a base point. The vector of the shadow coordinate at the tip of the shadow in the source image is calculated, the direction of the vector is calculated as the azimuth angle of the illumination direction when the source image is generated, and the number of pixels in the vector and the height of the workpiece From the ratio to the number of pixels, the zenith angle in the illumination direction when the source image is generated can be calculated. With the above configuration, calculation processing using a simple algorithm is sufficient without performing calculation processing using the photometric stereo method, so the azimuth angle and zenith angle of the illumination direction can be estimated with high accuracy and high speed. The subsequent photometric stereo processing can be quickly transferred.

さらにまた、第13の側面に係る画像検査装置によれば、前記照明方向推定手段は、予め設定された、前記撮像手段及び前記照明手段が配置された状態での天頂角及び/又は方位角の設定範囲を、推定された天頂角及び/又は方位角と比較して、前記設定範囲を外れた場合には警告を発するよう構成できる。上記構成により、ユーザは照明や撮像手段の設置や設定の間違いに気付くことができ、ユーザビリティが向上する。   Furthermore, according to the image inspection apparatus according to the thirteenth aspect, the illumination direction estimation means has a preset zenith angle and / or azimuth angle in a state where the imaging means and the illumination means are arranged. The setting range can be compared with the estimated zenith angle and / or azimuth angle, and a warning can be generated if the setting range is not met. With the above configuration, the user can notice an error in the installation or setting of the illumination or imaging means, and usability is improved.

さらにまた、第14の側面に係る画像検査装置によれば、前記照明制御手段は、異なる仮定照明方向毎にソース画像を生成する際の点灯順を、任意に変更可能に構成できる。   Furthermore, according to the image inspection apparatus according to the fourteenth aspect, the illumination control unit can arbitrarily change the lighting order when generating the source image for each different assumed illumination direction.

さらにまた、第15の側面に係る画像検査装置によれば、前記ソース画像生成手段は、前記撮像手段によって撮像された複数の部分照明画像同士で、対応関係にある画素毎の画素値を用いて、フォトメトリックステレオ法に基づき、各画素のワークの表面に対する法線ベクトルを算出するための法線ベクトル算出手段と、前記法線ベクトル算出手段で算出された各画素の法線ベクトルに対して、X方向及びY方向に微分処理を施し、ワークの表面の傾きの輪郭を示す輪郭画像を生成するための輪郭画像生成手段とを含むことができる。上記構成により、法線ベクトルに微分処理を施し、ワークの表面の傾きの輪郭を示す輪郭画像を生成し、この輪郭画像を検査対象の画像として適用することで、ワークや照明の傾きの影響を受け難い、従来のフォトメトリックステレオを用いた高さ計測よりも環境にロバストな画像検査を実現できる。特に、フォトメトリックステレオ法を利用して第1次の傾き画像を生成することを出発点としながらも、得られた第1次の傾き画像をX方向及びY方向に微分処理して第2次の傾き画像、すなわち、輪郭抽出画像を作成するようにした構成を備えているので、より簡単、かつ、ロバストにワークの傷や印字を検査できる。このようなフォトメトリックステレオ法を応用したことによる効果に加えて、ユーザがフォトメトリックステレオ法を利用して画像検査を行う際に、撮像手段や照明をラフに設置したとしても、細かな設定操作を強いられることなく、最適な照明条件で画像検査を行うことができるという作用効果も奏する。さらに本来の傷と元々ある輪郭と区別するのは通常困難であるため、傷があってはいけない箇所をサーチして検査領域とすることが求められているが、テクスチャ抽出画像でサーチをして、検査領域を決めてから傷検査を行うことができる。また、OCRを行う際にも、テクスチャ抽出画像でサーチをして、OCRを行う対象領域を決めてからOCRを行うことができる。   Furthermore, according to the image inspection apparatus according to the fifteenth aspect, the source image generation unit uses a pixel value for each pixel having a correspondence relationship between the plurality of partial illumination images captured by the imaging unit. Based on the photometric stereo method, a normal vector calculating means for calculating a normal vector for the surface of the work of each pixel, and a normal vector of each pixel calculated by the normal vector calculating means, And a contour image generating means for performing a differentiation process in the X direction and the Y direction to generate a contour image indicating a contour of the inclination of the surface of the workpiece. With the above configuration, the normal vector is subjected to differentiation processing to generate a contour image indicating the contour of the workpiece surface tilt, and this contour image is applied as an image to be inspected, thereby affecting the influence of the workpiece or illumination tilt. Image inspection that is harder to receive and more robust to the environment than conventional height measurement using photometric stereo can be realized. In particular, the first-order inclination image is generated using the photometric stereo method, and the obtained first-order inclination image is differentiated in the X direction and the Y direction to obtain the second order. Since it is configured to create a tilt image, that is, a contour extraction image, it is possible to more easily and robustly inspect for scratches and prints on the workpiece. In addition to the effects of applying such a photometric stereo method, even when the user performs image inspection using the photometric stereo method, even if imaging means and illumination are roughly installed, detailed setting operations There is also an effect that the image inspection can be performed under the optimal illumination condition without being forced to perform the above. Furthermore, since it is usually difficult to distinguish between the original scratch and the original contour, it is required to search for an area that should not have a scratch as an inspection area. After the inspection area is determined, the scratch inspection can be performed. Also, when performing OCR, it is possible to perform OCR after performing a search on a texture extracted image and determining a target area for performing OCR.

さらにまた、第16の側面に係る画像検査装置によれば、さらに生成された輪郭画像に対して検査対象となる検査領域の位置を特定するための検査領域特定手段と、前記検査領域特定手段で特定された検査領域内の傷を検出するための画像処理を施すための画像処理手段と、前記画像処理手段の処理結果に基づいて、ワーク表面の傷の有無を判定するための判定手段とを備えることができる。上記構成により、輪郭抽出画像生成後の傷検査に必要な傷検査ツールを備えたことで、フォトメトリックステレオ技術は三次元計測の一つの手法であるというのが一般的な共通認識であるところ、フォトメトリックステレオ技術を傷検査に応用した実用品として位置づけられる画像検査装置を提供できる。   Furthermore, according to the image inspection apparatus according to the sixteenth aspect, the inspection area specifying means for specifying the position of the inspection area to be inspected with respect to the generated contour image, and the inspection area specifying means Image processing means for performing image processing for detecting a flaw in the specified inspection area, and determination means for judging the presence or absence of a flaw on the workpiece surface based on the processing result of the image processing means Can be provided. With the above configuration, by providing a flaw inspection tool necessary for flaw inspection after generating the contour extraction image, it is a common common perception that photometric stereo technology is one method of three-dimensional measurement, It is possible to provide an image inspection apparatus that is positioned as a practical product that applies photometric stereo technology to scratch inspection.

さらにまた、第17の側面に係る画像検査方法によれば、ワークの画像を撮像して外観を検査する検査方法であって、ワークを、互いに異なる三以上の照明手段を一ずつ所定の点灯順にて点灯させて、異なる実際の照明方向から所定の点灯タイミングで照明すると共に、共通の撮像手段を用いて、各実際の照明方向毎に一の部分照明画像を撮像して、実際の照明方向が異なる複数枚の部分照明画像を取得する工程と、異なる照明手段で照明して取得した複数の部分照明画像同士で、対応関係にある画素毎の画素値を用いて、フォトメトリックステレオ法に基づき、照明方向を仮定した仮定照明方向におけるワークの表面のソース画像を、ソース画像生成手段で複数の異なる仮定照明方向毎に生成する工程と、前記ソース画像生成手段によって仮定照明方向毎に生成された複数のソース画像に基づき、照明方向推定手段でもって、前記照明手段における実際の照明方向と最も整合する推定照明方向を検出する工程とを含むことができる。これにより、実際の照明方向が画像検査装置側で不明な場合であっても、仮定照明方向の異なる複数のソース画像に基づいて、実際の照明方向を推定照明方向として推定することが可能となる。この結果、照明手段の配置を厳格に行わずともフォトメトリックステレオ法に基づく画像検査が可能となり、従来手間のかかっていた照明手段の設置作業を大幅に簡素化できる利点が得られる。   The image inspection method according to the seventeenth aspect is an inspection method for inspecting an appearance by capturing an image of a workpiece, wherein the workpiece is subjected to three or more different illumination means one by one in a predetermined lighting order. And illuminating at a predetermined lighting timing from different actual illumination directions, and using a common imaging means, one partial illumination image is captured for each actual illumination direction, and the actual illumination direction is determined. Based on the photometric stereo method, using a pixel value for each pixel in a correspondence relationship between a step of obtaining a plurality of different partial illumination images and a plurality of partial illumination images obtained by illumination with different illumination means, Generating a source image of the surface of the workpiece in the assumed illumination direction assuming the illumination direction for each of a plurality of different assumed illumination directions by the source image generating means; and Based on the plurality of source images generated for each constant illumination direction, with the illumination direction estimation means may include a step of detecting an estimated illumination direction most consistent with the actual illumination direction in the illumination means. Accordingly, even when the actual illumination direction is unknown on the image inspection apparatus side, the actual illumination direction can be estimated as the estimated illumination direction based on a plurality of source images having different assumed illumination directions. . As a result, it is possible to perform image inspection based on the photometric stereo method without strictly arranging the illumination means, and there is an advantage that the installation work of the illumination means, which has conventionally been troublesome, can be greatly simplified.

さらにまた、第18の側面に係る画像検査プログラムによれば、ワークの画像を撮像して外観を検査するための検査プログラムであって、コンピュータに、ワークを、互いに異なる三以上の照明手段を一ずつ所定の点灯順にて点灯させて、異なる実際の照明方向から所定の点灯タイミングで照明すると共に、共通の撮像手段を用いて、各実際の照明方向毎に一の部分照明画像を撮像して、実際の照明方向が異なる複数枚の部分照明画像を取得する機能と、異なる照明手段で照明して取得した複数の部分照明画像同士で、対応関係にある画素毎の画素値を用いて、フォトメトリックステレオ法に基づき、照明方向を仮定した仮定照明方向におけるワークの表面のソース画像を、ソース画像生成手段で複数の異なる仮定照明方向毎に生成する機能と、前記ソース画像生成手段によって仮定照明方向毎に生成された複数のソース画像に基づき、照明方向推定手段でもって、前記照明手段における実際の照明方向と最も整合する推定照明方向を検出する機能とを実現させることができる。これにより、実際の照明方向が画像検査装置側で不明な場合であっても、仮定照明方向の異なる複数のソース画像に基づいて、実際の照明方向を推定することが可能となる。この結果、照明手段の配置を厳格に行わずともフォトメトリックステレオ法に基づく画像検査が可能となり、従来手間のかかっていた照明手段の設置作業を大幅に簡素化できる利点が得られる。   Furthermore, the image inspection program according to the eighteenth aspect is an inspection program for inspecting an appearance by capturing an image of a workpiece, and the computer is provided with three or more illumination means different from each other. Illuminate in a predetermined lighting order one by one and illuminate at a predetermined lighting timing from different actual illumination directions, and use a common imaging means to capture one partial illumination image for each actual illumination direction, Photometric using the pixel value of each pixel that has a correspondence relationship between the function of acquiring multiple partial illumination images with different actual illumination directions and the multiple partial illumination images acquired by illuminating with different illumination means Function to generate source image of workpiece surface in hypothetical illumination direction assuming illumination direction based on stereo method for each of multiple different hypothetical illumination directions by source image generation means A function of detecting an estimated illumination direction that most closely matches an actual illumination direction in the illumination means, based on a plurality of source images generated for each assumed illumination direction by the source image generation means. Can be realized. Thereby, even if the actual illumination direction is unknown on the image inspection apparatus side, the actual illumination direction can be estimated based on a plurality of source images having different assumed illumination directions. As a result, it is possible to perform image inspection based on the photometric stereo method without strictly arranging the illumination means, and there is an advantage that the installation work of the illumination means, which has conventionally been troublesome, can be greatly simplified.

また本発明の第19の側面に係るコンピュータで読み取り可能な記録媒体または記憶した機器は、上記画像検査プログラムを格納するものである。記録媒体には、CD−ROM、CD−R、CD−RWやフレキシブルディスク、磁気テープ、MO、DVD−ROM、DVD−RAM、DVD−R、DVD+R、DVD−RW、DVD+RW、Blu−ray(商品名)、HD DVD(AOD)等の磁気ディスク、光ディスク、光磁気ディスク、半導体メモリその他のプログラムを格納可能な媒体が含まれる。またプログラムには、上記記録媒体に格納されて配布されるものの他、インターネット等のネットワーク回線を通じてダウンロードによって配布される形態のものも含まれる。さらに記憶した機器には、上記プログラムがソフトウェアやファームウェア等の形態で実行可能な状態に実装された汎用もしくは専用機器を含む。さらにまたプログラムに含まれる各処理や機能は、コンピュータで実行可能なプログラムソフトウエアにより実行してもよいし、各部の処理を所定のゲートアレイ(FPGA、ASIC)等のハードウエア、又はプログラムソフトウエアとハードウェアの一部の要素を実現する部分的ハードウエアモジュールとが混在する形式で実現してもよい。   A computer-readable recording medium or a stored device according to the nineteenth aspect of the present invention stores the image inspection program. CD-ROM, CD-R, CD-RW, flexible disk, magnetic tape, MO, DVD-ROM, DVD-RAM, DVD-R, DVD + R, DVD-RW, DVD + RW, Blu-ray (product) Name), HD DVD (AOD), and other magnetic disks, optical disks, magneto-optical disks, semiconductor memories, and other media that can store programs. The program includes a program distributed in a download manner through a network line such as the Internet, in addition to a program stored and distributed in the recording medium. Furthermore, the stored devices include general-purpose or dedicated devices in which the program is implemented in a state where it can be executed in the form of software, firmware, or the like. Furthermore, each process and function included in the program may be executed by computer-executable program software, or each part of the process or hardware may be executed by hardware such as a predetermined gate array (FPGA, ASIC), or program software. And a partial hardware module that realizes a part of hardware elements may be mixed.

本発明の実施形態1に係る画像検査装置の構成を示すブロック図である。It is a block diagram which shows the structure of the image inspection apparatus which concerns on Embodiment 1 of this invention. 図1の画像検査装置の撮像手段と照明手段の位置関係を示す模式平面図である。It is a schematic plan view which shows the positional relationship of the imaging means and illumination means of the image inspection apparatus of FIG. 図1の画像検査装置の撮像手段と照明手段の位置関係を示す模式側面図である。It is a model side view which shows the positional relationship of the imaging means and illumination means of the image inspection apparatus of FIG. 実施形態2に係る4つの照明ブロックを実現する照明手段を示す模式図である。It is a schematic diagram which shows the illumination means which implement | achieves the four illumination blocks which concern on Embodiment 2. FIG. 図4の照明手段で5つの照明ブロックを実現する様子を示す模式平面図である。It is a schematic plan view which shows a mode that five illumination blocks are implement | achieved with the illumination means of FIG. 実施形態3に係る照明手段を示す模式平面図である。It is a schematic plan view which shows the illumination means which concerns on Embodiment 3. 実施形態4に係る照明手段を示す模式平面図である。It is a schematic plan view which shows the illumination means which concerns on Embodiment 4. 変形例に係る照明手段を示す模式平面図である。It is a schematic plan view which shows the illumination means which concerns on a modification. 他の変形例に係る照明手段を示す模式平面図である。It is a schematic plan view which shows the illumination means which concerns on another modification. 実施形態5に係る画像検査装置の構成を示す模式図である。FIG. 10 is a schematic diagram illustrating a configuration of an image inspection apparatus according to a fifth embodiment. 実施形態6に係る画像検査装置の構成を示す模式図である。FIG. 10 is a schematic diagram illustrating a configuration of an image inspection apparatus according to a sixth embodiment. 画像処理部の信号処理系の説明に供するブロック図である。It is a block diagram with which it uses for description of the signal processing system of an image processing part. 図13Aは、フォトメトリックステレオ法の基本原理を説明するための、拡散反射面Sと照明との位置関係を示す図、図13BはL1から光を照射した状態を示す図、図13CはL2から光を照射した状態を示す図、図13Dは照射方向と反射光の明るさの組み合わせから、表面の向きを推定することを説明するための図である。FIG. 13A is a diagram showing a positional relationship between the diffuse reflection surface S and illumination for explaining the basic principle of the photometric stereo method, FIG. 13B is a diagram showing a state in which light is irradiated from L1, and FIG. 13C is a diagram from L2. The figure which shows the state which irradiated the light, FIG. 13D is a figure for demonstrating estimating the direction of the surface from the combination of an irradiation direction and the brightness of reflected light. 図14Aは輪郭抽出画像の生成方法を説明するための、垂直方向に微分した傾き画像の一例を示す図、図14Bは水平方向に微分した傾き画像の一例を示す図、図14Cは輪郭抽出画像の一例を示す図である。FIG. 14A is a diagram showing an example of a tilt image differentiated in the vertical direction, FIG. 14B is a diagram showing an example of a tilt image differentiated in the horizontal direction, and FIG. It is a figure which shows an example. 図15Aは、δ2s/δx2及びδ2s/δy2の計算方法を説明するための、表面情報を示す図、図15Bは傾き画像を示す図、図15Cは前進差分を示す図、図15Dは中央差分を示す図である。15A is a diagram showing surface information for explaining a calculation method of δ 2 s / δx 2 and δ 2 s / δy 2 , FIG. 15B is a diagram showing an inclination image, and FIG. 15C is a diagram showing a forward difference, FIG. 15D is a diagram showing the central difference. 図16Aはテクスチャ抽出画像の生成方法を説明するための、ソース画像を示す図、図16Bは平均法による処理を行った画像を示す図、図16Cはハレーション除去法による処理を行った画像を示す図である。FIG. 16A is a diagram showing a source image for explaining a generation method of a texture extraction image, FIG. 16B is a diagram showing an image processed by the averaging method, and FIG. 16C shows an image processed by the halation removal method FIG. アングルノイズ低減の説明に供する図である。It is a figure where it uses for description of angle noise reduction. 照明とカメラが一体型の場合に、障害物と干渉する様子を示す模式断面である。It is a schematic cross section which shows a mode that it interferes with an obstruction, when illumination and a camera are integrated. カメラが照明光の一部を遮る様子を示す模式図である。It is a schematic diagram which shows a mode that a camera blocks a part of illumination light. 照明とカメラを分離型とした構成を示す模式断面図である。It is a schematic cross section which shows the structure which made the illumination and the camera a separated type. 図21Aは照明とカメラとが分離型であるメリットを説明するための、LWDを小さく取った場合、図21BはLWDを大きく取った場合を示す図である。FIG. 21A is a diagram illustrating a case where the LWD is set small, and FIG. 21B is a diagram illustrating a case where the LWD is set large, for explaining the merit that the illumination and the camera are separated. リング状の照明を配置する様子を示す模式図である。It is a schematic diagram which shows a mode that ring-shaped illumination is arrange | positioned. リング状の照明とカメラの回転位置を一致させる様子を示す模式図である。It is a schematic diagram which shows a mode that ring-shaped illumination and the rotation position of a camera are made to correspond. 天頂角及び方位角の定義について説明するための図である。It is a figure for demonstrating the definition of a zenith angle and an azimuth. 図25Aは、仮定照明方向と整合する天頂角及び方位角で得られた輪郭抽出画像、図25Bは誤った天頂角と正しい方位角で得られた輪郭抽出画像、図25Cは正しい天頂角と誤った方位角(全体45°ずれ)で得られた輪郭抽出画像、図25Dは正しい天頂角と誤った方位角(シャッフル)で得られた輪郭抽出画像を示すイメージ図である。FIG. 25A is a contour extraction image obtained with a zenith angle and an azimuth angle that matches the assumed illumination direction, FIG. 25B is a contour extraction image obtained with an incorrect zenith angle and a correct azimuth angle, and FIG. 25C is a correct zenith angle and error. FIG. 25D is an image diagram showing a contour extraction image obtained with a correct zenith angle and an incorrect azimuth angle (shuffle). 照明設置の間違え方として、回転があることを説明するための図である。It is a figure for demonstrating that there exists rotation as a way of making a mistake in lighting installation. 図27Aは仮定照明方向と整合する照明方向を0°として、45°の角度巾で回転させて得られた、0°、図27Bは45°、図27Cは90°、図27Dは135°、図27Eは180°、図27Fは225°、図27Gは270°、図27Hは315°の方位角で得られた輪郭抽出画像を示すイメージ図である。27A is obtained by rotating at an angular width of 45 °, assuming an illumination direction that matches the assumed illumination direction as 0 °, 0 °, FIG. 27B is 45 °, FIG. 27C is 90 °, FIG. 27D is 135 °, FIG. 27E is an image diagram showing a contour extraction image obtained at an azimuth angle of 180 °, FIG. 27F at 225 °, FIG. 27G at 270 °, and FIG. 27H at 315 °. 照明設置の間違え方として、シャッフルがあることを説明するための図である。It is a figure for demonstrating that there is shuffle as a way of making a mistake in lighting installation. 図29Aは、仮定照明方向と整合する照明方向による輪郭抽出画像であり、図29B〜図29Fは、シャッフルのすべての組み合わせにおいて生成した輪郭抽出画像を示すイメージ図である。FIG. 29A is a contour extraction image with an illumination direction that matches the assumed illumination direction, and FIGS. 29B to 29F are image diagrams illustrating the contour extraction images generated in all combinations of shuffles. 様々なワークに対して、回転をさせて得たソース画像から、回転角度に対する高さの平均を算出してプロットしたグラフである。It is the graph which calculated and averaged the height with respect to a rotation angle from the source image obtained by rotating about various workpieces. シャッフルのすべての組み合わせに対して得たソース画像から、回転角度に対する高さの平均を算出してプロットしたグラフである。It is the graph which computed and averaged the height with respect to a rotation angle from the source image acquired with respect to all the combinations of shuffle. 照明設置の間違え方として、十字軸(xy軸)からのずれがあることを説明するための図である。It is a figure for demonstrating that there exists a shift | offset | difference from a cross axis (xy axis | shaft) as a way of making a mistake in lighting installation. 照明設置の間違え方として、天頂角非対称ずれ×2があることを説明するための図である。It is a figure for demonstrating that there exists a zenith angle asymmetrical deviation x2 as a mistake of lighting installation. 照明設置の間違え方として、天頂角対称変化×2があることを説明するための図である。It is a figure for demonstrating that there exists a zenith angle symmetrical change x2 as a mistake of lighting installation. 図35Aはワークが半球状で鏡面反射する場合の実際の照明方向の検出方法を説明するための、天頂角θの求め方を説明する図、図35Bは方位角の求め方を説明する図である。FIG. 35A is a diagram for explaining how to determine the zenith angle θ for explaining a method for detecting the actual illumination direction when the work is hemispherical and specularly reflects, and FIG. 35B is a diagram for explaining how to obtain the azimuth angle. is there. 図36Aはワークの高さが既知である場合の実際の照明方向の検出方法を説明するための、天頂角θの求め方を説明する図、図36Bは方位角の求め方を説明する図である。FIG. 36A is a diagram for explaining how to find the zenith angle θ for explaining a method for detecting the actual illumination direction when the height of the workpiece is known, and FIG. 36B is a diagram for explaining how to find the azimuth angle. is there. フォトメトリックステレオ法を利用した照明方向の検出処理の流れ示すフローチャートである。It is a flowchart which shows the flow of the detection process of the illumination direction using the photometric stereo method. フォトメトリックステレオ法を利用しない照明方向の検出処理の流れを示すフローチャートである。It is a flowchart which shows the flow of the detection process of the illumination direction which does not utilize a photometric stereo method. 実施例に係る画像検査方法を示すフローチャートである。It is a flowchart which shows the image inspection method which concerns on an Example. 変形例に係る画像検査方法を示すフローチャートである。It is a flowchart which shows the image inspection method which concerns on a modification.

以下、本発明の実施の形態を図面に基づいて説明する。ただし、以下に示す実施の形態は、本発明の技術思想を具体化するための例示であって、本発明は以下のものに特定されない。また、本明細書は特許請求の範囲に示される部材を、実施の形態の部材に特定するものでは決してない。特に実施の形態に記載されている構成部品の寸法、材質、形状、その相対的配置等は特に特定的な記載がない限りは、本発明の範囲をそれのみに限定する趣旨ではなく、単なる説明例にすぎない。なお、各図面が示す部材の大きさや位置関係等は、説明を明確にするため誇張していることがある。さらに以下の説明において、同一の名称、符号については同一もしくは同質の部材を示しており、詳細説明を適宜省略する。さらに、本発明を構成する各要素は、複数の要素を同一の部材で構成して一の部材で複数の要素を兼用する態様としてもよいし、逆に一の部材の機能を複数の部材で分担して実現することもできる。
(1.画像検査装置1の構成)
Hereinafter, embodiments of the present invention will be described with reference to the drawings. However, the embodiment described below is an example for embodying the technical idea of the present invention, and the present invention is not limited to the following. Further, the present specification by no means specifies the members shown in the claims to the members of the embodiments. In particular, the dimensions, materials, shapes, relative arrangements, and the like of the component parts described in the embodiments are not intended to limit the scope of the present invention unless otherwise specified, and are merely explanations. It is just an example. Note that the size, positional relationship, and the like of the members shown in each drawing may be exaggerated for clarity of explanation. Furthermore, in the following description, the same name and symbol indicate the same or the same members, and detailed description thereof will be omitted as appropriate. Furthermore, each element constituting the present invention may be configured such that a plurality of elements are constituted by the same member and the plurality of elements are shared by one member, and conversely, the function of one member is constituted by a plurality of members. It can also be realized by sharing.
(1. Configuration of the image inspection apparatus 1)

本発明の実施の形態1に係る画像検査装置のブロック図を、図1に示す。この図に示す画像検査装置1は、ワーク(以下、「ワークWK」ともいう。)を一定の方向から撮像する撮像手段11と、ワークWKを異なる三以上の照明方向から照明するための照明手段と、各照明手段を一ずつ点灯順に点灯させるための照明制御手段31と、照明制御手段と撮像手段と接続されてこれらを制御する画像処理部41を備えている。画像処理部41と撮像手段とは、撮像ケーブル12を介して、また画像処理部41と照明制御手段31とは照明ケーブル32を介して、それぞれ接続されている。また画像処理部は、表示手段51と操作手段61を接続している。さらに画像処理部には、必要に応じて外部機器であるPLC(Programable Logic Controller)やコンピュータ等と接続することもできる。   FIG. 1 shows a block diagram of an image inspection apparatus according to Embodiment 1 of the present invention. The image inspection apparatus 1 shown in this figure includes an imaging unit 11 that images a workpiece (hereinafter also referred to as “work WK”) from a certain direction, and an illumination unit that illuminates the workpiece WK from three or more different illumination directions. A lighting control unit 31 for lighting each lighting unit one by one in the lighting order, and an image processing unit 41 connected to the lighting control unit and the imaging unit to control them. The image processing unit 41 and the imaging unit are connected via the imaging cable 12, and the image processing unit 41 and the illumination control unit 31 are connected via the illumination cable 32, respectively. The image processing unit connects the display unit 51 and the operation unit 61. Furthermore, the image processing unit can be connected to an external device such as a PLC (Programmable Logic Controller) or a computer as necessary.

撮像手段は、照明制御手段により各照明手段を点灯させる照明タイミングにて、ワークWKを一定の方向から撮像することにより、照明方向の異なる複数の部分照明画像を撮像する。   The imaging unit captures a plurality of partial illumination images having different illumination directions by imaging the workpiece WK from a certain direction at an illumination timing at which each illumination unit is turned on by the illumination control unit.

画像処理部は、撮像手段によって撮像された複数の部分照明画像同士で、対応関係にある画素毎の画素値を用いて、フォトメトリックステレオ法に基づき、照明方向を仮定した仮定照明方向におけるワークの表面のソース画像を、複数の異なる仮定照明方向毎に生成するソース画像生成手段として機能する。ソース画像生成手段は、具体的には、法線ベクトル算出手段41aと、輪郭画像生成手段41bと、テクスチャ抽出画像生成手段41cと、検査領域特定手段41dと、画像処理手段41eと、判定手段41fと、照明方向推定手段41gの機能を実現する。法線ベクトル算出手段41aは、撮像手段によって撮像された複数の部分照明画像同士で、対応関係にある画素毎の画素値を用いて、各画素のワークWKの表面に対する法線ベクトルnを算出する。輪郭画像生成手段41bは、算出された各画素の法線ベクトルnに対して、X方向及びY方向に微分処理を施し、ワークWK表面の傾きの輪郭を示す輪郭画像を生成する。テクスチャ抽出画像生成手段41cは、照明手段による照明する回数個ある、算出された各画素の法線ベクトルnから、各画素のアルベドを算出し、アルベドから、ワークWKの表面の傾きの影響を除去した模様を示すテクスチャ抽出画像を生成する。検査領域特定手段41dは、生成された輪郭画像に対して検査対象となる検査領域の位置を特定する。画像処理手段41eは、特定された検査領域内の傷を検出するための画像処理を施す。判定手段41fは、処理結果に基づいて、ワークWK表面の傷の有無を判定する。照明方向推定手段41gは、ソース画像生成手段によって生成された複数の画像を基にする複数のソース画像SP(後述)から、照明手段における実際の照明方向と最も整合する照明方向を検出する。   The image processing unit uses a pixel value for each pixel having a correspondence relationship between a plurality of partial illumination images captured by the imaging unit, and based on the photometric stereo method, the image processing unit It functions as source image generation means for generating a source image of the surface for each of a plurality of different assumed illumination directions. Specifically, the source image generation means includes a normal vector calculation means 41a, a contour image generation means 41b, a texture extraction image generation means 41c, an inspection region specification means 41d, an image processing means 41e, and a determination means 41f. And the function of the illumination direction estimation means 41g is implement | achieved. The normal vector calculation unit 41a calculates a normal vector n with respect to the surface of the work WK of each pixel by using pixel values for each pixel having a correspondence relationship among the plurality of partial illumination images captured by the imaging unit. . The contour image generation unit 41b performs a differentiation process on the calculated normal vector n of each pixel in the X direction and the Y direction to generate a contour image indicating the contour of the inclination of the workpiece WK surface. The texture extraction image generating unit 41c calculates the albedo of each pixel from the calculated normal vector n of each pixel that is illuminated by the illuminating unit, and removes the influence of the surface inclination of the workpiece WK from the albedo. A texture extraction image showing the processed pattern is generated. The inspection area specifying unit 41d specifies the position of the inspection area to be inspected with respect to the generated contour image. The image processing unit 41e performs image processing for detecting a flaw in the specified inspection area. The determination unit 41f determines the presence or absence of a scratch on the surface of the workpiece WK based on the processing result. The illumination direction estimation unit 41g detects an illumination direction that most closely matches the actual illumination direction in the illumination unit from a plurality of source images SP (described later) based on the plurality of images generated by the source image generation unit.

撮像手段と照明手段とは、別個の部材として配置可能としている。これによって自由度の高いレイアウトが可能となる。一例として、図2の模式平面図及び図3の模式側面図に示すように、ステージSG上に載置されたワークWKの真上に、光軸を鉛直方向に向けた撮像手段11を配置する。また撮像手段11の周囲の東西南北の方位に、4個の照明手段、すなわち第一照明手段21、第二照明手段22、第三照明手段23、第四照明手段24を、同一の高さに配置する。配置された撮像手段と各照明手段の位置関係は、画像検査装置側で記録される。照明制御手段により所定の照明タイミングで各照明手段を順次点灯させて、共通の撮像手段でもって、ワークを一定の方向から撮像して部分照明画像を取得する。   The imaging unit and the illumination unit can be arranged as separate members. This enables a layout with a high degree of freedom. As an example, as shown in the schematic plan view of FIG. 2 and the schematic side view of FIG. 3, the imaging unit 11 with the optical axis directed in the vertical direction is disposed directly above the work WK placed on the stage SG. . Further, the four illumination means, that is, the first illumination means 21, the second illumination means 22, the third illumination means 23, and the fourth illumination means 24 are arranged at the same height in the east, west, north, and south directions around the imaging means 11. Deploy. The positional relationship between the imaging unit arranged and each illumination unit is recorded on the image inspection apparatus side. Each illumination means is sequentially turned on at a predetermined illumination timing by the illumination control means, and the workpiece is imaged from a certain direction with the common imaging means to obtain a partial illumination image.

なお、撮像手段と照明手段とは、別個の部材とする構成に限らず、これらをアーム等を介して一体に構成してもよい。この場合は、予め撮像手段と照明手段の位置関係が固定されているため、光軸を一致させるといった調整作業を不要とできる。ただし、自由度が失われる。
(撮像手段)
Note that the imaging unit and the illumination unit are not limited to being configured as separate members, and may be configured integrally via an arm or the like. In this case, since the positional relationship between the imaging unit and the illumination unit is fixed in advance, it is possible to eliminate the adjustment work of matching the optical axes. However, the degree of freedom is lost.
(Imaging means)

撮像手段11は、例えば、CCD(Charge Coupled Device)カメラやCMOS(Complementary Metal Oxide Semiconductor)イメージャ等の撮像素子が利用できる。撮像素子で被写体の画像を光電変換して画像信号を出力し、出力された画像信号を信号処理ブロックが輝度信号と色差信号とに変換して、撮像ケーブル12で接続された画像処理部41に出力する。
(照明手段)
As the imaging means 11, for example, an imaging element such as a CCD (Charge Coupled Device) camera or a CMOS (Complementary Metal Oxide Semiconductor) imager can be used. The image of the subject is photoelectrically converted by the imaging device to output an image signal, and the output image signal is converted into a luminance signal and a color difference signal by the signal processing block, and the image processing unit 41 connected by the imaging cable 12 is connected. Output.
(Lighting means)

照明手段21、22、23、24は、ワークWKに対して、異なる照明方向から照明光を照射できるよう、図2の模式平面図に示すようにワークWKの周囲をとり囲むように配置される。また図3の模式側面図に示すように、各照明手段は、光軸を斜め下方に向けて設置される。各照明手段で照明されたワークを、共通の撮像手段で撮像できるよう、撮像手段の光軸と、照明手段を設けた平面(仮想回転面)の中心軸とを一致させることが好ましい。また、照明手段同士の間隔(中心軸からの方位角)は、360°を照明手段の数で均等に分割して配置することが好ましい。さらに天頂角は、すべての照明手段で一定とすることが好ましい。さらにまた、各照明手段とワークとの距離も、一定とすること好ましい。このようにすることで、フォトメトリックステレオ処理の演算に必要な方位角や天頂角情報の入力を簡易化できる。また後述の通り、全灯画像MCを撮像する際はすべての照明手段を点灯した全灯状態で撮像するため、上記状態にすれば、全照明の強さを均等に弱めるだけで、ムラの少ない照明状態で撮像できる。   The illumination means 21, 22, 23, and 24 are arranged so as to surround the work WK as shown in the schematic plan view of FIG. 2 so that the work WK can be irradiated with illumination light from different illumination directions. . Further, as shown in the schematic side view of FIG. 3, each illuminating means is installed with its optical axis obliquely downward. It is preferable that the optical axis of the imaging unit and the central axis of the plane (virtual rotation plane) provided with the illumination unit coincide with each other so that the workpiece illuminated by each illumination unit can be imaged by the common imaging unit. Moreover, it is preferable to arrange | position 360 degrees equally as the space | interval (azimuth angle from a central axis) between illumination means, dividing | segmenting equally by the number of illumination means. Furthermore, the zenith angle is preferably constant for all illumination means. Furthermore, it is preferable that the distance between each illumination means and the workpiece is also constant. By doing so, it is possible to simplify the input of azimuth and zenith angle information necessary for the calculation of photometric stereo processing. As will be described later, when capturing the all-lamp image MC, since all the illumination means are imaged in the all-lamp state, the above-described state reduces the intensity of all the illuminations evenly and reduces unevenness. Images can be taken under illumination.

図1の例では、第一照明手段21、第二照明手段22、第三照明手段23、第四照明手段24の4つで構成される。各照明手段は、白熱球や蛍光灯等が利用できる。特に、発光ダイオード(Light Emitting Diode:LED)等の半導体発光素子は、消費電力が少なく長寿命で応答性にも優れ、好ましい。各照明手段は、図1に示すように、それぞれに対応するケーブル71、72、73、74を介して、照明分岐ユニット75に接続され、さらにケーブル76を介して、照明制御手段31に接続されている。
(照明分岐ユニット)
In the example of FIG. 1, the first illumination unit 21, the second illumination unit 22, the third illumination unit 23, and the fourth illumination unit 24 are configured. Each illumination means can use an incandescent bulb or a fluorescent lamp. In particular, a semiconductor light emitting element such as a light emitting diode (LED) is preferable because it consumes less power and has a long life and excellent responsiveness. As shown in FIG. 1, each lighting unit is connected to the lighting branching unit 75 via cables 71, 72, 73, 74 corresponding to each lighting unit, and further connected to the lighting control unit 31 via a cable 76. ing.
(Lighting branch unit)

照明分岐ユニットは、各照明手段を照明制御手段と接続するためのインターフェースである。具体的には、照明手段から延長された照明ケーブルを接続するための照明接続コネクタを設けている。図1の例では、4つの照明手段を接続するよう、4つの照明接続コネクタを設けている。この際、照明ケーブルを正しく照明接続コネクタに接続するよう、設置補助手段としてマーク等を設けてもよい。各照明手段の照明メーブルを、照明分岐ユニットの照明接続コネクタに正しく接続することで、照明制御手段でもって正しい順序で正しい方向から照明手段を点灯でき、さらに各照明タイミングと同期させて撮像手段を動作させることで、部分照明画像を撮像できる。なお、照明分岐ユニットは、図1の例では照明制御手段と別体に設けられているが、この構成に限られず、例えば照明制御手段に照明分岐ユニットを組み込んでもよい。   The illumination branching unit is an interface for connecting each illumination unit to the illumination control unit. Specifically, an illumination connection connector for connecting an illumination cable extended from the illumination means is provided. In the example of FIG. 1, four illumination connection connectors are provided so as to connect the four illumination means. At this time, a mark or the like may be provided as installation assistance means so that the illumination cable is correctly connected to the illumination connection connector. By correctly connecting the illumination table of each illumination means to the illumination connection connector of the illumination branch unit, the illumination means can be lit in the correct direction in the correct order by the illumination control means, and the imaging means can be synchronized with each illumination timing. A partial illumination image can be taken by operating. The illumination branching unit is provided separately from the illumination control unit in the example of FIG. 1, but is not limited to this configuration. For example, the illumination branching unit may be incorporated in the illumination control unit.

照明手段21、22、23、24の照明色は、ワークWKのタイプに応じて変更することもできる。例えば、細かい傷を検査したい場合には、波長が短い青色が好適である。また、着色されたワークを検査するときは、照明の色が邪魔にならないように、白色の照明を使うのが好ましい。さらに、ワークに油が付いているときには、その影響を防ぐために、赤色の照明を採用するとよい。   The illumination colors of the illumination means 21, 22, 23, and 24 can be changed according to the type of the work WK. For example, when it is desired to inspect a fine scratch, blue having a short wavelength is suitable. When inspecting a colored workpiece, it is preferable to use white illumination so that the illumination color does not get in the way. Furthermore, when oil is attached to the workpiece, red illumination may be employed to prevent the influence.

また照明手段は、上述した図1〜図3の例では4個としているが、異なる三以上の照明方向からワークWKを照明できるよう、少なくとも3個あれば足りる。照明手段の数を増やすと、より多くの照明方向から部分照明画像が得られるため、画像検査の精度を向上できる。例えば、北東、北西、南東、南西の方位を加えて全部で8個配置してもよい。また、照明手段同士の間隔(中心軸からの方位角)は、360°を照明手段の数で均等に分割して配置することが好ましい。さらに天頂角は、すべての照明手段で一定とすることが好ましい。なお、処理すべき画像の枚数が増えることで処理量が増え、処理時間が遅くなる。本実施の形態においては、処理速度と演算処理のし易さ、精度等のバランスを考慮して、上述の通り照明手段の数を4個としている。   In the example of FIGS. 1 to 3 described above, the number of illumination means is four. However, at least three illumination means are sufficient so that the workpiece WK can be illuminated from three or more different illumination directions. When the number of illumination means is increased, partial illumination images can be obtained from more illumination directions, so that the accuracy of image inspection can be improved. For example, you may arrange | position eight in total including the northeast, northwest, southeast, and southwest direction. Moreover, it is preferable to arrange | position 360 degrees equally as the space | interval (azimuth angle from a central axis) between illumination means, dividing | segmenting equally by the number of illumination means. Furthermore, the zenith angle is preferably constant for all illumination means. Note that the amount of processing increases as the number of images to be processed increases, and the processing time is delayed. In the present embodiment, the number of illumination means is set to four as described above in consideration of the balance between processing speed, ease of arithmetic processing, accuracy, and the like.

また、照明手段を、環状に配置された複数個の発光素子で構成することもできる。例えば図4に示す実施形態2に係るリング照明では、環状に配置された発光素子を4つの照明ブロックに分割している。そして照明制御手段が、第一照明ブロックを第一照明手段、第二照明ブロックを第二照明手段、第三照明ブロックを第三照明手段、第四照明ブロックを第四照明手段として、それぞれの照明ブロックの照明タイミングを異ならせることで、4つの別個の照明手段が存在するのと同様に制御できる。   Further, the illumination means can be constituted by a plurality of light emitting elements arranged in an annular shape. For example, in the ring illumination according to the second embodiment illustrated in FIG. 4, the annular light emitting element is divided into four illumination blocks. The illumination control means uses the first illumination block as the first illumination means, the second illumination block as the second illumination means, the third illumination block as the third illumination means, and the fourth illumination block as the fourth illumination means. By making the illumination timing of the blocks different, it can be controlled in the same way as there are four separate illumination means.

またこの構成であれば、同一のリング照明を用いて、照明手段の数を任意に変更できる利点も得られる。すなわち、各発光素子の点灯を照明制御手段で任意に制御できる場合は、図5に示すように、環状に配列された発光素子の円周を4区分から5区分に分割するように照明ブロックを変更し、5つの照明ブロックをそれぞれ点灯させる照明タイミングをずらして各部分照明画像を撮像するように照明制御手段で制御することで、5つの照明方向からの部分照明画像を取得できる。さらに同様に環状の円周を6分割、7分割に変更すれば、照明方向をさらに増やすことができる。また、常時一定の照明ブロックにて部分照明画像を取得する構成に限らず、周期毎に照明ブロックを変更してもよい。このように、各発光素子の点灯パターンを調整することで、同一のリング照明を用いて、仮想的に照明ブロックの数を変更し、照明手段の数を調整するのと同様の効果を得ることができる。言い換えると、共通のハードウェアでもって異なる精度に対応できる。   Further, with this configuration, there is an advantage that the number of illumination means can be arbitrarily changed using the same ring illumination. That is, when the lighting control means can arbitrarily control the lighting of each light emitting element, as shown in FIG. 5, the illumination block is divided so that the circumference of the annularly arranged light emitting elements is divided into 4 sections to 5 sections. The partial illumination images from the five illumination directions can be acquired by controlling the illumination control unit so that the partial illumination images are captured by shifting the illumination timing for lighting the five illumination blocks. Similarly, if the annular circumference is changed to 6 divisions and 7 divisions, the illumination direction can be further increased. Moreover, you may change an illumination block for every period, not only the structure which acquires a partial illumination image with a constant illumination block at all times. In this way, by adjusting the lighting pattern of each light emitting element, the same effect as the case of virtually changing the number of illumination blocks and adjusting the number of illumination means using the same ring illumination can be obtained. Can do. In other words, common hardware can handle different accuracies.

さらに照明手段は、円環状に配置する他、実施形態3として図6の模式平面図に示すように、バー状に構成された照明手段を矩形状に配置したり、実施形態4として図7の模式平面図に示すように、多角形状に配置することもできる。   Furthermore, the illumination means is arranged in an annular shape, and as shown in the schematic plan view of FIG. 6 as Embodiment 3, the illumination means configured in a bar shape is arranged in a rectangular shape, or as Embodiment 4 in FIG. As shown in the schematic plan view, they can be arranged in a polygonal shape.

あるいは、照明手段を円や多角形の環状に配置する他、平面状に配置することもできる。例えば、多数の発光素子を平面状に配置し、点灯する照明ブロックを変化させることで、異なる照明方向を実現することもできる。具体的には、図8に示す変形例に係る照明手段のように、同心円状の円環を複数重ねた照明ユニット20’を構成し、半径の異なる各円環をそれぞれ照明ブロックとして照明手段を構成する。あるいは、図9に示す他の変形例に係る照明手段のように、ドットマトリックス状に発光素子を並べた照明ユニット20”としつつ、中心を通る複数の線分で分割した照明ブロックでもって照明手段を構成してもよい。このように本発明において照明手段や照明方向とは、必ずしも物理的に離間された照明に限られず、一の照明手段を複数に分割した照明ブロックでもって、照明を行う構成も含む意味で使用する。   Alternatively, the illumination means can be arranged in a planar shape in addition to the circular or polygonal ring shape. For example, different illumination directions can be realized by arranging a large number of light emitting elements in a plane and changing the illumination block to be lit. Specifically, like the illumination unit according to the modification shown in FIG. 8, the illumination unit 20 ′ is configured by stacking a plurality of concentric rings, and the illumination unit is configured with each ring having a different radius as an illumination block. Configure. Alternatively, as in the illumination unit according to another modified example shown in FIG. 9, the illumination unit 20 ″ is a lighting unit in which light emitting elements are arranged in a dot matrix, and the illumination unit is divided by a plurality of line segments passing through the center. Thus, in the present invention, the illumination means and the illumination direction are not necessarily limited to physically separated illumination, and illumination is performed with an illumination block in which one illumination means is divided into a plurality of parts. It is used in the meaning including the structure.

なお、本実施例においては各照明手段による部分照明光が撮像範囲内で並行光であるとの前提で処理している。部分照明光が平行光である限り、照明光の方向(例えば東西南北のいずれか)だけが問題となり、その詳細な位置、例えば照明手段の光源の座標位置等は考慮する必要はない。
(照明制御手段)
In the present embodiment, processing is performed on the assumption that the partial illumination light from each illumination means is parallel light within the imaging range. As long as the partial illumination light is parallel light, only the direction of the illumination light (for example, any one of east, west, south, and north) becomes a problem, and its detailed position, for example, the coordinate position of the light source of the illumination means, does not need to be considered.
(Lighting control means)

照明制御手段は、三以上の照明手段を一ずつ点灯順に点灯させると共に、各照明手段を点灯させる照明タイミングにて、ワークを撮像手段で一定の方向から撮像するよう、各照明手段と撮像手段を同期させるように制御する。いいかえると照明制御手段は、照明手段による照明タイミングと、撮像手段による撮像タイミングとを同期させる。また照明制御手段が各照明手段を点灯させる点灯順は、ワークの周囲を取り囲むように配置された照明手段を、時計回り、反時計回りといった順で点灯させる他、離散的な順序、例えば一つおきや交差するような順としてもよい。どのような順であっても、各照明タイミングで撮像された部分照明画像が、どの照明方向の照明にて撮像されたものであるかを把握できれば、フォトメトリックステレオ法に基づいて法線ベクトル画像を構築できる。   The illumination control means turns on each of the illumination means and the imaging means so that the three or more illumination means are turned on one by one in the order of lighting, and the workpiece is imaged from a certain direction by the imaging means at the illumination timing at which each illumination means is turned on. Control to synchronize. In other words, the illumination control means synchronizes the illumination timing by the illumination means and the imaging timing by the imaging means. Further, the lighting control means turns on each lighting means by lighting the lighting means arranged so as to surround the work in the order of clockwise or counterclockwise, or in a discrete order, for example, one It may be in the order of crossing every other. Normal vector images based on the photometric stereo method can be used as long as the partial illumination images captured at each illumination timing are captured in which illumination direction in any order. Can be built.

なお図1の実施形態1では、照明制御手段31は、画像処理部41と別体として設けられているが、この構成に限られない。例えば、図10に示す実施形態5のように、画像処理部41と一体化されていてもよいし、あるいは図11に示す実施形態6のように、照明手段25に内蔵されていてもよい。
(画像処理部)
In Embodiment 1 of FIG. 1, the illumination control unit 31 is provided as a separate body from the image processing unit 41, but is not limited to this configuration. For example, it may be integrated with the image processing unit 41 as in the fifth embodiment shown in FIG. 10, or may be built in the illumination means 25 as in the sixth embodiment shown in FIG.
(Image processing unit)

画像処理部41は、撮像手段11及び照明手段21、22、23、24の動作を制御するとともに、撮像手段11から入力された4つの部分照明画像の画像信号Q1〜Q4を用いて、各画素における面の法線ベクトル画像(以下、「傾き画像」という。)を生成し、傾き画像のX方向及びY方向の第2次の傾き画像(以下、「輪郭抽出画像」という。)や、アルベド(albedo、反射率を意味する。)画像(以下、「テクスチャ抽出画像」ともいう。)を作成し、それらの画像を用いて、傷の検査や文字の検出等を行うための処理をする。なお、傷の検査や文字の検出等を行うための処理は、画像処理部41で処理する構成に限らず、例えばPLC81等の外部部機器側で実行させることもできる。   The image processing unit 41 controls the operations of the imaging unit 11 and the illumination units 21, 22, 23, and 24, and uses the image signals Q <b> 1 to Q <b> 4 of the four partial illumination images input from the imaging unit 11. A normal vector image (hereinafter referred to as an “inclined image”) of the surface at, and a second-order inclined image (hereinafter referred to as an “outline extracted image”) in the X and Y directions of the inclined image, or an albedo. (Albedo, meaning reflectance) An image (hereinafter also referred to as “texture extraction image”) is created, and processing for performing scratch inspection, character detection, and the like is performed using these images. Note that the processing for performing a flaw inspection, character detection, and the like is not limited to the configuration processed by the image processing unit 41, and can be executed by an external device such as the PLC 81, for example.

図12は、画像処理部41の信号処理系42を示している。信号処理系42は、CPU43、メモリ44、ROM45、表示手段51、ポインティングデバイス等の操作手段61、撮像手段11、照明制御手段31、結果出力処理を実行するPLC(プログラマブル・ロジック・コントローラ)81より構成されており、これらは、バス46やケーブル12、32、52、62、82を介して互いに接続されている。なお、ROM45は、可搬メディアであってもよい。また表示手段51を、例えばタッチパネルとする等、操作手段61と兼用させてもよい。   FIG. 12 shows a signal processing system 42 of the image processing unit 41. The signal processing system 42 includes a CPU 43, a memory 44, a ROM 45, a display unit 51, an operation unit 61 such as a pointing device, an imaging unit 11, an illumination control unit 31, and a PLC (programmable logic controller) 81 that executes a result output process. These are connected to each other via a bus 46 and cables 12, 32, 52, 62, 82. The ROM 45 may be a portable medium. Further, the display unit 51 may be combined with the operation unit 61 such as a touch panel.

CPU43は、ROM45に格納されているプログラムに基づいて、メモリ44、ROM45、表示手段51、操作手段61、撮像手段11、照明制御手段31、PLC81の相互間でのデータの送受を制御したり、表示手段51、撮像手段11、照明制御手段31の制御を行っている。   The CPU 43 controls transmission / reception of data between the memory 44, the ROM 45, the display unit 51, the operation unit 61, the imaging unit 11, the illumination control unit 31, and the PLC 81 based on a program stored in the ROM 45, Control of the display means 51, the imaging means 11, and the illumination control means 31 is performed.

画像処理部41は、例えば、プログラムが格納された1台のコンピュータを想定しているが、複数のコンピュータの組み合わせにより各手段が構成されるようにしてもよいし、一部の手段を専用の回路により構成してもよい。あるいは、ASICのように専用設計された部材とすることもできる。
(判定手段)
For example, the image processing unit 41 is assumed to be a single computer in which a program is stored. However, each unit may be configured by a combination of a plurality of computers, or some of the units may be dedicated. You may comprise by a circuit. Or it can also be set as the member designed exclusively like ASIC.
(Judgment means)

画像処理部41は上述の通り、判定手段の機能を実現する。判定手段は、得られたテクスチャ抽出画像に基づいて、傷の有無や大きさの検査を行う。例えば所定の閾値以上の場合に傷であると判定する。また、判定手段は必要に応じて輪郭抽出画像に基づいてOCRを行い、認識された文字列を出力することもできる。
(基本原理)
As described above, the image processing unit 41 realizes the function of the determination unit. The determination means inspects the presence / absence and size of the scratch based on the obtained texture extraction image. For example, if it is equal to or greater than a predetermined threshold, it is determined that it is a scratch. In addition, the determination unit can perform OCR based on the contour extraction image as necessary and output a recognized character string.
(Basic principle)

次に、以上の画像検査装置を用いて、ワークの外観検査を行う基本原理について、従来技術である特許文献1の技術と対比しながら説明する。まず特許文献1に開示された技術の基本原理は、フォトメトリックステレオ法の原理を利用し、未知の面に対して、様々な方向から光を当てて、ワークの反射光の違いを利用してワークの形を推定しようとするものである。ワークの反射光は、照明の入射角度、照明の距離等を反映し、入射角度が90°になるところが最も明るくなり、照明との距離が離れれば離れるほど暗くなる性質がある。   Next, the basic principle of performing an appearance inspection of a workpiece using the above-described image inspection apparatus will be described in comparison with the technique of Patent Document 1 which is a conventional technique. First, the basic principle of the technique disclosed in Patent Document 1 is based on the principle of the photometric stereo method. Light is applied to an unknown surface from various directions, and the difference in reflected light of the workpiece is used. It is intended to estimate the shape of the workpiece. The reflected light of the work reflects the incident angle of the illumination, the distance of the illumination, etc., and has the property that the portion where the incident angle is 90 ° is brightest and becomes darker as the distance from the illumination increases.

この性質を利用して、明るさと位置が既知である照明を複数個用意して、照明の点灯を順に切り替えていき、それぞれの点において、各方向の照明から照射されたときの反射光の明るさの違いを利用して表面がどちらを向いているかを推定する。具体的には、傾き画像のX成分Y成分を、X成分の輝度に置き換えたX成分画像やY成分の輝度に置き換えたY成分画像を作成して検査に応用しようとするものである。   Using this property, prepare multiple illuminations with known brightness and position, switch the lighting on in order, and the brightness of the reflected light when illuminated from each direction of illumination at each point Use the difference to estimate which direction the surface is facing. Specifically, an X component image in which the X component Y component of the tilt image is replaced with the luminance of the X component and a Y component image in which the luminance of the Y component is replaced are created and applied to the inspection.

しかしながら、この方法は、照明やワークの設置面の僅かな傾きや、元々入力している照明の位置等の入力情報の過誤に対して、得られる検査画像が大きく変化してしまう等、ロバスト性に劣るという問題があった。例えば、実際には凸凹がないのに凸凹の画像になったり、あるいは照明に対しては通常、近くが明るく見えるところ、明るさの変化によってワークの中央が盛り上がったような画像に見えるといった、ワークの実際の形状に即した検査画像が必ずしも得られないという欠点があった。   However, this method has robustness such as a slight change in the lighting or workpiece installation surface, or an error in input information such as the position of the originally input lighting, resulting in a large change in the obtained inspection image. There was a problem of being inferior. For example, a work that has an uneven image with no actual unevenness, or that appears to be bright in the vicinity of lighting, but appears to be an image where the center of the work is raised due to changes in brightness. However, there is a drawback that an inspection image conforming to the actual shape cannot always be obtained.

これに対して、本実施の形態に係る画像検査技術の基本原理は、フォトメトリックステレオ法を利用して第1次の傾き画像を生成することを出発点としながらも、得られた第1次の傾き画像をX方向及びY方向に微分処理して第2次の傾き画像、すなわち、輪郭抽出画像を作成し、その画像を用いて、傷の検査等を行うものである。第2次の傾き画像は、前述の欠点が生ずるようなケースであっても、その影響が小さく、面の傾き変化の大きいところが暗くなる階調とする一方、面の傾き変化の小さいところが明るくなる階調と設定することで、ワークの表面の傾きが大きく変化する傷や輪郭等を抽出するのに好適な画像となる。   On the other hand, the basic principle of the image inspection technique according to the present embodiment is that the obtained first order is obtained while generating a first-order tilt image using the photometric stereo method. The second tilt image, that is, the contour extraction image, is generated by differentiating the tilt image in the X direction and the Y direction, and the image is inspected for scratches and the like. Even in the case where the above-mentioned drawbacks occur, the second-order tilt image has a small effect, and the portion where the change in the surface inclination is large is darkened while the portion where the change in the surface inclination is small is bright. By setting the gradation, an image suitable for extracting scratches, contours, and the like that greatly change the inclination of the surface of the workpiece is obtained.

また、特許文献1に開示された技術では、フォトメトリックステレオ法を利用して生成した反射率画像(テクスチャ抽出画像に相当。)は、ハレーションが起きてしまい、文字の検出等が困難な場合があった。これに対して、本実施の形態に係る画像検査技術は、基本的には、2つの照明でしか同じ箇所ではハレーションしないという基本原理を利用して、各画素において、例えば4つの画素値の内、上から3つ目の画素値を採用することで、ハレーションの影響を取り除くようにしている。   Further, with the technique disclosed in Patent Document 1, the reflectance image (corresponding to a texture extracted image) generated by using the photometric stereo method may cause halation and it may be difficult to detect characters. there were. On the other hand, the image inspection technique according to the present embodiment basically uses the basic principle that halation is performed at the same location with only two illuminations. By adopting the third pixel value from the top, the influence of halation is removed.

加えて、特許文献1に開示された画像処理装置は、カメラと照明用の光源を一体に構成しているが、この構成では、カメラと光源が大型化して、設置に際して大きさの制約を受けるという問題もあった。これに対して本実施の形態に係る画像検査装置では、撮像手段と照明手段を別個の部材とできるので、配置スペースを考慮したより柔軟な設置が可能となって、使い勝手の面でも有利となる。
(フォトメトリックステレオ法の基本原理)
In addition, the image processing apparatus disclosed in Patent Document 1 integrally includes a camera and a light source for illumination. However, in this configuration, the camera and the light source are enlarged, and the size is restricted during installation. There was also a problem. On the other hand, in the image inspection apparatus according to the present embodiment, since the imaging unit and the illumination unit can be separate members, more flexible installation is possible in consideration of the arrangement space, which is advantageous in terms of usability. .
(Basic principle of photometric stereo method)

ここで、図13A〜図13Dを参照しながら、フォトメトリックステレオ法の基本原理について説明する。まず、図13Aに示すように、未知の拡散反射面S、及び明るさと位置が既知の複数の照明(この例では第一照明手段L1と第二照明手段L2の2個)がある場合を想定する。例えば図13Bに示すように、第一照明手段L1から光を照射すると、拡散反射面Sの表面における拡散反射光は、(1)照明の明るさ(既知)、(2)照明の向き(既知)、(3)ワークWKの表面の向き(法線ベクトルn)、(4)ワークWKの表面のアルベドのパラメータのみで決定される。   Here, the basic principle of the photometric stereo method will be described with reference to FIGS. 13A to 13D. First, as shown in FIG. 13A, it is assumed that there is an unknown diffuse reflection surface S and a plurality of illuminations whose brightness and position are known (in this example, two of the first illumination unit L1 and the second illumination unit L2). To do. For example, as shown in FIG. 13B, when light is irradiated from the first illumination means L1, the diffuse reflection light on the surface of the diffuse reflection surface S is (1) brightness of illumination (known), (2) direction of illumination (known) ), (3) surface orientation of workpiece WK (normal vector n), and (4) surface albedo parameter of workpiece WK.

そこで、図13B及び図13Cに示すように、複数の異なる照明方向、具体的には三以上の照明方向から照明光が投光されたときの拡散反射光からなる部分照明画像を、それぞれ撮像手段で撮影する。そして図13Dに示すように、3以上の部分照明画像を入力画像とすることで、未知である(3)ワークWK表面の向き(法線ベクトルn)、(4)ワークWK表面のアルベドを、以下の関係式に基づいて算出できる。
I=ρLSn
Therefore, as shown in FIG. 13B and FIG. 13C, each of the partial illumination images composed of the diffuse reflected light when the illumination light is projected from a plurality of different illumination directions, specifically, three or more illumination directions, is respectively imaged. Shoot with. Then, as shown in FIG. 13D, by using three or more partial illumination images as input images, the unknown (3) orientation of the workpiece WK surface (normal vector n), (4) the albedo of the workpiece WK surface, It can be calculated based on the following relational expression.
I = ρLSn

上式において、
ρ:アルベド
L:照明の明るさ
S:照明方向行列
n:表面の法線ベクトル
I:画像の階調値
In the above formula,
ρ: albedo L: illumination brightness S: illumination direction matrix n: surface normal vector I: image gradation value

上式から、照明手段が3つの場合、次式で表すことができる。   From the above formula, when there are three illumination means, it can be expressed by the following formula.

また照明手段が4つの場合は、次式で表すことができる。   Moreover, when there are four illumination means, it can be expressed by the following equation.

(法線ベクトルn) (Normal vector n)

上式より、法線ベクトルnは、次式で表現できる。
n=1/ρL・S+
From the above equation, the normal vector n can be expressed by the following equation.
n = 1 / ρL · S + I

上式において、
+:正方行列であれば、普通の逆行列
+:縦長行列の逆行列は以下の式で表現されるムーアペンローズの擬似逆行列
+=(StS)-1t
で求める。
(アルベド)
In the above formula,
If S + : square matrix, ordinary inverse matrix S + : inverse matrix of vertical matrix is Moore-Penrose pseudo inverse matrix S + = (S t S) −1 St
Ask for.
(Albedo)

さらにアルベドρは、次式で表現できる。
ρ=|I|/|LSn|
(2−2.輪郭抽出画像)
Further, the albedo ρ can be expressed by the following equation.
ρ = | I | / | LSn |
(2-2. Outline extraction image)

次に、フォトメトリックステレオ法で傾き画像を生成すると共に、得られた傾き画像から、傷や輪郭等のワークの表面情報を得る方法について説明する。
(傾き画像)
Next, a method of generating a tilt image by the photometric stereo method and obtaining surface information of a workpiece such as a scratch or a contour from the obtained tilt image will be described.
(Tilt image)

まず、傾き画像の生成方法について説明する。ワークの曲面をSとするとき、傾き画像は次式で与えられる。
x方向:δs/δx、y方向:δs/δy
First, a tilt image generation method will be described. When the curved surface of the workpiece is S, the tilt image is given by the following equation.
x direction: δs / δx, y direction: δs / δy

ここで傾き画像の例として、ワークとして一円玉を用いた例を図14A、図14Bに示す。図14Aは、法線方向のY座標成分画像、図14Bは法線方向のX座標成分画像である。ここでは、4つの照明方向から撮像した部分照明画像を用いて、Y方向(図において垂直方向)に微分することで図14Aに示す傾き画像を、またX方向(図において水平方向)に微分することで図14Bに示す傾き画像を図14Bを、それぞれ得ている。   Here, as an example of the tilt image, an example in which a one-yen coin is used as a work is shown in FIGS. 14A and 14B. FIG. 14A is a Y coordinate component image in the normal direction, and FIG. 14B is an X coordinate component image in the normal direction. Here, using the partial illumination images captured from the four illumination directions, the inclination image shown in FIG. 14A is differentiated in the X direction (horizontal direction in the figure) by differentiating in the Y direction (vertical direction in the figure). Thus, the tilt image shown in FIG. 14B is obtained as shown in FIG. 14B.

ここで、傷や輪郭等はワーク表面の傾きが変化する箇所なので、傾き画像をそれぞれの方向に微分する。第2次の傾き画像は、次式で与えられる。
x方向:δ2s/δx2、y方向:δ2s/δy2
(輪郭抽出画像)
Here, since the scratches, contours, and the like are places where the tilt of the workpiece surface changes, the tilt image is differentiated in each direction. The second-order tilt image is given by the following equation.
x direction: δ 2 s / δx 2 , y direction: δ 2 s / δy 2
(Outline extraction image)

以上から、x方向、y方向の傾き画像の部分δ2s/δx2、δ2s/δy2を合成して、ワークの輪郭や傷情報を含む輪郭抽出画像を生成する。輪郭抽出画像Eは、次式で与えられる。
E=δ2s/δx2+δ2s/δy2
From the above, the portions δ 2 s / δx 2 and δ 2 s / δy 2 of the tilt image in the x direction and the y direction are synthesized to generate a contour extracted image including the contour of the workpiece and flaw information. The contour extraction image E is given by the following equation.
E = δ 2 s / δx 2 + δ 2 s / δy 2

上式において、Eは輪郭情報、Sはワークの曲面をそれぞれ示している。図14A、図14Bから演算された輪郭抽出画像の例を、図14Cに示す。輪郭抽出画像は、高い部分が白色、低い部分が黒色となるように、画像の濃淡(輝度)で高さを表現している。
(微分合成方法)
In the above equation, E indicates contour information, and S indicates the curved surface of the workpiece. An example of the contour extraction image calculated from FIGS. 14A and 14B is shown in FIG. 14C. In the contour extracted image, the height is expressed by shading (brightness) of the image so that the high portion is white and the low portion is black.
(Differential synthesis method)

以上のような輪郭抽出画像の生成に際して行われる微分合成方法としては、(1)単純加算、(2)多重解像度、(3)二乗和等が挙げられる。
(1:単純加算)
Examples of the differential synthesis method performed when generating the contour extracted image as described above include (1) simple addition, (2) multi-resolution, and (3) sum of squares.
(1: Simple addition)

ここで(1)の単純加算は、各画素におけるX,Y傾き画像の微分の和である。
(2:多重解像度)
Here, the simple addition in (1) is the sum of the differentiation of the X and Y tilt images at each pixel.
(2: Multi-resolution)

また(2)の多重解像度は、傾き画像を異なる縮小率で縮小した縮小傾き画像を複数作成し、それぞれの縮小傾き画像において、(1)の方法で輪郭の強さを求める。縮小率は、例えば1/1、1/2、1/4、1/8、1/16、1/32等とする。このようにして得られた複数の縮小輪郭画像に対して、所定の重み付けを行い、拡大処理を行い、拡大された縮小輪郭画像をすべて足し合わせたものを輪郭抽出画像とする。ここで重み付けを変更すれば、任意の太さの傷や輪郭等を抽出することが可能となる。
(3:二乗和)
For the multi-resolution of (2), a plurality of reduced inclination images obtained by reducing the inclination image with different reduction ratios are created, and the strength of the contour is obtained by the method of (1) in each reduced inclination image. The reduction ratio is, for example, 1/1, 1/2, 1/4, 1/8, 1/16, 1/32, or the like. The plurality of reduced contour images obtained in this way are subjected to predetermined weighting and enlargement processing, and the sum of all the enlarged reduced contour images is defined as a contour extraction image. If weighting is changed here, it becomes possible to extract a flaw, outline, etc. of arbitrary thickness.
(3: sum of squares)

さらに(3)の二乗和では、X,Y傾き画像の微分の二乗の和を輪郭の強さとする輪郭抽出画像を作成する。なお、本実施形態においては、(2)の多重解像度を採用している。   Further, in the sum of squares of (3), a contour extraction image is created in which the sum of the squares of the derivatives of the X and Y tilt images is the strength of the contour. In the present embodiment, the multi-resolution (2) is adopted.

如何なる大きさを傷として判断するかは、ユーザの用途によって異なる。例えば、10ピクセルに跨がったものを傷として判断する場合もあれば、100ピクセルに跨がっている凹んだものを傷として判断する場合もある。また、急峻なエッジだけをエッジとして抽出したい場合もある。   What size is determined as a scratch varies depending on the use of the user. For example, there may be a case where a thing straddling 10 pixels is determined as a scratch, and a case where a concave part straddling 100 pixels is determined as a scratch. In some cases, only sharp edges may be extracted as edges.

傾き画像の画素数が大きいと処理上は大きな傷となるため、大きな傷を抽出したければ、傾き画像を縮小してから(1)の方法で輪郭の強さを求めてから拡大する。一方、小さな傷を抽出したければ、重み付けをせずに(1)の方法で微分合成をすればよい。   If the number of pixels in the tilt image is large, the processing results in a large scratch. Therefore, if a large scratch is to be extracted, the tilt image is reduced and then the contour strength is obtained by the method (1) and then enlarged. On the other hand, if it is desired to extract small scratches, differential synthesis may be performed by the method (1) without weighting.

すなわち、重み付けは、合成するときに予め決められた重みのセットを用意しておき、縮小傾き画像を上記の全種類作成し、大きい傷を見たければ、より縮小した画像からの結果を重くし、小さい傷を見たければ、縮小を弱めた画像からの結果を重くする。   That is, for weighting, a set of weights determined in advance is prepared, all the above-mentioned types of reduced tilt images are created, and if you want to see large scratches, the results from the more reduced images are weighted. If you want to see small scratches, weight the results from images with reduced reduction.

ここで、拡大された縮小輪郭画像をすべて足し合わせたものを輪郭抽出画像とするのは、傷は、通常、複数の周波数に跨がって検出されるため、例えば一つの周波数に限定すると、その限定した周波数で検出される傷だけを抽出してしまい、全体的にぼやけてしまうからである。
(特徴サイズ)
Here, the result of adding all the enlarged reduced contour images as the contour extraction image is that the scratch is usually detected across a plurality of frequencies. This is because only the flaws detected at the limited frequency are extracted and blurred as a whole.
(Feature size)

前述した重みのセットは、例えば、特徴サイズというパラメータを設けて、この値が1のときに一番細かい傷が検出でき、この値を上げていくと大きな傷が検出できるようにする。特徴サイズを大きくしていき、より大きな傷が検出し易い状態になったとき、ワーク表面の凸凹がより明瞭となる。そこで、特徴サイズに所定の閾値を設けて、その閾値以上になった場合を凹凸モードとして、輪郭抽出画像の特徴サイズによって、輪郭抽出モードと使い分けるようにしてもよい。   The weight set described above is provided with a parameter called feature size, for example, so that the finest scratches can be detected when this value is 1, and large scratches can be detected as this value is increased. When the feature size is increased and larger scratches are easily detected, the unevenness of the workpiece surface becomes clearer. Therefore, a predetermined threshold value may be provided for the feature size, and the case where the threshold value is equal to or greater than the threshold value may be used as the concavo-convex mode, depending on the feature size of the contour extraction image.

次に、δ2s/δx2及びδ2s/δy2の計算方法について説明する。この計算方法としては、(1)前進差分や、(2)中央差分等が挙げられる。
(1:前進差分)
Next, a method for calculating δ 2 s / δx 2 and δ 2 s / δy 2 will be described. Examples of the calculation method include (1) forward difference, (2) center difference, and the like.
(1: Forward difference)

前進差分においては、水平方向の傾き画像Gh、垂直方向の傾き画像Gvを入力として、輪郭画像Eの座標(x、y)における画素G(x,y)を、次式で計算する。   In the forward difference, the horizontal gradient image Gh and the vertical gradient image Gv are input, and the pixel G (x, y) at the coordinates (x, y) of the contour image E is calculated by the following equation.

E(x,y)=Gh(x−1,y)−Gh(x,y)+Gv(x,y−1)−Gv(x,y)   E (x, y) = Gh (x-1, y) -Gh (x, y) + Gv (x, y-1) -Gv (x, y)

ここで、輪郭画像に表れる傷の情報を、模式的なプロファイルとして図15A〜図15Dに示す。これらの図において、図15Aはワークの表面情報、図15Bは傾き画像、図15Cは前身差分による輪郭画像、図15Dは中央差分による輪郭画像のプロファイルを、それぞれ示している。(1)の前進差分では、図15A、図15Cに示すように、1ピクセル単位の傷が明瞭に見えるというメリットがある。一方で、元画像に対して0.5ピクセルずれた画像が得られてしまうというデメリットもある。
(2:中央差分)
Here, the information on the scratches appearing in the contour image is shown in FIGS. 15A to 15D as schematic profiles. In these drawings, FIG. 15A shows the surface information of the workpiece, FIG. 15B shows the tilt image, FIG. 15C shows the contour image based on the forerunner difference, and FIG. 15D shows the profile of the contour image based on the center difference. In the forward difference of (1), there is an advantage that scratches in units of one pixel can be clearly seen as shown in FIGS. 15A and 15C. On the other hand, there is a demerit that an image shifted by 0.5 pixels from the original image is obtained.
(2: Central difference)

次に中央差分によるδ2s/δx2及びδ2s/δy2の計算方法について説明する。水平方向の傾き画像Gh、垂直方向の傾き画像Gvを入力として、輪郭画像Eの座標(x、y)における画素G(x,y)を、次式で計算する。 Next, a method for calculating δ 2 s / δx 2 and δ 2 s / δy 2 by the central difference will be described. The pixel G (x, y) at the coordinates (x, y) of the contour image E is calculated by the following formula using the horizontal tilt image Gh and the vertical tilt image Gv as inputs.

E(x,y)=Gh(x−1,y)−Gh(x+1,y)+Gv(x,y−1)−Gv(x,y+1)   E (x, y) = Gh (x-1, y) -Gh (x + 1, y) + Gv (x, y-1) -Gv (x, y + 1)

(2)の中央差分は、図15A、図15Dに示すように、座標が元画像とずれないメリットがある一方で、結果が少しぼけてしまうというデメリットもある。
(2−3.テクスチャ抽出画像)
As shown in FIGS. 15A and 15D, the central difference of (2) has a merit that the coordinates are not shifted from the original image, but also has a demerit that the result is slightly blurred.
(2-3. Texture extraction image)

次に、フォトメトリックステレオ法で得られた傾き画像から、ワークの表面状態を除去して、文字の検出等に好適なテクスチャ抽出画像を得る方法について説明する。まず、テクスチャ情報は、ワークの表面のアルベドρから計算する。アルベドρは、次式で与えられる。   Next, a method for obtaining a texture extracted image suitable for character detection or the like by removing the surface state of the workpiece from the tilt image obtained by the photometric stereo method will be described. First, the texture information is calculated from the albedo ρ on the surface of the workpiece. The albedo ρ is given by the following equation.

ρ=|I|/|LSn|   ρ = | I | / | LSn |

上式において、
ρ:アルベド
L:照明の明るさ
S:照明方向行列
n:表面の法線ベクトル
I:画像の階調値
In the above formula,
ρ: albedo L: illumination brightness S: illumination direction matrix n: surface normal vector I: image gradation value

なお上記ρ=|I|/|LSn|の式でテクスチャ抽出画像(アルベド)を1枚求めることができるが、この式で得られた法線ベクトルとN枚の入力画像(部分照明画像)から、テクスチャ抽出画像(アルベド)をN枚求めてこれを合成し、一枚のテクスチャ抽出画像(アルベド)を求めることもできる。具体的な合成の方法としては平均法、ハレーション除去法等が挙げられる。   Note that one texture extraction image (albedo) can be obtained by the above equation ρ = | I | / | LSn |. From the normal vector obtained by this equation and N input images (partial illumination images). It is also possible to obtain N texture extracted images (albedo) and synthesize them to obtain one texture extracted image (albedo). Specific methods of synthesis include an average method, a halation removal method, and the like.

図16A〜図16Cに、テクスチャ出画像の例を示す。これらの図において、図16Aは入力画像である4枚のテクスチャ抽出画像を示しており、図16Bはこれらに対して平均法を適用したテクスチャ抽出画像、図16Cはハレーション除去法を適用したテクスチャ抽出画像を、それぞれ示している。
(1:平均法)
16A to 16C show examples of texture output images. In these figures, FIG. 16A shows four texture extracted images as input images, FIG. 16B shows a texture extracted image obtained by applying an average method to these images, and FIG. 16C shows a texture extracted image obtained by applying a halation removal method. Each image is shown.
(1: Average method)

平均法は、画素毎にN個のρの平均値をその画素における画素値とするものである。図16Bに示すように、全体の陰影は消えているものの、入力画像中でハレーションが生じている部分は、フォトメトリックステレオ法で消せないため、ハレーションの影響が残った画像となる。すなわち図16Aの4つの入力画像(部分照明画像)の内、白くなっている箇所がハレーションを起こしている箇所であり、平均法によって平均化すると、図16Bに示すように、ある程度凸凹が取れて、読み易くはなるものの、若干下地に凸凹が残ってしまう。
(2:ハレーション除去法)
In the averaging method, the average value of N ρ for each pixel is used as the pixel value in that pixel. As shown in FIG. 16B, although the entire shadow has disappeared, the portion where halation has occurred in the input image cannot be erased by the photometric stereo method, and thus the image remains affected by halation. That is, among the four input images (partial illumination images) in FIG. 16A, the whitened portions are the locations where halation occurs, and when averaged by the averaging method, unevenness is removed to some extent as shown in FIG. 16B. Although it is easy to read, some unevenness remains on the ground.
(2: Halation removal method)

撮像手段であるカメラのダイナミックレンジの制限やワーク表面の反射性の多様性のため、上記ρ=|I|/|LSn|の式そのものがその適応範囲を超えているため、ρに誤差が含まれる。この誤差を補正するために、ハレーション除去法が利用できる。   Because of the limitation of the dynamic range of the camera that is the imaging means and the variety of reflectivity of the work surface, the above equation of ρ = | I | / | LSn | It is. A halation removal method can be used to correct this error.

ハレーションが起きる箇所は照明の位置で決まるため、基本的には、4つの部分照明画像において、同じ箇所ではハレーションは起きないと考えられる。厳密にいえば、2つの方向の間ではハレーションが2カ所に跨がってしまうことがあるものの、基本的には、2つの照明でしか同じ箇所ではハレーションは生じないと言える。   Since the location where halation occurs is determined by the position of illumination, basically, it is considered that no halation occurs at the same location in the four partial illumination images. Strictly speaking, although halation may straddle two places between two directions, it can basically be said that halation does not occur at the same place with only two illuminations.

ハレーション除去法では、N枚の部分照明画像から計算した照明方向別テクスチャ抽出画像を合成する際に、各画素において一番画素値が高い部分照明画像、又は一番目〜N番目に画素値が高い部分照明画像はハレーションが多いと考えて、それらを除去した上で合成を行う。   In the halation removal method, when a texture-extracted image for each illumination direction calculated from N pieces of partial illumination images is synthesized, the partial illumination image having the highest pixel value or the first to Nth highest pixel values in each pixel. The partial illumination image is considered to have a lot of halation, and is synthesized after removing them.

具体的には、本実施形態において4つの照明方向別テクスチャ抽出画像の各画素について、3番目に大きい画素値(例えばアルベドの値や輝度)を採用して合成すると、図16Cの画像のようになり、ハレーションの影響を除去することができる。なお4番目に大きい画素値を採用すると、影の影響が生じるため若干暗い画像となる。逆に2番目に大きい画素値を採用すると、ハレーションの影響が若干残ってしまう。   Specifically, in the present embodiment, when each pixel of the four illumination direction-specific texture extracted images is synthesized by adopting the third largest pixel value (for example, albedo value or luminance), an image shown in FIG. 16C is obtained. Thus, the influence of halation can be removed. If the fourth largest pixel value is adopted, the image is slightly dark because of the influence of shadows. Conversely, when the second largest pixel value is adopted, the influence of halation remains slightly.

また照明手段が8方向の場合は、5番目以降の画素値にはハレーションの影響は発生しないと仮定して、上から5番目の画素値を採用している。実際、発明者が行った試験によれば、5番目の画素値を採用すると、画像が最も良くなることが確認された。また6番目以降の画素値を採用すると影の影響が出てくることも判明した。   When the illumination means is in eight directions, the fifth pixel value from the top is adopted on the assumption that the influence of halation does not occur on the fifth and subsequent pixel values. In fact, according to tests conducted by the inventors, it was confirmed that the image was best when the fifth pixel value was adopted. It has also been found that the influence of shadows comes out when the sixth and subsequent pixel values are adopted.

なお、合成の方法や平均の取り方は、これらに限定されず、種々の方法が利用できる。例えば、上述したハレーション除去法と平均法とを組み合わせて、アルベドの値をソートして、上から特定の順番の値を採用し、例えば3番目と4番目とを平均化してもよい。
(特徴サイズ)
Note that the synthesis method and averaging are not limited to these, and various methods can be used. For example, the above-described halation removal method and averaging method may be combined to sort the albedo values, adopt values in a specific order from the top, and average the third and fourth, for example.
(Feature size)

次に、設定の詳細について説明する。上述の通り、輪郭抽出画像を作成する際に、特徴サイズを設定できる。輪郭抽出画像は、特徴サイズを所定値以上にすることで、OCRに適した画像とできる。
(3−2.ゲイン)
Next, details of the setting will be described. As described above, the feature size can be set when the contour extraction image is created. The contour extraction image can be an image suitable for OCR by setting the feature size to a predetermined value or more.
(3-2. Gain)

輪郭抽出画像やテクスチャ抽出画像を作成する際には、これらの画像の生成過程において元の画像の画素値に対してゲインを乗算することができる。   When creating a contour extraction image or a texture extraction image, the pixel values of the original image can be multiplied by a gain in the process of generating these images.

輪郭抽出画像を作成するときのゲインは、計算処理で算出された画素値を、0〜255の濃淡に分散させるときの定数をいう。例えば、傷や輪郭等が浅すぎて、傷や輪郭等を把握し難いときにこのゲインの値を上げることによって、画素値の濃淡変化が大きくなるため、傷や輪郭等が把握し易くなる。   The gain at the time of creating the contour extraction image refers to a constant when the pixel values calculated by the calculation process are distributed in shades of 0 to 255. For example, when the value of this gain is increased when the scratches, contours, etc. are too shallow and it is difficult to grasp the scratches, contours, etc., the shading, contours, etc. are easily grasped because the change in the pixel value becomes large.

また、計算処理で算出された画素値が、0〜255の範囲を超えていれば、その間に収まるようにし、小さければ、0〜255の範囲に広げるように調節することで、傷や輪郭等が把握し易くなる。   Further, if the pixel value calculated by the calculation process exceeds the range of 0 to 255, the pixel value is adjusted to fall within the range, and if the pixel value is small, the adjustment is performed so that the pixel value is expanded to the range of 0 to 255. Will be easier to grasp.

上述したハレーション除去法では、アルベドの値をソートして上から例えば3番目を採用するため、生成した画像の明るさが予測できない。このため、正反射が取り除かれた結果、予測に反して暗くなることがある。そこで、明るさを調節するために、テクスチャ抽出画像を作成する際には所定のゲインを、画素値に掛ける。   In the halation removal method described above, since the albedo values are sorted and, for example, the third one from the top is adopted, the brightness of the generated image cannot be predicted. For this reason, as a result of removing regular reflection, it may become darker than expected. Therefore, in order to adjust the brightness, a predetermined gain is multiplied by the pixel value when creating the texture extracted image.

なお、傾き画像の計算に際しても、画素値が0〜255の範囲に収まるように、同様にゲインで調節することもできる。
(3−3.ノイズ除去フィルタ)
Note that when calculating the tilt image, the gain can be similarly adjusted so that the pixel value falls within the range of 0 to 255.
(3-3. Noise removal filter)

傾き画像の作成等に際しては、複数枚の画像を使って連立方程式で計算するところ、実際には差分的な計算をすることになる。この際、撮像手段で撮像した画像データは、生データの時点でノイズが存在しているため、傾き画像を作成する際に、ノイズ成分が強調され、輪郭がざらざらすることがある。このようなノイズを軽減するために、ガイデットフィルタ(Guided Filter)等のノイズ除去フィルタを利用する。一般的なローパスフィルタでは、ノイズのみならず傷の情報もなまったり消えたりしてしまうことがあるが、ガイデットフィルタであれば、傾き画像を求める際にガイデッドフィルタを適用することで、エッジを維持したままノイズを除去でき、好適である。
(3−4.アングルノイズ低減)
When creating an inclination image, etc., calculation is performed using simultaneous equations using a plurality of images, but in reality, a differential calculation is performed. At this time, since the image data captured by the image capturing means includes noise at the time of raw data, the noise component may be emphasized and the outline may be rough when creating the tilt image. In order to reduce such noise, a noise removal filter such as a guided filter is used. With a general low-pass filter, not only noise but also information on scratches may be lost or lost, but with a guided filter, the edge can be removed by applying a guided filter when obtaining a tilt image. Noise can be removed while maintaining it, which is preferable.
(3-4. Angle noise reduction)

次に、アングルノイズ低減の原理を、図17の模式図に基づいて説明する。この図に示すように、入射角がα,βという2つ照明があり、ワークWKが拡散反射面からなると仮定して、ワークWKの基準面に対する傾きをγ、基準面に垂直な向きからの角度をθ、照明αからの反射光の明るさをIα、照明βからの反射光の明るさをIβとしたとき、γは次式で与えられる。 Next, the principle of angle noise reduction will be described based on the schematic diagram of FIG. As shown in this figure, assuming that there are two illuminations with incident angles α and β, and the workpiece WK is formed of a diffuse reflection surface, the inclination of the workpiece WK with respect to the reference plane is γ, and the direction perpendicular to the reference plane is When the angle is θ, the brightness of the reflected light from the illumination α is I α , and the brightness of the reflected light from the illumination β is I β , γ is given by the following equation.

γ=arctan(A・|Iβ−Iα|/|Iβ+Iα|)、A=cotθ γ = arctan (A · | I β -I α | / | I β + I α |), A = cotθ

アングルノイズ低減は、|Iβ+Iα|がある程度小さいときに、強制的に傾きγを0とするものである。 The angle noise reduction is forcibly setting the slope γ to 0 when | I β + I α | is small to some extent.

仮に、IβもIαも極めて暗く、例えば、Iβ=2、Iα=1だとすると、|Iβ−Iα|/|Iβ+Iα|=1/3という大きな値となる。一方、IβもIαも明るく、例えば、Iβ=300、Iα=200だとすると、|Iβ−Iα|/|Iβ+Iα|=1/5という小さな値となる。Iβ=2、Iα=1というのは、単にノイズという可能性があるにも拘わらず、傾きに大きく反映されてしまうため、そのノイズの影響を軽減するために、アングルノイズ低減があり、強制的に傾きを0とする|Iβ+Iα|の閾値を設定できるようになっている。
(照明手段と撮像手段との分離型構造)
Even if I beta I alpha is extremely dark, for example, I β = 2, I α = 1 Datosuruto, | I β -I α | / | I β + I α | = a large value of 1/3. On the other hand, bright nor I beta I alpha, for example, I β = 300, I α = 200 Datosuruto, | I β -I α | / | I β + I α | = a small value of 1/5. I β = 2 and I α = 1 are largely reflected in the inclination despite the possibility of simply noise, so there is angle noise reduction to reduce the influence of the noise, A threshold value of | I β + I α | forcibly setting the inclination to 0 can be set.
(Separate structure of illumination means and imaging means)

フォトメトリックステレオ法を利用した画像検査においては、照明手段と撮像手段との対応位置を予め厳格に規定しておく必要がある。このため、従来の画像検査装置では、照明手段と撮像手段を一体に構成していた。いいかえると、フォトメトリックステレオ法では、撮像手段と照明手段の相対位置を厳密に位置決めした上で正確な三次元計測を行う計測手法であることから、元来、照明手段と撮像手段の設置に際して設置位置の自由度を与えるということは従来行われていなかった。しかしながら、照明手段と撮像手段とを予め固定する構成では、これらの部材が一体化された撮像照明ユニットが必然的に大型化するため、取り回しが悪くなる。   In the image inspection using the photometric stereo method, it is necessary to strictly define the corresponding positions of the illumination unit and the imaging unit in advance. For this reason, in the conventional image inspection apparatus, the illumination unit and the imaging unit are configured integrally. In other words, the photometric stereo method is a measurement method that performs accurate three-dimensional measurement after strictly positioning the relative position of the imaging means and the illumination means, so it was originally installed when the illumination means and the imaging means were installed. Giving position freedom has never been done before. However, in the configuration in which the illumination unit and the imaging unit are fixed in advance, the imaging illumination unit in which these members are integrated inevitably increases in size, so that handling becomes worse.

例えば検査位置に障害物が存在すると、撮像照明ユニットと干渉して、設置できない事態が生じ得る。特に、撮像手段の一形態であるカメラに装着するレンズには、例えばラインカメラやズームレンズ、大型のマクロレンズのように、大きなサイズのものがある。このような大型のレンズを撮像手段に装着する等、撮像手段が長大化するほど、図18において矢印で示すように、ワークWKの周囲に存在する障害物OSとカメラe1又はその周囲に配置された照明用の光源e21〜e24と干渉するリスクが高くなる。さらに撮像手段であるカメラe1が長大化すると、図19に示すようにカメラe1やレンズの一部で照明光が部分的に遮られて、ワークWKに影を落とす等、照明に支障を来すことも考えられる。このような事態を回避するために、撮像照明ユニットを障害物と干渉しない位置まで遠ざけて配置しようとすれば、照明手段とワークとの距離(ライトワーキングディスタンス(Light Working Distance:LWD))が遠くなることから、照明光の光量が減少して、検査精度の低下に繋がる。   For example, if there is an obstacle at the inspection position, it may interfere with the imaging illumination unit and may not be installed. In particular, there are lenses of a large size, such as a line camera, a zoom lens, and a large macro lens, which are attached to a camera that is a form of the imaging means. As the imaging means becomes longer, such as mounting such a large lens on the imaging means, as shown by the arrows in FIG. 18, the obstacle OS and the camera e1 that are present around the work WK are arranged around the surroundings. The risk of interference with the illumination light sources e21 to e24 increases. Further, when the camera e1 which is an imaging means becomes longer, as shown in FIG. 19, the illumination light is partially blocked by the camera e1 or a part of the lens, and a shadow is cast on the work WK. It is also possible. In order to avoid such a situation, if the imaging illumination unit is arranged away from a position where it does not interfere with an obstacle, the distance between the illumination means and the work (Light Working Distance (LWD)) is too long. As a result, the amount of illumination light decreases, leading to a decrease in inspection accuracy.

これに対して、撮像手段と照明手段を分離することができれば、障害物と干渉しない位置に配置しやすくなる。例えば上述した図18に示す障害物OSが存在する場合でも、第一照明手段21〜第四照明手段24を撮像手段11から離間させることで、図20に示すように、干渉しない位置に第一照明手段21〜第四照明手段24を設置することが可能となる。同様に、撮像手段に大型のレンズを装着する場合でも、レンズ12と第一照明手段21〜第四照明手段24との物理的干渉を回避するように調整可能である。このように、第一照明手段21〜第四照明手段24と撮像手段11とを分離型とすることで、障害物と干渉しない位置に調整する等、設置の自由度を高め、様々な環境でワークWKを検査することが可能となる。   On the other hand, if the imaging means and the illumination means can be separated, it will be easy to arrange them at positions that do not interfere with the obstacles. For example, even when the obstacle OS shown in FIG. 18 described above is present, the first illumination means 21 to the fourth illumination means 24 are separated from the imaging means 11 so that the first illumination means 21 is not interfered as shown in FIG. The illumination means 21 to the fourth illumination means 24 can be installed. Similarly, even when a large lens is attached to the image pickup means, adjustment can be made so as to avoid physical interference between the lens 12 and the first illumination means 21 to the fourth illumination means 24. In this way, the first illumination means 21 to the fourth illumination means 24 and the imaging means 11 are separated, thereby increasing the degree of freedom of installation, such as adjustment to a position that does not interfere with obstacles, in various environments. The work WK can be inspected.

また撮像手段が照明光を遮らないように、照明手段の取り付け位置等を調整することも可能となる。同様に、ハレーションや影の影響を抑制するように照明手段の配置位置を調整することも可能となる。特にフォトメトリックステレオ法では、ワークの表面が拡散反射面であることを前提にしているため、一般に、実際のワークの面とフォトメトリックステレオ法によって得られた傾き画像における面の法線ベクトルはズレてしまう。そこで、二階微分処理を行う等の対策が取られているが、このような方策に加え、照明手段を設置する際に、ハレーションを回避できる姿勢に調整することで、このようなズレを少なくすることができる。また、鏡面と同様に、明るさが変化してしまうような大きな凸凹では、ハレーションが悪影響を及ぼすようになる。例えば、ワークが円筒型の場合は、照明光を照射すると鏡面反射が生じるが、ここで凸凹が存在すると、鏡面反射の影響を少なからず受けるようになる。よって、照明光の設置位置や角度に自由度を与えることは、このような鏡面反射を低減するように予め調整することを可能にし、ひいては検査精度の向上に繋がる利点が得られる。   It is also possible to adjust the mounting position of the illumination means so that the imaging means does not block the illumination light. Similarly, it is possible to adjust the arrangement position of the illumination means so as to suppress the influence of halation and shadows. In particular, since the photometric stereo method assumes that the surface of the work is a diffuse reflection surface, the normal vector of the surface in the tilt image obtained by the photometric stereo method is generally different from the actual work surface. End up. Therefore, measures such as performing second-order differential processing have been taken, but in addition to such measures, when installing the illumination means, such deviation is reduced by adjusting the posture to avoid halation. be able to. In addition, as in the case of the mirror surface, halation has an adverse effect on large unevenness where the brightness changes. For example, when the workpiece is cylindrical, specular reflection occurs when illumination light is applied, but if there is unevenness, the influence of the specular reflection is received to some extent. Therefore, giving a degree of freedom to the installation position and angle of the illumination light makes it possible to make adjustments in advance so as to reduce such specular reflection, and as a result, has the advantage of improving inspection accuracy.

さらにフォトメトリックステレオ法では、影の影響を考慮する必要がある。フォトメトリックステレオ法は、照明の反射光から法線ベクトルを算出するため、反射光の検出が必須となる。しかし、例えばワークが複雑な形状で陰影が着き易いような場合に、このワークの近傍に照明手段を設置すると、光が届かない箇所からは適切な反射光が得られず、法線ベクトルの算出に支障を来すことがある。このような場合であっても、第一照明手段21〜第四照明手段24と撮像手段11との分離させたことで、第一照明手段21〜第四照明手段24を最適な位置や角度に設置して、このような影響を抑えることができる。   Furthermore, in the photometric stereo method, it is necessary to consider the influence of shadows. In the photometric stereo method, since a normal vector is calculated from reflected light of illumination, detection of reflected light is essential. However, for example, when the workpiece is complex and it is easy to get a shadow, if a lighting means is installed in the vicinity of this workpiece, appropriate reflected light cannot be obtained from a place where light does not reach, and normal vector calculation is performed. May cause problems. Even in such a case, the first illumination unit 21 to the fourth illumination unit 24 and the imaging unit 11 are separated from each other, so that the first illumination unit 21 to the fourth illumination unit 24 are set to the optimum positions and angles. This effect can be suppressed by installing it.

加えて、照明手段を撮像手段から分離したことで、照明光の高さを変更可能となる。この結果、ワークWKと照明との距離LWD(Light Working Distance)を小さくしたり、逆に大きくする検査が可能となり、ローアングルやマルチアングルの照明といった、検査用途に応じた適切な配置を選択できるようになる。
(1:LWDを小さく取った場合)
In addition, by separating the illumination unit from the imaging unit, the height of the illumination light can be changed. As a result, the distance LWD (Light Working Distance) between the work WK and the illumination can be reduced or conversely increased, and an appropriate arrangement according to the inspection application such as low-angle or multi-angle illumination can be selected. It becomes like this.
(1: When LWD is reduced)

LWDを小さく取ると、図21Aに示すように、第一照明手段21〜第四照明手段24からの光が横方向から多く当たることになる。一般にハレーションが発生するのは、入射角と反射角が同じ場合であるから、第一照明手段21〜第四照明手段24とワークWKとを接近させてLWDを小さくすることで、ハレーションの発生する位置を、ワークWKの外側近傍とすることができる。言い換えると、ワークWKの外側で意図的にハレーションを発生し易くして、ワークWKの表面近傍でのハレーションを抑制できる。これにより、ワークWKの有効視野を増加させることができる。   When the LWD is reduced, as shown in FIG. 21A, a large amount of light from the first illumination means 21 to the fourth illumination means 24 strikes from the lateral direction. In general, halation occurs when the incident angle and the reflection angle are the same. Therefore, by causing the first illumination means 21 to the fourth illumination means 24 and the work WK to approach each other to reduce LWD, halation occurs. The position can be near the outside of the workpiece WK. In other words, it is possible to intentionally generate halation on the outside of the work WK and suppress halation near the surface of the work WK. Thereby, the effective visual field of the workpiece | work WK can be increased.

また、LWDが小さい場合は、ローアングルでの照明となる。例えば上方からの直接照明では光が拡散して認識が困難なワーク表面上の凹凸でも、斜め側面から照射することで、小さい傾きの変化でもコントラストを大きく変化させて、浅い凸凹の変化を捉え易くできる。このようにローアングルでコントラストを強調することにより、フォトメトリックステレオ法において傾き画像や輪郭抽出画像をより鮮明にできる利点が得られる。   In addition, when the LWD is small, illumination is performed at a low angle. For example, even if unevenness on the workpiece surface is difficult to recognize due to light diffusing by direct illumination from above, illuminating from an oblique side makes it possible to capture changes in shallow irregularities by changing the contrast greatly even with small changes in tilt. it can. Thus, by emphasizing the contrast at a low angle, there is an advantage that the tilt image and the contour extraction image can be made clearer in the photometric stereo method.

一方で、LWDを小さく取った場合のデメリットとしては、浅い角度で照明光を照射することにより、影が生じ易くなるため、有効視野が減少し、フォトメトリックステレオ処理が困難となることがある。また、第一照明手段21〜第四照明手段24とワークWKが干渉し易くなるため、高さの大きいワークWKに対しては利用が制限されることがある。
(2:LWDを大きく取った場合)
On the other hand, as a demerit when the LWD is made small, shadows are easily generated by irradiating illumination light at a shallow angle, so that the effective visual field is reduced and photometric stereo processing may be difficult. In addition, since the first illuminating means 21 to the fourth illuminating means 24 and the work WK easily interfere with each other, the use of the work WK having a large height may be limited.
(2: Large LWD)

逆にLWDを大きく取ると、図21Bに示すように、第一照明手段21〜第四照明手段24からの照明光が上方向から多く照射されることになる。これによって影が生じ難くなるので、見えない領域が減少し、フォトメトリックステレオ処理の精度が向上する。また、第一照明手段21〜第四照明手段24とワークWKが干渉し難くなるため、高さの大きいワークWKに対しても好適に利用できる。   Conversely, if the LWD is increased, a large amount of illumination light from the first illumination means 21 to the fourth illumination means 24 is irradiated from above as shown in FIG. 21B. This makes it difficult for shadows to occur, reducing the invisible areas and improving the accuracy of photometric stereo processing. Moreover, since it becomes difficult for the 1st illumination means 21-the 4th illumination means 24 and the workpiece | work WK to interfere, it can utilize suitably also to the workpiece | work WK with large height.

一方で、ハレーションの発生する位置がワークWKの内側となるので、有効視野が減少してしまうことがある。またLWDを大きい場合は、マルチアングル方式の照明においてLWDが遠い場合に相当し、コントラストが出難いため、ワーク表面の浅い凸凹の変化を捉え難いこともある。一方で、マルチアングル方式の照明により、LWDが遠い場合には、第一照明手段21〜第四照明手段24の写り込みや照度ムラの少ない均一な撮像状態を作り出し、ワークWKそのものの表面状態を明確に捉えた画像を得ることができる。   On the other hand, since the position where halation occurs is inside the work WK, the effective visual field may be reduced. In addition, when the LWD is large, it corresponds to the case where the LWD is far in multi-angle illumination, and it is difficult to capture the change in shallow unevenness on the workpiece surface because it is difficult to obtain contrast. On the other hand, when the LWD is far away due to multi-angle illumination, the first illumination means 21 to the fourth illumination means 24 create a uniform imaging state with little illuminance unevenness and the surface state of the workpiece WK itself. A clearly captured image can be obtained.

このように、撮像手段と照明手段を分離したことで、様々な目的や用途の検査に対応でき、また配置の自由度を高められるといった利点が得られる。その一方で、照明手段と撮像手段とを別体に構成してフォトメトリックステレオ法で画像検査を行う場合は、照明手段と撮像手段との相対的な位置関係を明確に設定する必要がある。すなわち、フォトメトリックステレオ法においては照明方向が既知であることを前提として実行される。もし、フォトメトリックステレオ法用に設定された仮想照明方向と、実際の照明方向とが異なる場合は、検査精度が低下したり、誤った結果が出力されてしまう虞がある。   As described above, by separating the imaging unit and the illumination unit, there can be obtained an advantage that it is possible to cope with inspections for various purposes and applications and to increase the degree of freedom of arrangement. On the other hand, when the illumination unit and the imaging unit are configured separately and image inspection is performed by the photometric stereo method, it is necessary to clearly set the relative positional relationship between the illumination unit and the imaging unit. That is, the photometric stereo method is executed on the assumption that the illumination direction is known. If the virtual illumination direction set for the photometric stereo method is different from the actual illumination direction, there is a possibility that the inspection accuracy is lowered or an erroneous result is output.

ここで、照明方向を調整する方法としては、図22、図23に示すように、物理的に照明手段の位置を修正する方法と、現在の照明手段の位置、すなわち照明方向で、フォトメトリックステレオ法を実行するように、画像処理側で照明方向を実際に設置された照明手段のそれと一致させるように調整する方法が挙げられる。   Here, as a method of adjusting the illumination direction, as shown in FIGS. 22 and 23, a method of physically correcting the position of the illumination means, and a photometric stereo at the current position of the illumination means, that is, the illumination direction, are used. In order to execute the method, there is a method of adjusting the illumination direction on the image processing side so as to coincide with that of the illumination means actually installed.

前者の方法は、例えば図23に示すように、リング状に一体化した照明ユニットが発する各照明光の方向と、撮像手段の回転角度を一致させるように、相対的な回転位置を調整する作業が必要となり、非常に手間がかかる。また図22に示すように、各照明手段を分離して、独立して任意の位置に配置可能とした構成においては、上述した撮像手段との相対的な回転角度に加えて、照明手段同士の取り違えも起こるため、さらに調整作業が複雑化する。   In the former method, for example, as shown in FIG. 23, the relative rotation position is adjusted so that the direction of each illumination light emitted by the illumination unit integrated in a ring shape matches the rotation angle of the imaging means. Is necessary and very time consuming. In addition, as shown in FIG. 22, in the configuration in which each illumination unit is separated and can be arranged independently at any position, in addition to the relative rotation angle with the imaging unit described above, Since mistakes also occur, the adjustment work is further complicated.

これに対し後者の方法は、物理的な照明手段の角度や位置調整といった面倒な作業を行うことなく、ソフトウェア側で対応できるため、簡単で利便性に優れる。そこで本実施の形態においては、このような照明方向の調整を、照明方向推定手段41gを用いて行う手順を説明する。
(照明方向推定手段41g)
On the other hand, the latter method is simple and excellent in convenience because it can be handled on the software side without performing troublesome work such as adjusting the angle and position of the physical illumination means. Therefore, in the present embodiment, a procedure for performing such adjustment of the illumination direction using the illumination direction estimating means 41g will be described.
(Illumination direction estimation means 41g)

照明方向推定手段41gは、主として、画像処理部41により構成され、ソフトウェアによって処理がなされる。ここでは、(1)天頂角及び方位角のそれぞれがずれた場合の影響、(2)照明方向が検出できる原理、(3)ソフトウェアによる処理の観点から説明する。
(1)天頂角及び方位角のそれぞれがずれた場合の影響
The illumination direction estimation means 41g is mainly configured by the image processing unit 41 and processed by software. Here, (1) the influence when each of the zenith angle and the azimuth angle is shifted, (2) the principle that the illumination direction can be detected, and (3) the viewpoint of processing by software will be described.
(1) Effects when the zenith angle and azimuth angle shift

まず、天頂角及び方位角のそれぞれがずれた場合の影響について説明する。ここで、天頂角とは、図24Aの模式側面図に示すように、撮像手段11からワークWKへのベクトルと第一照明手段21〜第四照明手段24のそれぞれからワークWKへのベクトルとがなす角である。また方位角とは、図24Bの模式平面図に示すように、画像の基準方向(図24Bの例では上方向)を示すベクトルと、撮像手段11から第一照明手段21〜第四照明手段24のそれぞれへのべクトルとがなす角である。なお図24Bにおいては、説明の都合上第一照明手段21のみを図示し、他の照明手段22〜24の図示を省略している。   First, the influence when each of the zenith angle and the azimuth angle is shifted will be described. Here, as shown in the schematic side view of FIG. 24A, the zenith angle is a vector from the imaging means 11 to the work WK and a vector from each of the first illumination means 21 to the fourth illumination means 24 to the work WK. It is an angle to make. The azimuth is a vector indicating the reference direction of the image (upward in the example of FIG. 24B), the first illuminating means 21 to the fourth illuminating means 24 from the imaging means 11, as shown in the schematic plan view of FIG. 24B. It is the angle that the vector to each of makes. In FIG. 24B, only the first illumination means 21 is shown for convenience of explanation, and the other illumination means 22 to 24 are not shown.

フォトメトリックステレオ法では、照明方向が正確に判明していること、すなわち照明方向を規定する天頂角と方位角とが既知であることを大前提として、処理が行われる。この場合において、ユーザが設置した各照明手段の位置すなわち実際の照明方向と、フォトメトリックステレオ法による処理において想定されている照明の位置、すなわち前提とした仮定照明方向とが異なった場合に、問題となる。   In the photometric stereo method, processing is performed on the premise that the illumination direction is accurately known, that is, that the zenith angle and the azimuth angle that define the illumination direction are known. In this case, if the position of each lighting means installed by the user, that is, the actual lighting direction, and the position of the lighting assumed in the processing by the photometric stereo method, that is, the assumed lighting direction, are different. It becomes.

フォトメトリックステレオ法用に設定された仮想天頂角と実際の天頂角との相違は、理論上、撮像手段11と第一照明手段21〜第四照明手段24の垂直方向との相対的な位置の違いを意味する。ここで、天頂角、方位角がずれた場合の影響を説明するため、図25A〜図25Dの輪郭抽出画像に基づいて説明する。これらの図において、図25Aは仮定照明方向(天頂角及び方位角)と一致するように配置された照明方向で得られた、正しい輪郭抽出画像、図25Bは誤った天頂角と正しい方位角で得られた輪郭抽出画像、図25Cは正しい天頂角と誤った方位角(全体が45°回転してずれた場合)で得られた輪郭抽出画像、図25Dは正しい天頂角と誤った方位角(照明手段が入れ替わったシャッフル状態)で得られた輪郭抽出画像を、それぞれ示している。   The theoretical difference between the virtual zenith angle set for the photometric stereo method and the actual zenith angle is theoretically the relative position of the imaging means 11 and the first illumination means 21 to the fourth illumination means 24 in the vertical direction. Meaning the difference. Here, in order to explain the influence when the zenith angle and the azimuth angle are deviated, the description will be made based on the contour extracted images of FIGS. 25A to 25D. In these figures, FIG. 25A is a correct contour extraction image obtained with an illumination direction arranged to coincide with the assumed illumination direction (zenith angle and azimuth angle), and FIG. 25B is an incorrect zenith angle and correct azimuth angle. The obtained contour extraction image, FIG. 25C is a contour extraction image obtained with a correct zenith angle and an incorrect azimuth angle (when the whole is shifted by 45 °), and FIG. 25D is a correct zenith angle and an incorrect azimuth angle ( The contour extraction images obtained in the shuffle state in which the illumination means are replaced are shown respectively.

図25Aと図25Bから明らかなとおり、天頂角の変化は、輪郭抽出画像の凸凹が例えば2倍になったり、1/2になったりというように、コントラストが比例するという態様で表れる。この場合、正確な高さ情報を厳密に測定したい用途では問題となるものの、高さの絶対値(数値)でなく形状変化のみを把握したい用途では、さほど問題とならない。このことから、フォトメトリックステレオ法を画像検査に利用する用途において、天頂角の相違が検査対象の傷や印字等の検出精度に与える影響は、それほど大きくないといえる。   As is clear from FIGS. 25A and 25B, the change in the zenith angle appears in such a manner that the contrast is proportional, such that the unevenness of the contour extraction image is doubled or halved, for example. In this case, it becomes a problem in an application in which accurate height information is to be measured strictly, but in an application in which only the shape change is to be grasped instead of the absolute value (numerical value) of the height, there is not much problem. From this, it can be said that, in applications where the photometric stereo method is used for image inspection, the influence of the difference in the zenith angle on the detection accuracy such as scratches and prints to be inspected is not so great.

一方で、仮想方位角と実際の方位角との相違は、例えば図25A、図25C、図25Dに示すように、形状抽出性能が劣化する態様で表出してしまう。このため、フォトメトリックステレオ法を画像検査に利用する場合には、方位角が相違してしまうと、検査対象である傷や印字等の検出精度に与える影響は大きいといえる。
(2)照明方向を検出する原理
(2−1)ワークWKの形状が未知である場合
On the other hand, the difference between the virtual azimuth angle and the actual azimuth angle is expressed in a form in which the shape extraction performance deteriorates as shown in FIGS. 25A, 25C, and 25D, for example. For this reason, when the photometric stereo method is used for image inspection, if the azimuth angle is different, it can be said that the influence on the detection accuracy of scratches and prints to be inspected is great.
(2) Principle of detecting the illumination direction (2-1) When the shape of the workpiece WK is unknown

照明手段と撮像手段とは、相互の位置関係に物理的制約を様々に設けた状態で設置することが考えられる。例えば、各照明手段をリング状に配置したリング照明を設置する場合や、同じ角度巾で各照明手段を設置する場合、画像検査装置側で仮定照明方向と整合するように、例えば接続すべき照明手段と照明制御手段の照明接続コネクタとに共通のマークを設ける等して、各照明手段を取り違えることなく正確に設置する場合等が想定される。   It is conceivable that the illumination unit and the imaging unit are installed in a state where various physical restrictions are provided in the mutual positional relationship. For example, when installing ring illumination in which each illumination means is arranged in a ring shape, or when installing each illumination means with the same angular width, for example, illumination to be connected so as to match the assumed illumination direction on the image inspection apparatus side For example, a common mark may be provided on the lighting connection connector of the lighting control means and the lighting control means so that the lighting means can be accurately installed without being mistaken.

また照明手段と撮像手段との物理的制約の下では、照明手段の配置の間違え方は有限となる場合がある。例えば、4つの第一照明手段21〜第四照明手段24が90°間隔で同一円周上に配されており、これら4つの照明手段の平面視における中心に、ワークWKと撮像手段11とを配置させるという制約(条件)を考える。まず、一の照明手段を固定する場合、残りの3つの照明手段の配置の仕方は、33=6通りある。そして、固定すると考える照明が4つ、すなわち照明の決め方が4通りあり、この内正解の設置の仕方が1通りあるから、結局、間違え方の数は6×4−1=23通りあることにある。 In addition, under the physical constraints between the illumination unit and the imaging unit, there are cases where the way in which the illumination unit is disposed is finite. For example, four first illuminating means 21 to fourth illuminating means 24 are arranged on the same circumference at intervals of 90 °, and the workpiece WK and the imaging means 11 are arranged at the center in plan view of these four illuminating means. Consider the constraints (conditions) of placement. First, when one illumination means is fixed, there are 3 P 3 = 6 ways of arranging the remaining three illumination means. And there are 4 lightings to be fixed, that is, 4 ways to determine the lighting, and there is 1 way to set the correct answer, so there are 6 × 4−1 = 23 ways to make mistakes. is there.

この考え方を一般化して、平面視で撮像手段を中心とした同一円周上に360°/nの角度巾でn個の照明手段を配置する場合を考える。一の照明手段を固定すると、残りの照明手段の配置の仕方はn-1n-1通りある。また固定すると考える照明手段を、角度巾θずつ回転してずらす配置の仕方は、360°/θ通りある。 Generalizing this idea, consider a case where n illumination means are arranged with an angular width of 360 ° / n on the same circumference centered on the imaging means in plan view. When one illumination means is fixed, there are n-1 P n-1 ways of arranging the remaining illumination means. Further, there are 360 ° / θ ways of arranging the illumination means that are supposed to be fixed by rotating and shifting them by the angular width θ.

したがって、仮に固定すると考えた照明手段が、角度θずつずれた方位角である、0°、θ、2θ、・・・、(360°−2θ)/θ、(360°−θ)/θの何れかの位置の同一円周上に配置されており、残りのn−1個の照明手段が360°/nの角度巾で配置されているという物理的制約があった場合、n-1n-1×360°/θ通りの照明配置の組み合わせの中に仮定照明方向と整合する照明配置があり、n-1n-1×360°/θ−1通りは仮定照明方向と整合しない照明配置ということになる。 Therefore, the illuminating means that is supposed to be fixed has azimuth angles shifted by an angle θ of 0 °, θ, 2θ,..., (360 ° −2θ) / θ, (360 ° −θ) / θ. If there is a physical restriction that the light source is disposed on the same circumference at any position and the remaining n-1 illumination means are disposed at an angular width of 360 ° / n, n-1 P Among the combinations of n-1 × 360 ° / θ illumination arrangements, there is an illumination arrangement that matches the assumed illumination direction, and n-1 P n-1 × 360 ° / θ-1 ways does not match the assumed illumination direction. This is a lighting arrangement.

例えば、照明手段それぞれの実際の方位角については未知であるが、平面視で撮像手段を中心とした同一円周上に360°/nの角度巾でn個の照明手段が配置されるという物理的制約があった場合(以下、「ケース1」という。)、角度θを限りなく小さくしていけば、上記n-1n-1×360°/θ通りの組み合わせの中に、仮定照明方向の方位角に完全に整合する照明配置が理論上見つかるはずである。 For example, although the actual azimuth angle of each of the illumination means is unknown, the physicality that n illumination means are arranged with an angular width of 360 ° / n on the same circumference centered on the imaging means in plan view. If there is a general restriction (hereinafter referred to as “Case 1”), if the angle θ is reduced as much as possible, the above - mentioned combinations of n−1 P n−1 × 360 ° / θ are assumed illuminations. An illumination arrangement that perfectly matches the azimuth of the direction should be found in theory.

仮定照明方向の方位角に完全に整合する照明配置が見つかれば、照明方向が検出できることになるが、その方法はいくつか考えられる。   If an illumination arrangement that perfectly matches the azimuth angle of the assumed illumination direction is found, the illumination direction can be detected. Several methods are conceivable.

例えば、ケース1において、各照明方向から照明して撮像したn通りの画像から、その照明方向を仮定して、フォトメトリックステレオ法に従い上記n-1n-1×360°/θ通りの法線ベクトル画像又は輪郭抽出画像を評価関数にかけるソース画像SPとして生成し、評価関数によって、最も上位と評価されるソース画像SPを選択し、該ソース画像SPにおける天頂角及び方位角の変数値を実際の照明方向として検出する。
(照明方向の回転)
For example, in case 1, the n-1 P n-1 × 360 ° / θ method is performed according to the photometric stereo method, assuming the illumination direction from n images captured by illuminating from each illumination direction. A line vector image or a contour extraction image is generated as a source image SP to be subjected to an evaluation function, and the source image SP evaluated as the highest is selected by the evaluation function, and variable values of zenith angle and azimuth angle in the source image SP are selected. Detect as the actual illumination direction.
(Rotation of lighting direction)

まず、照明手段として、図26の模式平面図に示すように、複数の照明手段を一体化した照明ユニット(ここではリング照明)を用いた場合に、照明方向を特定する方法、いいかえると照明ユニットの回転角度を特定する方法について説明する。図26の例では、照明ユニットを、第一照明手段21、第二照明手段22、第三照明手段23、第四照明手段24を、ワークを中心に平面視0°、90°、180°、270°の位置にそれぞれ配置している。これらの照明手段は、撮像手段の光軸を中心とした仮想回転面上に実際の照明方向を有している。このようにして画定される実際の照明方向ALに対して、仮定照明方向ILを、0°の位置から時計回りに45°の角度巾で回転させて、各照明方向における輪郭抽出画像(ソース画像SP)を生成した例を、図27A〜図27Hに示す。これらの図において、図27Aは、仮定照明方向と整合するように実際の照明方向を一致させた、いいかえると仮定照明方向と実際の照明方向との差が0°の輪郭抽出画像、図27Bは差が45°、図27Cは90°、図27Dは135°、図27Eは180°、図27Fは225°、図27Gは270°、図27Hは315°において、それぞれ生成したソース画像SP(輪郭抽出画像)を示している。例えば仮定照明方向が180°回転してずれると、図27Eに示すように、得られた輪郭抽出画像の凸凹が真逆になる。また図27Cの90°や図27Gの270°のようにずれると、輪郭が極めて不明確となる。さらに図27Bの45°、図27Dの135°、図27Fの225°、図27Hの315°では、輪郭が鈍ったような様相を呈している。
(照明手段のシャッフル)
First, as shown in the schematic plan view of FIG. 26, when an illumination unit (here, ring illumination) integrated with a plurality of illumination means is used as the illumination means, in other words, the illumination unit. A method for specifying the rotation angle will be described. In the example of FIG. 26, the illumination unit is composed of the first illumination means 21, the second illumination means 22, the third illumination means 23, and the fourth illumination means 24. It is arranged at a position of 270 °. These illumination means have an actual illumination direction on a virtual rotation plane centered on the optical axis of the imaging means. With respect to the actual illumination direction AL defined in this manner, the assumed illumination direction IL is rotated clockwise from the position of 0 ° by an angle width of 45 °, and the contour extraction image (source image in each illumination direction) is rotated. An example of generating SP) is shown in FIGS. 27A to 27H. In these figures, FIG. 27A is a contour extraction image in which the actual illumination direction is matched to match the assumed illumination direction. In other words, FIG. 27B is a contour extraction image in which the difference between the assumed illumination direction and the actual illumination direction is 0 °. The difference is 45 °, FIG. 27C is 90 °, FIG. 27D is 135 °, FIG. 27E is 180 °, FIG. 27F is 225 °, FIG. 27G is 270 °, and FIG. (Extracted image). For example, when the assumed illumination direction is rotated by 180 ° and shifted, as shown in FIG. 27E, the unevenness of the obtained contour extraction image is reversed. Further, when the angle is shifted to 90 ° in FIG. 27C or 270 ° in FIG. 27G, the outline becomes very unclear. Furthermore, at 45 ° in FIG. 27B, 135 ° in FIG. 27D, 225 ° in FIG. 27F, and 315 ° in FIG.
(Shuffle of lighting means)

以上は、複数の照明手段が一体化された照明ユニットを用いた場合に、照明ユニットの回転角度に対応させる例を説明した。この場合は、第一照明手段21、第二照明手段22、第三照明手段23、第四照明手段24が照明ユニットに固定されているため、各照明手段が入れ替わる事態は考慮する必要がない。一方で、図28に示すように、各照明手段を個別に構成する場合は、さらに照明手段の入れ替わり(本明細書においては「シャッフル」と呼ぶ。)も考慮する必要がある。図28では説明のため、いずれか一の照明手段(ここでは第三照明手段23)を固定し、他の照明手段(第一照明手段21、第二照明手段22、第三照明手段23)を任意に入れ替える状態を示している。以下では、このような照明手段が入れ替わったシャッフル状態において、各照明手段を特定する手順について説明する。   In the above, an example in which a lighting unit in which a plurality of lighting units are integrated is used corresponding to the rotation angle of the lighting unit has been described. In this case, since the 1st illumination means 21, the 2nd illumination means 22, the 3rd illumination means 23, and the 4th illumination means 24 are being fixed to the illumination unit, it is not necessary to consider the situation where each illumination means changes. On the other hand, as shown in FIG. 28, when each lighting unit is individually configured, it is necessary to consider the replacement of the lighting unit (referred to as “shuffle” in this specification). In FIG. 28, for the sake of explanation, any one of the illumination means (here, the third illumination means 23) is fixed, and the other illumination means (the first illumination means 21, the second illumination means 22, and the third illumination means 23) are fixed. A state of arbitrary replacement is shown. Hereinafter, a procedure for specifying each illumination unit in a shuffle state in which such illumination units are replaced will be described.

ここで、図28のように、照明手段のシャッフル状態によって輪郭抽出画像が変化する様子を、図29A〜図29Fに示す。これらの図において、図29Aは、仮定照明方向と整合する照明方向による正しい輪郭抽出画像(ソース画像SP)であり、また図29B〜図29Fは、第一照明手段21、第二照明手段22、第三照明手段23をシャッフルしたすべての組み合わせ(3×2×1=6通り)において生成したソース画像SP(輪郭抽出画像)を、それぞれ示している。   Here, as shown in FIG. 28, FIGS. 29A to 29F show how the contour extraction image changes depending on the shuffle state of the illumination means. In these figures, FIG. 29A is a correct contour extraction image (source image SP) with an illumination direction that matches the assumed illumination direction, and FIGS. 29B to 29F show the first illumination means 21, the second illumination means 22, Source images SP (contour extraction images) generated in all combinations (3 × 2 × 1 = 6) in which the third illumination unit 23 is shuffled are shown.

図27及び図29が示すように、正しい輪郭抽出画像である図27A及び図29Aでは濃淡差が付いている。これに対して、照明方向が仮定照明方向と整合しない場合には、図27B〜図27Hや図29B〜図29Fが示すように、輪郭が滑らかになったり、不明確となったりする。一方で、検査対象のワークの形状としては、凹状となるものは少なく、凸状の形状が一般的と考えられる。また凸状の形状のワークでは、フォトメトリックステレオ法の正しいパラメータを選択した場合に、最も全体の凸が大きく表示された画像が得られている。このことから、凸度の平均を評価値として、照明方向の角度(回転角)と、シャッフルについて最大値を示すパラメータを探索する。例えば高さの平均を得る関数を評価関数とすれば、濃淡差として表出する凸凹の凸成分が最も多くなる場合に、この関数値が最も大きくなる。これを利用することで、このとき得られたソース画像SPにおける天頂角及び方位角の値を、実際の照明方向として検出できる。   As shown in FIGS. 27 and 29, the correct contour extraction images shown in FIGS. 27A and 29A are shaded. On the other hand, when the illumination direction does not match the assumed illumination direction, as shown in FIGS. 27B to 27H and FIGS. 29B to 29F, the contour becomes smooth or unclear. On the other hand, as the shape of the workpiece to be inspected, there are few concave shapes, and a convex shape is generally considered. In the case of a convex workpiece, when the correct parameter of the photometric stereo method is selected, an image having the largest overall convexity is obtained. From this, using the average convexity as an evaluation value, the angle (rotation angle) in the illumination direction and a parameter indicating the maximum value for shuffle are searched. For example, if a function for obtaining an average height is used as an evaluation function, this function value becomes the largest when the convex / concave component expressed as a shading difference is the largest. By utilizing this, the values of the zenith angle and azimuth angle in the source image SP obtained at this time can be detected as the actual illumination direction.

なお評価関数は、高さの平均値とする構成に限らず、例えば平均値の二乗等、他の関数を適宜利用できる。また、得られた高さの平均等の評価値の、最大値を絞り込むための方法も、特に限定されるものでなく、例えば、刻み幅探索、2分探索、黄金分割探索、最急降下法等が適宜利用できる。   Note that the evaluation function is not limited to the configuration having the average value of the height, and other functions such as the square of the average value can be used as appropriate. Further, the method for narrowing the maximum value of the evaluation values such as the average of the obtained height is not particularly limited. For example, step search, binary search, golden section search, steepest descent method, etc. Can be used as appropriate.

次に、様々な形状のワークに対して、図26に示すように仮定照明方向ILを回転をさせて得たソース画像SPから、画像全体での高さの平均を求め、回転角度毎にプロットしたグラフを、図30に示す。ここではワークとして、ハードディスク、ピンセット、一円玉、基板、フック、天頂角を傾けたフック、平板、電卓、目薬、SDカード、コンソールを用いた。結果として、いずれのワークにおいても、回転角度が0°(360°)付近で、高さの平均値の最も大きい画像が得られている。ここで0°(360°)は仮定照明方向ILが実際の照明方向ALと重なる位置、すなわち正しい照明方向である。よって、高さ平均値が最大となる回転角度を求めれば、この位置を推定照明方向として扱えることが確認できた。特に、様々な形状のワークにおいても、全体的に凸な形状であれば、一のピークを有する傾向が確認できた。また凸成分が多い程、推定照明方向の算出に好適であることが判る。   Next, the average height of the entire image is obtained from the source image SP obtained by rotating the assumed illumination direction IL as shown in FIG. The obtained graph is shown in FIG. Here, hard disks, tweezers, one-yen coins, substrates, hooks, hooks with tilted zenith angles, flat plates, calculators, eye drops, SD cards, and consoles were used as workpieces. As a result, in any workpiece, an image having the largest average value of the height is obtained when the rotation angle is around 0 ° (360 °). Here, 0 ° (360 °) is a position where the assumed illumination direction IL overlaps the actual illumination direction AL, that is, the correct illumination direction. Therefore, it was confirmed that if the rotation angle at which the average height is maximized was obtained, this position could be treated as the estimated illumination direction. In particular, even in workpieces of various shapes, the tendency to have one peak could be confirmed if the overall shape was convex. It can also be seen that the more convex components, the better the calculation of the estimated illumination direction.

また、図28に示すように撮像手段をシャッフルしたすべての組み合わせ(オリジナルを含む6通りの組み合わせ)に対して得たソース画像SPから、同様に画像全体での高さの平均を求め、回転角度毎にプロットしたグラフを、図31に示す。この図においても、回転角度が0°(360°)付近で、高さの平均値の最も大きい画像が得られている。すなわち、高さ平均値の最大となる回転角度を算出すれば、この位置を推定照明方向として扱えることが確認できた。   Further, as shown in FIG. 28, the average of the height of the entire image is similarly obtained from the source images SP obtained for all combinations (six combinations including the original) in which the imaging means is shuffled, and the rotation angle is obtained. The graph plotted for each is shown in FIG. Also in this figure, an image having the largest average value of the height is obtained when the rotation angle is around 0 ° (360 °). In other words, it was confirmed that if the rotation angle with the maximum height average value was calculated, this position could be treated as the estimated illumination direction.

以上から、撮像手段や照明方向の設置における実験誤差を考慮すると、高さの平均値を評価関数とすることで、この関数値が最大となる時点のソース画像SPにおける天頂角及び方位角の値を推定照明方向とすることで、実際の照明方向を検出できる。   From the above, considering experimental errors in installation of the imaging means and the illumination direction, the average value of the height is used as the evaluation function, so that the value of the zenith angle and azimuth angle in the source image SP at the time when this function value becomes maximum The estimated illumination direction can be used to detect the actual illumination direction.

ここで、照明手段と撮像手段との物理的制約には様々な形態が考えられる。例えば、等間隔に配置した照明手段と撮像手段とを完全に一体型とする例や、照明手段は一体で、撮像手段と分離させつつ、撮像手段の周囲に対して任意の回転角度で配置する例、あるいは各照明手段を独立して配置可能な自由照明の例がある。また、このような物理的制約に応じて、照明手段の設置の間違え方にも様々なバリエーションが考えられる。例えば、図26に示す回転方向の誤りや、図28に示すシャッフルすなわち照明手段の取り違えに加え、図32に示すような十字軸(xy軸)からのずれ、あるいは図33に示す天頂角非対称ずれ×2、図34に示す天頂角対称変化×2等の態様が挙げられる。ここで、照明手段と撮像手段との物理的制約のバリエーションに対して、照明手段設置の間違え方の態様毎に、その間違えが生じる可能性を、表1に纏める。   Here, various forms are conceivable as physical restrictions between the illumination unit and the imaging unit. For example, the illumination unit and the imaging unit arranged at equal intervals are completely integrated, or the illumination unit is integrated and separated from the imaging unit at an arbitrary rotation angle with respect to the periphery of the imaging unit. There are examples, or examples of free illumination in which each illumination means can be arranged independently. In addition, various variations can be conceived as to how to install the illumination means in accordance with such physical constraints. For example, in addition to the rotation direction error shown in FIG. 26, the shuffle, that is, the illumination means shown in FIG. 28, the deviation from the cross axis (xy axis) as shown in FIG. 32, or the zenith angle asymmetric deviation shown in FIG. Examples include x2 and zenith angle symmetry change x2 shown in FIG. Here, with respect to variations in physical constraints between the illuminating means and the imaging means, Table 1 summarizes the possibility of mistakes occurring for each manner of illuminating means installation mistakes.

また、このような照明手段の設置の間違え方の態様毎に、推定に失敗した場合の影響や推定に必要な拘束条件、推定に悪影響を与える因子について、表2に纏める。   In addition, Table 2 summarizes the effects of failure in estimation, the constraint conditions necessary for the estimation, and factors that adversely affect the estimation for each mode of installation of such illumination means.

(2−2)ワークWKの形状が既知である場合 (2-2) When the shape of the workpiece WK is known

ワークWKの形状が既知である場合、天頂角及び方位角を変数として算出されて生成されたソース画像SPから、天頂角及び方位角に対して、上記ソース画像SPにおけるワークWKの表面形状とソース画像SPにした実際の表面形状とのズレの大きさを数値化した関数を評価関数とする。この評価関数によれば、評価関数の値が最小となるとき、実際の照明方向によるソース画像SPとの整合の度合いが最大となる。したがって、この評価関数の値が最小となるときのソース画像SPにおける天頂角及び方位角の変数値を実際の照明方向として検出することができる。   When the shape of the workpiece WK is known, the surface shape and the source of the workpiece WK in the source image SP with respect to the zenith angle and the azimuth angle are calculated from the source image SP calculated by using the zenith angle and the azimuth angle as variables. A function obtained by quantifying the amount of deviation from the actual surface shape in the image SP is defined as an evaluation function. According to this evaluation function, when the value of the evaluation function is minimized, the degree of matching with the source image SP in the actual illumination direction is maximized. Therefore, the variable values of the zenith angle and azimuth angle in the source image SP when the value of the evaluation function is minimized can be detected as the actual illumination direction.

また、ワークWKが、鏡面反射成分が強い半球状のワークである場合、図35Aに示すように、照明手段からの光の入射角とワークからの光の反射角とが等しくなるようにハレーションが発生する。ワークWKの中心座標を基点とするハレーションの中心座標への方向ベクトルの大きさ及びワークWKの半径、並びに天頂角θの関係から、天頂角θは、以下のように求まる。   Further, when the workpiece WK is a hemispherical workpiece having a strong specular reflection component, as shown in FIG. Occur. From the relationship between the magnitude of the direction vector to the center coordinates of the halation with the center coordinate of the workpiece WK as the base point, the radius of the workpiece WK, and the zenith angle θ, the zenith angle θ is obtained as follows.

なお、以下のように、計算してもよい。   The calculation may be performed as follows.

この場合の方位角は、図35Bに示すように、方向ベクトルのxy平面の座標から求まる。   The azimuth angle in this case is obtained from the coordinates of the xy plane of the direction vector as shown in FIG. 35B.

さらに、ワークWKが、高さが既知のワークである場合、図36Aに示すように、照明光によるワークWKの影ができる。照明手段からの光のワークWKによる影の大きさ及びワークWKの高さ、並びに天頂角θの関係から、天頂角θは、以下のように求まる。   Further, when the workpiece WK is a workpiece having a known height, as shown in FIG. 36A, a shadow of the workpiece WK by illumination light can be formed. From the relationship between the size of the shadow of the light from the illumination means by the work WK, the height of the work WK, and the zenith angle θ, the zenith angle θ is obtained as follows.

この場合の方位角は、図36Bに示すように、影のベクトルのxy平面の座標から求まる。
(3)ソフトウェアによる処理
The azimuth angle in this case is obtained from the coordinates of the shadow vector in the xy plane, as shown in FIG. 36B.
(3) Processing by software

照明方向推定手段41gにおけるソフトウェアによる処理について図37〜図39に示すフローチャートを参照して説明する。図37は、フォトメトリックステレオ法を利用した照明方向の検出処理の流れを示すフローチャートである。図38は、フォトメトリックステレオ法を利用しない照明方向の検出処理の流れを示すフローチャートである。図39は、画像検査装置1の処理の全体の流れを示すフローチャートである。
(3−1)フォトメトリックステレオ法を利用した照明方向の検出方法
The process by the software in the illumination direction estimation means 41g is demonstrated with reference to the flowchart shown to FIGS. FIG. 37 is a flowchart showing the flow of the illumination direction detection process using the photometric stereo method. FIG. 38 is a flowchart showing the flow of the illumination direction detection process not using the photometric stereo method. FIG. 39 is a flowchart showing the overall flow of processing of the image inspection apparatus 1.
(3-1) Illumination direction detection method using photometric stereo method

まず、図37に示すフローチャートを参照して、フォトメトリックステレオ法を利用した照明方向の検出方法から説明する。ステップST1では、画像処理部41及び撮像手段11は、図39に示すフローチャートのステップST101〜ステップST105の処理を実行する。   First, an illumination direction detection method using the photometric stereo method will be described with reference to a flowchart shown in FIG. In step ST1, the image processing unit 41 and the imaging unit 11 execute the processes in steps ST101 to ST105 in the flowchart shown in FIG.

ステップST2では、ユーザは、ワークWKの形状が未知であるか既知であるかに応じて、評価関数に選定するとともに、天頂角を定数にするか変数とするかの判断、及び、その値や角度巾、並びに、方位角の角度巾について、パラメータの設定を行う。   In step ST2, the user selects an evaluation function according to whether the shape of the workpiece WK is unknown or is known, determines whether the zenith angle is a constant or a variable, Parameters are set for the angle width and the azimuth angle width.

ステップST3では、画像処理部41は、ステップST108における、ユーザによって輪郭抽出モードが選択された場合の処理を実行して、すべての変数値におけるソース画像SPを生成する。   In step ST3, the image processing unit 41 executes the process in step ST108 when the contour extraction mode is selected by the user, and generates the source images SP for all the variable values.

ワークWKの形状が既知である場合において、ステップST4では、画像処理部41は、記憶手段44に保存してあるソース画像SPとした実際の表面形状情報を参照する。ワークWKの形状が未知である場合には、この処理は実行しない。   When the shape of the workpiece WK is known, in step ST4, the image processing unit 41 refers to the actual surface shape information as the source image SP stored in the storage unit 44. If the shape of the workpiece WK is unknown, this process is not executed.

ステップST5では、画像処理部41は、ステップST3によって、天頂角及び方位角を変数(場合によっては定数)として算出されて生成されたソース画像SPから、天頂角及び方位角に対して、評価関数に応じて、最も上位と評価されるソース画像SPを選択する。   In step ST5, the image processing unit 41 performs an evaluation function on the zenith angle and azimuth angle from the source image SP generated by calculating the zenith angle and azimuth angle as variables (in some cases constants) in step ST3. Accordingly, the source image SP evaluated as the highest is selected.

ステップST5では、画像処理部41は、数値解析で収束しなかった場合に、ステップST2に戻り、パラメータの再設定を行う。   In step ST5, the image processing unit 41 returns to step ST2 and resets the parameters when the numerical analysis does not converge.

ステップST6では、画像処理部41は、ステップST5によって、評価関数に応じて、最も上位と評価されたソース画像SPにおける天頂角及び方位角の変数値(場合によっては定数値)を実際の照明方向として検出する。
(3−2)フォトメトリックステレオ法を利用しない照明方向の検出方法
In step ST6, the image processing unit 41 uses the zenith angle and azimuth variable values (constant values in some cases) in the source image SP evaluated as the highest in step ST5 in accordance with the evaluation function in the actual illumination direction. Detect as.
(3-2) Detection method of illumination direction without using photometric stereo method

続いて、図38に示すフローチャートを参照して、フォトメトリックステレオ法を利用しない照明方向の検出方法から説明する。ステップST11では、画像処理部41及び撮像手段11は、図39に示すフローチャートのステップST101〜ステップST103の処理を実行し、画像処理部41は、ワークWKが撮影された4つの画像信号Q1〜Q4を実際の表面形状情報として記憶手段44に保存する。   Next, an illumination direction detection method that does not use the photometric stereo method will be described with reference to the flowchart shown in FIG. In step ST11, the image processing unit 41 and the imaging unit 11 execute the processes in steps ST101 to ST103 in the flowchart shown in FIG. 39, and the image processing unit 41 has four image signals Q1 to Q4 obtained by photographing the workpiece WK. Is stored in the storage means 44 as actual surface shape information.

ステップST12では、画像処理部41は、記憶手段44に保存してある実際の表面形状情報を参照する。   In step ST <b> 12, the image processing unit 41 refers to actual surface shape information stored in the storage unit 44.

ステップST13では、ステップST12において参照した実際の表面形状情報から天頂角及び方位角を算出する。   In step ST13, a zenith angle and an azimuth angle are calculated from the actual surface shape information referred in step ST12.

ステップST14では、画像処理部41は、ステップST13によって、算出された天頂角及び方位角の値を実際の照明方向として検出する。   In step ST14, the image processing unit 41 detects the values of the calculated zenith angle and azimuth as the actual illumination direction in step ST13.

このように、自動的に、且つ高精度に、ユーザが設置した実際の照明方向を推定することができるので、フォトメトリックステレオ法と組み合わせた場合には、照明手段と撮像手段とを別体とすることができるメリットがある。すなわち、照明手段と撮像手段とを別体にして、ユーザが照明の位置を自由に変更できるようにすると、傾き画像(法線ベクトル)は、その照明の位置に応じて変わる特性があるため、その特性を許容する画像検査装置においては、ユーザが設置した実際の照明方向を推定する照明方向推定手段の存在は極めて有用な意義を有する。
(画像検査方法)
Thus, since the actual illumination direction set by the user can be estimated automatically and with high accuracy, when combined with the photometric stereo method, the illumination unit and the imaging unit are separated from each other. There are merits that can be done. That is, if the illumination unit and the imaging unit are separated and the user can freely change the position of the illumination, the tilt image (normal vector) has a characteristic that changes according to the position of the illumination. In an image inspection apparatus that allows such characteristics, the presence of an illumination direction estimation unit that estimates the actual illumination direction installed by the user is extremely useful.
(Image inspection method)

ここで、画像検査装置1を用いてワークの外観検査を行う画像検査方法の手順を、図39のフローチャートに基づいて説明する。   Here, a procedure of an image inspection method for performing an appearance inspection of a workpiece using the image inspection apparatus 1 will be described based on a flowchart of FIG.

ステップST101では、画像処理部41は、照明制御手段31を介して、照明手段21、22、23、24に対してトリガ信号を発し、照明手段21、22、23、24は、トリガ信号に応じて順に1つずつ点灯する。   In step ST101, the image processing unit 41 issues a trigger signal to the illumination units 21, 22, 23, and 24 via the illumination control unit 31, and the illumination units 21, 22, 23, and 24 respond to the trigger signal. Turn on one by one.

ステップST102では、撮像手段11は、各照明手段21、22、23、24が点灯する都度作動して、ワークWKを撮影する。   In step ST102, the imaging unit 11 operates each time the lighting units 21, 22, 23, and 24 are turned on, and images the workpiece WK.

ステップST103では、撮像手段11は、ワークWKが撮影された4つの画像信号Q1〜Q4を画像処理部41に転送する。   In step ST103, the imaging unit 11 transfers the four image signals Q1 to Q4 obtained by photographing the work WK to the image processing unit 41.

ステップST104では、画像処理部41は、撮像手段11から入力された4つの画像信号Q1〜Q4を用いて、画像信号Q1〜Q4毎に、各画素における面の法線ベクトルを計算する。   In step ST <b> 104, the image processing unit 41 uses the four image signals Q <b> 1 to Q <b> 4 input from the imaging unit 11 to calculate the normal vector of the surface in each pixel for each image signal Q <b> 1 to Q <b> 4.

ステップST105では、画像処理部41は、画像信号Q1〜Q4毎に、後段の処理で必要となる、1/1、1/2、1/4、1/8、1/16、1/32にそれぞれ縮小した縮小傾き画像を作成する。また、画像処理部41は、画像信号Q1〜Q4毎に、後段の処理で必要となる、テクスチャ抽出画像を作成しておく。   In step ST105, the image processing unit 41 reduces the image signals Q1 to Q4 to 1/1, 1/2, 1/4, 1/8, 1/16, and 1/32, which are necessary for subsequent processing. Create a reduced tilt image with each reduced size. In addition, the image processing unit 41 creates a texture extraction image that is necessary for subsequent processing for each of the image signals Q1 to Q4.

ステップST106では、必要に応じて特徴サイズの調整を行う。特徴サイズを変化させることで、凹凸抽出画像において抽出される凹凸の大きさが変わる。具体的には特徴サイズを大きくすると、大きなサイズの凹凸が抽出された凹凸抽出画像が得られる。逆に特徴サイズを小さくすると、小さなサイズの凹凸が抽出される。したがってユーザは、抽出したい傷の大きさに応じて特徴サイズを調整する。あるいは、OCR用途の場合は、特徴サイズを大きくすることで、OCRに適した凹凸抽出画像を得ることができる。   In step ST106, the feature size is adjusted as necessary. By changing the feature size, the size of the unevenness extracted in the unevenness extraction image changes. Specifically, when the feature size is increased, a concavo-convex extracted image from which large-sized concavo-convex has been extracted is obtained. On the other hand, when the feature size is reduced, small-sized irregularities are extracted. Therefore, the user adjusts the feature size according to the size of the wound to be extracted. Alternatively, in the case of OCR use, an unevenness extraction image suitable for OCR can be obtained by increasing the feature size.

ステップST107では、凹凸抽出画像計算を行う。この例では画像処理部41が、ステップST106で設定された特徴サイズに従って凹凸を抽出した凹凸抽出画像を生成し、これを表示手段51に表示させる。   In step ST107, unevenness extraction image calculation is performed. In this example, the image processing unit 41 generates a concavo-convex extracted image obtained by extracting the concavo-convex according to the feature size set in step ST <b> 106, and displays it on the display unit 51.

ステップST110〜112では、画像処理部41又はPLC81が、輪郭抽出画像に対して、傷検査ツールを利用して傷を検出するための傷検出処理をして、傷かどうかを判定する傷判定処理をする。   In steps ST110 to ST112, the image processing unit 41 or the PLC 81 performs a flaw detection process for detecting a flaw using a flaw inspection tool on the contour extraction image, and determines whether or not the flaw is a flaw. do.

まず、ステップST110では、画像処理部41又はPLC81は、生成された輪郭画像に対して検査対象となる検査領域の位置を特定する。検査領域を設定する際には、例えば、エッジを抽出する等して、ワークWKの画像を抽出する。ワークWKが大きく位置ずれしない場合には、検査領域の設定位置を予め登録しておいてもよい。   First, in step ST110, the image processing unit 41 or the PLC 81 specifies the position of the inspection region to be inspected with respect to the generated contour image. When setting the inspection area, for example, an image of the work WK is extracted by extracting an edge or the like. When the work WK does not greatly deviate, the set position of the inspection area may be registered in advance.

ステップST111では、画像処理部41又はPLC81は、特定された検査領域内の傷を検出するための画像処理を施す。画像処理部41又はPLC81は、記憶されている算出方法により基準濃度値を算出し、画素毎に検査領域の各画素の濃度値と基準濃度値との差分を算出する。そして、画像処理部41又はPLC81は、設定して記憶されている閾値(傷量という閾値を決めておく。)によるラベリング処理(2値画像の白画素の固まりに、「0、1、2・・・」という札(ラベル)を貼っていく処理。)を実行し、特定された傷毎に特徴量を算出する。算出する特徴量は、例えば差分の正負に関する正負情報、差分の総和、差分の最大値、差分の平均値、又は差分の標準偏差である。   In step ST111, the image processing unit 41 or the PLC 81 performs image processing for detecting a flaw in the specified inspection area. The image processing unit 41 or the PLC 81 calculates a reference density value by a stored calculation method, and calculates a difference between the density value of each pixel in the inspection area and the reference density value for each pixel. Then, the image processing unit 41 or the PLC 81 performs labeling processing based on a threshold value that is set and stored (a threshold value that is a scratch amount is determined) (“0, 1, 2,. .. ”is executed, and a feature amount is calculated for each specified flaw. The feature quantity to be calculated is, for example, positive / negative information regarding the positive / negative of the difference, the sum of the differences, the maximum value of the differences, the average value of the differences, or the standard deviation of the differences.

ステップST112では、画像処理部41又はPLC81は、ステップST111で特定された傷に対して、傷判定に用いる判定基準に基づいて傷判定処理を実行する。傷と判定された場合、表示手段51上で、傷の箇所にマーキングをし、処理を終了する。
(変形例)
In step ST112, the image processing unit 41 or the PLC 81 performs a scratch determination process on the scratch identified in step ST111 based on a determination criterion used for scratch determination. If it is determined as a scratch, marking is made on the scratched area on the display means 51, and the process is terminated.
(Modification)

以上の例では、特徴サイズをユーザが調整可能とすることで、特徴サイズのパラメータでもってユーザが望むサイズの凹凸を抽出した凹凸抽出画像を生成する例を説明した。ただ本発明はこの構成に限らず、ユーザの観察用途や目的に応じた複数の観察モードを予め用意しておき、ユーザに観察モードを選択させることで、所望の画像を生成するように構成することもできる。このような例を図40のフローチャートに基づいて説明する。ステップST”1〜ST”5は、上述した図39と同様であるため、詳細説明を省略する。   In the above example, the example in which the feature size can be adjusted by the user to generate the unevenness extraction image in which the unevenness of the size desired by the user is extracted using the feature size parameter has been described. However, the present invention is not limited to this configuration, and a plurality of observation modes corresponding to the user's observation application and purpose are prepared in advance, and a desired image is generated by allowing the user to select an observation mode. You can also. Such an example will be described based on the flowchart of FIG. Steps ST ″ 1 to ST ″ 5 are the same as those in FIG. 39 described above, and thus detailed description thereof is omitted.

ステップST”6では、観察モードをユーザに選択させる。この例では、輪郭抽出モード、テクスチャ抽出モード、凹凸モードの何れかを選択可能としている。各観察モードは、各観察用途に適した特徴サイズを予めプリセットしておく。なお、観察モードの選択後に、ユーザが手動で特徴サイズを微調整可能に構成してもよい。選択された観察モードに従って、次に移行するステップが異なる。すなわち輪郭抽出モードが選択された場合はステップST”7へ、テクスチャ抽出モードが選択された場合はステップST”8へ、凹凸モードが選択された場合はステップST”9へ、それぞれ移行する。各ステップの処理後は、ステップST”10に移行する。このように、凹凸抽出画像生成手段と輪郭画像生成手段41bとテクスチャ抽出画像生成手段41cとは、切り替え可能としている。   In step ST ″ 6, the user is made to select an observation mode. In this example, any one of a contour extraction mode, a texture extraction mode, and an uneven mode can be selected. Each observation mode has a feature size suitable for each observation application. It should be noted that the feature size can be manually adjusted by the user after selection of the observation mode, and the next transition step differs according to the selected observation mode, ie, contour extraction. If the mode is selected, the process proceeds to step ST ″ 7, if the texture extraction mode is selected, the process proceeds to step ST ″ 8, and if the uneven mode is selected, the process proceeds to step ST ″ 9. After the processing of each step, the process proceeds to step ST ″ 10. Thus, the unevenness extraction image generation unit, the contour image generation unit 41b, and the texture extraction image generation unit 41c can be switched.

ステップST”7では、画像処理部41は、凹凸抽出画像計算を行う。すなわち、画像処理部41は、凹凸抽出画像が表示される特徴サイズの輪郭抽出画像を表示手段51に表示する。   In step ST ″ 7, the image processing unit 41 performs the unevenness extraction image calculation. That is, the image processing unit 41 displays on the display means 51 a contour extraction image having a feature size on which the unevenness extraction image is displayed.

ステップST”8では、画像処理部41は、ユーザによって輪郭抽出モードが選択された場合の処理を実行する。すなわち、画像処理部41は、ステップST”5において作成された縮小傾き画像に基づいて、輪郭抽出画像計算を行い、輪郭抽出画像を表示手段51に表示する。   In step ST ″ 8, the image processing unit 41 executes a process when the contour extraction mode is selected by the user. That is, the image processing unit 41 is based on the reduced tilt image created in step ST ″ 5. The contour extraction image is calculated, and the contour extraction image is displayed on the display means 51.

ステップST”9では、画像処理部41は、ユーザによってテクスチャ抽出モードが選択された場合の処理を実行する。すなわち、画像処理部41は、ステップST”5において作成されたテクスチャ抽出画像に基づいて、テクスチャ抽出画像計算を行い、テクスチャ抽出画像を表示手段51に表示する。   In step ST ″ 9, the image processing unit 41 executes processing in the case where the texture extraction mode is selected by the user. That is, the image processing unit 41 is based on the texture extracted image created in step ST ″ 5. Then, the texture extraction image calculation is performed, and the texture extraction image is displayed on the display means 51.

以降のステップST”10〜12は、上述した図39と同様の手順が利用でき、詳細説明を省略する。   Subsequent steps ST ″ 10 to 12 can use the same procedure as in FIG. 39 described above, and a detailed description thereof will be omitted.

以上の画像検査装置によれば、フォトメトリックステレオ法を利用して第1次の傾き画像を生成することを出発点としながらも、得られた第1次の傾き画像をX方向及びY方向に微分処理して第2次の傾き画像、すなわち、輪郭抽出画像を作成するようにしている。この処理によって、照明やワーク設置面の僅かな傾きや、元々入力している照明の位置等の入力情報の過誤に対して、得られる検査画像が大きく変化してしまい、例えば、実際には凸凹していないのに凸凹の画像になる現象、照明に対して、通常、近くが明るくなる傾向を受けて、ワークWKの中央が盛り上がったような画像になるといった現象等の、実物に即した検査画像が得られない、という従来のようなフォトメトリックステレオ法の欠点を少なくする事ができる。面の凹方向に傾き変化の大きいところが暗くなる階調とする一方、面の凸方向に変化の小さいところが明るくなる階調と設定することで、ワーク表面の傾きが大きく変化する傷や輪郭等を抽出するのに好適な画像となる。   According to the image inspection apparatus described above, the first-order tilt image obtained in the X direction and the Y-direction is generated while generating the first-order tilt image using the photometric stereo method. A second-order tilt image, that is, a contour extraction image is generated by performing differentiation. This process greatly changes the inspection image to be obtained due to errors in the input information such as the slight inclination of the illumination or workpiece installation surface or the position of the illumination that was originally input. Inspection that matches the real thing, such as the phenomenon that the image becomes uneven although it has not been done, and the phenomenon that the center of the workpiece WK is raised due to the tendency to become brighter near the illumination. The disadvantage of the conventional photometric stereo method that an image cannot be obtained can be reduced. By setting the gradation where the slope change is large in the concave direction of the surface to darken, while setting the gradation where the small change in the convex direction of the surface is brighter, scratches and contours that greatly change the workpiece surface inclination are set. The image is suitable for extraction.

また輪郭画像生成手段が、算出された各画素の法線ベクトルから異なる縮小率の複数の縮小傾き画像を作成し、それぞれの縮小傾き画像において、X方向及びY方向に微分処理を施し、得られた縮小輪郭画像に対して、所定の縮小率の縮小輪郭画像が大きく反映されるように重み付けをして、元のサイズへ拡大してから、拡大された縮小輪郭画像をすべて足し合わせたものを輪郭抽出画像とすることができる。この構成によれば、如何なる大きさを傷として判断するかは、ユーザの用途によって異なるところ、所定の縮小率の縮小輪郭画像が輪郭抽出画像に大きく反映されるように重み付けができるようにしたので、ユーザの用途に応じて、ユーザが所望する縮小率の縮小輪郭画像が強調された輪郭抽出画像が得られる。ユーザのニーズとしては、例えば、10ピクセルに跨がったものを傷として判断したい場合もあれば、100ピクセルに跨がっている凹んだものを傷として判断したい場合もある。また、急峻なエッジだけをエッジとして抽出したい場合もある。   Further, the contour image generation means creates a plurality of reduced inclination images with different reduction ratios from the calculated normal vectors of the respective pixels, and performs a differentiation process in each of the reduced inclination images in the X direction and the Y direction. The reduced outline image is weighted so that the reduced outline image with a predetermined reduction ratio is largely reflected, enlarged to the original size, and then added to all the enlarged reduced outline images. A contour extracted image can be obtained. According to this configuration, what size is determined as a flaw depends on the user's application, and weighting can be performed so that a reduced contour image with a predetermined reduction ratio is largely reflected in the contour extracted image. According to the user's application, a contour extraction image in which a reduced contour image having a reduction ratio desired by the user is emphasized is obtained. As user needs, for example, there is a case where it is desired to determine a scratch extending over 10 pixels as a scratch, and a case where a concave portion extending over 100 pixels is determined as a scratch. In some cases, only sharp edges may be extracted as edges.

また傷は、通常、複数の周波数に跨がって検出されるところ、拡大された縮小輪郭画像をすべて足し合わせたものを輪郭抽出画像としているので、一つの周波数の縮小輪郭画像に限定した場合に比べて、傷や輪郭等が、全体的にぼやけることなく、クリアに検出できる。   Also, scratches are usually detected across a plurality of frequencies, but the sum of all the enlarged reduced contour images is used as the contour extraction image, so when limited to a reduced contour image of one frequency Compared to the above, scratches, contours, and the like can be clearly detected without blurring.

さらに重み付けは、予め決められた重みのセットを用意しておき、縮小輪郭画像に対して、重みのセットを掛けることによって、それぞれの縮小率の縮小輪郭画像の採用比を按分することによって行うことができる。これによれば、輪郭抽出画像に合成するときに予め決められた重みのセット(特徴サイズ)がプリセットされているので、ユーザは、所望する輪郭抽出画像に瞬時に簡単に切り替えることができる。   Furthermore, weighting is performed by preparing a set of predetermined weights, and by multiplying the reduced contour image by the weight set, and by dividing the adoption ratio of the reduced contour image of each reduction ratio. Can do. According to this, since a set of weights (feature size) determined in advance when combining with the contour extraction image is preset, the user can easily and instantly switch to the desired contour extraction image.

さらにまた重みのセットは、ワークの表面の凸凹が明瞭な輪郭抽出画像が得られる縮小輪郭画像の採用比が大きくなるセットを含むことができる。この使い方を例えば凹凸モードとすることで、輪郭抽出モードと使い分けることができる。   Furthermore, the set of weights can include a set in which the adoption ratio of the reduced contour image from which a contour extraction image with clear irregularities on the surface of the workpiece is obtained is increased. For example, by using the uneven mode for this usage, it can be used separately from the contour extraction mode.

さらにまた、重みのセットは、OCRに適した輪郭抽出画像が得られる縮小輪郭画像の採用比が大きくなるセットを含むことができるので、例えば鋳物の刻印のようなものに対して、OCRをするのに好適な画像を作成することができる。   Furthermore, the set of weights can include a set in which the adopted ratio of the reduced contour image from which a contour extraction image suitable for OCR is obtained is increased, so that OCR is performed on a casting mark, for example. Therefore, it is possible to create a suitable image.

さらにまた、照明手段による照明する回数個ある、算出された各画素の法線ベクトルから、入力画像と同数個の各画素のアルベドを算出し、アルベドから、ワークの表面の傾き状態を除去した模様を示すテクスチャ抽出画像を生成するようにして、輪郭画像生成手段とテクスチャ抽出画像生成手段とを切り替え可能に構成したので、本来の傷と元々ある輪郭と区別するのは通常困難であるため、傷があってはいけない箇所をサーチして検査領域とすることが求められているが、テクスチャ抽出画像でサーチをして、検査領域を決めてから傷検査を行うことができる。また、OCRを行う際にも、テクスチャ抽出画像でサーチをして、OCRを行う対象領域を決めてからOCRを行うことができる。   Furthermore, the albedo of the same number of pixels as the input image is calculated from the calculated normal vector of each pixel that is illuminated by the illumination means, and the tilt state of the workpiece surface is removed from the albedo. Since the contour image generation means and the texture extraction image generation means are configured to be switchable so as to generate a texture extraction image indicating the above, it is usually difficult to distinguish the original scratch from the original contour. Although it is required to search for an area where there should not be an inspection area, it is possible to perform a scratch inspection after searching the texture extracted image and determining the inspection area. Also, when performing OCR, it is possible to perform OCR after performing a search on a texture extracted image and determining a target area for performing OCR.

テクスチャ抽出画像生成手段は、入力画像と同数個の各画素のアルベドの値をソートして上から特定の順番の画素値を採用したものをテクスチャ抽出画像とすることができる。これにより、ハレーションを起こしている輝度が高い画素値は採用されず、ハレーションの影響が取り除かれたテクスチャ抽出画像が得られる。   The texture extracted image generation means can sort the albedo values of the same number of pixels as the input image and adopt the pixel values in a specific order from the top as the texture extracted image. As a result, a pixel value having high luminance causing halation is not adopted, and a texture extracted image from which the influence of halation is removed is obtained.

また輪郭抽出画像生成後の傷検査に必要な傷検査ツールを備えることで、フォトメトリックステレオ技術は三次元計測の一つの手法であるというのが一般的な共通認識であるところ、フォトメトリックステレオ技術を傷検査に応用した実用品として位置づけられる画像検査装置を提供できる。   In addition, it is common knowledge that photometric stereo technology is a method of three-dimensional measurement by providing a flaw inspection tool necessary for flaw inspection after generating contour extraction images. Photometric stereo technology It is possible to provide an image inspection apparatus that is positioned as a practical product that is applied to scratch inspection.

さらに画像検査装置は、ワークを一定の方向から撮像する撮像手段と、ワークを異なる方向から少なくとも3回照明する照明手段と、照明手段を1つずつ順に点灯させる照明制御手段と、各照明タイミングにて撮像手段を駆動させることにより、複数の画像を生成する画像生成手段と、複数の画像で対応関係にある画素毎の画素値を用いて、各画素のワークの表面に対する法線ベクトルを算出する法線ベクトル算出手段と、照明手段による照明する回数個ある、算出された各画素の法線ベクトルから、法線ベクトルと同数個の各画素のアルベドを算出し、アルベドから、ワークの表面の傾き状態を除去した模様を示すテクスチャ抽出画像を生成するテクスチャ抽出画像生成手段とを備え、テクスチャ抽出画像生成手段は、法線ベクトルと同数個の各画素のアルベドの値をソートして上から特定の順番の画素値を採用したものをテクスチャ抽出画像とすることができる。これによれば、テクスチャ抽出画像生成手段は、法線ベクトルと同数個の各画素のアルベドの値をソートして上から特定の順番の画素値を採用したものをテクスチャ抽出画像とするようにしたので、ハレーションを起こしている輝度が高い画素値は採用されず、ハレーションの影響が取り除かれたテクスチャ抽出画像が得られる。   Further, the image inspection apparatus includes an imaging unit that images the workpiece from a certain direction, an illumination unit that illuminates the workpiece at least three times from different directions, an illumination control unit that sequentially turns on the illumination unit one by one, and each illumination timing. By driving the image pickup means, a normal vector with respect to the surface of the work of each pixel is calculated using the image generation means for generating a plurality of images and the pixel values for each pixel in a corresponding relationship in the plurality of images. Calculate the albedo of each pixel as many as the normal vector from the normal vector calculation means and the normal vector of each pixel that has been illuminated by the illumination means, and the inclination of the surface of the workpiece from the albedo Texture extraction image generation means for generating a texture extraction image showing the pattern from which the state has been removed, and the texture extraction image generation means has the same number as the normal vector. It can be a material obtained by employing the pixel values of a specific order from the top to sort the values of albedo of each pixel of the texture extracted image. According to this, the texture extraction image generation means sorts the albedo values of the same number of pixels as the normal vector and adopts a pixel value in a specific order from the top as the texture extraction image. Therefore, pixel values with high luminance causing halation are not adopted, and a texture extracted image from which the influence of halation is removed is obtained.

このように、実施の形態に係る画像検査装置によれば、フォトメトリックステレオ法を利用して、より簡単、かつ、ロバストにワークの傷や印字を検査することができる。   As described above, according to the image inspection apparatus according to the embodiment, it is possible to more easily and robustly inspect the scratches and prints of the work by using the photometric stereo method.

本発明の画像検査装置、画像検査方法、画像検査プログラム及びコンピュータで読み取り可能な記録媒体又は記録した機器は、フォトメトリックステレオを用いた検査装置やデジタイザに好適に利用できる。   The image inspection apparatus, the image inspection method, the image inspection program, and the computer-readable recording medium or the recorded device of the present invention can be suitably used for an inspection apparatus or a digitizer using a photometric stereo.

1…画像検査装置
11…撮像手段
12、32、52、62、82…ケーブル
71、72、73、74、76…ケーブル
20、20’、20”…環状照明ユニット
21、22、23、24、25…照明手段
31…照明制御手段
41…画像処理部;41a…法線ベクトル算出手段;41b…輪郭画像生成手段
41c…テクスチャ抽出画像生成手段;41d…検査領域特定手段
41e…画像処理手段;41f…判定手段;41g…照明方向推定手段
42…信号処理系
43…CPU
44…メモリ
45…ROM
46…バス
51…表示手段
61…操作手段
75…照明分岐ユニット
81…PLC
e1…カメラ
e21〜e24…照明用の光源
WK…ワーク
SG…ステージ
L1…第一照明手段;L2…第二照明手段
n…法線ベクトル
S…拡散反射面
OS…障害物
AL…実際の照明方向
IL…仮定照明方向
DESCRIPTION OF SYMBOLS 1 ... Image inspection apparatus 11 ... Imaging means 12, 32, 52, 62, 82 ... Cable 71, 72, 73, 74, 76 ... Cable 20, 20 ', 20 "... Annular illumination unit 21, 22, 23, 24, 25 ... illumination means 31 ... illumination control means 41 ... image processing unit; 41a ... normal vector calculation means; 41b ... contour image generation means 41c ... texture extraction image generation means; 41d ... inspection region specification means 41e ... image processing means; ... Determination means; 41g ... Illumination direction estimation means 42 ... Signal processing system 43 ... CPU
44 ... Memory 45 ... ROM
46 ... Bus 51 ... Display means 61 ... Operation means 75 ... Illumination branch unit 81 ... PLC
e1 ... cameras e21 to e24 ... illumination light source WK ... work SG ... stage L1 ... first illumination means; L2 ... second illumination means n ... normal vector S ... diffuse reflection surface OS ... obstacle AL ... actual illumination direction IL: Assumed illumination direction

Claims (19)

ワークの外観検査を行うための画像検査装置であって、
ワークを互いに異なる実際の照明方向から照明するための三以上の照明手段と、
前記三以上の照明手段を一ずつ所定の点灯順に点灯させるための照明制御手段と、
前記照明制御手段により各照明手段を点灯させる照明タイミングにて、ワークを一定の方向から撮像することにより、実際の照明方向が異なる複数の部分照明画像を撮像するための撮像手段と、
前記撮像手段によって撮像された複数の部分照明画像同士で、対応関係にある画素毎の画素値を用いて、フォトメトリックステレオ法に基づき、照明方向を仮定した仮定照明方向におけるワークの表面のソース画像を、複数の異なる仮定照明方向毎に生成するためのソース画像生成手段と、
前記ソース画像生成手段によって仮定照明方向毎に生成された複数のソース画像に基づき、前記照明手段における実際の照明方向と最も整合する推定照明方向を検出するための照明方向推定手段と
を備えることを特徴とする画像検査装置。
An image inspection apparatus for inspecting the appearance of a workpiece,
Three or more illumination means for illuminating the workpiece from different actual illumination directions;
Illumination control means for lighting the three or more illumination means one by one in a predetermined lighting order;
Imaging means for capturing a plurality of partial illumination images having different actual illumination directions by imaging the workpiece from a certain direction at an illumination timing at which each illumination means is turned on by the illumination control means;
The source image of the surface of the workpiece in the assumed illumination direction assuming the illumination direction based on the photometric stereo method using the pixel values for each pixel having a correspondence relationship among the plurality of partial illumination images captured by the imaging unit Source image generating means for generating a plurality of different assumed illumination directions,
Illumination direction estimation means for detecting an estimated illumination direction that most closely matches the actual illumination direction in the illumination means, based on a plurality of source images generated for each assumed illumination direction by the source image generation means. A characteristic image inspection apparatus.
請求項1に記載の画像検査装置であって、
前記三以上の照明手段が、一体的に構成されており、かつ前記撮像手段の光軸を中心とした仮想回転面上に実際の照明方向を有しており、
前記照明方向推定手段が、仮想回転面上に位置すると仮定された複数の仮定照明方向の中から、推定照明方向を推定してなることを特徴とする画像検査装置。
The image inspection apparatus according to claim 1,
The three or more illumination means are integrally configured, and have an actual illumination direction on a virtual rotation plane centered on the optical axis of the imaging means,
An image inspection apparatus, wherein the illumination direction estimation means estimates an estimated illumination direction from a plurality of assumed illumination directions assumed to be located on a virtual rotation plane.
請求項1に記載の画像検査装置であって、
前記三以上の照明手段が、互いに独立して配置可能に構成されており、かつ前記撮像手段の光軸を中心とした仮想回転面上に実際の照明方向を有しており、
前記照明方向推定手段が、仮想回転面上に位置すると仮定された複数の仮定照明方向の中から、推定照明方向を推定すると共に、前記三以上の照明手段のそれぞれの設置位置を推定可能に構成してなることを特徴とする画像検査装置。
The image inspection apparatus according to claim 1,
The three or more illumination means are configured to be arranged independently of each other, and have an actual illumination direction on a virtual rotation plane centered on the optical axis of the imaging means,
The illumination direction estimating means is configured to estimate an estimated illumination direction from a plurality of assumed illumination directions assumed to be located on a virtual rotation surface, and to estimate each installation position of the three or more illumination means. An image inspection apparatus characterized by comprising:
請求項1〜3のいずれか一に記載の画像検査装置であって、
前記照明方向推定手段は、ワークの表面形状を凸状と仮定して照明照明方向を推定してなることを特徴とする画像検査装置。
The image inspection apparatus according to claim 1,
The image inspection apparatus, wherein the illumination direction estimating means estimates the illumination illumination direction on the assumption that the surface shape of the workpiece is convex.
請求項1〜4のいずれか一に記載の画像検査装置であって、
前記ソース画像生成手段は、前記複数のソース画像を、照明方向を特定する天頂角及び方位角を変数として生成するものであり、
前記照明方向推定手段は、前記ソース画像生成手段でもって生成されたソース画像のうち、実際の照明方向によるソース画像との整合の度合いを示す第1評価関数に従い、最も上位と評価されるソース画像を選択し、該ソース画像における天頂角及び方位角の変数値を推定照明方向として推定してなることを特徴とする画像検査装置。
The image inspection apparatus according to any one of claims 1 to 4,
The source image generation means generates the plurality of source images with a zenith angle and an azimuth angle that specify an illumination direction as variables,
The illumination direction estimating means is a source image evaluated as the highest in accordance with a first evaluation function indicating a degree of matching with the source image in the actual illumination direction among the source images generated by the source image generating means. The image inspection apparatus is characterized in that the zenith angle and azimuth angle variable values in the source image are estimated as the estimated illumination direction.
請求項5に記載の画像検査装置であって、
前記第1評価関数は、天頂角及び方位角を変数として算出されて生成されたソース画像から、天頂角及び方位角に対して、前記ソース画像におけるワークの表面形状とソース画像にした実際の表面形状とのズレの大きさを数値化した関数であることを特徴とする画像検査装置。
The image inspection apparatus according to claim 5,
The first evaluation function is obtained by calculating the surface shape of the workpiece in the source image and the actual surface of the source image with respect to the zenith angle and azimuth angle from the source image calculated by using the zenith angle and azimuth as variables. An image inspection apparatus, which is a function obtained by quantifying the amount of deviation from a shape.
請求項1〜4のいずれか一に記載の画像検査装置であって、
前記ソース画像生成手段は、前記複数のソース画像を、照明方向を特定する天頂角及び方位角のうち、天頂角を定数とし、方位角を変数として生成するものであり、
前記照明方向推定手段は、前記ソース画像生成手段でもって生成されたソース画像のうち、実際の照明方向によるソース画像との整合の度合いを示す第2評価関数によって、最も上位と評価されるソース画像を選択し、該ソース画像における方位角の変数値と天頂角の定数値を推定照明方向として推定してなることを特徴とする画像検査装置。
The image inspection apparatus according to any one of claims 1 to 4,
The source image generation means generates the plurality of source images with a zenith angle as a constant and a azimuth as a variable among zenith angles and azimuth angles that specify an illumination direction,
The illumination direction estimation means is a source image evaluated as the highest by a second evaluation function indicating a degree of matching with the source image in the actual illumination direction among the source images generated by the source image generation means. An image inspection apparatus characterized by selecting the variable value of the azimuth angle and the constant value of the zenith angle in the source image as the estimated illumination direction.
請求項7に記載の画像検査装置であって、
前記第2評価関数は、天頂角を定数とし、方位角を変数として算出されて生成されたソース画像から、方位角に対して、ワークの表面の凸凹の凸成分の表出割合を数値化した関数であることを特徴とする画像検査装置。
The image inspection apparatus according to claim 7,
The second evaluation function quantifies the expression ratio of the uneven component of the surface of the workpiece with respect to the azimuth angle from the source image calculated by using the zenith angle as a constant and the azimuth angle as a variable. An image inspection apparatus characterized by being a function.
請求項5〜8のいずれか一に記載の画像検査装置であって、
変数としての方位角は、予め定められた組み合わせの中から値が設定されることを特徴とする画像検査装置。
The image inspection apparatus according to any one of claims 5 to 8,
An image inspection apparatus characterized in that a value is set from a predetermined combination for an azimuth angle as a variable.
請求項5〜8のいずれか一に記載の画像検査装置であって、
変数としての方位角は、均等の角度巾で値が設定されることを特徴とする画像検査装置。
The image inspection apparatus according to any one of claims 5 to 8,
An image inspection apparatus in which an azimuth angle as a variable is set with a uniform angular width.
請求項5〜10に記載の画像検査装置であって、
前記照明方向推定手段は、ワークを、鏡面反射成分を含む半球状と推定し、さらに前記ソース画像毎に、ワークのソース画像中での中心座標を基点として、ワークからの鏡面反射成分の画像での中心にあるハレーション座標のベクトルを求め、前記ベクトルの方向を、前記ソース画像を生成した際の照明方向の方位角として算出し、前記ベクトルの画素数とワークの大きさの画素数との比から、前記ソース画像を生成した際の照明方向の天頂角を算出してなることを特徴とする画像検査装置。
The image inspection apparatus according to claim 5, wherein
The illumination direction estimating means estimates the workpiece as a hemisphere including a specular reflection component, and further, for each source image, uses a center coordinate in the source image of the workpiece as a base point, as an image of the specular reflection component from the workpiece. A vector of the halation coordinates at the center of the image, and the direction of the vector is calculated as the azimuth angle of the illumination direction when the source image is generated, and the ratio between the number of pixels of the vector and the number of pixels of the workpiece size The zenith angle in the illumination direction when the source image is generated is calculated from the image inspection apparatus.
請求項5〜10に記載の画像検査装置であって、
前記照明方向推定手段は、ワークの高さを既知として、前記ソース画像毎に、ワークのソース画像での中心座標を基点として、ワークのソース画像での影の先端にある影座標のベクトルを求め、前記ベクトルの方向を、前記ソース画像を生成した際の照明方向の方位角として算出し、前記ベクトルの画素数とワークの高さの画素数との比から、前記ソース画像を生成した際の照明方向の天頂角を算出してなることを特徴とする画像検査装置。
The image inspection apparatus according to claim 5, wherein
The illumination direction estimating means obtains a vector of shadow coordinates at the tip of a shadow in the work source image, with the height of the work being known and for each source image, based on the center coordinate in the work source image. The direction of the vector is calculated as the azimuth angle of the illumination direction when the source image is generated, and the ratio of the number of pixels of the vector to the number of pixels of the workpiece height is used to generate the source image. An image inspection apparatus characterized by calculating a zenith angle in an illumination direction.
請求項5〜10に記載の画像検査装置であって、
前記照明方向推定手段は、予め設定された、前記撮像手段及び前記照明手段が配置された状態での天頂角及び/又は方位角の設定範囲を、推定された天頂角及び/又は方位角と比較して、前記設定範囲を外れた場合には警告を発するよう構成してなることを特徴とする画像検査装置。
The image inspection apparatus according to claim 5, wherein
The illumination direction estimating means compares a preset setting range of the zenith angle and / or azimuth with the imaging means and the illumination means arranged with the estimated zenith angle and / or azimuth. An image inspection apparatus configured to issue a warning when the set range is not satisfied.
請求項1〜13のいずれか一に記載の画像検査装置であって、
前記照明制御手段は、異なる仮定照明方向毎にソース画像を生成する際の点灯順を、任意に変更可能に構成してなることを特徴とする画像検査装置。
An image inspection apparatus according to any one of claims 1 to 13,
The image inspection apparatus, wherein the illumination control unit is configured to be able to arbitrarily change a lighting order when generating a source image for each different assumed illumination direction.
請求項1〜14のいずれか一に記載の画像検査装置であって、
前記ソース画像生成手段は、
前記撮像手段によって撮像された複数の部分照明画像同士で、対応関係にある画素毎の画素値を用いて、フォトメトリックステレオ法に基づき、各画素のワークの表面に対する法線ベクトルを算出するための法線ベクトル算出手段と、
前記法線ベクトル算出手段で算出された各画素の法線ベクトルに対して、X方向及びY方向に微分処理を施し、ワークの表面の傾きの輪郭を示す輪郭画像を生成するための輪郭画像生成手段と、
を含むことを特徴とする画像検査装置。
An image inspection apparatus according to any one of claims 1 to 14,
The source image generation means includes
For calculating a normal vector with respect to the surface of the workpiece of each pixel based on the photometric stereo method using pixel values for each pixel having a correspondence relationship among a plurality of partial illumination images captured by the imaging unit Normal vector calculation means;
Contour image generation for performing differential processing in the X direction and Y direction on the normal vector of each pixel calculated by the normal vector calculation means to generate a contour image indicating the contour of the workpiece surface inclination Means,
An image inspection apparatus comprising:
請求項1〜15のいずれか一に記載の画像検査装置であって、さらに、
生成された輪郭画像に対して検査対象となる検査領域の位置を特定するための検査領域特定手段と、
前記検査領域特定手段で特定された検査領域内の傷を検出するための画像処理を施すための画像処理手段と、
前記画像処理手段の処理結果に基づいて、ワーク表面の傷の有無を判定するための判定手段と
を備えることを特徴とする画像検査装置。
The image inspection apparatus according to claim 1, further comprising:
Inspection area specifying means for specifying the position of the inspection area to be inspected with respect to the generated contour image;
Image processing means for performing image processing for detecting a flaw in the inspection area specified by the inspection area specifying means;
An image inspection apparatus comprising: determination means for determining the presence or absence of scratches on the workpiece surface based on the processing result of the image processing means.
ワークの画像を撮像して外観を検査する検査方法であって、
ワークを、三以上の照明手段を一ずつ所定の点灯順にて点灯させて、異なる実際の照明方向から所定の点灯タイミングで照明すると共に、共通の撮像手段を用いて、各実際の照明方向毎に一の部分照明画像を撮像して、実際の照明方向が異なる複数枚の部分照明画像を取得する工程と、
異なる照明手段で照明して取得した複数の部分照明画像同士で、対応関係にある画素毎の画素値を用いて、フォトメトリックステレオ法に基づき、照明方向を仮定した仮定照明方向におけるワークの表面のソース画像を、ソース画像生成手段で複数の異なる仮定照明方向毎に生成する工程と、
前記ソース画像生成手段によって仮定照明方向毎に生成された複数のソース画像に基づき、照明方向推定手段でもって、前記照明手段における実際の照明方向と最も整合する推定照明方向を検出する工程と、
を含むことを特徴とする画像検査方法。
An inspection method for inspecting the appearance by taking an image of a workpiece,
Three or more lighting means are lighted one by one in a predetermined lighting order, and the work is illuminated at a predetermined lighting timing from different actual lighting directions, and a common imaging means is used for each actual lighting direction. Capturing one partial illumination image and obtaining a plurality of partial illumination images having different actual illumination directions; and
Based on the photometric stereo method, the surface of the workpiece in the assumed illumination direction is assumed based on the photometric stereo method, using pixel values for each pixel in a correspondence relationship between multiple partial illumination images acquired by illumination with different illumination means. Generating a source image for each of a plurality of different assumed illumination directions by the source image generating means;
Based on a plurality of source images generated for each assumed illumination direction by the source image generation means, with the illumination direction estimation means, detecting an estimated illumination direction that most closely matches the actual illumination direction in the illumination means;
An image inspection method comprising:
ワークの画像を撮像して外観を検査するための検査プログラムであって、コンピュータに、
ワークを、三以上の照明手段を一ずつ所定の点灯順にて点灯させて、異なる実際の照明方向から所定の点灯タイミングで照明すると共に、共通の撮像手段を用いて、各実際の照明方向毎に一の部分照明画像を撮像して、実際の照明方向が異なる複数枚の部分照明画像を取得する機能と、
異なる照明手段で照明して取得した複数の部分照明画像同士で、対応関係にある画素毎の画素値を用いて、フォトメトリックステレオ法に基づき、照明方向を仮定した仮定照明方向におけるワークの表面のソース画像を、ソース画像生成手段で複数の異なる仮定照明方向毎に生成する機能と、
前記ソース画像生成手段によって仮定照明方向毎に生成された複数のソース画像に基づき、照明方向推定手段でもって、前記照明手段における実際の照明方向と最も整合する推定照明方向を検出する機能と、
を実現させることを特徴とする画像検査プログラム。
An inspection program for inspecting the appearance by taking an image of a workpiece,
Three or more lighting means are lighted one by one in a predetermined lighting order, and the work is illuminated at a predetermined lighting timing from different actual lighting directions, and a common imaging means is used for each actual lighting direction. A function of capturing one partial illumination image and acquiring a plurality of partial illumination images with different actual illumination directions;
Based on the photometric stereo method, the surface of the workpiece in the assumed illumination direction is assumed based on the photometric stereo method, using pixel values for each pixel in a correspondence relationship between multiple partial illumination images acquired by illumination with different illumination means. A function of generating a source image for each of a plurality of different assumed illumination directions by the source image generation means;
Based on a plurality of source images generated for each assumed illumination direction by the source image generation means, a function for detecting an estimated illumination direction that most closely matches an actual illumination direction in the illumination means with an illumination direction estimation means;
An image inspection program characterized by realizing the above.
請求項18に記載の画像検査プログラムを記録したコンピュータで読み取り可能な記録媒体又は記録した機器。   A computer-readable recording medium or a recorded device on which the image inspection program according to claim 18 is recorded.
JP2014119139A 2014-06-09 2014-06-09 Image inspection apparatus, image inspection method, image inspection program, computer-readable recording medium, and recorded apparatus Active JP6395456B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2014119139A JP6395456B2 (en) 2014-06-09 2014-06-09 Image inspection apparatus, image inspection method, image inspection program, computer-readable recording medium, and recorded apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2014119139A JP6395456B2 (en) 2014-06-09 2014-06-09 Image inspection apparatus, image inspection method, image inspection program, computer-readable recording medium, and recorded apparatus

Publications (2)

Publication Number Publication Date
JP2015232487A true JP2015232487A (en) 2015-12-24
JP6395456B2 JP6395456B2 (en) 2018-09-26

Family

ID=54934016

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2014119139A Active JP6395456B2 (en) 2014-06-09 2014-06-09 Image inspection apparatus, image inspection method, image inspection program, computer-readable recording medium, and recorded apparatus

Country Status (1)

Country Link
JP (1) JP6395456B2 (en)

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2018013740A (en) * 2016-07-22 2018-01-25 株式会社キーエンス Magnification observation device
JP2018138902A (en) * 2017-02-24 2018-09-06 株式会社キーエンス Appearance inspection device and illumination device for appearance inspection
CN108647554A (en) * 2018-05-15 2018-10-12 佛山市南海区广工大数控装备协同创新研究院 A kind of sport footwear air cushion stereoscopic two-dimensional code identification and detection device and method
DE102018102926A1 (en) 2017-08-10 2019-02-14 Omron Corporation Image processing system, settings support device, and settings support program
CN109872382A (en) * 2017-12-01 2019-06-11 欧姆龙株式会社 Image processing system and image processing method
EP3499178A1 (en) 2017-12-15 2019-06-19 Omron Corporation Image processing system, image processing program, and image processing method
EP3499408A1 (en) 2017-12-15 2019-06-19 Omron Corporation Image processing system, image processing program, and image processing method
EP3531344A1 (en) 2018-02-26 2019-08-28 OMRON Corporation Image processing system and setting method
US10412810B2 (en) 2017-08-10 2019-09-10 Omron Corporation Setting support apparatus, image processing system, and non-transitory computer-readable recording medium
EP3540647A1 (en) 2018-03-15 2019-09-18 OMRON Corporation Image processing system, image processing device and image processing program
JPWO2019082584A1 (en) * 2017-10-24 2020-10-22 日本電気株式会社 Information processing device
WO2020241844A1 (en) * 2019-05-31 2020-12-03 興和株式会社 Image processing device and image processing program
WO2022019185A1 (en) * 2020-07-21 2022-01-27 富士フイルム富山化学株式会社 Engraved mark identification device, engraved mark identification method, and drug identification device
CN114354607A (en) * 2021-10-09 2022-04-15 七海测量技术(深圳)有限公司 Luminosity three-dimensional flaw detection method based on spiral phase contrast filtering algorithm
JP7160428B1 (en) * 2021-05-21 2022-10-25 株式会社レイマック Non-contact blood vessel analysis method

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001084362A (en) * 1999-07-12 2001-03-30 Fuji Photo Film Co Ltd Method and device for estimating light source direction and three-dimensional shape and recording medium
JP2001084386A (en) * 1999-07-12 2001-03-30 Fuji Photo Film Co Ltd Method and device for estimating light source direction and recording medium
JP2001084380A (en) * 1999-07-12 2001-03-30 Fuji Photo Film Co Ltd Method and device for estimating light source direction and recording medium
US6636627B1 (en) * 1999-07-12 2003-10-21 Fuji Photo Film Co., Light source direction estimating method and apparatus
JP2013186100A (en) * 2012-03-12 2013-09-19 Hitachi Ltd Shape inspection method and device
JP2014038049A (en) * 2012-08-17 2014-02-27 Sony Corp Three-dimensional measuring apparatus, three-dimensional measuring method, program, and base plate manufacturing method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001084362A (en) * 1999-07-12 2001-03-30 Fuji Photo Film Co Ltd Method and device for estimating light source direction and three-dimensional shape and recording medium
JP2001084386A (en) * 1999-07-12 2001-03-30 Fuji Photo Film Co Ltd Method and device for estimating light source direction and recording medium
JP2001084380A (en) * 1999-07-12 2001-03-30 Fuji Photo Film Co Ltd Method and device for estimating light source direction and recording medium
US6636627B1 (en) * 1999-07-12 2003-10-21 Fuji Photo Film Co., Light source direction estimating method and apparatus
JP2013186100A (en) * 2012-03-12 2013-09-19 Hitachi Ltd Shape inspection method and device
JP2014038049A (en) * 2012-08-17 2014-02-27 Sony Corp Three-dimensional measuring apparatus, three-dimensional measuring method, program, and base plate manufacturing method

Cited By (28)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2018013740A (en) * 2016-07-22 2018-01-25 株式会社キーエンス Magnification observation device
JP2018138902A (en) * 2017-02-24 2018-09-06 株式会社キーエンス Appearance inspection device and illumination device for appearance inspection
US10412310B2 (en) 2017-08-10 2019-09-10 Omron Corporation Image processing system, setting assistance device, and non-transitory computer-readable media
DE102018102926A1 (en) 2017-08-10 2019-02-14 Omron Corporation Image processing system, settings support device, and settings support program
CN109387510A (en) * 2017-08-10 2019-02-26 欧姆龙株式会社 Image processing system, device for assisting in setting and computer readable recording medium
CN109387510B (en) * 2017-08-10 2021-07-09 欧姆龙株式会社 Image processing system, setting support device, and computer-readable recording medium
US10412810B2 (en) 2017-08-10 2019-09-10 Omron Corporation Setting support apparatus, image processing system, and non-transitory computer-readable recording medium
US11423632B2 (en) 2017-10-24 2022-08-23 Nec Corporation Device and method for determining surface irregularities with irradiation angle
JPWO2019082584A1 (en) * 2017-10-24 2020-10-22 日本電気株式会社 Information processing device
CN109872382B (en) * 2017-12-01 2023-06-20 欧姆龙株式会社 Image processing system and image processing method
CN109872382A (en) * 2017-12-01 2019-06-11 欧姆龙株式会社 Image processing system and image processing method
US10853935B2 (en) 2017-12-15 2020-12-01 Omron Corporation Image processing system, computer readable recording medium, and image processing method
EP3499178A1 (en) 2017-12-15 2019-06-19 Omron Corporation Image processing system, image processing program, and image processing method
CN109945794A (en) * 2017-12-15 2019-06-28 欧姆龙株式会社 Image processing system, computer readable recording medium and image processing method
US10859506B2 (en) 2017-12-15 2020-12-08 Omron Corporation Image processing system for processing image data generated in different light emission states, non-transitory computer readable recording medium, and image processing method
EP3499408A1 (en) 2017-12-15 2019-06-19 Omron Corporation Image processing system, image processing program, and image processing method
EP3531344A1 (en) 2018-02-26 2019-08-28 OMRON Corporation Image processing system and setting method
US10863069B2 (en) 2018-02-26 2020-12-08 Omron Corporation Image processing system and setting method
EP3540647A1 (en) 2018-03-15 2019-09-18 OMRON Corporation Image processing system, image processing device and image processing program
US10896499B2 (en) 2018-03-15 2021-01-19 Omron Corporation Image processing system, image processing device and image processing program
CN108647554A (en) * 2018-05-15 2018-10-12 佛山市南海区广工大数控装备协同创新研究院 A kind of sport footwear air cushion stereoscopic two-dimensional code identification and detection device and method
WO2020241844A1 (en) * 2019-05-31 2020-12-03 興和株式会社 Image processing device and image processing program
US11812157B2 (en) 2019-05-31 2023-11-07 Kowa Company, Ltd. Image processing device and image processing program
WO2022019185A1 (en) * 2020-07-21 2022-01-27 富士フイルム富山化学株式会社 Engraved mark identification device, engraved mark identification method, and drug identification device
JP7429786B2 (en) 2020-07-21 2024-02-08 富士フイルム富山化学株式会社 Stamp identification device, stamp identification method, and drug identification device
JP7160428B1 (en) * 2021-05-21 2022-10-25 株式会社レイマック Non-contact blood vessel analysis method
CN114354607A (en) * 2021-10-09 2022-04-15 七海测量技术(深圳)有限公司 Luminosity three-dimensional flaw detection method based on spiral phase contrast filtering algorithm
CN114354607B (en) * 2021-10-09 2023-10-31 七海测量技术(深圳)有限公司 Luminosity three-dimensional flaw detection method based on spiral phase contrast filtering algorithm

Also Published As

Publication number Publication date
JP6395456B2 (en) 2018-09-26

Similar Documents

Publication Publication Date Title
JP6395456B2 (en) Image inspection apparatus, image inspection method, image inspection program, computer-readable recording medium, and recorded apparatus
JP6424020B2 (en) Image inspection apparatus, image inspection method, image inspection program, computer-readable recording medium, and recorded apparatus
JP6408259B2 (en) Image inspection apparatus, image inspection method, image inspection program, computer-readable recording medium, and recorded apparatus
JP6745173B2 (en) Image inspection apparatus, image inspection method, image inspection program, computer-readable recording medium, and recorded device
JP6650986B2 (en) Image inspection apparatus, image inspection method, image inspection program, computer-readable recording medium, and recorded device
JP6403446B2 (en) Image inspection apparatus, image inspection method, image inspection program, computer-readable recording medium, and recorded apparatus
KR101951576B1 (en) Inspection device and inspection method
JP6507653B2 (en) Inspection apparatus and control method of inspection apparatus
US20060018534A1 (en) Technique for detecting a defect of an object by area segmentation of a color image of the object
JP6308880B2 (en) Image inspection device
JP6568991B2 (en) Image inspection apparatus, image inspection method, image inspection program, computer-readable recording medium, and recorded apparatus
JP6045429B2 (en) Imaging apparatus, image processing apparatus, and image processing method
US10533952B2 (en) Method of inspecting a terminal of a component mounted on a substrate and substrate inspection apparatus
JP2011208941A (en) Flaw inspection device and flaw inspection method
JP2007033126A (en) Substrate inspection device, parameter adjusting method thereof and parameter adjusting device
CN116908185A (en) Method and device for detecting appearance defects of article, electronic equipment and storage medium
JP2018112478A (en) Image inspection device and image inspection method
JP6927294B2 (en) Measuring device, measuring method and measuring program
JP5934516B2 (en) Inspection area display device and inspection area display method
JP6739325B2 (en) Appearance image creation method and lookup table creation jig
JP2008292398A (en) Method of inspecting floating defect of component electrode and substrate inspecting device
WO2024070338A1 (en) Position measuring system, and illumination condition optimizing system
JP4419778B2 (en) Substrate inspection device, parameter setting method and parameter setting device
JP2006242584A (en) Irregularity defect detecting method and apparatus
JP2011232070A (en) Measuring method and inspection device for recess depth

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20170301

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20171213

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20180123

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20180307

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20180828

R150 Certificate of patent or registration of utility model

Ref document number: 6395456

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250