JPH1011589A - Picture processing method - Google Patents
Picture processing methodInfo
- Publication number
- JPH1011589A JPH1011589A JP8166162A JP16616296A JPH1011589A JP H1011589 A JPH1011589 A JP H1011589A JP 8166162 A JP8166162 A JP 8166162A JP 16616296 A JP16616296 A JP 16616296A JP H1011589 A JPH1011589 A JP H1011589A
- Authority
- JP
- Japan
- Prior art keywords
- pixel
- image
- pixels
- processing
- outline
- 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.)
- Pending
Links
Landscapes
- Image Analysis (AREA)
- Length Measuring Devices By Optical Means (AREA)
Abstract
Description
【0001】[0001]
【発明の属する技術分野】本発明は、物体の形状をコン
ピュータで認識するための画像処理方法に関するもので
ある。[0001] 1. Field of the Invention [0002] The present invention relates to an image processing method for recognizing a shape of an object by a computer.
【0002】[0002]
【従来の技術】従来、物体の画像よりその物体の外形を
形づくる線としての輪郭を抽出する際には、物体の画像
を明るさの度合ごとに多段階の値で表した多値画像にし
た後、この多値画像を微分して明るさの変化が大きい輪
郭部分のみ(輪郭を形成する部分)を強調し、これを任
意の明るさの閾値で二値化する画像処理をして輪郭のみ
を抽出していた。2. Description of the Related Art Conventionally, when extracting an outline as a line that forms the outline of an object from the image of the object, the image of the object is converted into a multi-valued image represented by multi-level values for each degree of brightness. Then, this multi-valued image is differentiated to emphasize only the outline portion (the portion forming the outline) where the change in brightness is large, and image processing is performed to binarize this with an arbitrary brightness threshold, and only the outline is processed. Was extracted.
【0003】[0003]
【発明が解決しようとする課題】しかしながら、微分処
理により強調された輪郭部分の値には幅があり、一定で
ないために、閾値の選択が難しく、そのため抽出した輪
郭部分の幅にばらつきが発生して正確な輪郭が抽出でき
ない問題がある。また、二値化した画像の輪郭部分の幅
が1画素分にならないため、物体の周囲長を算出する際
に、輪郭部分上のどの位置の画素から周囲長を算出する
かによって周囲長が変ってしまい、周囲長の算出方法が
難しく精度が悪くなるといった問題が発生していた。However, since the value of the contour portion emphasized by the differential processing has a width and is not constant, it is difficult to select a threshold value, and thus the width of the extracted contour portion varies. And accurate contours cannot be extracted. Also, since the width of the outline portion of the binarized image is not equal to one pixel, when calculating the circumference length of the object, the circumference length varies depending on which pixel on the outline portion calculates the circumference length. As a result, there has been a problem that the method of calculating the circumference is difficult and accuracy is deteriorated.
【0004】また、上記方法では輪郭の抽出及び物体の
周囲長の算出に複雑なハードウェア、ソフトウェアを必
要としていたため、処理速度が遅い、装置価格が高いと
いった問題があった。Further, in the above method, complicated hardware and software are required for extracting the contour and calculating the perimeter of the object, so that there is a problem that the processing speed is slow and the device price is high.
【0005】そこで本発明の目的は、単純な処理で正確
に図形(物体)の輪郭のみを抽出でき、また正確に物体
の周囲長を算出できる画像処理方法を提供することにあ
る。SUMMARY OF THE INVENTION It is an object of the present invention to provide an image processing method capable of accurately extracting only the contour of a figure (object) by simple processing and accurately calculating the perimeter of the object.
【0006】[0006]
【課題を解決するための手段】上記課題を解決するため
に請求項1の発明は、物体の画像よりその輪郭を抽出す
る画像処理方法において、任意の明るさで上記画像の各
画素を二値化し、その二値化した任意の画素の値と位置
とをPijとし、その画素Pijに隣接する上下左右4画素
の値と位置とをそれぞれPij-1、Pi-1j、Pi+1j、P
ij+1とし、上記画素Pijと隣接する上記各画素とをAccording to a first aspect of the present invention, there is provided an image processing method for extracting an outline of an object from an image of the object. The value and position of the binarized arbitrary pixel are defined as P ij, and the values and positions of the four pixels vertically, horizontally, and horizontally adjacent to the pixel P ij are defined as P ij−1 , P i−1j and P i, respectively. + 1j , P
ij + 1 , and the pixel P ij and each of the adjacent pixels are
【0007】[0007]
【数1】 (Equation 1)
【0008】で表したブール代数で処理し、この処理を
全画素について行って物体の輪郭を抽出するものであ
る。The processing is performed by the Boolean algebra represented by the above equation, and this processing is performed for all pixels to extract the contour of the object.
【0009】請求項2の発明は、物体の画像よりその輪
郭を抽出する画像処理方法において、任意の明るさで上
記画像の各画素を二値化し、その二値化した任意の画素
の値と位置とをPijとし、その画素Pijの近傍の上下左
右8画素の値と位置とをそれぞれPi-1j-1、Pij-1、P
i+1j-1、Pi-1j、Pi+1j、Pi-1j+1、Pij+1、Pi+1j +1
とし、上記画素Pijとその近傍の上記各画素とをAccording to a second aspect of the present invention, in the image processing method for extracting an outline from an image of an object, each pixel of the image is binarized at an arbitrary brightness, and a value of the binarized arbitrary pixel is determined. Let P ij be the position, and the values and positions of the eight pixels up, down, left, and right in the vicinity of the pixel P ij are P i-1j-1 , P ij-1 , P
i + 1j-1, P i -1j, P i + 1j, P i-1j + 1, P ij + 1, P i + 1j +1
And the pixel P ij and each of the pixels in the vicinity thereof are
【0010】[0010]
【数3】 (Equation 3)
【0011】で表したブール代数で処理し、この処理を
全画素について行って物体の輪郭を抽出するものであ
る。The processing is carried out by the Boolean algebra represented by the above formula, and this processing is performed for all the pixels to extract the contour of the object.
【0012】すなわち本発明の要点は、先ず、物体の明
るさと背景の明るさとの間に閾値を設定して物体の画像
を二値化し、得られた二値画像の輪郭を形成する画素の
値が“1”、それ以外の部分の画素の値が“0”になる
ように数1の論理演算式で上記二値画像を処理するのみ
で正確な物体の輪郭を抽出できるようにした画像処理方
法を発明した点にある。このように処理することで、輪
郭部分の幅が1画素分となる輪郭を抽出でき、また、そ
の輪郭を形成する画素の値の総和を計算することにより
図形(物体)の周囲長を求めることができる。That is, the gist of the present invention is that first, a threshold value is set between the brightness of an object and the brightness of the background, the image of the object is binarized, and the value of a pixel forming an outline of the obtained binary image is obtained. Is an image processing which can extract an accurate contour of an object only by processing the above binary image by the logical operation formula of Expression 1 so that the value of the pixel in the other part becomes "1" and the value of the pixel in the other part becomes "0". The point is that the method was invented. By performing such processing, it is possible to extract a contour in which the width of the contour portion is equal to one pixel, and to obtain the perimeter of a figure (object) by calculating the sum of the values of the pixels forming the contour. Can be.
【0013】[0013]
【発明の実施の形態】次に、本発明の画像処理方法を添
付図面を用いて説明する。Next, an image processing method according to the present invention will be described with reference to the accompanying drawings.
【0014】先ず、スキャナーやCCDカメラ等を用い
て物体の形状を認識すべく物体を画像に取り込む。この
画像を、物体と背景部分とを区別できる任意の明るさの
閾値で、例えば物体表面の明るさと背景部分の明るさと
の間の明るさの閾値を設定して二値化して二値画像を得
る。この二値画像を図4に示す。First, an object is captured in an image in order to recognize the shape of the object using a scanner, a CCD camera, or the like. This image is binarized by setting a threshold of brightness between the brightness of the object surface and the brightness of the background portion, for example, with an arbitrary brightness threshold that can distinguish the object and the background portion, thereby forming a binary image. obtain. This binary image is shown in FIG.
【0015】図4に示すように、二値画像30はm×n
個の画素から構成されており、任意の位置(i,j)
(1≦i≦n,1≦j≦m)の画素Pij10は濃度値P
(“1”または“0”)をもっている。As shown in FIG. 4, the binary image 30 is m × n
Pixels at any position (i, j)
The pixel P ij 10 of (1 ≦ i ≦ n, 1 ≦ j ≦ m) has the density value P
("1" or "0").
【0016】次にこの二値画像30を構成する画素を、
それぞれの画素がもつ値で示した図を図3に示す。Next, the pixels constituting the binary image 30 are
FIG. 3 shows the values represented by the values of each pixel.
【0017】図中、白抜き部分の画素は“0”で、斜線
部分の画素は“1”である。In the figure, the pixels in the white portions are "0", and the pixels in the hatched portions are "1".
【0018】図3の二値画像30に示すように、物体の
輪郭は“0”と“1”の境界にあり、“0”と接する
“1”を抽出すれば、その輪郭が求められる。As shown in the binary image 30 of FIG. 3, the contour of the object is at the boundary between "0" and "1". If "1" in contact with "0" is extracted, the contour is obtained.
【0019】次に、この二値画像30の輪郭を抽出する
処理を行う。Next, a process of extracting the contour of the binary image 30 is performed.
【0020】任意の位置(i,j)(1≦i≦n,1≦
j≦m)の画素Pij10を処理するに際しては、その画
素Pij10に隣接する上下左右4画素の値と位置とをそ
れぞれPij-1、Pi-1j、Pi+1j、Pij+1とし、Any position (i, j) (1 ≦ i ≦ n, 1 ≦
When processing the pixel P ij 10 of (j ≦ m), the values and positions of the four pixels above, below, left, and right adjacent to the pixel P ij 10 are respectively represented by P ij-1 , P i-1j , P i + 1j , P ij + 1 ,
【0021】[0021]
【数1】 (Equation 1)
【0022】で表したブール代数で処理する。このよう
に処理した二値画像を図2に示す。The processing is performed by the Boolean algebra represented by FIG. 2 shows the binary image thus processed.
【0023】図2に示すように、画素Pij10はP´ij
20、画素Pi-1j12はP´i-1j22、画素Pi-1j-11
4はP´i-1j-124に変換されている。As shown in FIG. 2, the pixel P ij 10 is P ′ ij
20, pixel P i-1j 12 is P ′ i-1j 22, pixel P i-1j-1 1
4 has been converted to P ' i-1j-1 24.
【0024】すなわち、上述した画素Pij10は
“1”、画素Pi-1j12も“1”、また背景を構成する
画素Pi-1j-114は“0”の値をもっているので、これ
らの値とその上下左右4画素の値とを上記数1のブール
代数に代入することにより、画素Pij10は“0”に、
画素Pi-1j12は“1“に、画素Pi-1j-114は“0”
にそれぞれ変換される。このように処理された二値画像
30を構成する画素を、それぞれの画素がもつ値で示し
た図を図1に示す。That is, the pixel P ij 10 has a value of “1”, the pixel P i-1j 12 has a value of “1”, and the pixel P i-1j-1 14 constituting the background has a value of “0”. By substituting these values and the values of the four pixels above, below, left and right into the Boolean algebra of Equation 1, the pixel P ij 10 becomes “0”,
The pixel Pi-1j- 12 is "1", and the pixel Pi-1j-1 14 is "0".
Respectively. FIG. 1 is a diagram showing the pixels constituting the binary image 30 processed in this way, with the values of the respective pixels.
【0025】図中、白抜き部分の画素は“0”で、斜線
部分の画素は“1”である。In the figure, the pixels in the white portions are "0", and the pixels in the hatched portions are "1".
【0026】図1に示すように、画素P´ij20は
“0”、画素P´i-1j22は“1”、また画素P´
i-1j-124は“0”の値に変換され、すなわち処理され
た二値画像40を構成する画素のうち物体の輪郭Mを形
成する画素のみが“1”に変換されるので、物体の輪郭
Mのみを抽出することができる。As shown in FIG. 1, the pixel P'ij 20 is "0", the pixel P'i-1j 22 is "1", also pixel P'
i-1j-1 24 is converted to a value of "0", that is, only the pixels forming the contour M of the object among the pixels constituting the processed binary image 40 are converted to "1". Can be extracted.
【0027】換言すれば、図形の輪郭Mを形成する画素
は、“1”の値をもち、かつその画素に隣接する画素の
いずれか一つ以上が“0”の値であることが条件であ
る。そこで、ブール代数In other words, a pixel forming the outline M of the figure has a value of “1”, and at least one of the pixels adjacent to the pixel has a value of “0”. is there. So Boolean algebra
【0028】[0028]
【数1】 (Equation 1)
【0029】において、In the above,
【0030】[0030]
【数2】 (Equation 2)
【0031】の部分の演算結果が“0”となる条件は、
要素Pij-1,Pi-1j,Pi+1j,Pij +1のいずれも“1”
の場合であり、演算結果が“1”となる条件は、要素P
ij -1,Pi-1j,Pi+1j,Pij+1のいずれか一つ以上が
“0”の場合である。よって、画素P´ij20が“1”
となる条件は、数2の部分の値が“1”で、かつ画素P
ij10の値が“1”となる場合である。これは上述した
輪郭Mを形成する画素となるための条件に合致し、この
条件を満たさない場合は値“0”となるので、物体の輪
郭Mのみを抽出することができるのである。The condition that the operation result of the part is "0" is as follows.
Each of the elements P ij-1 , P i-1j , P i + 1j , and P ij +1 is “1”
And the condition that the operation result is “1” is based on the element P
This is a case where at least one of ij −1 , P i−1j , P i + 1j , and P ij + 1 is “0”. Therefore, the pixel P ′ ij 20 is “1”
Is that the value of the portion of Equation 2 is “1” and the pixel P
This is the case when the value of ij10 is "1". This satisfies the above-described condition for forming a pixel forming the contour M, and when this condition is not satisfied, the value is “0”, so that only the contour M of the object can be extracted.
【0032】このようにして抽出した物体の輪郭Mは、
その幅が1画素分で形成されているので二値化後の輪郭
M部分の幅にばらつきが無く、正確である。また、その
輪郭M部分の幅が1画素分で形成されていることから、
輪郭Mを形成する画素の値の総和を求めることにより、
物体の周囲長を算出することができる。The contour M of the object thus extracted is
Since the width is formed by one pixel, the width of the outline M portion after binarization has no variation and is accurate. Also, since the width of the outline M is formed by one pixel,
By calculating the sum of the values of the pixels forming the contour M,
The perimeter of the object can be calculated.
【0033】以上説明したように、物体表面の明るさと
背景部分の明るさとの間の明るさの閾値を設定して物体
の画像を二値化し、得られた二値画像の輪郭Mを形成す
る画素の値が“1”、それ以外の部分の画素の値が
“0”になるように数1の論理演算式でその二値画像を
処理するだけで図形(物体)の輪郭Mのみを抽出でき、
また、その輪郭Mを形成する画素の値の総和を計算する
ことにより図形(物体)の正確な周囲長も求めることが
できる。As described above, the brightness threshold between the brightness of the object surface and the brightness of the background portion is set, the image of the object is binarized, and the contour M of the obtained binary image is formed. Only the outline M of the figure (object) is extracted by simply processing the binary image with the logical operation formula of Equation 1 so that the pixel value is “1” and the pixel values of the other parts are “0”. Can,
In addition, by calculating the sum of the values of the pixels forming the contour M, the exact perimeter of the figure (object) can be obtained.
【0034】また、取り込んだ画像を二値化した後、任
意の画素の値と位置とをPij、その画素の近傍の上下左
右8画素の値と位置とをそれぞれPi-1j-1、Pij-1、P
i+ 1j-1、Pi-1j、Pi+1j、Pi-1j+1、Pij+1、Pi+1j+1
として、その任意の画素Pijとその近傍の上下左右8画
素をAfter binarizing the captured image, the value and position of an arbitrary pixel are represented by P ij , and the values and positions of eight pixels in the vicinity of the pixel are represented by P i-1j-1 , respectively. P ij-1 , P
i + 1j-1, P i -1j, P i + 1j, P i-1j + 1, P ij + 1, P i + 1j + 1
And the arbitrary pixel P ij and the eight pixels up, down, left, and right in the vicinity thereof
【0035】[0035]
【数3】 (Equation 3)
【0036】と表したブール代数で処理し、この処理を
全画素について行うことにより、より正確に図形の輪郭
のみを抽出することができると共に、図形の周囲長を求
めることができる。By performing processing using a Boolean algebra expressed as follows and performing this processing for all pixels, it is possible to more accurately extract only the outline of the figure and obtain the perimeter of the figure.
【0037】[0037]
【発明の効果】以上要するに本発明によれば、物体の輪
郭のみを抽出する画像処理が単純な論理演算だけで行え
るため、複雑なソフトウェアによるコンピュータ処理が
不要となり、処理速度が速くなる。また、取り込んだ画
像を直接二値化したのち輪郭を抽出するため、抽出した
輪郭部分の幅は1画素分で形成されるので、輪郭を形成
する画素の値の総和から容易かつ正確に物体の周囲長を
求めることができる。In summary, according to the present invention, since image processing for extracting only the contour of an object can be performed only by a simple logical operation, computer processing by complicated software is not required, and the processing speed is increased. In addition, since the outline is extracted after directly binarizing the captured image, the width of the extracted outline portion is formed by one pixel, so that the object can be easily and accurately calculated from the sum of the values of the pixels forming the outline. The perimeter can be determined.
【0038】また、本発明は論理回路によるハードウェ
ア処理でも簡単に行えるため、高速処理が可能で、安価
な画像処理装置を作ることができる。Further, since the present invention can be easily performed even by hardware processing by a logic circuit, high-speed processing can be performed and an inexpensive image processing apparatus can be manufactured.
【図面の簡単な説明】[Brief description of the drawings]
【図1】本発明方法により処理された二値画像を示す図
である。FIG. 1 is a diagram showing a binary image processed by the method of the present invention.
【図2】本発明方法により処理された二値画像を示す図
である。FIG. 2 is a diagram showing a binary image processed by the method of the present invention.
【図3】一般的な二値画像を示す図である。FIG. 3 is a diagram illustrating a general binary image.
【図4】一般的な二値画像を示す図である。FIG. 4 is a diagram showing a general binary image.
M 輪郭 10 画素Pij 12 画素Pi-1j 14 画素Pi-1j-1 20 画素P´ij 22 画素P´i-1j 24 画素P´i-1j-1 30 二値画像 40 二値画像M contour 10 pixel P ij 12 pixel P i-1j 14 pixel P i-1j-1 20 pixel P ′ ij 22 pixel P ′ i-1j 24 pixel P ′ i-1j-1 30 binary image 40 binary image
Claims (2)
処理方法において、任意の明るさで上記画像の各画素を
二値化し、その二値化した任意の画素の値と位置とをP
ijとし、その画素Pijに隣接する上下左右4画素の値と
位置とをそれぞれPij-1、Pi-1j、Pi+1j、Pij+1と
し、上記画素Pijと隣接する上記各画素とを 【数1】 で表したブール代数で処理し、この処理を全画素につい
て行って物体の輪郭を抽出することを特徴とする画像処
理方法。In an image processing method for extracting an outline from an image of an object, each pixel of the image is binarized at an arbitrary brightness, and a value and a position of the binarized arbitrary pixel are represented by P
and ij, and the position and the value of vertical and horizontal 4 pixels adjacent to the pixel P ij P ij-1, P i-1j , respectively, P i + 1j, and P ij + 1, the adjacent to the pixel P ij Each pixel is expressed as An image processing method characterized by processing using a Boolean algebra represented by (1) and performing this processing on all pixels to extract the contour of the object.
処理方法において、任意の明るさで上記画像の各画素を
二値化し、その二値化した任意の画素の値と位置とをP
ijとし、その画素Pijの近傍の上下左右8画素の値と位
置とをそれぞれPi-1j-1、Pij-1、Pi+1j-1、Pi-1j、
Pi+1j、Pi-1j+1、Pij+1、Pi+1j +1とし、上記画素P
ijとその近傍の上記各画素とを 【数3】 で表したブール代数で処理し、この処理を全画素につい
て行って物体の輪郭を抽出することを特徴とする画像処
理方法。2. An image processing method for extracting an outline from an image of an object, wherein each pixel of the image is binarized at an arbitrary brightness, and a value and a position of the binarized arbitrary pixel are represented by P
ij, and the values and positions of eight pixels in the vicinity of the pixel P ij are represented by P i-1j-1 , P ij-1 , P i + 1j-1 , P i-1j , respectively.
P i + 1j , P i-1j + 1 , P ij + 1 , P i + 1j +1 and the pixel P
ij and each of the above pixels in the vicinity thereof are An image processing method characterized by processing using a Boolean algebra represented by (1) and performing this processing on all pixels to extract the contour of the object.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP8166162A JPH1011589A (en) | 1996-06-26 | 1996-06-26 | Picture processing method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP8166162A JPH1011589A (en) | 1996-06-26 | 1996-06-26 | Picture processing method |
Publications (1)
Publication Number | Publication Date |
---|---|
JPH1011589A true JPH1011589A (en) | 1998-01-16 |
Family
ID=15826231
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP8166162A Pending JPH1011589A (en) | 1996-06-26 | 1996-06-26 | Picture processing method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JPH1011589A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP6035375B1 (en) * | 2015-06-02 | 2016-11-30 | 株式会社メック | Defect inspection apparatus and defect inspection method |
-
1996
- 1996-06-26 JP JP8166162A patent/JPH1011589A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP6035375B1 (en) * | 2015-06-02 | 2016-11-30 | 株式会社メック | Defect inspection apparatus and defect inspection method |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107784669A (en) | A kind of method that hot spot extraction and its barycenter determine | |
CN117094975A (en) | Method and device for detecting surface defects of steel and electronic equipment | |
JP2000207489A (en) | Character extracting method and device and record medium | |
Kamada et al. | High-speed, high-accuracy binarization method for recognizing text in images of low spatial resolutions | |
JPH1125222A (en) | Method and device for segmenting character | |
CN115239595A (en) | Method for detecting qualification of two-dimensional code of packaging printed matter | |
KR100295360B1 (en) | Image Processing Method Using Shading Algorithm | |
JPH1011589A (en) | Picture processing method | |
JP2002133424A (en) | Detecting method of inclination angle and boundary of document | |
JP2800192B2 (en) | High-speed character / graphic separation device | |
JPH05342412A (en) | Extracting system for gradient vector and feature extracting system for character recognition | |
JPS62138986A (en) | Character recognizing device | |
JP2795860B2 (en) | Character recognition device | |
JP2956151B2 (en) | Image processing method and apparatus | |
JP2998443B2 (en) | Character recognition method and device therefor | |
JPH05225336A (en) | Method for extracting boundary and device therefor | |
JP2001043312A (en) | Document picture processor | |
JPH11351835A (en) | Method for extracting contour line of cutting edge by processing taken image of tool | |
CN115700824A (en) | Character segmentation method, electronic device and storage medium | |
JPH05225337A (en) | Method extracting boundary and device therefor | |
JP2959042B2 (en) | Image pattern extraction method | |
JPH02254574A (en) | Noise removing system | |
JP2771045B2 (en) | Document image segmentation method | |
JPH0337229B2 (en) | ||
CN112508980A (en) | Image edge extraction method and system based on 5-by-5 module uniform normalization template |