Ancient book document text column extraction method based on morphological improved vertical projection method

By using the vertical projection method based on morphological improvement in text column extraction of ancient books and documents, the problems of oversegment, weak segmentation and poor universality in the prior art are solved, and a fast and accurate text column extraction effect is achieved.

CN119723601APending Publication Date: 2025-03-28DALIAN NATIONALITIES UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411772265.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

The prior art has problems of oversegment, weak segmentation and poor universality in text column extraction of ancient documents. Especially in the case of image quality deterioration, text overlap and writing deformation, the vertical projection method is prone to excessive troughs/crows, resulting in poor extraction effect.

Method used

The vertical projection method based on morphological improvement is adopted, and the images of ancient documents are binarized, and stroke widths, morphological expansion and vertical projection are rapidly estimated, so as to reduce unnecessary troughs/crows and improve extraction accuracy.

Benefits of technology

It realizes fast and accurate text column extraction of ancient books and documents, solves the problems of oversegment and weak segmentation, and improves the universality and efficiency of the extraction method.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119723601A_ABST
    Figure CN119723601A_ABST
Patent Text Reader

Abstract

The invention discloses an ancient book document text column extraction method based on a morphological improved vertical projection method, belongs to the field of document image processing, aims at solving the problem of quickly and accurately extracting an ancient book document text column, and has the technical key points that an ancient book document image is preprocessed to obtain a binary document image; quickly estimating the stroke width of the ancient book document according to the binary document image; performing morphological dilation on the binary document image by selecting a stroke width with a certain multiple to obtain a dilated image; performing matrix column summation on the expanded image to obtain a vertical projection vector; setting a non-zero value in the vertical projection vector as 1 to obtain a first replacement vector; supplementing 0 before and after the first permutation vector to obtain a second permutation vector; a difference value between adjacent elements in the second replacement vector is calculated to obtain a result vector, an element value = 1 in the result vector corresponds to the initial position of one column of the text, an element value =-1 in the result vector corresponds to the end position of one column of the text, and text column segmentation is carried out according to the initial position and the end position of one column.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of document image processing and relates to an ancient book document text column extraction method based on a morphologically improved vertical projection method. Background Art

[0002] Research on information retrieval technology for ancient documents has important theoretical significance and application value. Among them, extracting text columns from the entire historical document image is an important preprocessing step in multiple key technical links such as historical document layout analysis, database construction, text recognition and retrieval. Ancient documents are generally very old, with problems such as degradation, large writing deformation, and poor scanned image quality, which makes it difficult to automatically extract (segment, segment) text columns.

[0003] Problems and shortcomings of existing technical solutions:

[0004] (1) Manual segmentation: It requires a lot of manpower and time.

[0005] (2) Traditional word extraction methods based on connected domain analysis: This type of method first extracts all connected domains (i.e., letters, components, or strokes, etc.) in the entire document, and then uses manually designed rules or features to classify these connected domains into three categories: over-segmentation, weak segmentation, and correct segmentation. The over-segmented areas are further merged using manually designed rules, and the weakly segmented areas are subjected to secondary precise segmentation and other processing. Finally, the correct processing results are recombined into separate characters according to the spelling rules. However, since ancient documents have multiple characters, different font styles, and deformations, over-segmentation or weak segmentation often occurs, and it is necessary to design component merging rules or fine segmentation rules, making the extraction method more complicated. At the same time, since this type of method is highly dependent on heuristic rules and manual parameter settings, the extraction method for one document often cannot be fully automatically migrated to another document, resulting in poor versatility of the segmentation method.

[0006] (3) Vertical projection method: The main idea of ​​this method is to use the spaces between words or characters, find the position of the spaces through vertical projection (corresponding to the trough / peak of the projection), and then segment the words or characters according to the position of the spaces. The vertical projection method is widely used in text segmentation. However, there are problems when the vertical projection method is directly applied to the text column extraction of ancient documents: due to the deterioration of the image quality of ancient documents, overlapping of characters, writing deformation, etc., conventional binarization will produce a large number of short strokes, resulting in too many troughs / peaks of the vertical projection, which interferes with the determination of the true troughs / peaks and leads to a large number of over-segmentation. If the threshold method is further used to constrain the selection of troughs, it will cause a series of problems such as poor versatility, excessive time consumption and weak segmentation. It will also increase subsequent algorithms such as merging rules, further increasing the complexity of the text column method. Summary of the invention

[0007] In order to solve the problem of quickly and accurately extracting text columns from ancient book documents, in a first aspect, according to some embodiments of the present application, a method for extracting text columns from ancient book documents based on a morphologically improved vertical projection method is provided, wherein the ancient book document is a document arranged in columns, and the extraction method comprises the following steps:

[0008] Preprocess the ancient book document image to obtain a binary document image I bw , where the text is white and the background is black;

[0009] According to the binary document image I bw , quickly estimate the stroke width of ancient documents;

[0010] For the binary document image I bw Select a certain multiple of the stroke width to perform morphological expansion to obtain the expanded image I pz ;

[0011] For the dilated image I pz Sum the matrix columns to get the vertical projection vector I cz , where the vertical projection vector I cz The peaks of the wave correspond to the text area, and the troughs correspond to the background area;

[0012] The vertical projection vector I cz Set the non-zero values ​​in to 1 to obtain the first permutation vector T1;

[0013] The first permutation vector is padded with zeros at the front and back to obtain a second permutation vector T2;

[0014] Calculate the result vector k of the difference between adjacent elements in the second permutation vector T2, wherein the element value = 1 in the result vector k corresponds to the starting position of a text column, and the element value = -1 corresponds to the ending position of a text column, and the text column is segmented according to the starting position and the ending position of a column.

[0015] According to the ancient book document text column extraction method based on morphological improved vertical projection method in some embodiments of the present application, the ancient book document image is preprocessed by Otsu method to obtain a binary image I bw1 , for the binarized image I bw1 The inversion operation obtains the binary document image I bw .

[0016] According to some embodiments of the present application, the ancient book document text column extraction method based on the morphological improved vertical projection method, wherein the binary document image I bw Select 3 times the stroke width for morphological dilation to obtain the dilated image I pz。

[0017] According to some embodiments of the present application, a method for extracting text columns from ancient book documents based on the morphologically improved vertical projection method is provided, wherein the morphological expansion adopts a disc-shaped structure.

[0018] According to the ancient book document text column extraction method based on the morphological improved vertical projection method in some embodiments of the present application, the starting position represented by the element value of 1 in the statistical result vector k is recorded as vector ind_st; the ending position represented by the element value of -1 in the statistical result vector k is recorded as vector ind_ed, and the number of elements in the vector ind_st represents the number of text columns in the document image;

[0019] Obtain the position and length of the text area according to the starting position and the ending position;

[0020] The number of text columns in the document image is obtained according to the number of elements in the vector ind_st, which is expressed as seg_no=the number of elements in ind_st.

[0021] According to the ancient book document text column extraction method based on the morphological improved vertical projection method in some embodiments of the present application, the ancient book document includes a document of ancient Chinese books typeset in columns and / or a document of ancient Manchu books typeset in columns.

[0022] On the second aspect, according to some embodiments of the present application, a document text column extraction method based on a morphologically improved vertical projection method is provided, wherein the document is a horizontally arranged document; including rotating the horizontally arranged document by 90 degrees to represent it as a vertically arranged document, and implementing the extraction method described in any one of claims 1-6 on the rotation of 90 degrees to represent it as a vertically arranged document.

[0023] On the third aspect, an embodiment of the present application also provides an electronic device, comprising: one or more processors, a memory, and one or more programs; wherein the one or more programs are stored in the memory, and the one or more programs include instructions, which, when executed by the electronic device, enable the electronic device to execute the first aspect and any possible technical solution of the first aspect.

[0024] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium includes a computer program. When the computer program runs on an electronic device, the electronic device executes the first aspect and any possible technical solution of the first aspect.

[0025] Beneficial effects:

[0026] In the first aspect, the extraction method of the present invention first performs image binarization processing, then quickly estimates the stroke width value of the entire document, and then uses multiples of the stroke width value to perform morphological dilation processing, and connects the discontinuous strokes, free strokes, etc. generated after the binarization to form a whole. In this way, on the vertical projection image, the number of redundant discrete troughs / peaks will be greatly reduced, and even redundant discrete troughs / peaks will not appear, so the regularly arranged columns can be segmented out.

[0027] On the second aspect, the method of the present invention is applicable to vertically arranged ancient Chinese character documents and Manchu documents. Among them, for Manchu, due to its vertical writing and belonging to a vertical font, there are few characteristics of continuous length of horizontal strokes. The writing of Manchu has a vertical axis, and the width of the vertical axis can better reflect the characteristics of the stroke width. The present invention makes full use of its characteristics to improve the speed and accuracy of stroke width estimation.

[0028] On the third aspect, the present invention realizes automatic extraction (segmentation, segmentation) of text columns through a fast stroke width estimation method, morphological processing and an improved vertical projection method, thereby solving the over-segmentation problem caused by too many discrete troughs / peaks, and has the effect of fast and accurate text column extraction of ancient documents.

[0029] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 It is a schematic diagram of an image of an ancient Chinese book document, with the text part being black and the background part being white.

[0031] Figure 2 yes Figure 1 Binarized and inverted image I bw , the text part is white and the background part is black.

[0032] Figure 3 yes Figure 2 Schematic diagram of the line with the most characters.

[0033] Figure 4 yes Figure 2 Image after morphological dilation Ipz .

[0034] Figure 5 The method of the present invention is Figure 1 Graph showing the effect of text column extraction.

[0035] Figure 6 It is a horizontally arranged Chinese character document.

[0036] Figure 7Schematic diagrams before and after column extraction of multi-font documents; among them, (a) Schematic diagram of a multi-font document, (b) Column extraction result of the multi-font document.

[0037] Figure 8 Schematic diagrams before and after column extraction of multi-font documents by different methods; among them, (a) Multi-font Manchu document composed of 11 fonts with the full Manchu letter "humble", (b) Text column extraction result of the original vertical projection method, (c) Text column extraction result of the method of the present invention. Specific implementation manner

[0038] The embodiments of the present application will be described in detail below with reference to the accompanying drawings. The examples of the embodiments are shown in the drawings. The present application provides a method and an electronic device. Among them, the method and the device are based on the same technical concept. Since the principles of solving problems by the method and the device are similar, the implementation of the device and the method can be referred to each other, and the repeated parts will not be described again.

[0039] The present invention relates to a method for extracting text columns of ancient book documents based on an improved vertical projection method of morphology. The ancient book documents are documents typeset in columns. The extraction method includes the following steps:

[0040] Preprocess the ancient book document image to obtain a binary document image I bw , where the text is white and the background is black;

[0041] According to the binary document image I bw , quickly estimate the stroke width of the ancient book document;

[0042] For the binary document image I bw Select a certain multiple of the stroke width for morphological dilation to obtain a dilated image I pz ;

[0043] Perform matrix column summation on the dilated image I pz to obtain a vertical projection vector I cz , where the peaks of the vertical projection vector I cz correspond to the text regions, and the valleys correspond to the background regions;

[0044] Set the non-zero values in the vertical projection vector I cz to 1 to obtain a first replacement vector T1;

[0045] Complement 0 before and after the first replacement vector to obtain a second replacement vector T2;

[0046] Calculate the result vector k of the difference between adjacent elements in the second permutation vector T2, wherein the element value = 1 in the result vector k corresponds to the starting position of a text column, and the element value = -1 corresponds to the ending position of a text column, and the text column is segmented according to the starting position and the ending position of a column.

[0047] In the ancient book document text column extraction method based on morphological improved vertical projection method in this embodiment, the ancient book document image is preprocessed by Otsu method to obtain a binary image I bw1 , for the binarized image I bw1 The inversion operation obtains the binary document image I bw .

[0048] In the ancient book document text column extraction method based on morphological improved vertical projection method in this embodiment, the binary document image I bw Select 3 times the stroke width for morphological dilation to obtain the dilated image I pz。

[0049] In the ancient book document text column extraction method based on the morphologically improved vertical projection method in this embodiment, the morphological expansion adopts a disc-shaped structure.

[0050] In the ancient book document text column extraction method based on the morphological improved vertical projection method in this embodiment, the starting position represented by the element value of 1 in the statistical result vector k is recorded as vector ind_st; the ending position represented by the element value of -1 in the statistical result vector k is recorded as vector ind_ed, and the number of elements in the vector ind_st represents the number of text columns in the document image;

[0051] Obtain the position and length of the text area according to the starting position and the ending position;

[0052] The number of text columns in the document image is obtained according to the number of elements in the vector ind_st, which is expressed as seg_no=the number of elements in ind_st.

[0053] In the ancient book document text column extraction method based on the morphological improved vertical projection method in this embodiment, the ancient book document includes a document of ancient Chinese books arranged in columns and / or a document of ancient Manchu books arranged in columns.

[0054] In the ancient book document text column extraction method based on the morphologically improved vertical projection method in this embodiment, the document is a horizontally arranged document; including rotating the horizontally arranged document 90 degrees to represent it as a vertically arranged document, and implementing any one of the extraction methods on the rotated 90 degrees to represent it as a vertically arranged document.

[0055] In a first aspect, the extraction method of the present invention first performs image binarization processing, then quickly estimates the stroke width values of the entire document, and then performs morphological dilation processing with a multiple of the stroke width value to connect the discontinuous strokes, free strokes, etc. generated after binarization to form a whole. In this way, on the vertical projection image, the number of redundant discrete valleys / peaks will be greatly reduced, or even no redundant discrete valleys / peaks will appear, and the regularly arranged columns can be segmented out.

[0056] In a second aspect, the method of the present invention is applicable to vertically arranged Chinese ancient book documents and Manchu documents. Among them, for Manchu, due to its vertical writing and being a vertical font, with few characteristics of the continuous length of strokes in the horizontal direction, the writing of Manchu has a vertical axis, and the width of the vertical axis can better reflect the characteristics of the stroke width. The present invention makes more full use of its characteristics to improve the speed and accuracy of stroke width estimation.

[0057] In a third aspect, the present invention realizes automatic text column extraction (segmentation, splitting) through a fast method for estimating stroke width values, morphological processing, and an improved vertical projection method, solves the over-segmentation problem caused by excessive discrete valleys / peaks, and has the effect of quickly and accurately extracting text columns of ancient book documents.

[0058] The text of ancient book documents is generally typeset in columns. For example, Manchu ancient book documents are generally written vertically from left to right and belong to vertical fonts, with few continuous lengths of strokes in the horizontal direction. The writing of Manchu has a vertical axis, and the width of the vertical axis can better reflect the stroke width. The continuous length of strokes can be understood as, for example, the捺 at the bottom of the character "之" in Chinese characters. Therefore, the width estimation of Manchu font strokes naturally has font characteristics that can be utilized.

[0059] Extracting text columns from the entire historical document image is an important preprocessing step for multiple key technical links such as historical document layout analysis, database construction, text recognition, and retrieval. Character stroke width is an essential step for extracting text columns. Only by quickly and accurately extracting the character stroke width can the column extraction be fast and accurate. The stroke widths of characters in an ancient book document may be relatively consistent, for example, printed characters of the same font size, or may not be consistent, for example, in the case of different characters, different fonts, different font sizes, and handwritten characters. Therefore, most of the existing methods for extracting character stroke width require extracting, counting, and analyzing the stroke connectivity domains of the entire document. This method for obtaining stroke width is cumbersome, time-consuming, and has poor generality and robustness.

[0060] Among them, as a separate method or the method for quickly estimating the stroke width of ancient book documents in the above extraction method, this method includes

[0061] Counting the horizontal projection of the column layout document; wherein the column layout document is a binary document image, a pixel value of 0 in the binary document image represents the black color of the binary document image, and a pixel value of 1 represents the white color of the binary document image;

[0062] Acquire the row number containing the most stroke width samples according to the horizontal projection;

[0063] Extracting a first row vector of a row containing the most stroke width samples in the binary document image;

[0064] Add 0s to the front and back of the first row vector to obtain the second row vector;

[0065] Determine the starting point and the ending point of each stroke in the second row vector according to the differential vector of the second row vector, and obtain the width value of each stroke according to the starting point and the ending point;

[0066] The document stroke width value is calculated according to the stroke width values ​​of the second row vector.

[0067] In the method for quickly estimating the stroke width of an ancient book document in this embodiment, the binary document image is represented by an M×N matrix I, where M represents the number of rows of the matrix and N represents the number of columns of the matrix.

[0068] In the method for quickly estimating the stroke width of an ancient book document in this embodiment, the line number containing the most stroke width samples is obtained according to the horizontal projection, including:

[0069] Get the projection value vector I of each row of the matrix I of the binary document image sp , with a length of M, where the vector I sp Each element value corresponds to a row of projection results;

[0070] The row number row corresponding to the maximum value in the vector Isp is obtained, and a row in the binary document image corresponding to the row number row is the row number containing the most stroke width samples.

[0071] In the method for quickly estimating the stroke width of ancient books and documents in this embodiment, if there are multiple row numbers corresponding to the maximum value of the vector Isp, any one of them, the first one, or the last one is selected to obtain a row number row, and the row in the binary document image corresponding to the row number row is the row number containing the most stroke width samples.

[0072] In the method for quickly estimating the stroke width of an ancient document in this embodiment, the first row vector of the row containing the most stroke width samples in the binary document image is extracted, including

[0073] Extract the row-th row vector of the matrix I of the binary document image, recorded as vector T0, where vector T0 is a 1×N row vector and is represented as the first row vector;

[0074] In the method for quickly estimating the stroke width of an ancient book document in this embodiment, the first row vector is padded with zeros before and after to obtain a second row vector, including

[0075] Add a 0 before and after the first row vector T0 to get the second row vector, denoted by T, vector T = [0, T0, 0];

[0076] In the method for quickly estimating the stroke width of an ancient book document in this embodiment, the starting point and the end point of each stroke in the second row vector are determined according to the differential vector of the second row vector, including differentiating the second row vector T, and the differential vector k is expressed as:

[0077] k = diff(T);

[0078] Among them, in the differential vector k, the position where the element value in the vector k is 1 corresponds to the starting point of the stroke, and the position where the element value is -1 corresponds to the end point of the stroke; the stroke width len = the stroke end point position - the stroke starting point position.

[0079] In the method for quickly estimating the stroke width of an ancient book document in this embodiment, the ancient book document is a Chinese character document arranged in columns. According to the stroke width values ​​of the second row vector, the average value of the stroke width values ​​is calculated, and the average value of the stroke width values ​​is used as the stroke width value of the document.

[0080] In the method for quickly estimating the stroke width of an ancient book document in this embodiment, the ancient book document is a Manchu document arranged in columns. According to the stroke width values ​​of the second row vector, the frequency of occurrence of the stroke width values ​​is counted, wherein the stroke width value with the highest frequency of occurrence is the mode of the stroke width values, and the mode is used as the stroke width value of the document.

[0081] In the method for quickly estimating the stroke width of an ancient book document in this embodiment, the ancient book document is a Manchu document arranged in columns, and the frequency of occurrence of the stroke width values ​​is counted, wherein, if the stroke width value with the highest frequency of occurrence exceeds one, then the mode of the stroke width value does not exist, and the average value of the stroke width values ​​is calculated, and the average value of the stroke width values ​​is taken as the stroke width value of the document.

[0082] In the first aspect, the stroke width estimation method of the present invention considers from the perspective of rows, and a row of characters may contain characters of all columns (or most columns) of the entire document. First, from a statistical perspective, it is found that the row containing the most characters in the document must contain the most character information of all columns, which is more typical and can represent the stroke width values ​​of the characters in a document. Therefore, it is not necessary to consider all the characters in the entire document. It is only necessary to examine the mode or average value of the stroke width value of the longest text line in the document, which can be a typical representative of the stroke width value of a document. Secondly, the method of the present invention is applicable to vertically arranged Chinese ancient book documents and Manchu documents. Again, the present invention is aimed at Manchu, which is written vertically and belongs to a vertical font. There is little continuous length of strokes in the horizontal direction. The writing of Manchu has a vertical axis, and the width of the vertical axis can better reflect the characteristics of the stroke width. The stroke width represented by the vertical axis is accurate and stable. Therefore, in the present invention, in the estimation of the stroke width of Manchu, for the calculation of the stroke width of Manchu, the frequency of occurrence of the stroke width value is counted, wherein the stroke width value with the highest frequency of occurrence is the mode of the stroke width value, and the mode is used as the document stroke width value. If the stroke width value with the highest frequency of occurrence exceeds 1, the mode of the stroke width value does not exist, and then the average value of the stroke width values ​​is calculated, and the average value of the stroke width values ​​is used as the document stroke width value. That is, the stroke width reflected by the width of the Manchu vertical axis is preferentially used as the result. When the Manchu vertical axis is difficult to distinguish and reflect, the stroke width is reflected by the stroke width average value, so that the Manchu stroke width estimation is faster and more accurate.

[0083] In the second aspect, the stroke width estimation method of the present invention can quickly and accurately extract the stroke width by only performing simple matrix operations, without the need for complex image processing operations such as connected domain marking and stroke extraction. Experiments have shown that the response speed of stroke width estimation is greatly improved. Moreover, the document column extraction based on the above stroke width extraction also has extremely high accuracy.

[0084] Specifically, the present invention is based on the ancient book document text column extraction method of the morphologically improved vertical projection method. First, the image is binarized, and then the stroke width value of the entire document is quickly estimated. Then, the morphological expansion process is performed with multiples of the stroke width value, and the discontinuous strokes and free strokes generated after the binarization are connected to form a whole. In this way, on the vertical projection image, the number of redundant discrete troughs / peaks will be greatly reduced, and even redundant discrete troughs / peaks will not appear, and the regularly arranged columns can be segmented out. The method of the present invention is aimed at the characteristics of Manchu, which is written vertically and belongs to a vertical font, and there are few horizontal strokes with continuous lengths. The fast method of stroke width value estimation, morphological processing and improved vertical projection method are used to realize automatic text column extraction (segmentation, segmentation), which solves the problem of over-segmentation caused by too many discrete troughs / peaks, and has the effect of fast and accurate text column extraction of ancient book documents.

[0085] The ancient book document text column extraction method based on morphological improved vertical projection method includes the following steps:

[0086] (1) Input of ancient book document images;

[0087] (2) Image preprocessing;

[0088] (3) Rapid estimation of stroke width;

[0089] (4) morphological expansion;

[0090] (5) Vertical projection method;

[0091] (6) Text column segmentation.

[0092] The specific implementation methods of the above steps are described in detail as follows:

[0093] (1) Ancient book document image input: The default is black text, white background, RGB color image, and document image is represented by I, such as Figure 1 shown.

[0094] (2) Image preprocessing, including the following steps:

[0095] (2-1) Image binarization;

[0096] (2-2) Image inversion.

[0097] Specifically, in this step, the image is first binarized using the Otsu method, and the binarized image is bw1 Indicates that Figure 2 The purpose of image inversion is to make the text white and the background black, which is convenient for morphological operations and projection. The image after the inversion operation is used bwIndicates. Take the MATLAB software programming environment as an example: that is, the text value = 1, the background value = 0. If the image originally has white text and black background, there is no need to perform the inversion operation. Figure 2 As shown in Figure 1, binarization will bring serious breakage problems, which is one of the main reasons why the conventional vertical projection method will produce redundant troughs / peaks when extracting text columns, resulting in extraction failure.

[0098] (3) Rapid estimation of stroke width, including

[0099] (3-1) The binary document image obtained by image preprocessing is used bw Indicates that the default is a binary image, with white text (pixel value = 1) and black background (pixel value = 0), and the text is arranged in columns. The M×N matrix I, M represents the number of rows in the matrix, and N represents the number of columns in the matrix.

[0100] (3-2) Statistical horizontal projection, that is, Figure 2 The binary document image I shown bw , sum by row, return vector I sp The length of is M. Figure 3 As shown, the image size is 631×1018, that is, M=631. bw Sum by row, that is, find the projection value of each of the 631 rows (1 for text, 0 for background), and get vector I sp is a column vector of length 631.

[0101] (3-3) Find the row with the most characters: Find I sp The row number corresponding to the maximum value rowmax. If there are multiple rows with the same value and they are all the maximum value, the first one is taken by default, and the row number with the most characters is recorded as row. sp is a vector of length M, in which each element value corresponds to the projection result of a row. Find I sp The row number corresponding to the maximum value in is the row number with the most characters. sp The maximum value is recorded as rowmax. In this example, rowmax = 240. Find the element with value 240 in I sp The sequence number row in Figure 3 In the example, row = 254. That is, for Figure 3 For example, the line with the most characters is line 254, and the total number of characters (projection) is 240 pixels. Figure 2 In the example, rowmax=240, and the corresponding row is 254, then row=254. That is, the 254th row of matrix I contains the most stroke width samples. Figure 3 The red line in the figure shows the pixel rows in the image processing, not the text rows in the usual sense.

[0102] (3 - 4) Calculation of stroke width value: Extract the row vector of the \(row\) - th row of matrix \(I\), denoted as \(T0\), then \(T0\) is a \(1\times N\) row vector. Add a \(0\) at the front and back of \(T0\) to get a new row vector denoted as \(T\), that is, \(T = [0,T0,0]\). Count the length of the white strokes in this row, which is the stroke width. The method is as follows: Take the difference of \(T\), and the resulting vector is denoted as \(k\), that is, \(k = diff(T)\). In the difference vector, the positions with value \(1\) correspond to the starting points of the strokes, and the positions with value \(-1\) correspond to the ending points of the strokes. For example, assume a sub - segment of \(T\) is \(t=[001111100]\), where 5 consecutive \(1\)'s indicate that the stroke width \( = 5\). The difference result is \(k = diff(t)=[010000 - 10]\). Then the starting position of the stroke \(k(2)=1\), the position corresponding to the ending point of the stroke \(k(7)= - 1\), and the stroke width \(len=\) ending position of the stroke – starting position of the stroke \(=7 - 2 = 5\).

[0103] (3 - 5) Estimation of stroke width value: Count all the stroke width values included in the \(row\) - th row. For Chinese ancient document, take the average value of the stroke width values, round it to the nearest integer, and output it as the final value of the stroke width \(sw\). For Manchu ancient document, find the stroke width value with the highest frequency of occurrence, that is, the mode of the stroke width values, and output it as the final value of the stroke width \(sw\); if the mode does not exist, still take the average value of the stroke width, round it to the nearest integer, and output it as the final output of the stroke width \(sw\).

[0104] The text of ancient document is generally typeset in columns. For example, in the Manchu ancient document, it is generally written vertically from left to right and belongs to a vertical font, with few continuous lengths of horizontal strokes. The Manchu writing has a vertical axis, and the width of the vertical axis can better reflect the stroke width. The continuous length of the stroke can be understood as, for example, the downward stroke similar to the lower part of the Chinese character '之'. Therefore, the width estimation of Manchu font strokes naturally has font characteristics that can be utilized.

[0105] Extracting text columns from the entire historical document image is an important pre - processing step for multiple key technical links such as historical document layout analysis, database construction, text recognition, and retrieval. Character stroke width extraction is an essential step for extracting text columns. Only by quickly and accurately extracting the character stroke width can the column extraction be fast and accurate. The stroke widths of characters in an ancient document may be relatively consistent, for example, for printed texts with the same font size, or may be inconsistent, for example, in the cases of different characters, different fonts, different font sizes, and handwritten texts. Therefore, most of the existing methods for extracting character stroke width require extracting, counting, and analyzing the stroke connectivity regions of the entire document. This method of obtaining stroke width is cumbersome, time - consuming, and has poor generality and robustness.

[0106] The present invention considers from the perspective of the row, and a row of characters may contain characters of all columns (or most) of the columns of the entire document. First, from the perspective of statistics, it is found that the row containing the most characters in the document must contain the most character information of all columns, which is more typical and can represent the character stroke width value in a document. Therefore, it is not necessary to consider all the characters in the entire document. It is only necessary to examine the mode or average value of the stroke width value of the longest text line in the document, which can be a typical representative of the stroke width value of a document. Secondly, the method of the present invention is applicable to vertically arranged Chinese ancient book documents and Manchu documents. Again, the present invention is directed to Manchu, which is written vertically and belongs to a vertical font, and there is little horizontal continuous length of strokes. The writing of Manchu has a vertical axis, and the width of the vertical axis can better reflect the characteristics of stroke width. The stroke width represented by the vertical axis is accurate and stable. Therefore, the present invention is in the Manchu stroke width estimation, for the calculation of Manchu stroke width, the stroke width value occurrence frequency is counted, wherein the stroke width value with the highest occurrence frequency is the mode of the stroke width value, and the mode is used as the document stroke width value. If the stroke width value with the highest frequency of occurrence exceeds one, the mode of the stroke width value does not exist, and then the average value of the stroke width values ​​is calculated, and the average value of the stroke width values ​​is used as the document stroke width value. That is, the stroke width reflected by the width of the Manchu vertical axis is preferred as the result. When the Manchu vertical axis is difficult to distinguish and reflect, the stroke width is reflected by the average stroke width, so that the Manchu stroke width estimation is faster and more accurate.

[0107] Therefore, based on the above, the present invention can only perform simple matrix operations and can also quickly and accurately extract stroke widths without the need for complex image processing operations such as connected domain marking and stroke extraction. Experiments have shown that the response speed of stroke width estimation is greatly improved. Moreover, the document column extraction based on the above stroke width extraction also has extremely high accuracy.

[0108] (4) Morphological expansion: Morphological expansion uses a disc-shaped structure with a radius of 3 times the stroke width (Note: 3 times here is an empirical value and can be adjusted according to the density of strokes and characters in different documents). bw The image is expanded, and the expanded image is used pz Indicates that Figure 4 The effect of morphological dilation operation: the vertical projection method will produce a lot of redundant troughs / peaks. After morphological dilation, the text area is enhanced, and the previous free strokes and small breaks will be connected and integrated with the main body of the text column, thus eliminating the redundant troughs / peaks.

[0109] (5) Vertical projection method: sum up the image matrix columns → set non-zero values ​​to 1 → difference processing → count the position, length and number of text columns of the text area.

[0110] Image matrix column summation: for I pz The image uses the matrix column summation method to achieve conventional vertical projection and obtain the projection vector I cz In the vertical projection at this time, the peak corresponds to the text area, and the trough corresponds to the background area.

[0111] Non-zero values ​​are set to 1: Because the projection value of the text part is generally non-zero, and the value is large and not uniform, but this does not make any sense for subsequent operations, so the projection vector I cz All non-zero values ​​in are set to 1, and the replaced vector is represented by T1. Furthermore, in order to facilitate subsequent differential processing, a 0 element is added before and after T1, represented by T2.

[0112] Difference processing: Calculate the difference between two adjacent elements in T1, and record the result vector as k. In k, value = 1 corresponds to the starting position of the text column, and value = -1 corresponds to the end position of the text column. The difference is to subtract the previous value of the element from the next value of the element in the vector. For example, if the sequence is 1, 0, 1, 1, the sequence after difference is: -1, 1, 0.

[0113] Count the position, length and number of text columns in the text area: the starting position represented by the element value of 1 in the statistical result vector k is recorded as vector ind_st; the ending position represented by the element value of -1 in the statistical result vector k is recorded as vector ind_ed. The vector ind_st contains the starting positions, and the number of text columns in the document image seg_no = the number of elements in ind_st. Figure 1 The text in has 22 columns, the same as the column document extraction result.

[0114] (6) Based on the starting information of the text column given by the statistical results in (5), the text column in the document source image I is extracted. The result is as follows Figure 5 shown.

[0115] Experimental Example 1: Through experimental tests, the rapid estimation of stroke width in step (3) of the method of the present invention has been well applied in column extraction of ancient book documents.

[0116] The comparison method is connected domain analysis.

[0117] (1) For Figure 1 The document shown in the figure compares the time and results of the method of the present invention and the comparative method, as shown in Table 1:

[0118] Table 1

[0119] Time / Unit: Seconds Stroke width / unit: pixels Comparison method time 0.844149 7.0711 The method of the present invention takes time 0.002970 7

[0120] As can be seen from Table 1, the comparison method took 0.844149 seconds with a result of 7.0711, while the method of the present invention took 0.002970 seconds with a result of 7. It can be seen that in terms of the accuracy of stroke width estimation, the two methods are basically the same, but in terms of time consumption, the comparison method is about 284 times that of the present invention.

[0121] (2) For the Manchu document as shown in Figure 8 (c), which contains 11 fonts of a Manchu letter "modest", for the document as shown in Figure 8 (c), compare the time consumption and results of the method of the present invention and the comparison method, as shown in Table 2:

[0122] Table 2

[0123] Time / Unit: Seconds Stroke width / unit: pixels Comparison method time 0.688152 3.03820 The method of the present invention takes time 0.006016 4

[0124] Thus, it can be seen that the method of the present invention is not only applicable to Chinese characters, but also applicable to Manchu and the like. However, a slight modification is required. For Chinese, take the average value of the stroke width, and for Manchu, take the mode of the stroke width. If the mode does not exist, still take the average value of the stroke width. Because Manchu writing has a vertical axis, and the width of the vertical axis more accurately and stably reflects the stroke width. As can be seen from Table 2, using the comparison method, the obtained stroke width is 3.0382, and the time consumption is 0.688152 seconds; using the method of the present invention, the obtained stroke width is 4, and the time consumption is 0.006016 seconds. In terms of time consumption, the comparison method is about 114 times that of the present invention. This also reflects that in the estimation of Manchu width, the present invention can utilize the characteristics of Manchu and can more quickly and accurately extract the stroke width.

[0125] (3) For the horizontally arranged document as shown in Figure 6 , compare the time consumption and results of the method of the present invention and the comparison method, as shown in Table 3:

[0126] Table 3

[0127] Time / Unit: Seconds Stroke width / unit: pixels Comparison method time 0.359343 4.1231 The method of the present invention takes time 0.001836 4

[0128] The method of the present invention is also applicable to modern horizontally arranged documents. As can be seen from Table 3, using the comparison method, the obtained stroke width is 4.1231, and the time consumption is 0.359343 seconds; using the method of the present invention, the obtained stroke width is 4, and the time consumption is 0.001836 seconds. It can be seen that in terms of the accuracy of stroke width estimation, the two methods are basically the same, but in terms of time consumption, the comparison method is about 195 times that of the present invention.

[0129] Experimental Example 2: Through experimental tests, the method for extracting text columns from ancient book document images based on the improved vertical projection method of morphology of the present invention can quickly and accurately segment / extract text columns in regularly typeset ancient book document images, without complicated post-processing and additional parameter adjustment, with high speed and strong versatility. The present invention can also perform column extraction on documents with mixed fonts, such as Figure 7 As shown, where the red line indicates the starting position of the text column and the green line indicates the ending position of the text column.

[0130] The present invention can also perform column extraction on Manchu documents. To verify the experimental effect of the method of the present invention on different scripts, 11 different Manchu fonts are specifically selected for testing, such as Figure 8 as shown. Figure 8 (a) is a document composed of the Manchu word for "modest" in 11 different fonts. Figure 8 (b) is a Manchu document segmented by the original vertical projection method, and 14 columns are extracted. The red line indicates the starting position of the text column and the green line indicates the ending position of the text column. From Figure 8 (b), it can be seen that the text in the 3rd column from left to right is over-segmented into three columns; the 5th text column is also over-segmented. Figure 8 (c) is the text column extracted by the method of the present invention. Due to the use of morphological dilation operation, the free strokes are fused with the main body of the text, so there is no problem of over-segmentation.

[0131] The present invention also tests 100 Manchu documents with a mixture of various Manchu fonts. The 100 Manchu documents contain 1100 columns of Manchu text. The method of the present invention can quickly and accurately segment / extract the Manchu text columns in the Manchu document images with standard layout, without complicated post-processing and additional parameter adjustment. It only takes about 0.1 seconds to extract the text columns of a document (about 110 columns), and the correct rate is 99.82% (1098 / 1100), obtaining a good extraction effect, that is, both the extraction speed and the accuracy reach a satisfactory level.

[0132] Based on the above embodiments, the embodiments of the present application also provide a computer program. When the computer program runs on a computer, the computer is made to execute the method provided by the above embodiments.

[0133] Based on the above embodiments, the embodiments of the present application also provide a computer storage medium. The computer storage medium stores a computer program. When the computer program is executed by a computer, the computer is made to execute the method provided by the above embodiments.

[0134] Among them, the storage medium can be any available medium that can be accessed by a computer. Taking this as an example but not limited to: the computer-readable medium may include RAM, ROM, EEPROM, CD-ROM or other optical disc storage, magnetic disk storage medium or other magnetic storage devices, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer.

[0135] Based on the above embodiments, an embodiment of the present application further provides a chip, which is used to read a computer program stored in a memory to implement the method provided in the above embodiments.

[0136] Based on the above embodiments, an embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the method provided in the above embodiments is implemented.

[0137] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0138] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0139] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0140] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0141] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A method for extracting text columns from ancient book documents based on morphologically improved vertical projection method, wherein the ancient book document is a document arranged in columns, characterized in that: The extraction method comprises the following steps: Preprocess the ancient book document image to obtain a binary document image I bw , where the text is white and the background is black; According to the binary document image I bw , quickly estimate the stroke width of ancient documents; For the binary document image I bw Select a certain multiple of the stroke width to perform morphological expansion to obtain the expanded image I pz ; For the dilated image I pz Sum the matrix columns to get the vertical projection vector I cz , where the vertical projection vector I cz The peaks of the wave correspond to the text area, and the troughs correspond to the background area; The vertical projection vector I cz Set the non-zero values ​​in to 1 to obtain the first permutation vector T1; The first permutation vector is padded with zeros at the front and back to obtain a second permutation vector T2; Calculate the result vector k of the difference between adjacent elements in the second permutation vector T2, wherein the element value = 1 in the result vector k corresponds to the starting position of a text column, and the element value = -1 corresponds to the ending position of a text column, and the text column is segmented according to the starting position and the ending position of a column.

2. The ancient book document text column extraction method based on morphological improved vertical projection method according to claim 1 is characterized in that: in, The image I is obtained by preprocessing the ancient document image using the Otsu method. bw1 , for the binarized image I bw1 The inversion operation obtains the binary document image I bw .

3. The ancient book document text column extraction method based on morphological improved vertical projection method according to claim 1 is characterized in that: in, For the binary document image I bw Select 3 times the stroke width for morphological dilation to obtain the dilated image I pz。 4. The ancient book document text column extraction method based on morphological improved vertical projection method according to claim 3 is characterized in that: in, The morphological expansion adopts a dish-shaped structure.

5. The ancient book document text column extraction method based on morphological improved vertical projection method according to claim 1 is characterized in that: The starting position represented by the element value of 1 in the statistical result vector k is recorded as vector ind_st; the ending position represented by the element value of -1 in the statistical result vector k is recorded as vector ind_ed, and the number of elements in the vector ind_st represents the number of text columns in the document image; Obtain the position and length of the text area according to the starting position and the ending position; The number of text columns in the document image is obtained according to the number of elements in the vector ind_st, which is expressed as seg_no=the number of elements in ind_st.

6. The ancient book document text column extraction method based on morphological improved vertical projection method according to claim 1 is characterized in that: The ancient book documents include documents of ancient Chinese books typeset in columns and / or documents of ancient Manchu books typeset in columns.

7. A document text column extraction method based on morphological improved vertical projection method, characterized in that: The document is a horizontally arranged document; the document is rotated 90 degrees to form a vertically arranged document, and the extraction method of any one of claims 1 to 6 is implemented on the document rotated 90 degrees to form a vertically arranged document.

8. An electronic device, comprising: One or more processors, a memory, and one or more programs; wherein the one or more programs are stored in the memory, and the one or more programs include instructions, which, when executed by the electronic device, enable the electronic device to execute the method described in any one of claims 1-7.

9. A computer-readable storage medium, comprising a computer program, and when the computer program is executed on an electronic device, the electronic device is enabled to execute the method according to any one of claims 1 to 7.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.