JP4741289B2 - Image processing apparatus and image processing method - Google Patents

Image processing apparatus and image processing method Download PDF

Info

Publication number
JP4741289B2
JP4741289B2 JP2005152806A JP2005152806A JP4741289B2 JP 4741289 B2 JP4741289 B2 JP 4741289B2 JP 2005152806 A JP2005152806 A JP 2005152806A JP 2005152806 A JP2005152806 A JP 2005152806A JP 4741289 B2 JP4741289 B2 JP 4741289B2
Authority
JP
Japan
Prior art keywords
density
density value
pixels
histogram
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.)
Expired - Fee Related
Application number
JP2005152806A
Other languages
Japanese (ja)
Other versions
JP2006331018A (en
Inventor
宗利 今田
康成 ▲吉▼冨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sharp Corp
Original Assignee
Sharp 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 Sharp Corp filed Critical Sharp Corp
Priority to JP2005152806A priority Critical patent/JP4741289B2/en
Publication of JP2006331018A publication Critical patent/JP2006331018A/en
Application granted granted Critical
Publication of JP4741289B2 publication Critical patent/JP4741289B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

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

Description

本発明は、濃淡画像を2値化する画像処理装置および画像処理方法に関する。   The present invention relates to an image processing apparatus and an image processing method for binarizing a grayscale image.

食品容器、包装紙などの印刷物および電子部品などの工業製品を対象とする非接触の計測、検査を行う場合、CCD(Charge Coupled Device)カメラなどを利用して対象ワークを撮像し、撮像した画像データに画像処理を施すことで実現している。   When performing non-contact measurement and inspection for printed products such as food containers and wrapping paper, and industrial products such as electronic parts, the target workpiece is imaged using a CCD (Charge Coupled Device) camera, etc. This is achieved by applying image processing to the data.

計測、検査などを行うためには、撮像した画像データを対象ワークの領域と背景領域とに分離する必要がある。撮像した画像データは多階調の濃淡画像データであるので、これを2値化処理することで対象ワークの領域と背景領域とに分離することができる。   In order to perform measurement, inspection, and the like, it is necessary to separate captured image data into a target work area and a background area. Since the captured image data is multi-gradation grayscale image data, it can be separated into a target work area and a background area by binarizing this data.

対象ワークと背景との分離精度は、2値化処理を実行する際の閾値に大きく影響を受ける。閾値を決定する技術としては、オペレータが閾値となる値を入力し、その値を用いたときの2値化処理後の画像を確認しながら適切な閾値を試行錯誤で決定する技術があるが、決定するまでに膨大な時間を必要とし、決定するための基準がオペレータによって変動するなどの問題がある。   The separation accuracy between the target work and the background is greatly affected by the threshold value when the binarization process is executed. As a technique for determining the threshold, there is a technique in which an operator inputs a value to be a threshold and determines an appropriate threshold by trial and error while confirming an image after binarization processing when the value is used. There is a problem that a huge amount of time is required to make a decision, and the criteria for making the decision vary depending on the operator.

このような問題を解決するために、画像データに基づいて2値化処理の閾値を自動で決定する技術が開発されている。
閾値の自動決定には、たとえば以下に示す2つの方法(アルゴリズム)が用いられる。
In order to solve such a problem, a technique for automatically determining a threshold value for binarization processing based on image data has been developed.
For example, the following two methods (algorithms) shown below are used for automatic determination of the threshold value.

・判別分析法(非特許文献1参照)
画像データの濃度値ヒストグラムを閾値kで2つのクラス(k以上とk未満)に分割したとき、2つのクラスが最もよく分離するように閾値kを決める方法が、判別分析方法である。
Discriminant analysis method (see Non-Patent Document 1)
When the density value histogram of image data is divided into two classes (k or more and less than k) by the threshold value k, a method for determining the threshold value k so that the two classes are most separated is a discriminant analysis method.

たとえば、濃度が256階調の場合、閾値kを濃度範囲0〜254まで変化させ、濃度0〜kまでの集合C0と濃度k+1〜255までの集合C1との間のクラス間分散値が最大となるkを求める。
クラス間分散値S2 = w0w1(u1-u0)2 …(1)
u0:C0のポイント数の平均、u1:C1のポイント数の平均
w0:C0の発生する確率、w1:C1の発生する確率
For example, when the density is 256 gradations, the threshold value k is changed from the density range 0 to 254, and the interclass variance value between the set C0 from the density 0 to k and the set C1 from the density k + 1 to 255 is the maximum. K is obtained.
Interclass variance S 2 = w0w1 (u1-u0) 2 (1)
u0: Average number of C0 points, u1: Average number of C1 points
w0: Probability of C0, w1: Probability of C1

・多段平滑ヒストグラムモデルに基づく方法(特許文献1参照)
画像データの累積画素数のヒストグラムを作成し、累積画素数が変曲部で分かれる2つの領域の濃度境界を2値化の閾値として決定する方法である。この方法では、2つの領域において、それぞれ近似直線または近似曲線を求め、その交点を閾値とする。具体的な手順を、図8のフローチャートに示す。
A method based on a multistage smooth histogram model (see Patent Document 1)
In this method, a histogram of the cumulative number of pixels of image data is created, and the density boundary between two regions where the cumulative number of pixels is separated at the inflection part is determined as a binarization threshold. In this method, an approximate straight line or an approximate curve is obtained in each of the two areas, and the intersection is used as a threshold value. A specific procedure is shown in the flowchart of FIG.

(1)濃度ヒストグラム作成(ステップS11)
各濃度値の画素数を計数してヒストグラムを作成する。
(1) Creation of density histogram (step S11)
A histogram is created by counting the number of pixels of each density value.

(2)バックグランド削除処理(ステップS12)
最大濃度の1/3から2/3までの濃度領域における最低画素数を求め、その最低画素数を濃度ヒストグラム全領域のバックグラウンドとみなして、各濃度値の画素数からその画素数を引く。引いた画素数が負の場合は、“0”に置き換える。
(2) Background deletion processing (step S12)
The minimum number of pixels in the density region from 1/3 to 2/3 of the maximum density is obtained, the minimum number of pixels is regarded as the background of the entire density histogram, and the number of pixels is subtracted from the number of pixels of each density value. When the number of subtracted pixels is negative, it is replaced with “0”.

(3)累積画素数ヒストグラム作成(ステップS13)
(2)においてバックグランドを削除した濃度ヒストグラムにおいて、最大濃度値255から各濃度値の画素数を順次累積した累積画素数ヒストグラムを作成する。
(3) Cumulative pixel count histogram creation (step S13)
In the density histogram from which the background is deleted in (2), an accumulated pixel number histogram is created by sequentially accumulating the number of pixels of each density value from the maximum density value 255.

(4)2値化閾値の自動決定(ステップS14)
誤差関数を近似式(近似直線または近似曲線)として、誤差が最小となる近似式の交点を求め、この交点の濃度値を閾値とする。
(4) Automatic determination of binarization threshold (step S14)
Using the error function as an approximate expression (approximate straight line or approximate curve), the intersection of the approximate expression that minimizes the error is obtained, and the density value at this intersection is used as a threshold value.

田村秀行編著、「コンピュータ画像処理」、第1版、オーム社、平成14年12月20日、p.140Edited by Hideyuki Tamura, “Computer Image Processing”, 1st Edition, Ohmsha, December 20, 2002, p. 140 特開2004−180000号公報JP 2004-180000 A

「判別分析法」では、濃度ヒストグラムにおいて、「大きな山が2つあり、2つの山の間に谷がある濃度分布」、すなわち「クラスが2つある濃度分布」であることを前提としており、それ以外の分布であっても閾値を算出できるものの安定性が小さくなる。たとえば、画像内に真っ白な部分(低濃度)と灰色の部分(中濃度)と真っ黒な部分(高濃度)があった場合、分布として「3つの山と2つの谷」ができ、判別分析法では、灰色の中濃度の部分を白とするか黒とするかの問題が残る。   The “discriminant analysis method” is based on the assumption that the density histogram is “a density distribution with two large peaks and a valley between the two peaks”, that is, a “density distribution with two classes”. Even with other distributions, although the threshold value can be calculated, the stability is reduced. For example, if there are a white part (low density), a gray part (medium density), and a black part (high density) in the image, “three peaks and two valleys” are created as a distribution, and the discriminant analysis method Then, there remains a problem of whether the gray medium density portion is white or black.

また、「多段平滑ヒストグラムモデルに基づく方法」では、次のような点で汎用性に欠けるという課題が残る。   In addition, the “method based on a multistage smooth histogram model” still has a problem that it lacks versatility in the following points.

1)バックグランド削除処理による影響
図4(a)に示すような濃度ヒストグラムが得られた場合、最大濃度の1/3から2/3までの濃度領域に低濃度側1/3の領域に存在する山の度数および高濃度側1/3の領域に存在する山の度数よりも遥かに大きな度数の山が存在することになる。このとき、低濃度側1/3の領域に存在する小さな山および高濃度側1/3の領域に存在する小さな山が、バックグランド削除処理で消えることになり、その後に求めた閾値では正しく2値化できない結果となる(図4(b)参照)。
1) Influence of background deletion processing When a density histogram as shown in FIG. 4A is obtained, it exists in the low density side 1/3 of the density range from 1/3 to 2/3 of the maximum density. Therefore, there is a mountain having a frequency much larger than the frequency of the mountain and the frequency of the mountain existing in the 1/3 region of the high concentration side. At this time, a small mountain existing in the low-concentration side 1/3 region and a small mountain existing in the high-concentration side 1/3 region disappear by the background deletion process, and the threshold obtained thereafter is correctly 2. The result cannot be converted into a value (see FIG. 4B).

2)過飽和状態の場合の課題
濃度値が、最大濃度値の“255”である画素数が他の濃度値の画素数に比べて遥かに大きい、いわゆる「過飽和状態」の場合、同じ濃度領域内を分割してしまうような濃度値を閾値と決定するため、一見容易に2値化できそうな画像データにもかかわらず、適切な2値画像が得られない場合がある(図5(b)参照)。これは、累積画素数ヒストグラムから閾値を求める方法では、「過飽和状態」となる最大濃度値の画素数の影響に対する対策が十分ではない。
2) Problems in the case of the supersaturated state In the case of the so-called “supersaturated state” where the number of pixels whose density value is “255” of the maximum density value is much larger than the number of pixels of other density values, In this case, an appropriate binary image may not be obtained in spite of image data that can be easily binarized at first glance (FIG. 5B). reference). This is because the method for obtaining the threshold value from the cumulative pixel number histogram does not provide sufficient countermeasures against the influence of the pixel number of the maximum density value that is in the “supersaturated state”.

3)誤差関数が直線近似の場合の課題
直線近似する誤差関数において、たとえば、縦軸方向の最小誤差を求める方法として最小二乗法を用いた場合は、勾配が大きいと過敏に作用する傾向があり、勾配が小さい場合は傾きに対する反応が鈍く、閾値となる濃度値が勾配に応じて大きく変動する傾向があるため、閾値の決定が不安定になる(図7(b)参照)。
3) Problems when the error function is linear approximation In the error function for linear approximation, for example, when the least square method is used as a method for obtaining the minimum error in the vertical axis direction, if the gradient is large, it tends to act sensitively. When the gradient is small, the response to the gradient is dull, and the concentration value serving as the threshold tends to fluctuate greatly depending on the gradient, so the determination of the threshold becomes unstable (see FIG. 7B).

4)近似式の交点による影響
累積画素数ヒストグラムの領域を二分割する濃度値を設定し、各領域における誤差の和が最小となる近似式を求めている。この場合、近似式の交点となる濃度値を閾値とするため、適切な2値化画像が得られない場合がある。
4) Influence of intersection of approximate expression The density value for dividing the area of the cumulative pixel count histogram into two is set, and an approximate expression that minimizes the sum of errors in each area is obtained. In this case, an appropriate binarized image may not be obtained because the density value that is the intersection of the approximate expressions is used as a threshold value.

本発明の目的は、より安定した適切な2値化閾値を決定することができ、適切な2値化画像データを得ることができる画像処理装置および画像処理方法を提供することである。   An object of the present invention is to provide an image processing apparatus and an image processing method capable of determining a more stable appropriate binarization threshold and obtaining appropriate binarized image data.

本発明は、入力された濃淡画像データを基に、各濃度値に対する画素数のヒストグラムである濃度ヒストグラムを作成する濃度ヒストグラム作成手段と、
前記濃度ヒストグラムの分布に基づいて、クラス間分散が最も大きくなる濃度値を境界濃度値とし、この境界濃度値より低濃度側で最大画素数となる濃度値と、この境界濃度値より高濃度側で最大画素数となる濃度値とを抽出し、前記低濃度側で最大画素数となる濃度値と前記境界濃度値との平均値を下限濃度値とし、前記境界濃度値と前記高濃度側で最大画素数となる濃度値との平均値を上限濃度値とし、前記上限濃度値から前記下限濃度値までの各濃度値に対する画素数の平均値を小画素数として算出し、前記濃度ヒストグラムの各濃度値に対する画素数からこの小画素数を減算することで画素数を変化させる前処理手段と、
前記前処理手段によって画素数が変化した濃度ヒストグラムに基づいて、各濃度値の画素数を最高濃度値または最低濃度値から順に累積したヒストグラムである累積画素数ヒストグラムを作成する累積画素数ヒストグラム作成手段と、
前記累積画素数ヒストグラムを、濃度値によって2つの領域に分割し、分割した領域ごとに累積画素数ヒストグラムに対してモーメント法を適用したときの近似直線における関数誤差を算出し、この算出した誤差の和が最小となるような濃度値を、前記濃淡画像データを2値化するための閾値とする閾値決定手段とを備えたことを特徴とする画像処理装置である。
The present invention comprises a density histogram creating means for creating a density histogram that is a histogram of the number of pixels for each density value based on the input grayscale image data;
Based on the distribution of the density histogram, the density value at which the inter-class variance is the largest is the boundary density value, the density value that is the maximum number of pixels on the lower density side than the boundary density value, and the higher density side than the boundary density value To extract the density value that becomes the maximum number of pixels, and use the average value of the density value that becomes the maximum number of pixels on the low density side and the boundary density value as the lower limit density value, and the boundary density value and the high density side An average value with the density value that is the maximum number of pixels is set as an upper limit density value, an average value of the number of pixels for each density value from the upper limit density value to the lower limit density value is calculated as a small pixel number, and each density histogram Preprocessing means for changing the number of pixels by subtracting the number of small pixels from the number of pixels for the density value ;
Based on the density histogram in which the number of pixels has been changed by the preprocessing means, a cumulative pixel number histogram creating means for creating a cumulative pixel number histogram that is a histogram in which the number of pixels of each density value is accumulated in order from the highest density value or the lowest density value. When,
The cumulative number of pixels histogram, the density value is divided into two regions, it calculates a function error in the approximation straight line when applying the method of moments and against the cumulative number of pixels histogram for each was divided region, and the calculated An image processing apparatus comprising: a threshold value determination unit that sets a density value that minimizes a sum of errors as a threshold value for binarizing the grayscale image data.

また本発明は、前記前処理手段は、最大濃度値に対する画素数が、最大濃度値近傍の濃度値に対する画素数よりも所定の割合以上に多いかどうかを判断し、多い場合は、前記最大濃度値に対する画素数の一部を他の濃度値に対する画素数に分配させることで画素数を変化させることを特徴とする。   In the present invention, the preprocessing unit determines whether the number of pixels with respect to the maximum density value is greater than a predetermined ratio than the number of pixels with respect to the density value in the vicinity of the maximum density value. The number of pixels is changed by distributing a part of the number of pixels for the value to the number of pixels for other density values.

また本発明は、入力された濃淡画像データを基に、各濃度値に対する画素数のヒストグラムである濃度ヒストグラムを作成する濃度ヒストグラム作成工程と、
前記濃度ヒストグラムの分布に基づいて、クラス間分散が最も大きくなる濃度値を境界濃度値とし、この境界濃度値より低濃度側で最大画素数となる濃度値と、この境界濃度値より高濃度側で最大画素数となる濃度値とを抽出し、前記低濃度側で最大画素数となる濃度値と前記境界濃度値との平均値を下限濃度値とし、前記境界濃度値と前記高濃度側で最大画素数となる濃度値との平均値を上限濃度値とし、前記上限濃度値から前記下限濃度値までの各濃度値に対する画素数の平均値を小画素数として算出し、前記濃度ヒストグラムの各濃度値に対する画素数からこの小画素数を減算することで画素数を変化させる前処理工程と、
前記前処理工程で画素数が変化した濃度ヒストグラムに基づいて、各濃度値の画素数を最高濃度値または最低濃度値から順に累積したヒストグラムである累積画素数ヒストグラムを作成する累積画素数ヒストグラム作成工程と、
前記累積画素数ヒストグラムを、濃度値によって2つの領域に分割し、分割した領域ごとに累積画素数ヒストグラムに対してモーメント法を適用したときの近似直線における関数誤差を算出し、この算出した誤差の和が最小となるような濃度値を、前記濃淡画像データを2値化するための閾値とする閾値決定工程とを備えたことを特徴とする画像処理方法である。
The present invention also provides a density histogram creating step of creating a density histogram that is a histogram of the number of pixels for each density value based on the input grayscale image data;
Based on the distribution of the density histogram, the density value at which the inter-class variance is the largest is the boundary density value, the density value that is the maximum number of pixels on the lower density side than the boundary density value, and the higher density side than the boundary density value To extract the density value that becomes the maximum number of pixels, and use the average value of the density value that becomes the maximum number of pixels on the low density side and the boundary density value as the lower limit density value, and the boundary density value and the high density side An average value with the density value that is the maximum number of pixels is set as an upper limit density value, an average value of the number of pixels for each density value from the upper limit density value to the lower limit density value is calculated as a small pixel number, and each density histogram A preprocessing step of changing the number of pixels by subtracting the number of small pixels from the number of pixels for the density value ;
A cumulative pixel number histogram creating step of creating a cumulative pixel number histogram that is a histogram in which the number of pixels of each density value is sequentially accumulated from the highest density value or the lowest density value based on the density histogram in which the number of pixels has changed in the preprocessing step. When,
The cumulative number of pixels histogram, the density value is divided into two regions, it calculates a function error in the approximation straight line when applying the method of moments and against the cumulative number of pixels histogram for each was divided region, and the calculated And a threshold value determining step using a density value that minimizes the sum of errors as a threshold value for binarizing the grayscale image data.

本発明によれば、まず濃度ヒストグラム作成手段が、画像処理装置に入力された濃淡画像データを基に、各濃度値に対する画素数のヒストグラムである濃度ヒストグラムを作成し、前処理手段が、前記濃度ヒストグラムの分布に基づいて、所定の濃度値に対する画素数を変化させる。累積画素数ヒストグラム作成手段は、前記前処理手段によって画素数が変化した濃度ヒストグラムに基づいて、各濃度値の画素数を最高濃度値または最低濃度値から順に累積したヒストグラムである累積画素数ヒストグラムを作成する。   According to the present invention, first, the density histogram creation means creates a density histogram that is a histogram of the number of pixels for each density value based on the grayscale image data input to the image processing apparatus, and the preprocessing means creates the density histogram. Based on the histogram distribution, the number of pixels for a predetermined density value is changed. The cumulative pixel number histogram creating means generates a cumulative pixel number histogram which is a histogram in which the number of pixels of each density value is accumulated in order from the highest density value or the lowest density value based on the density histogram in which the number of pixels has been changed by the preprocessing means. create.

閾値決定手段は、前記累積画素数ヒストグラムを、濃度値によって2つの領域に分割し、モーメント法を適用して分割した領域ごとに累積画素数ヒストグラムに対する関数誤差を算出する。この算出した誤差の和が最小となるような濃度値を、前記濃淡画像データを2値化するための閾値として決定する。   The threshold value determining means divides the cumulative pixel number histogram into two regions according to density values, and calculates a function error for the cumulative pixel number histogram for each divided region by applying the moment method. A density value that minimizes the sum of the calculated errors is determined as a threshold value for binarizing the grayscale image data.

これにより、直線近似式の勾配に影響されず、また直線の交点を求めることもないので、より安定した適切な2値化閾値を決定することができ、適切な2値化画像データを得ることができる。   Thereby, since it is not influenced by the gradient of the linear approximation formula and the intersection of the straight lines is not obtained, a more stable and appropriate binarization threshold can be determined, and appropriate binarized image data can be obtained. Can do.

た、前記前処理手段は、前記濃度ヒストグラムの分布に基づいて、クラス間分散が最も大きくなる濃度値を境界濃度値とし、この境界濃度値より低濃度側で最大画素数となる濃度値と、この境界濃度値より高濃度側で最大画素数となる濃度値とを抽出する。前記低濃度側で最大画素数となる濃度値と前記境界濃度値との平均値を下限濃度値とし、前記境界濃度値と前記高濃度側で最大画素数となる濃度値との平均値を上限濃度とし、前記上限濃度値から前記下限濃度値までの各濃度値に対する画素数の平均値を小画素数として算出する。前記濃度ヒストグラムの各濃度値に対する画素数からこの小画素数を減算することで画素数を変化させる。 Also, the pre-processing means, based on the distribution of the density histogram, a density value interclass variance is maximized by the boundary density value, the density value becomes the maximum number of pixels at a lower density side than the boundary density value Then, the density value which becomes the maximum number of pixels on the higher density side than the boundary density value is extracted. The lower limit density value is the average value of the density value that is the maximum number of pixels on the low density side and the boundary density value, and the upper limit is the average value of the density value that is the maximum number of pixels on the high density side. a concentration value, calculates the average value of the number of pixels for each density value from the upper concentration value to the lower limit concentration value as a small number of pixels. The number of pixels is changed by subtracting the number of small pixels from the number of pixels for each density value in the density histogram.

これにより、バックグランド削除処理を行うことなく、小画素数の影響を取り除くことができるので、より適切な2値化閾値を決定することができ、適切な2値化画像データを得ることができる。   Thereby, since the influence of the number of small pixels can be removed without performing the background deletion process, a more appropriate binarization threshold can be determined, and appropriate binarized image data can be obtained. .

また本発明によれば、前記前処理手段は、最大濃度値に対する画素数が、最大濃度値近傍の濃度値に対する画素数よりも所定の割合以上に多いかどうかを判断し、多い場合は、前記最大濃度値に対する画素数の一部を他の濃度値に対する画素数に分配させることで画素数を変化させる。   According to the invention, the preprocessing means determines whether or not the number of pixels for the maximum density value is greater than a predetermined ratio than the number of pixels for the density values near the maximum density value. The number of pixels is changed by distributing a part of the number of pixels for the maximum density value to the number of pixels for the other density values.

これにより、最大濃度値(たとえば、255)の画素数が他の濃度値の画素数より遥かに多い、いわゆる過飽和状態であっても、より適切な2値化閾値を決定することができ、適切な2値化画像データを得ることができる。   As a result, a more appropriate binarization threshold can be determined even in a so-called supersaturated state where the number of pixels of the maximum density value (for example, 255) is much larger than the number of pixels of other density values. Binary image data can be obtained.

本発明によれば、まず濃度ヒストグラム作成工程において、画像処理装置に入力された濃淡画像データを基に、各濃度値に対する画素数のヒストグラムである濃度ヒストグラムを作成し、前処理工程において、前記濃度ヒストグラムの分布に基づいて、クラス間分散が最も大きくなる濃度値を境界濃度値とし、この境界濃度値より低濃度側で最大画素数となる濃度値と、この境界濃度値より高濃度側で最大画素数となる濃度値とを抽出し、前記低濃度側で最大画素数となる濃度値と前記境界濃度値との平均値を下限濃度値とし、前記境界濃度値と前記高濃度側で最大画素数となる濃度値との平均値を上限濃度値とし、前記上限濃度値から前記下限濃度値までの各濃度値に対する画素数の平均値を小画素数として算出し、前記濃度ヒストグラムの各濃度値に対する画素数からこの小画素数を減算することで画素数を変化させる。累積画素数ヒストグラム作成工程では、前記前処理工程で画素数が変化した濃度ヒストグラムに基づいて、各濃度値の画素数を最高濃度値または最低濃度値から順に累積したヒストグラムである累積画素数ヒストグラムを作成する。
According to the present invention, first, in the density histogram creation step, a density histogram that is a histogram of the number of pixels for each density value is created based on the grayscale image data input to the image processing apparatus, and in the preprocessing step, the density histogram Based on the histogram distribution, the density value with the largest interclass variance is defined as the boundary density value, the density value that is the maximum number of pixels on the lower density side than this boundary density value, and the maximum value on the higher density side than this boundary density value. A density value that is the number of pixels is extracted, an average value of the density value that is the maximum number of pixels on the low density side and the boundary density value is a lower limit density value, and the maximum pixel is on the boundary density value and the high density side An average value of the density values to be a number is an upper limit density value, an average value of the number of pixels for each density value from the upper limit density value to the lower limit density value is calculated as a small pixel number, and the density histogram Changing the number of pixels by subtracting the number of the small pixel from the number of pixels for each density value. In the cumulative pixel number histogram creating step, a cumulative pixel number histogram is a histogram in which the number of pixels of each density value is accumulated in order from the highest density value or the lowest density value based on the density histogram in which the number of pixels has changed in the preprocessing step. create.

閾値決定工程では、前記累積画素数ヒストグラムを、濃度値によって2つの領域に分割し、モーメント法を適用して分割した領域ごとに累積画素数ヒストグラムに対する関数誤差を算出する。この算出した誤差の和が最小となるような濃度値を、前記濃淡画像データを2値化するための閾値として決定する。   In the threshold value determining step, the cumulative pixel number histogram is divided into two regions according to density values, and a function error with respect to the cumulative pixel number histogram is calculated for each divided region by applying the moment method. A density value that minimizes the sum of the calculated errors is determined as a threshold value for binarizing the grayscale image data.

これにより、直線近似式の勾配に影響されず、また直線の交点を求めることもないので、より安定した適切な2値化閾値を決定することができ、適切な2値化画像データを得ることができる。   Thereby, since it is not influenced by the gradient of the linear approximation formula and the intersection of the straight lines is not obtained, a more stable and appropriate binarization threshold can be determined, and appropriate binarized image data can be obtained. Can do.

本発明では、バックグランドの削除処理に基づく問題、過飽和状態に基づく問題および誤差関数の近似に基づく問題を解決している。   The present invention solves problems based on background deletion processing, problems based on supersaturated states, and problems based on approximation of error functions.

バックグランドの削除処理に基づく問題に対しては、バックグランドの削除処理を行わず、濃度ヒストグラムを作成した後、その分散状態に基づいて除去すべき画素数を決定し、各濃度値の画素数から決定した画素数を減算する手段を設けることで解決する。   For problems based on background deletion processing, after creating a density histogram without performing background deletion processing, determine the number of pixels to be removed based on the dispersion state, and determine the number of pixels for each density value. This is solved by providing means for subtracting the number of pixels determined from.

過飽和状態に基づく問題に対しては、最大濃度値の画素数を、他の濃度値に分配させる手段を設けることで解決する。   The problem based on the supersaturated state is solved by providing means for distributing the number of pixels of the maximum density value to other density values.

誤差関数の近似に基づく問題に対しては、直線近似式の勾配に影響されないように、モーメント法を適用し、二分割した各領域の関数誤差の和が最小となる濃度を閾値として決定する手段を設けることで解決する。   For problems based on error function approximation, means to apply the moment method so that it is not affected by the slope of the linear approximation formula, and to determine the concentration that minimizes the sum of function errors in each of the two divided regions as a threshold It solves by providing.

図1は、本発明の実施の一形態である画像処理装置10のハード構成とデータの流れを簡略化して示すブロック図である。テレビカメラまたはスキャナなどの撮像手段11によって対象物の2次元濃淡画像データが得られる。マイクロコンピュータなどによって実現される処理手段12は、この撮像手段11の出力をメモリ13にストアする。メモリ13にストアされた濃淡画像データは、処理手段12によって読出されて本発明に従って画像処理され、2値化画像データが得られる。こうして得られた2値化画像データは、表示手段14によって目視表示される。表示手段14は、たとえば液晶パネルまたは陰極線管などであってもよい。プリンタ15は、処理手段12からの2値化画像データを、記録紙に印字することができる。カラー画像データの場合には、その中の一色を対象とすることもできるし、カラー画像データから公知の方法で輝度画像に変換して本法を適用することもできる。   FIG. 1 is a block diagram showing a simplified hardware configuration and data flow of an image processing apparatus 10 according to an embodiment of the present invention. Two-dimensional grayscale image data of the object is obtained by the imaging means 11 such as a television camera or a scanner. The processing means 12 realized by a microcomputer or the like stores the output of the imaging means 11 in the memory 13. The grayscale image data stored in the memory 13 is read out by the processing means 12 and subjected to image processing according to the present invention to obtain binary image data. The binarized image data obtained in this way is visually displayed by the display means 14. The display means 14 may be a liquid crystal panel or a cathode ray tube, for example. The printer 15 can print the binarized image data from the processing means 12 on a recording sheet. In the case of color image data, one of the colors can be targeted, or the present method can be applied by converting the color image data into a luminance image by a known method.

以下では、計測、検査などの対象となるワークを撮像手段11で撮像し、得られた画像データに基づいて処理手段12が、ワークと背景とを分離するために2値化処理を行う場合について説明する。   Hereinafter, a case where a workpiece to be measured or inspected is imaged by the imaging unit 11 and the processing unit 12 performs binarization processing to separate the workpiece and the background based on the obtained image data. explain.

濃度ヒストグラム作成手段、前処理手段、累積画素数ヒストグラム作成手段および閾値決定手段は、処理手段12およびメモリ13で構成され、メモリ13に記憶される画像処理プログラムを処理手段12が実行することで、濃度ヒストグラム作成手段、前処理手段、累積画素数ヒストグラム作成手段および閾値決定手段として機能する。   The density histogram creation means, the preprocessing means, the cumulative pixel number histogram creation means, and the threshold value determination means are configured by the processing means 12 and the memory 13, and the processing means 12 executes the image processing program stored in the memory 13. Functions as density histogram creation means, preprocessing means, cumulative pixel number histogram creation means, and threshold value determination means.

濃淡画像データおよび2値化画像データは複数の画素から構成され、各画素には画像データ内の位置を示す座標と、濃度値(多値または2値)とが与えられる。   The grayscale image data and the binarized image data are composed of a plurality of pixels, and each pixel is given a coordinate indicating a position in the image data and a density value (multivalue or binary).

(手順1)濃度ヒストグラム作成
濃度値ごとにその濃度値を有する画素の数をカウントし、濃度値と画素数(頻度)とのヒストグラムを作成する。
(Procedure 1) Creation of density histogram For each density value, the number of pixels having the density value is counted, and a histogram of the density value and the number of pixels (frequency) is created.

(手順2)小画素数除去処理
濃度ヒストグラムの分散状態に基づいて、除去すべき画素数である「小画素数」を求め、濃度ヒストグラムの各濃度値における画素数から「小画素数」を減算する。
(Procedure 2) Small pixel number removal processing Based on the dispersion state of the density histogram, the “small pixel number” that is the number of pixels to be removed is obtained, and the “small pixel number” is subtracted from the number of pixels in each density value of the density histogram. To do.

(手順3)過飽和解消処理
最大濃度値(たとえば、255)の画素数が最大濃度値近傍の濃度値に対する画素数より遥かに多い「過飽和状態」であるかどうかを判断し、「過飽和状態」であると判断したときは、最大濃度値の画素数を濃度ヒストグラムの他の濃度値に分配させることで、最大濃度値の画素数を閾値の決定に影響するようにする。
(Procedure 3) Supersaturation elimination processing It is determined whether or not the number of pixels of the maximum density value (for example, 255) is much "supersaturated" much larger than the number of pixels for density values near the maximum density value. When it is determined that there is, the number of pixels having the maximum density value is distributed to other density values in the density histogram so that the number of pixels having the maximum density value affects the determination of the threshold value.

(手順4)累積画素数ヒストグラム作成
手順2、手順3を経た濃度ヒストグラムに基づいて、たとえば最大濃度値255から各濃度値の画素数を順次累積した累積画素数ヒストグラムを作成する。
(Procedure 4) Cumulative Pixel Number Histogram Creation Based on the density histogram that has undergone the procedures 2 and 3, for example, a cumulative pixel number histogram is created by sequentially accumulating the number of pixels of each density value from the maximum density value 255.

(手順5)2値化閾値決定
累積画素数ヒストグラムを二分割するような濃度値を設定し、二分割した各濃度領域におけるモーメント法による誤差の和が最小となる濃度値を2値化閾値として決定する。
以下では、フローチャートを用いて本発明をさらに詳細に説明する。
(Procedure 5) Determination of binarization threshold value A density value that divides the cumulative pixel number histogram into two is set, and a density value that minimizes the sum of errors in the moment method in each of the two divided density areas is set as a binarization threshold value. decide.
Hereinafter, the present invention will be described in more detail with reference to flowcharts.

図2は、本発明の画像処理を示すフローチャートである。
まずステップS1では、撮像した画像データに基づいて濃度ヒストグラムを作成する。
FIG. 2 is a flowchart showing the image processing of the present invention.
First, in step S1, a density histogram is created based on the captured image data.

ステップS2では、小画素数除去処理を行う。小画素数除去処理では、まず、濃度分布のクラス間分散が最も大きくなる濃度値(境界濃度値)を境に、境界濃度値より低濃度側において最大画素数となる濃度値と、境界濃度値より高濃度側において最大画素数となる濃度値とを抽出する。次に、低濃度側で最大画素数となる濃度値と境界濃度値との平均濃度値を下限濃度値とし、境界濃度値と高濃度側で最大画素数となる濃度値との平均濃度値を上限濃度とする。そして、上限濃度値から下限濃度値までの各濃度値の画素数の平均値を削除する画素数である「小画素数」として決定し、濃度ヒストグラムにおける各濃度値の画素数から減算して新たな濃度ヒストグラムを作成する。ただし、減算後の画素数が負となるときは、画素数を“0”とする。   In step S2, small pixel number removal processing is performed. In the small pixel number removal processing, first, the density value that becomes the maximum number of pixels on the lower density side than the boundary density value, and the boundary density value, with the density value (boundary density value) at which the interclass variance of the density distribution becomes the largest as the boundary The density value that is the maximum number of pixels on the higher density side is extracted. Next, the average density value of the density value that is the maximum number of pixels on the low density side and the boundary density value is the lower limit density value, and the average density value of the boundary density value and the density value that is the maximum number of pixels on the high density side is Use the upper limit concentration. Then, the average value of the number of pixels of each density value from the upper limit density value to the lower limit density value is determined as the “small pixel number” that is the number of pixels to be deleted, and is newly subtracted from the number of pixels of each density value in the density histogram. Create a strong density histogram. However, when the number of pixels after subtraction is negative, the number of pixels is set to “0”.

小画素数除去処理としては、上記のような処理の他に、濃度ヒストグラムの少なくとも一つの谷を含む濃度値範囲を設定し、この濃度値範囲内の各濃度値に対する画素数の平均値を、削除する画素数である「小画素数」として決定し、濃度ヒストグラムにおける各濃度値の画素数から減算して新たな濃度ヒストグラムを作成する処理であってもよい。   As the small pixel number removal processing, in addition to the above processing, a density value range including at least one valley of the density histogram is set, and an average value of the number of pixels for each density value in the density value range is determined as follows: The processing may be a process of determining a “small pixel number” that is the number of pixels to be deleted and subtracting from the number of pixels of each density value in the density histogram to create a new density histogram.

ステップS3では、過飽和状態であるかどうかを判断し、過飽和状態であればステップS4に進み、過飽和状態でなければステップS5に進む。   In step S3, it is determined whether or not it is a supersaturated state. If it is a supersaturated state, the process proceeds to step S4, and if it is not a supersaturated state, the process proceeds to step S5.

過飽和状態であるかどうかの判断は、濃度ヒストグラムにおいて、最大濃度値の画素数が、最大濃度値近傍の濃度値の画素数よりも所定の割合以上に多いかどうかによって判断する。たとえば、最大濃度値近傍の濃度値を、最大濃度値−1とすると、以下の条件式を満足するかどうかによって判断する。
(最大濃度値の画素数)×R≧[(最大濃度値−1)の画素数] …(2)
ここで、Rは予め定める比率を示し、5%以下に設定することが好ましい。
Whether or not the state is supersaturated is determined based on whether or not the number of pixels of the maximum density value is greater than a predetermined ratio in the density histogram than the number of pixels of the density value near the maximum density value. For example, if the density value near the maximum density value is set to the maximum density value−1, the determination is made based on whether or not the following conditional expression is satisfied.
(Number of pixels of maximum density value) × R ≧ [Number of pixels of (maximum density value−1)] (2)
Here, R represents a predetermined ratio, and is preferably set to 5% or less.

ステップS4では、最大濃度値の影響を他の濃度値に分配させる最大濃度分配処理を行う。最大濃度分配処理では、最大濃度値255となる画素数をN等分し、それを濃度値(256−N)〜254までの画素数に加算し、最大濃度値となる画素数を元の画素数のN分の1として新たな濃度ヒストグラムを作成する。   In step S4, a maximum density distribution process for distributing the influence of the maximum density value to other density values is performed. In the maximum density distribution process, the number of pixels having the maximum density value 255 is equally divided into N and added to the number of pixels from density values (256-N) to 254, and the number of pixels having the maximum density value is converted to the original pixel. A new density histogram is created as 1 / N of the number.

具体的には、最大濃度分配処理前の濃度値Kの画素数をf(K)とすると、最大濃度分配処理後の画素数g(K)は以下のようになる。   Specifically, assuming that the number of pixels of the density value K before the maximum density distribution process is f (K), the number of pixels g (K) after the maximum density distribution process is as follows.

ステップS5では、累積画素数ヒストグラムを作成する。
累積画素数ヒストグラムは、現時点での濃度ヒストグラムに基づいて、最大濃度値の画素数に順次各濃度値の画素数を累積して累積画素数ヒストグラムを作成する。
In step S5, a cumulative pixel number histogram is created.
The cumulative pixel number histogram creates a cumulative pixel number histogram by sequentially accumulating the number of pixels of each density value to the number of pixels of the maximum density value based on the current density histogram.

ステップS6では、モーメント法を適用して2値化閾値を決定する。
累積画素数ヒストグラムを二分割するような濃度値を設定し、この濃度値で二分割した各領域にいて、モーメント法を適用して誤差を算出し、算出した誤差の和が最小となるような濃度値を2値化閾値として決定する。
In step S6, the binarization threshold is determined by applying the moment method.
Set a density value that divides the cumulative pixel count histogram into two parts, calculate the error by applying the moment method in each area divided into two by this density value, and minimize the sum of the calculated errors The density value is determined as a binarization threshold.

具体的には、モーメント法による以下の評価式の値(誤差の和)が最小になるような濃度値k1を2値化閾値として決定する。
評価式=(σ1+σ2)/2−√{(σ2−σ1)2/4+σ3 2}
+(σ’1+σ’2)/2−√{(σ’2−σ’1)2/4+σ’3 2} …(4)
ここで、σ1=Σ(k2)−(Σk)2/N
σ2=ΣH(k)2−{ΣH(k)}2/N
σ3=Σ{k×H(k)}−(Σk)×Σ(H(k))/N
σ’1=Σ’(k2)−(Σ’k)2/N’
σ’2=Σ’H(k)2−{ΣH(k)}2/N’
σ’3=Σ’(k×H(k))−(Σ’k)×Σ’(H(k))/N’
Σk :最小濃度値から濃度値k1までの濃度値の和
Σ’k:濃度値k1+1から最大濃度値までの濃度値の和
N :最小濃度値から濃度値kまでの画素数の和
N’ :濃度値k+1から最大濃度値までの画素数の和
なお、濃度ヒストグラムにおける最大濃度値から濃度値kまでの累積画素数を
H(k)とし、これは濃度値kにおける累積画素数に相当する。
Specifically, the density value k 1 that minimizes the value of the following evaluation formula (sum of errors) by the moment method is determined as the binarization threshold.
Evaluation formula = (σ 1 + σ 2) / 2-√ {(σ 2 -σ 1) 2/4 + σ 3 2}
+ (Σ '1 + σ' 2) / 2-√ {(σ '2 -σ' 1) 2/4 + σ '3 2} ... (4)
Here, σ 1 = Σ (k 2 ) − (Σk) 2 / N
σ 2 = ΣH (k) 2 − {ΣH (k)} 2 / N
σ 3 = Σ {k × H (k)} − (Σk) × Σ (H (k)) / N
σ ′ 1 = Σ ′ (k 2 ) − (Σ′k) 2 / N ′
σ ′ 2 = Σ′H (k) 2 − {ΣH (k)} 2 / N ′
σ ′ 3 = Σ ′ (k × H (k)) − (Σ′k) × Σ ′ (H (k)) / N ′
Σk: Sum of density values from minimum density value to density value k 1
Σ′k: Sum of density values from density value k 1 +1 to the maximum density value
N: Sum of the number of pixels from the minimum density value to the density value k 1
N ′: Sum of the number of pixels from the density value k 1 +1 to the maximum density value Note that the cumulative number of pixels from the maximum density value to the density value k in the density histogram is H (k), which is the cumulative pixel at the density value k. It corresponds to a number.

以上より、濃度ヒストグラムにおいて、所定の画素数を除去することで、バックグランド削除処理を行う必要がなくなり、適切な2値化閾値を得ることができる。また、モーメント法を適用することで、累積画素数ヒストグラムの形状に影響されることなく安定した閾値を得ることができる。さらに、過飽和状態の画像データであっても適切な2値化閾値を得ることができる。   As described above, by removing a predetermined number of pixels from the density histogram, it is not necessary to perform background deletion processing, and an appropriate binarization threshold can be obtained. Further, by applying the moment method, a stable threshold value can be obtained without being affected by the shape of the cumulative pixel number histogram. Furthermore, an appropriate binarization threshold value can be obtained even for supersaturated image data.

特に本発明は、食品容器、包装紙などの印刷物、電子部品などの工業製品の検査、計測において、照明の変動にも追随する閾値を得ることができるため、対象ワークと背景とを安定して分離することができる。   In particular, the present invention can obtain a threshold value that follows fluctuations in illumination in inspection and measurement of industrial products such as food containers and wrapping paper and electronic products, so that the target work and the background can be stabilized. Can be separated.

以下では、本発明の実施例について説明する。
図3〜図7は、表示手段14の表示画面であり、2値化の対象となる濃淡画像データに基づく画像、および2値化画像データに基づく画像を示している。なお、2値化画像データに基づく画像は、濃淡画像データに基づく画像に重ね合わせて表示している。さらに、各画像に重ねて濃度ヒストグラム(画面上側)および累積画素数ヒストグラム(画面下側)を表示している。
Examples of the present invention will be described below.
3 to 7 are display screens of the display means 14 and show an image based on grayscale image data to be binarized and an image based on the binarized image data. Note that the image based on the binarized image data is displayed superimposed on the image based on the grayscale image data. Further, a density histogram (upper screen) and a cumulative pixel count histogram (lower screen) are displayed overlaid on each image.

図3は、実施例1による表示画面を示す図である。図3(a)が濃淡画像を示し、図3(b)がその濃淡画像本発明の2値化処理を施した2値化画像を示している。図3(a)と図3(b)を比較すると、濃淡画像上のワークが2値化画像上でも明確に表示されていることが分かる。   FIG. 3 is a diagram illustrating a display screen according to the first embodiment. FIG. 3A shows a grayscale image, and FIG. 3B shows the binary image obtained by performing the binarization processing of the present invention. Comparing FIG. 3A and FIG. 3B, it can be seen that the work on the grayscale image is clearly displayed on the binarized image.

図4は、実施例2による表示画面を示す図である。図4(a)は本発明の2値化処理を施した2値化画像を示し、図4(b)は、従来の多段平滑ヒストグラムモデルに基づく方法による2値化画像を示している。実施例2の濃淡画像データの濃度ヒストグラムは、図4(a)に示すように、中濃度領域に大きな山が存在するので、従来の2値化処理では図4(b)に示すように背景が適切に2値化されない。これに対し本発明では、図4(a)に示すように、適切に2値化されている。   FIG. 4 is a diagram illustrating a display screen according to the second embodiment. FIG. 4A shows a binarized image subjected to the binarization processing of the present invention, and FIG. 4B shows a binarized image obtained by a method based on a conventional multistage smooth histogram model. In the density histogram of the grayscale image data of the second embodiment, as shown in FIG. 4A, a large mountain exists in the middle density area. Therefore, in the conventional binarization process, the background as shown in FIG. Is not properly binarized. On the other hand, in the present invention, as shown in FIG.

図5は、実施例3による表示画面を示す図である。図5(a)は本発明の2値化処理を施した2値化画像を示し、図5(b)は、従来の多段平滑ヒストグラムモデルに基づく方法による2値化画像を示している。実施例3の濃淡画像データの濃度ヒストグラムは、図5(a)に示すように、最大濃度値の画素数が他の濃度値の画素数に比べて遥かに大きい過飽和状態であるので、従来の2値化処理では図5(b)に示すように適切に2値化されない。これに対し本発明では、図5(a)に示すように、適切に2値化されている。   FIG. 5 is a diagram illustrating a display screen according to the third embodiment. FIG. 5A shows a binarized image subjected to the binarization processing of the present invention, and FIG. 5B shows a binarized image obtained by a method based on a conventional multistage smooth histogram model. As shown in FIG. 5A, the density histogram of the grayscale image data of the third embodiment is a supersaturated state in which the number of pixels of the maximum density value is much larger than the number of pixels of other density values. In the binarization process, binarization is not appropriately performed as shown in FIG. On the other hand, in the present invention, as shown in FIG.

図6および図7は、実施例4による表示画面を示す図である。図6(a)はモーメント法を適用した場合の、累積画素数ヒストグラムの近似直線を示し、図6(b)は最小二乗法を適用した場合の、累積画素数ヒストグラムの近似直線を示している。図7(a)は本発明の2値化処理を施した2値化画像を示し、図7(b)は、従来の多段平滑ヒストグラムモデルに基づく方法による2値化画像を示している。従来の2値化処理では図7(b)に示すように適切に2値化されないのに対し、本発明では、図7(a)に示すように、適切に2値化されている。   6 and 7 are diagrams showing display screens according to the fourth embodiment. 6A shows an approximate straight line of the cumulative pixel number histogram when the moment method is applied, and FIG. 6B shows an approximate straight line of the cumulative pixel number histogram when the least square method is applied. . FIG. 7A shows a binarized image subjected to the binarization processing of the present invention, and FIG. 7B shows a binarized image obtained by a method based on a conventional multistage smooth histogram model. In the conventional binarization process, binarization is not appropriately performed as shown in FIG. 7B, whereas in the present invention, binarization is appropriately performed as shown in FIG. 7A.

本発明の実施の一形態である画像処理装置10のハード構成とデータの流れを簡略化して示すブロック図である。1 is a block diagram showing a simplified hardware configuration and data flow of an image processing apparatus 10 according to an embodiment of the present invention. 本発明の画像処理を示すフローチャートである。It is a flowchart which shows the image processing of this invention. 実施例1による表示画面を示す図である。It is a figure which shows the display screen by Example 1. FIG. 実施例2による表示画面を示す図である。It is a figure which shows the display screen by Example 2. FIG. 実施例3による表示画面を示す図である。It is a figure which shows the display screen by Example 3. FIG. 実施例4による表示画面を示す図である。It is a figure which shows the display screen by Example 4. FIG. 実施例4による表示画面を示す図である。It is a figure which shows the display screen by Example 4. FIG. 従来の画像処理を示すフローチャートである。It is a flowchart which shows the conventional image processing.

符号の説明Explanation of symbols

10 画像処理装置
11 撮像手段
12 処理手段
13 メモリ
14 表示手段
15 プリンタ
DESCRIPTION OF SYMBOLS 10 Image processing apparatus 11 Imaging means 12 Processing means 13 Memory 14 Display means 15 Printer

Claims (3)

入力された濃淡画像データを基に、各濃度値に対する画素数のヒストグラムである濃度ヒストグラムを作成する濃度ヒストグラム作成手段と、
前記濃度ヒストグラムの分布に基づいて、クラス間分散が最も大きくなる濃度値を境界濃度値とし、この境界濃度値より低濃度側で最大画素数となる濃度値と、この境界濃度値より高濃度側で最大画素数となる濃度値とを抽出し、前記低濃度側で最大画素数となる濃度値と前記境界濃度値との平均値を下限濃度値とし、前記境界濃度値と前記高濃度側で最大画素数となる濃度値との平均値を上限濃度値とし、前記上限濃度値から前記下限濃度値までの各濃度値に対する画素数の平均値を小画素数として算出し、前記濃度ヒストグラムの各濃度値に対する画素数からこの小画素数を減算することで画素数を変化させる前処理手段と、
前記前処理手段によって画素数が変化した濃度ヒストグラムに基づいて、各濃度値の画素数を最高濃度値または最低濃度値から順に累積したヒストグラムである累積画素数ヒストグラムを作成する累積画素数ヒストグラム作成手段と、
前記累積画素数ヒストグラムを、濃度値によって2つの領域に分割し、分割した領域ごとに累積画素数ヒストグラムに対してモーメント法を適用したときの近似直線における関数誤差を算出し、この算出した誤差の和が最小となるような濃度値を、前記濃淡画像データを2値化するための閾値とする閾値決定手段とを備えたことを特徴とする画像処理装置。
A density histogram creating means for creating a density histogram which is a histogram of the number of pixels for each density value based on the input grayscale image data;
Based on the distribution of the density histogram, the density value at which the inter-class variance is the largest is the boundary density value, the density value that is the maximum number of pixels on the lower density side than the boundary density value, and the higher density side than the boundary density value To extract the density value that becomes the maximum number of pixels, and use the average value of the density value that becomes the maximum number of pixels on the low density side and the boundary density value as the lower limit density value, and the boundary density value and the high density side An average value with the density value that is the maximum number of pixels is set as an upper limit density value, an average value of the number of pixels for each density value from the upper limit density value to the lower limit density value is calculated as a small pixel number, and each density histogram Preprocessing means for changing the number of pixels by subtracting the number of small pixels from the number of pixels for the density value ;
Based on the density histogram in which the number of pixels has been changed by the preprocessing means, a cumulative pixel number histogram creating means for creating a cumulative pixel number histogram that is a histogram in which the number of pixels of each density value is accumulated in order from the highest density value or the lowest density value. When,
The cumulative number of pixels histogram, the density value is divided into two regions, it calculates a function error in the approximation straight line when applying the method of moments and against the cumulative number of pixels histogram for each was divided region, and the calculated An image processing apparatus comprising: a threshold value determining unit that sets a density value that minimizes a sum of errors as a threshold value for binarizing the grayscale image data.
前記前処理手段は、最大濃度値に対する画素数が、最大濃度値近傍の濃度値に対する画素数よりも所定の割合以上に多いかどうかを判断し、多い場合は、前記最大濃度値に対する画素数の一部を他の濃度値に対する画素数に分配させることで画素数を変化させることを特徴とする請求項1に記載の画像処理装置。 The preprocessing means determines whether or not the number of pixels for the maximum density value is greater than a predetermined ratio than the number of pixels for the density value in the vicinity of the maximum density value. The image processing apparatus according to claim 1, wherein the number of pixels is changed by distributing a part to the number of pixels for other density values. 入力された濃淡画像データを基に、各濃度値に対する画素数のヒストグラムである濃度ヒストグラムを作成する濃度ヒストグラム作成工程と、
前記濃度ヒストグラムの分布に基づいて、クラス間分散が最も大きくなる濃度値を境界濃度値とし、この境界濃度値より低濃度側で最大画素数となる濃度値と、この境界濃度値より高濃度側で最大画素数となる濃度値とを抽出し、前記低濃度側で最大画素数となる濃度値と前記境界濃度値との平均値を下限濃度値とし、前記境界濃度値と前記高濃度側で最大画素数となる濃度値との平均値を上限濃度値とし、前記上限濃度値から前記下限濃度値までの各濃度値に対する画素数の平均値を小画素数として算出し、前記濃度ヒストグラムの各濃度値に対する画素数からこの小画素数を減算することで画素数を変化させる前処理工程と、
前記前処理工程で画素数が変化した濃度ヒストグラムに基づいて、各濃度値の画素数を最高濃度値または最低濃度値から順に累積したヒストグラムである累積画素数ヒストグラムを作成する累積画素数ヒストグラム作成工程と、
前記累積画素数ヒストグラムを、濃度値によって2つの領域に分割し、分割した領域ごとに累積画素数ヒストグラムに対してモーメント法を適用したときの近似直線における関数誤差を算出し、この算出した誤差の和が最小となるような濃度値を、前記濃淡画像データを2値化するための閾値とする閾値決定工程とを備えたことを特徴とする画像処理方法。
A density histogram creating step for creating a density histogram that is a histogram of the number of pixels for each density value based on the input grayscale image data;
Based on the distribution of the density histogram, the density value at which the inter-class variance is the largest is the boundary density value, the density value that is the maximum number of pixels on the lower density side than the boundary density value, and the higher density side than the boundary density value To extract the density value that becomes the maximum number of pixels, and use the average value of the density value that becomes the maximum number of pixels on the low density side and the boundary density value as the lower limit density value, and the boundary density value and the high density side An average value with the density value that is the maximum number of pixels is set as an upper limit density value, an average value of the number of pixels for each density value from the upper limit density value to the lower limit density value is calculated as a small pixel number, and each density histogram A preprocessing step of changing the number of pixels by subtracting the number of small pixels from the number of pixels for the density value ;
A cumulative pixel number histogram creating step of creating a cumulative pixel number histogram that is a histogram in which the number of pixels of each density value is sequentially accumulated from the highest density value or the lowest density value based on the density histogram in which the number of pixels has changed in the preprocessing step. When,
The cumulative number of pixels histogram, the density value is divided into two regions, it calculates a function error in the approximation straight line when applying the method of moments and against the cumulative number of pixels histogram for each was divided region, and the calculated An image processing method comprising: a threshold value determining step in which a density value that minimizes a sum of errors is used as a threshold value for binarizing the grayscale image data.
JP2005152806A 2005-05-25 2005-05-25 Image processing apparatus and image processing method Expired - Fee Related JP4741289B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2005152806A JP4741289B2 (en) 2005-05-25 2005-05-25 Image processing apparatus and image processing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2005152806A JP4741289B2 (en) 2005-05-25 2005-05-25 Image processing apparatus and image processing method

Publications (2)

Publication Number Publication Date
JP2006331018A JP2006331018A (en) 2006-12-07
JP4741289B2 true JP4741289B2 (en) 2011-08-03

Family

ID=37552653

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2005152806A Expired - Fee Related JP4741289B2 (en) 2005-05-25 2005-05-25 Image processing apparatus and image processing method

Country Status (1)

Country Link
JP (1) JP4741289B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101929560B1 (en) * 2013-01-29 2019-03-14 삼성전자주식회사 Method and apparatus for detecting edge in image

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04207668A (en) * 1990-11-30 1992-07-29 Mitsubishi Electric Corp Image processor
JP2004180000A (en) * 2002-11-27 2004-06-24 Kansai Tlo Kk Method and device for binarizing image

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04207668A (en) * 1990-11-30 1992-07-29 Mitsubishi Electric Corp Image processor
JP2004180000A (en) * 2002-11-27 2004-06-24 Kansai Tlo Kk Method and device for binarizing image

Also Published As

Publication number Publication date
JP2006331018A (en) 2006-12-07

Similar Documents

Publication Publication Date Title
US6970606B2 (en) Automatic image quality evaluation and correction technique for digitized and thresholded document images
US8712188B2 (en) System and method for document orientation detection
JP4601134B2 (en) Method and apparatus for defect detection based on shape features
US20070253040A1 (en) Color scanning to enhance bitonal image
US8331670B2 (en) Method of detection document alteration by comparing characters using shape features of characters
CN105469027A (en) Horizontal and vertical line detection and removal for document images
WO2005041558A1 (en) Statistical self-calibrating detection and removal of blemishes in digital images
US20120207379A1 (en) Image Inspection Apparatus, Image Inspection Method, And Computer Program
US8571343B2 (en) Methods and systems for document-image correction
US20040161148A1 (en) Method and system for object recognition using fractal maps
US20040161161A1 (en) Method and system for image segmentation
CN114240925A (en) Method and system for detecting document image definition
JP2004139600A (en) Image processing method, processor and computer program code means for executing the method
US7646892B2 (en) Image inspecting apparatus, image inspecting method, control program and computer-readable storage medium
JP4741289B2 (en) Image processing apparatus and image processing method
JP5424694B2 (en) Image recognition apparatus and program
JP5157575B2 (en) Defect detection method
US20180268561A1 (en) Method and apparatus for identifying a gap between objects in an image
US8355582B2 (en) Image processing apparatus and image processing method
JP4253265B2 (en) Shadow detection apparatus, shadow detection method and shadow detection program, image processing apparatus using shadow detection apparatus, image processing method using shadow detection method, and image processing program using shadow detection program
JP2004180000A (en) Method and device for binarizing image
JP2007011939A (en) Image decision device and method therefor
US11750748B2 (en) Image processing apparatus, method, and storage medium to evaluate printed material with decreased influence of specific characteristic of print medium determined from margin area of printed chart
KR100537829B1 (en) Method for segmenting Scan Image
JP2000070243A (en) Irradiation area extraction device, irradiation area extraction and computer readable storage medium

Legal Events

Date Code Title Description
A711 Notification of change in applicant

Free format text: JAPANESE INTERMEDIATE CODE: A711

Effective date: 20080519

A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20080526

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A821

Effective date: 20080519

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A821

Effective date: 20080620

A711 Notification of change in applicant

Free format text: JAPANESE INTERMEDIATE CODE: A711

Effective date: 20081024

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A821

Effective date: 20081024

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20101203

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20101214

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20110214

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20110426

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20110506

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20140513

Year of fee payment: 3

LAPS Cancellation because of no payment of annual fees