JP2012065230A - Image binarizing method and image binarizing apparatus - Google Patents

Image binarizing method and image binarizing apparatus Download PDF

Info

Publication number
JP2012065230A
JP2012065230A JP2010209128A JP2010209128A JP2012065230A JP 2012065230 A JP2012065230 A JP 2012065230A JP 2010209128 A JP2010209128 A JP 2010209128A JP 2010209128 A JP2010209128 A JP 2010209128A JP 2012065230 A JP2012065230 A JP 2012065230A
Authority
JP
Japan
Prior art keywords
image
pixel
edge
binarization
region
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP2010209128A
Other languages
Japanese (ja)
Other versions
JP5732217B2 (en
Inventor
Hidetsugu Hasebe
英嗣 長谷部
Kazutoshi Ukai
和歳 鵜飼
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.)
Glory Ltd
Original Assignee
Glory 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 Glory Ltd filed Critical Glory Ltd
Priority to JP2010209128A priority Critical patent/JP5732217B2/en
Publication of JP2012065230A publication Critical patent/JP2012065230A/en
Application granted granted Critical
Publication of JP5732217B2 publication Critical patent/JP5732217B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

PROBLEM TO BE SOLVED: To provide an image binarizing method and an image binarizing apparatus that provide an appropriate binary image even when ruled lines, characters, or background portions of an input image have various differences in density.SOLUTION: The image binarizing apparatus comprises: a mask image generating unit that generates a binary mask image on the basis of an edge intensity as the absolute value of a differential value of an input image; a pattern extracting unit that generates a pattern-extracted image by extracting pixels corresponding to effective pixels of the mask image from the input image; a labeling unit that divides the effective pixels of the mask image for each of continuous regions; a threshold value determining unit that determines a binarization threshold value for each individual region of the pattern-extracted images corresponding to the continuous regions based on a brightness distribution of the individual region; and a binarization processing unit that binarizes the individual regions using the binarization threshold value for each individual region.

Description

本発明は、帳票等の入力画像を2値化する画像2値化方法および画像2値化装置に関する。   The present invention relates to an image binarization method and an image binarization apparatus for binarizing an input image such as a form.

従来、帳票等の入力画像に対して画像処理やパターン認識を行う場合には、前処理として2値化処理を行うことが多い。ここで、2値化処理とは、入力画像の輝度値を所定の閾値を用いて2値化することで、罫線や文字といった対象画像を背景と分離する処理のことを指す。   Conventionally, when image processing or pattern recognition is performed on an input image such as a form, binarization processing is often performed as preprocessing. Here, the binarization processing refers to processing for separating the target image such as ruled lines and characters from the background by binarizing the luminance value of the input image using a predetermined threshold.

たとえば、特許文献1には、入力画像の2次微分値に基づいて文字領域のヒストグラムおよび背景領域のヒストグラムを作成し、両ヒストグラムの交点を閾値として決定たうえで、かかる閾値を用いて入力画像を2値化する画像2値化手法が開示されている。   For example, in Patent Document 1, a histogram of a character region and a histogram of a background region are created based on a second derivative value of an input image, and an intersection of both histograms is determined as a threshold value. An image binarization method for binarizing the image is disclosed.

また、特許文献2には、入力画像をあらかじめ設定された複数のブロックに分割したうえで、ブロックごとに閾値を決定する画像2値化方法が開示されている。   Patent Document 2 discloses an image binarization method in which an input image is divided into a plurality of preset blocks and a threshold value is determined for each block.

特許第3831797号公報Japanese Patent No. 3831797 特開2005−165925号公報JP 2005-165925 A

しかしながら、特許文献1に記載の画像2値化方法のように、単一の閾値を用いて入力画像を2値化することとすると、入力画像の罫線や文字あるいは背景に多様な濃淡差がある場合に適切な2値画像を得ることが困難であるという問題があった。   However, when the input image is binarized using a single threshold as in the image binarization method described in Patent Document 1, there are various shade differences in the ruled lines, characters, or background of the input image. In some cases, it is difficult to obtain an appropriate binary image.

たとえば、白地の背景の一部に罫線や文字と同一輝度の背景が含まれる場合に、単一の閾値を用いて2値化を行うと、かかる背景部分が2値画像において残存してしまうおそれがある。また、かかる背景部分を除外するために閾値を暗めに設定すると、背景部分とともに罫線や文字まで消えてしまうおそれがある。   For example, when a part of a white background includes a background having the same brightness as a ruled line or a character, if the binarization is performed using a single threshold, the background part may remain in the binary image. There is. Further, if the threshold is set to be dark in order to exclude the background portion, the ruled lines and characters may be erased together with the background portion.

なお、特許文献2に記載の画像2値化方法のように、あらかじめ決められたブロックごとに閾値を決定したとしても、ブロック内に輝度の異なる背景が混在する場合には、2値画像において背景が残存するおそれがあるため、適切な2値化画像を得ることは困難である。   Even if the threshold value is determined for each predetermined block as in the image binarization method described in Patent Document 2, if a background with different luminance is mixed in the block, the background in the binary image Therefore, it is difficult to obtain an appropriate binarized image.

これらのことから、入力画像の罫線や文字あるいは背景に多様な濃淡差がある場合であっても適切な2値画像を得ることができる画像2値化方法あるいは画像2値化装置をいかにして実現するかが大きな課題となっている。   From these facts, how can an image binarization method or image binarization apparatus that can obtain an appropriate binary image even when there are various shading differences in ruled lines, characters, or background of the input image? The realization is a big issue.

本発明は、上述した従来技術の課題を解決するためになされたものであり、入力画像の罫線や文字あるいは背景に多様な濃淡差がある場合であっても適切な2値画像を得ることができる画像2値化方法および画像2値化装置を提供することを目的とする。   The present invention has been made to solve the above-described problems of the prior art, and an appropriate binary image can be obtained even when there are various shading differences in ruled lines, characters, or background of an input image. An object is to provide an image binarization method and an image binarization apparatus.

上述した課題を解決し、目的を達成するために、本発明は、入力画像を2値化する画像2値化方法であって、前記入力画像の微分値の絶対値であるエッジ強度を求めるとともに、当該エッジ強度が所定のエッジ強度閾値以上の画素を有効画素とし前記エッジ強度閾値未満の画素を無効画素とした2値のマスク画像を生成するマスク画像生成工程と、前記マスク画像の有効画素に対応する画素を前記入力画像から抽出することによって型抜き画像を生成する型抜き工程と、前記マスク画像の有効画素を連続領域ごとに区分けする区分け工程と、前記連続領域に対応する前記型抜き画像の個別領域ごとに、当該個別領域の輝度分布に基づいて2値化閾値を決定する閾値決定工程と、前記個別領域ごとに、前記閾値決定工程において決定した2値化閾値を用いて当該個別領域に含まれる画素を2値化する2値化工程とを含んだことを特徴とする。   In order to solve the above-described problems and achieve the object, the present invention is an image binarization method for binarizing an input image, and obtains an edge strength which is an absolute value of a differential value of the input image. A mask image generating step for generating a binary mask image in which a pixel whose edge intensity is equal to or greater than a predetermined edge intensity threshold is an effective pixel and a pixel whose edge intensity is less than the edge intensity threshold is an invalid pixel; and an effective pixel of the mask image A die cutting step for generating a die cut image by extracting corresponding pixels from the input image, a step for dividing effective pixels of the mask image into continuous regions, and the die cut image corresponding to the continuous regions A threshold value determination step for determining a binarization threshold value for each individual region based on a luminance distribution of the individual region, and a binarization value determined in the threshold value determination step for each individual region Characterized in that it includes a binarization step of binarizing the pixels included in the individual areas with the value.

また、本発明は、上記の発明において、前記マスク画像生成工程は、前記入力画像のエッジ強度を用いてエッジ強度分布を生成するとともに、生成したエッジ強度分布の2次微分値に基づいて当該エッジ強度分布の変曲点を検出し、検出した変曲点におけるエッジ強度を前記エッジ強度閾値として決定することを特徴とする。   Further, in the present invention according to the above invention, in the mask image generation step, the edge intensity distribution is generated using the edge intensity of the input image, and the edge based on the second derivative value of the generated edge intensity distribution. An inflection point of the intensity distribution is detected, and an edge strength at the detected inflection point is determined as the edge strength threshold value.

また、本発明は、上記の発明において、前記エッジ強度が前記エッジ強度閾値以上の画素のうち前記微分値が正である正エッジ画素と前記微分値が負である負エッジ画素との境界領域であって、前記正エッジ画素および前記負エッジ画素の並び順が、1つの線分から得られる前記正エッジ画素および前記負エッジ画素の並び順とは逆である境界領域を谷領域として抽出し、抽出した谷領域に位置する前記マスク画像の有効画素を無効画素と置き換える無効化工程をさらに含んだことを特徴とする。   Further, the present invention is the above invention, wherein a boundary region between a positive edge pixel having a positive differential value and a negative edge pixel having a negative differential value among the pixels having the edge intensity equal to or higher than the edge intensity threshold. A boundary region in which the arrangement order of the positive edge pixels and the negative edge pixels is opposite to the arrangement order of the positive edge pixels and the negative edge pixels obtained from one line segment is extracted as a valley region and extracted. The method further includes a disabling step of replacing the effective pixel of the mask image located in the valley region with the ineffective pixel.

また、本発明は、上記の発明において、前記エッジ強度が前記エッジ強度閾値以上の画素のうち前記微分値が正である正エッジ画素と前記微分値が負である負エッジ画素との境界領域であって、前記正エッジ画素および前記負エッジ画素の並び順が、1つの線分から得られる前記正エッジ画素および前記負エッジ画素の並び順と同じである境界領域を山領域として抽出し、抽出した山領に位置する前記マスク画像の無効画素を有効画素と置き換える有効化工程をさらに含んだことを特徴とする。   Further, the present invention is the above invention, wherein a boundary region between a positive edge pixel having a positive differential value and a negative edge pixel having a negative differential value among the pixels having the edge intensity equal to or higher than the edge intensity threshold. A boundary region in which the arrangement order of the positive edge pixels and the negative edge pixels is the same as the arrangement order of the positive edge pixels and the negative edge pixels obtained from one line segment is extracted and extracted as a mountain region The method further includes a validation step of replacing invalid pixels of the mask image located in the mountain area with valid pixels.

また、本発明は、上記の発明において、前記閾値決定工程は、前記個別領域の輝度分布において最も高輝度側に位置する山部と当該山部に隣接する他の山部とによって形成される谷部における輝度値を前記2値化閾値として決定することを特徴とする。   Also, in the present invention according to the above invention, the threshold value determining step is a valley formed by a peak portion located on the highest brightness side in the brightness distribution of the individual region and another peak portion adjacent to the peak portion. The luminance value in the unit is determined as the binarization threshold value.

また、本発明は、入力画像を2値化する画像2値化装置であって、前記入力画像の微分値の絶対値であるエッジ強度を求めるとともに、当該エッジ強度が所定のエッジ強度閾値以上の画素を有効画素とし前記エッジ強度閾値未満の画素を無効画素とした2値のマスク画像を生成するマスク画像生成手段と、前記マスク画像の有効画素に対応する画素を前記入力画像から抽出することによって型抜き画像を生成する型抜き手段と、前記マスク画像の有効画素を連続領域ごとに区分けする区分け手段と、前記連続領域に対応する前記型抜き画像の個別領域ごとに、当該個別領域の輝度分布に基づいて2値化閾値を決定する閾値決定手段と、前記個別領域ごとに、前記閾値決定手段によって決定された2値化閾値を用いて当該個別領域に含まれる画素を2値化する2値化手段とを備えたことを特徴とする。   The present invention is also an image binarization device that binarizes an input image, and obtains an edge strength that is an absolute value of a differential value of the input image, and the edge strength is equal to or greater than a predetermined edge strength threshold value. A mask image generating means for generating a binary mask image in which a pixel is an effective pixel and a pixel less than the edge intensity threshold is an invalid pixel, and a pixel corresponding to the effective pixel of the mask image is extracted from the input image A die cutting unit for generating a die cut image, a sorting unit for dividing the effective pixels of the mask image into continuous regions, and a luminance distribution of the individual region for each individual region of the die cut image corresponding to the continuous region And a threshold value determining means for determining a binarization threshold value based on the image, and for each individual area, an image included in the individual area using the binarization threshold value determined by the threshold value determining means. Characterized in that a and a binarizing means for binarizing.

本発明によれば、入力画像の微分値の絶対値であるエッジ強度を求めるとともに、当該エッジ強度が所定のエッジ強度閾値以上の画素を有効画素としエッジ強度閾値未満の画素を無効画素とした2値のマスク画像を生成し、マスク画像の有効画素に対応する画素を入力画像から抽出することによって型抜き画像を生成し、マスク画像の有効画素を連続領域ごとに区分けし、連続領域に対応する型抜き画像の個別領域ごとに、当該個別領域の輝度分布に基づいて2値化閾値を決定し、個別領域ごとに、2値化閾値を用いて当該個別領域に含まれる画素を2値化することとしたため、入力画像の罫線や文字あるいは背景に多様な濃淡差がある場合であっても適切な2値画像を得ることができるという効果を奏する。   According to the present invention, the edge intensity, which is the absolute value of the differential value of the input image, is obtained, and pixels having the edge intensity equal to or higher than the predetermined edge intensity threshold are effective pixels, and pixels having the edge intensity less than the edge intensity threshold are invalid pixels A mask image of values is generated, a die cut image is generated by extracting pixels corresponding to effective pixels of the mask image from the input image, and effective pixels of the mask image are divided into continuous regions, and corresponding to the continuous regions. For each individual area of the die-cut image, a binarization threshold is determined based on the luminance distribution of the individual area, and the pixels included in the individual area are binarized using the binarization threshold for each individual area. Therefore, there is an effect that an appropriate binary image can be obtained even when there are various shade differences in the ruled lines, characters, or background of the input image.

また、本発明によれば、入力画像のエッジ強度を用いてエッジ強度分布を生成するとともに、生成したエッジ強度分布の2次微分値に基づいて当該エッジ強度分布の変曲点を検出し、検出した変曲点におけるエッジ強度をエッジ強度閾値として決定することとしたため、罫線・文字領域と背景領域とを適切に分離することができるという効果を奏する。   Further, according to the present invention, an edge intensity distribution is generated using the edge intensity of the input image, and an inflection point of the edge intensity distribution is detected based on the second derivative value of the generated edge intensity distribution, and the detection is performed. Since the edge strength at the inflection point is determined as the edge strength threshold, the ruled line / character region and the background region can be appropriately separated.

また、本発明によれば、エッジ強度がエッジ強度閾値以上の画素のうち前記微分値が正である正エッジ画素と前記微分値が負である負エッジ画素との境界領域であって、正エッジ画素および負エッジ画素の並び順が、1つの線分から得られる正エッジ画素および負エッジ画素の並び順とは逆である境界領域を谷領域として抽出し、抽出した谷領域に位置するマスク画像の有効画素を無効画素と置き換えることとしたため、マスク画像において結合してしまった罫線や文字同士を適切に分離することができるという効果を奏する。   Further, according to the present invention, a boundary region between a positive edge pixel having a positive differential value and a negative edge pixel having a negative differential value among pixels having an edge strength equal to or greater than an edge strength threshold, the positive edge A boundary region in which the arrangement order of pixels and negative edge pixels is opposite to the arrangement order of positive edge pixels and negative edge pixels obtained from one line segment is extracted as a valley region, and a mask image located in the extracted valley region is extracted. Since the effective pixels are replaced with the invalid pixels, the ruled lines and characters combined in the mask image can be appropriately separated from each other.

また、本発明によれば、エッジ強度がエッジ強度閾値以上の画素のうち前記微分値が正である正エッジ画素と前記微分値が負である負エッジ画素との境界領域であって、正エッジ画素および負エッジ画素の並び順が、1つの線分から得られる正エッジ画素および負エッジ画素の並び順と同じである境界領域を山領域として抽出し、抽出した山領に位置するマスク画像の無効画素を有効画素と置き換えることとしたため、マスク画像において分離してしまった1つの罫線や文字を適切に結合することができるという効果を奏する。   Further, according to the present invention, a boundary region between a positive edge pixel having a positive differential value and a negative edge pixel having a negative differential value among pixels having an edge strength equal to or greater than an edge strength threshold, the positive edge A boundary area in which the arrangement order of pixels and negative edge pixels is the same as the arrangement order of positive edge pixels and negative edge pixels obtained from one line segment is extracted as a mountain area, and the invalid pixel of the mask image located in the extracted mountain area Is replaced with an effective pixel, so that one ruled line or character separated in the mask image can be appropriately combined.

また、本発明によれば、個別領域の輝度分布において最も高輝度側に位置する山部と当該山部に隣接する他の山部とによって形成される谷部における輝度値を2値化閾値として決定することとしたため、型抜き工程において除去しきれなかった背景領域を2値化工程において確実に除去することができるという効果を奏する。   Further, according to the present invention, the luminance value in the valley formed by the peak located on the highest brightness side in the luminance distribution of the individual area and the other peak adjacent to the peak is used as the binarization threshold. Since the determination is made, the background area that could not be removed in the die cutting process can be surely removed in the binarization process.

図1は、本発明に係る画像2値化手法の概要を示す図である。FIG. 1 is a diagram showing an overview of an image binarization method according to the present invention. 図2は、本実施例に係る画像2値化装置の構成を示すブロック図である。FIG. 2 is a block diagram illustrating the configuration of the image binarization apparatus according to the present embodiment. 図3は、マスク画像生成処理の処理手順を示す図である。FIG. 3 is a diagram illustrating a processing procedure of mask image generation processing. 図4は、エッジ強度閾値決定処理の説明図である。FIG. 4 is an explanatory diagram of edge strength threshold value determination processing. 図5は、マスク画像修正処理の説明図である。FIG. 5 is an explanatory diagram of the mask image correction process. 図6は、閾値決定処理の説明図である。FIG. 6 is an explanatory diagram of the threshold value determination process. 図7は、画像2値化装置が実行する処理手順を示すフローチャートである。FIG. 7 is a flowchart showing a processing procedure executed by the image binarization apparatus. 図8は、マスク画像修正処理の他の処理手順を示すフローチャートである。FIG. 8 is a flowchart showing another processing procedure of the mask image correction process.

以下に、添付図面を参照して、本発明に係る画像2値化方法および画像2値化装置の好適な実施例を詳細に説明する。   Exemplary embodiments of an image binarization method and an image binarization apparatus according to the present invention will be described below in detail with reference to the accompanying drawings.

まず、実施例の詳細な説明に先立って、本発明に係る画像2値化手法の概要について図1を用いて説明する。図1は、本発明に係る画像2値化手法の概要を示す図である。なお、同図の(A)には、従来の画像2値化手法によって得られる2値画像の一例を、同図の(B)には、本発明に係る画像2値化手法の概要を、それぞれ示している。   First, prior to detailed description of the embodiment, an outline of an image binarization method according to the present invention will be described with reference to FIG. FIG. 1 is a diagram showing an overview of an image binarization method according to the present invention. Note that (A) in the figure shows an example of a binary image obtained by a conventional image binarization technique, and (B) in the figure shows an outline of the image binarization technique according to the present invention. Each is shown.

図1の(A)に示したように、従来の画像2値化手法では、たとえば入力画像の輝度分布に基づいて1つの2値化閾値を決定し、決定した2値化閾値を入力画像全体に適用して2値画像を生成していた。   As shown in FIG. 1A, in the conventional image binarization method, for example, one binarization threshold is determined based on the luminance distribution of the input image, and the determined binarization threshold is used for the entire input image. To generate a binary image.

このため、従来の画像2値化手法では、入力画像の背景に濃淡差がある場合に(図1の(A−1)参照)、濃い背景部分が2値画像において残ってしまうおそれがあり(図1の(A−2)参照)、適切な2値画像を得ることが困難であった。また、かかる背景部分を除外するために2値化閾値を高めに設定すると、背景部分とともに罫線や文字まで消えてしまうおそれもあった。   For this reason, in the conventional image binarization method, when there is a difference in density in the background of the input image (see (A-1) in FIG. 1), there is a possibility that a dark background portion may remain in the binary image ( It was difficult to obtain an appropriate binary image (see (A-2) in FIG. 1). Also, if the binarization threshold is set high to exclude such background portions, there is a risk that even the ruled lines and characters will disappear together with the background portions.

そこで、本発明に係る画像2値化手法では、所定のマスク画像を用いて入力画像から罫線領域および文字領域(以下、「罫線・文字領域」と記載する)を抽出する(すなわち、背景領域を除外する)型抜きを行う。そして、型抜きによって得られた型抜き画像を個別領域へ区分けしたうえで、個別領域ごとに2値化閾値を決定することとした。   Therefore, in the image binarization method according to the present invention, a ruled line region and a character region (hereinafter referred to as “ruled line / character region”) are extracted from an input image using a predetermined mask image (that is, a background region is extracted). Exclude) Die cutting. Then, after dividing the die-cut image obtained by die-cutting into individual regions, the binarization threshold is determined for each individual region.

まず、本発明に係る画像2値化手法では、図1の(B)に示したように、入力画像のエッジ強度に基づいてマスク画像を生成する(同図の(B−1)参照)。   First, in the image binarization method according to the present invention, as shown in FIG. 1B, a mask image is generated based on the edge strength of the input image (see (B-1) in FIG. 1).

具体的には、本発明に係る画像2値化手法では、ソーベルフィルタ等の微分フィルタを用いて入力画像の微分値を求め、この微分値の絶対値であるエッジ強度を求める。そして、本発明に係る画像2値化手法では、エッジ強度が所定のエッジ強度閾値以上の画素を有効画素(白画素)とし、エッジ強度閾値未満の画素を無効画素(黒画素)とする2値のマスク画像を生成する。   Specifically, in the image binarization method according to the present invention, a differential value of an input image is obtained using a differential filter such as a Sobel filter, and an edge strength which is an absolute value of the differential value is obtained. In the image binarization method according to the present invention, a binary image in which a pixel having an edge strength equal to or higher than a predetermined edge strength threshold is set as an effective pixel (white pixel) and a pixel having an edge strength lower than the edge strength threshold is set as an invalid pixel (black pixel). A mask image is generated.

これにより、背景領域と比較してエッジ強度の大きい罫線・文字領域が白画素であらわされ、罫線・文字領域と比較してエッジ強度の小さい背景部分が黒画素であらわされたマスク画像を得ることができる。   This makes it possible to obtain a mask image in which ruled lines / character areas having higher edge strength compared to the background area are represented by white pixels, and background portions having lower edge strength compared to the ruled lines / character areas are represented by black pixels. Can do.

なお、かかるマスク画像は、入力画像の罫線や文字を膨張させたような画像となる。これは、微分フィルタが、注目画素およびその周囲の画素の画素値を用いてエッジ強度を求めるものであり、罫線や文字を構成する画素の画素値がその周囲の画素のエッジ強度に影響を及ぼすためである。   Such a mask image is an image obtained by expanding ruled lines and characters of the input image. This is because the differential filter obtains the edge strength using the pixel values of the pixel of interest and the surrounding pixels, and the pixel values of the pixels constituting the ruled line and the character influence the edge strength of the surrounding pixels. Because.

つづいて、本発明に係る画像2値化手法では、生成したマスク画像を用いて入力画像の型抜きを行う(図1の(B−2)参照)。具体的には、マスク画像の有効画素(白画素)に対応する画素を入力画像から抽出する。   Subsequently, in the image binarization method according to the present invention, the input image is die-cut using the generated mask image (see (B-2) in FIG. 1). Specifically, pixels corresponding to effective pixels (white pixels) of the mask image are extracted from the input image.

これにより、入力画像から罫線・文字領域を抜き出した(言い換えれば、入力画像から背景領域が除去された)型抜き画像が得られる。ただし、上述したように、入力画像の罫線や文字よりもマスク画像の罫線や文字の方が太いため、実際には、罫線や文字だけでなくその周囲の背景も抜き出されることとなる。   Thereby, a die-cut image obtained by extracting the ruled line / character region from the input image (in other words, the background region is removed from the input image) is obtained. However, as described above, since the ruled lines and characters of the mask image are thicker than the ruled lines and characters of the input image, actually, not only the ruled lines and characters but also the surrounding background are extracted.

つづいて、本発明に係る画像2値化手法では、マスク画像を連続領域ごとに区分けする(図1の(B−3)参照)。ここで、連続領域とは、マスク画像において有効画素(白画素)が連続している領域である。かかる処理によりマスク画像は、罫線や文字ごとに区分けされる。   Subsequently, in the image binarization method according to the present invention, the mask image is divided into continuous regions (see (B-3) in FIG. 1). Here, the continuous area is an area where effective pixels (white pixels) are continuous in the mask image. With this process, the mask image is divided into ruled lines and characters.

つづいて、本発明に係る画像2値化手法では、マスク画像の連続領域に対応する型抜き画像の個別領域ごとに、かかる個別領域の輝度分布に基づいて2値化閾値を決定する(図1の(B−4)参照)。   Subsequently, in the image binarization method according to the present invention, a binarization threshold value is determined for each individual region of the punched image corresponding to the continuous region of the mask image based on the luminance distribution of the individual region (FIG. 1). (See (B-4)).

具体的には、本発明に係る画像2値化手法では、個別領域の輝度分布において最も高輝度側に位置する山部とかかる山部に隣接する他の山部とによって形成される谷部における輝度値を2値化閾値として決定する。   Specifically, in the image binarization method according to the present invention, in the valley formed by the peak located on the highest brightness side in the luminance distribution of the individual area and the other peak adjacent to the peak. The luminance value is determined as a binarization threshold value.

すなわち、背景色は、罫線や文字の色よりも薄い(すなわち白に近い)のが通常であるので、最も高輝度側(すなわち、白に近い側)に位置する山部が、マスク画像によって除去しきれなかった背景領域の分布に相当すると考えられる。したがって、かかる山部と他の山部との谷部における輝度値を2値化閾値として決定することで、罫線・文字領域と背景領域とを確実に分離することができる。   That is, the background color is usually lighter than the color of the ruled lines and characters (that is, close to white), so that the peak located on the highest luminance side (that is, the side close to white) is removed by the mask image. This is considered to correspond to the distribution of the background area that could not be fully covered. Therefore, the ruled line / character area and the background area can be reliably separated by determining the luminance value at the valley between the peak and the other peak as the binarization threshold.

そして、本発明に係る画像2値化手法では、個別領域ごとに決定した2値化閾値をそれぞれ用いて個別領域ごとに2値化を行う(図1の(B−5)参照)。この結果、従来の2値画像とは異なり、背景領域が確実に除去された2値画像を得ることができる。   In the image binarization method according to the present invention, binarization is performed for each individual region using the binarization threshold values determined for each individual region (see (B-5) in FIG. 1). As a result, unlike the conventional binary image, it is possible to obtain a binary image in which the background area is reliably removed.

このように、本発明に係る画像2値化手法では、入力画像のエッジ強度に基づいてマスク画像を生成するとともに、生成したマスク画像を用いて入力画像の型抜きを行う。また、本発明に係る画像2値化手法では、マスク画像の有効画素を連続領域ごとに区分けし、連続領域に対応する型抜き画像の個別領域ごとに、かかる個別領域の輝度分布に基づいて2値化閾値を決定する。   As described above, in the image binarization method according to the present invention, the mask image is generated based on the edge strength of the input image, and the input image is die-cut using the generated mask image. Further, in the image binarization method according to the present invention, the effective pixels of the mask image are divided into continuous regions, and 2 for each individual region of the die-cut image corresponding to the continuous region based on the luminance distribution of the individual region. A value threshold is determined.

そして、本発明に係る画像2値化手法では、個別領域ごとに決定した2値化閾値をそれぞれ用いて各個別領域を2値化することとした。したがって、本発明に係る画像2値化手法によれば、入力画像の罫線や文字あるいは背景に多様な濃淡差がある場合であっても適切な2値画像を得ることができる。   In the image binarization method according to the present invention, each individual area is binarized using the binarization threshold value determined for each individual area. Therefore, according to the image binarization method according to the present invention, an appropriate binary image can be obtained even when there are various shade differences in the ruled lines, characters, or background of the input image.

なお、本発明に係る画像2値化手法では、背景領域のエッジ強度分布および罫線・文字領域のエッジ強度分布の形状の違いに着目し、入力画像のエッジ強度分布の変曲点におけるエッジ強度をエッジ強度閾値として決定することとしているが、かかる点の詳細については、後述する。   In the image binarization method according to the present invention, the edge strength at the inflection point of the edge strength distribution of the input image is calculated by paying attention to the difference in the shape of the edge strength distribution of the background region and the edge strength distribution of the ruled line / character region. The edge strength threshold is determined, but details of this point will be described later.

また、上述したように、マスク画像では、罫線や文字が入力画像よりも太くなるため、近接する罫線や文字同士が結合してしまう場合がある。また、エッジ強度に基づいてマスク画像を生成するため、1本の線が2本に分離してしまう場合もある。   Further, as described above, in the mask image, the ruled lines and characters are thicker than the input image, so that adjacent ruled lines and characters may be combined. In addition, since a mask image is generated based on the edge strength, one line may be separated into two.

そこで、本発明に係る画像2値化手法では、エッジ強度がエッジ強度閾値以上の画素のうち微分値が正である正エッジ画素と微分値が負である負エッジ画素との境界領域における正エッジ画素および負エッジ画素の並び順に基づき、分離すべき領域(谷領域)および結合すべき領域(山領域)を検出し、検出した谷領域および山領域に基づいてマスク画像を修正することとしている。なお、かかる点についても、後述することとする。   Therefore, in the image binarization method according to the present invention, a positive edge in a boundary region between a positive edge pixel having a positive differential value and a negative edge pixel having a negative differential value among pixels having an edge strength equal to or greater than an edge strength threshold. Based on the arrangement order of the pixels and the negative edge pixels, a region to be separated (valley region) and a region to be combined (mountain region) are detected, and the mask image is corrected based on the detected valley region and mountain region. This point will also be described later.

以下では、図1を用いて説明した画像2値化手法を適用した画像2値化方法および画像2値化装置についての実施例を詳細に説明する。なお、以下では、画像読取装置(たとえば、スキャナ装置)から入力画像を取得する画像2値化装置について説明するが、スキャナ装置を含んだ画像2値化装置を構成することとしてもよい。   Hereinafter, an embodiment of an image binarization method and an image binarization apparatus to which the image binarization method described with reference to FIG. 1 is applied will be described in detail. In the following, an image binarization apparatus that acquires an input image from an image reading apparatus (for example, a scanner apparatus) will be described. However, an image binarization apparatus including a scanner apparatus may be configured.

図2は、本実施例に係る画像2値化装置10の構成を示すブロック図である。なお、同図には、画像2値化装置10の特徴を説明するために必要な構成要素のみを示しており、一般的な構成要素についての記載を省略している。   FIG. 2 is a block diagram illustrating the configuration of the image binarization apparatus 10 according to the present embodiment. In the figure, only components necessary for explaining the characteristics of the image binarization apparatus 10 are shown, and descriptions of general components are omitted.

図2に示すように、画像2値化装置10は、画像読取装置20と接続されており、画像読取装置20が読み取った画像(たとえば、帳票をスキャンした画像)を取得する。なお、画像読取装置20としては、たとえば、いわゆるスキャナ装置を用いることができる。   As shown in FIG. 2, the image binarization apparatus 10 is connected to an image reading apparatus 20, and acquires an image read by the image reading apparatus 20 (for example, an image obtained by scanning a form). For example, a so-called scanner device can be used as the image reading device 20.

画像2値化装置10は、制御部11と、記憶部12とを備えており、制御部11は、マスク画像生成部11aと、マスク画像修正部11bと、型抜き部11cと、ラベリング部11dと、閾値決定部11eと、2値化処理部11fとをさらに備えている。そして、記憶部12は、ラベル情報12aと、閾値情報12bとを記憶する。   The image binarization apparatus 10 includes a control unit 11 and a storage unit 12. The control unit 11 includes a mask image generation unit 11a, a mask image correction unit 11b, a die cutting unit 11c, and a labeling unit 11d. And a threshold value determination unit 11e and a binarization processing unit 11f. Then, the storage unit 12 stores label information 12a and threshold information 12b.

マスク画像生成部11aは、画像読取装置20から入力画像が入力された場合に、入力画像のエッジ強度に基づくマスク画像を生成する処理部である。具体的には、マスク画像生成部11aは、ソーベルフィルタを用いて入力画像からエッジを抽出することによって微分画像を生成し、生成した微分画像を所定のエッジ強度閾値を用いて閾値処理することでマスク画像を生成する。   The mask image generation unit 11 a is a processing unit that generates a mask image based on the edge strength of the input image when the input image is input from the image reading device 20. Specifically, the mask image generation unit 11a generates a differential image by extracting edges from the input image using a Sobel filter, and performs threshold processing on the generated differential image using a predetermined edge intensity threshold value. To generate a mask image.

ここで、マスク画像生成部11aによるマスク画像生成処理の処理手順について図3を用いて説明しておく。図3は、マスク画像生成処理の処理手順を示す図である。   Here, the processing procedure of the mask image generation process by the mask image generation unit 11a will be described with reference to FIG. FIG. 3 is a diagram illustrating a processing procedure of mask image generation processing.

図3に示すように、マスク画像生成部11aは、水平方向および垂直方向のソーベルフィルタを入力画像に対してそれぞれ掛けることにより、微分値を各画素値とする水平方向のエッジ画像および垂直方向の微分画像を生成する(図3の(1)参照)。   As shown in FIG. 3, the mask image generation unit 11a applies a horizontal and vertical Sobel filter to the input image, respectively, so that the horizontal edge image and the vertical direction each having a differential value as a pixel value. The differential image is generated (see (1) in FIG. 3).

なお、本実施例では、微分フィルタの一例としてソーベルフィルタを用いる場合について説明するが、プレヴィットフィルタやラプラシアンフィルタ等のソーベルフィルタ以外のフィルタを微分フィルタとして用いてもよい。   In this embodiment, a case where a Sobel filter is used as an example of a differential filter will be described. However, a filter other than a Sobel filter such as a Previt filter or a Laplacian filter may be used as a differential filter.

つづいて、マスク画像生成部11aは、水平方向および垂直方法のそれぞれの微分画像ごとにエッジ強度閾値を決定する(図3の(2)参照)。なお、かかるエッジ強度閾値決定処理の具体的な内容については、図4を用いて後述することとする。   Subsequently, the mask image generation unit 11a determines an edge intensity threshold value for each differential image in the horizontal direction and the vertical method (see (2) in FIG. 3). The specific contents of the edge strength threshold determination process will be described later with reference to FIG.

つづいて、マスク画像生成部11aは、微分画像ごとに決定したエッジ強度閾値をそれぞれ用いて各微分画像の閾値処理を行う(図3の(3)参照)。   Subsequently, the mask image generation unit 11a performs threshold processing of each differential image using the edge intensity threshold determined for each differential image (see (3) in FIG. 3).

具体的には、マスク画像生成部11aは、微分値の絶対値であるエッジ強度がエッジ強度閾値以上の画素のうち、微分値が負の画素を黒画素(画素値「−1」)とし、微分値が正の画素を白画素(画素値「1」)とする。また、マスク画像生成部11aは、エッジ強度がエッジ強度閾値未満の画素をグレー画素(画素値「0」)とする。これにより、黒、白またはグレーの3色であらわされたエッジ画像が得られる。このように、閾値処理後の微分値画像がエッジ画像となる。   Specifically, the mask image generation unit 11a sets a pixel having a negative differential value as a black pixel (pixel value “−1”) among pixels having an edge strength that is an absolute value of the differential value and an edge strength threshold value or more, A pixel having a positive differential value is defined as a white pixel (pixel value “1”). In addition, the mask image generation unit 11a sets a pixel whose edge strength is less than the edge strength threshold as a gray pixel (pixel value “0”). As a result, an edge image represented by three colors of black, white or gray is obtained. In this way, the differential value image after the threshold processing is an edge image.

そして、マスク画像生成部11aは、エッジ画像の各画素のうち黒画素または白画素を「白画素」へ変換するとともにグレー画素を「黒画素」へ変換したうえで、両エッジ画像を合成することで(図3の(4)参照)、白黒2値のマスク画像を生成する。なお、以下では、マスク画像の白画素を「有効画素」と呼び、黒画素を「無効画素」と呼ぶ場合がある。   Then, the mask image generation unit 11a converts black pixels or white pixels among the pixels of the edge image into “white pixels” and gray pixels into “black pixels”, and then combines the two edge images. (See (4) in FIG. 3), a black and white binary mask image is generated. Hereinafter, the white pixel of the mask image may be referred to as “effective pixel”, and the black pixel may be referred to as “invalid pixel”.

ここで、図3の(2)に示したエッジ強度閾値決定処理について図4を用いて説明する。図4は、エッジ強度閾値決定処理の説明図である。なお、同図では、一例として、水平方向の微分画像についてのエッジ強度閾値決定処理を示している。また、同図の(A)には、水平方向の微分画像の微分値分布を、同図の(B)には、エッジ強度分布の2次微分値に基づいてエッジ強度閾値が決定される様子を、それぞれ示している。なお、エッジ強度分布とは、微分値の絶対値であるエッジ強度の分布である。   Here, the edge strength threshold value determination process shown in (2) of FIG. 3 will be described with reference to FIG. FIG. 4 is an explanatory diagram of edge strength threshold value determination processing. In the figure, as an example, edge strength threshold value determination processing for a differential image in the horizontal direction is shown. Further, (A) in the figure shows the differential value distribution of the differential image in the horizontal direction, and (B) in the figure shows how the edge strength threshold is determined based on the secondary differential value of the edge strength distribution. Respectively. The edge intensity distribution is an edge intensity distribution that is an absolute value of a differential value.

図4の(A)に示したように、入力画像の微分値分布(言い換えると、微分画像の画素値分布)は、なだらかな分布の山の頂点付近(微分値が「0」の近傍)に急峻なピークを有する形状となっている(同図の(A−1)参照)。ここで、かかる微分値分布は、同図の(A−2)に示した背景領域の微分値分布と、同図の(A−3)に示した罫線・文字領域の微分値分布とが合成されていると考えられる。   As shown in FIG. 4A, the differential value distribution of the input image (in other words, the pixel value distribution of the differential image) is in the vicinity of the peak of the gentle distribution peak (near the differential value of “0”). The shape has a steep peak (see (A-1) in the figure). Here, the differential value distribution is composed of the differential value distribution in the background area shown in (A-2) of the figure and the differential value distribution in the ruled line / character area shown in (A-3) of the figure. It is thought that.

具体的には、背景領域の画素は、微分値が「0」のものが圧倒的に多い。これは、背景領域には、エッジが存在しないのが通常であるためである。ただし、汚れ等による微小な濃淡差もあるため、背景領域には微分値が「0」以外の画素もわずかながら存在する。したがって、背景領域のエッジ強度分布は、図4の(A−2)に示したように、微分値「0」を頂点として指数関数的に減少する傾向がある。   Specifically, the pixels in the background area are overwhelmingly those with a differential value of “0”. This is because the background region usually has no edge. However, since there is a slight shading difference due to dirt or the like, there are a small number of pixels having a differential value other than “0” in the background area. Therefore, the edge intensity distribution in the background region tends to decrease exponentially with the differential value “0” as the apex, as shown in FIG.

一方、罫線や文字を構成する画素は、背景領域との濃淡差によってさまざまなエッジ強度を持つこととなる。ただし、背景領域との境界部分では画像ぼけ等によって濃淡変化がなだらなかとなるため、微分値「0」近傍の値を持つ画素が相対的に多くなる。したがって、罫線・文字領域の微分値分布は、図4の(A−3)に示したように、微分値「0」を頂点としてなだらかに減少する傾向がある。   On the other hand, the pixels constituting the ruled lines and characters have various edge strengths depending on the difference in density from the background area. However, since the change in density becomes gentle due to image blurring or the like at the boundary with the background area, the number of pixels having a value near the differential value “0” is relatively large. Accordingly, the differential value distribution in the ruled line / character region tends to decrease gently with the differential value “0” as a vertex, as shown in FIG.

そこで、マスク画像生成部11aは、微分画像のエッジ強度分布の変曲点を検出し、検出した変曲点におけるエッジ強度をエッジ強度閾値とすることで、背景領域および罫線・文字領域を分離することとした。   Therefore, the mask image generation unit 11a detects an inflection point of the edge intensity distribution of the differential image, and uses the edge intensity at the detected inflection point as an edge intensity threshold, thereby separating the background area and the ruled line / character area. It was decided.

具体的には、マスク画像生成部11aは、図4の(B)に示したように、エッジ画像の微分値の絶対値であるエッジ強度の分布を取ることで、エッジ強度を階級値とするエッジ強度分布を生成する。   Specifically, as shown in FIG. 4B, the mask image generation unit 11a takes the edge strength as the class value by taking the distribution of the edge strength that is the absolute value of the differential value of the edge image. Generate an edge strength distribution.

また、マスク画像生成部11aは、かかるエッジ強度分布の1次微分値を求める。また、マスク画像生成部11aは、反転後の1次微分値をさらに1次微分することによってエッジ強度分布の2次微分値を得る。なお、図4の(B)では、1次微分値に対して「−1」を掛けて正負を反転させたものを示している。   Further, the mask image generation unit 11a obtains a primary differential value of the edge intensity distribution. In addition, the mask image generation unit 11a obtains a secondary differential value of the edge intensity distribution by further performing primary differentiation of the inverted primary differential value. In FIG. 4B, the positive / negative is inverted by multiplying the primary differential value by “−1”.

なお、図4の(B)に示したエッジ強度分布の左側の縦軸は「画素数」であり、「●」印でプロットされた分布の度数をあらわしている。また、同エッジ強度分布の右側の縦軸は「微分値」であり、「▲」印でプロットされた分布および「■」印でプロットされた分布の度数をあらわしている。   The vertical axis on the left side of the edge intensity distribution shown in FIG. 4B is the “number of pixels”, and represents the frequency of the distribution plotted with “●” marks. In addition, the vertical axis on the right side of the edge intensity distribution is “differential value”, and represents the frequency of the distribution plotted with “▲” and the distribution plotted with “■”.

つづいて、マスク画像生成部11aは、エッジ強度分布の2次微分値の正負が変わる点(ゼロクロス点)を変曲点として検出する。具体的には、マスク画像生成部11aは、正負が変わる前後の各2次微分値(プロット値)を結ぶ直線と微分値「0」との交点を変曲点として検出する。そして、マスク画像生成部11aは、検出した変曲点におけるエッジ強度をエッジ強度閾値として決定する。   Subsequently, the mask image generation unit 11a detects, as an inflection point, a point (zero cross point) at which the sign of the secondary differential value of the edge intensity distribution changes. Specifically, the mask image generation unit 11a detects, as an inflection point, an intersection between a straight line connecting the respective secondary differential values (plot values) before and after the change of positive and negative and the differential value “0”. Then, the mask image generation unit 11a determines the edge strength at the detected inflection point as the edge strength threshold.

このように、マスク画像生成部11aは、入力画像のエッジ強度を用いてエッジ強度分布を生成するとともに、生成したエッジ強度分布の2次微分値に基づいて当該エッジ強度分布の変曲点を検出し、検出した変曲点におけるエッジ強度をエッジ強度閾値として決定する。したがって、罫線・文字領域と背景領域とが適切に分離されたマスク画像を得ることができる。   As described above, the mask image generation unit 11a generates an edge intensity distribution using the edge intensity of the input image, and detects an inflection point of the edge intensity distribution based on the second derivative value of the generated edge intensity distribution. Then, the edge strength at the detected inflection point is determined as the edge strength threshold. Therefore, it is possible to obtain a mask image in which the ruled line / character area and the background area are appropriately separated.

また、本実施例では、背景領域のエッジ強度分布および罫線・文字領域のエッジ強度分布の形状の違いに着目してエッジ強度閾値を決定することとした。したがって、図4の(A)に示したように、2つの分布が重なっている場合であっても、背景領域と罫線・文字領域とを適切に分離することができる。   In this embodiment, the edge strength threshold is determined by paying attention to the difference in the shape of the edge strength distribution of the background region and the edge strength distribution of the ruled line / character region. Therefore, as shown in FIG. 4A, the background area and the ruled line / character area can be appropriately separated even when the two distributions overlap.

なお、ここでは、ゼロクロス点を変曲点として検出する場合について説明したが、これに限ったものではない。たとえば、正負が変わった直前または直後のプロット値を変曲点として検出してもよい。このようにすれば、ゼロクロス点を算出する必要がなくなるため、変曲点の検出に要する処理負荷を低減することができる。また、移動平均等により平滑化した値を用いて変曲点を検出することとすれば、ノイズの影響が除外されるため、変曲点をより適切に検出することができる。   Although the case where the zero cross point is detected as the inflection point has been described here, the present invention is not limited to this. For example, the plot value immediately before or after the change of positive / negative may be detected as the inflection point. In this way, it is not necessary to calculate the zero cross point, so that the processing load required for detecting the inflection point can be reduced. Further, if the inflection point is detected using a value smoothed by a moving average or the like, the influence of noise is excluded, so that the inflection point can be detected more appropriately.

また、ここでは、水平方向のエッジ画像についてのエッジ強度閾値決定処理について説明したが、垂直方向のエッジ画像についても同様の手順でエッジ強度閾値を決定することができる。また、マスク画像生成部11aは、マスク画像を生成すると、生成したマスク画像をエッジ画像とともにマスク画像修正部11bへ渡す処理を行う。   Although the edge strength threshold value determination process for the horizontal edge image has been described here, the edge strength threshold value can be determined for the vertical edge image in the same procedure. Further, when the mask image generation unit 11a generates a mask image, the mask image generation unit 11a performs a process of passing the generated mask image together with the edge image to the mask image correction unit 11b.

図2の説明に戻り、マスク画像修正部11bについて説明する。マスク画像修正部11bは、エッジ画像を用いてマスク画像の修正を行う処理部である。   Returning to the description of FIG. 2, the mask image correcting unit 11b will be described. The mask image correction unit 11b is a processing unit that corrects a mask image using an edge image.

ここで、マスク画像修正部11bによるマスク画像修正処理について図5を用いて説明する。図5は、マスク画像修正処理の説明図である。なお、同図の(A)には、マスク画像の修正すべき箇所を、同図の(B)には、マスク画像修正処理の動作例を、同図の(C)には、谷画像および山画像による修正後のマスク画像の一例を、それぞれ示している。   Here, the mask image correction process by the mask image correction unit 11b will be described with reference to FIG. FIG. 5 is an explanatory diagram of the mask image correction process. Note that (A) in the figure shows the portion to be corrected of the mask image, (B) in the figure shows an example of the operation of the mask image correction processing, and (C) in the figure shows the valley image and An example of a mask image after correction using a mountain image is shown.

図5の(A−1)に示したように、入力画像において2つの線が近接している場合、エッジ画像では、一方の線から得られるエッジ画素のうち正のエッジ強度を持つ正エッジ画素(白画素)が、他方の線から得られるエッジ画素のうち負のエッジ強度を持つ負エッジ画素(黒画素)と接することがある。このような場合、マスク画像では、これら2つの線が1本の線としてあらわされることとなる。   As shown in FIG. 5A-1, when two lines are close to each other in the input image, in the edge image, a positive edge pixel having a positive edge strength among edge pixels obtained from one line. (White pixel) may be in contact with a negative edge pixel (black pixel) having a negative edge strength among edge pixels obtained from the other line. In such a case, in the mask image, these two lines are expressed as one line.

また、図5の(A−2)に示したように、入力画像中に太い線が存在する場合、エッジ画像では、かかる線から得られる正エッジ画素(白画素)および負エッジ画素(黒画素)が離れる場合がある。このような場合、マスク画像では、1本の線が2本線としてあらわされることとなる。   Further, as shown in FIG. 5A-2, when a thick line exists in the input image, in the edge image, a positive edge pixel (white pixel) and a negative edge pixel (black pixel) obtained from the line. ) May leave. In such a case, one line is represented as two lines in the mask image.

そこで、マスク画像修正部11bは、異なる線からそれぞれ得られる正エッジ画素および負エッジ画素間の境界(図5の(A−1)に示した「谷」)を検出し、かかる谷を含んだ谷領域に位置するマスク画像の白画素を黒画素へ置き換えることで、1つに結合した線を本来の2本線に修正する。   Therefore, the mask image correcting unit 11b detects the boundary between the positive edge pixel and the negative edge pixel obtained from different lines (“valley” shown in FIG. 5A-1), and includes such a valley. By replacing the white pixels of the mask image located in the valley area with black pixels, the combined line is corrected to the original two lines.

また、マスク画像修正部11bは、1つの線から得られる正エッジ画素および負エッジ画素間の境界(図5の(A−2)に示した「山」)を検出し、かかる山を含んだ山領域に位置するマスク画像上の黒画素を白画素へ置き換えることで、2本に分離した線を本来の1本線に修正する。   Further, the mask image correcting unit 11b detects the boundary between the positive edge pixel and the negative edge pixel obtained from one line (“mountain” shown in FIG. 5A-2), and includes such a mountain. By replacing black pixels on the mask image located in the mountain area with white pixels, the line separated into two lines is corrected to the original single line.

具体的には、図5の(B)に示したように、マスク画像修正部11bは、エッジ画像を所定の走査方向(ここでは、右方向)に向かって1画素ずつ走査していき、白画素から黒画素へ変化している境界である谷を検出する。そして、マスク画像修正部11bは、谷を検出すると、検出した谷の両側に位置する白画素および黒画素を含んだ領域を谷領域として抽出する(同図の(B−1)参照)。   Specifically, as shown in FIG. 5B, the mask image correcting unit 11b scans the edge image pixel by pixel in a predetermined scanning direction (in this case, the right direction), and white A valley which is a boundary changing from a pixel to a black pixel is detected. And the mask image correction part 11b will extract the area | region containing the white pixel and black pixel which are located in the both sides of the detected trough as a trough area | region, if a trough is detected (refer (B-1) of the figure).

同様に、マスク画像修正部11bは、黒画素から白画素へ変化している境界である山を検出すると、検出した山の両側に位置する黒画素および白画素を含んだ領域を山領域として抽出する(図5の(B−2)参照)。   Similarly, when the mask image correcting unit 11b detects a mountain which is a boundary changing from a black pixel to a white pixel, the mask image correcting unit 11b extracts a region including the black pixel and the white pixel located on both sides of the detected mountain as a mountain region. (Refer to (B-2) in FIG. 5).

また、マスク画像修正部11bは、黒画素および白画素が隣接している領域だけでなく、黒画素および白画素がグレー画素を介して所定の幅閾値(ここでは、8画素)以内で近接している領域も谷領域や山領域として抽出する。たとえば、マスク画像修正部11bは、黒画素からグレー画素を1画素介して白画素へ変化している場合には、これら黒画素、グレー画素および白画素を含んだ領域を山領域として抽出する(図5の(B−3)参照)。   In addition, the mask image correcting unit 11b not only has a region where the black pixel and the white pixel are adjacent to each other, but also the black pixel and the white pixel are close to each other within a predetermined width threshold (here, 8 pixels) via the gray pixel. Are also extracted as valley regions and mountain regions. For example, when the black pixel changes from a black pixel to a white pixel through one pixel, the mask image correcting unit 11b extracts the region including the black pixel, the gray pixel, and the white pixel as a mountain region ( (See (B-3) in FIG. 5).

なお、マスク画像修正部11bは、白画素および黒画素がグレー画素を介して所定の幅閾値以上離れている場合には、かかる領域を谷領域または山領域として検出しない(図5の(B−4)参照)。また、ここでは、水平方向のエッジ画像から谷領域および山領域を抽出する場合のみを示しているが、垂直方向のエッジ画像からも同様に谷領域および山領域を抽出する。   Note that the mask image correcting unit 11b does not detect such a region as a valley region or a mountain region when the white pixel and the black pixel are separated by a predetermined width threshold or more via the gray pixel ((B- in FIG. 5). 4)). Further, here, only the case where the valley region and the mountain region are extracted from the edge image in the horizontal direction is shown, but the valley region and the mountain region are similarly extracted from the edge image in the vertical direction.

つづいて、マスク画像修正部11bは、抽出した谷領域を黒画素(無効画素)としその他の領域を白画素(有効画素)とした谷画像を生成する。同様に、マスク画像修正部11bは、抽出した山領域を白画素(有効画素)としその他の領域を黒画素(無効画素)とした山画像を生成する。   Subsequently, the mask image correction unit 11b generates a valley image in which the extracted valley region is a black pixel (invalid pixel) and the other region is a white pixel (effective pixel). Similarly, the mask image correcting unit 11b generates a mountain image in which the extracted mountain area is a white pixel (effective pixel) and the other area is a black pixel (invalid pixel).

そして、マスク画像修正部11bは、谷画像の黒画素(無効画素)に対応するマスク画像の白画素(有効画素)を黒画素(無効画素)へ置き換える。すなわち、マスク画像に谷画像を重ね合わせて、谷画像の黒い部分に位置するマスク画像の白い部分を黒に置き換える。これにより、図5の(C)に示したように、異なる線同士の境界部分が黒画素となり、結合してしまった罫線や文字同士が分離される。   Then, the mask image correcting unit 11b replaces the white pixel (effective pixel) of the mask image corresponding to the black pixel (invalid pixel) of the valley image with the black pixel (invalid pixel). That is, the valley image is superimposed on the mask image, and the white portion of the mask image located in the black portion of the valley image is replaced with black. As a result, as shown in FIG. 5C, the boundary portion between different lines becomes a black pixel, and the ruled lines and characters that have been combined are separated.

また、マスク画像修正部11bは、山画像の白画素(有効画素)に対応するマスク画像の黒画素(無効画素)を白画素(有効画素)へ置き換える。これにより、図5の(C)に示したように、本来ならば1つの線であるべき2本線の境界部分が白画素となり、分離してしまった1つの罫線や文字が結合される。   Further, the mask image correcting unit 11b replaces the black pixel (invalid pixel) of the mask image corresponding to the white pixel (effective pixel) of the mountain image with a white pixel (effective pixel). As a result, as shown in FIG. 5C, the boundary portion of the two lines that should be one line becomes a white pixel, and one separated ruled line or character is combined.

つまり、谷画像や山画像を用いてマスク画像を修正することによって、後述するラベリング処理を適切に行うことが可能となる。   That is, by correcting the mask image using the valley image or the mountain image, it becomes possible to appropriately perform the labeling process described later.

このように、マスク画像修正部11bは、正エッジ画素(白画素)と負エッジ画素(黒画素)との境界領域であって、正エッジ画素および負エッジ画素の並び順が、1つの線分から得られる正エッジ画素および負エッジ画素の並び順とは逆である境界領域を谷領域として抽出する。また、マスク画像修正部11bは、抽出した谷領域に位置するマスク画像の有効画素(白画素)を無効画素(黒画素)と置き換える。したがって、マスク画像において結合してしまった罫線や文字同士を適切に分離することができる。   As described above, the mask image correcting unit 11b is a boundary region between the positive edge pixel (white pixel) and the negative edge pixel (black pixel), and the arrangement order of the positive edge pixel and the negative edge pixel is determined from one line segment. A boundary region that is opposite to the arrangement order of the obtained positive edge pixels and negative edge pixels is extracted as a valley region. Further, the mask image correcting unit 11b replaces the effective pixel (white pixel) of the mask image located in the extracted valley region with the invalid pixel (black pixel). Therefore, ruled lines and characters that have been combined in the mask image can be appropriately separated.

また、マスク画像修正部11bは、正エッジ画素(白画素)と負エッジ画素(黒画素)との境界領域であって、正エッジ画素および負エッジ画素の並び順が、1つの線分から得られる正エッジ画素および負エッジ画素の並び順と同じである境界領域を山領域として抽出する。また、マスク画像修正部11bは、抽出した山領に位置するマスク画像の無効画素(黒画素)を有効画素(白画素)と置き換える。したがって、マスク画像において分離してしまった1つの罫線や文字を適切に結合することができる。   The mask image correcting unit 11b is a boundary region between the positive edge pixel (white pixel) and the negative edge pixel (black pixel), and the arrangement order of the positive edge pixel and the negative edge pixel can be obtained from one line segment. A boundary region having the same arrangement order of positive edge pixels and negative edge pixels is extracted as a mountain region. In addition, the mask image correcting unit 11b replaces the invalid pixel (black pixel) of the extracted mask image located in the mountain area with the effective pixel (white pixel). Therefore, it is possible to appropriately combine one ruled line or character that has been separated in the mask image.

なお、マスク画像修正部11bは、修正後のマスク画像を型抜き部11cおよびラベリング部11dへ渡す処理を併せて行う。   The mask image correcting unit 11b also performs a process of passing the corrected mask image to the die cutting unit 11c and the labeling unit 11d.

図2の説明に戻り、型抜き部11cについて説明する。型抜き部11cは、マスク画像修正部11bから修正後のマスク画像(以下、単に「マスク画像」と記載する)を受け取った場合に、受け取ったマスク画像を用いて入力画像の型抜きを行う処理部である。具体的には、型抜き部11cは、マスク画像の有効画素(白画素)に対応する画素を入力画像から抽出することによって型抜き画像を生成する処理を行う。   Returning to the description of FIG. 2, the die cutting portion 11 c will be described. When the die cutting unit 11c receives a corrected mask image (hereinafter simply referred to as “mask image”) from the mask image correcting unit 11b, the die cutting unit 11c performs die cutting of the input image using the received mask image. Part. Specifically, the die cutting unit 11c performs a process of generating a die cutting image by extracting pixels corresponding to effective pixels (white pixels) of the mask image from the input image.

また、型抜き部11cは、型抜き画像を生成すると、生成した型抜き画像を閾値決定部11eおよび2値化処理部11fへ渡す処理を併せて行う。   Further, when the die cutting unit 11c generates a die cutting image, the die cutting unit 11c also performs a process of passing the generated die cutting image to the threshold value determination unit 11e and the binarization processing unit 11f.

ラベリング部11dは、マスク画像修正部11bからマスク画像を受け取った場合に、受け取ったマスク画像の有効画素を連続領域ごとに区分けするラベリング処理を行う処理部である。これにより、マスク画像は、罫線ごとあるいは文字ごとに区分けされる。   The labeling unit 11d is a processing unit that performs a labeling process that divides the effective pixels of the received mask image into continuous regions when the mask image is received from the mask image correction unit 11b. Thereby, the mask image is divided for each ruled line or for each character.

また、ラベリング部11dは、ラベリング処理を完了すると、各連続領域の位置情報をラベル情報12aとして記憶部12へ記憶させる。   Moreover, the labeling part 11d will memorize | store the positional information on each continuous area | region in the memory | storage part 12 as label information 12a, if a labeling process is completed.

閾値決定部11eは、型抜き部11cから型抜き画像を受け取った場合に、マスク画像の各連続領域に対応する型抜き画像の個別領域をラベル情報12aに基づいて特定し、特定した個別領域ごとに2値化閾値を決定する処理部である。具体的には、閾値決定部11eは、個別領域の輝度分布を生成し、生成した輝度分布に基づいて2値化閾値を決定する処理を行う。   When the threshold determination unit 11e receives a die-cut image from the die-cutting unit 11c, the threshold determination unit 11e specifies an individual region of the die-cut image corresponding to each continuous region of the mask image based on the label information 12a. Is a processing unit for determining a binarization threshold. Specifically, the threshold determination unit 11e performs a process of generating a luminance distribution of the individual area and determining a binarization threshold based on the generated luminance distribution.

ここで、閾値決定部11eによる閾値決定処理について図6を用いて説明する。図6は、閾値決定処理の説明図である。なお、同図の(A−1)には、入力画像の一例を、同図の(A−2)には、入力画像から生成されるマスク画像を、同図の(A−3)には、入力画像上にマスク画像を重ね合わせた図を、同図の(A−4)には、入力画像の2値画像をそれぞれ示している。また、同図の(B)には、個別領域の輝度分布の一例を、それぞれ示している。   Here, the threshold value determination process by the threshold value determination unit 11e will be described with reference to FIG. FIG. 6 is an explanatory diagram of the threshold value determination process. Note that (A-1) in the figure shows an example of the input image, (A-2) in the figure shows a mask image generated from the input image, and (A-3) in the figure shows. The figure in which the mask image is superimposed on the input image is shown in (A-4) of FIG. Further, (B) in the figure shows an example of the luminance distribution of the individual area.

図6の(A−2)に示したマスク画像を用いて同図の(A−1)に示した入力画像を型抜きすると、同図の(A−3)の領域200aや領域200bに示したように、入力画像の罫線や文字とともに周囲の背景も抜き出されることとなる。これは、マスク画像では、罫線や文字が入力画像よりも太く、背景を完全に除去しきれないためである。なお、同図の(A−3)に示した領域200aは、同図の(A−2)に示した連続領域100aに対応する型抜き画像の個別領域の一部であり、同図の(A−3)に示した領域200bは、同図の(A−2)に示した連続領域100bに対応する型抜き画像の個別領域の一部である。   When the input image shown in (A-1) of FIG. 6 is cut using the mask image shown in (A-2) of FIG. 6, it is shown in areas 200a and 200b of (A-3) of FIG. As described above, the surrounding background is extracted together with the ruled lines and characters of the input image. This is because in the mask image, the ruled lines and characters are thicker than the input image, and the background cannot be completely removed. Note that the area 200a shown in (A-3) in the figure is a part of the individual area of the punched image corresponding to the continuous area 100a shown in (A-2) in the figure, and ( A region 200b shown in A-3) is a part of the individual region of the die-cut image corresponding to the continuous region 100b shown in (A-2) of FIG.

ここで、背景領域の色は、罫線・文字領域の色よりも薄いのが通常である。言い換えれば、背景領域の輝度は、罫線・文字領域の輝度よりも高いのが通常である。そこで、閾値決定部11eは、図6の(B)に示したように、個別領域の輝度分布を生成し、生成した輝度分布のうち、最も高輝度側に位置する山部とかかる山部に隣接する他の山部によって形成される谷部400における輝度値を2値化閾値として決定する。これにより、型抜き処理において除去しきれなかった背景領域をより確実に除去する2値化閾値を個別領域ごとに得ることができる。そして、この結果、同図の(A−4)に示したように、型抜き処理において除去しきれなかった背景領域がより確実に除去された2値画像を得ることができる。   Here, the color of the background area is usually lighter than the color of the ruled line / character area. In other words, the luminance of the background area is usually higher than that of the ruled line / character area. Therefore, as shown in FIG. 6B, the threshold value determination unit 11e generates a luminance distribution of the individual region, and among the generated luminance distribution, the peak portion located on the highest luminance side and the peak portion are related to the peak portion. The luminance value in the valley 400 formed by other adjacent peaks is determined as a binarization threshold. Thereby, the binarization threshold value which more reliably removes the background area that could not be removed in the die cutting process can be obtained for each individual area. As a result, as shown in (A-4) of the figure, it is possible to obtain a binary image in which the background area that could not be removed by the die cutting process is more reliably removed.

なお、図6の(A−3)に示した領域200aのように、罫線の外側および内側に存在する背景の輝度が異なる領域では、輝度の高い(明るい)背景のみが除去され、輝度の低い(暗い)背景が除去されずに残存することとなる。このため、同図の(A−4)に示した領域300aのように、2値画像では、一部が入力画像と比較して若干太く表示される場合がある。ただし、マスク画像を用いて入力画像の型抜きを行った時点で、大部分の背景領域を罫線・文字領域から分離することができているため、背景領域がわずかに残っていたとしても、これによって2値画像の視認性が損なわれることはない。   Note that, in a region where the brightness of the background existing outside and inside the ruled line is different, as in the region 200a illustrated in FIG. 6A-3, only the bright (bright) background is removed and the brightness is low. The (dark) background will remain without being removed. For this reason, in the binary image, a part of the binary image may be displayed slightly thicker than the input image, as in an area 300a shown in FIG. However, since most of the background area can be separated from the ruled line / character area when the input image is cut using the mask image, even if the background area remains slightly, Thus, the visibility of the binary image is not impaired.

また、閾値決定部11eは、2値化閾値を決定すると、決定した2値化閾値を対応する個別領域の位置情報とともに閾値情報12bとして記憶部12へ記憶させる処理を併せて行う。   Further, when the threshold value determination unit 11e determines the binarization threshold value, the threshold value determination unit 11e also performs a process of storing the determined binarization threshold value in the storage unit 12 as threshold information 12b together with the position information of the corresponding individual area.

図2の説明に戻り、2値化処理部11fについて説明する。2値化処理部11fは、型抜き部11cから型抜き画像を受け取った場合に、型抜き画像の個別領域および各個別領域に適用すべき2値化閾値を閾値情報12bに基づいて特定したうえで、個別領域ごとに2値化処理を行う処理部である。なお、2値化処理部11fは、全ての個別領域についての2値化を終えると、2値化後の型抜き画像を2値画像として出力する。   Returning to the description of FIG. 2, the binarization processing unit 11f will be described. When the binarization processing unit 11f receives a die-cut image from the die-cutting unit 11c, the binarization processing unit 11f specifies an individual area of the die-cut image and a binarization threshold to be applied to each individual area based on the threshold information 12b. The processing unit performs binarization processing for each individual area. Note that the binarization processing unit 11f outputs the binarized die-cut image as a binary image when binarization is completed for all the individual areas.

記憶部12は、不揮発性メモリやハードディスクドライブといった記憶デバイスで構成される記憶部であり、ラベル情報12aと、閾値情報12bとを記憶する。ラベル情報12aは、ラベリング部11dによって生成される情報であり、マスク画像の連続領域を識別する識別情報ごとに、対応する連続領域の位置情報を関連付けた情報である。また、閾値情報12bは、閾値決定部11eによって生成される情報であり、個別領域の位置情報ごとに、対応する個別領域に対して適用される2値化閾値を関連付けた情報である。   The storage unit 12 is a storage unit configured by a storage device such as a nonvolatile memory or a hard disk drive, and stores label information 12a and threshold information 12b. The label information 12a is information generated by the labeling unit 11d, and is information in which position information of the corresponding continuous area is associated with each identification information for identifying the continuous area of the mask image. The threshold information 12b is information generated by the threshold determination unit 11e, and is information in which a binarization threshold applied to a corresponding individual area is associated with each piece of position information of the individual area.

次に、本実施例に係る画像2値化装置10が実行する処理手順について図7を用いて説明する。図7は、画像2値化装置10が実行する処理手順を示すフローチャートである。   Next, a processing procedure executed by the image binarization apparatus 10 according to the present embodiment will be described with reference to FIG. FIG. 7 is a flowchart showing a processing procedure executed by the image binarization apparatus 10.

図7に示すように、画像2値化装置10では、マスク画像生成部11aが、平均値フィルタ等を用いて入力画像を平滑化したうえで(ステップS101)、ソーベルフィルタを用いて水平方向および垂直方向に一次微分を行って微分画像をそれぞれ生成する(ステップS102)。   As shown in FIG. 7, in the image binarization apparatus 10, the mask image generation unit 11 a smoothes the input image using an average value filter or the like (step S <b> 101), and then horizontally using a Sobel filter. The differential image is generated by performing the primary differentiation in the vertical direction (step S102).

つづいて、マスク画像生成部11aは、エッジ強度分布を用いて各微分画像のエッジ強度閾値を決定し(ステップS103)、決定したエッジ強度閾値を用いて各微分画像を閾値処理することによってエッジ画像を生成する(ステップS104)。そして、マスク画像生成部11aは、各エッジ画像を合成することによってマスク画像を生成する(ステップS105)。   Subsequently, the mask image generation unit 11a determines an edge intensity threshold value of each differential image using the edge intensity distribution (step S103), and performs threshold processing on each differential image using the determined edge intensity threshold value, thereby obtaining an edge image. Is generated (step S104). Then, the mask image generation unit 11a generates a mask image by combining the edge images (step S105).

つづいて、画像2値化装置10では、マスク画像修正部11bが、各エッジ画像を用いて谷画像および山画像を生成するとともに生成した谷画像および山画像を用いてマスク画像を修正し(ステップS106)、型抜き部11cが、修正後のマスク画像を用いて入力画像の型抜きを行うことによって型抜き画像を生成する(ステップS107)。また、ラベリング部11dは、修正後のマスク画像のラベリング処理を行う(ステップS108)。   Subsequently, in the image binarization apparatus 10, the mask image correcting unit 11b generates a valley image and a mountain image using each edge image and corrects the mask image using the generated valley image and mountain image (step In step S106, the die cutting unit 11c generates a die cutting image by performing die cutting of the input image using the corrected mask image (step S107). Further, the labeling unit 11d performs a labeling process on the corrected mask image (step S108).

つづいて、画像2値化装置10では、閾値決定部11eが、型抜き画像の個別領域を1つ選択し(ステップS109)、選択した個別領域の輝度分布に基づいて2値化閾値を決定し(ステップS110)、2値化処理部11fが、決定した2値化閾値を用いて個別領域内の画素を2値化する(ステップS111)。   Subsequently, in the image binarization apparatus 10, the threshold value determination unit 11e selects one individual area of the punched image (step S109), and determines the binarization threshold value based on the luminance distribution of the selected individual area. (Step S110) The binarization processing unit 11f binarizes the pixels in the individual area using the determined binarization threshold (Step S111).

そして、画像2値化装置10では、全ての個別領域について処理済みか否かを判定し(ステップS112)、処理済みでなければ(ステップS112、No)、未処理の個別領域についてステップS109〜S112の処理を繰り返す。一方、全ての個別領域について処理済みである場合には(ステップS112、Yes)、処理を終了する。   Then, the image binarization apparatus 10 determines whether or not all the individual areas have been processed (step S112), and if not processed (step S112, No), steps S109 to S112 for the unprocessed individual areas. Repeat the process. On the other hand, if all the individual areas have been processed (step S112, Yes), the process ends.

上述してきたように、本実施例では、マスク画像生成部が、入力画像の微分値の絶対値であるエッジ強度を求めるとともに、かかるエッジ強度が所定のエッジ強度閾値以上の画素を有効画素としエッジ強度閾値未満の画素を無効画素とした2値のマスク画像を生成し、型抜き部が、マスク画像の有効画素に対応する画素を入力画像から抽出することによって型抜き画像を生成し、ラベリング部が、マスク画像の有効画素を連続領域ごとに区分けし、閾値決定部が、連続領域に対応する型抜き画像の個別領域ごとに、かかる個別領域の輝度分布に基づいて2値化閾値を決定し、2値化処理部が、個別領域ごとに、2値化閾値を用いてかかる個別領域に含まれる画素を2値化することとした。したがって、入力画像の罫線や文字あるいは背景に多様な濃淡差がある場合であっても適切な2値画像を得ることができる。   As described above, in this embodiment, the mask image generation unit obtains the edge strength that is the absolute value of the differential value of the input image, and uses the pixel having the edge strength equal to or higher than a predetermined edge strength threshold as an effective pixel. A binary mask image in which pixels less than the intensity threshold are invalid pixels is generated, and a die cutting unit generates a die cutting image by extracting pixels corresponding to effective pixels of the mask image from the input image, and a labeling unit However, the effective pixels of the mask image are divided into continuous regions, and the threshold value determination unit determines a binarization threshold value for each individual region of the punched image corresponding to the continuous region based on the luminance distribution of the individual region. The binarization processing unit binarizes pixels included in the individual area using a binarization threshold for each individual area. Therefore, an appropriate binary image can be obtained even when there are various shade differences in the ruled lines, characters, or background of the input image.

ところで、帳票等では、各項目の境界線が、罫線ではなく背景色の違いで表現される場合がある。このような境界線では、罫線とは異なりエッジが片側にしかあらわれないため、マスク画像においてかすれが生じ易く、適切な型抜き画像を生成することができないおそれがある。   By the way, in a form or the like, the boundary line of each item may be expressed not by a ruled line but by a background color difference. In such a boundary line, unlike a ruled line, an edge appears only on one side, so that the mask image is likely to be blurred, and an appropriate die-cut image may not be generated.

そこで、マスク画像修正部11bは、上記のような境界線や罫線のように比較的長く連続する線分のエッジをエッジ強度閾値とは異なる条件を用いて検出し、検出結果を用いてマスク画像を修正することによって上記のかすれを解消することとしてもよい。ここで、かかるマスク画像修正処理について図8を用いて説明する。図8は、マスク画像修正処理の他の処理手順を示すフローチャートである。   Therefore, the mask image correcting unit 11b detects the edge of a relatively long continuous line segment such as the above-described boundary line or ruled line using a condition different from the edge strength threshold, and uses the detection result to mask the mask image. It is good also as eliminating the above-mentioned blur by correcting. Here, the mask image correction processing will be described with reference to FIG. FIG. 8 is a flowchart showing another processing procedure of the mask image correction process.

図8に示すように、マスク画像修正部11bは、所定のエッジ強度以上の画素が水平方向に所定以上連続している領域を水平方向の微分画像から抽出する(ステップS201)。同様に、マスク画像修正部11bは、所定のエッジ強度以上の画素が垂直方向に所定以上連続している領域を垂直方向の微分画像から抽出する(ステップS202)。たとえば、マスク画像修正部11bは、エッジ強度が「2」以上の画素が50画素以上連続している領域を各エッジ画像から抽出する。   As shown in FIG. 8, the mask image correcting unit 11b extracts a region in which pixels having a predetermined edge strength or higher are continuous for a predetermined distance in the horizontal direction from the differential image in the horizontal direction (step S201). Similarly, the mask image correction unit 11b extracts, from the differential image in the vertical direction, a region in which pixels having a predetermined edge strength or higher are continued for a predetermined amount in the vertical direction (step S202). For example, the mask image correction unit 11b extracts from each edge image a region in which 50 or more pixels having an edge strength of “2” or more are continuous.

つづいて、マスク画像修正部11bは、各微分画像から抽出した領域に対応するマスク画像の無効画素(黒画素)を有効画素(白画素)へ置き換え(ステップS203)、処理を終了する。   Subsequently, the mask image correcting unit 11b replaces the invalid pixel (black pixel) of the mask image corresponding to the region extracted from each differential image with the effective pixel (white pixel) (step S203), and ends the process.

これにより、背景色の違いで表現された境界線や罫線のマスク画像におけるかすれを解消できるため、より適切な型抜き画像を得ることができる。   As a result, blurring in the mask image of the boundary line or ruled line expressed by the difference in the background color can be eliminated, so that a more appropriate die cut image can be obtained.

また、上述してきた実施例では、マスク画像を用いて入力画像から罫線および文字の両方を抜き出すこととしたが、罫線だけあるいは文字だけを入力画像から抜き出すこともできる。   In the embodiment described above, both the ruled lines and the characters are extracted from the input image using the mask image. However, only the ruled lines or only the characters can be extracted from the input image.

かかる場合、型抜き部11cは、マスク画像の各連続領域の中から所定の条件に合致する連続領域をラベル情報12aを用いて特定し、特定した連続領域のみを用いて入力画像の型抜きを行う。たとえば、型抜き部11cは、水平方向または垂直方向に50画素以上連続している連続領域のみを用いて入力画像の型抜きを行うことで、文字や点線あるいはノイズを抜き出すことなく、罫線だけを抜き出すことができる。   In such a case, the die cutting unit 11c specifies a continuous region that matches a predetermined condition from among the continuous regions of the mask image using the label information 12a, and performs die cutting of the input image using only the specified continuous region. Do. For example, the die cutting unit 11c cuts only the ruled line without extracting characters, dotted lines, or noise by performing die cutting of the input image using only a continuous region that is continuous in the horizontal direction or the vertical direction by 50 pixels or more. Can be extracted.

以上のように、本発明に係る画像2値化方法および画像2値化装置は、入力画像の罫線や文字あるいは背景に濃淡差がある場合であっても適切な2値画像を得たい場合に有用であり、特に、フリーフォーマットの帳票を2値化したい場合に適している。   As described above, the image binarization method and the image binarization apparatus according to the present invention are used to obtain an appropriate binary image even when there is a difference in shading between the ruled lines, characters, or background of the input image. This is useful, and is particularly suitable for binarizing a free format form.

10 画像2値化装置
11 制御部
11a マスク画像生成部
11b マスク画像修正部
11c 型抜き部
11d ラベリング部
11e 閾値決定部
11f 2値化処理部
12 記憶部
12a ラベル情報
12b 閾値情報
20 画像読取装置
DESCRIPTION OF SYMBOLS 10 Image binarization apparatus 11 Control part 11a Mask image generation part 11b Mask image correction part 11c Die-cut part 11d Labeling part 11e Threshold determination part 11f Binarization process part 12 Storage part 12a Label information 12b Threshold information 20 Image reader

Claims (6)

入力画像を2値化する画像2値化方法であって、
前記入力画像の微分値の絶対値であるエッジ強度を求めるとともに、当該エッジ強度が所定のエッジ強度閾値以上の画素を有効画素とし前記エッジ強度閾値未満の画素を無効画素とした2値のマスク画像を生成するマスク画像生成工程と、
前記マスク画像の有効画素に対応する画素を前記入力画像から抽出することによって型抜き画像を生成する型抜き工程と、
前記マスク画像の有効画素を連続領域ごとに区分けする区分け工程と、
前記連続領域に対応する前記型抜き画像の個別領域ごとに、当該個別領域の輝度分布に基づいて2値化閾値を決定する閾値決定工程と、
前記個別領域ごとに、前記閾値決定工程において決定した2値化閾値を用いて当該個別領域に含まれる画素を2値化する2値化工程と
を含んだことを特徴とする画像2値化方法。
An image binarization method for binarizing an input image,
A binary mask image in which an edge strength which is an absolute value of a differential value of the input image is obtained, and a pixel whose edge strength is equal to or greater than a predetermined edge strength threshold is an effective pixel and a pixel whose edge strength is less than the edge strength threshold is an invalid pixel A mask image generation step for generating
A die-cutting step of generating a die-cut image by extracting pixels corresponding to effective pixels of the mask image from the input image;
A step of dividing the effective pixels of the mask image into continuous regions;
A threshold value determining step for determining a binarization threshold value for each individual area of the punched image corresponding to the continuous area based on a luminance distribution of the individual area;
A binarization step for binarizing pixels included in the individual region using the binarization threshold value determined in the threshold value determination step for each individual region. .
前記マスク画像生成工程は、
前記入力画像のエッジ強度を用いてエッジ強度分布を生成するとともに、生成したエッジ強度分布の2次微分値に基づいて当該エッジ強度分布の変曲点を検出し、検出した変曲点におけるエッジ強度を前記エッジ強度閾値として決定することを特徴とする請求項1に記載の画像2値化方法。
The mask image generation step includes
An edge intensity distribution is generated using the edge intensity of the input image, an inflection point of the edge intensity distribution is detected based on a second derivative value of the generated edge intensity distribution, and the edge intensity at the detected inflection point The image binarization method according to claim 1, wherein the threshold value is determined as the edge intensity threshold value.
前記エッジ強度が前記エッジ強度閾値以上の画素のうち前記微分値が正である正エッジ画素と前記微分値が負である負エッジ画素との境界領域であって、前記正エッジ画素および前記負エッジ画素の並び順が、1つの線分から得られる前記正エッジ画素および前記負エッジ画素の並び順とは逆である境界領域を谷領域として抽出し、抽出した谷領域に位置する前記マスク画像の有効画素を無効画素と置き換える無効化工程
をさらに含んだことを特徴とする請求項1または2に記載の画像2値化方法。
A boundary region between a positive edge pixel having a positive differential value and a negative edge pixel having a negative differential value among the pixels having the edge strength equal to or higher than the edge strength threshold, the positive edge pixel and the negative edge A boundary region in which the pixel arrangement order is opposite to the arrangement order of the positive edge pixel and the negative edge pixel obtained from one line segment is extracted as a valley region, and the effective mask image located in the extracted valley region is extracted. The image binarization method according to claim 1, further comprising an invalidation step of replacing a pixel with an invalid pixel.
前記エッジ強度が前記エッジ強度閾値以上の画素のうち前記微分値が正である正エッジ画素と前記微分値が負である負エッジ画素との境界領域であって、前記正エッジ画素および前記負エッジ画素の並び順が、1つの線分から得られる前記正エッジ画素および前記負エッジ画素の並び順と同じである境界領域を山領域として抽出し、抽出した山領に位置する前記マスク画像の無効画素を有効画素と置き換える有効化工程
をさらに含んだことを特徴とする請求項1、2または3に記載の画像2値化方法。
A boundary region between a positive edge pixel having a positive differential value and a negative edge pixel having a negative differential value among the pixels having the edge strength equal to or higher than the edge strength threshold, the positive edge pixel and the negative edge A boundary region in which the pixel arrangement order is the same as the arrangement order of the positive edge pixel and the negative edge pixel obtained from one line segment is extracted as a mountain region, and invalid pixels of the mask image located in the extracted mountain region are extracted. The image binarization method according to claim 1, further comprising an enabling step of replacing with effective pixels.
前記閾値決定工程は、
前記個別領域の輝度分布において最も高輝度側に位置する山部と当該山部に隣接する他の山部とによって形成される谷部における輝度値を前記2値化閾値として決定することを特徴とする請求項1〜4のいずれか一つに記載の画像2値化方法。
The threshold determination step includes
Determining a luminance value in a trough formed by a peak located on the highest luminance side in the luminance distribution of the individual region and another peak adjacent to the peak as the binarization threshold; The image binarization method according to any one of claims 1 to 4.
入力画像を2値化する画像2値化装置であって、
前記入力画像の微分値の絶対値であるエッジ強度を求めるとともに、当該エッジ強度が所定のエッジ強度閾値以上の画素を有効画素とし前記エッジ強度閾値未満の画素を無効画素とした2値のマスク画像を生成するマスク画像生成手段と、
前記マスク画像の有効画素に対応する画素を前記入力画像から抽出することによって型抜き画像を生成する型抜き手段と、
前記マスク画像の有効画素を連続領域ごとに区分けする区分け手段と、
前記連続領域に対応する前記型抜き画像の個別領域ごとに、当該個別領域の輝度分布に基づいて2値化閾値を決定する閾値決定手段と、
前記個別領域ごとに、前記閾値決定手段によって決定された2値化閾値を用いて当該個別領域に含まれる画素を2値化する2値化手段と
を備えたことを特徴とする画像2値化装置。
An image binarization device for binarizing an input image,
A binary mask image in which an edge strength which is an absolute value of a differential value of the input image is obtained, and a pixel whose edge strength is equal to or greater than a predetermined edge strength threshold is an effective pixel and a pixel whose edge strength is less than the edge strength threshold is an invalid pixel Mask image generation means for generating
A die-cutting means for generating a die-cut image by extracting pixels corresponding to effective pixels of the mask image from the input image;
Partitioning means for partitioning the effective pixels of the mask image for each continuous region;
Threshold value determining means for determining a binarization threshold value for each individual region of the die-cut image corresponding to the continuous region based on a luminance distribution of the individual region;
An image binarization comprising: binarization means for binarizing pixels included in the individual area using the binarization threshold value determined by the threshold value determination means for each individual area apparatus.
JP2010209128A 2010-09-17 2010-09-17 Image binarization method and image binarization apparatus Active JP5732217B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2010209128A JP5732217B2 (en) 2010-09-17 2010-09-17 Image binarization method and image binarization apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2010209128A JP5732217B2 (en) 2010-09-17 2010-09-17 Image binarization method and image binarization apparatus

Publications (2)

Publication Number Publication Date
JP2012065230A true JP2012065230A (en) 2012-03-29
JP5732217B2 JP5732217B2 (en) 2015-06-10

Family

ID=46060474

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2010209128A Active JP5732217B2 (en) 2010-09-17 2010-09-17 Image binarization method and image binarization apparatus

Country Status (1)

Country Link
JP (1) JP5732217B2 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9525910B2 (en) 2013-12-30 2016-12-20 Samsung Electronics Co., Ltd. Display apparatus and channel map managing method thereof
JP2018088204A (en) * 2016-11-30 2018-06-07 ブラザー工業株式会社 Image processing device and program
JP2020174856A (en) * 2019-04-17 2020-10-29 株式会社 資生堂 Ultrasonic measurement method, ultrasonic measurement program, and ultrasonic measurement device
CN114529715A (en) * 2022-04-22 2022-05-24 中科南京智能技术研究院 Image identification method and system based on edge extraction

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05145749A (en) * 1991-11-19 1993-06-11 Sanyo Electric Co Ltd Selective binarizing method
JPH11259653A (en) * 1998-03-12 1999-09-24 Stanley Electric Co Ltd Image processing method
JP2000503145A (en) * 1996-01-02 2000-03-14 コグネックス コーポレイション Machine vision method and apparatus for edge-based image histogram analysis
JP2000165670A (en) * 1998-11-26 2000-06-16 Minolta Co Ltd Image processor, image processing method and recording medium recording image processing program
JP2000181992A (en) * 1998-12-11 2000-06-30 Fujitsu Ltd Color document image recognition device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05145749A (en) * 1991-11-19 1993-06-11 Sanyo Electric Co Ltd Selective binarizing method
JP2000503145A (en) * 1996-01-02 2000-03-14 コグネックス コーポレイション Machine vision method and apparatus for edge-based image histogram analysis
JPH11259653A (en) * 1998-03-12 1999-09-24 Stanley Electric Co Ltd Image processing method
JP2000165670A (en) * 1998-11-26 2000-06-16 Minolta Co Ltd Image processor, image processing method and recording medium recording image processing program
JP2000181992A (en) * 1998-12-11 2000-06-30 Fujitsu Ltd Color document image recognition device

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9525910B2 (en) 2013-12-30 2016-12-20 Samsung Electronics Co., Ltd. Display apparatus and channel map managing method thereof
JP2018088204A (en) * 2016-11-30 2018-06-07 ブラザー工業株式会社 Image processing device and program
JP2020174856A (en) * 2019-04-17 2020-10-29 株式会社 資生堂 Ultrasonic measurement method, ultrasonic measurement program, and ultrasonic measurement device
JP7246635B2 (en) 2019-04-17 2023-03-28 株式会社 資生堂 Ultrasonic measurement method, ultrasonic measurement program, and ultrasonic measurement device
CN114529715A (en) * 2022-04-22 2022-05-24 中科南京智能技术研究院 Image identification method and system based on edge extraction
CN114529715B (en) * 2022-04-22 2022-07-19 中科南京智能技术研究院 Image identification method and system based on edge extraction

Also Published As

Publication number Publication date
JP5732217B2 (en) 2015-06-10

Similar Documents

Publication Publication Date Title
ES2773719T3 (en) Text enhancement of a textual image undergoing optical character recognition
US10559067B2 (en) Removal of shadows from document images while preserving fidelity of image contents
JP5455038B2 (en) Image processing apparatus, image processing method, and program
EP3002712A2 (en) Horizontal and vertical line detection and removal for document images
US9349237B2 (en) Method of authenticating a printed document
EP3073415B1 (en) Image processing apparatus and image processing method
US20160292503A1 (en) Computer-readable storage medium storing image processing program, image processing device, and image processing method
JP5732217B2 (en) Image binarization method and image binarization apparatus
US9064179B2 (en) Region extraction apparatus, region extraction method, and computer program product
JP2004265264A (en) Image processor
JP4676978B2 (en) Face detection device, face detection method, and face detection program
CN110826360A (en) OCR image preprocessing and character recognition
CN113537037A (en) Pavement disease identification method, system, electronic device and storage medium
KR20150099116A (en) Method for recognizing a color character using optical character recognition and apparatus thereof
JP4010440B2 (en) Image processing apparatus with shadow detection
US11570331B2 (en) Image processing apparatus, image processing method, and storage medium
JP2005184787A (en) Image processing method and device
RU2520407C1 (en) Method and system of text improvement at digital copying of printed documents
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
CN112215783B (en) Image noise point identification method, device, storage medium and equipment
CN112634229B (en) Method for removing black edge of image
JP4209804B2 (en) Image processing apparatus, image processing method, storage medium, and program
Yoshida et al. A new binarization method for a sign board image with the blanket method
Yoshida et al. A Binarization Method for a Scenery Image with the Fractal Dimension
JP5272841B2 (en) Noise component removal apparatus and noise component removal method

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20130816

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20140828

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20140916

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20141117

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20150407

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20150413

R150 Certificate of patent or registration of utility model

Ref document number: 5732217

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150