Table line break restoration method and system for document image recognition
Patent Information
- Application Number
- CN202410541442.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-30
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2044-04-30
AI Technical Summary
在实际应用中,仅识别文档中的文字往往不能满足需求,文档中含有的表格,往往也需要做结构化提取
[0024]This invention provides a method and system for restoring broken table lines in document image recognition. The solution addresses table line breaks encountered during table detection in document images. Based on a linear fitting strategy, when the distance or positional relationship between the endpoints of two table lines meets the breakage condition, the intersection point of the table lines is calculated using a pre-constructed fitting line formula. The table line endpoints are then updated or the table lines are reconnected based on these intersection points, thus restoring the table lines. This method can effectively restore table lines broken at corners, H-shaped breaks, and T-shaped breaks, significantly improving the accuracy of table recognition in document images.
Smart Images

Figure CN118379745B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of table extraction technology, and in particular relates to a method and system for restoring broken table lines for document image recognition. Background Technology
[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.
[0003] Optical Character Recognition (OCR) technology facilitates the acquisition of large amounts of text material needed for digital documents, enabling people to obtain information more conveniently and efficiently. In practical applications, simply recognizing the text in a document often cannot meet the needs; tables contained in the document also often require structured extraction.
[0004] The inventors discovered that the general steps of table recognition are to first detect table lines in the document image, then extract cells based on the table lines, and finally obtain the text content in the cells. However, real images are often affected by shooting angle, lighting, and shadows, which affects the image's clarity, saturation, and regional pixels to varying degrees. This results in broken or partially missing table lines extracted by image processing, leading to inaccurate extraction of the final table structure. Summary of the Invention
[0005] To address the aforementioned problems, this invention provides a method and system for restoring broken table lines in document image recognition. This solution addresses table line breaks encountered during table detection in document images. Based on a linear fitting strategy, when the distance or positional relationship between the endpoints of two table lines meets the breakage condition, the intersection point of the table lines is calculated using a pre-constructed fitting line formula. The table line endpoints are then updated or the table lines are reconnected based on these intersection points, thus restoring the table lines. This method can effectively restore table lines broken at corners, H-shaped breaks, and T-shaped breaks, significantly improving the accuracy of table recognition in document images.
[0006] According to a first aspect of the present invention, a method for restoring broken table lines for document image recognition is provided, comprising:
[0007] The document image to be identified is segmented into table lines to obtain a binary image of the table lines;
[0008] Based on the obtained binary image of the table lines, image morphology operations are used to extract the horizontal and vertical lines of the table lines.
[0009] Based on the positional relationship between the horizontal and vertical lines of the table, and combined with the intersection of the horizontal and vertical lines of the table determined by the pre-built table line fitting straight line formula, it is determined whether there is a break at the corner. If so, the intersection of the table lines is used as the endpoint of the corresponding horizontal and vertical lines to restore the break at the corner.
[0010] Based on the slope and vertical spacing of the table lines, the horizontal lines of the table lines are grouped together. Two adjacent horizontal lines form a group. According to the intersection of each group of horizontal lines with all the vertical lines of the table lines, when there are two horizontal lines whose endpoints are located between two adjacent intersections, there is an H-shaped break. By connecting the endpoints of the two horizontal lines, the H-shaped break can be restored.
[0011] Furthermore, the determination of the corner break is specifically as follows: traverse all table horizontal and vertical lines to obtain table horizontal and vertical lines that satisfy the condition that the two endpoints of the table horizontal line are on the same side of the table vertical line, and the two endpoints of the table vertical line are on the same side of the table horizontal line; determine the intersection point of the current table horizontal and vertical lines based on the pre-constructed table line fitting straight line formula; and determine whether there is a corner break based on the distance between the intersection point and the endpoints of the table horizontal and vertical lines.
[0012] Furthermore, the pre-constructed table line fitting straight line formula is obtained based on the endpoints of the acquired table line horizontal or vertical lines.
[0013] Furthermore, the table line breakage also includes T-shaped breaks. The restoration of the T-shaped breakage is specifically as follows: For a horizontal table line, obtain the vertical line that intersects with the horizontal line; traverse each vertical line in turn. If the right endpoint of the current horizontal line is located between two vertical lines, and the distance from the right endpoint to the left vertical line is greater than a preset value * the distance between the two vertical lines, then extend the right endpoint to intersect the right vertical line; if the left endpoint of the horizontal line is located between two vertical lines, and the distance from the left endpoint to the right vertical line is greater than a preset value * the distance between the two vertical lines, then extend the left endpoint to intersect the left vertical line.
[0014] Furthermore, image morphology operations are used to extract the horizontal lines of the table. Specifically, when extracting the horizontal lines of the table, an opening operation based on image morphology is used to erode the vertical lines in the binary image of the table lines, retaining only the horizontal lines; a dilation operation is then performed on the binary image of the table lines after the erosion operation; and the coordinates of the horizontal lines are obtained based on the binary image of the table after the dilation operation, combined with connected component analysis.
[0015] Furthermore, image morphology operations are used to extract the vertical lines of the table. Specifically, when extracting the vertical lines of the table, an opening operation based on image morphology is used to erode the horizontal lines in the binary image of the table lines, retaining only the vertical lines; a dilation operation is then performed on the binary image of the table lines after the erosion operation; and the coordinates of the vertical lines are obtained based on the binary image of the table after the dilation operation, combined with connected component analysis.
[0016] Furthermore, the H-shaped fracture specifically refers to two vertical lines connected by a horizontal line, with a partial fracture in the horizontal line; the T-shaped fracture specifically refers to two lines, one horizontal and one vertical, with one line connecting to the middle of the other line, and a fracture occurring at the intersection.
[0017] According to a second aspect of the present invention, a table line breakage restoration system for document image recognition is provided, comprising:
[0018] The table segmentation unit is used to segment the document image to be recognized into table lines to obtain a binary image of the table lines.
[0019] The horizontal and vertical line extraction unit is used to extract the horizontal and vertical lines of the table based on the obtained binary image of the table lines using image morphology operations.
[0020] The fracture restoration unit is used to determine whether there is a fracture at a corner position based on the positional relationship between the horizontal and vertical lines of the table, combined with the intersection points of the horizontal and vertical lines determined by a pre-built table line fitting straight line formula. If a fracture exists, the intersection point is used as the endpoint of the corresponding horizontal and vertical lines to restore the fracture at the corner position. Based on the slope and vertical spacing of the table lines, the horizontal lines of the table are grouped, with two adjacent horizontal lines forming a group. According to the intersection points of each group of horizontal lines with all vertical lines of the table, when there are two horizontal lines whose endpoints are located between two adjacent intersection points, an H-shaped fracture exists. By connecting the endpoints of the two horizontal lines, the H-shaped fracture is restored.
[0021] According to a third aspect of the present invention, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and running on the memory, wherein the processor executes the program to implement the aforementioned method for restoring broken table lines for document image recognition.
[0022] According to a fourth aspect of the present invention, a non-transitory computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the aforementioned method for restoring broken table lines for document image recognition.
[0023] The above one or more technical solutions have the following beneficial effects:
[0024] This invention provides a method and system for restoring broken table lines in document image recognition. The solution addresses table line breaks encountered during table detection in document images. Based on a linear fitting strategy, when the distance or positional relationship between the endpoints of two table lines meets the breakage condition, the intersection point of the table lines is calculated using a pre-constructed fitting line formula. The table line endpoints are then updated or the table lines are reconnected based on these intersection points, thus restoring the table lines. This method can effectively restore table lines broken at corners, H-shaped breaks, and T-shaped breaks, significantly improving the accuracy of table recognition in document images.
[0025] Advantages of additional aspects of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0026] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.
[0027] Figure 1 This is a flowchart of a table line breakage restoration method for document image recognition as described in an embodiment of the present invention;
[0028] Figure 2(a) is a schematic diagram of the table image described in an embodiment of the present invention;
[0029] Figure 2(b) is a schematic diagram of the extraction of horizontal table lines in an embodiment of the present invention;
[0030] Figure 2(c) is a schematic diagram of the extraction of vertical table lines in an embodiment of the present invention;
[0031] Figure 3(a) is a schematic diagram of the table line corner breakage in an embodiment of the present invention;
[0032] Figure 3(b) is a schematic diagram of the restoration of the broken corner of the table line in the embodiment of the present invention;
[0033] Figures 4(a) and 4(b) are schematic diagrams of the "H"-shaped breakage of the table line in the embodiment of the present invention;
[0034] Figure 5 This is a schematic diagram of the "T"-shaped break in the table line as described in an embodiment of the present invention;
[0035] Figure 6(a) is a schematic diagram of the table line breakage in an embodiment of the present invention;
[0036] Figure 6(b) is a schematic diagram of the table line restoration in an embodiment of the present invention. Detailed Implementation
[0037] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0038] It should be noted that the terminology used herein is for the purpose of describing particular implementations only and is not intended to limit the exemplary implementations of the present invention.
[0039] Where there is no conflict, the embodiments and features in the embodiments of the present invention can be combined with each other.
[0040] Example 1:
[0041] The purpose of this embodiment is to provide a method for restoring broken table lines in document image recognition.
[0042] A method for restoring broken table lines in document image recognition, comprising:
[0043] The document image to be identified is segmented into table lines to obtain a binary image of the table lines;
[0044] Based on the obtained binary image of the table lines, image morphology operations are used to extract the horizontal and vertical lines of the table lines.
[0045] Based on the positional relationship between the horizontal and vertical lines of the table, and combined with the intersection of the horizontal and vertical lines of the table determined by the pre-built table line fitting straight line formula, it is determined whether there is a break at the corner. If so, the intersection of the table lines is used as the endpoint of the corresponding horizontal and vertical lines to restore the break at the corner.
[0046] Based on the slope and vertical spacing of the table lines, the horizontal lines of the table lines are grouped together. Two adjacent horizontal lines form a group. According to the intersection of each group of horizontal lines with all the vertical lines of the table lines, when there are two horizontal lines whose endpoints are located between two adjacent intersections, there is an H-shaped break. By connecting the endpoints of the two horizontal lines, the H-shaped break can be restored.
[0047] In specific implementation, the determination of the corner break is as follows: traverse all table horizontal and vertical lines to obtain table horizontal and vertical lines that satisfy the condition that the two endpoints of the table horizontal line are on the same side of the table vertical line, and the two endpoints of the table vertical line are on the same side of the table horizontal line; determine the intersection point of the current table horizontal and vertical lines based on the pre-constructed table line fitting straight line formula; and determine whether there is a corner break based on the distance between the intersection point and the endpoints of the table horizontal and vertical lines.
[0048] In practice, the pre-built table line fitting straight line formula is obtained by fitting the endpoints of the acquired table lines (horizontal or vertical).
[0049] In specific implementation, the table line breakage also includes T-shaped breakage. The restoration of the T-shaped breakage is as follows: For a horizontal table line, obtain the vertical line that intersects with the horizontal line; traverse each vertical line in turn. If the right endpoint of the current horizontal line is located between two vertical lines, and the distance from the right endpoint to the left vertical line is greater than a preset value * the distance between the two vertical lines, then extend the right endpoint to intersect the right vertical line; if the left endpoint of the horizontal line is located between two vertical lines, and the distance from the left endpoint to the right vertical line is greater than a preset value * the distance between the two vertical lines, then extend the left endpoint to intersect the left vertical line.
[0050] In the specific implementation, image morphology operations are used to extract the horizontal lines of the table. Specifically, when extracting the horizontal lines of the table, the vertical lines in the binary image of the table are eroded based on the image morphology opening operation, and only the horizontal lines are retained. The binary image of the table after the erosion operation is then dilated. Based on the binary image of the table after the dilation operation, the coordinates of the horizontal lines are obtained by combining connected component analysis.
[0051] In the specific implementation, image morphology operations are used to extract the vertical lines of the table. Specifically, when extracting the vertical lines of the table, the horizontal lines in the binary image of the table are eroded based on the image morphology opening operation, and only the vertical lines are retained. The binary image of the table after the erosion operation is then dilated. Based on the binary image of the table after the dilation operation, the coordinates of the vertical lines are obtained by combining connected component analysis.
[0052] In specific implementation, the H-shaped fracture is specifically two vertical lines connected by a horizontal line, and the horizontal line has a local fracture; the T-shaped fracture is specifically two lines, one horizontal and one vertical, with one line connecting to the middle of the other line, and a fracture occurring at the intersection.
[0053] Specifically, for ease of understanding, the following detailed description of the solution in this embodiment is provided in conjunction with the accompanying drawings:
[0054] This embodiment addresses the issue of broken table lines during table detection. Based on a linear fitting strategy, it provides a method for restoring broken table lines in document image recognition. The table line breaks include corner breaks, "T"-shaped breaks, and "H"-shaped breaks. When the distance or positional relationship between the endpoints of two table lines meets the breakage condition, a straight line formula is fitted to calculate the intersection point of the table lines. This intersection point is then updated as the endpoint of the table lines, thus restoring the table lines. This method can restore most broken table lines, improving the accuracy of table recognition in document images.
[0055] like Figure 1 As shown, a method for restoring broken table lines in document image recognition specifically includes the following processing steps:
[0056] (1) Table line detection and extraction
[0057] The Unet model, through semantic segmentation, can clearly separate table lines from the background. Horizontal and vertical lines are extracted separately using image morphology processing, as shown in the attached image. Figures 2(a) to 2(c) As shown.
[0058] When extracting horizontal lines, an opening operation (erosion followed by dilation) is performed on the image. First, the vertical lines in the image are eroded, leaving only the horizontal lines. The structuring element for image erosion is set to (1,10), i.e., 1 row and 10 columns. This shape of structuring element can effectively erode the narrower areas, i.e., the vertical lines. Then, the same structuring element is used for dilation to restore the eroded areas at both ends of the horizontal lines. Finally, connected component analysis is used to extract the coordinates of the horizontal lines.
[0059] Similarly, when extracting the vertical lines, the horizontal lines are eroded first. The structuring element kernel_b of the image erosion is set to (10,1), i.e., 10 rows and 1 column. This shape of structuring element can effectively erode areas with small heights, i.e., the horizontal lines. Then, the same structuring element is used for dilation to restore the eroded areas at both ends of the vertical lines. Finally, the coordinates of the vertical lines are obtained using connected component analysis.
[0060] (2) Table line breakage connection
[0061] The extracted table's horizontal and vertical lines show breaks, requiring restoration. There are three main types of broken table lines: corner breaks, "H"-shaped breaks, and "T"-shaped breaks. This is addressed by fitting table lines; the method for straight-line fitting is as follows.
[0062] Fit the linear equations of the horizontal and vertical lines of the table: L: Ax + By + C = 0. Each table line has the following attributes: starting coordinates, ending coordinates, parameter A, parameter B, and parameter C.
[0063] The intersection point P of the two table lines can be calculated using the following formula:
[0064]
[0065] The coordinates of the intersection point P(x,y) can be obtained:
[0066]
[0067] ① Connection of broken parts at corners
[0068] a. Identify the positional relationships between the horizontal and vertical lines and their corners.
[0069] Based on the positional relationship between a point and a line, identify cases where the two endpoints of the horizontal line are on the same side of the vertical line, and vice versa. Also identify cases where the two lines might be at an angle. Figures 3(a) to 3(b) As shown.
[0070] b. Calculate the intersection point P(x, y) of the table lines, and the intersection point will not lie on any line.
[0071] c. Calculate the distances from the intersection point to the two endpoints of the horizontal and vertical lines.
[0072] The Euclidean distances from the intersection point to the two endpoints of the horizontal line are r1, r2; the Euclidean distances to the vertical line are r3, r4.
[0073] d. Determine whether the distance from the intersection point to the endpoint is less than a threshold value.
[0074] If the shortest distance from the intersection point to the endpoint of each line is less than the alpha threshold, that is, min(r1, r2) < alpha, min(r3, r4) < alpha, it indicates that the requirement for corner position breakage is satisfied.
[0075] e. Update the endpoint positions of the table lines to realize the breakage connection of corner lines.
[0076] ② Connection of "H"-shaped breakage of table lines
[0077] a. Traverse the horizontal lines of the table, group the horizontal lines with similar slopes based on the slope and longitudinal spacing of the table lines. Each group of horizontal lines has similar height positions and slopes, which may be the broken segments of the same horizontal line, and finally a summary list is obtained
[0078] list:[[line1,line2],[...],..]
[0079] b. Traverse each group of lines in the list, calculate the intersection points of the horizontal lines in the group with all vertical lines, and save the intersection point list pt_list;
[0080] c. Sort pt_list from left to right, traverse the two points pt1 and pt2 in sequence. If the endpoints of the lines in the group are located between the two intersection points, judge whether the connection condition is met. Calculate the distances from the endpoints of the two lines to the intersection points to obtain the left distance and the right distance. As shown in Figure 4(b), if the sum of the left and right distances exceeds the distance between the two intersection points multiplied by a preset value, the lines are connected.
[0081] ③ "T"-shaped breakage connection of table lines
[0082] a. Traverse the horizontal lines, and for each horizontal line, filter out the vertical lines that intersect with it (directly intersect or intersect with the extension line of the horizontal line)
[0083] b. Sort the vertical lines from left to right.
[0084] c. Traverse every two vertical lines in sequence.
[0085] If the right endpoint of the horizontal line is located between the two vertical lines, and the distance from the right endpoint to the left vertical line > the preset value multiplied by the distance between the two vertical lines, extend the right endpoint to intersect with the right vertical line, as shown Figure 5As shown.
[0086] If the left endpoint of the horizontal line is located between the two vertical lines, and the distance from the left endpoint to the right vertical line is greater than the preset value multiplied by the distance between the two vertical lines, then extend the left endpoint to intersect the left vertical line.
[0087] Figures 6(a) and 6(b) show the results of the table lines being broken and restored.
[0088] (3) Extracting table cells
[0089] Construct a background image where all pixel values are 0, and then draw the table's horizontal and vertical lines on this background image, with each line having a pixel value of 1. This creates a binarized image. In this image, the table lines divide the background into individual rectangular boxes, which also form independent connected components.
[0090] Connectivity analysis was performed on the binarized image to obtain the coordinates of the four points in each cell.
[0091] (4) Character recognition
[0092] PaddleOCR is used to perform text recognition on images, obtaining the content and location of each text block.
[0093] (5) Table text matching
[0094] Iterate through each cell and each text block, calculate the intersection-union ratio (IUR) of each cell area and the text block area. If the IUR exceeds the threshold, it means that the text position belongs to the table frame, and add the text information to the cell information.
[0095] Example 2
[0096] The purpose of this embodiment is to provide a table line breakage restoration system for document image recognition.
[0097] A system for restoring broken table lines in document images, comprising:
[0098] The table segmentation unit is used to segment the document image to be recognized into table lines to obtain a binary image of the table lines.
[0099] The horizontal and vertical line extraction unit is used to extract the horizontal and vertical lines of the table based on the obtained binary image of the table lines using image morphology operations.
[0100] The fracture restoration unit is used to determine whether there is a fracture at a corner position based on the positional relationship between the horizontal and vertical lines of the table, combined with the intersection points of the horizontal and vertical lines determined by a pre-built table line fitting straight line formula. If a fracture exists, the intersection point is used as the endpoint of the corresponding horizontal and vertical lines to restore the fracture at the corner position. Based on the slope and vertical spacing of the table lines, the horizontal lines of the table are grouped, with two adjacent horizontal lines forming a group. According to the intersection points of each group of horizontal lines with all vertical lines of the table, when there are two horizontal lines whose endpoints are located between two adjacent intersection points, an H-shaped fracture exists. By connecting the endpoints of the two horizontal lines, the H-shaped fracture is restored.
[0101] Furthermore, the system described in this embodiment corresponds to the method described in Embodiment 1, and its technical details have been described in detail in Embodiment 1, so they will not be repeated here.
[0102] Example 3:
[0103] The purpose of this embodiment is to provide an electronic device.
[0104] An electronic device includes a memory, a processor, and a computer program stored in the memory and running on the memory. When the processor executes the program, it implements the aforementioned method for restoring broken table lines for document image recognition.
[0105] Example 4:
[0106] The purpose of this embodiment is to provide a non-transitory computer-readable storage medium.
[0107] A non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the aforementioned method for restoring broken table lines for document image recognition.
[0108] Those skilled in the art will understand that the modules or steps of the present invention described above can be implemented using general-purpose computer devices. Optionally, they can be implemented using computer-executable program code, thereby allowing them to be stored in a storage device for execution by a computer device, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. The present invention is not limited to any particular combination of hardware and software.
[0109] While the specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.
Claims
1. A method for restoring broken table lines in document image recognition, characterized in that, include: The document image to be identified is segmented into table lines to obtain a binary image of the table lines; Based on the obtained binary image of the table lines, image morphology operations are used to extract the horizontal and vertical lines of the table lines. Based on the positional relationship between the horizontal and vertical lines of the table, and combined with the intersection of the horizontal and vertical lines of the table determined by the pre-built table line fitting straight line formula, it is determined whether there is a break at the corner. If so, the intersection of the table lines is used as the endpoint of the corresponding horizontal and vertical lines to restore the break at the corner. The determination of the corner break position is specifically as follows: traverse all the horizontal and vertical lines of the table, and obtain the horizontal and vertical lines of the table that satisfy the condition that the two endpoints of the horizontal line are on the same side of the vertical line and the two endpoints of the vertical line are on the same side of the horizontal line; based on the pre-constructed table line fitting straight line formula, determine the intersection point of the current horizontal and vertical lines of the table. Based on the distance between the intersection point and the endpoints of the horizontal and vertical lines of the table, determine whether there is a break at the corner. Based on the slope and vertical spacing of the table lines, the horizontal lines of the table lines are grouped together. Two adjacent horizontal lines form a group. According to the intersection of each group of horizontal lines with all the vertical lines of the table lines, when there are two horizontal lines whose endpoints are located between two adjacent intersections, there is an H-shaped break. By connecting the endpoints of the two horizontal lines, the H-shaped break can be restored.
2. The method for restoring broken table lines for document image recognition as described in claim 1, characterized in that, The pre-built table line fitting straight line formula is obtained by fitting the endpoints of the acquired table lines, either horizontal or vertical.
3. The method for restoring broken table lines for document image recognition as described in claim 1, characterized in that, The table line breakage also includes T-shaped breaks. The restoration of the T-shaped breakage specifically involves: for each horizontal table line, obtaining the vertical lines intersecting that horizontal line; sequentially traversing each vertical line, if the right endpoint of the current horizontal line is located between two vertical lines, and the distance from the right endpoint to the left vertical line is greater than a preset value... If the distance between the two vertical lines is such that the right endpoint is extended to intersect the right vertical line, then the left endpoint of the horizontal line is located between the two vertical lines, and the distance from the left endpoint to the right vertical line is greater than a preset value. The distance between the two vertical lines is determined by extending the left endpoint to intersect the left vertical line.
4. The method for restoring broken table lines for document image recognition as described in claim 1, characterized in that, The horizontal lines of the table are extracted using image morphology operations. Specifically, the vertical lines in the binary image of the table lines are eroded based on the image morphology opening operation, leaving only the horizontal lines. The binary image of the table lines after the erosion operation is then dilated. Based on the binary image of the table lines after the dilation operation, the coordinates of the horizontal lines are obtained by combining connected component analysis.
5. The method for restoring broken table lines for document image recognition as described in claim 1, characterized in that, Image morphology operations are used to extract the vertical lines of the table. Specifically, when extracting the vertical lines of the table, an opening operation based on image morphology is performed on the horizontal lines in the binary image of the table lines, and only the vertical lines are retained. A dilation operation is then performed on the binary image of the table lines after the erosion operation. Based on the binary image of the table after the dilation operation, the coordinates of the vertical lines are obtained by combining connected component analysis.
6. The method for restoring broken table lines for document image recognition as described in claim 1, characterized in that, The H-shaped fracture is specifically defined as two vertical lines connected by a horizontal line, with the horizontal line exhibiting a local fracture.
7. The method for restoring broken table lines for document image recognition as described in claim 3, characterized in that, The T-shaped fracture specifically consists of two lines, one horizontal and one vertical, with one line connecting to the middle of the other line and the fracture occurring at the intersection.
8. A system for restoring broken table lines in document image recognition, characterized in that, include: The table segmentation unit is used to segment the document image to be recognized into table lines to obtain a binary image of the table lines. The horizontal and vertical line extraction unit is used to extract the horizontal and vertical lines of the table based on the obtained binary image of the table lines using image morphology operations. The fracture restoration unit is used to determine whether there is a fracture at the corner position based on the positional relationship between the horizontal and vertical lines of the table and the intersection point of the horizontal and vertical lines of the table determined by the pre-built table line fitting straight line formula. If there is a fracture, the intersection point of the table lines is used as the endpoint of the corresponding horizontal and vertical lines of the table to restore the fracture at the corner position. The determination of the corner break position is specifically as follows: traverse all the horizontal and vertical lines of the table, and obtain the horizontal and vertical lines of the table that satisfy the condition that the two endpoints of the horizontal line are on the same side of the vertical line and the two endpoints of the vertical line are on the same side of the horizontal line; based on the pre-constructed table line fitting straight line formula, determine the intersection point of the current horizontal and vertical lines of the table. Based on the distance between the intersection point and the endpoints of the horizontal and vertical lines of the table, determine whether there is a break at the corner. Based on the slope and vertical spacing of the table lines, the horizontal lines of the table lines are grouped together. Two adjacent horizontal lines form a group. According to the intersection of each group of horizontal lines with all the vertical lines of the table lines, when there are two horizontal lines whose endpoints are located between two adjacent intersections, there is an H-shaped break. By connecting the endpoints of the two horizontal lines, the H-shaped break can be restored.
9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and running thereon, characterized in that, When the processor executes the program, it implements a table line breakage restoration method for document image recognition as described in any one of claims 1-7.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program implements a method for restoring broken table lines for document image recognition as described in any one of claims 1-7.
Citation Information
Patent Citations
Table repairing method for coping with distorted graph in image table extraction
CN112800731A
Intersection correcting device for table frame line, table recognition device, and optical character reader
JP1996125855A