A method and system for analyzing the layout of ancient Tibetan books based on deep learning
Through the multi-branch model and mirror filling method based on deep learning, the problems of large calculation amount and poor robustness in the layout analysis of Tibetan ancient books are solved, and accurate segmentation and layout analysis of text lines of Tibetan ancient books are realized, which improves the analysis efficiency and accuracy.
Patent Information
- Application Number
- CN202210219619.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-08
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2042-03-08
AI Technical Summary
The existing technology has problems such as large amount of calculation, low time efficiency, and poor robustness in the layout analysis of Tibetan ancient books. Especially when dealing with uneven lighting, stains, damaged images, and documents with different fonts, it is difficult to achieve accurate text line cutting. point.
Using the layout analysis method based on deep learning, the trained multi-branch model is used to perform text line Mask prediction, text line X-Height height position Mask prediction, character area Mask prediction, annotation information Mask prediction and border line Mask prediction, combined with mirror filling method and watershed algorithm to achieve accurate analysis of the layout of Tibetan ancient books.
It improves the accuracy of layout analysis of Tibetan ancient books, reduces the difficulty and time cost of text line segmentation, has strong automatic processing capabilities, and is suitable for complex Tibetan ancient book documents.
Smart Images

Figure CN114663892B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of layout analysis, and in particular to a method and system for analyzing the layout of ancient Tibetan books based on deep learning. Background Art
[0002] There are a large number of ancient Tibetan books, covering a wide range of content, and they are precious cultural heritage of China. However, due to their age, long preservation time, and improper preservation methods, the paper of ancient books has seriously degraded and cannot be repeatedly read by researchers. Therefore, in order to better study ancient books, it is urgent to organize the text of ancient Tibetan books and store the text information in the image as a character code file. It is difficult to complete the text information organization of ancient Tibetan books completely in the form of manual entry. Using automatic recognition to analyze the layout and recognize the text can save a lot of time cost. As for automatic computer analysis and recognition, due to the complex layout of ancient Tibetan books, the serious degradation of handwriting, and the existence of a large number of stroke adhesion, fracture and noise, the difficulty of layout analysis and recognition of ancient Tibetan books is greatly increased.
[0003] The automatic computer analysis and recognition methods currently used in the study of Tibetan ancient books mainly include the following steps: the first step is to perform preprocessing processes such as color correction, binarization, and image direction correction on the image; the second step is to use layout analysis technology to segment the preprocessed document image into different areas such as text, pictures, annotations, decorations, and borders. The main goal is to obtain text, annotations and other text areas for recognition; the third step is to design a text line segmentation method to complete the text area segmentation task, thereby segmenting the text line area into individual text lines.
[0004] In the existing processing method, each link in the layout analysis is carried out separately, which requires a large amount of calculation and has low time efficiency. The result of each link will have a direct impact on the next link. If the result of one link is inaccurate, it will cause a large fluctuation in the result of the entire layout analysis.
[0005] In the binarization stage, traditional methods cannot guarantee the robustness of the algorithm, and it is often difficult to obtain clear binary images for document images with uneven lighting, stains, damage, etc. The training process of the neural network-based method is complicated, and a high-quality data set is required to complete the training of the network model. In addition, the detailed information cannot be accurately predicted during the processing, resulting in adhesion in the areas where the strokes on the original document image are not connected, which creates more difficulties for the next stage of processing.
[0006] In the text line segmentation stage, traditional methods require more computational effort during the processing and are often applicable to one font. For document images with different fonts, it is often necessary to repeatedly adjust parameters during the experiment. In addition, the inter-line adhesion area and the stroke break area need to be processed separately during segmentation, which greatly affects the speed of text line segmentation. For example, in the preprocessing stage (a method and system for binarization of ancient Tibetan document images, application number: 202110226520.4; a method for stain removal from ancient document images, application number: 2017107487873), the ancient document images were binarized and corresponding methods were proposed by color space conversion and network model design respectively; in the text line segmentation stage (a method and system for line segmentation of ancient Tibetan document [P], CN107944451B; a method and system for segmentation of adhesion text lines of ancient Tibetan document images in Ujin style [P], CN111626302A), a text line segmentation method was proposed by using the positional relationship between baseline information and character connected domains. The paper (Li XH, Yin F, Xue T, et al, Instance Aware Document Image Segmentation using Label Pyramid Networks and Deep Watershed Transformation[C] / / 2019International Conference on Document Analysis and Recognition(ICDAR), 2019.) proposed a layout analysis scheme based on label pyramid, which achieved good results in Chinese and English text line segmentation, but the layout analysis results were not ideal. Summary of the invention
[0007] In order to solve the above problems existing in the prior art, the present invention provides a method and system for analyzing the layout of ancient Tibetan books based on deep learning.
[0008] To achieve the above object, the present invention provides the following solutions:
[0009] A method for analyzing the layout of ancient Tibetan books based on deep learning, including:
[0010] Acquire an ancient Tibetan document image to be analyzed; the ancient Tibetan document image to be analyzed is a whole image of the ancient Tibetan document or a slice image of the ancient Tibetan document;
[0011] The image of the ancient Tibetan book document to be analyzed is input into the trained layout analysis model to obtain the layout analysis result of the ancient Tibetan book; the layout analysis model is trained using a data set; the data set includes: an original image data set and a Mask image data set; the layout analysis model includes: branch one, branch two, branch three, branch four and branch five; the branch one is used for text line Mask prediction; the branch two is used for text line X-Height height position Mask prediction; the branch three is used for character area Mask prediction; the branch four is used for annotation information Mask prediction; the branch five is used for border line Mask prediction.
[0012] Preferably, the process of constructing the data set includes:
[0013] Obtaining original images to generate an original image dataset;
[0014] Binarization is performed on the original image in the original image data set to obtain a binarization result image;
[0015] Performing structural element segmentation on the binarization result image to obtain a structural element segmentation result image; the structural element segmentation result image includes: a border line mask image, an annotation information mask image, a character area mask image and a text line segmentation image;
[0016] Obtaining a text line X-Height height position Mask image according to the text line segmentation image in the structural element segmentation result image;
[0017] Add the text line X-Height height position Mask image and the text line segmentation image bit by bit to obtain a superimposed image;
[0018] Performing a squeezing operation on the superimposed image to obtain a text line Mask image;
[0019] A mask image dataset is generated based on the border line mask image, the text line X-Height height position mask image, the character area mask image, the annotation information mask image and the text line mask image.
[0020] Preferably, the step of performing a squeezing operation on the superimposed image to obtain a text line Mask image specifically includes:
[0021] Preset the maximum number of pixels to be squeezed outward between two adjacent text lines and the minimum number of pixels to be squeezed between two adjacent text lines;
[0022] According to the start coordinate position and the end coordinate position of two adjacent text lines, the actual maximum number of pixels squeezed outward and the number of squeezed pixels are determined according to the preset maximum number of pixels and the minimum number of pixels;
[0023] The superimposed image is adjusted according to the actual maximum number of pixels squeezed outward to obtain a text line Mask image.
[0024] Preferably, the starting coordinate position and the ending coordinate position of two adjacent text lines specifically include:
[0025] When (Q i -P i )-(Max push +Min dist )*2≥0, Push dist =Max push ;
[0026] When (Q i -P i )-(Max push +Min dist )*2<0, and (Q i -P i -Min dist ) / / 2>0, Push dist =(Q i -P i -Min dist ) / / 2;
[0027] When (Q i -P i )-(Max push +Min dist ) * 2<0, and (Q i -P i -Min dist ) / / 2≤0, Push dist =-Min dist ;
[0028] Among them, / / indicates rounding, Q i Indicates the starting coordinate position of two adjacent text lines, P i Indicates the end coordinate position of two adjacent text lines, Max push Indicates the maximum number of pixels that can be squeezed outward between two adjacent text lines. dist Indicates the preset minimum number of pixels between two adjacent text lines after squeezing. Push dist Indicates the actual maximum number of pixels squeezed outward.
[0029] Preferably, during the prediction process of the layout analysis model, a mirror filling method is used to fill in the images in the original image data set.
[0030] Preferably, in the process of predicting the layout analysis model, a mirror filling method is used to fill the images in the original image data set, specifically including:
[0031] When the whole image of the ancient Tibetan book document is used for prediction, the filling sizes of the left border, the right border, the upper border and the lower border of the image are determined according to the width and height of the whole image of the ancient Tibetan book document and the number of downsampling of the layout analysis model;
[0032] When the slice image of the ancient Tibetan document is used for prediction, the filling sizes of the left border, the right border, the upper border and the lower border of the slice image of the ancient Tibetan document are made to meet the preset values.
[0033] Preferably, the filling sizes of the left border, the right border, the upper border and the lower border of the image are determined according to the width and height of the overall image of the adopted Tibetan ancient book document and the number of downsampling of the layout analysis model, specifically including:
[0034] When W%2 P =0, then Padding left =Padding right =0;
[0035] When W%2 P ≠0 and (2 P -W %2 P )%2=0,Padding left =Padding right =(2 P -W %2 P ) / / 2;
[0036] When W%2 P ≠0 and (2 P -W %2 P )% 2≠0, Padding left =(2 P -W %2 P ) / / 2, Padding right =(2 P -W %2 P ) / / 2+1;
[0037] When H%2 P =0, Padding top =Padding bottom =0;
[0038] When H%2P ≠0, and (2 P -H%2 P )%2=0, then Padding top =Padding bottom =(2 P -H%2 P ) / / 2;
[0039] When H%2 P ≠0, and (2 P -H%2 P )% 2≠0, then Padding top =(2 P -H%2 P ) / / 2, Padding bottom =(2 P -H%2 P ) / / 2+1;
[0040] Among them, / / indicates rounding, % indicates remainder, W indicates the width of the whole image of the ancient Tibetan document, H indicates the height of the whole image of the ancient Tibetan document, P indicates the number of downsampling, Padding left Indicates the padding size of the left border, Padding right Indicates the padding size of the right border, Padding top Indicates the padding size of the upper border, Padding bottom Indicates the padding size of the bottom border.
[0041] Preferably, when performing slice image prediction, the preset value is (MN) / 2; wherein M is the width of the slice image of the ancient Tibetan document, N is the height of the slice image of the ancient Tibetan document, and M is 2 P An integer multiple of , and N is an integer multiple of 2.
[0042] Preferably, during the prediction process of the layout analysis model, the watershed algorithm is used to segment the text line Mask image in the layout analysis model, and then the text line X-Height height position Mask prediction result is used to allocate the text line Mask image that meets the preset conditions to complete the text line segmentation prediction.
[0043] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0044] The deep learning-based Tibetan ancient book layout analysis method provided by the present invention adopts a layout analysis model that has been trained and includes a branch for text line Mask prediction, a branch for text line X-Height height position Mask prediction, a branch for character area Mask prediction, a branch for annotation information Mask prediction, and a branch for border line Mask prediction. Based on the overall image of the Tibetan ancient book document or the slice image of the Tibetan ancient book document, accurate analysis of the Tibetan ancient book layout can be achieved.
[0045] In addition, the present invention also adopts a Tibetan ancient book layout analysis system based on deep learning, which includes: a processor and a memory; the processor and the memory interact with each other; the memory stores a data set and a computer software program; the data set includes: an original image data set and a mask image data set; the computer software program is used to execute the above-mentioned Tibetan ancient book layout analysis method based on deep learning.
[0046] Since the technical effect achieved by the Tibetan ancient book layout analysis system based on deep learning provided by the present invention is the same as the technical effect achieved by the Tibetan ancient book layout analysis method based on deep learning provided above, it will not be described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0048] Figure 1 A flow chart of the Tibetan ancient book layout analysis method based on deep learning provided by the present invention;
[0049] Figure 2 A schematic diagram of the structural element segmentation result provided by an embodiment of the present invention; wherein, Figure 2 (a) is the original image to be segmented; Figure 2 (b) Text line segmentation map; Figure 2 (c) is the border line Mask image; Figure 2 (d) is the text line character mask image; Figure 2 (e) is the annotation information Mask map;
[0050] Figure 3 An example diagram of Tibetan syllables provided by an embodiment of the present invention;
[0051] Figure 4The text line X-Height height position diagram provided by the embodiment of the present invention; wherein, Figure 4 (a) is an example diagram of the X-Height position of a text line; Figure 4 (b) is the X-Height position Mask image of the text line;
[0052] Figure 5 A flowchart for determining the actual maximum number of pixels squeezed outward provided by an embodiment of the present invention;
[0053] Figure 6 A schematic diagram of a text line with a large gap inside provided by an embodiment of the present invention;
[0054] Figure 7 A text line segmentation map and a text line X-Height height position image overlay map provided by an embodiment of the present invention;
[0055] Figure 8 The text line Mask image generated when the maximum number of pixels squeezed outward between two adjacent text lines and the minimum number of pixels between two adjacent text lines after squeezing are different values provided in the embodiment of the present invention; wherein, Figure 8 (a) is the original image, Figure 8 (b) is a text line mask image generated when the maximum number of pixels squeezed outward between two adjacent text lines is preset to be -2, and the minimum number of pixels between two adjacent text lines after the squeezing operation is preset to be 3; Figure 8 (c) is a text line mask image generated when the maximum number of pixels squeezed outward between two adjacent text lines is preset to be 0 and the minimum number of pixels between two adjacent text lines after the squeezing operation is preset to be 3; Figure 8 (d) is a text line mask image generated when the maximum number of pixels squeezed outward between two adjacent text lines is preset to be 2 and the minimum number of pixels between two adjacent text lines after the squeezing operation is preset to be 3; Figure 8 (e) is a text line mask image generated when the maximum number of pixels squeezed outward between two adjacent text lines is preset to be 3 and the minimum number of pixels between two adjacent text lines after the squeezing operation is preset to be 3;
[0056] Fig. 9 A schematic diagram of a sample set provided by an embodiment of the present invention; wherein: Fig. 9 (a) is the original image in the sample set; Fig. 9 (b) is the border line mask image in the sample set; Fig. 9 (c) is the mask map of annotation information in the sample set; Fig. 9 (d) is the character area mask image in the sample set; Fig. 9 (e) is the X-Height height position Mask image of the text line in the sample set; Fig. 9(f) is a text line mask image generated when the maximum number of pixels squeezed outward between two adjacent text lines in the sample set is preset to be 3, and the minimum number of pixels between two adjacent text lines after the squeeze operation is preset to be 3;
[0057] Fig.10 A flowchart of the mirror filling method provided in an embodiment of the present invention;
[0058] Fig.11 An overall process framework diagram of the layout analysis of ancient Tibetan books using a deep learning-based layout analysis method provided in an embodiment of the present invention;
[0059] Fig.12 A schematic diagram of the structure of a Tibetan ancient book layout analysis model provided by an embodiment of the present invention;
[0060] Fig.13 A schematic diagram of the layout analysis results provided by an embodiment of the present invention; wherein Fig.13 (a) is the image of the ancient Tibetan book document in Ujin script to be predicted; Fig.13 (b) is a text line segmentation result diagram of the ancient Tibetan book document image in Ujin style to be predicted; Fig.13 (c) is a schematic diagram of the layout analysis results of the ancient Tibetan book document image in Ujin script to be predicted;
[0061] Fig.14 A schematic diagram of the structure of the Tibetan ancient book layout analysis system based on deep learning provided by the present invention;
[0062] Fig.15 A computer software program diagram of the mirror filling calculation method provided by an embodiment of the present invention;
[0063] Fig.16 A computer software program diagram for determining the actual maximum number of pixels squeezed outward provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0064] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0065] The purpose of the present invention is to provide a method and system for analyzing the layout of ancient Tibetan books based on deep learning, which can improve the accuracy of the analysis results of the layout of ancient Tibetan books.
[0066] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0067] like Figure 1 The present invention provides a method for analyzing the layout of ancient Tibetan books based on deep learning, comprising:
[0068] Step 100: Acquire an ancient Tibetan document image to be analyzed. The ancient Tibetan document image to be analyzed is a whole image of the ancient Tibetan document or a slice image of the ancient Tibetan document.
[0069] Step 101: Input the image of the ancient Tibetan book document to be analyzed into the trained layout analysis model to obtain the layout analysis result of the ancient Tibetan book. The layout analysis model uses a data set for training and prediction. The data set includes: an original image data set and a mask image data set. The layout analysis model includes: branch one, branch two, branch three, branch four and branch five. Branch one is used for text line mask prediction. Branch two is used for text line X-Height height position mask prediction. Branch three is used for character area mask prediction. Branch four is used for annotation information mask prediction. Branch five is used for border line mask prediction. Among them, the structure of the layout analysis model is as follows Fig.12 shown.
[0070] The construction process of the above-mentioned dataset includes:
[0071] Step 102: Acquire an original image to generate an original image data set.
[0072] Step 103: binarize the original image in the original image data set to obtain a binarized result image.
[0073] Step 104: Segment the binary result image by structural elements to obtain a structural element segmentation result image. The structural element segmentation result image includes: a border line mask image, an annotation information mask image, and a text line segmentation image.
[0074] Step 105: Obtain a text line X-Height height position Mask image according to the text line segmentation image in the structural element segmentation result image.
[0075] Step 106: Add the text line X-Height height position Mask image and the text line segmentation image bit by bit to obtain a superimposed image.
[0076] Step 107: Perform a squeezing operation on the superimposed image to obtain a text line Mask image. This step specifically includes:
[0077] Step 1071: preset the maximum number of pixels to be squeezed outward between two adjacent text lines and the minimum number of pixels between two adjacent text lines after squeezing.
[0078] Step 1072: According to the start coordinate position and the end coordinate position of two adjacent text lines, the actual maximum number of pixels to be squeezed outward is determined according to the preset maximum number of pixels and the preset minimum number of pixels. Figure 5 As shown in FIG. 1 , the actual maximum number of pixels squeezed outward is determined as follows:
[0079] When (Q i -P i )-(Max push +Min dist )*2≥0, Push dist =Max push ;
[0080] When (Q i -P i )-(Max push +Min dist )*2<0, and (Q i -P i -Min dist ) / / 2>0, Push dist =(Q i -P i -Min dist ) / / 2;
[0081] When (Q i -P i )-(Max push +Min dist )*2<0, and (Q i -P i -Min dist ) / / 2≤0, Push dist =-Min dist ;
[0082] Among them, / / indicates rounding, Q i Indicates the starting coordinate position of two adjacent text lines, P i Indicates the end coordinate position of two adjacent text lines, Max push Indicates the maximum number of pixels that can be squeezed outward between two adjacent text lines. dist Indicates the preset minimum number of pixels between two adjacent text lines after squeezing. Push dist Indicates the actual maximum number of pixels squeezed outward.
[0083] Step 1073: adjusting the superimposed image according to the actual maximum number of pixels squeezed outward to obtain a text line Mask image.
[0084] Step 108: Generate a mask image dataset based on the border line mask image, the text line X-Height height position mask image, the character area mask image, the annotation information mask image and the text line mask image.
[0085] Furthermore, in the process of predicting the layout analysis model, the image in the original image dataset is filled with a mirror filling method, which specifically includes:
[0086] When the whole image of the ancient Tibetan document is used for prediction, the padding size of the left border, right border, upper border and lower border of the image is determined according to the width and height of the whole image of the ancient Tibetan document and the number of downsampling of the layout analysis model. Fig.10 As shown, the filling size determination process can be: when W%2 P =0, then Padding left =Padding right =0. When W%2 P ≠0 and (2 P -W %2 P )%2=0,Padding left =Padding right =(2 P -W %2 P ) / / 2. When W%2 P ≠0 and (2 P -W %2 P )% 2≠0, Padding left =(2 P -W %2 P ) / / 2, Padding right =(2 P -W %2 P ) / / 2+1. When H%2 P = 0, Padding top =Padding bottom =0. When H%2 P ≠0, and (2 P -H%2 P )%2=0, then Padding top =Padding bottom =(2 P -H%2 P ) / / 2. When H%2 P ≠0, and (2 P -H%2 P )% 2≠0, then Padding top =(2 P -H%2 P) / / 2, Padding bottom =(2 P -H%2 P ) / / 2+1. Among them, / / indicates rounding, % indicates remainder, W indicates the width of the whole image of the ancient Tibetan document, H indicates the height of the whole image of the ancient Tibetan document, P indicates the number of downsampling, Padding left Indicates the padding size of the left border, Padding right Indicates the padding size of the right border, Padding top Indicates the padding size of the upper border, Padding bottom Indicates the padding size of the bottom border.
[0087] When using the slice image of the ancient Tibetan document for prediction, the padding size of the left border, right border, upper border and lower border of the slice image of the ancient Tibetan document is made to meet the preset value. For example, the preset value can be set to (MN) / 2. Where M is the width of the slice image of the ancient Tibetan document, N is the height of the slice image of the ancient Tibetan document, and M is 2 P Integer multiple, N is an integer multiple of 2.
[0088] Furthermore, in the process of predicting the layout analysis model, the watershed algorithm is used to segment the text line mask image in the layout analysis model, and then the text line X-Height height position mask prediction result is used to allocate the text line mask image that meets the preset conditions to complete the text line segmentation prediction. For example, if the height of a certain mask is less than 1 / 2 of the height of the text line X-Height height position mask, it is identified as an over-segmented image block generated by the watershed. If the mask passes through the height position area of a certain text line, the mask is assigned to the mask of the text line where the X-Height is located, otherwise it is assigned to the nearest text line mask, and finally the text line segmentation result is obtained. The attribution of broken strokes and the segmentation of bonded strokes are automatically completed by the text line mask prediction, and no additional processing is required. This method greatly reduces the difficulty of text line segmentation and improves the segmentation speed.
[0089] In addition, the present invention also adopts a Tibetan ancient book layout analysis system based on deep learning, such as Fig.14 As shown, the system includes: a processor 200 and a memory 201. The processor 200 and the memory 201 perform data exchange. The memory 201 stores a data set and a computer software program. The data set includes: an original image data set and a mask image data set. The computer software program is used to execute the above-mentioned Tibetan ancient book layout analysis method based on deep learning. Among them, the memory 201 can be a computer-readable storage medium.
[0090] Based on the perspective of machine operation, the specific implementation process of the technical solution provided above is illustrated by taking the layout analysis of ancient Tibetan books in Ujin style as an example, but it is not limited to this in practical applications.
[0091] In order to implement the technical solutions provided above, the core work mainly includes: data set construction and layout analysis process.
[0092] A. Dataset Construction
[0093] The first step is binarization. The original document image is binarized. The binarization process here is obtained by using a network model such as U-Net or a traditional binarization algorithm such as Ostu.
[0094] The second step is to segment the structural elements and obtain the border line mask image, annotation information mask image, character area mask image and text line segmentation image.
[0095] Different text line regions, border lines, annotation information, and text line body characters are all different structural elements. The binary image is segmented into different text line regions, border lines, annotation information, and characters by segmentation method, and some details are manually corrected to obtain the structural element segmentation result image, such as Figure 2 As shown, the segmentation results of the border line, annotation information, and character area are directly used as their masks, and different text line segmentation images are saved for use in the process of obtaining the text line X-Height height position Mask image.
[0096] The third step is to obtain the X-Height height position Mask image of the text line. According to the characteristics of the text line of ancient Tibetan books in Ujin style, the text line segmentation map in the structural element segmentation result image is locally horizontally projected to obtain the local baseline position, and then the local baseline is manually corrected to obtain the accurate local baseline position, and finally the X-Height Mask image is obtained. The precise local baseline marking process will take a lot of time, so the local baseline is selected as the baseline position within the local range of a certain line of text.
[0097] When making manual corrections, the accuracy of the local baseline decreases because different people have different judgments on the baseline position. At the same time, as a line baseline, it is more difficult to detect. In addition, since each character has a different number of horizontal strokes, these horizontal strokes will interfere with the baseline detection, thereby increasing the difficulty of baseline detection and increasing the error rate of baseline detection. Predicting X-Height allows the network model to more easily use the feature information of characters and text lines, reducing the difficulty of detection. In addition, compared with a line baseline, X-Height is a range with a higher fault tolerance rate. Finally, according to the definition of X-Height, the position of the baseline can be easily derived from the prediction result of X-Height.
[0098] Unlike other characters, Tibetan characters are written starting from the first stroke of the baseline and are aligned from left to right according to the baseline position. The hidden line is the baseline position of the text line. Tibetan is a phonetic language consisting of 30 letters and 4 vowels. Tibetan sentences are composed of words, and words are composed of different syllables. Syllables are separated by diacritical marks, i.e., syllable nodes, which are also aligned with the baseline position. A syllable is composed of at most 7 components: base character, upper added character, lower added character, front added character, back added character, back added character and vowel. Each vertical unit is called a character. For example, Figure 3 The following is a 4-character syllable. Except for the base character, other components can be omitted or partially omitted. According to the spelling rules of syllables, single-character syllables, double-character syllables, triple-character syllables and quadruple-character syllables can be formed. Tibetan letters have long legs and short legs, so we define the height from the baseline to the short-leg character as X-Height, such as Figure 4 As shown in (a), each text line has its own X-Height. The ancient Tibetan text in Ujin style fully reflects this feature. Figure 4 (b) is the X-Height position Mask image of the text line.
[0099] Step 4: Get the text line mask image. According to the text line segmentation map, the position information of adjacent text lines is recorded, and then its mask position is calculated. In the process of calculating the mask position of adjacent text lines, in order to prevent the expansion and corrosion operation from causing some uncontrollable situations in the annotation image, and also to obtain fine annotation data, a method based on the extrusion principle is designed and proposed to annotate the text line mask. This method can accurately control the size range of the mask between adjacent text lines. This method of mask annotation can automatically disconnect the adhesion area, reduce the difficulty of stroke adhesion segmentation between text lines, and automatically attribute the text stroke break area to the text line mask, reducing the difficulty of character strokes being assigned to the correct text line due to breakage, thereby solving the problem of stroke adhesion and stroke breakage in the process of mask production. Mask production in this way will enable the network model to complete the segmentation of stroke adhesion between lines and the assignment of stroke breakage to the correct line during training, greatly reducing the difficulty of text line segmentation.
[0100] Define a horizontal position i, Q i and P i Respectively represent the coordinate positions of the start and end of the two adjacent text lines, Max push Represents the maximum number of pixels that can be squeezed outward between two adjacent text lines. dist Represents the preset minimum number of pixels between two adjacent text lines after squeezing. Push dist Represents the actual maximum number of pixels squeezed outward. The actual maximum number of pixels squeezed outward will be dynamically adjusted according to the maximum number of pixels of adjacent elements to ensure that the Mask of adjacent text lines does not overlap during the squeezing process. Therefore, in the actual squeezing process, the actual maximum number of pixels squeezed outward is Push. dist The specific calculation process is as follows Figure 5 As shown, its computer implementation program is as follows Fig.16 shown.
[0101] Based on the above calculation process, since there are large gaps inside some text lines, such as Figure 6 As shown in FIG. 1 , these gaps may cause a text line to generate multiple masks. Therefore, the present invention performs bitwise addition of the X-Height height position Mask image and the text line segmentation map to generate an overlay map, such as Figure 7 As shown, the gaps within the row are filled, and then the overlay image is processed using the maximum number of pixels squeezed outward determined based on the squeezing principle.
[0102] Finally, when Max push 、Min dist The text line Mask images generated when the values are different are as follows Figure 8 shown.
[0103] Through the above steps, we can obtain 212 original images and their corresponding border line mask images, text line X-Height height position mask images, character area mask images, annotation information mask images and text line mask images as sample sets, such as Fig. 9 shown.
[0104] B. Layout Analysis Process
[0105] The layout analysis algorithm process used in the present invention is as follows: Fig.11 As shown, specifically including:
[0106] The first step is data set preprocessing. Due to GPU performance limitations, it is difficult to complete the training of the entire image, so the image needs to be sliced. In order to obtain the complete slicing results of the labeled data, the image is first sliced sequentially from left to right and from top to bottom to complete the slicing of the complete image. This process will ensure that all information in each image can be used for training the network model to obtain an image sequential slice sample set. In addition, in order to increase the number and diversity of samples, the image is randomly selected and sliced to obtain an image random slice sample set. The image sequential slice sample set and the image random slice sample set together constitute the training data set.
[0107] Step 2: Data reading: The data reading module reads the data set from the storage medium into the memory or video memory.
[0108] The third step is data augmentation. Random data augmentation is performed on the read image, including adding image processing operations such as rotation, translation, and flipping. This process requires processing the original image and the mask image dataset at the same time.
[0109] Step 4: Network model definition. Define the network model (i.e., layout analysis model) structure, including different backbone networks, different task branch settings, network model hyperparameters, and loss function settings. The network model structure proposed in this invention is as follows: Fig.12 As shown, in the sample diagram of the present invention, from top to bottom are branch 1, branch 2, branch 3, branch 4 and branch 5, wherein branch 1 performs text line Mask prediction, branch 2 performs text line X-Height height position Mask prediction, branch 3 performs character area Mask prediction, branch 4 performs annotation information Mask prediction, and branch 5 performs border line Mask prediction. In actual use, task branches can be added or deleted according to task requirements.
[0110] Step 5: Model training and saving. Use the optimization function to continuously optimize the loss value between the output of the network model and the labeled mask image, complete the training of the network model, and then persist the trained network model.
[0111] Step 6: Model prediction. Two prediction methods are provided: whole document image prediction and document image slice prediction. Whole image prediction is to directly predict the whole image. Slice prediction is to slice the image to be tested, then call the network model to predict the sliced image, and finally splice the sliced images to complete the image prediction.
[0112] Since the prediction effect of the edge part of the sliced image is poor, the present invention uses a cross-slicing method to complete the image prediction, that is, the image is sliced using an M×M size, but only the N×N result is selected as the prediction information, where M>N.
[0113] The network model of the present invention performs 4 downsampling during feature extraction, so the input image must be divisible by 2 to the fourth power during the prediction process. Therefore, during the prediction process, the image size needs to be adjusted first. The present invention proposes a mirror filling solution.
[0114] For the prediction of the entire image, we need to consider the relationship between the width W, height H and the number of downsampling times P of the entire image, so as to calculate the size of the padding on the upper border of the image. top , the size of the bottom border padding bottom , the size of the left border padding left , the size of the right border padding right , the mirror filling calculation method is as follows Fig.10 The computer software program for implementing the mirror filling calculation method is shown in Fig.15 shown.
[0115] During image slice prediction, the slice image size M must be 2 P N is an integer multiple of 2. Padding is the size of the image upper border padding during the image edge area slicing process. top , the size of the bottom border padding bottom , the size of the left border padding left , the size of the right border padding right Both are equal to (MN) / 2.
[0116] Step 7. Text line segmentation. Use the watershed algorithm to segment the predicted map of the network model text line mask, and then use the X-Height detection result to assign the smaller segmentation map Mask. Specifically, if the height of a certain Mask is less than 1 / 2 of the X-Height height, it is identified as an over-segmented image block generated by the watershed. If the Mask passes through the X-Height area of a text line, the Mask is assigned to the Mask of the text line where the X-Height is located, otherwise it is assigned to the Mask of the nearest text line, and finally the text line segmentation result is obtained. The attribution of broken strokes and the segmentation of adhered strokes are automatically completed by the text line Mask prediction, and no additional processing is required. This method greatly reduces the difficulty of text line segmentation and improves the segmentation speed.
[0117] When inputting an image of an ancient Tibetan book in Ujin style, such as Fig.13 (a) shows, the text line segmentation result is as follows Fig.13 (b) as shown.
[0118] Step 8: Layout analysis. Branches 2, 3, 4, and 5 in the network model correspond to the text line X-Height position Mask, character area Mask, annotation information Mask, and border line Mask, respectively, and the result is the layout analysis result. The layout analysis project will predict each pixel point, greatly improving the accuracy of layout analysis.
[0119] When inputting an image of an ancient Tibetan book in Ujin style, such as Fig.13 (a) shows, the layout analysis results are as follows Fig.13 (c) as shown.
[0120] Based on the above description, compared with the prior art, the technical solution provided by the present invention has the following advantages:
[0121] 1. Convert the problems of adhesion segmentation between text lines and stroke breakage attribution into mask production problems, providing a solution for automatic structural element segmentation.
[0122] 2. The multi-branch network structure suitable for the layout analysis of ancient Tibetan books can accurately complete the pixel-level layout segmentation task.
[0123] 3. The X-Height of the text line in the Ujin Tibetan document image is defined and utilized to further improve the accuracy of the segmentation results.
[0124] 4. The dataset annotation scheme proposed in the present invention can quickly produce layout analysis datasets through binary images, and different parameters can be modified according to needs during the production process to obtain pixel-level layout data tags, which can fill the technical gap in the production of layout analysis datasets for ancient Tibetan books in the Ujin script.
[0125] 5. The present invention models a multi-branch network model so that each branch processes different tasks and finally completes the pixel-level layout segmentation task. It can simply and effectively solve the problems of complex layout structure of ancient Tibetan books and a large number of adhesions, breaks, and intersections of characters between lines.
[0126] 6. The model has multiple branches and the number of branches can be adjusted according to different levels of tasks, which has strong scalability.
[0127] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0128] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of the present invention. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A method for analyzing the layout of ancient Tibetan books based on deep learning. It is characterized in that include: Obtaining an image of an ancient Tibetan document to be analyzed; The ancient Tibetan document image to be analyzed is a whole image of the ancient Tibetan document or a slice image of the ancient Tibetan document; Inputting the image of the ancient Tibetan book document to be analyzed into a trained layout analysis model to obtain a layout analysis result of the ancient Tibetan book; The layout analysis model is trained using a data set; the data set includes: an original image data set and a mask image data set; the layout analysis model includes: branch one, branch two, branch three, branch four and branch five; branch one is used for text line mask prediction; branch two is used for text line X-Height height position mask prediction; branch three is used for character area mask prediction; branch four is used for annotation information mask prediction; branch five is used for border line mask prediction; The process of constructing the dataset includes: Obtaining original images to generate an original image dataset; Binarization is performed on the original image in the original image data set to obtain a binarization result image; Performing structural element segmentation on the binarization result image to obtain a structural element segmentation result image; the structural element segmentation result image includes: a border line mask image, an annotation information mask image, a character area mask image and a text line segmentation image; Obtaining a text line X-Height height position Mask image according to the text line segmentation image in the structural element segmentation result image; Add the text line X-Height height position Mask image and the text line segmentation image bit by bit to obtain a superimposed image; Performing a squeezing operation on the superimposed image to obtain a text line Mask image; Generate a mask image dataset based on the border line mask image, the text line X-Height height position mask image, the character area mask image, the annotation information mask image and the text line mask image; The step of performing a squeezing operation on the superimposed image to obtain a text line Mask image specifically includes: Preset the maximum number of pixels to be squeezed outward between two adjacent text lines and the minimum number of pixels to be squeezed between two adjacent text lines; According to the start coordinate position and the end coordinate position of two adjacent text lines, the actual maximum number of pixels squeezed outward is determined according to the preset maximum number of pixels and the preset minimum number of pixels; The superimposed image is adjusted according to the actual maximum number of pixels squeezed outward to obtain a text line Mask image; The determining of the actual maximum number of pixels to be squeezed outward according to the start coordinate position and the end coordinate position of two adjacent text lines and the preset maximum number of pixels and the preset minimum number of pixels specifically includes: When (Q i -P i )-(Max push +Min dist )*2≥0, Push dist =Max push ; When (Q i -P i )-(Max push +Min dist )*2<0, and (Q i -P i -Min dist ) / / 2>0, Push dist =(Q i -P i -Min dist ) / / 2; When (Q i -P i )-(Max push +Min dist )*2<0, and (Q i -P i -Min dist ) / / 2≤0, Push dist =-Min dist ; Among them, / / indicates rounding, Q i Indicates the starting coordinate position of two adjacent text lines, P i Indicates the end coordinate position of two adjacent text lines, Max push Indicates the maximum number of pixels that can be squeezed outward between two adjacent text lines. dist Indicates the preset minimum number of pixels between two adjacent text lines after squeezing. Push dist Indicates the actual maximum number of pixels squeezed outward.
2. According to the method for analyzing the layout of ancient Tibetan books based on deep learning according to claim 1, It is characterized in that During the prediction process, a mirror filling method is used to fill the images in the original image dataset.
3. According to the method for analyzing the layout of ancient Tibetan books based on deep learning according to claim 2, It is characterized in that During the prediction process, the image in the original image dataset is filled using a mirror filling method, specifically including: When the whole image of the ancient Tibetan book document is used for prediction, the filling sizes of the left border, the right border, the upper border and the lower border of the image are determined according to the width and height of the whole image of the ancient Tibetan book document and the number of downsampling of the layout analysis model; When the slice image of the ancient Tibetan document is used for prediction, the filling sizes of the left border, the right border, the upper border and the lower border of the slice image of the ancient Tibetan document are made to meet the preset values.
4. According to the method for analyzing the layout of ancient Tibetan books based on deep learning according to claim 3, It is characterized in that The filling sizes of the left border, the right border, the upper border and the lower border of the image are determined according to the width and height of the overall image of the Tibetan ancient book document and the number of downsampling of the layout analysis model, specifically including: When W%2 P =0, then Padding left =Padding right =0; When W%2 P ≠0 and (2 P -W %2 P )%2=0,Padding left =Padding right =(2 P -W %2 P ) / / 2; When W%2 P ≠0 and (2 P -W %2 P )% 2≠0, Padding left =(2 P -W %2 P ) / / 2, Padding right =(2 P -W %2 P ) / / 2+1; When H%2 P = 0, Padding top =Padding bottom =0; When H%2 P ≠0, and (2 P -H%2 P )%2=0, then Padding top =Padding bottom =(2 P -H%2 P ) / / 2; When H%2 P ≠0, and (2 P -H%2 P )% 2≠0, then Padding top =(2 P -H%2 P ) / / 2, Padding bottom =(2 P -H%2 P ) / / 2+1; Among them, / / indicates rounding, % indicates remainder, W indicates the width of the whole image of the ancient Tibetan document, H indicates the height of the whole image of the ancient Tibetan document, P indicates the number of downsampling, Padding left Indicates the padding size of the left border, Padding right Indicates the padding size of the right border, Padding top Indicates the padding size of the upper border, Padding bottom Indicates the padding size of the bottom border.
5. According to the method for analyzing the layout of ancient Tibetan books based on deep learning according to claim 3, It is characterized in that The preset value is (MN) / 2; wherein M is the width of the slice image of the ancient Tibetan document, N is the height of the slice image of the ancient Tibetan document, and M is 2 P An integer multiple of , N is an integer multiple of 2, and P is the number of downsampling times of the layout analysis model.
6. The method for analyzing the layout of ancient Tibetan books based on deep learning according to claim 1, It is characterized in that During the prediction process, the watershed algorithm is used to segment the text line Mask image in the layout analysis model, and then the text line Mask image that meets the preset conditions is allocated using the text line X-Height height position Mask prediction result to complete the text line segmentation prediction.
7. A Tibetan ancient book layout analysis system based on deep learning, It is characterized in that include: Processor and memory; The processor and the memory perform data exchange; The memory stores a data set and a computer software program; The data set includes: an original image data set and a Mask image data set; The computer software program is used to execute the Tibetan ancient book layout analysis method based on deep learning as described in any one of claims 1 to 6.
Citation Information
Patent Citations
A method and system for line segmentation of ancient Tibetan texts
CN107944451B
Adhesion text line segmentation method and system for Wujin Tibetan ancient book document image
CN111626302A
Tibetan ancient book document image binarization method and system
CN112837329A
Method and device for positioning answering area in test question image and electronic equipment
CN111507251A
Layout analysis method and system for Tibetan ancient books
CN112561928A
