JPH04340177A - Detection of edge - Google Patents

Detection of edge

Info

Publication number
JPH04340177A
JPH04340177A JP3050019A JP5001991A JPH04340177A JP H04340177 A JPH04340177 A JP H04340177A JP 3050019 A JP3050019 A JP 3050019A JP 5001991 A JP5001991 A JP 5001991A JP H04340177 A JPH04340177 A JP H04340177A
Authority
JP
Japan
Prior art keywords
edge
straight line
threshold
binary image
threshold value
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
JP3050019A
Other languages
Japanese (ja)
Other versions
JPH0778832B2 (en
Inventor
Michio Otsuka
倫生 大塚
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.)
Panasonic Electric Works Co Ltd
Original Assignee
Matsushita Electric Works Ltd
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 Matsushita Electric Works Ltd filed Critical Matsushita Electric Works Ltd
Priority to JP3050019A priority Critical patent/JPH0778832B2/en
Publication of JPH04340177A publication Critical patent/JPH04340177A/en
Publication of JPH0778832B2 publication Critical patent/JPH0778832B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Landscapes

  • Image Input (AREA)
  • Image Analysis (AREA)

Abstract

PURPOSE:To set up a proper threshold for binarization by applying the comparatively small quantity of operation to a binarized image. CONSTITUTION:A straight line to be a candidate including edges for a binarized image between them is detected (step 101). A pair of windows holding the straight line are set up and the number of black picture elements included in each window is counted (step 102). Whether the straight line includes an edge or not is judged based upon the number of black picture elements in respective windows (steps 103, 104). At the time of judging no inclusion of an edge, a threshold for binarizing is changed (steps 106, 107). A new binarized image is formed based upon the changed threshold and the same processing is repeated for the newly formed binary image.

Description

【発明の詳細な説明】[Detailed description of the invention]

【0001】0001

【産業上の利用分野】本発明は、対象物と背景との濃度
差を利用し、所定の閾値を用いて2値化した2値画像に
基づいて対象物と背景との境界線であるエッジを検出す
るエッジ検出方法に関するものである。
[Industrial Application Field] The present invention utilizes the density difference between the object and the background to determine the edge of the boundary between the object and the background based on a binary image that is binarized using a predetermined threshold value. The present invention relates to an edge detection method for detecting.

【0002】0002

【従来の技術】従来より、対象物と背景との境界線であ
るエッジを検出するエッジ検出方法としては、濃淡画像
の各画素についての微分値を求め、求めた微分値に基づ
いて2値化を行う閾値を補正する方法が特開昭64−7
9882号公報に開示されている。
[Prior Art] Conventionally, as an edge detection method for detecting an edge that is a boundary line between an object and a background, a differential value for each pixel of a grayscale image is determined, and the differential value is binarized based on the determined differential value. A method for correcting the threshold value for performing
It is disclosed in Japanese Patent No. 9882.

【0003】この方法は、対象物と背景との濃度差が小
さいときには微分値の最大値が小さくなり、濃度差が大
きいときには微分値の最大値も大きくなるという知見に
基づいている。すなわち、微分値の最大値が大きくなる
ほど2値化のための閾値を高く設定することによって、
対象物と背景との識別が容易になるような適正な2値画
像を得るようにしているのである。
This method is based on the knowledge that when the density difference between the object and the background is small, the maximum value of the differential value is small, and when the density difference is large, the maximum value of the differential value is also large. In other words, by setting the threshold for binarization higher as the maximum value of the differential value becomes larger,
The aim is to obtain an appropriate binary image that makes it easy to distinguish between the object and the background.

【0004】0004

【発明が解決しようとする課題】上記方法では、対象物
と背景とのコントラストの大きさに応じて適正な閾値を
設定できるという利点がある。しかしながら、少なくと
もエッジを含む領域については、すべての画素について
微分値を求める必要があるから、各画素が多値である濃
淡画像に対して多量の演算を行う必要があり、演算量が
非常に多くなるという問題があった。
The above method has the advantage that an appropriate threshold value can be set depending on the contrast between the object and the background. However, at least for areas that include edges, it is necessary to find differential values for all pixels, so it is necessary to perform a large amount of calculations on grayscale images in which each pixel has multiple values, and the amount of calculations is extremely large. There was a problem.

【0005】本発明は上記問題点の解決を目的とするも
のであり、2値画像に対する比較的少ない量の演算で2
値化のための適正な閾値が設定できるようにしたエッジ
検出方法を提供しようとするものである。
[0005] The present invention aims to solve the above-mentioned problems, and is capable of processing binary images with a relatively small amount of calculations.
The present invention aims to provide an edge detection method that allows setting of an appropriate threshold value for value conversion.

【0006】[0006]

【課題を解決するための手段】本発明では、上記目的を
達成するために、2値画像に基づいて対象物と背景との
境界線であるエッジを検出するエッジ検出方法において
、エッジを含む候補になる直線を検出した後、この直線
を挟んで一対のウインドウを設定し、各ウインドウに含
まれる白画素または黒画素の画素数に基づいて上記直線
がエッジを含むかどうかを判定し、エッジを含まないと
判定した場合には2値化を行う閾値を変化させて2値画
像を再度作成し、新たに作成された2値画像に対して上
記処理を施すのである。
[Means for Solving the Problems] In order to achieve the above object, the present invention provides an edge detection method for detecting an edge that is a boundary line between an object and a background based on a binary image. After detecting a straight line, set a pair of windows across this straight line, determine whether the straight line includes an edge based on the number of white pixels or black pixels included in each window, and detect the edge. If it is determined that it is not included, the threshold value for binarization is changed to create a binary image again, and the above process is performed on the newly created binary image.

【0007】[0007]

【作用】上記方法によれば、2値画像においてエッジを
含む候補になる直線を検出した後、この直線の両側での
白画素または黒画素の分布を検出することによって、上
記直線がエッジを含むかどうかを判定しているのであっ
て、閾値が適正に設定されていて上記直線がエッジを含
む直線であれば、上記直線を挟んで白画素あるいは黒画
素の画素数に大きな差が生じることによって、上記直線
がエッジを含むかどうかが正確に判定できるのである。 また、エッジを含まないと判定された場合に、閾値を変
化させて2値画像を再度作成し、その後、上記処理を繰
り返すようにしているので、閾値が適正な値になるまで
閾値を変化させて適正な閾値に収束させることができる
のであり、2値画像に対する演算のみの比較的少ない演
算量で適正な閾値を求めることができることになる。
[Operation] According to the above method, after detecting a straight line that is a candidate for containing an edge in a binary image, by detecting the distribution of white pixels or black pixels on both sides of this straight line, the straight line includes an edge. If the threshold is set appropriately and the above straight line includes an edge, there will be a large difference in the number of white pixels or black pixels across the above straight line. , it is possible to accurately determine whether the straight line includes an edge. Additionally, if it is determined that no edges are included, the threshold value is changed and the binary image is created again, and the above process is then repeated, so the threshold value can be changed until the threshold value reaches an appropriate value. Therefore, it is possible to converge to an appropriate threshold value using a relatively small amount of calculation, which involves only calculations for binary images.

【0008】[0008]

【実施例】図2に示すように、対象物を含む画像は、C
CDカメラ等の画像入力装置1により撮像される。画像
入力装置1より出力されるアナログ信号である画像信号
は、A/D変換回路2を通してディジタル信号に変換さ
れた後、2値化処理部3において2値化されて2値画像
メモリ4に格納される。2値化処理部3における閾値は
閾値設定部5で設定される。
[Example] As shown in FIG. 2, an image containing an object is C
The image is captured by an image input device 1 such as a CD camera. The image signal, which is an analog signal output from the image input device 1, is converted into a digital signal through the A/D conversion circuit 2, and then binarized in the binarization processing section 3 and stored in the binary image memory 4. be done. The threshold value in the binarization processing section 3 is set by the threshold value setting section 5.

【0009】本発明では、2値画像メモリ4に格納され
た2値画像に基づいて、2値化処理部3における適正な
閾値を設定するのであって、図1に示すように、まず対
象物と背景との境界線であるエッジを含む候補になる直
線(以下、エッジ候補と略称する)を検出する(ステッ
プ100、101)。すなわち、エッジ検出部6では、
2値画像メモリ4に格納された2値画像について、図3
に示すように、エッジを検出すべき領域としてあらかじ
めマスクMを設定しておき、マスクMの中の画素Pにつ
いてエッジ候補を検出する。たとえば、垂直方向のエッ
ジ候補を検出するには、水平方向に順次探索を行うので
あって、まず、マスクMの中の左端の垂直方向のライン
L1 について上端から下向きに画素の値を順次判定す
る。ここに、白画素(白抜きの丸)の値を0、黒画素(
斜線付きの丸)の値を1とし、黒画素が3個以上連接し
ているラインL1 〜L5 が2本以上連接していると
きに(ここでは、ラインL3 、L4 が条件を満たす
)、連接しているラインL3 、L4の左端のラインL
3 をエッジ候補とする。水平方向のエッジ候補を検出
するには、垂直方向に順次探索を行えばよい。また、こ
こでは、対象物の内側が黒画素になると考えているが、
対象物の内側が白画素になる場合には、白画素の連接に
よってエッジ候補を検出すればよい。なお、マスクMの
大きさ、画素Pの連接個数、ラインL1 〜L5 の連
接個数などは実施例に限定されるものではない。
In the present invention, an appropriate threshold value in the binarization processing unit 3 is set based on the binary image stored in the binary image memory 4. As shown in FIG. A candidate straight line (hereinafter referred to as an edge candidate) including an edge that is a boundary line between the image and the background is detected (steps 100 and 101). That is, in the edge detection section 6,
Regarding the binary image stored in the binary image memory 4, FIG.
As shown in FIG. 3, a mask M is set in advance as a region in which edges are to be detected, and edge candidates are detected for pixels P in the mask M. For example, to detect edge candidates in the vertical direction, a search is performed sequentially in the horizontal direction, and first, the pixel values of the leftmost vertical line L1 in the mask M are sequentially determined from the top downward. . Here, set the value of the white pixel (white circle) to 0, and the value of the black pixel (
When two or more lines L1 to L5 in which three or more black pixels are connected are connected (in this case, lines L3 and L4 satisfy the condition), the value of The leftmost line L of the lines L3 and L4
3 is an edge candidate. To detect edge candidates in the horizontal direction, sequential searches may be performed in the vertical direction. Also, here we assume that the inside of the object becomes a black pixel, but
If the inside of the object is a white pixel, edge candidates may be detected by connecting white pixels. Note that the size of the mask M, the number of connected pixels P, the number of connected lines L1 to L5, etc. are not limited to those in the embodiment.

【0010】以上のようにしてエッジ候補Eを検出した
後、計数部7では、図4に示すように、マスクMの中に
エッジ候補Eを挟んで一対のウインドウW1、W2 を
設定する。両ウインドウW1 、W2 は同形状であっ
て同数の画素Pを含むように設定され、各ウインドウW
1、W2 の中の白画素または黒画素の数がそれぞれ計
数される(図1のステップ102)。たとえば、対象物
の内側が黒画素になる場合に、各ウインドウW1 、W
2 の中の黒画素の個数を計数すれば、エッジ候補Eに
対して対象物側の黒画素の数は背景側の黒画素の数より
も大幅に多くなるから、両ウインドウW1 、W2 の
中の黒画素の個数の差や比を求めれば、エッジ候補Eが
真のエッジであるかどうかの判定が行えることになる。
After detecting the edge candidate E as described above, the counting section 7 sets a pair of windows W1 and W2 in the mask M with the edge candidate E sandwiched therebetween, as shown in FIG. Both windows W1 and W2 are set to have the same shape and include the same number of pixels P.
1, the number of white pixels or black pixels in W2 is counted (step 102 in FIG. 1), respectively. For example, if the inside of the object is a black pixel, each window W1, W
2, the number of black pixels on the object side with respect to the edge candidate E will be significantly greater than the number of black pixels on the background side. By finding the difference or ratio of the number of black pixels in , it is possible to determine whether edge candidate E is a true edge.

【0011】すなわち、判定部8は、計数部7において
計数された各ウインドウW1 、W2 の中の黒画素ま
たは白画素の個数の差または比を所定の基準値と比較し
、基準値との大小関係に基づいてエッジ候補Eが真のエ
ッジであるかどうかの判定を行うのである。ここに、ウ
インドウW1 、W2 の中の各黒画素の個数をw1、
w2とし、2種類の基準値α、βを設定する。図1のス
テップ103、104に示すように、w2≧αであれば
光量は十分であるものと判断し、w2−w1≧βであれ
ば、コントラストも大きいから検出したエッジ候補Eは
真のエッジであると判定する(ステップ105)。一方
、w2<αであれば、光量が不足しているものと判断し
て2値化のための閾値を下げるように閾値設定部5を制
御することによって(ステップ106)、2値化処理部
3の閾値を変更し、撮像を再度行って上記処理を繰り返
す。また、w2≧αが成立しても、w2−w1<βであ
れば、光量が多すぎるものと判断して閾値を上げるよう
に閾値設定部5を制御し(ステップ107)、撮像を再
度行って上記処理を繰り返す。ここに、2値化処理部3
の閾値は所定幅で多段階に設定され、閾値の上下は1段
階ずつ行われる。
That is, the determining unit 8 compares the difference or ratio of the number of black pixels or white pixels in each window W1, W2 counted by the counting unit 7 with a predetermined reference value, and determines the difference or ratio between the numbers and the reference value. Based on the relationship, it is determined whether the edge candidate E is a true edge. Here, the number of black pixels in windows W1 and W2 is w1,
w2, and two types of reference values α and β are set. As shown in steps 103 and 104 in FIG. 1, if w2≧α, it is determined that the light amount is sufficient, and if w2−w1≧β, the contrast is also large, so the detected edge candidate E is a true edge. It is determined that (step 105). On the other hand, if w2<α, it is determined that the amount of light is insufficient, and the threshold setting unit 5 is controlled to lower the threshold for binarization (step 106). 3 is changed, imaging is performed again, and the above process is repeated. Furthermore, even if w2≧α holds true, if w2−w1<β, it is determined that the amount of light is too large, and the threshold value setting unit 5 is controlled to increase the threshold value (step 107), and imaging is performed again. and repeat the above process. Here, the binarization processing section 3
The threshold value is set in multiple steps with a predetermined width, and the threshold value is raised and lowered one step at a time.

【0012】なお、上記実施例では閾値を変更したとき
に、画像入力装置1による撮像を再度行っているが、撮
像した画像を濃淡画像メモリに格納しておき、閾値を変
更したときに、濃淡画像メモリに格納した濃淡画像に対
して2値化を施すようにしてもよい。また、2値化処理
部3、閾値設定部5、エッジ検出部6、計数部7、判定
部8はマイクロコンピュータを用いれば容易に実現でき
るものである。
[0012] In the above embodiment, when the threshold value is changed, the image input device 1 performs imaging again, but the captured image is stored in the grayscale image memory, and when the threshold value is changed, the grayscale image is Binarization may be applied to the grayscale image stored in the image memory. Furthermore, the binarization processing section 3, threshold value setting section 5, edge detection section 6, counting section 7, and determination section 8 can be easily realized using a microcomputer.

【0013】[0013]

【発明の効果】本発明は上述のように、2値画像におい
てエッジを含む候補になる直線を検出した後、この直線
の両側での白画素または黒画素の分布を検出することに
よって、上記直線がエッジを含むかどうかを判定してい
るのであって、閾値が適正に設定されていて上記直線が
エッジを含む直線であれば、上記直線を挟んで白画素あ
るいは黒画素の画素数に大きな差が生じることによって
、上記直線がエッジを含むかどうかが正確に判定できる
のである。また、エッジを含まないと判定された場合に
、閾値を変化させて2値画像を再度作成し、その後、上
記処理を繰り返すようにしているので、閾値が適正な値
になるまで閾値を変化させて適正な閾値に収束させるこ
とができるのであり、2値画像に対する演算のみの比較
的少ない演算量で適正な閾値を求めることができるとい
う利点を有するのである。すなわち、エッジの周辺の光
量を判定して、環境の変化によるコントラストの変動に
対する閾値の補正を行うことができるのであって、適正
な閾値で2値化された2値画像に基づいてエッジを正確
に検出できるのである。
Effects of the Invention As described above, the present invention detects a straight line that is a candidate including an edge in a binary image, and then detects the distribution of white pixels or black pixels on both sides of this straight line. is determining whether or not it includes an edge, and if the threshold is set appropriately and the above straight line includes an edge, there will be a large difference in the number of white pixels or black pixels across the above straight line. By this occurrence, it is possible to accurately determine whether the above-mentioned straight line includes an edge. Additionally, if it is determined that no edges are included, the threshold value is changed and the binary image is created again, and the above process is then repeated, so the threshold value can be changed until the threshold value reaches an appropriate value. This has the advantage that an appropriate threshold value can be determined with a relatively small amount of calculations that involve only calculations for binary images. In other words, the amount of light around the edge can be determined and the threshold can be corrected for changes in contrast due to changes in the environment. It can be detected.

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

【図1】実施例の動作説明図である。FIG. 1 is an explanatory diagram of the operation of the embodiment.

【図2】実施例のブロック図である。FIG. 2 is a block diagram of an embodiment.

【図3】実施例のエッジ検出部に関する動作説明図であ
る。
FIG. 3 is an explanatory diagram of the operation of the edge detection section of the embodiment.

【図4】実施例の計数部に関する動作説明図である。FIG. 4 is an explanatory diagram of the operation of the counting section of the embodiment.

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

1  画像入力装置 2  A/D変換回路 3  2値化処理部 4  2値画像メモリ 5  閾値設定部 6  エッジ検出部 7  計数部 8  判定部 1 Image input device 2 A/D conversion circuit 3 Binarization processing section 4 Binary image memory 5 Threshold setting section 6 Edge detection section 7 Counting section 8 Judgment section

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】  2値画像に基づいて対象物と背景との
境界線であるエッジを検出するエッジ検出方法において
、エッジを含む候補になる直線を検出した後、この直線
を挟んで一対のウインドウを設定し、各ウインドウに含
まれる白画素または黒画素の画素数に基づいて上記直線
がエッジを含むかどうかを判定し、エッジを含まないと
判定した場合には2値化を行う閾値を変化させて2値画
像を再度作成し、新たに作成された2値画像に対して上
記処理を施すことを特徴とするエッジ検出方法。
Claim 1: In an edge detection method that detects an edge that is a boundary line between an object and a background based on a binary image, after detecting a straight line that is a candidate including an edge, a pair of windows is formed with this straight line in between. is set, and it is determined whether the above straight line includes an edge based on the number of white pixels or black pixels included in each window. If it is determined that the straight line does not include an edge, the threshold for binarization is changed. An edge detection method characterized in that the binary image is re-created by the user, and the above-mentioned processing is performed on the newly created binary image.
JP3050019A 1991-03-15 1991-03-15 Edge detection method Expired - Lifetime JPH0778832B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP3050019A JPH0778832B2 (en) 1991-03-15 1991-03-15 Edge detection method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP3050019A JPH0778832B2 (en) 1991-03-15 1991-03-15 Edge detection method

Publications (2)

Publication Number Publication Date
JPH04340177A true JPH04340177A (en) 1992-11-26
JPH0778832B2 JPH0778832B2 (en) 1995-08-23

Family

ID=12847287

Family Applications (1)

Application Number Title Priority Date Filing Date
JP3050019A Expired - Lifetime JPH0778832B2 (en) 1991-03-15 1991-03-15 Edge detection method

Country Status (1)

Country Link
JP (1) JPH0778832B2 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113538600A (en) * 2020-04-15 2021-10-22 毫末智行科技有限公司 Method and apparatus for determining the baseline of a target, ranging method and apparatus

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS619769A (en) * 1984-06-25 1986-01-17 Matsushita Electric Works Ltd Picture image processor
JPS6346578A (en) * 1986-08-14 1988-02-27 Toshiba Seiki Kk Pattern recognizing method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS619769A (en) * 1984-06-25 1986-01-17 Matsushita Electric Works Ltd Picture image processor
JPS6346578A (en) * 1986-08-14 1988-02-27 Toshiba Seiki Kk Pattern recognizing method

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113538600A (en) * 2020-04-15 2021-10-22 毫末智行科技有限公司 Method and apparatus for determining the baseline of a target, ranging method and apparatus

Also Published As

Publication number Publication date
JPH0778832B2 (en) 1995-08-23

Similar Documents

Publication Publication Date Title
EP3309703B1 (en) Method and system for decoding qr code based on weighted average grey method
US20030123726A1 (en) Scene change detection apparatus
JP2005165387A (en) Screen streak defect detection method and apparatus, and display device
CN113569859A (en) Image processing method and device, electronic equipment and storage medium
US7773132B2 (en) Image processing device and method, and video camera with zebra pattern features
JPH04340177A (en) Detection of edge
JP2710527B2 (en) Inspection equipment for periodic patterns
JP2021190515A (en) Workpiece left-over determination system
JPH09288037A (en) Inspection method for lcd panel
JP3109237B2 (en) Line segment constituent pixel extraction method and line segment judgment method in image
JPS63155369A (en) Image processing method
JPH11316840A (en) Method and system for detecting road area
JP2647458B2 (en) Halftone dot area separation device
JPH0683960A (en) Method for extracting density border constituent pixel in image
JP3379591B2 (en) Binarization processing method and apparatus
JPH11250247A (en) Isolated area judging device
JP2841373B2 (en) Pattern inspection equipment
Li et al. An Improved FAST Corner Detection Algorithm for Real-Time Lane Lines Detection on Road Surface
JPS63131281A (en) Automatic number plate recognizer
CN116894815A (en) Detection methods and related equipment for product surface defects
CN117611554A (en) A shadow detection method based on the fusion of YUV color space and gradient features
JPH0476700A (en) Image processing type vehicle detector
JP3714647B2 (en) Image position detection method
JPH02254574A (en) Noise removing system
JP3436003B2 (en) Image processing device

Legal Events

Date Code Title Description
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 19960227