Paging method of multi-page text in document image, electronic equipment, storage medium and program product
By identifying and segmenting page numbers in document images, the paging line is automatically determined, which solves the problem of automatic paging of multi-page texts in the prior art, and realizes efficient and accurate document paging and recognition.
Patent Information
- Application Number
- CN202411623072.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-02-07
AI Technical Summary
The existing OCR technology cannot automatically paginate the document images of multi-page text, resulting in confusion in recognition results. Users need to manually divide and organize, which increases the workload.
By obtaining the OCR recognition results of the document image, determining the text block and location, identifying characters with page number characteristics, determining the paging line, and paging multi-page text according to the paging line.
It realizes automated, efficient and accurate paging of multi-page OCR text recognition, reduces manual intervention, and improves the automation level and efficiency of document processing.
Smart Images

Figure CN119399787A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a paging method for multiple pages of text in a document image, an electronic device, a storage medium and a program product. Background Art
[0002] In modern society, the digitization and electronicization of documents has become a trend, especially in the fields of education, scientific research, law and corporate management. A large number of paper documents need to be scanned and converted into editable and archived electronic texts. In this process, optical character recognition (OCR) technology plays a vital role. OCR technology can convert the text content in scanned or photographed document images into editable text, greatly improving work efficiency. However, when processing document images containing multiple pages of text, the current OCR technology can recognize the text in the document image and return its location information, but the recognition results are often chaotic and cannot be directly paginated. This requires users to manually segment and organize the text, which increases a lot of workload. Summary of the invention
[0003] The present invention provides a paging method for multiple pages of text in a document image, an electronic device, a storage medium and a program product, which are used to solve the defect that automatic paging cannot be performed during OCR recognition in the prior art, and realize automatic paging during OCR recognition.
[0004] The present invention provides a paging method for multiple pages of text in a document image, comprising the following steps: obtaining an OCR recognition result of a document image; wherein the document image comprises at least two pages; determining a text block and a text block position in the document image according to the OCR recognition result; in response to determining that characters in the text block have page number character features, page number context features and page number position features, determining that the characters in the text block are suspected page numbers; wherein the page number position features include the page number being at a corner of a page or the page number being in the middle of a page; determining a paging line according to the position of the suspected page number and the page number position features; paging the multiple pages of text according to the paging line, and dividing the characters in the text block into corresponding pages according to the position of the text block.
[0005] According to a method for paging multiple pages of text in a document image provided by the present invention, before determining that the characters in the text block are suspected page numbers in response to determining that the characters in the text block have page number character features, page number context features and page number position features, the method also includes: performing pattern matching on the characters in the text block through a pre-constructed regular expression to determine whether the characters in the text block have the page number character features.
[0006] According to a method for paging multiple pages of text in a document image provided by the present invention, before determining that the characters in the text block are suspected page numbers in response to determining that the characters in the text block have page number character features, page number context features and page number position features, the method also includes: in response to the spacing between the text block and other text blocks exceeding a preset spacing threshold, and the text block is not in the same line as the other text blocks, determining that the characters in the text block have the page number context features.
[0007] According to a method for paging multiple pages of text in a document image provided by the present invention, before determining that the characters in the text block are suspected page numbers in response to determining that the characters in the text block have page number character features, page number context features and page number position features, the method also includes: determining whether the characters in the text block have the page number position features by comparing the distance between the characters in the text block and the page edge of the document image with the distance between a preset page number position and the page edge.
[0008] According to a paging method for multiple pages of text in a document image provided by the present invention, when the page number position feature is that the page number is in the middle of the page, determining the paging line based on the position of the suspected page number and the page number position feature includes: connecting the center points of each of the suspected page numbers in pairs to obtain a first set of lines between the suspected page numbers; removing the suspected lines between the page numbers that intersect within the range of the document image and removing the suspected lines between the page numbers whose angle with the image direction of the document image is less than a preset angle threshold based on the first set to obtain a second set of lines between the suspected page numbers; determining the midpoints of two suspected page numbers corresponding to the suspected lines between the page numbers in the second set, drawing a straight line perpendicular to the suspected lines between the page numbers based on the midpoints to obtain a set of vertical lines, and using the straight lines on which the suspected lines between the page numbers in the second set and the set of vertical lines as the paging lines.
[0009] According to a paging method for multiple pages of text in a document image provided by the present invention, when the page number position feature is that the page number is at the corner of the page, the paging line is determined according to the position of the suspected page number and the page number position feature, including: connecting the center points of each of the suspected page numbers in pairs to obtain a first set of lines between the suspected page numbers; based on the first set, removing the suspected lines between the page numbers that intersect within the range of the text image to obtain a third set of the suspected lines between the page numbers; and using the straight line where the suspected lines between the page numbers in the third set are located as the paging line.
[0010] According to a paging method for multiple pages of text in a document image provided by the present invention, determining the text blocks and text block positions in the document image based on the OCR recognition results includes: obtaining a text box in the OCR recognition results; after corroding and dilating the text box, determining the text blocks and text block positions in the document image through connected domain analysis.
[0011] According to a method for paging multiple pages of text in a document image provided by the present invention, before obtaining the OCR recognition result of the document image, the method further includes: performing grayscale processing, binarization processing and noise removal processing on the document image.
[0012] The present invention also provides a paging device for multiple pages of text in a document image, comprising the following modules: an acquisition module, used to: acquire an OCR recognition result of the document image; wherein the document image includes at least two pages; a first determination module, used to: determine a text block and a text block position in the document image according to the OCR recognition result; a second determination module, used to: determine that the characters in the text block are suspected page numbers in response to determining that the characters in the text block have page number character features, page number context features and page number position features; a third determination module, used to: determine a paging line according to the position of the suspected page number and the page number position features; a paging processing module, used to: paging the multiple pages of text according to the paging line, and dividing the characters in the text block into corresponding pages according to the position of the text block.
[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for paging multiple pages of text in a document image as described above is implemented.
[0014] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method for paging multiple pages of text in a document image as described in any one of the above is implemented.
[0015] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method for paging multiple pages of text in a document image as described above is implemented.
[0016] The present invention provides a paging method, electronic device, storage medium and program product for multiple pages of text in a document image, wherein the OCR recognition result of the document image is obtained; wherein the document image includes at least two pages, a text block and a text block position in the document image are determined according to the OCR recognition result, in response to determining that the characters in the text block have page number character features, page number context features and page number position features, the characters in the text block are determined to be suspected page numbers, the page number position features include the page number being at the corner of the page or the page number being in the middle of the page, a paging line is determined according to the position of the suspected page number and the page number position features, multiple pages of text are paginated according to the paging line, and the characters in the text block are divided into corresponding pages according to the positions of the text blocks, thereby realizing automatic, efficient and accurate paging of multiple pages of OCR text recognition, and the paging recognition does not depend on the page number sequence, has high flexibility, significantly improves the accuracy and efficiency of multi-text OCR recognition, reduces manual intervention in OCR recognition, reduces labor costs, and greatly improves the automation level and efficiency of document processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 It is a flow chart of the paging method for multiple pages of text in a document image provided by the present invention.
[0019] Figure 2 This is one of the paging processing schematic diagrams in the paging method for multiple pages of text in a document image provided by the present invention.
[0020] Figure 3 This is the second schematic diagram of paging processing in the paging method for multiple pages of text in a document image provided by the present invention.
[0021] Figure 4 This is the third schematic diagram of paging processing in the paging method for multiple pages of text in a document image provided by the present invention.
[0022] Figure 5 This is the fourth schematic diagram of paging processing in the paging method for multiple pages of text in a document image provided by the present invention.
[0023] Figure 6 This is the fifth schematic diagram of paging processing in the paging method for multiple pages of text in a document image provided by the present invention.
[0024] Figure 7 It is a structural schematic diagram of a paging device for multiple pages of text in a document image provided by the present invention.
[0025] Figure 8 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0027] Figure 1 FIG. 1 is a flow chart of a method for paging multiple pages of text in a document image provided by the present invention. Figure 1 As shown, the method includes: Step S1, obtaining an OCR recognition result of a document image; wherein the document image includes two pages or more of text.
[0028] By performing OCR recognition on a document image containing at least two pages of a document, an OCR recognition result of the document image can be obtained. The position of a text box and the character content in the text box can be output through OCR recognition.
[0029] Step S2: determining the text block and the position of the text block in the document image according to the OCR recognition result.
[0030] When determining the text block and the text block position in the document image according to the OCR recognition result, the OCR recognition result may not be further processed, but the text box recognized by OCR is directly used as the text block and the text box position is used as the text block position.
[0031] However, since the text boxes recognized by OCR are usually located in a row, and a row may contain multiple text boxes, if the text boxes are directly used as text blocks, the workload is large when the text blocks are processed later. Therefore, the text blocks to be processed and the positions of the text blocks can be obtained by further processing based on the text boxes recognized by OCR. One method can be to combine adjacent text boxes into a text block based on the relationship between the spacing between the text boxes and the preset spacing threshold. The position of the text block can be represented by the circumscribed rectangle of the text block.
[0032] Step S3, in response to determining that the characters in the text block have page number character features, page number context features and page number position features, determine that the characters in the text block are suspected page numbers; wherein the page number position features include the page number being at a corner of the page or the page number being in the middle of the page.
[0033] Different from other contents in the document image, the page number has its own characteristics, which can be reflected in the page number character features, page number context features and page number position features. Among them, the page number has a specific representation method. The page number character features refer to the features of the characters representing the page number. The page number context features refer to the relationship features between the page number and the surrounding characters.
[0034] In addition, the position of the page number is also quite special, such as usually located at the bottom left of the page, the bottom right of the page, the bottom middle of the page, the top left of the page, the top right of the page, and the top middle of the page. Setting the page number position features includes page numbers in the corners of the page or page numbers in the middle of the page. Among them, the page number is located at the bottom left of the page, the bottom right of the page, the top left of the page, and the top right of the page are all page numbers in the corners of the page. The page number is located in the middle of the bottom of the page and the middle of the top of the page. It belongs to the page number in the middle of the page.
[0035] If it is determined that the characters in the text block have page number character features, page number context features, and page number position features, then the characters in the text block are determined to be suspected page numbers.
[0036] Step S4: determining a page break line according to the position of the suspected page number and the position feature of the page number.
[0037] In a document image containing multiple pages, the page numbers may be located in the middle of the bottom of the page, or on the left and right sides of the bottom of the page, or in the middle of the top of the page, or on the left and right sides of the top of the page. Page numbers located on the left and right sides of the bottom of the page and page numbers located on the left and right sides of the top of the page are both located at the corners of the page. Therefore, it is believed that in a document image containing multiple pages, each page document has the same page number position characteristics.
[0038] For extremely rare cases, such as when the page numbers of the preface and the main text of a book have different page number position characteristics, they can be processed separately when constructing the document image by scanning or photographing, ensuring that each page of the multi-page document in the document image has the same page number position characteristics.
[0039] Since the page number is usually located at the edge of the page, the page number position feature indicates whether the page number is located at the corner or the middle of the page. The paging line can be determined based on the determined positions of each suspected page number and the page number position feature.
[0040] The present invention is highly flexible in determining page number paging, and can select an appropriate partitioning scheme according to the different positions of the page numbers in the page. Accurate paging can be achieved regardless of whether the page numbers are located at the top or bottom, the left or right side of the page. For multiple page numbers, it does not depend on the order of the page numbers, but is flexibly partitioned according to the page number positions to ensure the accuracy of the partitions. This feature makes the present invention highly adaptable when processing documents of different types and formats, and can flexibly respond to various typesetting methods to achieve accurate paging.
[0041] Step S5, paging the multiple pages of text according to the paging lines, and dividing the characters in the text blocks into corresponding pages according to the positions of the text blocks.
[0042] After the paging line is determined, the multiple pages of text are paginated according to the paging line, and the characters in the text block are divided into corresponding pages according to the position of the text block. When the characters in the text block are divided into corresponding pages according to the position of the text block, the center point of the text block can be obtained, and the characters in the text block are divided into corresponding pages according to the area range of the page in which the center point of the text block is located.
[0043] The present invention provides a paging method for multiple pages of text in a document image, by obtaining an OCR recognition result of the document image; wherein the document image includes at least two pages, determining a text block and a text block position in the document image according to the OCR recognition result, in response to determining that the characters in the text block have page number character features, page number context features and page number position features, determining that the characters in the text block are suspected page numbers, the page number position features include the page number being at a corner of a page or the page number being in the middle of a page, determining a paging line according to the position of the suspected page number and the page number position features, paging multiple pages of text according to the paging line, and dividing the characters in the text block into corresponding pages according to the positions of the text blocks, thereby realizing automatic, efficient and accurate paging of multiple pages of OCR text recognition, and the paging recognition does not depend on the page number sequence, has high flexibility, significantly improves the accuracy and efficiency of multi-text OCR recognition, reduces manual intervention in OCR recognition, reduces labor costs, and greatly improves the automation level and efficiency of document processing.
[0044] According to a method for paging multiple pages of text in a document image provided by the present invention, before determining that the characters in the text block are suspected page numbers in response to determining that the characters in the text block have page number character features, page number context features and page number position features, the method also includes: performing pattern matching on the characters in the text block through a pre-constructed regular expression to determine whether the characters in the text block have the page number character features.
[0045] Page numbers are usually represented by Arabic numerals, Chinese numerals, Roman numerals, etc., and the representation forms are such as "1", "Page 1", "Ⅰ", "Page Ⅰ", "one", "First Page", "壹", "Page 壹", etc. It is possible to determine whether the characters in a text block conform to the page number character characteristics according to whether the characters in the text block conform to the common page number format.
[0046] A regular expression can be constructed according to the common page number format, and the characters in the text block are pattern-matched through the pre-constructed regular expression to determine whether the text block has the page number character characteristics. Among them, if it matches, it means that the text block has the page number character characteristics; if it does not match, it means that the text block does not have the page number character characteristics.
[0047] The paging method for multi-page text in the document image provided by the present invention determines whether the characters in the text block have the page number character characteristics by pattern-matching the characters in the text block through the pre-constructed regular expression, and improves the accuracy of the judgment result of whether the characters in the text block have the page number character characteristics.
[0048] According to a paging method for multi-page text in a document image provided by the present invention, before determining that the characters in the text block are suspected page numbers in response to determining that the characters in the text block have page number character characteristics, page number context characteristics, and page number position characteristics, the method further includes: in response to the distance between the text block and other text blocks exceeding a preset distance threshold, and the text block and other text blocks being in different rows, determining that the characters in the text block have the page number context characteristics.
[0049] The line spacing between a page number and other text is usually large and will not be in the same row as other text. This characteristic is called the page number context characteristic. If the distance between a text block and other text blocks exceeds a preset distance threshold, and the text block and other text blocks are in different rows, it is determined that the characters in the text block have the page number context characteristics.
[0050] The paging method for multi-page text in the document image provided by the present invention determines that the characters in the text block have the page number context characteristics in response to the distance between the text block and other text blocks exceeding a preset distance threshold, and the text block and other text blocks being in different rows, and improves the accuracy of the judgment result of whether the characters in the text block have the page number context characteristics.
[0051] According to a method for paging multiple pages of text in a document image provided by the present invention, before determining that the characters in the text block are suspected page numbers in response to determining that the characters in the text block have page number character features, page number context features and page number position features, the method also includes: determining whether the characters in the text block have the page number position features by comparing the distance between the characters in the text block and the page edge of the document image with the distance between a preset page number position and the page edge.
[0052] Since page numbers are usually located at the left bottom of the page, the right bottom of the page, the middle bottom of the page, the left top of the page, the right top of the page, and the middle top of the page, in a document image, it is known how many page numbers are included in a row at most. According to the common positions of page numbers on the page and the number of pages in a row, multiple preset page number positions can be determined, and the distances between the preset page number positions and the page edges of the document image can be calculated.
[0053] Calculate the distance between the characters in the text block and the page edge of the document image, where the distance between the characters in the text block and the page edge of the document image can be taken as the distance between the center point of the circumscribed rectangle of the characters in the text block and the page edge of the document image. Compare the distance between the characters in the text block and the page edge of the document image with the distance between the preset page number position and the page edge. If the distance between the characters in the text block and the page edge of the document image is close to one of the values of the distance between the preset page number position and the page edge (for example, the difference is less than a preset threshold), it is determined that the characters in the text block have page number position features.
[0054] The Sobel operator or the Canny edge detection algorithm may be used to detect edge information of the document image.
[0055] The paging method for multiple pages of text in a document image provided by the present invention determines whether the characters in the text block have page number position features by comparing the distance between the characters in the text block and the page edge of the document image with the distance between a preset page number position and the page edge, thereby improving the accuracy of the judgment result of whether the characters in the text block have page number position features.
[0056] According to a paging method for multiple pages of text in a document image provided by the present invention, when the page number position feature is that the page number is in the middle of the page, determining the paging line based on the position of the suspected page number and the page number position feature includes: connecting the center points of each of the suspected page numbers in pairs to obtain a first set of lines between the suspected page numbers; removing the suspected lines between the page numbers that intersect within the range of the document image and removing the suspected lines between the page numbers whose angle with the image direction of the document image is less than a preset angle threshold based on the first set to obtain a second set of lines between the suspected page numbers; determining the midpoints of two suspected page numbers corresponding to the suspected lines between the page numbers in the second set, drawing a straight line perpendicular to the suspected lines between the page numbers based on the midpoints to obtain a set of vertical lines, and using the straight lines on which the suspected lines between the page numbers in the second set and the set of vertical lines as the paging lines.
[0057] If the page number position feature is that the page number is in the middle of the page, when determining the paging line according to the suspected page number position and the page number position feature, the center points of each suspected page number are connected in pairs to obtain a first set of lines between suspected page numbers, wherein the center point of each suspected page number can be taken as the center point of the circumscribed rectangle of each suspected page number.
[0058] If the page number position feature is that the page number is in the middle of the page, based on the first set, two types of suspected page number lines are removed. One type is the suspected page number lines that cross within the range of the document image, and the other type is the suspected page number lines whose angle with the image direction of the document image is less than a preset angle threshold. The image direction of the document image can be determined based on the direction of the text in the document. After removing the two types of suspected page number lines, the second set is obtained.
[0059] Determine the midpoints of the two suspected page numbers corresponding to the line between the suspected page numbers in the second set, draw a straight line perpendicular to the line between the suspected page numbers based on the midpoint, obtain a set of vertical lines, and use the line between the suspected page numbers and the set of vertical lines in the second set as the paging line. The midpoint of the two suspected page numbers can be taken as the midpoint of the center points of the circumscribed rectangles of the two suspected page numbers. If the distance between multiple vertical lines is less than the preset spacing threshold, only one of them is retained.
[0060] It is understandable that if there are only two pages in a row, a set of perpendicular lines can be obtained by connecting two midpoints. In this case, the set of perpendicular lines only has this one perpendicular line.
[0061] The following example further illustrates the paging scheme when the page number is in the middle of the page.
[0062] Figure 2 This is one of the paging processing schematic diagrams in the paging method for multiple pages of text in a document image provided by the present invention. Figure 2As shown, A, B, C, and D are the outer rectangular frames of suspected page numbers. Figure 2 The result of the suspected page number connection line is shown, including line segments AB, CD, AC, BD, AD and BC, which constitute the first set. Among them, AD and BC intersect within the range of the document image and need to be removed. AC and BD need to be removed when the angle between the image direction of the document image is less than the preset angle threshold, and the second set is obtained after removal.
[0063] Figure 3 This is the second schematic diagram of paging processing in the paging method of multiple pages of text in a document image provided by the present invention. Figure 3 As shown, it is shown Figure 2 The result of removing segments AC, BD, AD and BC. Segments AB and CD form the second set.
[0064] Figure 4 This is the third schematic diagram of paging processing in the paging method for multiple pages of text in a document image provided by the present invention. Determine the midpoint E of rectangular frame A and rectangular frame B, and determine the midpoint F of rectangular frame C and rectangular frame D. A perpendicular line can be drawn from point E to AB, and a perpendicular line can be drawn from point F to CD. Since the two perpendicular lines actually overlap, just take one of them. The perpendicular line set includes one of the perpendicular lines EF. Since there are only two pages in a row in the document image, a perpendicular line can also be obtained directly by connecting the midpoint E and the midpoint F. Figure 4 As shown, the final paging lines include straight line AB, straight line CD and straight line EF.
[0065] It should be noted that the preset spacing thresholds in various embodiments of the present invention can be set separately according to different usage scenarios, and are not required to be the same.
[0066] The present invention provides a paging method for multiple pages of text in a document image. The method obtains a first set of lines between suspected page numbers by connecting the center points of each suspected page number in pairs. Based on the first set, the suspected lines between page numbers that cross within the range of the document image are removed, and the suspected lines between page numbers whose angle with the image direction of the document image is less than a preset angle threshold are removed to obtain a second set of suspected lines between page numbers. The midpoints of two suspected page numbers corresponding to the suspected lines between page numbers in the second set are determined. Based on the midpoints, a straight line perpendicular to the suspected lines between page numbers is drawn to obtain a set of vertical lines. The straight lines and the set of vertical lines on which the suspected lines between page numbers in the second set are located are used as paging lines, thereby achieving accurate determination of the paging lines when the page numbers are in the middle of the page.
[0067] According to a paging method for multiple pages of text in a document image provided by the present invention, when the page number position feature is that the page number is at the corner of the page, the paging line is determined according to the position of the suspected page number and the page number position feature, including: connecting the center points of each of the suspected page numbers in pairs to obtain a first set of lines between the suspected page numbers; based on the first set, removing the suspected lines between the page numbers that intersect within the range of the text image to obtain a third set of the suspected lines between the page numbers; and using the straight line where the suspected lines between the page numbers in the third set are located as the paging line.
[0068] If the page number position feature is that the page number is at the corner of the page, when determining the paging line according to the suspected page number position and the page number position feature, the center points of the suspected page numbers are connected in pairs to obtain a first set of suspected page number lines. If the page number position feature is that the page number is at the corner of the page, based on the first set, the suspected page number lines that cross within the range of the document image are removed, and a third set of suspected page number lines is obtained after removal. The straight lines where the suspected page number lines in the third set are located are used as paging lines.
[0069] The following example further illustrates the paging scheme when the page numbers are at the corners of the page.
[0070] Figure 5 FIG. 4 is a fourth schematic diagram of paging processing in the paging method for multiple pages of text in a document image provided by the present invention. Figure 5 As shown, A, B, C, and D are the outer rectangular frames of suspected page numbers. Figure 2 The result of the suspected page number connection line is shown, including line segments AB, CD, AC, BD, AD and BC, which constitute the first set. Among them, AD and BC intersect within the scope of the document image and need to be removed, and the second set is obtained after removal.
[0071] Figure 6 FIG. 5 is a fifth schematic diagram of paging processing in the paging method for multiple pages of text in a document image provided by the present invention. Figure 6 As shown, it is shown Figure 5 The result of removing AD and BC. The second set includes line segments AB, CD, AC and BD. The page break lines include the lines where AB, CD, AC and BD are located. Although the vertical page break lines AC and BD may pass through individual characters, the characters in the text block are divided into corresponding pages according to the center point of the text block, which ensures the accuracy and no omission of page division.
[0072] in, Figure 2-Figure 6 The outermost rectangle in the represents the document image.
[0073] The paging method for multiple pages of text in a document image provided by the present invention obtains a first set of lines between suspected page numbers by connecting the center points of each suspected page number in pairs, removes the suspected lines between page numbers that cross within the range of the text image based on the first set, and obtains a third set of suspected lines between page numbers. The straight lines where the suspected lines between page numbers in the third set are located are used as paging lines, thereby achieving accurate determination of the paging lines when the page numbers are at the corners of the pages.
[0074] According to a paging method for multiple pages of text in a document image provided by the present invention, determining the text blocks and text block positions in the document image based on the OCR recognition results includes: obtaining a text box in the OCR recognition results; after corroding and dilating the text box, determining the text blocks and text block positions in the document image through connected domain analysis.
[0075] When determining the text block and the position of the text block in the document image according to the OCR recognition result, first obtain the text box in the OCR recognition result, and then erode and expand the text box in the OCR recognition result, and then re-determine the text block and the position of the text block in the document image through connected domain analysis.
[0076] The paging method for multiple pages of text in a document image provided by the present invention obtains a text box in an OCR recognition result, performs corrosion processing and expansion processing on the text box, and then re-determines the text block and the position of the text block in the document image through connected domain analysis, thereby improving the rationality of the text block and being conducive to saving computing resources.
[0077] According to a method for paging multiple pages of text in a document image provided by the present invention, before obtaining the OCR recognition result of the document image, the method further includes: performing grayscale processing, binarization processing and noise removal processing on the document image.
[0078] Before performing OCR recognition on a document image, the document image may be preprocessed to improve the accuracy of OCR recognition of the document image.
[0079] The preprocessing of document images can include the following operations: Convert the document image to grayscale.
[0080] Through binarization processing, a binary image is obtained, and the text area in the grayscale image is highlighted.
[0081] Remove noise such as spots and stray lines from binary images.
[0082] The paging method for multiple pages of text in a document image provided by the present invention improves the accuracy of OCR recognition of the document image by performing grayscale processing, binarization processing and noise removal processing on the document image.
[0083] The paging method for multi-page text in a document image provided by the present invention has a wide range of application scenarios when processing various multi-page documents, including but not limited to: Digitization of books and reports: Books or reports containing multiple pages can be efficiently scanned and digitized, and the pages can be automatically sorted.
[0084] Archives management: During the archives digitization process, archive files containing multiple pages can be effectively processed, avoiding the tedious work of manual segmentation.
[0085] Academic document organization: For academic papers or journals containing multiple pages, automatic pagination and text organization can be achieved to improve the efficiency of document management.
[0086] The paging method for multiple pages of text in a document image provided by the present invention can significantly improve the accuracy and efficiency of OCR recognition of multiple pages of text, reduce manual intervention, and improve work efficiency and the automation level of document management.
[0087] The paging device for multiple pages of text in a document image provided by the present invention is described below. The paging device for multiple pages of text in a document image described below and the paging method for multiple pages of text in a document image described above can be referred to each other.
[0088] Figure 7 Schematic diagram of the structure of the paging device for multiple pages of text in a document image provided by the present invention. Figure 7 As shown, the device includes an acquisition module 10, a first determination module 20, a second determination module 30, a third determination module 40 and a paging processing module 50, wherein: the acquisition module 10 is used to: obtain the OCR recognition result of the document image; wherein the document image includes at least two pages; the first determination module 20 is used to: determine the text block and the text block position in the document image according to the OCR recognition result; the second determination module 30 is used to: in response to determining that the characters in the text block have page number character features, page number context features and page number position features, determine that the characters in the text block are suspected page numbers; the third determination module 40 is used to: determine the paging line according to the position of the suspected page number and the page number position feature; the paging processing module 50 is used to: paging the multiple pages of text according to the paging line, and dividing the characters in the text block into corresponding pages according to the position of the text block.
[0089] The paging device for multiple pages of text in a document image provided by the present invention obtains an OCR recognition result of a document image; wherein the document image includes at least two pages, determines a text block and a text block position in the document image according to the OCR recognition result, and in response to determining that the characters in the text block have page number character features, page number context features and page number position features, determines that the characters in the text block are suspected page numbers, the page number position features include the page number being at a corner of a page or the page number being in the middle of a page, determines a paging line according to the position of the suspected page number and the page number position features, pages the multiple pages of text according to the paging line, and divides the characters in the text block into corresponding pages according to the position of the text block, thereby realizing automatic, efficient and accurate paging of multiple pages of OCR text recognition, and the paging recognition does not depend on the page number sequence, has high flexibility, significantly improves the accuracy and efficiency of multi-text OCR recognition, reduces manual intervention in OCR recognition, reduces labor costs, and greatly improves the automation level and efficiency of document processing.
[0090] Figure 8 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 8 As shown, the electronic device may include: a processor (processor) 810, a communication interface (Communications Interface) 820, a memory (memory) 830 and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other through the communication bus 840. The processor 810 can call the logic instructions in the memory 830 to execute a paging method for multiple pages of text in a document image, the method comprising: obtaining an OCR recognition result of the document image; wherein the document image includes at least two pages; determining a text block and a text block position in the document image according to the OCR recognition result; in response to determining that the characters in the text block have page number character features, page number context features and page number position features, determining that the characters in the text block are suspected page numbers; wherein the page number position features include the page number at the corner of the page or the page number in the middle of the page; determining a paging line according to the position of the suspected page number and the page number position features; paging the multiple pages of text according to the paging line, and dividing the characters in the text block into corresponding pages according to the position of the text block.
[0091] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0092] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the paging method for multiple pages of text in a document image provided by the above-mentioned methods, the method including: obtaining an OCR recognition result of the document image; wherein the document image includes at least two pages; determining a text block and a text block position in the document image according to the OCR recognition result; in response to determining that the characters in the text block have page number character features, page number context features and page number position features, determining that the characters in the text block are suspected page numbers; wherein the page number position features include the page number at the corner of the page or the page number in the middle of the page; determining a paging line according to the position of the suspected page number and the page number position features; paging the multiple pages of text according to the paging line, and dividing the characters in the text block into corresponding pages according to the position of the text block.
[0093] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the paging method for multiple pages of text in a document image provided by the above-mentioned methods, the method comprising: obtaining an OCR recognition result of a document image; wherein the document image comprises at least two pages; determining a text block and a text block position in the document image according to the OCR recognition result; in response to determining that the characters in the text block have page number character features, page number context features and page number position features, determining that the characters in the text block are suspected page numbers; wherein the page number position features comprise page numbers at the corners of a page or page numbers in the middle of a page; determining a paging line according to the position of the suspected page number and the page number position features; paging the multiple pages of text according to the paging line, and dividing the characters in the text block into corresponding pages according to the position of the text block.
[0094] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0095] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0096] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for paging multiple pages of text in a document image, characterized in that: include: Obtaining an OCR recognition result of a document image; wherein the document image includes at least two pages; Determine the text block and the text block position in the document image according to the OCR recognition result; In response to determining that the characters in the text block have page number character features, page number context features, and page number position features, determining that the characters in the text block are suspected page numbers; wherein the page number position features include the page number being at a corner of a page or the page number being in the middle of a page; Determine a paging line according to the position of the suspected page number and the position feature of the page number; The multiple pages of text are divided into pages according to the page break lines, and the characters in the text blocks are divided into corresponding pages according to the positions of the text blocks.
2. The method for paging multiple pages of text in a document image according to claim 1, characterized in that: Before determining that the characters in the text block are suspected page numbers in response to determining that the characters in the text block have page number character features, page number context features, and page number position features, the method further includes: Pattern matching is performed on characters in the text block using a pre-built regular expression to determine whether the characters in the text block have the page number character features.
3. The method for paging multiple pages of text in a document image according to claim 1, characterized in that: Before determining that the characters in the text block are suspected page numbers in response to determining that the characters in the text block have page number character features, page number context features, and page number position features, the method further includes: In response to a spacing between the text block and other text blocks exceeding a preset spacing threshold, and the text block and other text blocks are not in the same line, it is determined that the characters in the text block have the page number context feature.
4. The method for paging multiple pages of text in a document image according to claim 1, characterized in that: Before determining that the characters in the text block are suspected page numbers in response to determining that the characters in the text block have page number character features, page number context features, and page number position features, the method further includes: By comparing the distance between the characters in the text block and the page edge of the document image with the distance between the preset page number position and the page edge, it is determined whether the characters in the text block have the page number position feature.
5. The method for paging multiple pages of text in a document image according to claim 1, characterized in that: When the page number position feature is that the page number is in the middle of the page, determining the page break line according to the position of the suspected page number and the page number position feature includes: Connecting the center points of the suspected page numbers in pairs to obtain a first set of connecting lines between the suspected page numbers; Based on the first set, the suspected page number connection lines that cross within the range of the document image are removed, and the suspected page number connection lines whose angle with the image direction of the document image is less than a preset angle threshold are removed to obtain a second set of the suspected page number connection lines; Determine the midpoints of the two suspected page numbers corresponding to the line between the suspected page numbers in the second set, draw a straight line perpendicular to the line between the suspected page numbers based on the midpoint to obtain a set of perpendicular lines, and use the straight line where the line between the suspected page numbers in the second set is located and the set of perpendicular lines as the paging line.
6. The method for paging multiple pages of text in a document image according to claim 1, characterized in that: When the page number position feature is that the page number is at a corner of a page, determining a page break line according to the position of the suspected page number and the page number position feature includes: Connecting the center points of the suspected page numbers in pairs to obtain a first set of connecting lines between the suspected page numbers; Based on the first set, the suspected page number connection lines that cross within the range of the text image are removed to obtain a third set of the suspected page number connection lines; The straight line where the suspected connecting lines between page numbers in the third set are located is used as the paging line.
7. The method for paging multiple pages of text in a document image according to claim 1, characterized in that: Determining the text block and the position of the text block in the document image according to the OCR recognition result includes: Obtain the text box in the OCR recognition result; After the text frame is corroded and expanded, the text block and the position of the text block in the document image are determined through connected domain analysis.
8. The method for paging multiple pages of text in a document image according to claim 1, characterized in that: Before obtaining the OCR recognition result of the document image, the method further includes: The document image is subjected to grayscale processing, binarization processing and noise removal processing.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method for paging multiple pages of text in a document image as claimed in any one of claims 1 to 8 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for paging multiple pages of text in a document image as claimed in any one of claims 1 to 8 is implemented.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method for paging multiple pages of text in a document image as claimed in any one of claims 1 to 8 is implemented.