JPS6179375A - Binarization system - Google Patents

Binarization system

Info

Publication number
JPS6179375A
JPS6179375A JP59201313A JP20131384A JPS6179375A JP S6179375 A JPS6179375 A JP S6179375A JP 59201313 A JP59201313 A JP 59201313A JP 20131384 A JP20131384 A JP 20131384A JP S6179375 A JPS6179375 A JP S6179375A
Authority
JP
Japan
Prior art keywords
threshold value
black
value
pixels
threshold
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
Application number
JP59201313A
Other languages
Japanese (ja)
Inventor
Kunio Koshiro
小城 邦雄
Yasushi Kida
泰 木田
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.)
Sumitomo Electric Industries Ltd
Original Assignee
Sumitomo Electric Industries 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 Sumitomo Electric Industries Ltd filed Critical Sumitomo Electric Industries Ltd
Priority to JP59201313A priority Critical patent/JPS6179375A/en
Publication of JPS6179375A publication Critical patent/JPS6179375A/en
Pending legal-status Critical Current

Links

Landscapes

  • Facsimile Image Signal Circuits (AREA)
  • Image Input (AREA)

Abstract

PURPOSE:To apply binarization correctly to a picture of an optional object even with uneven lighting nby dividing the entire picture into rectangular partial regions and obtaining an optimum threshold value giving a ratio of black picture element number to white picture element number in coincidence with the ratio of black region to white region of a test pattern at each rectangualar partial region. CONSTITUTION:A binarization circuit reads the content of a memory 8 storing a threshold value Zkh at each partial region of the test pattern by using an address generating cirlcuit 7 to recognizes the Zkh. A comparison circuit 10 compares the Zkh with a value of all picture elements belonging to the partial region Qkh, outputs logical 1 when the value of picture element is larger than the threshold value and outputs 0 when smaller than the threshold value. An accumulation circuit 9 inputs a data 0 or 1 from the comparator circuit 10 and accumulates the value to a register Rkh corresponding to each partial region Qkh. Since the value of the picture element is compared with the threshold value Zkh at each partial region, the accumulation is executed at each register Rkh. It is possible to read the content of the register Rkh in the accumulation circuit 9 from an operating device.

Description

【発明の詳細な説明】 (ア)産業−11の利用分野 この発明は、2次元の21直画像を対象としたすべての
画像処理に共通して利用可能なものである。
DETAILED DESCRIPTION OF THE INVENTION (A) Field of Application in Industry-11 This invention can be commonly used in all image processing that targets two-dimensional 21-direction images.

たとえば、ロボットの視覚装置、画像を用いた計測装置
または険査装置、さらに、光学的文字読取装置、ファク
シミリなどの前処理に必甥な2値化方式に関する。
For example, the present invention relates to a binarization method that is necessary for pre-processing of robot visual devices, image-based measuring devices or inspection devices, optical character reading devices, facsimiles, and the like.

2値というのは、白と黒の2つの値ということであり、
0又は1で表わすこともある。2次元画素を画素に分割
し、画素の明暗の程度を、白又は黒のいずれかに対応さ
せる操作を2値化という。原画像の画素の色調は、白と
黒を両極として、灰色の連続的な明暗が連続するもので
ある。
Binary means two values, white and black.
It may also be expressed as 0 or 1. The operation of dividing a two-dimensional pixel into pixels and making the degree of brightness of each pixel correspond to either white or black is called binarization. The color tone of the pixels of the original image is a continuous light and shade of gray, with white and black as the extremes.

明暗の程度はアナログ量であるが、物体の認識、形状の
判定、文字の読取などの処理の場合、白又は黒の2値に
区別してから、画像処理を行うのが便利である。
Although the degree of brightness and darkness is an analog quantity, in the case of processing such as object recognition, shape determination, and character reading, it is convenient to perform image processing after distinguishing into binary values, white or black.

2値化するだめには、その画素の明暗の値を、ある予め
定められた閾値と比較し、閾1直より上か、下かによっ
て2値に分けるのである。
To perform binarization, the brightness value of the pixel is compared with a predetermined threshold value, and the pixel is divided into two values depending on whether it is above or below threshold 1.

閾値をどのように与えるのか?という事が最も重要にな
る。物体の輪郭、文字や記ちの線が最も鮮明に表われる
ために、どのように閾値を決定すればよいのか?これが
問題である。
How do we give the threshold? That is the most important thing. How should the threshold be determined so that the contours of objects, the lines of letters and inscriptions appear most clearly? This is the problem.

(イ)従来技術 従来の画像の2値化力式には、大別して2つの方式があ
る。
(a) Prior Art Conventional image binarization power formulas can be roughly divided into two types.

第1は閾値を固定しておくか、又は手1iilJによっ
て設定する方法である。固定閾値法と呼ぶ。
The first method is to fix the threshold value or to set it manually. This is called the fixed threshold method.

第2は閾値を自動的に決定するものである。自動閾値決
定法と呼ぶことにする。
The second method is to automatically determine the threshold value. This will be called the automatic threshold determination method.

自動閾値決定法にも、色々な方式がある。例えば、 (I)  画像の濃度ヒストグラムの谷部を閾値とする
方法。全画像又は部分画像について、画素ごとの濃度レ
ベルを決定し、濃度レベルに属する画素数をグラフに表
わしたヒストグラムを用いる。
There are various automatic threshold determination methods. For example, (I) a method in which the valleys of the density histogram of an image are used as thresholds; A density level for each pixel is determined for the entire image or a partial image, and a histogram is used that graphically represents the number of pixels belonging to each density level.

ヒストクラムの谷部というのは、そのレベルに属する画
素数が少いものをいう。
The valleys of the histogram are those where the number of pixels belonging to that level is small.

原画1象の性質により、ヒストグラムに谷部が存在する
とは限らず、谷部があっても、いずれかにかたよりすき
でいたりすると、正しく21値化できないという欠点が
ある。
Due to the nature of the original image, there are not necessarily valleys in the histogram, and even if there are valleys, if the valleys are off to one side or the other, there is a drawback that 21-value conversion cannot be performed correctly.

筒中のだめ谷点閾値という。This is called the trough point threshold in the cylinder.

(m 輝度レベルの最大と最小の中間の輝度レベルの値
を閾値とする方法。全画像又は部分画像について、輝度
レベルの最大、最小を求め、その半分のレベルを閾値と
する。
(m) A method in which the value of the brightness level between the maximum and minimum brightness levels is used as the threshold. The maximum and minimum brightness levels are determined for the entire image or a partial image, and half of the brightness level is used as the threshold.

これは、濃度分布を問題にしないから、閾値が必ずしも
輝度レベルの平均値ではない。
Since this does not concern the density distribution, the threshold value is not necessarily the average value of the luminance levels.

中間閾値と呼ぶことができる。It can be called an intermediate threshold.

圃 輝度レベルの変化が急峻な所を閾値とする方法。輪
郭線の近傍では、線に対し直角な方向に、輝度レベルが
急激に変化するtriずである。この変化を検知し、変
化の強く起る部分の輝度レベルを閾値とする。微分閾値
と簡単に呼ぶことができる。
Field A method where the threshold is set at a place where the brightness level changes sharply. In the vicinity of the contour line, the brightness level changes rapidly in the direction perpendicular to the line. This change is detected, and the brightness level of the portion where the change occurs strongly is set as a threshold. It can be simply called a differential threshold.

これら(I)〜亜のどの方式に於ても、画像全体で同一
の閾値を用いるものと、各部分領域で異なった閾値を用
いるものがある。
In any of these methods (I) to (sub), there are those that use the same threshold value for the entire image and those that use different threshold values for each partial area.

(つ)発明が解決しようとする問題点 従来の2値化方式には、次の難点がある。(1) Problems that the invention attempts to solve The conventional binarization method has the following drawbacks.

固定閾値法では、照度が変化する場合に、適切に対応て
きない。照明光の強度が強くなると、物体の輪郭々との
実際とは無関係に、より白い部分の面積が増えるし、照
明光が弱いと、白い部分の面積が減る。照明光の強度が
一定していれば良いがかならずしも、そのようにはなら
ない。
The fixed threshold method cannot adequately cope with changes in illuminance. When the intensity of the illumination light increases, the area of the white part increases, regardless of the actual outline of the object, and when the illumination light becomes weaker, the area of the white part decreases. It would be good if the intensity of the illumination light was constant, but this is not always the case.

自動閾値決定法は、照度変化があっても、これに拘わら
ず、黒白の2値に分けることができる。
The automatic threshold value determination method can divide the image into black and white, regardless of changes in illuminance.

しかし、これにしても、画像の輝度情報により、最適と
思われる閾値を推定l−でいるにすぎない。
However, even in this case, the threshold value considered to be optimal is merely estimated l- based on the brightness information of the image.

谷点閾値の場合、画像のパターンによって、谷点が必ず
しも存在し々いことがある。この場合、2値化てき々い
。捷だ谷点が2つ以上ある事もある。この場合、2値化
にはあい捷いさが残る。
In the case of a valley point threshold, valley points may not necessarily exist depending on the pattern of the image. In this case, binarization is difficult. Sometimes there are two or more points. In this case, binarization remains inconvenient.

中間閾値の場合、輝度レベルの最高と最低の中間値を閾
値とする。
In the case of an intermediate threshold value, the threshold value is an intermediate value between the highest and lowest brightness levels.

最高輝度の画素、又は最低輝度の画素が極端に少なかっ
たり多かったりする事がある。中間値は、平均値では々
い。このだめ、白と黒の境界に当る濃度レベルに中間値
が対のするとは限らない。
The number of pixels with the highest brightness or the number of pixels with the lowest brightness may be extremely small or large. The intermediate value is often the average value. Unfortunately, intermediate values do not necessarily correspond to density levels that fall on the boundary between white and black.

微分閾値は、妥当性の高い閾値の決定法であるが、谷点
閾値、中間閾値に於ける閾値のように一定レベルの閾値
にならない。微分が最大になるレベルの値は画像内の場
所によって異なり、ローカルに閾値を決定し々ければな
らない。しかも、微分が最大になるというのであるから
、画素の明暗を多くの段階によってレベル付けしなけれ
ばならない。
Although the differential threshold is a method of determining a threshold with high validity, the threshold does not reach a constant level like the trough threshold and the intermediate threshold. The value of the level at which the differential is maximum varies depending on the location within the image, and the threshold value must be determined locally. Furthermore, since the differential is maximized, the brightness and darkness of pixels must be leveled in many stages.

明暗の段階を分けるステップ数が少いと、微分値に多く
の誤差が含捷れるから、閾値自体の決定に多大の誤差が
伴うことになる。さらに、計算が複雑になる、という欠
点もある。
If the number of steps for dividing the bright and dark stages is small, the differential value will contain many errors, and the determination of the threshold value itself will involve a large amount of error. Another drawback is that the calculations are complicated.

さらに、谷点閾値、中間閾値の場合、画像全体で同一の
閾値を用いると、照明ムラがある場合に対応でき々いな
どの問題がある。
Furthermore, in the case of the valley point threshold and the intermediate threshold, if the same threshold is used for the entire image, there is a problem that it is difficult to deal with cases where there is illumination unevenness.

本発明は、照度の変化や照明ムラがあったとしても、正
しく画素の明暗の値を2値化できる2値化方式を与える
ことを目的とする。
An object of the present invention is to provide a binarization method that can correctly binarize the brightness and darkness values of pixels even if there are changes in illuminance or uneven illumination.

(1)問題点を解決するだめの手段 本発明は、」−記の問題点を解決するだめ、予め白黒の
面積の比が定寸っている部分領域を有するテストパター
ンを用いる。
(1) Means for Solving the Problems The present invention uses a test pattern having a partial area in which the ratio of black and white areas is predetermined in order to solve the problems listed in ``-''.

対象となる画像を撮像する前に、テストパターンを撮像
し、このテストパターンを適当々2つの輝度に関する閾
値を用いて2値化する。2値化した時の黒の部分の面積
、又は白の部分の面積は、テストパターンの黒又は白の
面積と異なる。そこで、閾値を変えて、同じテストパタ
ーンの像を2値化する。2値化したものの黒の部分の面
積が、テストパターンの黒の部分の面積にほぼ等しくな
る壕で閾値の変更を繰り返す。こうして、正しく、テス
トパターンを2値化できる閾値を捜し出す。
Before capturing a target image, a test pattern is captured, and this test pattern is binarized using two appropriate thresholds regarding brightness. The area of the black part or the area of the white part when binarized is different from the area of the black or white part of the test pattern. Therefore, the image of the same test pattern is binarized by changing the threshold value. The threshold value is changed repeatedly until the area of the black part of the binarized image becomes approximately equal to the area of the black part of the test pattern. In this way, a threshold value that can correctly binarize the test pattern is found.

このよう々閾値の変更は、複数の縦横の画素が成る程度
集まっている部分@域ごとになされる。
In this way, the threshold value is changed for each area where a plurality of vertical and horizontal pixels are gathered.

部分領域ごとに閾値が決定される。A threshold value is determined for each partial region.

最初の閾値は、適当なものでよい。閾値を変更すること
により、テストパターンを正しく2値化できる閾値を漸
近的に求めてゆくわけである。
The initial threshold may be any suitable value. By changing the threshold value, a threshold value that can correctly binarize the test pattern is asymptotically determined.

部分領域ことに閾値Zを求めてゆくが、これは、対象と
なる画(象とは無関係にテストパターンを使う事によっ
て求められる。実]祭の画像そのものを使って、谷点、
中間値、微分最大点などを閾値とするものとは全く異な
っている。対象画像と独立に閾値を決定するのであるか
ら、固定閾値法に近いものである。しかし々から、テス
トパターンを使用し、部分イ頁威ことに閾[直を決定し
ているから、テストパターンと対象画像を照らす照明が
等しければ、この閾値は、部分画像を常に正しく2値化
できるはずである。
We will calculate the threshold value Z for the partial region, which is obtained by using the test pattern regardless of the target image (the actual image).
This is completely different from those that use intermediate values, maximum differential points, etc. as thresholds. Since the threshold value is determined independently of the target image, this method is close to the fixed threshold method. However, since the test pattern is used and the partial image is determined by a threshold value, if the illumination illuminating the test pattern and the target image are equal, this threshold value will always correctly binarize the partial image. It should be possible.

実際には、画像全体を、m×l個の矩形部分領域に分割
する。第3図にこの分割を四示する。ひとつひとつの部
分領域Qは、多くの縦(黄に並んだ画素の集合である。
Actually, the entire image is divided into m×l rectangular partial regions. FIG. 3 shows four of these divisions. Each partial region Q is a collection of many pixels arranged vertically (in yellow).

そこで部分領域をに、hで符号つけする。全画像は、横
にm1縦に1個の部分領域を並べたものである。部分領
域をQkhという。
Therefore, the partial area is labeled with h. The entire image is made up of one partial area arranged horizontally by m1 and vertically. The partial area is called Qkh.

1(===l、 、m、h=l、 、l である。1 (===l, , m, h=l, , l.

部分領域ことに市しい閾1直Zkhが求められるべきで
ある。本発明ではテストパターンを正しく2値化する閾
値へ漸近的にZの値を近づけてゆく。
A threshold Zkh, which is particularly relevant for sub-areas, should be determined. In the present invention, the value of Z is asymptotically brought closer to the threshold value for correctly binarizing the test pattern.

もつとも収束の早い方法を選ぶのが望ましい。しかし、
Zを正しい値へ収束させる方法自体は任意のものでよい
It is desirable to choose a method that converges quickly. but,
Any method may be used to converge Z to the correct value.

簡単のため、部分領域のサフィックスに、hを除いて、
説明する。
For simplicity, omit h from the suffix of the partial area,
explain.

第3図に放て、斜線を付した部分が黒で、それ以外の部
分が白であるようなテストパターンを用いる。テストパ
ターンの全体は、画像の全体と一致しているとする。
A test pattern shown in FIG. 3 is used in which the shaded area is black and the other areas are white. It is assumed that the entire test pattern matches the entire image.

部分領域の繰り返しと、テストパターンの白黒の繰り返
しとは同じである、とする。
It is assumed that the repetition of the partial area and the repetition of black and white of the test pattern are the same.

つまり、部分領域Qには、同じ位置に、同じ大きさの黒
の部分、白の部分があるわけである。ここでは、黒が正
方形状で中心にあってその周縁に白の枠が形成されたテ
ストパターンを示すが、これは単なる例示である。同じ
パターンが部分領域ごとに繰り返すものであればよいの
であり、微細なパターンはどうであっても差支えない。
In other words, the partial area Q has a black part and a white part of the same size at the same position. Here, a test pattern is shown in which a black square is located at the center and a white frame is formed around the periphery, but this is merely an example. It is sufficient that the same pattern is repeated in each partial region, and any fine pattern is acceptable.

同じテストパターンの繰り返しであるが、照明光の強度
が、対象物の中心部と周縁部とで異なるから、同一の閾
値によって、全ての部分領域の像を正しく2値化できな
い。
Although the same test pattern is repeated, since the intensity of the illumination light differs between the center and the periphery of the object, it is not possible to correctly binarize the images of all partial regions using the same threshold value.

部分領域Qに含捷れる全画素の数をUとする。Let U be the total number of pixels included in the partial area Q.

全画素Uの内、2値化した時、黒になる画素の数をB1
白になる画素の数をWとする。
Among all pixels U, the number of pixels that become black when binarized is B1
Let W be the number of pixels that become white.

B + W二U(1) である。B + W2U (1) It is.

デス1−パターンの部分領域Qに対11缶する部分の内
、黒の部分がS/[Jであるとする。白の部分は(1−
5/U)  である。
It is assumed that among the 11 parts corresponding to the partial area Q of the Death 1 pattern, the black part is S/[J. The white part is (1-
5/U).

テストパターンを撮像し、これを適止な閾値Zfで2値
化すれば、黒の画素数は81白の画素数は(U−5)と
なるはずである。
If a test pattern is imaged and binarized using an appropriate threshold value Zf, the number of black pixels should be 81 and the number of white pixels should be (U-5).

しかし、実際には照明光の強度が一定していないので、
適正な閾値Zを予め定めることができない。
However, in reality, the intensity of the illumination light is not constant, so
An appropriate threshold value Z cannot be determined in advance.

黒の画素の数は、ある部分画像についていえば、閾値Z
の関数である。たたし、閾値Zは、明るくなる方が正の
方向であるとしている。つ寸り、輝度レベルでZの値を
決める。
For a certain partial image, the number of black pixels is equal to the threshold Z
is a function of However, it is assumed that the brighter the threshold value Z is, the more positive the threshold value Z becomes. The Z value is determined by the brightness level.

Zが低ければ、極めて黒さの強い部分だけが、黒の画素
ということになる。
If Z is low, only extremely black parts will be black pixels.

Zが高ければ、高輝度レベルで2値化が行われるから、
黒の画素になる部分が増える。
If Z is high, binarization is performed at a high brightness level, so
The number of black pixels increases.

従って、ある照明光で撮像したある部分画像を、ある閾
値Zによって2値化した画像の黒画素数BはZの単調増
加関数である、という事ができる。
Therefore, it can be said that the number B of black pixels of an image obtained by binarizing a certain partial image captured with a certain illumination light using a certain threshold value Z is a monotonically increasing function of Z.

テストパターンを部分画1象に対応させた時、Uの画素
の内、Sが黒画素になるわけである。8個の黒画素を発
生させるよう々閾竹を選ぶべき々のである。
When the test pattern corresponds to one partial image, S among the U pixels becomes a black pixel. The threshold should be selected so as to generate eight black pixels.

結局、閾値Zの関数としての黒画素&B(Z)が、B(
Z)=S         (2)となるよう々Zが適
正閾値Zfを与えるのである。
Eventually, the black pixel &B(Z) as a function of the threshold Z becomes B(
Z gives an appropriate threshold value Zf so that Z)=S (2).

Zの関数として、黒画素数Bが第3図のように示される
とする。この関数形は未知である。照明などにより異な
るからである。(2)式を満すZfを求めたい。
Assume that the number B of black pixels is shown as a function of Z as shown in FIG. This functional form is unknown. This is because it differs depending on lighting etc. We want to find Zf that satisfies equation (2).

さまざまな方法がありうる。例をのべる。There are many possible ways. Give an example.

(1)例えば、ある3つの予め定められた固定の閾値Z
l、Z2、Z3を考え、この閾値によって2値化された
テストパターンの部分領域中の黒画素数をB1、B2、
B3とする。
(1) For example, three predetermined fixed threshold values Z
l, Z2, and Z3, the number of black pixels in the partial area of the test pattern binarized using this threshold is B1, B2,
Let's call it B3.

B(Z)が二次関数であるとして近似すると、a、b、
cを未知定数として、 4つの方程式 %式%(3) が成立する。ここから、alb、cを消去するとZfが
得られる。これは行列式 の解として得られる。こうして得られた閾値Zfは、3
点Z1、Z2、Z3の値B4、B2、B8のみから、(
2)式を満足する閾値zfを求めるものとしては最も正
確なものである。第4図はこの方法を説明する図で、横
軸は閾値、縦軸は黒画素数である。
If B(Z) is approximated as a quadratic function, a, b,
With c as an unknown constant, the following four equations (3) hold true. From here, by eliminating alb and c, Zf is obtained. This is obtained as a solution to the determinant. The threshold value Zf obtained in this way is 3
From only the values B4, B2, and B8 of points Z1, Z2, and Z3, (
2) This is the most accurate method for determining the threshold value zf that satisfies the formula. FIG. 4 is a diagram explaining this method, where the horizontal axis is the threshold value and the vertical axis is the number of black pixels.

(2)同様に、4点での値が分ったとすると、(7)式
の行列式が、5行5列の式になり、(ZlB、Zよ′、
Zl、1、B1 )が5行々らふものとなる。ただしi
 = Q、・、4であって、Zo==ZfBo−8とみ
なすものとする。
(2) Similarly, if we know the values at 4 points, the determinant of equation (7) becomes an equation with 5 rows and 5 columns, and (ZlB, Z',
Zl, 1, B1) becomes 5 rows. However, i
= Q, ., 4, and it is assumed that Zo==ZfBo-8.

(3)  閾値Zと、これにより2値化された時の黒画
素数Bとの関係が既知である点の数が増えるに従って、
(2)式を満す適正閾値Zfを正確に求める事ができる
(3) As the number of points for which the relationship between the threshold Z and the number of black pixels B when binarized is known increases,
An appropriate threshold value Zf that satisfies equation (2) can be accurately determined.

一1ヒにn個の閾f+1i (zよ)に対する黒画素&
(B□)が分ったとすると、(n+1 )個の要素(z
in% ”’、z、、1、B、 )より々る( n +
1 )個の行ベクトル(i−0、−1n)を重ね合わせ
た行列式を作り、これが0になるものとして、Zfを求
めることができる。
Black pixels & for n thresholds f+1i (z)
(B□), then (n+1) elements (z
in% ”', z,, 1, B, ) more ( n +
1) A determinant is created by superimposing the row vectors (i-0, -1n), and Zf can be found by assuming that the determinant becomes 0.

以−LのZfの求め方は、いくつかの、BとZの関係を
知って、−挙にZfを求めるものである。
The way to find Zf of L is to know several relationships between B and Z and then find Zf all at once.

その他に漸近的にzfを求める方法もありうる。In addition, there may be a method of asymptotically determining zf.

(4)第5図にZとBの関係を示す。求めるものはB(
Z)=Sと々るZfである。簡単のだめB2曲線という
(4) Figure 5 shows the relationship between Z and B. What you are looking for is B (
Z)=S totoru Zf. It is called the simple B2 curve.

2点Zl、Z2に於ける黒画素& B l、B2を計数
する。Zl、Z2はZfより小さいものと、大きいもの
であるように選ぶ。
Count the black pixels &Bl, B2 at two points Zl, Z2. Zl and Z2 are selected to be smaller and larger than Zf.

ZlとB1を座標とする点をPl、Z2とB2を座標と
する点をB2とする。
Let the point whose coordinates are Zl and B1 be Pl, and the point whose coordinates are Z2 and B2 be B2.

直線P、 B2ばB2曲線の第1近似であるが、かなり
はずれている。B二SとなるPI B2上の点をR2と
する。R2に対応する閾値をZ3とする。
Straight line P, B2 is the first approximation of the B2 curve, but it is considerably off. Let R2 be the point on PI B2 that becomes B2S. Let Z3 be the threshold value corresponding to R2.

Z8に対して、黒画素数B8を求める。これがB2曲線
上の点P8を与える。
The number of black pixels B8 is determined for Z8. This gives point P8 on the B2 curve.

点P3から、直線P、 p2に平行な直線を引き、B=
Sと交わる点をR3とする。この点のZ座標を74とす
る。
From point P3, draw a straight line parallel to straight line P and p2, and B=
Let the point where it intersects with S be R3. Let the Z coordinate of this point be 74.

B2−B。B2-B.

である。(8)式の(spa)の係数は、直線P、 B
2の勾配であって単に と書くことができる。こうして、閾値Zに関する漸化式 %式%) を得る。こうして、Z、を遂次求めてゆき、極限として
、適正閾値Zfを知る。
It is. The coefficient of (spa) in equation (8) is the straight line P, B
It is the slope of 2 and can be simply written as. In this way, a recurrence formula regarding the threshold Z is obtained. In this way, Z is successively determined, and the appropriate threshold value Zf is found as the limit.

実際には無限にこの計算をする必要はない。In reality, it is not necessary to perform this calculation infinitely.

3〜6回程度で、よい近似1直か得られる。A good approximation can be obtained in about 3 to 6 times.

(5)漸化式によって、(Z、)を求めてゆく方法は計
算機による計算に適している。漸化式はOn)式に限ら
ない。直線の勾配をP、 B2に固定せず、P、 、 
P、の勾配とすることにしてもよい。この場合、 として、 Zj++ = Zj+ω3 (5−B5 )     
  (13)というような漸化式を用いる事かできる。
(5) The method of finding (Z,) using a recurrence formula is suitable for calculation by computer. The recurrence formula is not limited to the On) formula. Without fixing the slope of the straight line to P, B2, P, ,
It may be set as the gradient of P. In this case, as Zj++ = Zj+ω3 (5-B5)
A recurrence formula such as (13) can be used.

このように、(2)式の適正閾値は、(1)〜(5)で
述べたような方法で求められる。
In this way, the appropriate threshold value of equation (2) is obtained by the methods described in (1) to (5).

本発明の2値化方式は、 (イ)画像全体を(mX1個の矩形部分領域(Qkh)
に分割し、部分0「(域ことに異々る閾値(Z)で2値
化する回路と、 (ロ)各矩形部分領域内で、白または黒の部分の面積の
比が、一定で、しかも既知であるテストパターンを撮像
し、仮の閾値(Zj)によって2値化し、この2個画像
上で各矩形部分領域の白または黒の画素数を計数する回
路と、 (ハ) この計数値が、テストパターンの白または黒の
面積に相当する画素数と一致するように最適な間両を演
算する回路、 とよりなっている。
The binarization method of the present invention (a) converts the entire image into (m×1 rectangular partial area (Qkh)
(b) Within each rectangular partial area, the area ratio of the white or black part is constant, In addition, a circuit that images a known test pattern, binarizes it using a temporary threshold (Zj), and counts the number of white or black pixels in each rectangular partial area on these two images; is a circuit that calculates the optimum distance so that the number of pixels matches the number of pixels corresponding to the white or black area of the test pattern.

(オ)作 用 テストパターンは、黒白の比率が一定で、しかも比率が
既である同一の部分パターンが縦横に(mXlだけ繰り
返しているパターンである。
(e) Effect The test pattern is a pattern in which the ratio of black and white is constant and the same partial pattern with the same ratio is repeated vertically and horizontally (by mXl).

このテストパターンを撮像してできた画像を(mXn 
)の部分領域(Qkh )に分け、別異の閾値(Zkh
)によって2値化する。2値化した結果ある部分領域に
於ける全画素Uの内、黒画素がB1白画素がWであった
とする。
The image created by capturing this test pattern (mXn
) into subregions (Qkh ), and set different thresholds (Zkh
) to binarize. Assume that, as a result of binarization, among all the pixels U in a certain partial area, the black pixels are B1 and the white pixels are W.

テストパターンの点部分の面積比は、S/U、白部分の
面積比l#1(1−5/U)であるとする。
It is assumed that the area ratio of the point portion of the test pattern is S/U, and the area ratio of the white portion is l#1 (1-5/U).

閾値Zを決めれば、黒画素数B1自画素数Wが決まるか
ら、B、、WはZの関数ということになる。
If the threshold value Z is determined, the number of black pixels B1 and the number of self-pixels W are determined, so B, , W are functions of Z.

そこでZの値を変えて、黒画素数BがSに等しくなるよ
うにする。これによって最適な閾1直Zfを知る。Zf
の求め方は、行列式をといて、−挙にZfを求める方法
もあるし、漸近的に求める方法もある。
Therefore, the value of Z is changed so that the number B of black pixels becomes equal to S. From this, the optimal threshold 1st line Zf is known. Zf
There is a method to find Zf by solving the determinant, and there is also a method to find Zf asymptotically.

Zfが各部分領域ごとに決定される。これを部分領域に
対応する固定閾1直Zf(k、h)とするのである。
Zf is determined for each partial region. This is set as a fixed threshold Zf(k,h) corresponding to the partial area.

固定閾値Zf(klh)は照明状態の関数であるが、照
明状態を同一に保つ限り、Zf(klh)は適正閾値で
ある。この後、対象となる物体にも同じ照明を与えて、
撮像し、2値化する。2値化の閾値は予め求めた固定閾
値Zf(k、h)である。
The fixed threshold Zf(klh) is a function of the lighting conditions, but as long as the lighting conditions are kept the same, Zf(klh) is an appropriate threshold. After this, give the same illumination to the target object,
Capture and binarize. The binarization threshold is a fixed threshold Zf (k, h) determined in advance.

zf(k、h)はテストパターンの黒白を正しく復元で
きる閾値を与えている。しだがって、任意の対象を同じ
照E!11条件で撮像した場合、対象物の輪郭線や黒白
境界を正しく復元できるよう々2値化のための閾f直と
なる。
zf(k, h) provides a threshold value that allows correct restoration of the black and white of the test pattern. Therefore, any target can be illuminated with the same light E! When an image is captured under 11 conditions, the threshold f for binarization is set so that the outline of the object and the black-and-white boundary can be correctly restored.

(力)実施例 第1図は本発明の2値化方式の全体構成図である。(force) example FIG. 1 is an overall configuration diagram of the binarization method of the present invention.

1は被処理画像を撮像する装置である。これは、撮像さ
れた画像を走査1〜、ビデオ信号と1−て出力するもの
である。これは、アナログ量についての1吉号である。
1 is a device that captures an image to be processed. This scans the captured image and outputs it as a video signal. This is a good sign for analog quantities.

2は、撮像装置1の出力であるビテオ信りを1画素nピ
ッ)・にディジタル変換し、各種の制御信号とともに出
力する制御装置である。
Reference numeral 2 denotes a control device that digitally converts the video signal output from the imaging device 1 into one pixel (n pixels) and outputs it together with various control signals.

nビットに変換するのであるから、これは白から黒まで
の明暗変化を、2nのレベルに分割したものである。連
続する明暗変化つ寸り画素の輝度の連続変化を、2nの
非連続な階調に変換するのである。
Since it is converted into n bits, this is a result of dividing the brightness change from white to black into 2n levels. Continuous changes in brightness of pixels with continuous changes in brightness and darkness are converted into 2n discontinuous gradations.

3は、制御装置2から出力された2階調の画素の集合よ
りなる画像を(mxβ)個の矩形部分領域ごとに異なる
閾値で2値化し、白画素を1、黒画素を0で出力するも
のである。2値化回路3とよぶ。
3 binarizes an image consisting of a set of two-tone pixels output from the control device 2 using different threshold values for each (mxβ) rectangular partial area, and outputs white pixels as 1 and black pixels as 0. It is something. It is called a binarization circuit 3.

4は、(mX1個に分割された部分領域Qことに、2値
化の閾値レベルZを決定するだめの演算回路である。
4 is an arithmetic circuit for determining the threshold level Z for binarization in the partial area Q divided into m×1 pieces.

第2図は、2値化回路の構成側図である。FIG. 2 is a side view of the configuration of the binarization circuit.

5は、制御装置と演算回路と本回路のインターフェンス
回路である。
5 is an interface circuit between the control device, the arithmetic circuit, and the main circuit.

6ば、回路の各部を制御するだめに必要なタイミング信
り゛を発生するタイミング信号発生回路である。
6 is a timing signal generation circuit that generates timing signals necessary to control each part of the circuit.

7はアドレス発生回路である。8は(mxI!>ワード
の記憶容量を持つメモリである。
7 is an address generation circuit. 8 is a memory having a storage capacity of (mxI!>words).

9は(mX1個のレジスタを持つ累算回路である。9 is an accumulation circuit having (m×1 registers).

10は比較回路である。比較回路10は制御装置から出
力される各画素の輝度レベルと、8に予め記憶されてい
る各部分領域内の2値化のための閾値とを比較1〜、画
素の輝度レベルが閾値より大の時に1を、輝度レベルが
閾値より小の時にOを出力する。
10 is a comparison circuit. The comparison circuit 10 compares the brightness level of each pixel output from the control device with the threshold value for binarization in each partial area stored in advance in 8. It outputs 1 when the brightness level is smaller than the threshold value, and outputs O when the brightness level is smaller than the threshold value.

次に、最適の2値化閾値を、各部分領域ことに求める方
法を具体的に述べる。
Next, a method for determining the optimal binarization threshold for each partial region will be specifically described.

第3図はテストパターンの例を示す平面図である。全画
像を(mXn)の矩形部分@域に分割し、矩形部分@戚
ことに、あらかじめ定まつた位置、定まった寸法の黒領
域を有するテストパターンである。この例では、各矩形
領域の中心部に、正方形状の黒領域が存在するようにな
っているが、これに限らない。同一の寸法、位置にある
黒領域でさえあればよい。
FIG. 3 is a plan view showing an example of a test pattern. This is a test pattern in which the entire image is divided into (mXn) rectangular parts, and each rectangular part has a black area of a predetermined position and a predetermined size. In this example, a square black area exists at the center of each rectangular area, but the invention is not limited to this. It is sufficient as long as the black areas have the same size and position.

矩形部分領域の面積の内、黒領域の占める比をS/Uと
する。これは、全ての矩形部分領域に於て同一である。
The ratio of the black area to the area of the rectangular partial area is S/U. This is the same for all rectangular partial areas.

テストパターンを撮像する。矩形部分領域がU個の画素
に対応したとする。すると、撮像された矩形部分領域の
画素の輝度をある閾値Zで2値化し、黒画素として分類
されたものの数を計数し、これが8個てあったとすれば
、これは最適の閾値である、という事になる。
Image the test pattern. Assume that the rectangular partial area corresponds to U pixels. Then, the brightness of the pixels in the imaged rectangular partial area is binarized using a certain threshold value Z, and the number of pixels classified as black pixels is counted. If there are 8 pixels, this is the optimal threshold value. That's what it means.

輝度レベルをnビットに階調化したとする。ひとつのレ
ベル間隔が輝度の111位となるが、このレベル間隔を
1とする。輝度の最小端が0、最大値が2nとなるとす
る。
Assume that the brightness level is gradated to n bits. One level interval corresponds to the 111th brightness, and this level interval is assumed to be 1. Assume that the minimum brightness value is 0 and the maximum value is 2n.

適当々輝度レベルH,Lを考える。これは、輝。Consider the brightness levels H and L as appropriate. This is Hikaru.

度の最大、最小値に近い値てあって、最適の閾値は、I
]、■7レベルの間にあるような値とする。つ捷 リ゛
、 2>H>L>0       (+4)であって、Hl
Lを初期閉鎖として出発し、漸近的に最適閾値に近付い
てゆくようにする。
The optimal threshold value is close to the maximum and minimum values of the degree of I
], ■The value should be between 7 levels. The equation is 2>H>L>0 (+4), and Hl
We start with L as the initial closure and asymptotically approach the optimal threshold.

まず、演算装置4より、2値化回路内のメモリ8の各矩
形部分領域Qkhに相当するアドレス(kh)に、閾値
りを書込み、初期閾値を設定する。Lは、全ての部分領
域に対し共通の値であってよい。寸だ、部分領域によっ
て異々る値であっても良い。
First, the arithmetic unit 4 writes a threshold value to an address (kh) corresponding to each rectangular partial area Qkh of the memory 8 in the binarization circuit to set an initial threshold value. L may be a common value for all partial regions. However, it may be a different value depending on the partial area.

そして、テストパターンを撮像する。画像の輝度信号が
撮像装置1からビデオ信号として制御装置2へ送られる
。これは、画面を、左から右へと走査し、1段ずつ下へ
移ってゆくような順序で、全画素の輝度レベルを連続隈
として出力するものである。制御装置2では、これを画
素ごとの輝度レベルをA/D変換し 2内階調のティス
クリードな値とする。
Then, the test pattern is imaged. A brightness signal of an image is sent from the imaging device 1 to the control device 2 as a video signal. This scans the screen from left to right and outputs the luminance levels of all pixels as continuous shadows in an order that moves down one stage at a time. The control device 2 A/D converts the luminance level of each pixel to obtain a value that is a 2nd gray level.

2値化回路は、アドレス発生口1it!)7によって、
テストパターンの部分領域ごとに、閾値Zkhが格納さ
れているメモリ8の内容を読出し、Z□hを知る。比較
回路10は、Zkhと、部分領域Qkhに属する全ての
画素の値とZkhとを比較し、画素の値が閾値より大き
い場合に1を出力し、閾値より小さい場合に0を出力す
る。
The binarization circuit has 1 address generation point! )7,
For each partial area of the test pattern, the contents of the memory 8 in which the threshold value Zkh is stored are read out, and Z□h is determined. The comparison circuit 10 compares Zkh with the values of all pixels belonging to the partial region Qkh, and outputs 1 when the pixel value is larger than the threshold value, and outputs 0 when it is smaller than the threshold value.

累算回路9は、比較回路10からの0又は1のデータを
入力し、各部分領域Qkhに相当するレジスタRkhに
この値を累算してゆく。各部分領域ごとに画素の値の、
閾値Zkhとの比較が行われるから、レジスタRkhご
とに順次累算が実行される。
The accumulating circuit 9 inputs data of 0 or 1 from the comparator circuit 10 and accumulates this value in the register Rkh corresponding to each partial area Qkh. pixel value for each subregion,
Since the comparison with the threshold value Zkh is performed, accumulation is performed sequentially for each register Rkh.

累算回路9内のレジスタ(Rkh )の内容は、演算装
置4から読み出すことが可能である。
The contents of the register (Rkh) in the accumulation circuit 9 can be read from the arithmetic unit 4.

最初の閾値Zkhは、すでに述べたように、閾値しであ
る。つ寸りZkh−Lという条件で出発する。
The first threshold Zkh is, as already mentioned, the threshold value. I departed on the condition that it was a small Zkh-L.

レジスタRkhに累算した値は黒画素数又は白画素数に
対応している。して2値化した時のある部分領域に於け
る黒画素数をSLiとする。
The value accumulated in the register Rkh corresponds to the number of black pixels or the number of white pixels. Let SLi be the number of black pixels in a certain partial area when binarized.

同様に、メモリ8に閾値Hを書き込み、テストパターン
を撮像し、画素ごとに閾値Hと比較し、部分領域Qkh
に於ける黒画素数SHiを求める。
Similarly, the threshold value H is written in the memory 8, the test pattern is imaged, and the partial area Qkh is compared with the threshold value H for each pixel.
Find the number of black pixels SHi in .

こうして、部分領域ことに、閾値H,Lによって2値化
した時の黒画素数SHi、SLlが求捷る。
In this way, the black pixel numbers SHi and SLl when binarized using the thresholds H and L are determined for the partial region.

iは(kh )を表わすサフィックスである。i is a suffix representing (kh).

ここで、矩形部分領域のサフィックスi又は(kh)を
、簡嘔のため省いて表記することにする。
Here, the suffix i or (kh) of the rectangular partial area will be omitted for simplicity.

最適閾値への第1近似として T(1)二L+ω(S−5L)      (15)を
用いる。ただし、ωは黒画素数をひとつ増加させるため
に必要な閾値の増加分で によって定義される定数である。
We use T(1)2L+ω(S-5L) (15) as a first approximation to the optimal threshold. However, ω is a constant defined by the amount of increase in the threshold value required to increase the number of black pixels by one.

T(1)を閾値として、同じ部分領域Qに含捷れる画素
を2値化する。この時の黒画素数を5(1)とする。次
に、第2近似T(2)を次のように決める。
Using T(1) as a threshold, pixels included in the same partial region Q are binarized. The number of black pixels at this time is assumed to be 5 (1). Next, the second approximation T(2) is determined as follows.

T(2) −T(1)+ω(S−5(1))     
 (+7)以下同様に、k回目の閉鎖をT (k)、黒
画素数をS’(k)とした時、(k+1 )回目の閾値
T(k+1)をT (k+1 ) −T(k)十ω(S
−5(k))    (18)として、遂次、最適の閾
値に近似させてゆく。実際には、数回の反復計算により
、最適の閾値に収束する。
T(2) −T(1)+ω(S-5(1))
(+7) Similarly, when the k-th closure is T (k) and the number of black pixels is S' (k), the (k+1)-th threshold T (k+1) is T (k+1) - T (k) 10ω(S
−5(k)) (18), the optimal threshold value is successively approximated. In reality, the optimum threshold value is converged after several iterative calculations.

以−ヒに説明した方法は、(−1:)の(4)に述べた
方法と同じである。既に述べたように、この他にもZf
を求める方法はいくつか存在する。
The method described below is the same as the method described in (4) of (-1:). As already mentioned, in addition to this, Zf
There are several ways to find.

(キ)効 果 本発明は、全画像を矩形部分領域に分け、各矩形部分領
域に対応する黒領域、白領域の定まったパターンの繰り
返しからなるテストパターンを撮像し、各矩形部分領域
ごとに、テストパターンの黒領域と白領域の比に一致す
る黒画素数と白画素数の比を与える最適閾値を求めるよ
うにしている。
(G) Effect The present invention divides the entire image into rectangular partial areas, images a test pattern consisting of repeating a fixed pattern of black areas and white areas corresponding to each rectangular partial area, and , an optimal threshold value is determined that gives a ratio of the number of black pixels to the number of white pixels that matches the ratio of the black area to the white area of the test pattern.

各矩形部分領域ごとに異なる2値化閾値を求めるので、
照明ムラがあったとしても、任意の被対象物の画像を正
しく2硝化した2値化画1象を得ることができる。
Since a different binarization threshold is determined for each rectangular partial region,
Even if there is uneven illumination, it is possible to obtain a single binarized image in which the image of any object is correctly dinitrated.

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

第1図は2値化方式の全体の構成を示すブロック図。 第2図は2値化回路の構成図。 第3図はテストパターンを全画像に対応させた図。 第4図は閾値Z−黒画素数Bの3点のデータから最適(
mZfを求めるための説明図。 第5図は閾姶Z−黒画素数Bのデータから漸近的に最適
値Zfを求めるだめの説明図。 1  撮像装置 2  制御装置 3 2値化回路 4・・ 演算回路 5     インターフェイス回路 6  ・   タイミング発生回路 7    アドレス発生回路 8      メ   モ   リ 9  累算回路 10   比較回路 発  明  者     小  城  邦  雑木  
1)   泰
FIG. 1 is a block diagram showing the overall configuration of the binarization method. FIG. 2 is a block diagram of a binarization circuit. FIG. 3 is a diagram showing the test pattern corresponding to all images. Figure 4 shows the optimal (
An explanatory diagram for determining mZf. FIG. 5 is an explanatory diagram of how to asymptotically obtain the optimum value Zf from the data of threshold value Z-number of black pixels B. 1 Imaging device 2 Control device 3 Binarization circuit 4... Arithmetic circuit 5 Interface circuit 6 Timing generation circuit 7 Address generation circuit 8 Memory 9 Accumulation circuit 10 Comparison circuit Inventor Kuni Ogi Misaki
1) Yasushi

Claims (1)

【特許請求の範囲】[Claims] 2次元の被処理画像を撮像し、ビデオ信号に変換後、ア
ナログ・ディジタル変換し、各画素毎に輝度に応じたn
ビットのディジタル信号を得る第1の手段と、得られた
各画素nビットのディジタル画像をm×l個の矩形部分
領域毎に異なる閾値で、白画素と黒画素とに2値化する
第2の手段と、各部分領域内の白画素または黒画素の数
を計数する第3の手段と、第3の手段で得られた値をも
とに最適の2値化閾値を演算する第4の手段を有し、あ
らかじめ黒領域と白領域の比の定まつたパターンがm×
l個繰返すテストパターンを撮像し、部分領域ごとに閾
値を設定して、2値化し、白画素又は黒画素の数の比が
、テストパターンの白領域、黒領域の比に等しくなる閾
値を求める事を特徴とする2値化方式。
A two-dimensional image to be processed is captured, converted into a video signal, and then converted into an analog/digital signal.
A first means for obtaining a digital signal of bits, and a second means for binarizing the obtained n-bit digital image of each pixel into white pixels and black pixels using different threshold values for each m×l rectangular partial area. a third means for counting the number of white pixels or black pixels in each partial region; and a fourth means for calculating an optimal binarization threshold based on the value obtained by the third means. A pattern having a predetermined ratio of black areas and white areas is
Image a test pattern that is repeated l times, set a threshold value for each partial region, binarize it, and find a threshold value at which the ratio of the number of white pixels or black pixels is equal to the ratio of the white area and black area of the test pattern. A binarization method that is characterized by
JP59201313A 1984-09-26 1984-09-26 Binarization system Pending JPS6179375A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP59201313A JPS6179375A (en) 1984-09-26 1984-09-26 Binarization system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP59201313A JPS6179375A (en) 1984-09-26 1984-09-26 Binarization system

Publications (1)

Publication Number Publication Date
JPS6179375A true JPS6179375A (en) 1986-04-22

Family

ID=16438936

Family Applications (1)

Application Number Title Priority Date Filing Date
JP59201313A Pending JPS6179375A (en) 1984-09-26 1984-09-26 Binarization system

Country Status (1)

Country Link
JP (1) JPS6179375A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS63126081A (en) * 1986-11-14 1988-05-30 Nippon Steel Corp Detecting method for print
WO2004102481A1 (en) * 2003-05-15 2004-11-25 Fujitsu Limited Biological information measuring device

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS63126081A (en) * 1986-11-14 1988-05-30 Nippon Steel Corp Detecting method for print
WO2004102481A1 (en) * 2003-05-15 2004-11-25 Fujitsu Limited Biological information measuring device
US7965874B2 (en) 2003-05-15 2011-06-21 Fujitsu Limited Biological information detecting device

Similar Documents

Publication Publication Date Title
JP2686274B2 (en) Cell image processing method and apparatus
CN107784669A (en) A kind of method that hot spot extraction and its barycenter determine
US7333656B2 (en) Image processing method and image processing apparatus
CN111951322B (en) Image pickup module quality detection method, device and computer storage medium
JPS61141087A (en) Method and device for processing picture
JPS6179375A (en) Binarization system
JP3906221B2 (en) Image processing method and image processing apparatus
JP3071956B2 (en) Vickers hardness automatic reading device
US6597805B1 (en) Visual inspection method for electronic device, visual inspecting apparatus for electronic device, and record medium for recording program which causes computer to perform visual inspecting method for electronic device
JP2710527B2 (en) Inspection equipment for periodic patterns
JP3260425B2 (en) Pattern edge line estimation method and pattern inspection device
JPH08161508A (en) Pattern detecting method
JP4299908B2 (en) Object boundary determination method and apparatus
JP3234636B2 (en) Defect inspection equipment
JP2843388B2 (en) Wire bonding condition inspection device
JPH0723845B2 (en) Defect detection method
JPH0687264B2 (en) Image binarization method
JP2625429B2 (en) Image processing method
JPH05225336A (en) Method for extracting boundary and device therefor
JP2642185B2 (en) Angle detector
JP3109237B2 (en) Line segment constituent pixel extraction method and line segment judgment method in image
JPH118798A (en) Ccd camera system and image processing method
JPS63131272A (en) Decision method for binarization threshold
JP2859603B2 (en) Method and apparatus for binarizing image data
JPS6346579A (en) Image processor