Rapid estimation method for stroke width value of ancient book document

By statistically horizontal projection in ancient books, extracting and differentially processing vectors of specific rows, the problem of cumbersome and time-consuming extraction of stroke widths in ancient books in the prior art is solved, and fast and accurate stroke width estimation and document column extraction are achieved.

CN119810843APending Publication Date: 2025-04-11DALIAN NATIONALITIES UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411772261.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

The prior art has problems such as cumbersome, time-consuming, versatility and poor robustness in fast and accurate extraction of character stroke widths in ancient documents.

Method used

By statistical column-typed document horizontal projection, obtain the row sequence number containing the most stroke width samples, extract the vector of the corresponding row, perform differential processing to determine the starting point and end point of the stroke, calculate the stroke width value, and use the average value or mode as the stroke width value of the document.

Benefits of technology

It realizes fast and accurate estimation of character stroke widths in ancient documents, improves the response speed of stroke width estimation, and improves the accuracy of document column extraction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119810843A_ABST
    Figure CN119810843A_ABST
Patent Text Reader

Abstract

A rapid estimation method for stroke width values of an ancient book document belongs to the field of document image processing, aims to solve the problem of rapidly estimating the stroke widths of characters in the ancient book document, and is technically characterized by comprising the following steps of: counting horizontal projections of a column typesetting document; wherein the column typesetting document is a binary document image; according to the horizontal projection, obtaining a line sequence number containing the most stroke width samples; extracting a first row vector of a row containing the most stroke width samples in the binary document image; supplementing 0 before and after the first row vector to obtain a second row vector; according to the difference vector of the second row vector, determining a starting point position and an ending point position of each stroke in the second row vector, and obtaining a width value of each stroke according to the starting point position and the ending point position; and calculating the width value of the strokes of the document according to the width value of each stroke of the second row vector.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of document image processing and relates to a method for quickly estimating the stroke width value of a document. Background Art

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

[0003] 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 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, printed characters with the same font size, or may be inconsistent, for example, in the cases of different characters, different fonts, different font sizes, and handwritten characters. Therefore, most of the existing methods for extracting character stroke widths require extracting, counting, and analyzing the stroke connectivity domains of the entire document. The method of obtaining the stroke width in this way is cumbersome, time-consuming, and has poor generality and robustness. Summary of the Invention

[0004] In order to solve the problem of quickly estimating the character stroke width in an ancient document, in a first aspect, according to some embodiments of the present application, a method for quickly estimating the stroke width value of an ancient document, the ancient document is a document typeset in columns, and the estimation method includes the following steps:

[0005] Statistically project the horizontal direction of the column typeset document; wherein, the column typeset document is a binary document image, and in the binary document image, a pixel value of 0 represents black in the binary document image, and a pixel value of 1 represents white in the binary document image;

[0006] Obtain the row number containing the most stroke width samples according to the horizontal projection;

[0007] Extract the first row vector of the row containing the most stroke width samples in the binary document image;

[0008] Pad the first row vector with 0s before and after to obtain a second row vector;

[0009] Determine the starting position and ending position of each stroke in the second row vector according to the difference vector of the second row vector, and obtain each stroke width value according to the starting position and ending position;

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

[0011] According to the method for quickly estimating the stroke width value of an ancient book document in some embodiments of the present application, 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.

[0012] According to the method for quickly estimating the stroke width value of an ancient book document in some embodiments of the present application, the row number containing the most stroke width samples is obtained according to the horizontal projection, including:

[0013] 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;

[0014] 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.

[0015] According to the method for quickly estimating the stroke width value of an ancient book document in some embodiments of the present application, 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.

[0016] According to the method for quickly estimating the stroke width value of an ancient book document in some embodiments of the present application, the first row vector of the row containing the most stroke width samples in the binary document image is extracted, including

[0017] 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;

[0018] According to the method for quickly estimating the stroke width of an ancient book document in some embodiments of the present application, the first row vector is padded with zeros at the front and back to obtain a second row vector, including

[0019] 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];

[0020] According to the method for quickly estimating the stroke width value of an ancient book document in some embodiments of the present application, the starting position and the end position 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:

[0021] k = diff(T);

[0022] 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.

[0023] According to a method for quickly estimating stroke width values ​​of an ancient book document in some embodiments of the present application, the ancient book document is a Chinese character document arranged in columns. Based on the stroke width values ​​of the second row vector, an 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.

[0024] According to a method for quickly estimating stroke width values ​​of ancient book documents in some embodiments of the present application, the ancient book document is a Manchu document arranged in columns, and the frequency of occurrence of the stroke width values ​​is counted based on the stroke width values ​​of the second row vector, 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.

[0025] According to a method for quickly estimating stroke width values ​​of an ancient book document in some embodiments of the present application, 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.

[0026] In a second aspect, the method according to any one of some embodiments of the present application is applied in document text column extraction.

[0027] Beneficial effects:

[0028] (1) The present invention considers from the perspective of rows, and a row of characters may contain characters from all (or most) columns of the entire document. First, from a statistical perspective, it is found that the row containing the most characters in a document must contain the most character information from all columns, which is more typical and can represent the stroke width values ​​of 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 documents and Manchu documents. Thirdly, the present invention is aimed at Manchu, which is written vertically and belongs to a vertical font. There is little 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 stroke width represented by the vertical axis is accurate and stable. Therefore, in the present invention, in the estimation of Manchu stroke width, for the calculation of Manchu stroke width, the frequency of occurrence of stroke width values ​​is counted, wherein the stroke width value with the highest frequency of occurrence is the mode of stroke width values, and the mode is used as the stroke width value of the document. 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.

[0029] (2) The above method of the present invention can quickly and accurately extract stroke width by performing only 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.

[0030] 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

[0031] 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.

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

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

[0034] Figure 4 is Figure 2 the image after morphological dilation processing Ipz .

[0035] Figure 5 is the effect diagram of text column extraction of the method of the present invention for Figure 1 .

[0036] Figure 6 is a horizontally arranged Chinese character document

[0037] Figure 7 is a schematic diagram before and after column extraction of a multi-font document; among them, (a) is a schematic diagram of a multi-font document, and (b) is the column extraction result of a multi-font document

[0038] Figure 8 is a schematic diagram before and after column extraction of a multi-font document of different methods; among them, (a) is a multi-font Manchu document composed of 11 fonts of the full Manchu character "modesty", (b) is the text column extraction result of the original vertical projection method, and (c) is the text column extraction result of the method of the present invention Specific embodiments

[0039] 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 accompanying 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

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

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

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

[0043] 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 ;

[0044] For the dilated image I pz Perform matrix column summation 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

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

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

[0047] 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.

[0048] 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 .

[0049] 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。

[0050] 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.

[0051] 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;

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

[0053] 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.

[0054] 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.

[0055] In the method for extracting text columns of ancient Chinese documents based on the improved vertical projection method by morphology in this embodiment, the documents are horizontally arranged; the method includes rotating the horizontally arranged documents by 90 degrees to represent the documents arranged vertically, and implementing any of the extraction methods on the documents represented by rotating 90 degrees to be arranged vertically.

[0056] In the 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 multiples of the stroke width values to connect the discontinuous strokes, free strokes, etc. generated after binarization into a whole. In this way, on the vertical projection image, the number of redundant discrete valleys / peaks will be greatly reduced, and even there will be no redundant discrete valleys / peaks, and the regularly arranged columns can be segmented.

[0057] In the second aspect, the method of the present invention is applicable to vertically arranged Chinese ancient document and Manchu documents. Among them, for Manchu, due to its vertical writing and belonging to vertical fonts, there are 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.

[0058] In the third aspect, the present invention realizes automatic extraction (segmentation, splitting) of text columns 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 Chinese documents.

[0059] The text of ancient Chinese documents is generally typeset in columns. For example, Manchu ancient Chinese 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 lower part of "之" in Chinese characters. Therefore, the width estimation of Manchu font strokes naturally has font characteristics that can be utilized.

[0060] 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, and character stroke width is an indispensable step in extracting text columns. Only when the character stroke width is extracted quickly and accurately can the column extraction be fast and accurate. The stroke widths of characters in an ancient document may be relatively consistent, for example, printed text with the same font size, or they may be inconsistent, for example, in different texts, different fonts, different font sizes, and handwriting. Therefore, most of the existing methods for extracting character stroke widths require the extraction, statistics, and analysis of the stroke connectivity domain of the entire document. This method of obtaining stroke widths is cumbersome, time-consuming, and has poor versatility and robustness.

[0061] Among them, as a separate method or a method for quickly estimating the stroke width of an ancient book document in the above extraction method, the method includes

[0062] 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;

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

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

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

[0066] Determine the starting position and the ending position 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 position and the ending position;

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

[0068] 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, wherein M represents the number of rows of the matrix, and N represents the number of columns of the matrix.

[0069] 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:

[0070] 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;

[0071] 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.

[0072] 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.

[0073] 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

[0074] 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;

[0075] 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

[0076] 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];

[0077] 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:

[0078] k = diff(T);

[0079] 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.

[0080] 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.

[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. 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.

[0082] 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.

[0083] 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.

[0084] 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.

[0085] 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.

[0086] 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.

[0087] Problems and shortcomings of existing technical solutions:

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

[0089] (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.

[0090] (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.

[0091] In order to solve the above problems, the present invention provides a method for extracting text columns from ancient book documents based on a morphologically improved vertical projection method, comprising the following steps:

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

[0093] (2) Image preprocessing;

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

[0095] (4) morphological expansion;

[0096] (5) Vertical projection method;

[0097] (6) Text column segmentation.

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

[0099] (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.

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

[0101] (2-1) Image binarization;

[0102] (2-2) Image inversion.

[0103] 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.

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

[0105] (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.

[0106] (3-2) Statistical horizontal projection, that is, Figure 2 The binary document image I 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.

[0107] (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.

[0108] (3-4) Calculation of stroke width: Extract the row vector of matrix I, denoted as T0, then T0 is a 1×N row vector. Add a 0 before and after T0, and the resulting new row vector is denoted as T, i.e. T=[0,T0,0]. Count the length of the white stroke in this row, that is, the stroke width, by taking a difference on T, and denoting the differenced vector as k, i.e. k=diff(T). In the difference vector, the position with a value of 1 corresponds to the starting point of the stroke, and the position with a value of -1 corresponds to the end point of the stroke. For example, suppose a subsegment of T is t=[001111100], where 5 1s are connected, indicating a stroke width of 5. The difference result is k=diff(t)=[010000-10]. Then the starting point of the stroke is k(2)=1, and the end point of the stroke corresponds to k(7)=-1. The stroke width len=stroke end point position – stroke starting point position=7-2=5.

[0109] (3-5) Stroke width estimation: Count all stroke width values ​​contained in row. For ancient Chinese documents, take the average of the stroke width values ​​and round it off to an integer, and output it as the final value of the stroke width sw. For ancient Manchu documents, find the stroke width value with the highest frequency, that is, the mode of the stroke width value, and output it as the final value of the stroke width sw; if the mode does not exist, take the average of the stroke widths and round it off to an integer, and output it as the final value of the stroke width sw.

[0110] 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 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 aimed at Manchu, which is written vertically and belongs to a vertical font. There is little 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 stroke width represented by the vertical axis is accurate and stable. Therefore, in the present invention, in the Manchu stroke width estimation, for the calculation of the 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.

[0111] 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.

[0112] (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.

[0113] (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.

[0114] 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.

[0115] 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.

[0116] 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.

[0117] 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.

[0118] (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.

[0119] 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.

[0120] The comparison method is connected domain analysis.

[0121] (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:

[0122] Table 1

[0123] 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

[0124] 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.

[0125] (2) For the Manchu document shown in Figure 8 (c), which contains 11 fonts of a Manchu letter "modest", for the document 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:

[0126] Table 2

[0127] 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

[0128] 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, it needs to be slightly modified. 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 the writing of Manchu 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.

[0129] (3) For the horizontally arranged document 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:

[0130] Table 3

[0131] 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

[0132] 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.

[0133] 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, and has a fast 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 represents the starting position of the text column and the green line represents the ending position of the text column.

[0134] The present invention can also perform column extraction on Manchu documents. To verify the experimental effects 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 "modesty" 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 represents the starting position of the text column and the green line represents the ending position of the text column. From Figure 8 (b), it can be seen that the characters in the 3rd column from left to right are 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 characters, so the problem of over-segmentation does not occur.

[0135] The present invention also tests 100 Manchu documents with a mixture of various Manchu fonts. The 100 Manchu documents contain 1100 columns of Manchu characters. The method of the present invention can quickly and accurately segment / extract the Manchu text columns in the Manchu document images with regular layout, without complicated post-processing and additional parameter adjustment. It only takes about 0.1 second 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 rate reach a satisfactory level.

[0136] 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.

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

[0138] 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.

[0139] 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.

[0140] 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.

[0141] 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.

[0142] 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.

[0143] 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 comprising 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.

[0144] 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.

[0145] 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 quickly estimating the stroke width of an ancient book document, wherein the ancient book document is a document arranged in columns, characterized in that: The estimation method comprises the following steps: 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; Acquire the row number containing the most stroke width samples according to the horizontal projection; Extracting the first row vector of the row containing the most stroke width samples in the binary document image; Add 0s to the front and back of the first row vector to obtain the second row vector; Determine the starting position and the ending position 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 position and the ending position; The document stroke width value is calculated according to the stroke width values ​​of the second row vector.

2. The method for quickly estimating the stroke width of an ancient book document according to claim 1, characterized in that: 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.

3. The method for quickly estimating the stroke width of an ancient book document according to claim 2, characterized in that: The obtaining, according to the horizontal projection, the row number containing the most stroke width samples comprises: 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; 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.

4. The method for quickly estimating the stroke width of an ancient book document according to claim 3 is characterized in that: 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. The row in the binary document image corresponding to the row number row is the row number containing the most stroke width samples.

5. The method for quickly estimating the stroke width of an ancient book document according to claim 3 or 4, characterized in that: Extract the first row vector of the row containing the most stroke width samples in the binary document image, including The row-th row vector of the matrix I of the binary document image is extracted and recorded as vector T0. Vector T0 is a 1×N row vector and is represented as the first row vector.

6. The method for quickly estimating the stroke width of an ancient book document according to claim 5, characterized in that: The first row vector is padded with 0s to obtain the second row vector, including 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].

7. The method for quickly estimating the stroke width of an ancient book document according to claim 6, characterized in that: According to the differential vector of the second row vector, the starting position and the ending position of each stroke in the second row vector are determined, including differentiating the second row vector T, and the differential vector k is expressed as: k = diff(T); 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.

8. The method for quickly estimating the stroke width of an ancient book document according to any one of claims 1 to 7, characterized in that: The ancient book document is a Chinese character document arranged in columns. According to the stroke width values ​​of the second row vector, an 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.

9. The method for quickly estimating the stroke width of an ancient book document according to any one of claims 1 to 7, characterized in that: The ancient book document is a Manchu document arranged in columns, and according to the stroke width values ​​of the second row vector, the occurrence frequency of the stroke width values ​​is counted, wherein the stroke width value with the highest occurrence frequency is the mode of the stroke width values, and the mode is used as the stroke width value of the document; Preferably, 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, 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.

10. Application of the method according to any one of claims 1 to 9 in document text column extraction.