JP6030915B2 - Image rearrangement method, image rearrangement system, and image rearrangement program - Google Patents

Image rearrangement method, image rearrangement system, and image rearrangement program Download PDF

Info

Publication number
JP6030915B2
JP6030915B2 JP2012231467A JP2012231467A JP6030915B2 JP 6030915 B2 JP6030915 B2 JP 6030915B2 JP 2012231467 A JP2012231467 A JP 2012231467A JP 2012231467 A JP2012231467 A JP 2012231467A JP 6030915 B2 JP6030915 B2 JP 6030915B2
Authority
JP
Japan
Prior art keywords
area
character
column
image
histogram
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.)
Active
Application number
JP2012231467A
Other languages
Japanese (ja)
Other versions
JP2014085689A (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.)
NTT Communications Corp
Original Assignee
NTT Communications 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 NTT Communications Corp filed Critical NTT Communications Corp
Priority to JP2012231467A priority Critical patent/JP6030915B2/en
Publication of JP2014085689A publication Critical patent/JP2014085689A/en
Application granted granted Critical
Publication of JP6030915B2 publication Critical patent/JP6030915B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Description

本発明は、文書画像から文字を切り出して配置する画像再配置方法、画像再配置システム、および画像再配置プログラムに関する。   The present invention relates to an image rearrangement method, an image rearrangement system, and an image rearrangement program that cut out and arrange characters from a document image.

文書画像からの文字の切り出し方法として、画像中から行・列を検出して各行ごとに文字位置を特定する手法がある。文字の切り出しに際しては、一般的に、文字認識が行われている(例えば特許文献1参照)。しかし、文字認識には、多くの処理時間を要するとともに、認識誤りによって文字が置き換わるという問題がある。   As a method of extracting characters from a document image, there is a method of detecting a row / column from an image and specifying a character position for each row. In character segmentation, character recognition is generally performed (see, for example, Patent Document 1). However, character recognition requires a lot of processing time and has a problem that characters are replaced by recognition errors.

そこで、文書画像中の文字を認識することなく、画像のまま文字を切り出し、表示領域の大きさに合わせて文字を画像のまま再配置(リフロー)して表示する技術が研究されている。   In view of this, a technique has been studied in which characters are cut out from the image without recognizing the characters in the document image, and the characters are rearranged (reflowed) and displayed according to the size of the display area.

特開2006-235817号公報JP 2006-235817 A

文書データをスキャンして文書画像とする際に、文書データが傾いた状態でスキャンされてしまう場合がある。この場合、文書画像の文字が傾いて斜めになっている状態で、文書画像の垂直方向または水平方向に列または行が存在するものとして処理すると、列として切り出した列領域または行として切り出した行領域に、余分な領域が含まれてしまう。そのため、画像として列領域または行領域から切り出した文字を再配置して表示した場合に、文字のがたつきや、見栄えが悪くなる可能性がある。なお、従来の再配置技術では、文書画像の傾きについては、考慮されていない。   When document data is scanned into a document image, the document data may be scanned in a tilted state. In this case, if it is assumed that a column or row exists in the document image in the vertical or horizontal direction with the characters of the document image tilted and slanted, the column region or row cut out as a column is cut out. An extra area is included in the area. Therefore, when the characters cut out from the row area or the row area are rearranged and displayed as an image, there is a possibility that the letters will not be rattled or look bad. In the conventional rearrangement technique, the inclination of the document image is not taken into consideration.

本発明は上記事情に鑑みてなされたものであり、本発明の目的は、文書画像の傾きを加味して行領域または列領域を切り出す画像再配置方法、画像再配置システム、および画像再配置プログラムを提供することにある。   The present invention has been made in view of the above circumstances, and an object of the present invention is to provide an image rearrangement method, an image rearrangement system, and an image rearrangement program for cutting out a row area or a column area in consideration of the inclination of a document image. Is to provide.

上記目的を達成するため、本発明は、コンピュータが行う画像再配置方法であって、読み込んだ文書画像から、複数の文字矩形を含む文字領域を抽出する領域抽出ステップと、前記文字領域を所定数に分割し、各分割領域毎に前景のヒストグラムを生成し、各分割領域で作成されるヒストグラムの位置のずれを用いて、画像の傾きを推定する傾き推定ステップと、前記傾きの分だけ各文字矩形の位置をずらして、前記文字領域のヒストグラムを生成し、前記ヒストグラムの幅の行領域または列領域を抽出し、当該行領域または列領域に含まれる文字矩形の高さまたは幅を、前記行領域の高さまたは前記列領域の幅に合わせる行・列取得ステップと、前記行領域または前記列領域から、前記行領域の高さまたは前記列領域の幅に合わせた各文字矩形を切り出す文字切り出しステップと、を行う。 In order to achieve the above object, the present invention provides an image rearrangement method performed by a computer, an area extracting step for extracting a character area including a plurality of character rectangles from a read document image, and a predetermined number of the character areas. A foreground histogram is generated for each divided area, and the inclination estimation step for estimating the inclination of the image using the positional deviation of the histogram created in each divided area, and each character corresponding to the inclination The position of the rectangle is shifted to generate a histogram of the character area, the row area or the column area having the width of the histogram is extracted, and the height or width of the character rectangle included in the line area or the column area is and row and column acquisition step of bringing the width of the height or the column region region, the row region or from said line region, each character to fit the width of the height or the column region of the line region Performing a character segmentation step for cutting out shapes, the.

本発明は、画像再配置システムであって、読み込んだ文書画像から、複数の文字矩形を含む文字領域を抽出する領域抽出手段と、前記文字領域を所定数に分割し、各分割領域毎に前景のヒストグラムを生成し、各分割領域で作成されるヒストグラムの位置のずれを用いて、画像の傾きを推定する傾き推定手段と、前記傾きの分だけ各文字矩形の位置をずらして、前記文字領域のヒストグラムを生成し、前記ヒストグラムの幅の行領域または列領域を抽出し、当該行領域または列領域に含まれる文字矩形の高さまたは幅を、前記行領域の高さまたは前記列領域の幅に合わせる行・列取得手段と、前記行領域または前記列領域から、前記行領域の高さまたは前記列領域の幅に合わせた各文字矩形を切り出す文字切り出し手段と、を備える。 The present invention is an image rearrangement system, wherein a region extraction unit that extracts a character region including a plurality of character rectangles from a read document image, the character region is divided into a predetermined number, and the foreground is divided into each divided region. The character region is generated by shifting the position of each character rectangle by an amount corresponding to the inclination, and an inclination estimation means for estimating the inclination of the image using the shift of the position of the histogram created in each divided region. A histogram is generated, a row area or a column area having a width of the histogram is extracted, and the height or width of the character rectangle included in the row area or the column area is set as the height of the row area or the width of the column area. And a character cutout means for cutting out each character rectangle in accordance with the height of the row area or the width of the column area from the row area or the column area .

本発明は、コンピュータが実行する画像再配置プログラムであって、前記コンピュータに、読み込んだ文書画像から、複数の文字矩形を含む文字領域を抽出する領域抽出ステップと、前記文字領域を所定数に分割し、各分割領域毎に前景のヒストグラムを生成し、各分割領域で作成されるヒストグラムの位置のずれを用いて、画像の傾きを推定する傾き推定ステップと、前記傾きの分だけ各文字矩形の位置をずらして、前記文字領域のヒストグラムを生成し、前記ヒストグラムの幅の行領域または列領域を抽出し、当該行領域または列領域に含まれる文字矩形の高さまたは幅を、前記行領域の高さまたは前記列領域の幅に合わせる行・列取得ステップと、前記行領域または前記列領域から、前記行領域の高さまたは前記列領域の幅に合わせた各文字矩形を切り出す文字切り出しステップと、を実行させる。 The present invention is an image rearrangement program executed by a computer, wherein an area extraction step of extracting a character area including a plurality of character rectangles from a document image read into the computer, and dividing the character area into a predetermined number Then, a foreground histogram is generated for each divided area, and an inclination estimation step for estimating the inclination of the image using a shift of the position of the histogram created in each divided area, and for each character rectangle by the inclination, A position is shifted to generate a histogram of the character region, a row region or a column region having a width of the histogram is extracted, and a height or width of a character rectangle included in the row region or the column region is set to the height of the row region. and row and column acquisition step of bringing the height or width of the column region, from the row area or the row region, tailored to the width of the height or the column region of the line region A character segmentation step of cutting out the character rectangle, is executed.

本発明によれば、文書画像の傾きを加味して行領域または列領域を切り出す画像再配置方法、画像再配置システム、および画像再配置プログラムを提供することができる。   According to the present invention, it is possible to provide an image rearrangement method, an image rearrangement system, and an image rearrangement program for cutting out a row area or a column area in consideration of the inclination of a document image.

本発明の実施形態に係る画像再配置システムを示す構成図である。It is a block diagram which shows the image rearrangement system which concerns on embodiment of this invention. リフロー表示のイメージを示す図である。It is a figure which shows the image of a reflow display. クラスおよびオブジェクトの関係を示す図である。It is a figure which shows the relationship between a class and an object. 矩形座標の表現方法を示す図である。It is a figure which shows the expression method of a rectangular coordinate. リフローデータ生成処理のフローチャートである。It is a flowchart of a reflow data generation process. 網掛け領域の拡大図である。It is an enlarged view of a shaded area. 2値化処理の結果を示す図である。It is a figure which shows the result of a binarization process. 初期ラベリング結果の統合を示す図である。It is a figure which shows integration of an initial labeling result. キャプションエリア候補とヒストグラムとを示す図である。It is a figure which shows a caption area candidate and a histogram. ラベルを用いたヒストグラムの作成を示す図である。It is a figure which shows creation of the histogram using a label. 画素の走査によるヒストグラムの作成を示す図である。It is a figure which shows creation of the histogram by the scanning of a pixel. キャプションエリアの設定を示す図である。It is a figure which shows the setting of a caption area. キャプションと本文との判別を示す図である。It is a figure which shows discrimination | determination with a caption and a text. 文字領域の取得を示す図である。It is a figure which shows acquisition of a character area. 文字領域のヒストグラムを示す図である。It is a figure which shows the histogram of a character area. 傾き推定を説明するための図である。It is a figure for demonstrating inclination estimation. 傾きを考慮した列の取得を説明するための図である。It is a figure for demonstrating acquisition of the column which considered inclination. 縦書きおよび横書きの読み順の並べ替えを示すものである。This shows the rearrangement of the reading order of vertical writing and horizontal writing. ルビの統合を示す図である。It is a figure which shows integration of ruby. 文字間隔の整形例を示す図である。It is a figure which shows the example of shaping of a character space | interval. 列端の文字間隔の整形例を示す図である。It is a figure which shows the shaping example of the character space | interval of the column end. 最終的な切り出し結果を示す図である。It is a figure which shows the final cutting-out result. リフローデータの一例を示す図である。It is a figure which shows an example of reflow data. リフロー表示処理のフローチャートである。It is a flowchart of a reflow display process. リフローデータを分冊に区切る方法を示す図である。It is a figure which shows the method of dividing reflow data into a separate volume. 文字および図表の配列イメージを示す図である。It is a figure which shows the arrangement | sequence image of a character and a chart.

以下、本発明の実施形態について説明する。   Hereinafter, embodiments of the present invention will be described.

図1は、本発明の実施形態に係る画像再配置システムの全体構成を示す図である。図示する画像再配置システムは、レイアウト解析部1と、データ保存部2と、リフロー(再配置)表示部3とを備える。レイアウト解析部1は、画像としてスキャンされた文書データなどの画像(文書画像)を読み込み、様々な画面サイズのデバイスにおいて快適に読むことを実現するためのリフローデータを生成する。データ保存部2には、読み込んだ画像、および、生成したリフローデータを格納する。リフロー表示部3は、データ保存部2に格納されたデータを用いて、画像から切り出した文字や図表などを、画面サイズに合わせて再配置し、表示する。図2は、リフロー表示のイメージを示す図である。   FIG. 1 is a diagram showing an overall configuration of an image rearrangement system according to an embodiment of the present invention. The illustrated image rearrangement system includes a layout analysis unit 1, a data storage unit 2, and a reflow (rearrangement) display unit 3. The layout analysis unit 1 reads an image (document image) such as scanned document data as an image, and generates reflow data for realizing comfortable reading on devices of various screen sizes. The data storage unit 2 stores the read image and the generated reflow data. The reflow display unit 3 uses the data stored in the data storage unit 2 to rearrange and display characters and diagrams cut out from the image according to the screen size. FIG. 2 is a diagram showing an image of reflow display.

図1に示すレイアウト解析部1は、処理対象となるデータを画像として読み込む画像読み込み部11と、読み込まれた画像の2値化処理を行う2値化処理部12と、2値化された画像で文字または図表と認識されたピクセルの連続した領域を抽出し、ラベルを付けるラベリング部13と、ラベリング結果を用いて図表を示す領域を抽出する図表認識部14と、図表として認識されなかった文字領域から行または列を認識し、文字情報の切り出しを行う文字切り出し部15と、所定の場合にページ全体を図表領域にするなどのレイアウトを変換するレイアウト変換部16と、読み込んだ画像の最終ページのバーコードを認識し、ISBNコードを取得するバーコード解析部17と、各データを保存する記憶部18とを備える。   The layout analysis unit 1 shown in FIG. 1 includes an image reading unit 11 that reads data to be processed as an image, a binarization processing unit 12 that performs binarization processing on the read image, and a binarized image. Extracts a continuous area of pixels recognized as characters or charts in Fig. 1, a labeling unit 13 for labeling, a chart recognition unit 14 for extracting a region indicating a chart using a labeling result, and a character not recognized as a chart A character cutout unit 15 that recognizes a row or column from an area and cuts out character information, a layout conversion unit 16 that converts a layout such as making the entire page a chart area in a predetermined case, and the last page of the read image The barcode analysis unit 17 for recognizing the barcode and acquiring the ISBN code and the storage unit 18 for storing each data are provided.

また、図示するリフロー表示部3は、レンダリング部31と、ディスプレイ32と、タッチパネルなどの操作受付部33とを備える。レンダリング部31は、データ保存部2に格納された画像およびリフローデータを用いて、画像から切り出した文字や図表などを画面サイズに合わせて再配置し、ディスプレイ32に表示する。ユーザは、例えば、ディスプレイ32上に形成されたタッチパネルなどの操作受付部32にタッチすることで、ページ捲り、ページ移動などの指示をリフロー表示部3に入力する。   The illustrated reflow display unit 3 includes a rendering unit 31, a display 32, and an operation receiving unit 33 such as a touch panel. Using the image and reflow data stored in the data storage unit 2, the rendering unit 31 rearranges characters and diagrams cut out from the image according to the screen size and displays them on the display 32. For example, the user touches the operation reception unit 32 such as a touch panel formed on the display 32 to input instructions such as page turning and page movement to the reflow display unit 3.

上記説明した画像再配置システムには、例えば、CPUと、メモリと、HDD等の外部記憶装置と、入力装置と、出力装置とを備えた汎用的なコンピュータシステムを用いることができる。このコンピュータシステムにおいて、CPUがメモリ上にロードされた画像再配置システム用のプログラムを実行することにより、画像再配置システムの各機能が実現される。また、画像再配置システム用のプログラムは、ハードディスク、フレキシブルディスク、CD−ROM、MO、DVD−ROMなどのコンピュータ読取り可能な記録媒体に記憶することも、ネットワークを介して配信することもできる。   For the image rearrangement system described above, for example, a general-purpose computer system including a CPU, a memory, an external storage device such as an HDD, an input device, and an output device can be used. In this computer system, each function of the image rearrangement system is realized by the CPU executing a program for the image rearrangement system loaded on the memory. The program for the image rearrangement system can be stored in a computer-readable recording medium such as a hard disk, a flexible disk, a CD-ROM, an MO, a DVD-ROM, or can be distributed via a network.

なお、レイアウト解析部1は、例えばPC、サーバなどのコンピュータに実装され、リフロー表示部3およびデータ保存部2は、例えばスマートフォン、タブレットなどの携帯端末などに実装することが考えられる。しかしながら、これに限定されず、例えば携帯端末などの1つのコンピュータが、レイアウト解析部1、データ保存部2およびリフロー表示部3を実装することとしてもよい。   The layout analysis unit 1 may be mounted on a computer such as a PC or a server, and the reflow display unit 3 and the data storage unit 2 may be mounted on a mobile terminal such as a smartphone or a tablet. However, the present invention is not limited to this. For example, a single computer such as a portable terminal may implement the layout analysis unit 1, the data storage unit 2, and the reflow display unit 3.

次に、本実施形態のデータ構造について説明する。   Next, the data structure of this embodiment will be described.

図3に、主要なクラスとオブジェクトの関係を示す。IR Layout クラス31は、読み込んだ画像のページ全体に関わるレイアウト情報を保持しており、1 または複数のIR Area クラス32のデータと関連している。例えば、IR Layout クラス31は、2 値化した結果、横書き領域、縦書き領域、図表領域の面積およびそれらの和(CHARH AREA, CHARV AREA, FIGURE AREA, SUM AREA)、文字領域取得に利用するY 方向のヒストグラムデータ、初期ラベリング結果の保持リスト(srcArea)、文字候補リスト(charCandidate)、文字領域リスト(charArea)、図表領域リスト(imageArea)などを保持する。   FIG. 3 shows the relationship between main classes and objects. The IR Layout class 31 holds layout information relating to the entire page of the read image, and is associated with one or more IR Area class 32 data. For example, the IR Layout class 31 uses the binarized area, horizontal writing area, vertical writing area, chart area area and their sum (CHARH AREA, CHARV AREA, FIGURE AREA, SUM AREA), and Y used for character area acquisition. Holds direction histogram data, initial labeling result holding list (srcArea), character candidate list (charCandidate), character area list (charArea), chart area list (imageArea), and the like.

IR Area クラス32は、画像中に複数存在する領域に関する情報を保持する。領域には”縦書き領域”、”横書き領域”、”図表領域”の3 種類が存在する。”縦書き領域”、”横書き領域”はさらに細かい単位のIR Column クラス33のデータと関連している。IR Area クラス32は、例えば、領域の種別(縦書き、横書き、図表)、領域の矩形座標データ、領域の縦書き・横書き判定用の領域内X 方向ヒストグラム、領域の縦書き・横書き判定用の領域内Y 方向ヒストグラム、領域に含まれる行・列のデータなどを保持する。   The IR Area class 32 holds information regarding a plurality of areas present in the image. There are three types of areas: “vertical writing area”, “horizontal writing area”, and “chart area”. The “vertical writing area” and “horizontal writing area” are related to the data of the IR Column class 33 in a finer unit. The IR Area class 32 includes, for example, an area type (vertical writing, horizontal writing, chart), rectangular coordinate data of the area, an X-direction histogram in the area for vertical / horizontal writing determination of the area, and vertical / horizontal writing determination of the area. Holds the Y-direction histogram in the area and the row / column data contained in the area.

IR Column クラス33は、”縦書き領域”、”横書き領域”に含まれる”列”または”行”に関する情報を保持する。例えば、IR Column クラス33は、行・列の矩形座標データ、行・列に含まれる文字矩形のデータなどを保持する。IR Column クラス33は、1 または複数のIR Cordinate クラス34と関連している。   The IR Column class 33 holds information related to “column” or “row” included in the “vertical writing area” and “horizontal writing area”. For example, the IR Column class 33 holds rectangular coordinate data of rows and columns, character rectangle data included in the rows and columns, and the like. The IR Column class 33 is associated with one or more IR Cordinate classes 34.

IR Cordinate クラス34は、”列”または”行”に含まれる”文字矩形”の座標情報を保持する。また、段落位置についても合わせて管理する。その他に”縦書き”、”横書き”、”図表”領域および”行”、”列”の矩形座標の管理にも利用する。矩形座標は、図4 に示すように矩形左上の座標を基準とし、矩形の幅、高さを利用して管理する。例えば、IR Cordinate クラス34は、文字か段落かの種別、文字矩形の左上X 座標、文字矩形の左上Y 座標、文字矩形の幅、文字矩形の高さなどを保持する。   The IR Cordinate class 34 holds the coordinate information of the “character rectangle” included in the “column” or “row”. The paragraph position is also managed. In addition, it is also used to manage the rectangular coordinates of "vertical writing", "horizontal writing", "chart" area and "row", "column". As shown in FIG. 4, the rectangular coordinates are managed using the width and height of the rectangle based on the coordinates at the upper left corner of the rectangle. For example, the IR Cordinate class 34 stores the type of character or paragraph, the upper left X coordinate of the character rectangle, the upper left Y coordinate of the character rectangle, the width of the character rectangle, the height of the character rectangle, and the like.

本実施形態では、このように文書構造を階層的に管理して処理を行う。また、これらのデータは、レイアウト解析部1の記憶部18に格納される。   In this embodiment, the document structure is hierarchically managed as described above. Further, these data are stored in the storage unit 18 of the layout analysis unit 1.

次に、本実施形態の処理について説明する。   Next, the processing of this embodiment will be described.

以下にリフローデータ生成処理と、リフロー表示処理について説明する。   The reflow data generation process and the reflow display process will be described below.

<リフローデータ生成処理>
図5は、レイアウト解析部1が行う、リフローデータ生成処理のフローチャートである。ここでは、画像読み込みからリフローデータを生成するまでについて説明する。
<Reflow data generation processing>
FIG. 5 is a flowchart of the reflow data generation process performed by the layout analysis unit 1. Here, a process from reading an image to generating reflow data will be described.

[S11:画像の読み込み]
まず、画像読み込み部11は、処理対象となるデータ(文書データなど)を、画像として読み込み、記憶部18に記憶する。本実施形態では、例えば、プリミティブな画像処理にOpenCV を活用し、OpenCVは各種画像コーデックをサポートしているため、様々な形式(例えば、JPEG 形式、PNG 形式、TIFF 形式など)に対応可能であるものとする。なお、読み込みの際には、画像の2値化処理で使用するため、強制的にグレースケール画像として読み込むものとする。そして、読み込んだ画像のページ(画像ファイル)毎に、S12からS17の処理を行う。
[S11: Read image]
First, the image reading unit 11 reads data to be processed (such as document data) as an image and stores it in the storage unit 18. In this embodiment, for example, OpenCV is used for primitive image processing, and OpenCV supports various image codecs, so it can support various formats (for example, JPEG format, PNG format, TIFF format, etc.). Shall. When reading, it is assumed to be forcibly read as a grayscale image because it is used in the binarization processing of the image. Then, the process from S12 to S17 is performed for each page (image file) of the read image.

[S12:画像の2値化処理]
2値化処理部12は、S11で読み込まれた画像の2値化処理を行う。2値化処理は、濃淡がある画像(8bit 画像であれば0〜255)をある条件に従って、0 か1 の2値で表すように変換する処理のことである。ここでは、文字、もしくは図表がある部分を1、文字がない部分、すなわち背景を0 として認識するように2 値化を行う。画像の2値化処理により、画像の文字・図表部分(前景)と背景の分離を行うアルゴリズムについて、以下に説明する。
[S12: Binarization processing of image]
The binarization processing unit 12 performs binarization processing on the image read in S11. The binarization process is a process of converting an image with shading (0 to 255 in the case of an 8-bit image) to be represented by a binary value of 0 or 1 according to a certain condition. Here, binarization is performed so that a part with a character or a diagram is recognized as 1, and a part without a character, that is, a background is recognized as 0. An algorithm for separating the character / chart portion (foreground) and background of the image by the binarization processing of the image will be described below.

(1)前処理
最適な2 値化の結果を得るには、2 値化自体のアルゴリズム以外に前処理が重要である。本実施形態では、前処理として「背景の調整」と「網掛け領域の処理」の2つを行うものとする。
(1) Preprocessing In order to obtain the optimal binarization result, preprocessing is important in addition to the binarization algorithm itself. In the present embodiment, two processes, “background adjustment” and “shaded area processing”, are performed as preprocessing.

背景の調整については、後述する2値化処理では判別分析法を活用し、動的に閾値を決定し、2値化を行っている。このため、例えば白紙のページであったとしても、スキャニング時の問題で前景を検出してしまう可能性がある。そこで、本実施形態では、背景の輝度値は十分に明るいとを仮定し、例えば式1に示すように2値化を行う前に一定以上の輝度値lum[x,y]を持つ画素に対し、最大輝度値に変更する補正処理を行う。式1では、閾値の例として230に設定している。
Regarding background adjustment, binarization processing described later utilizes a discriminant analysis method to dynamically determine a threshold value and perform binarization. For this reason, even if it is a blank page, foreground may be detected due to a problem during scanning. Therefore, in the present embodiment, it is assumed that the luminance value of the background is sufficiently bright, and for example, for pixels having a luminance value lum [x, y] of a certain level or higher before binarization as shown in Equation 1. Then, correction processing for changing to the maximum luminance value is performed. In Equation 1, 230 is set as an example of the threshold value.

網掛け領域の処理については、印刷文書には網掛けによる表現を多く見ることができる。単色の印刷の場合、網掛け領域は図6に示すように黒と白のドットが交互に繰り返されることで表現されており、2値化処理時に前景として網掛け領域全体を検出できない場合がある。   With regard to the processing of the shaded area, many printed expressions can be seen in the printed document. In the case of monochrome printing, the shaded area is expressed by alternately repeating black and white dots as shown in FIG. 6, and the entire shaded area may not be detected as a foreground during binarization processing. .

そこで、本実施形態では、ボックスフィルタをかけ画像をあらかじめ平滑化することにより、網掛け領域を前景として検出できるようにする。ボックスフィルタのカーネルは、式2に示すようにn×nを採用し、アンカーはカーネル中心として処理を行う。nは、画面の分解能に合わせて所定の値(例えば、3など)を設定するものとする。
Therefore, in the present embodiment, a shaded area can be detected as a foreground by applying a box filter and smoothing the image in advance. The box filter kernel uses n × n as shown in Equation 2, and the anchor performs processing with the kernel center. n is set to a predetermined value (for example, 3) according to the resolution of the screen.

(2)2値化処理
2値化とは、画像の各ピクセルを背景クラスと前景クラスに分ける処理である。本実施形態においては、2値化処理に判別分析法を活用し、閾値を決定しているが、判別分析法以外の手法を用いて2値化処理を行うこととしてもよい。判別分析法ではクラス間分散ω とクラス内分散ωの比で表される分離度Tが最大となる閾値を決定する。
(2) Binarization processing
Binarization is a process of dividing each pixel of an image into a background class and a foreground class. In the present embodiment, the threshold value is determined using the discriminant analysis method in the binarization process, but the binarization process may be performed using a method other than the discriminant analysis method. In the discriminant analysis method, a threshold value that maximizes the degree of separation T expressed by the ratio between the interclass variance ω 0 and the intraclass variance ω i is determined.

図7に、2値化処理後の画像を示す。図表と文字が前景(白)として認識されていることが分かる。背景は、黒で表現されている。   FIG. 7 shows an image after the binarization processing. It can be seen that the chart and characters are recognized as the foreground (white). The background is expressed in black.

[S13:ラベリング処理]
ラベリング部13は、S12の2値化処理で検出された前景において、ピクセルの連結する成分毎に異なるラベルをつけていくラベリング処理を行う。すなわち、連結成分を囲む矩形をラベリング結果として抽出する。理想的には1文字もしくは1つの図表が、それぞれ1つの連結成分と認識される。例えば「日」という文字は1つの連結成分として得ることができる。このラベリングの結果を、初期ラベリング結果の保持リスト(srcArea)として記憶部18に格納する。
[S13: Labeling process]
The labeling unit 13 performs a labeling process in which a different label is attached to each component connected to pixels in the foreground detected by the binarization process in S12. That is, a rectangle surrounding the connected components is extracted as a labeling result. Ideally, one character or one chart is recognized as one connected component. For example, the letter “day” can be obtained as one connected component. The labeling result is stored in the storage unit 18 as an initial labeling result holding list (srcArea).

しかしながら、日本語の文字は複数の連結成分に分かれることも稀ではない。例えば、「現」という字は2つの連結成分に分かれてしまう。また図表も、必ずしも1つの連結成分として取得することはできないため、各種の統合処理が必要となる。1つの文字が複数のラベルに分離されている場合に各々の矩形が重なるような場合がある。   However, it is not uncommon for Japanese characters to be divided into a plurality of connected components. For example, the word “present” is divided into two connected components. Also, since charts cannot always be acquired as one connected component, various integration processes are required. When one character is separated into a plurality of labels, the rectangles may overlap.

そこで、例えば、図8のように重なりのある矩形の統合を行うことで、その後の処理を簡略化し、高速化を行うことができる。ここで、重なり合うラベルAの矩形と、ラベルBの矩形が統合前にそれぞれ(xa, ya, wa, ha)、(xb, yb, wb, hb)で表されているとする。なお、各ラベルの矩形は、図4で示したように、(矩形の左上x座標, 矩形の左上y座標, 矩形の幅, 矩形の高さ)で表すものとする。この場合、統合後のラベルの矩形は、以下のように変換する。   Therefore, for example, by integrating the overlapping rectangles as shown in FIG. 8, the subsequent processing can be simplified and the processing speed can be increased. Here, it is assumed that the rectangle of label A and the rectangle of label B are represented by (xa, ya, wa, ha) and (xb, yb, wb, hb), respectively, before integration. As shown in FIG. 4, the rectangle of each label is represented by (the upper left x coordinate of the rectangle, the upper left y coordinate of the rectangle, the width of the rectangle, the height of the rectangle). In this case, the integrated rectangle of the label is converted as follows.

(min(xa,xb), min(ya,yb), max(xa + wa, xb + wb) - min(xa, xb), max(ya + ha, yb + hb) - min(ya, yb))
初期ラベリング結果の保持リスト(srcArea)に格納されたラベリング結果からラベル同士を比較し、矩形が重なる場合はこのように統合(一方を削除し、もう一方を更新)を行う。
(Min (xa, xb), min (ya, yb), max (xa + wa, xb + wb)-min (xa, xb), max (ya + ha, yb + hb)-min (ya, yb) )
The labels are compared with each other from the labeling results stored in the initial labeling result holding list (srcArea), and if the rectangles overlap, the integration is performed in this way (one is deleted and the other is updated).

[S14:図表の認識処理]
図表認識部14は、S13で統合されたラベリング結果を用いて、図表を示す連結成分を抽出し、図表を表すラベルとそれ以外のラベルとに分ける。これは一般的に、図表が文字よりも大きいことなどのレイアウトに関する事前知識を活用して抽出を行う。また、図表と、それに紐づくキャプションは一体となってユーザに提示することが望ましいため、図表とそれに紐づくキャプションを示す連結成分の統合処理を行う。
[S14: Chart Recognition Process]
The chart recognition unit 14 extracts a connected component indicating the chart using the labeling result integrated in S13, and divides it into a label representing the chart and other labels. In general, the extraction is performed by utilizing prior knowledge about the layout such as that the chart is larger than the character. In addition, since it is desirable to present the chart and the caption associated therewith to the user as a unit, the integrated processing of the connected components indicating the chart and the caption associated therewith is performed.

(1)図表領域の取得
図表を表すラベルは、文字を表すラベルに比べて非常に大きいため、矩形サイズに閾値を設けることで容易に検出を行うことができる。本実施形態では、画像全体の面積の1% 以上の矩形面積の大きさを持つラベルを図表として認識し、記憶部18の図表領域リスト(IR Layout::imageArea)に格納する。また図表として認識されなかったラベルは、文字候補として、記憶部18の文字候補リスト(IR Layout::charCandidate)に格納する。
(1) Acquisition of a chart area Since a label representing a chart is much larger than a label representing a character, detection can be easily performed by providing a threshold value for the rectangular size. In the present embodiment, a label having a rectangular area size of 1% or more of the entire image area is recognized as a chart and stored in a chart area list (IR Layout :: imageArea) of the storage unit 18. A label that is not recognized as a chart is stored as a character candidate in a character candidate list (IR Layout :: charCandidate) in the storage unit 18.

(2)キャプションの統合
図表とそれの説明であるキャプションは、一覧性を保つために1つの図表領域として統合することが必要である。ここでは、検出された図表とキャプションを統合する処理について説明する。すなわち、図表領域の周囲のキャプションエリア候補に、文字候補としてのラベルが存在する場合、当該文字候補のラベルをキャプションと判別し、当該キャプションを図表領域に統合する。以下に、キャプションの統合処理について説明する。
(2) Integration of captions Charts and captions that describe them need to be integrated as a single chart area in order to maintain a list. Here, a process for integrating the detected chart and caption will be described. That is, when a label as a character candidate exists in the caption area candidates around the chart area, the label of the character candidate is determined as a caption, and the caption is integrated into the chart area. The caption integration process will be described below.

(a)キャプションエリア候補のヒストグラム生成
まず、検出された図表領域の周囲に、キャプションエリア候補を設定する。キャプションエリア候補は、図9に示すように図表領域70の4 辺から等距離Lの範囲を設定する。図表領域の上端をTop領域71、下端をBottom領域72、左端をLeft領域73、右端をRight領域74とする。距離Lは、例えば、図表領域を表すパラメータを利用し、L = min(width, height) としてもよい。すなわち、対象とする図表領域のwidth (幅)およびheight(高さ)の小さい方の値としてもよい。
(A) Histogram Generation of Caption Area Candidates First, caption area candidates are set around the detected chart area. As the caption area candidate, a range of equidistant L from the four sides of the chart area 70 is set as shown in FIG. The upper end of the chart area is the Top area 71, the lower end is the Bottom area 72, the left end is the Left area 73, and the right end is the Right area 74. The distance L may be set to L = min (width, height) using, for example, a parameter representing a chart area. That is, it may be the smaller value of the width (width) and height (height) of the target chart area.

本実施形態では、設定された4つのキャプションエリア候補で、前景のヒストグラムを計算する。Top 領域71およびBottom 領域72ではX 方向のヒストグラム、Left 領域73およびRight 領域74ではY 方向のヒストグラムを計算する。   In the present embodiment, a foreground histogram is calculated using the set four caption area candidates. In the Top area 71 and Bottom area 72, a histogram in the X direction is calculated, and in the Left area 73 and Right area 74, a histogram in the Y direction is calculated.

図9に示すように、キャプション(前景)があるRight 領域74とBottom 領域72ではヒストグラムの山75、76ができる。キャプションがないTop 領域71とLeft 領域73ではヒストグラムは平坦となる。   As shown in FIG. 9, histogram peaks 75 and 76 are formed in the Right region 74 and the Bottom region 72 with captions (foreground). In the Top area 71 and the Left area 73 where there is no caption, the histogram is flat.

なお、画像のX方向ないしY方向の各座標におけるその座標上に存在する前景(文字、文字矩形など)の指標となる値を計算することでヒストグラムを作成する。このヒストグラムの計算は、本実施形態では、図10に示すように、記憶部18の文字候補リスト(IR Layout::charCandidate)を活用して、文字候補として認識されたラベルの数をX 方向またはY 方向にカウントして、簡易的に計算することとする。図10に示すように、文字領域に3つの文字矩形が存在する場合、X 方向またはY 方向に各座標上に存在するラベルの数を取得する。   A histogram is created by calculating a value that is an index of the foreground (character, character rectangle, etc.) existing on each coordinate in the X direction or Y direction of the image. In the present embodiment, as shown in FIG. 10, the histogram is calculated by using the character candidate list (IR Layout :: charCandidate) in the storage unit 18 to calculate the number of labels recognized as character candidates in the X direction or Count in the Y direction and calculate simply. As shown in FIG. 10, when three character rectangles exist in the character area, the number of labels present on each coordinate in the X direction or the Y direction is acquired.

具体的には、文字領域内の各ラベルの領域rについて、
X 方向のヒストグラムを作成する場合は、当該ラベルの領域rの左端≦i≦右端を満たす全てのiについてhx(i)に1を加え、
Y 方向のヒストグラムを作成する場合は、当該ラベルの領域rの上端≦i≦下端を満たす全てのjについてhx(j)に1を加える。
Specifically, for the area r of each label in the character area,
When creating a histogram in the X direction, 1 is added to hx (i) for all i satisfying the left end ≦ i ≦ right end of the region r of the label,
When creating a histogram in the Y direction, 1 is added to hx (j) for all j satisfying the upper end ≦ i ≦ lower end of the region r of the label.

これにより、本実施形態では、精度を落とすることなく、高速な計算を実現する。   Thereby, in this embodiment, high-speed calculation is realized without reducing accuracy.

なお、ヒストグラムは、図11に示すように、文字領域の画像の画素自身を走査することで作成してもよい。   Note that the histogram may be created by scanning the pixels of the image of the character area as shown in FIG.

(b)キャプションエリアの設定と領域の更新
ヒストグラムの計算が終わった後、キャプションエリアを設定する。図12のBottom 領域に示すように、ヒストグラムのランレングスを計算し、最も外側のヒストグラム81のランの終端82までをキャプションエリア83として拡張する。
(B) Setting of caption area and update of area After the calculation of the histogram is completed, the caption area is set. As shown in the Bottom area of FIG. 12, the run length of the histogram is calculated, and the run end 82 of the outermost histogram 81 is expanded as a caption area 83.

この際、図12のTop 領域84のようにヒストグラム85は存在するものの、ヒストグラム85のランがキャプションエリア候補84を超えて存在する場合(ランがキャプションエリア候補内で収束しない場合)には、キャプションではないと判断し、図表領域の拡張を行わない。   At this time, although the histogram 85 exists as in the Top area 84 of FIG. 12, if the run of the histogram 85 exists beyond the caption area candidate 84 (when the run does not converge within the caption area candidate), the caption is displayed. Therefore, the chart area is not expanded.

また、図13に示す例では、キャプションエリア候補のRight領域には、キャプションではない本文のラベル(文字候補)が存在する。この場合、図12のTop 領域84とは異なり、本文のラベルの隙間(行間)が、キャプションエリア候補の境界91と一致する(重なる)場合がある。このとき、ヒストグラムの山ができ、ヒストグラムのランがキャプションエリア候補を超えて存在しない(ランがキャプションエリア候補内で収束している)と判別され、本文のラベルをキャプションとして誤検出してしまう問題がある。このため、本実施形態では、ヒストグラムのラン毎に、キャプションエリア候補の境界92に重なるラベルがあるか否かをチェックする。ラベルがある場合、そのランに属する領域は、キャプションではないと判断する。図13の場合、ラベル93が境界92に重なっているため、ラン95に属する領域はキャプションではないと判断する。また、この処理において、文字間の隙間が境界92と一致してしまう場合がある。そこで、境界92の外側の一定範囲94に文字候補として認識されたラベルがあるか否かもチェックし、ラベルがある場合は、そのランに属する領域は、キャプションではないと判断する。図13では、ラン96に対応する行の文字間が境界92と一致しているが、範囲94にラベルが含まれるため、ラン96に属する領域はキャプションではないと判断する。境界と重なるラベル、境界の外側の一定範囲にあるラベルのいずれも存在しない場合、キャプションとして判断する。   In the example illustrated in FIG. 13, a label (character candidate) of a text that is not a caption exists in the right area of the caption area candidate. In this case, unlike the Top region 84 in FIG. 12, the label gap (line spacing) of the text may coincide with (overlap) the boundary 91 of the caption area candidate. At this time, a histogram peak is created, and it is determined that the histogram run does not exist beyond the caption area candidate (the run has converged within the caption area candidate), and the label of the text is erroneously detected as a caption. There is. For this reason, in the present embodiment, it is checked for each run of the histogram whether there is a label overlapping the boundary 92 of the caption area candidate. If there is a label, it is determined that the area belonging to the run is not a caption. In the case of FIG. 13, since the label 93 overlaps the boundary 92, it is determined that the region belonging to the run 95 is not a caption. In this process, the gap between characters may coincide with the boundary 92. Therefore, it is also checked whether or not there is a label recognized as a character candidate in a certain range 94 outside the boundary 92. If there is a label, it is determined that the area belonging to the run is not a caption. In FIG. 13, the character line of the line corresponding to the run 96 matches the boundary 92, but since the label is included in the range 94, it is determined that the area belonging to the run 96 is not a caption. If neither a label that overlaps the boundary nor a label in a certain range outside the boundary exists, it is determined as a caption.

以上のようにして、キャプションエリアを設定した後、記憶部18の文字候補リスト(IR Layout::charCandidate)に格納されている文字候補領域でキャプションエリア内に存在している領域の削除を行い、図表領域をキャプションエリア分拡大して更新する。また取得した図表領域の面積の和を計算し、図表領域の面積(IR Layout::FIGURE AREA)に格納する(後々のレイアウト変換に利用する)。   After setting the caption area as described above, the area existing in the caption area in the character candidate area stored in the character candidate list (IR Layout :: charCandidate) in the storage unit 18 is deleted. The chart area is enlarged and updated by the caption area. Also, the sum of the areas of the obtained chart regions is calculated and stored in the area of the chart region (IR Layout :: FIGURE AREA) (used for later layout conversion).

以上により、S14では、S13のラベリング結果を、図表領域リスト(IR Layout::imageArea )と、文字候補リスト(IR Layout::charCandidate)とに分ける。   As described above, in S14, the labeling result in S13 is divided into a chart area list (IR Layout :: imageArea) and a character candidate list (IR Layout :: charCandidate).

[S15:文字情報の切り出し]
文字切り出し部15は、記憶部18の文字候補リスト(IR Layout::charCandidate)を用いて、1 文字、1文字の矩形を切り出す処理を行う。
[S15: Cutting out character information]
The character cutout unit 15 uses the character candidate list (IR Layout :: charCandidate) in the storage unit 18 to perform a process of cutting out one character and one character rectangle.

すなわち、図表およびキャプションとして認識されなかった文字候補のラベルは、文字を構成していると考えられる。まず、これらの文字を構成しているラベルの画像内分布より、文字領域を矩形として定義する。次に定義された文字領域内で文字が縦書きで書かれているか、もしくは横書きで書かれているかを、文字領域内のラベルの分布から推測する。定義された各文字領域内で縦書き・横書きが判別できた後に、縦書きの場合には列、横書きの場合には行の認識を行い、最後に1 文字、1 文字の切り出しを行う。以下に、これらの処理について説明する。   That is, it is thought that the label of the character candidate which was not recognized as a chart and a caption constitutes a character. First, the character area is defined as a rectangle from the distribution in the image of the labels constituting these characters. Next, it is inferred from the distribution of labels in the character area whether the character is written vertically or horizontally in the defined character area. After vertical / horizontal writing can be discriminated within each defined character area, columns are recognized for vertical writing and rows for horizontal writing, and one character and one character are cut out at the end. Hereinafter, these processes will be described.

(1)文字領域の取得
まず、文字候補リスト(IR Layout::charCandidate)のデータを用いて、文字領域を取得する。一般的な書籍を対象と仮定すれば、縦方向で文書の領域を分割することができる。例えば、文書の上部から柱領域(章題などが書かれるエリア)、本文領域、ノンブル領域(ページ番号の書かれるエリア)のように分割して別の領域として考えることが可能である。そこで、文字候補リスト(IR Layout::charCandidate)を利用して、Y 方向の前景ヒストグラムを作成し、このランレングスを計算することで領域の縦分割を行う。
(1) Acquisition of character area First, a character area is acquired using data of a character candidate list (IR Layout :: charCandidate). Assuming that a general book is a target, it is possible to divide the document area in the vertical direction. For example, it can be divided into a column area (an area where chapter titles are written), a body area, and a noble area (area where page numbers are written) from the top of the document and considered as a separate area. Therefore, a foreground histogram in the Y direction is created using a character candidate list (IR Layout :: charCandidate), and the area is divided vertically by calculating this run length.

図14に、縦分割の方法を示す。画像101の中で、柱領域102、本文領域103、ノンブル領域104が異なる領域として認識できていることが分かる。図表が入るページの場合にも文字候補リスト(IR Layout::charCandidate)を利用してヒストグラムを作成するため、図表部分105は無視してこの処理を行うことが可能である。   FIG. 14 shows a vertical division method. It can be seen that in the image 101, the column area 102, the body area 103, and the folio area 104 can be recognized as different areas. Even in the case of a page containing a chart, since the histogram is created using the character candidate list (IR Layout :: charCandidate), the chart portion 105 can be ignored and this process can be performed.

また、同じ領域でありながら、偶然、文字の切れ目が一致することにより、複数の領域に分割されてしまうことがある。これを防ぐため隣接領域が十分近い場合(例えば、30 ピクセル以内など)、領域の統合を行うこととする。   In addition, even though the area is the same, it may be divided into a plurality of areas due to coincidence of character breaks. In order to prevent this, if adjacent areas are sufficiently close (for example, within 30 pixels), the areas should be integrated.

最終的に分割された領域に含まれる文字候補リスト(IR Layout::charCandidate)の矩形領域のX 方向最小値と最大値を求め、文字領域を決定する。具体的には、
文字候補の上端≧分割された文字領域の上端、
かつ、 文字候補の下端≦分割された文字領域の下端、
を満たす全ての文字候補の中で、最小の左端および最大の右端を、それぞれ文字領域の左端および右端とする。取得した文字領域は、記憶部18の文字領域リスト(IR Layout::charArea)に格納しておく。
The character area is determined by obtaining the minimum value and maximum value in the X direction of the rectangular area of the character candidate list (IR Layout :: charCandidate) included in the finally divided area. In particular,
Upper end of character candidate ≧ upper end of divided character area,
And the lower end of the character candidate ≦ the lower end of the divided character area,
Among all the character candidates satisfying the above, the minimum left end and the maximum right end are set as the left end and the right end of the character area, respectively. The acquired character area is stored in a character area list (IR Layout :: charArea) in the storage unit 18.

(2)文字方向の推定
取得された文字領域で、文字が縦書きで書かれているか、横書きで書かれているかを判定する。まず、図15に示すように、取得された文字領域内でX 方向、Y 方向のヒストグラムを作成する。ヒストグラム作成後、X 方向、Y 方向の双方で、白ラン(連続する前景ヒストグラムの長さ)および黒ラン(連続する背景ヒストグラムの長さ)の平均を計算する。ただし、前景ヒストグラム、背景ヒストグラムとは、それぞれ、ヒストグラムの値が0より大きい部分、ヒストグラムの値が0である部分のことである。
(2) Estimating character direction In the acquired character area, it is determined whether characters are written in vertical writing or horizontal writing. First, as shown in FIG. 15, histograms in the X direction and the Y direction are created in the acquired character area. After creating the histogram, calculate the average of the white run (the length of the continuous foreground histogram) and the black run (the length of the continuous background histogram) in both the X and Y directions. However, the foreground histogram and the background histogram are a portion where the histogram value is greater than 0 and a portion where the histogram value is 0, respectively.

ここでは、X 方向の白ランの平均をxwrun、黒ランの平均をxbrunとし、Y 方向の白ランの平均をywrun、黒ランの平均をybrun とする。   Here, the average of white runs in the X direction is xwrun, the average of black runs is xbrun, the average of white runs in the Y direction is ywrun, and the average of black runs is ybrun.

例えば、図15に示すように、文字領域が縦書きである場合、ybrun はほとんどなくなる。縦書きをY 方向に射影すると文字がない部分はほとんど表れないためである。反対にxbrun は一定の値を持つことになる。なぜならば、行間に文字のないスペースが定期的に生じるためである。つまり、xbrun > ybrun の場合、基本的に縦書きと判定し、それ以外は横書きと判定する。   For example, as shown in FIG. 15, when the character area is vertically written, ybrun is almost eliminated. This is because when vertical writing is projected in the Y direction, almost no parts appear. Conversely, xbrun has a constant value. This is because spaces without characters are regularly generated between lines. That is, when xbrun> ybrun, it is basically determined as vertical writing, otherwise it is determined as horizontal writing.

しかしながら、この条件には例外が存在する。それは、横書きで1行だけの場合である。複数行ある横書き領域の場合には上記の条件で問題がないが、1行だけの場合には、ybrun はほぼゼロとなり、xbrun は一定の値を持つため、縦書きと判定されてしまう。例えば、柱領域やノンブル領域はこのままだと縦書き領域と判定されてしまうことになる。   However, there are exceptions to this condition. That is the case of horizontal writing with only one line. In the case of a horizontal writing area with multiple lines, there is no problem with the above conditions. However, if there is only one line, ybrun is almost zero and xbrun has a constant value, so it is determined as vertical writing. For example, a column area or a noble area is still determined as a vertical writing area.

そこで、これを回避するために、以下の条件1および条件2を満たす場合には、横書きの1 行だと認識し、xbrun > ybrun であっても横書きと判定する。   Therefore, in order to avoid this, when the following condition 1 and condition 2 are satisfied, it is recognized that the line is horizontal writing, and horizontal writing is determined even if xbrun> ybrun.

条件1:文字領域の高さheigtと、ybrun が同程度の大きさである。例えば、以下の式を満たす場合、同程度であると判定する。
Condition 1: The height heigt of the character area and ybrun are about the same size. For example, when the following expression is satisfied, it is determined that they are approximately the same.

条件2:xwrun と、ywrun の大きさがあまり離れていない。例えば、以下の式を満たす場合、あまり離れていないと判定する。
Condition 2: xwrun and ywrun are not so far apart. For example, when the following expression is satisfied, it is determined that the distance is not so far.

条件1および条件2の例外条件を追加することで、文字領域の縦書き・横書きを正しく認識することができる。判定された縦書き・横書きの結果は記憶部18のIR Area の領域の種別に格納しておく。   By adding the exception conditions of condition 1 and condition 2, it is possible to correctly recognize vertical writing and horizontal writing of the character area. The determined vertical writing / horizontal writing results are stored in the IR Area area type of the storage unit 18.

(3)傾き推定
文字領域の縦書き・横書きが判定できたら、縦書きの場合はX 方向のヒストグラムを利用して列を取得し、横書きの場合はY 方向のヒストグラムを利用して行の取得を行う。以降は簡単のため、文字領域が縦書きである場合について説明する。
(3) Inclination estimation Once vertical / horizontal writing of a character area has been determined, the column is acquired using the histogram in the X direction for vertical writing, and the row is acquired using the histogram in the Y direction for horizontal writing. I do. Hereinafter, for the sake of simplicity, a case where the character area is vertically written will be described.

取得された文字領域の中で最も大きい文字領域を特定し、当該文字領域をn分割する。縦書きの文字領域であれば横に分割し(X 方向の線で分割し)、横書きの文字領域であれば縦に分割する(Y 方向の線で分割する)。なお、文字領域の分割は、等分するのが望ましいが、等分でない場合は分割比率等を用いることとしてもよい。   The largest character area among the acquired character areas is specified, and the character area is divided into n. If it is a vertically written character area, it is divided horizontally (divided by lines in the X direction). If it is a horizontally written character area, it is divided vertically (divided by lines in the Y direction). It should be noted that the character area is preferably divided equally, but if it is not equally divided, a division ratio or the like may be used.

図16は、傾き推定を説明するための図である。ここでは、文字領域121を上下に2等分する場合を例として説明する。まず、分割した各領域122、123において、X方向の前景のヒストグラムを作成する。すなわち、上部領域122のヒストグラムhu(x)と、下部領域123のヒストグラムhd(x)とを作成する。なお、ヒストグラムは、前述した図10または図11の方法により作成する。S11で読み込まれた画像が傾いている場合、その傾きに応じて、分割した領域122、123のヒストグラムのラン(山)の位置がずれる。そのため、以下のc(x)が最大となるx(傾きを補正するためにずらす量)を算出する。
FIG. 16 is a diagram for explaining inclination estimation. Here, a case where the character region 121 is divided into two equal parts in the vertical direction will be described as an example. First, a foreground histogram in the X direction is created in each of the divided regions 122 and 123. That is, the histogram hu (x) of the upper region 122 and the histogram hd (x) of the lower region 123 are created. The histogram is created by the method shown in FIG. 10 or FIG. When the image read in S11 is tilted, the positions of the histogram runs (mountains) of the divided regions 122 and 123 are shifted according to the tilt. Therefore, x (the amount to be shifted to correct the inclination) that maximizes the following c (x) is calculated.

なお、bu(i)は、上部領域122のヒストグラムhu(x)を2値化するものであって、ヒストグラムhu(i)が0より大きい場合(少なくとも1つの文字候補のラベルが存在する場合)は「+1」を設定し、それ以外(文字候補のラベルが1つも存在しない場合)は「-1」を設定する。なお、iは、x座標である。bd(i)は、下部領域123のヒストグラムhd(i)を2値化するものであって、bu(i)と同様である。   Note that bu (i) binarizes the histogram hu (x) of the upper region 122 and the histogram hu (i) is greater than 0 (when at least one character candidate label exists). Sets “+1”, otherwise “-1” is set (if there is no character candidate label). Note that i is an x coordinate. bd (i) binarizes the histogram hd (i) of the lower region 123 and is the same as bu (i).

そして、算出したxを用いて画像の傾きsを、以下の式により推定する。   Then, using the calculated x, the inclination s of the image is estimated by the following equation.

傾きs = x ÷ (文字領域の高さ ÷ 2)
図16に示す例では、2等分した場合の例であるため、上記式では(文字領域の高さ ÷ 2)としているが、分割数に応じて分割した領域間の距離を設定する。すなわち、分割領域のうち2つが選択されたとき、
傾きs=x÷(|一方の領域の中心のy座標−他方の領域の中心のy座標|÷2)
とする。また、分割数が3以上の場合は分割領域の選択方法が複数通りあるため、例えばy座標が最も離れた2つを選択してもよいし、y座標が小さい方から2つを選択してもよい。一般的には分割領域の距離が離れている方が高精度になるため前者を用いるが、小説等でせりふが多い文字領域など、文字領域の下方まで文字が続かない行が多いときには後者の方がよい場合がある。さらに、分割領域の組み合わせを複数とって各々でsを算出し、その平均値や中央値をとってもよい。複数の組み合わせは、全ての組み合わせや、隣接する分割領域の組み合わせでもよいし、他の組み合わせでも構わない。
Slope s = x ÷ (height of character area ÷ 2)
In the example shown in FIG. 16, since it is an example of dividing into two equal parts, in the above formula, the height of the character area is divided by 2, but the distance between the divided areas is set according to the number of divisions. That is, when two of the divided areas are selected,
Inclination s = x ÷ (| y coordinate of the center of one area -y coordinate of the center of the other area | ÷ 2)
And In addition, when the number of divisions is 3 or more, there are a plurality of selection methods for the divided regions. For example, two of the most distant y coordinates may be selected, or two of the y coordinates may be selected from the smaller one. Also good. In general, the former is used because the accuracy is higher when the distance between the divided areas is larger. However, the latter is preferred when there are many lines in which characters do not continue below the character area, such as character areas with many lines in novels. May be good. Further, a plurality of combinations of divided areas may be taken to calculate s for each, and an average value or median value thereof may be taken. The plurality of combinations may be all combinations, combinations of adjacent divided areas, or other combinations.

なお、本実施形態では、読み込んだ画像のページ全体の傾きを、ページ内で面積が最大の文字領域を用いて推定しているが、ページ内の文字領域毎に上記の方法により傾きを推定し、文字領域毎の傾きを保持することとしてもよい。ページ全体の傾きを推定する場合、最大の文字領域を用いることで、他の小さい文字領域における傾き推定の失敗を回避することができるとともに、処理時間を短縮することができる。一方、文字領域毎に傾きを推定する場合、画像に幾何学的な歪みが発生している場合(例えば、スキャンが曲がってる場合等)に、各文字領域単位で高精度な傾きを推定することができる。   In this embodiment, the inclination of the entire page of the read image is estimated using the character area having the largest area in the page, but the inclination is estimated by the above method for each character area in the page. The inclination for each character area may be held. When estimating the inclination of the entire page, by using the largest character area, it is possible to avoid the inclination estimation failure in other small character areas and to shorten the processing time. On the other hand, when estimating the inclination for each character area, when the image has a geometric distortion (for example, when the scan is bent), the inclination is estimated with high accuracy for each character area. Can do.

(4)行・列の取得
文字領域の縦書き・横書きを判定し、傾きの推定を終えると、縦書きの場合はX 方向のヒストグラムを利用して列を取得、横書きの場合はY 方向のヒストグラムを利用して行の取得を行う。ここでは、文字領域が縦書きである場合について説明を行う。
(4) Row / column acquisition After vertical / horizontal writing of the character area is determined and the inclination is estimated, the column is acquired using the histogram in the X direction for vertical writing, and the Y direction for horizontal writing. Use the histogram to get the rows. Here, a case where the character area is vertically written will be described.

まず、ヒストグラムの前景のランレングスを検出することで、列幅を取得していく。この際、極端に幅の小さい(3 ピクセル以下)場合は、誤検出だとして無視をする。   First, the column width is obtained by detecting the run length of the foreground of the histogram. At this time, if it is extremely small (3 pixels or less), it is ignored as a false detection.

ここで、推定した傾きsを考慮したヒストグラムを再作成する。図17(a)は、傾いた文字領域について再作成したヒストグラムの例である。図示する例では、推定した傾きsの分だけ文字候補のラベルの加算位置をずらしてヒストグラムを作成している。具体的には、各ラベルの領域rについて、その領域rの左端≦ i ≦ 右端を満たす全てのiについて、h(i + s * (領域rの上端))に1を加える。これにより、傾きsの分だけ領域rの加算位置をずらしたヒストグラム131が作成される。   Here, a histogram in consideration of the estimated slope s is recreated. FIG. 17A shows an example of a histogram recreated for a tilted character area. In the illustrated example, the histogram is created by shifting the addition position of the character candidate labels by the estimated inclination s. Specifically, for each label region r, 1 is added to h (i + s * (upper end of region r)) for all i satisfying the left end ≦ i ≦ right end of the region r. As a result, a histogram 131 is created by shifting the addition position of the region r by the inclination s.

そして、図17(b)に示すように、作成されたヒストグラムの山の範囲に含まれる各ラベルの領域rを列に含め、当該列に含めた各ラベルの領域rの幅を、ヒストグラムのランレングス(幅)に合わせて、更新する。具体的には、各ラベルの領域rについて、
領域rの左端 ≦ ヒストグラムの左端 + s * 領域rの上端 かつ
領域rの右端 ≦ ヒストグラムの右端 + s * 領域rの上端
の場合、以下の処理を行う。
Then, as shown in FIG. 17B, the region r of each label included in the peak range of the created histogram is included in the column, and the width of the region r of each label included in the column is calculated as the histogram run. Update to match the length. Specifically, for the area r of each label,
When the left end of the region r ≦ the left end of the histogram + s * the upper end of the region r and the right end of the region r ≦ the right end of the histogram + s * the upper end of the region r, the following processing is performed.

領域rを列に含め、領域rの左端を「ヒストグラムの左端 - s * 領域rの上端」に設定し、領域rの幅をヒストグラムのランレングスと同じにする。これにより、各ラベルの領域rの幅が、列幅と等しくなり、同じ列に格納されている文字候補をレンダリング時に並べやすくなる。   The region r is included in the column, the left end of the region r is set to “left edge of the histogram−s * the upper end of the region r”, and the width of the region r is the same as the run length of the histogram. Thereby, the width of the region r of each label becomes equal to the column width, and the character candidates stored in the same column can be easily arranged at the time of rendering.

次に、取得した列幅の範囲に含まれる文字候補リスト(IR Layout::charCandidate)のデータのY 方向の最小値、最大値を利用して列の高さを取得して、列領域リスト(charArea.column )として、列を表す矩形情報と、列に含まれる文字候補リスト(IR Layout::charCandidate) のデータとを記憶部18に格納する。   Next, the column height is obtained using the minimum and maximum values in the Y direction of the data of the character candidate list (IR Layout :: charCandidate) included in the acquired column width range, and the column area list ( (CharArea.column), the rectangular information representing the column and the data of the character candidate list (IR Layout :: charCandidate) included in the column are stored in the storage unit 18.

本実施形態では、このように傾きを推定し、推定した傾きの分だけずらしてヒストグラムを生成する。これにより、列として切り出した列領域または行として切り出した行領域に、余分な領域が含まれることなく、本来の画像の列領域または行領域を正しく切り出すことができる。なお、文書画像が傾いている状態で、文書画像の垂直方向または水平方向に列または行が存在するものとして処理した場合は、作成したヒストグラムのランレングスが本来の列幅または行の高さより大きくなってしまい、結果として切り出した列領域または行領域に余分な領域が含まれてしまう。本実施形態では、傾きを推定することで、切り出した列領域または行領域に余分な領域が含まれることを回避することができる。   In the present embodiment, the inclination is estimated in this way, and a histogram is generated by shifting by the estimated inclination. Thereby, the column area or the row area of the original image can be correctly cut out without including an extra area in the row area cut out as a column or the row area cut out as a row. If the document image is tilted and processed as if there were columns or rows in the vertical or horizontal direction of the document image, the run length of the created histogram is larger than the original column width or row height. As a result, an extra area is included in the extracted column area or row area. In the present embodiment, by estimating the inclination, it can be avoided that an extra region is included in the extracted column region or row region.

次に、文字候補、行・列領域、および文字領域の読み順への並び替えを行う。最後のデータ出力や文字の切り出しに備えて、ここまで取得したリストを読み順に並べ替えておく必要がある。図18は、縦書きの場合と横書きの場合の読み順の並べ替えを示すものである。図18では、数字が読み順を示している。図示するように、行・列に含まれる文字候補は、列の場合はパラメータy が小さい順、行の場合はパラメータx が小さい順に並べ替えておく。行・列領域のリストは、列の場合はパラメータx が大きい順、行の場合はパラメータy が小さい順に並べ替えておく。   Next, the character candidates, row / column regions, and character regions are rearranged in the reading order. In preparation for the last data output or character segmentation, it is necessary to rearrange the list acquired so far in the reading order. FIG. 18 shows the rearrangement of the reading order in the case of vertical writing and in the case of horizontal writing. In FIG. 18, the numbers indicate the reading order. As shown in the figure, the candidate characters included in the row / column are rearranged in the order of the parameter y decreasing in the case of a column and in the order of decreasing parameter x in the case of a row. The list in the row / column area is sorted in the order of increasing parameter x in the case of columns, and in decreasing order of parameter y in the case of rows.

文字領域リストは、まず画面全体の列面積(IR Layout::CHARV AREA )および行面積(IR Layout::CHARH AREA)を取得し、画面全体が縦書きの構成か横書きの構成か判定を行う。すなわち、IR Layout::CHARV AREA > IR Layout::CHARH AREA で縦書き、それ以外で横書きであると判断する。   The character area list first obtains the column area (IR Layout :: CHARV AREA) and line area (IR Layout :: CHARH AREA) of the entire screen, and determines whether the entire screen is in a vertical writing configuration or a horizontal writing configuration. That is, it is determined that IR Layout :: CHARV AREA> IR Layout :: CHARH AREA is vertical writing and horizontal writing is otherwise.

この判断結果によって、縦書きと判断された場合には、領域のY 方向が重なる場合、パラメータx が大きい順、それ以外の場合にはパラメータy が小さい順に並べ替える。横書きと判断された場合には、領域のY 方向が重なる場合、パラメータx が小さい順、それ以外の場合にはパラメータy が小さい順に並べ替える。   If it is determined that the vertical writing is made based on the determination result, if the Y directions of the regions overlap, the parameter x is sorted in the descending order, and in other cases, the parameter y is sorted in the ascending order. If it is determined that the writing is horizontal writing, if the Y direction of the areas overlap, the parameter x is sorted in ascending order, otherwise the parameter y is sorted in ascending order.

(5)ルビの統合
これまでに取得された行・列の中にはルビに当たるものも含まれている。ルビを単独でリフローして表示してしまうと、意味が通らなくなってしまうため、ルビはルビをつける対象の文字矩形と統合を行う。
(5) Integration of ruby Some of the rows and columns acquired so far include ruby. If the ruby is reflowed and displayed alone, the meaning will not be understood, so ruby will be integrated with the target character rectangle.

ルビの特徴として、ルビをつける対象の文字矩形から距離が近い、ルビは対象の文字矩形に対し、列幅または行の高さが小さいことである。この2つの特徴を利用してルビを統合する。図19にルビ統合の処理を示す。   As a feature of ruby, the distance from the character rectangle to which ruby is attached is short, and ruby has a smaller column width or row height than the target character rectangle. Ruby is integrated using these two features. FIG. 19 shows ruby integration processing.

ここでは、簡単のために縦書きの場合で説明する。この場合、ルビは文字の右側に付くことになる。いま、隣接する列の内、右側の列をCr、左側の列をCl としたとき、まず列間の距離l = Cr.x - (Cl.x + Cl.width)を計算する。この距離l が列幅Cl.width の半分以下である場合、十分距離が近いと判定する。さらに、列幅の比(Cr.Width / Cl.width )が0.5以下の場合に、列幅が隣接する列幅と比較して小さいと判定する。なお、ここで判定に用いた閾値(列幅の“半分”以下、列幅の比の“0.5”以下)は例示であって、これ以外の値を用いることとしてもよい。   Here, for the sake of simplicity, the case of vertical writing will be described. In this case, ruby is attached to the right side of the character. If the right column is Cr and the left column is Cl 2, the distance between columns is l = Cr. Calculate x-(Cl.x + Cl.width). This distance l is the column width Cl. If it is less than half of width, it is determined that the distance is sufficiently close. Further, when the column width ratio (Cr.Width / Cl.width) is 0.5 or less, it is determined that the column width is smaller than the adjacent column width. It should be noted that the threshold values used in the determination (the column width is “half” or less and the column width ratio is “0.5” or less) are merely examples, and other values may be used.

この2つの判定により、ルビ列として判定された場合、ルビ列とY 方向で重なっている文字矩形をルビ列の右端まで拡張する。また、レンダリングの際の文字センタリングを容易にするため、ここで右端まで拡張した分と同じだけ左端も拡張する。   If it is determined as a ruby string by these two determinations, the character rectangle that overlaps the ruby string in the Y direction is extended to the right end of the ruby string. Also, in order to facilitate character centering during rendering, the left end is expanded as much as the portion extended to the right end here.

(6)文字の切り出し
日本語を構成する文字(漢字、ひらがな)は、1つ文字が1つの連結成分とはなっていないため、これまでの処理で得られた文字候補の矩形は、1つの文字が複数の矩形に分かれてしまうことが頻繁に起こる。そこで、1つの文字であると推定できる文字候補の矩形同士を統合し、さらにレンダリング時のリフロー配置を見易くするために改行の認識、文字間隔の整形を行う。
(6) Character segmentation Characters that make up Japanese (Kanji, Hiragana) are not connected to one character, so the rectangle of candidate characters obtained by the previous processing is one It often happens that characters are divided into multiple rectangles. Therefore, the rectangles of character candidates that can be estimated to be one character are integrated, and line breaks are recognized and character spacing is shaped to make it easier to see the reflow arrangement during rendering.

(a)文字矩形の統合
これまでの処理により、文字矩形は行・列に属し、行の場合、並び順はX方向の小さい順、矩形の高さは行の高さと等しくなっており、列の場合、並び順はY方向の小さい順、矩形の幅は列幅と等しくなっている(ルビと統合した矩形は除く)。すなわち、行の場合はY方向、列の場合はX方向での統合を考える必要はなく、並んでいる矩形を順に統合するかどうか判断すれば良いことになる。矩形の統合ルールとして日本語の文字の特徴、文字の幅と高さが同程度となることを利用した。
(a) Integration of character rectangles By the processing so far, character rectangles belong to rows and columns, and in the case of rows, the order of arrangement is the smallest in the X direction, the height of the rectangles is equal to the height of the rows, and the columns In the case of, the order of arrangement is the smallest in the Y direction, and the width of the rectangle is equal to the column width (except for the rectangle integrated with ruby). That is, there is no need to consider integration in the Y direction for rows and X direction for columns, and it is only necessary to determine whether or not the arranged rectangles should be integrated in order. We used the characteristics of Japanese characters and the fact that the width and height of the characters are the same as the rectangle integration rule.

以降は簡単のため、列内の文字矩形統合(縦書き)について説明を行う。これは列毎に文字矩形の並び順の前後で矩形の統合を判断することで実現する。まず前後の矩形が一部重なる場合には無条件で統合を行う。矩形の重なりはS13のラベリング処理ですでに行っているが、例えば、”い”という文字は初期のラベリング結果では左の部分と右の部分が重なっていないが、列に属した段階で幅を列幅に更新しているため、新たに矩形が重なることが生じる。   Hereinafter, for the sake of simplicity, the character rectangle integration (vertical writing) in the column will be described. This is realized by determining the integration of the rectangles before and after the arrangement order of the character rectangles for each column. First, if the front and rear rectangles partially overlap, unification is performed unconditionally. The overlapping of the rectangles has already been performed in the labeling process of S13. For example, the character “I” does not overlap the left part and the right part in the initial labeling result. Since the column width is updated, new rectangles may overlap.

次に前後の矩形が重なっていない場合には矩形を統合した場合の矩形高さheightn を以下の式より算出する。
Next, when the front and rear rectangles do not overlap, the rectangle height heightn when the rectangles are merged is calculated from the following equation.

いま、列幅をcolumn_width としたときに、以下の式を満たす場合に統合を行う。なお、以下の式の右辺の“1.0”は例示であって、これ以外の値を用いることとしてもよい。
Now, when the column width is column_width, integration is performed when the following formula is satisfied. Note that “1.0” on the right side of the following expression is an example, and other values may be used.

また、前後の文字矩形がルビを統合した矩形だった場合には統合を行う。これはビューワ側での禁則の関係で、一連のルビが付いた文字は複数の文字からなっていていても、1つの矩形として切り出す。なお、ルビを統合した矩形かどうかは列幅と矩形の幅が異なることから判断することができる。   Also, if the preceding and following character rectangles are rectangles in which ruby is integrated, integration is performed. This is forbidden on the viewer side, and even if a character with a series of ruby characters consists of multiple characters, it is cut out as a single rectangle. Note that it is possible to determine whether or not the rectangle is a combination of ruby because the column width is different from the rectangle width.

(b)改行の認識
リフロー表示部3のレンダリング部31でリフローを行う際に改行を把握していると、適切に改行を入れることができ、読み易さに寄与することができるため、段落の認識を行う。
(b) Recognizing line breaks When the rendering unit 31 of the reflow display unit 3 recognizes a line break when performing reflow, it can properly insert a line break and contribute to readability. Recognize.

行・列毎に文字の統合を行っていく際に、行・列に含まれている最後の文字矩形に到達した場合に改行が存在するかを認識する。簡単のため、縦書きについて説明すると、文字領域のY 方向下端と比較して、最後の文字矩形のY 方向下端、すなわち列のY 方向下端に距離がある場合に改行があると認識を行う。具体的には列幅のnd倍以上(例えば0.7 倍以上)の距離がある場合に改行があると考える。 When integrating characters for each row / column, it recognizes whether a line break exists when the last character rectangle contained in the row / column is reached. For the sake of simplicity, vertical writing will be described. If there is a distance between the lower end in the Y direction of the last character rectangle, that is, the lower end in the Y direction of the column, it is recognized that there is a line break. Specifically, a line break is considered when there is a distance of n d times or more (eg, 0.7 times or more) of the column width.

さらに、改行があった後に次の文字列との間に大きな余白がある場合(例えば、見出しと本文の間など)にはもう1つ改行があると考えることとする。この場合、改行データを2回付加することとなる。大きな余白の定義は、次の列との距離が列幅のn倍(例えば1倍)よりも大きい余白とする。 Furthermore, if there is a large margin between the next character string after a line break (for example, between the heading and the body), it is assumed that there is another line break. In this case, line feed data is added twice. Defining a large margin, the distance between the next column is greater margin than n s times the column width (e.g. 1-fold).

(c)文字間隔の整形
ここまでの処理で得られた矩形は、文字に外接する矩形であるため、文字間の余白が削られてしまっている。このままレンダリング部31でリフローを行うと文字が詰まってしまう。そこで文字間の余白部分を連続する前後の文字矩形に配分する。余白は均等に存在するのではなく、前後の文字矩形の大きさによって変わるため、それを考慮して配分する。
(c) Formatting of character spacing Since the rectangle obtained by the processing so far is a rectangle circumscribing the character, the margin between characters has been cut off. If the reflow is performed in the rendering unit 31 as it is, characters are clogged. Therefore, the white space between characters is distributed to consecutive character rectangles. The margins do not exist evenly, but change according to the size of the front and rear character rectangles, so they are allocated in consideration.

図20は、文字間隔の整形方法の一例を示す図である。簡略化のために縦書き領域の場合に絞って説明する。ここで、並び順で前後する文字矩形について考える。いま、連続する矩形の高さheighti とheighti+1 の比がheighti : heighti+1 = A : Bだったとする。このとき文字矩形i と文字矩形i + 1 の余白を、逆比B : A で配分することにする。なお、横書きの場合には、同様に文字の幅width を利用すれば良い。   FIG. 20 is a diagram illustrating an example of a character spacing shaping method. For the sake of simplicity, the description will be focused on the vertical writing area. Here, let us consider a character rectangle that moves back and forth in the arrangement order. Assume that the ratio of height heighti and heighti + 1 of consecutive rectangles is heighti: heighti + 1 = A: B. At this time, the margins of the character rectangle i and the character rectangle i + 1 are allocated with an inverse ratio B: A. In the case of horizontal writing, the character width width may be used as well.

なお、列端(先頭、末尾)の文字矩形については、上記の余白の配分方法を用いることができない。そのため、図21に示すように、列端の文字の高さが小さい場合、余白の配分が行われず文字矩形の高さが小さいままであり、リフローを行う際にこの部分の文字間隔が極端に詰まってしまう。これを防止するため、列端の文字矩形の高さが所定値(例えば、列幅×0.8〜1.2程度)以下の場合、所定値まで文字矩形の高さ拡張する。なお、文字矩形の高さを所定値まで拡張する場合、先頭の文字矩形については、当該文字矩形の上端が文字領域からはみ出さないようにし、末尾の文字矩形については、当該文字矩形の下端が文字領域からはみ出さないようにする。   It should be noted that the above margin distribution method cannot be used for the character rectangle at the end of the column (first and last). Therefore, as shown in FIG. 21, when the height of the character at the end of the column is small, the white space is not allocated and the height of the character rectangle remains small, and the character spacing of this portion becomes extremely large when performing reflow. Clogged. In order to prevent this, when the height of the character rectangle at the end of the column is a predetermined value (for example, column width × 0.8 to 1.2 or less), the height of the character rectangle is expanded to a predetermined value. When the height of the character rectangle is expanded to a predetermined value, the upper end of the character rectangle should not protrude from the character area for the first character rectangle, and the lower end of the character rectangle for the last character rectangle. Do not protrude from the character area.

図22に、図表領域、文字矩形などの最終的な切り出し結果の一例を表示する。なお、文字列下の空欄の矩形は、改行を示す。   FIG. 22 displays an example of final cutout results such as a chart area and a character rectangle. A blank rectangle below the character string indicates a line feed.

[S16:レイアウト変換]
これまでの文字や図表の情報の切り出し結果により、リフローデータを作成することができるが、対象とする画像のレイアウトによってはうまく機能しない場合がある。そこで、レイアウト変換部16は、読み手の読みやすさを考慮して、解析された結果が一定条件下の場合には読み込んだ画像のページ全体を図表領域にするなどの、解析したレイアウトの結果を変更する処理を行う。
[S16: Layout conversion]
Reflow data can be created based on the result of cutting out information on characters and charts so far, but it may not function properly depending on the layout of the target image. Therefore, the layout conversion unit 16 considers the readability of the reader, and if the analyzed result is under a certain condition, the layout conversion unit 16 displays the analyzed layout result such as making the entire page of the read image a chart area. Perform the change process.

(1)画像ページへの変換
一覧性が必要なページの場合や、取得したレイアウト解析結果が明らかに失敗している状況においては、無理やりリフローデータを生成するよりも、そのページは一枚の画像として表示した方が読み手の立場で考えると好ましい。具体的には下記のケースの場合、その読み込んだ画像を画像ページとしてページ全体を図表領域として、変換を行う。
(1) Conversion to image page In the case of a page that needs to be listed, or in a situation where the obtained layout analysis result has clearly failed, the page is a single image rather than forcibly generating reflow data. Is preferable from the viewpoint of the reader. Specifically, in the following case, conversion is performed using the read image as an image page and the entire page as a chart area.

(a)図表が主体のページ
処理対象として文字が主体の文書を想定しているため、ページ中の文字領域面積と比較して、図表領域面積が大きな場合(表紙など)には、図表の一覧性を確保するために画像ページとして変換を行う。
(a) Pages with a chart as the main subject Since a document whose subject is a text is assumed as the processing target, if the area of the chart area is large compared to the area of the text area on the page (such as a cover page), a list of charts In order to ensure the property, conversion is performed as an image page.

具体的にはレイアウト解析の過程で取得した各領域毎の面積(縦書き文字領域(CHARH AREA)、横書き文字領域(CHARV AREA)、図表領域(FIGURE AREA))を活用し、図表領域の面積が、文字領域の面積のn倍(例えば、1.5倍)より大きい場合に、図表が主体であると認識し、画像ページへ変換する。   Specifically, the area of each area (vertical writing area (CHARH AREA), horizontal writing area (CHARV AREA), chart area (FIGURE AREA)) obtained in the process of layout analysis is utilized. If the area is larger than n times (for example, 1.5 times) the area of the character area, the chart is recognized as being the main subject and converted to an image page.

なお、本実施形態では、文字領域の面積を示すCHARH AREA、CHARV AREA は、いわゆる文字領域の面積ではなく、例えば縦書きであれば、文字領域中の列部分の面積の総和であるものとする(空白部分は領域面積と考えない)が、勿論、空白部分を含めた文字領域そのものの面積を使用してもよい。   In the present embodiment, CHARH AREA and CHARV AREA indicating the area of the character area are not the area of the so-called character area, but are the sum of the areas of the column portions in the character area, for example, in the case of vertical writing. (The blank area is not considered as the area of the area). Of course, the area of the character area itself including the blank area may be used.

(b)目次ページ
目次ページは、一覧性が重要であること、また、文字に飾りが付いていることが多いため、正確に認識して切り出すことが難しい。そこで目次と認識できた場合には画像ページとして変換を行う。
(b) Table of contents page It is difficult to accurately recognize and cut out the table of contents page because the listability is important and the characters are often decorated. Therefore, if it can be recognized as a table of contents, it is converted as an image page.

目次の判定には、目次ページは本の前半に登場すること、見出しが連続するため、行間が広く空く(改行が2 回続く)こととなる。そこで、ページ番号i がi < 50 かつ、ページに存在する行・列数COL_NUM と、改行の数BR_NUM を計測し、以下の式を満たす場合に、目次ページとして認識し、画像ページへと変換する。なお、このページの判定に用いた閾値“50”、“0.7”は例示であって、これ以外の値を用いることとしてもよい。
When determining the table of contents, the table of contents page appears in the first half of the book, and the headings are continuous, so the line spacing is wide (the line breaks twice). Therefore, when the page number i is i <50 and the number of rows / columns COL_NUM existing on the page and the number of line breaks BR_NUM are measured, and the following formula is satisfied, it is recognized as a table of contents page and converted to an image page. . Note that the thresholds “50” and “0.7” used for the determination of this page are merely examples, and other values may be used.

(c)検出面積が極端に少ないページ
文字領域や図表領域として検出された領域が非常に少ないページ(例えば、章題だけが書いてあるページ)は一覧性が大事なことが多いため、画像ページへと変換する。具体的には、レイアウト解析により取得し各領域の面積の和(SUM_AREA = CHARH_AREA + CHARV_AREA + FIGURE_AREA)が、ページ全体の面積(PAGE AREA = X SIZE ・ Y SIZE)に対し、n%(例えば、5% )以下の場合には、画像ページへと変換する。
(c) Pages with an extremely small detection area Pages with very few areas detected as character areas or chart areas (for example, pages where only chapter titles are written) are often important for listing. Convert to. Specifically, the sum of the areas of each region (SUM_AREA = CHARH_AREA + CHARV_AREA + FIGURE_AREA) obtained by layout analysis is n% (for example, 5 %) In the following cases, convert to an image page.

(2)ノンブル・柱の削除
リフローデータにした時点で紙書籍の”ページ”という概念がなくなるため、ページ番号が書かれているノンブル領域は必要のないデータとなる、また柱と呼ばれる章題などを書かれた領域についてもページ単位に付与されている情報であるため、リフローデータの生成には用いないことにする。
(2) Deletion of nobles and pillars Since the concept of “pages” in paper books disappears when reflow data is used, the noble area where page numbers are written becomes unnecessary data, and chapters called pillars, etc. Since the area written in is also information given to each page, it is not used for generating reflow data.

そこで、レイアウト解析後にノンブル・柱に相当するデータについては削除を行う。ノンブル・柱の認識は、文字領域の位置を用いて行うものとする。すなわち、所定の範囲(例えば、画像の上下の端から、画像の高さのn%(例えば、20%))以内に存在している文字領域は、ノンブルまたは柱であると認識する。また、前記所定の範囲に存在する文字領域であって、かつ、当該文字領域に含まれる行または列が所定値(例えば、1〜3)以下の場合、ノンブルまたは柱であると認識することとしてもよい。   Therefore, after the layout analysis, the data corresponding to the noble / column is deleted. The recognition of the noble and the pillar is performed using the position of the character area. That is, a character area existing within a predetermined range (for example, from the top and bottom edges of the image to n% (for example, 20%) of the height of the image) is recognized as a bumble or a pillar. In addition, when the character area exists in the predetermined range and the row or column included in the character area is a predetermined value (for example, 1 to 3) or less, it is recognized as a noble or a pillar. Also good.

また、前記所定の範囲に存在する文字領域であって、かつ、当該文字領域の横幅/画像の横幅が所定値以下の場合、ノンブルまたは柱であると認識することとしてもよい。   Further, when the character area exists in the predetermined range and the width of the character area / the width of the image is equal to or less than a predetermined value, the character area may be recognized as a noble or a pillar.

[S17:テンポラリ結果の出力]
S16の処理後に、レイアウト変換部16は、処理対象の画像の1ページ分の処理結果を記憶部18に出力する。なお、S20で最終的に出力するリフローデータは、S11で読み込んだ全てのページの画像と1 対1 に対応するものであるが、S17で一時的な結果を出力することで、読み込んだ画像の1 ページ目の画像ファイルから最終ページの画像ファイルまで逐次的に処理を行う必要がなくなるため、並列計算による処理速度の向上を実現することが可能になる。
[S17: Output temporary result]
After the processing of S <b> 16, the layout conversion unit 16 outputs the processing result for one page of the processing target image to the storage unit 18. Note that the reflow data finally output in S20 has a one-to-one correspondence with the images of all pages read in S11, but by outputting temporary results in S17, Since it is not necessary to perform sequential processing from the image file of the first page to the image file of the last page, it is possible to improve the processing speed by parallel calculation.

以上説明したS12からS17の処理は、読み込んだ画像の各ページ毎に行う。そのため、未処理のページが存在する場合は(S18:NO)、S12に戻り以降の処理を行うとともに、全てのページの処理が終了した場合は(S18:YES)、S19に進む。   The processes from S12 to S17 described above are performed for each page of the read image. For this reason, if there is an unprocessed page (S18: NO), the process returns to S12 and the subsequent processes are performed. If all pages have been processed (S18: YES), the process proceeds to S19.

[S19:バーコード解析]
本の背表紙にはバーコードがついており、バーコードを認識することで本の識別子であるISBN コードを取得する。ISBN コードを取得できれば音楽CD のCDDB からメタデータが取得できるのと同様に本のメタデータを取得し、S11で読み込んだ画像のコンテンツの管理に役立てることができる。そこで、バーコード解析部17は、所定のページの画像の中のバーコードを検出し、検出したバーコードからコード種別を判別し、ISBN-13 もしくはISBN-10 の情報のみを取得する。本実施形態では、背表紙は基本的に最終ページに存在すると仮定し、最終ページのみこの処理を行うこととするが、最終ページだけでなく、例えば、最終ページから数ページ(10ページ以下程度)にこの処理を行うこととしてもよい。
[S19: Barcode analysis]
The back cover of the book has a barcode, and the ISBN code, which is the book identifier, is acquired by recognizing the barcode. If the ISBN code can be acquired, the metadata of the book can be acquired in the same manner as the metadata can be acquired from the CDDB of the music CD, which can be used for managing the content of the image read in S11. Therefore, the barcode analysis unit 17 detects a barcode in an image of a predetermined page, determines the code type from the detected barcode, and acquires only the information of ISBN-13 or ISBN-10. In this embodiment, it is assumed that the spine is basically present on the last page, and this processing is performed only on the last page. However, not only the last page but also several pages from the last page (about 10 pages or less), for example. Alternatively, this process may be performed.

なお、本実施形態では、バーコードの解析にZBar ライブラリを利用するものとする。ZBar ライブラリでは、ImageMagick を活用した画像の入出力を用意しているが、単純にグレースケール画像のメモリを渡すだけで動作可能であり、他の画像読み込みライブラリで代替が可能なため、すでにレイアウト解析のために読み込み済みの画像フォーマットを代わりに渡すことで処理を行う。   In this embodiment, the ZBar library is used for bar code analysis. The ZBar library provides image input and output using ImageMagick, but it can be operated simply by passing the memory of a grayscale image, and can be replaced by another image reading library, so layout analysis has already been performed. Process by passing the loaded image format instead.

[S20:最終結果の出力]
S11で読み込んだ画像の全てのページに対し、文字情報および図表の切り出しが行われた後に、S17で出力したテンポラリ結果ファイルを統合し、1つのリフローデータとして記憶部18に出力する。本実施形態では、リフロー表示部3のレンダリング部31などのレンダリングエンジンで利用できるように、JSON 形式でリフローデータの出力を行う。JSON データは1 コンテンツに対し、1 つのJSONファイルとし、全てのページの解析結果を含んだものとして定義する。本実施形態では、高速化のために並列演算を行っており、逐次先頭からページ順に処理するわけではないため、各ページ毎の処理結果をテンポラリ結果としてS17で出力し、それを最後に統合することで最終JSON ファイルを作成する。
[S20: Output final result]
After the character information and charts are cut out for all pages of the image read in S11, the temporary result files output in S17 are integrated and output to the storage unit 18 as one reflow data. In this embodiment, the reflow data is output in the JSON format so that it can be used by a rendering engine such as the rendering unit 31 of the reflow display unit 3. JSON data is defined as one JSON file for one content, including the analysis results of all pages. In this embodiment, parallel processing is performed for speeding up, and processing is not performed sequentially from the top to the bottom. Therefore, the processing result for each page is output as a temporary result in S17, and is integrated at the end. Create the final JSON file.

図23は、リフローデータの一例を示すものである。   FIG. 23 shows an example of reflow data.

リフローデータは、切り出した文字および図表のオブジェクト領域毎に設定される。具体的には、オブジェクト領域の種別と、読み込んだ画像のページIDと、オブジェクトの左上の座標(x,y)と、オブジェクト領域の幅、オブジェクトの高さなどを備える。オブジェクト領域の種別としては、例えば、0:文字、1:図表、2:改行などが考えられる。その他の種別として、改ページ、章区切り、縦書き文字、横書き文字などがあってもよい。また、オブジェクト領域の種別が改行の場合は、以降の要素を省略して出力する。なお、画像のページIDと、座標(x,y)は、読み込んだ画像のどのページのどの場所にオブジェクトがあるかを特定するために用いる。   The reflow data is set for each character area and object area of the chart. Specifically, it includes the type of the object area, the page ID of the read image, the upper left coordinates (x, y) of the object, the width of the object area, the height of the object, and the like. As the type of the object area, for example, 0: character, 1: chart, 2: line feed can be considered. Other types may include page breaks, chapter breaks, vertical writing characters, horizontal writing characters, and the like. When the object area type is a line feed, the subsequent elements are omitted and output. Note that the page ID of the image and the coordinates (x, y) are used to specify in which position of which page of the read image the object is located.

読み込んだ画像のページ毎に、読み順で文字、改行を出力し、最後に図表領域の出力を行い、最後に全てのページを統合することで1つのリフローデータを生成し、記憶部18にする。   For each page of the read image, characters and line feeds are output in the reading order, finally the chart area is output, and finally all pages are integrated to generate one reflow data, which is stored in the storage unit 18. .

次に、読み込んだ画像(以下、元画像)と、生成したリフローデータとを用いたリフロー表示処理について説明する。   Next, a reflow display process using the read image (hereinafter referred to as an original image) and the generated reflow data will be described.

<リフロー表示処理>
図24は、スマートフォン、タブレット端末などに搭載されたリフロー表示部3が行う、リフロー表示処理のフローチャートである。
<Reflow display processing>
FIG. 24 is a flowchart of the reflow display process performed by the reflow display unit 3 mounted on a smartphone, a tablet terminal, or the like.

S21において、レンダリング部31は、リフローデータ生成処理で生成されたリフローデータと、元画像とを読み込む。なお、リフロー表示部3は、レイアウト解析部1の記憶部18に記憶された元画像およびリフローデータを、例えばネットワークなどを介して取得し、データ保存部2に格納する。   In S21, the rendering unit 31 reads the reflow data generated by the reflow data generation process and the original image. The reflow display unit 3 acquires the original image and the reflow data stored in the storage unit 18 of the layout analysis unit 1 via, for example, a network and stores them in the data storage unit 2.

S22において、レンダリング部31は、読み込んだリフローデータのオブジェクトの集合を、所定の位置で区切った分冊を生成する。すなわち、オブジェクトの集合を、所定のオブジェクト数を基準として分割する。図25に示すように、分冊の作成には、2つの方法が考えられる。第1の方法は、所定のオブジェクト数でリフローデータを区切ることで、分冊を作成する。図25(a)に示す例では、1000オブジェクト毎にリフローデータを区切る。すなわち、1から1000までのオブジェクトは分冊1とし、1001から2000までのオブジェクトは分冊2とする。   In S <b> 22, the rendering unit 31 generates a separate volume obtained by dividing a set of read reflow data objects at a predetermined position. That is, a set of objects is divided based on a predetermined number of objects. As shown in FIG. 25, two methods can be considered for creating a separate volume. The first method creates a separate volume by dividing the reflow data by a predetermined number of objects. In the example shown in FIG. 25A, the reflow data is divided every 1000 objects. That is, the objects from 1 to 1000 are referred to as volume 1 and the objects from 1001 to 2000 are as volume 2.

第2の方法は、所定のオブジェクト数以降で、区切りのよいオブジェクトを検出した箇所で区切って、分冊を作成する。区切りのよいオブジェクトとしては、改行、図表などが考えられる。図25(b)に示す例では、1000オブジェクト以降で最初に区切りのよいオブジェクト(図示する例では改行)を検出した箇所で区切り、当該オブジェクトまでを分冊1とする。そして、分冊1の区切りの後から1000オブジェクト以降で最初に区切りのよいオブジェクト(図示する例では図表)を検出した箇所で区切り、当該オブジェクトまでを分冊2とする。   In the second method, a separate volume is created by dividing a predetermined number of objects or more at a location where an object with good separation is detected. Line breaks, charts, etc. can be considered as objects with good separation. In the example shown in FIG. 25 (b), the first separated object is detected after 1000 objects, and the first part is a volume 1 where the first separated object is detected. Then, after the separation of the volume 1, the first separated object after the 1000 objects (the diagram in the example shown) is separated at the location where the object is detected, and the volume up to the object is referred to as volume 2.

S23において、レンダリング部31は、ユーザの操作対象の分冊に含まれる各オブジェクトを、リフローデータを用いて元画像から切り出し、ディスプレイ32の表示領域(画面)の大きさに応じて生成した配置領域に、オブジェクトを順次、再配置する。そして、再配置領域をディスプレイの表示領域と等しいサイズに切り分けた(分割した)、リフローページを生成する。図26は、文字および図表の配置・配列イメージを示すものである。縦書きの場合、オブジェクトを配置する領域のサイズは、例えば高さを表示領域の高さと等しく、幅は無制限とする。この配置領域に分冊の全ての文字を配置した後、配置領域を表示領域の幅と等しい長さ毎に区切り、その1区切りを1つのリフローページとする。   In S <b> 23, the rendering unit 31 extracts each object included in the user's operation target volume from the original image using the reflow data, and creates the arrangement area generated according to the size of the display area (screen) of the display 32. , Rearrange objects sequentially. Then, a reflow page is generated by dividing (dividing) the rearrangement area into a size equal to the display area of the display. FIG. 26 shows an arrangement / arrangement image of characters and charts. In the case of vertical writing, the size of the area in which the object is arranged is, for example, the height equal to the height of the display area, and the width is unlimited. After all the characters of the separate volume are arranged in this arrangement area, the arrangement area is divided every length equal to the width of the display area, and one division is defined as one reflow page.

本実施形態では、CSS3(http://www.w3.org/TR/jlreq/ja/)の多言語対応(CSS3 Writing Modes Module)を用いて、各文字のオブジェクトを所定の拡大率で日本語組版の要件に従って縦書きに配置するものとする。また、CSS2のdisplay:inline-block指定により、画像から切り出したオブジェクト領域を文字として取り扱うことができる。   In this embodiment, CSS3 (http://www.w3.org/TR/jlreq/ja/) multilingual support (CSS3 Writing Modes Module) is used to convert each character object into Japanese at a predetermined magnification. It shall be arranged vertically according to the typesetting requirements. Also, by specifying display: inline-block in CSS2, the object area cut out from the image can be handled as a character.

なお、図24に示すように、オブジェクトの種別が改行の場合、無条件で改行し、以降のオブジェクトを次の列に改行する。また、CSS3の段組(CSS3 Multi-column Layout Module)を流用し、文章をリフローページ単位に分割する。また、図表のオブジェクトは、1行・列とし、拡大率は原則固定とする。但し、画面内に収まらない場合は、収まるサイズに拡大率を調整する。   As shown in FIG. 24, when the type of the object is a line feed, the line is unconditionally broken, and the subsequent objects are broken into the next line. In addition, the CSS3 multi-column layout module is used to divide the text into reflow pages. In addition, the object of the chart is one row and column, and the enlargement ratio is fixed in principle. However, if it does not fit within the screen, the enlargement ratio is adjusted to a size that fits.

S24において、レンダリング部31は、S23で配置した分冊の、ユーザが注目しているリフローページを、ディスプレイ32に表示する。   In S <b> 24, the rendering unit 31 displays on the display 32 the reflow page of the volume arranged in S <b> 23 that is noticed by the user.

S25で、操作受付部33は、ユーザの操作(タッチパネルへのタッチなど)を受け付ける。ユーザ操作が、ページ捲りまたはジャンプなどのページ移動の操作の場合であって(S26:YES)、移動先のリフローページがS23で処理した分冊と同じ分冊内の場合は(S27:NO)、S23で生成されたリフローページの中の移動先のリフローページを表示する(S24)。移動先のリフローページが別の分冊内の場合は(S27:YES)、S23に進み、移動先の分冊に含まれる各オブジェクを配置した全てのリフローページを生成し、その後、ユーザ操作で指定された移動先のリフローページを表示する(S24)。   In S25, the operation reception unit 33 receives a user operation (such as touching the touch panel). If the user operation is a page movement operation such as page turning or jump (S26: YES), and the reflow page to be moved is in the same volume as the volume processed in S23 (S27: NO), S23 The reflow page of the movement destination in the reflow page generated in (1) is displayed (S24). If the destination reflow page is in another volume (S27: YES), the process proceeds to S23, where all the reflow pages in which the objects included in the destination volume are arranged are generated, and then specified by the user operation. The reflow page of the moved destination is displayed (S24).

なお、ページ捲りの場合は、同じ分冊内の場合、現在表示しているリフローページの単純に1つ前または1つ後ろのリフローページを表示する。分冊の端を超えて、1つ前または1つ後に移動する場合は、S23で移動先の分冊のオブジェクトを全てリフローページに配置した後に、移動先のリフローページを表示する。   In the case of page turning, in the same volume, a reflow page that is simply one before or after the currently displayed reflow page is displayed. When the booklet moves beyond the end of the booklet and moves forward or backward, the destination reflow page is displayed after all the objects of the booklet to be moved are placed on the reflow page in S23.

ジャンプ操作は、移動先のページを元画像のページ番号で指定する。移動先としては指定した元画像のページの最初のオブジェクトが含まれるリフローページを、移動先として表示する。移動先が、異なる分冊の場合は、S23で移動先の分冊のオブジェクトを全てリフローページに配置した後に、移動先のリフローページを表示する。   In the jump operation, the destination page is designated by the page number of the original image. As the movement destination, the reflow page including the first object of the designated original image page is displayed as the movement destination. If the destination is a different volume, the destination reflow page is displayed after all the objects in the destination volume are placed on the reflow page in S23.

ユーザ操作が、拡大・縮小操作の場合(S28)、操作された拡大率に変更し(S29)、S23に進み、現在表示している分冊のオブジェクを変更後の拡大率で全てリフローページに再配置し、その後、操作前のリフローページの最初のオブジェクトが含まれる再配置後のリフローページを表示する(S24)。   When the user operation is an enlargement / reduction operation (S28), the operation is changed to the operated enlargement ratio (S29), and the process proceeds to S23. Then, the reflow page after relocation including the first object of the reflow page before operation is displayed (S24).

ユーザ操作が、表示領域サイズの変更の場合(S30)、変更後の表示領域サイズに変更し(S31)、S23に進み、現在表示している分冊のオブジェクを変更後の表示領域サイズのリフローページで再配置し、その後、操作前のリフローページの最初のオブジェクトが含まれる再配置後のリフローページを表示する(S24)。表示領域サイズの変更には、例えば、ディスプレイ32の向きを縦長から横長に変更すること、ディスプレイ32の表示領域サイズを拡大したり、縮小することなどが考えられる。   When the user operation is a change of the display area size (S30), the display area size is changed to the changed display area (S31), and the process proceeds to S23 to change the reflow page of the display area size after the change of the currently displayed volume object. After that, the reflow page after the rearrangement including the first object of the reflow page before the operation is displayed (S24). For example, the display area size can be changed by changing the orientation of the display 32 from portrait to landscape, expanding the display area size of the display 32, or reducing the display area size.

なお、ユーザ操作として、リフローページの表示と元画像のページの表示との切り替え操作があってもよい。例えば、現在表示しているリフローページの最初のオブジェクトが含まれる元画像のページをディスプレイ32の表示領域に合わせて表示する、または、現在表示している元画像のページに含まれる最初のオブジェクトを含むリフローページを表示することが考えられる。   Note that the user operation may include a switching operation between the reflow page display and the original image page display. For example, the original image page including the first object of the currently displayed reflow page is displayed in accordance with the display area of the display 32, or the first object included in the currently displayed original image page is displayed. It is conceivable to display a reflow page including the page.

以上説明した本実施形態では、文書画像を構成する各文字および図表を囲う矩形座標で構成されるリフローデータを生成し、表示側でディスプレイサイズに合わせてリフローデータを用いて文字画像をリフローさせることで、様々なディスプレイサイズで快適な読書をユーザに提供することができる。   In the present embodiment described above, reflow data composed of rectangular coordinates enclosing each character and chart constituting the document image is generated, and the character image is reflowed using the reflow data according to the display size on the display side. Thus, comfortable reading can be provided to the user with various display sizes.

また、本実施形態では、読み込んだ画像の傾きを推定し、推定した傾きの分だけずらしてヒストグラムを生成する。これにより、列として切り出した列領域または行として切り出した行領域に、余分な領域が含まれることなく、本来の画像の列領域または行領域を正しく切り出すことができる。すなわち、画像として列領域または行領域から切り出した文字をリフローして表示した場合に、文字のがたつきが回避され、見栄えのよい、快適な読書をユーザに提供することができる。   In this embodiment, the inclination of the read image is estimated, and a histogram is generated by shifting the estimated inclination. Thereby, the column area or the row area of the original image can be correctly cut out without including an extra area in the row area cut out as a column or the row area cut out as a row. That is, when a character cut out from a column area or a line area is reflowed and displayed as an image, the rattling of the character is avoided, and a good-looking and comfortable reading can be provided to the user.

また、本実施形態では、図表とそのキャプションとを統合し、1つの図表領域として扱うため、リフロー表示の際に図表とキャプションとが分離して表示されてしまうという問題を解消することができる。   Further, in the present embodiment, since the chart and its caption are integrated and handled as one chart area, the problem that the chart and the caption are displayed separately during reflow display can be solved.

また、本実施形態では、文字領域のX方向およびY方向のヒストグラムを作成することで、文字領域の縦書き・横書きを正しく判定することができる。   In the present embodiment, by creating a histogram in the X direction and Y direction of the character area, it is possible to correctly determine whether the character area is vertically or horizontally written.

また、本実施形態では、連続する文字矩形の余白を、当該連続する文字矩形に配分することで、文字間隔を整形することができる。   Moreover, in this embodiment, a character space | interval can be shape | molded by allocating the margin of a continuous character rectangle to the said continuous character rectangle.

また、本実施形態では、ルビとその対象とする文字とを統合し、1つの文字矩形として扱うため、リフロー表示の際にルビと対象とする文字とが分離して表示されてしまうという問題を解消することができる。   In the present embodiment, ruby and the target character are integrated and handled as one character rectangle, so that the ruby and the target character are displayed separately during reflow display. Can be resolved.

また、本実施形態では、読み込んだ画像の列領域または行領域における改行を認識することで、読み込んだ画像における改行部分をリフロー表示においても維持することができる。これにより、読み込んだ画像おける改行部分がリフロー表示において改行でなくなった場合の文字のがたつきの発生を回避することができる。   Further, in this embodiment, by recognizing a line break in the column area or the line area of the read image, the line break portion in the read image can be maintained even in the reflow display. As a result, it is possible to avoid the occurrence of rattling when the line break portion in the read image is no longer a line break in the reflow display.

また、本実施形態では、生成したリフローデータを、所定のオブジェクト数で区切った分冊単位で、オブジェクトのリフローを行う。これにより、リフロー表示の際に、一度に多くのオブジェクトの処理を行わなくてすむため、処理時間、使用するメモリ量などのリソースを削減することができる。また、操作レスポンスの劣化を防止し、ユーザの利便性を向上することができる。   In the present embodiment, the reflow of objects is performed in units of separate volumes obtained by dividing the generated reflow data by a predetermined number of objects. This eliminates the need to process many objects at the time of reflow display, thereby reducing resources such as processing time and the amount of memory used. In addition, it is possible to prevent degradation of the operation response and improve user convenience.

なお、本発明は上記実施形態に限定されるものではなく、その要旨の範囲内で数々の変形が可能である。   In addition, this invention is not limited to the said embodiment, Many deformation | transformation are possible within the range of the summary.

1 :レイアウト解析部
11:画像読み込み部
12:2値化処理部
13:ラベリング部
14:図表認識部
15:文字切り出し部
16:レイアウト変換部
17:バーコード解析部
18:記憶部
2 :データ保存部
3 :リフロー表示部
31:レンダリング部
32:ディスプレイ
33:操作受付部
1: layout analysis unit 11: image reading unit 12: binarization processing unit 13: labeling unit 14: chart recognition unit 15: character segmentation unit 16: layout conversion unit 17: barcode analysis unit 18: storage unit 2: data storage Unit 3: Reflow display unit 31: Rendering unit 32: Display 33: Operation receiving unit

Claims (8)

コンピュータが行う画像再配置方法であって、
読み込んだ文書画像から、複数の文字矩形を含む文字領域を抽出する領域抽出ステップと、
前記文字領域を所定数に分割し、各分割領域毎に前景のヒストグラムを生成し、各分割領域で作成されるヒストグラムの位置のずれを用いて、画像の傾きを推定する傾き推定ステップと、
前記傾きの分だけ各文字矩形の位置をずらして、前記文字領域のヒストグラムを生成し、前記ヒストグラムの幅の行領域または列領域を抽出し、当該行領域または列領域に含まれる文字矩形の高さまたは幅を、前記行領域の高さまたは前記列領域の幅に合わせる行・列取得ステップと、
前記行領域または前記列領域から、前記行領域の高さまたは前記列領域の幅に合わせた各文字矩形を切り出す文字切り出しステップと、を行うこと
を特徴とする画像再配置方法。
An image rearrangement method performed by a computer,
An area extraction step for extracting a character area including a plurality of character rectangles from the read document image;
An inclination estimation step of dividing the character area into a predetermined number, generating a foreground histogram for each divided area, and estimating an inclination of the image using a shift in the position of the histogram created in each divided area;
The position of each character rectangle is shifted by the inclination, a histogram of the character area is generated, a row area or a column area having a width of the histogram is extracted, and the height of the character rectangle included in the line area or the column area is extracted. A row / column acquisition step for adjusting the height or width to the height of the row region or the width of the column region;
A character cutout step of cutting out each character rectangle in accordance with the height of the row region or the width of the column region from the row region or the column region .
請求項1に記載の画像再配置方法であって、
前記領域抽出ステップは、前記文書画像から、図表が含まれる図表領域を抽出し、
前記図表領域の周囲のキャプション候補領域に文字矩形が存在する場合、当該文字矩形をキャプションと判別し、前記キャプションを前記図表領域に統合するキャプション統合ステップを、さらに行うこと
を特徴とする画像再配置方法。
The image rearrangement method according to claim 1,
The area extraction step extracts a chart area including a chart from the document image,
When a character rectangle exists in a caption candidate area around the chart area, the image rearrangement further includes a caption integration step of determining the character rectangle as a caption and integrating the caption into the chart area. Method.
請求項1または2に記載の画像再配置方法であって、
前記文字領域のX方向およびY方向のヒストグラムを生成し、X方向の背景のヒストグラムの連続する長さの平均が、Y方向の背景のヒストグラムの連続する長さの平均より大きい場合、縦書きであると判別し、それ以外は横書きであると推定する文字方向推定ステップを、さらに行うこと
を特徴とする画像再配置方法。
The image rearrangement method according to claim 1 or 2,
When the histogram of the X direction and the Y direction of the character area is generated and the average of the continuous length of the background histogram of the X direction is larger than the average of the continuous length of the background histogram of the Y direction, An image rearrangement method, further comprising: a character direction estimation step that determines that there is a character and that the other character is written horizontally.
請求項1から3のいずれか一項に記載の画像再配置方法であって、
隣接する行または列の間隔が、大きい方の行の高さまたは列の幅に対して所定の割合以下であって、隣接する行の高さまたは列の幅の比が所定の割合以下の場合は、高さが小さい方の行または幅が小さい方の列はルビであると判別し、前記ルビを対象とする文字矩形に統合するルビ統合ステップを、さらに行うこと
を特徴とする画像再配置方法。
The image rearrangement method according to any one of claims 1 to 3,
The spacing between adjacent rows or columns is less than or equal to a specified percentage of the larger row height or column width, and the ratio of adjacent row height or column width is less than or equal to a specified percentage The image rearrangement further comprises a ruby integration step of determining that a row having a smaller height or a column having a smaller width is ruby and integrating the ruby into a character rectangle. Method.
請求項1から4のいずれか一項に記載の画像再配置方法であって、
連続する文字矩形の余白を、当該文字矩形に配分すること
を特徴とする画像再配置方法。
An image rearrangement method according to any one of claims 1 to 4, comprising:
An image rearrangement method characterized by allocating a space of continuous character rectangles to the character rectangles.
請求項1から5のいずれか一項に記載の画像再配置方法であって、
前記文書画像から切り出した文字矩形または図表領域のオブジェクトの集合を、所定のオブジェクト数を基準として分割する分割ステップと、
分割した単位で、前記オブジェクトをディスプレイの表示領域の大きさに応じて生成した再配置領域に再配置する再配置ステップと、
前記再配置領域を前記ディスプレイの表示領域に応じて分割したリフローページをディスプレイに表示する表示ステップと、を行うこと
を特徴とする画像再配置方法。
An image rearrangement method according to any one of claims 1 to 5,
A division step of dividing a set of objects of a character rectangle or a chart area cut out from the document image on the basis of a predetermined number of objects;
A rearrangement step of rearranging the object in a rearrangement area generated according to the size of the display area of the display in divided units;
A display step of displaying on the display a reflow page obtained by dividing the rearrangement area according to the display area of the display.
画像再配置システムであって、
読み込んだ文書画像から、複数の文字矩形を含む文字領域を抽出する領域抽出手段と、
前記文字領域を所定数に分割し、各分割領域毎に前景のヒストグラムを生成し、各分割領域で作成されるヒストグラムの位置のずれを用いて、画像の傾きを推定する傾き推定手段と、
前記傾きの分だけ各文字矩形の位置をずらして、前記文字領域のヒストグラムを生成し、前記ヒストグラムの幅の行領域または列領域を抽出し、当該行領域または列領域に含まれる文字矩形の高さまたは幅を、前記行領域の高さまたは前記列領域の幅に合わせる行・列取得手段と、
前記行領域または前記列領域から、前記行領域の高さまたは前記列領域の幅に合わせた各文字矩形を切り出す文字切り出し手段と、を備えること
を特徴とする画像再配置システム。
An image rearrangement system,
Area extraction means for extracting a character area including a plurality of character rectangles from the read document image;
Inclination estimating means for dividing the character region into a predetermined number, generating a foreground histogram for each divided region, and estimating the inclination of the image using a shift in the position of the histogram created in each divided region;
The position of each character rectangle is shifted by the inclination, a histogram of the character area is generated, a row area or a column area having a width of the histogram is extracted, and the height of the character rectangle included in the line area or the column area is extracted. Row / column acquisition means for adjusting the height or width to the height of the row region or the width of the column region;
Character re-arranging means for cutting out each character rectangle in accordance with the height of the row region or the width of the column region from the row region or the column region .
コンピュータが実行する画像再配置プログラムであって、
前記コンピュータに、
読み込んだ文書画像から、複数の文字矩形を含む文字領域を抽出する領域抽出ステップと、
前記文字領域を所定数に分割し、各分割領域毎に前景のヒストグラムを生成し、各分割領域で作成されるヒストグラムの位置のずれを用いて、画像の傾きを推定する傾き推定ステップと、
前記傾きの分だけ各文字矩形の位置をずらして、前記文字領域のヒストグラムを生成し、前記ヒストグラムの幅の行領域または列領域を抽出し、当該行領域または列領域に含まれる文字矩形の高さまたは幅を、前記行領域の高さまたは前記列領域の幅に合わせる行・列取得ステップと、
前記行領域または前記列領域から、前記行領域の高さまたは前記列領域の幅に合わせた各文字矩形を切り出す文字切り出しステップと、
を実行させるための画像再配置プログラム。
An image rearrangement program executed by a computer,
In the computer,
An area extraction step for extracting a character area including a plurality of character rectangles from the read document image;
An inclination estimation step of dividing the character area into a predetermined number, generating a foreground histogram for each divided area, and estimating an inclination of the image using a shift in the position of the histogram created in each divided area;
The position of each character rectangle is shifted by the inclination, a histogram of the character area is generated, a row area or a column area having a width of the histogram is extracted, and the height of the character rectangle included in the line area or the column area is extracted. A row / column acquisition step for adjusting the height or width to the height of the row region or the width of the column region;
A character cutout step of cutting out each character rectangle in accordance with the height of the row region or the width of the column region from the row region or the column region;
Image rearrangement program to execute.
JP2012231467A 2012-10-19 2012-10-19 Image rearrangement method, image rearrangement system, and image rearrangement program Active JP6030915B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2012231467A JP6030915B2 (en) 2012-10-19 2012-10-19 Image rearrangement method, image rearrangement system, and image rearrangement program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2012231467A JP6030915B2 (en) 2012-10-19 2012-10-19 Image rearrangement method, image rearrangement system, and image rearrangement program

Publications (2)

Publication Number Publication Date
JP2014085689A JP2014085689A (en) 2014-05-12
JP6030915B2 true JP6030915B2 (en) 2016-11-24

Family

ID=50788728

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2012231467A Active JP6030915B2 (en) 2012-10-19 2012-10-19 Image rearrangement method, image rearrangement system, and image rearrangement program

Country Status (1)

Country Link
JP (1) JP6030915B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6543290B2 (en) * 2017-02-28 2019-07-10 シナノケンシ株式会社 Electronic book making program
CN108460384B (en) * 2018-02-08 2024-01-19 南京晓庄学院 Character segmentation method for offline handwriting text

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH07121658A (en) * 1993-10-20 1995-05-12 Nippon Digital Kenkyusho:Kk Character string detection system
JP3379663B2 (en) * 1994-09-30 2003-02-24 沖電気工業株式会社 Character recognition device
JPH08235307A (en) * 1995-02-27 1996-09-13 Nec Corp Character string detector
JPH1125213A (en) * 1997-07-07 1999-01-29 Oki Electric Ind Co Ltd Method and device for judging row direction
JP2000295461A (en) * 1999-04-09 2000-10-20 Sharp Corp Image compositing method and color facsimile equipment
JP2003288334A (en) * 2002-03-28 2003-10-10 Toshiba Corp Document processor and document processing method
US7966557B2 (en) * 2006-03-29 2011-06-21 Amazon Technologies, Inc. Generating image-based reflowable files for rendering on various sized displays
JP5049880B2 (en) * 2008-05-30 2012-10-17 株式会社東芝 Information processing device
JP5538159B2 (en) * 2010-09-22 2014-07-02 シャープ株式会社 Page number determination apparatus, page number determination method, page number determination program, and computer-readable recording medium

Also Published As

Publication number Publication date
JP2014085689A (en) 2014-05-12

Similar Documents

Publication Publication Date Title
KR101334483B1 (en) Apparatus and method for digitizing a document, and computer-readable recording medium
US9007405B1 (en) Column zoom
US8515176B1 (en) Identification of text-block frames
US8824798B2 (en) Information processing device, computer readable medium storing information processing program, and information processing method
JP5321109B2 (en) Information processing apparatus and information processing program
US9734132B1 (en) Alignment and reflow of displayed character images
US8538154B2 (en) Image processing method and image processing apparatus for extracting heading region from image of document
JP2010123002A (en) Document image layout device
JP5950700B2 (en) Image processing apparatus, image processing method, and program
JP6030915B2 (en) Image rearrangement method, image rearrangement system, and image rearrangement program
JP5182902B2 (en) Document image output device
JP5769131B2 (en) Image processing apparatus and program
US8526744B2 (en) Document processing apparatus and computer readable medium
US10609249B2 (en) Scanner and scanning control program which outputs an original image and an extracted image in a single file
JP2009251872A (en) Information processing device and information processing program
JP2008108114A (en) Document processor and document processing method
JP7241506B2 (en) Correction support device and correction support program for optical character recognition results
JP6322086B2 (en) Display control device, display device, program, recording medium
US20170047043A1 (en) Image display apparatus, image display method, and storage medium
JP5794154B2 (en) Image processing program, image processing method, and image processing apparatus
JP6711203B2 (en) Image processing apparatus and image processing program
JP4518212B2 (en) Image processing apparatus and program
JP7031465B2 (en) Information processing equipment and programs
US8643651B2 (en) Type-setting method for a text image file
JP4830763B2 (en) Image processing system and image processing program

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20150902

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20160622

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20160628

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20160822

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: 20161004

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20161021

R150 Certificate of patent or registration of utility model

Ref document number: 6030915

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250