A table structured detection method, system, terminal and storage medium
The table is detected and split by a linear detection algorithm to form a tree structure, which solves the problem of low detection accuracy of complex tables in the prior art, and realizes efficient and accurate table structured detection.
Patent Information
- Application Number
- CN202210320114.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-29
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2042-03-29
AI Technical Summary
Existing table structured algorithms need to rely on massive data, and have low detection accuracy for complex tables such as dense tables and shaped tables.
The linear detection algorithm is used to detect the detection table for table line. The table is split through the detected table lines to generate subtables, and each subtable cycle is performed to form a tree structure, and finally generate the table structured detection result. .
It does not rely on massive data, has small calculation amount and high detection accuracy, and is suitable for deployment to mobile terminals, improving the detection accuracy of complex tables.
Smart Images

Figure CN114694157B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of table structuring algorithms, and in particular to a table structuring detection method, system, terminal and storage medium. Background Art
[0002] The current table structuring algorithms mainly include methods based on deep learning and methods based on visual algorithms. Among them, the deep learning-based methods include semantic segmentation algorithms or instance segmentation algorithms. The main target of this method is table lines, which requires reliance on massive data. Although the detection accuracy is high, the amount of calculation is large and it is not convenient to deploy on mobile terminals. The method based on visual algorithms detects cell lines through edge detection, straight line detection, and pixel distribution algorithms. This method can achieve good detection results for conventional tables, but the detection accuracy is low for complex tables such as dense tables and special-shaped tables. Summary of the invention
[0003] The present invention provides a table structure detection method, system, terminal and storage medium, aiming to solve the technical problems existing in the existing table structure algorithm, such as the need to rely on massive data and the low detection accuracy for complex tables.
[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0005] A table structure detection method, comprising:
[0006] A straight line detection algorithm is used to detect table lines on the table to be detected; the table lines shown include horizontal table lines and vertical table lines;
[0007] Splitting the table to be detected according to the detected table lines to generate sub-tables corresponding to the number of the table lines;
[0008] The line detection algorithm is used to detect table lines for each sub-table respectively, and it is determined whether table lines are detected in the sub-table. If table lines are detected, the sub-table is split again according to the detected table lines; if table lines are not detected,
[0009] Generate a table structured detection result of the table image to be detected.
[0010] The technical solution adopted by the embodiment of the present invention also includes: the use of a straight line detection algorithm to perform table line detection on the table to be detected includes:
[0011] Performing grayscale processing on the table image to be detected, converting the table image to be detected into a grayscale image;
[0012] Performing edge detection on the grayscale image to obtain edge detection results of the grayscale image in the x-direction and the y-direction;
[0013] Binarizing the grayscale image after edge detection to obtain a binary image;
[0014] Using the Hough line detection algorithm to perform line detection on the binary image to obtain candidate lines;
[0015] The candidate straight lines are screened according to the set discrimination conditions to obtain the final straight line detection result.
[0016] The technical solution adopted by the embodiment of the present invention also includes: the formula for graying the image of the table to be detected is:
[0017] Gray=R*0.299+G*0.587+B*0.114
[0018] Among them, Gray represents the grayscale image, and R, G, and B represent the grayscale values of the red, green, and blue channels of the color image respectively.
[0019] The technical solution adopted by the embodiment of the present invention also includes: the screening of the candidate straight lines according to the set discrimination conditions includes:
[0020] It is determined whether the detected candidate straight lines meet the discrimination condition. If the discrimination condition is met, the candidate straight lines meeting the discrimination condition are sorted according to the overlap between the candidate straight lines and the binary image, and the candidate straight line with the highest overlap is selected as the final straight line detection result.
[0021] The technical solution adopted by the embodiment of the present invention also includes: the discrimination condition for screening the candidate straight lines is specifically:
[0022] The overlap between the candidate straight line and the binary image is higher than a set threshold, and the angle error of the candidate straight line is less than a set degree.
[0023] The technical solution adopted by the embodiment of the present invention also includes: the use of a straight line detection algorithm to perform table line detection on the table to be detected includes:
[0024] Performing horizontal table line detection on the table to be detected;
[0025] Determine whether the detected horizontal table line runs through the entire table to be detected. If the horizontal table line runs through the entire table to be detected, split the table to be detected according to the detected horizontal table line; if the horizontal table line does not run through the entire table to be detected,
[0026] Performing vertical table line detection on the table to be detected;
[0027] It is determined whether the detected longitudinal table line runs through the entire table to be detected. If the longitudinal table line runs through the entire table to be detected, the table to be detected is split according to the detected longitudinal table line.
[0028] The technical solution adopted by the embodiment of the present invention further includes: the use of a straight line detection algorithm to perform table line detection on each sub-table separately further includes:
[0029] Perform horizontal table line detection on each sub-table separately;
[0030] Determine whether the detected horizontal table line runs through the entire sub-table. If the horizontal table line runs through the entire sub-table, split the sub-table according to the detected horizontal table line; if the horizontal table line does not run through the entire sub-table,
[0031] Perform vertical table line detection on each sub-table separately;
[0032] It is determined whether the detected vertical table line runs through the entire sub-table. If the vertical table line runs through the entire sub-table, the sub-table is split according to the detected vertical table line; if the vertical table line does not run through the entire sub-table, the table line detection of the sub-table is terminated.
[0033] Another technical solution adopted by the embodiment of the present invention is: a table structure detection system, comprising:
[0034] The first straight line detection module is used to detect the table lines of the table to be detected by using a straight line detection algorithm; the table lines include horizontal table lines and vertical table lines;
[0035] Table splitting module: used for splitting the table to be detected according to the detected table lines, and generating sub-tables corresponding to the number of the table lines;
[0036] The second straight line detection module is used to use the straight line detection algorithm to perform table line detection on each sub-table respectively, and determine whether the table line is detected in the sub-table. If the table line is detected, the sub-table is re-split according to the detected table line by the table splitting module; if the table line is not detected, the table structure detection result of the table image to be detected is generated.
[0037] Another technical solution adopted by an embodiment of the present invention is: a terminal, the terminal includes a processor and a memory coupled to the processor, wherein:
[0038] The memory stores program instructions for implementing the above table structure detection method;
[0039] The processor is configured to execute the program instructions stored in the memory to perform the table structure detection operation.
[0040] Another technical solution adopted by the embodiment of the present invention is: a storage medium stores program instructions executable by a processor, and the program instructions are used to execute the above-mentioned table structure detection method.
[0041] The table structured detection method, system, terminal and storage medium of the embodiment of the present invention use a straight line detection algorithm to detect horizontal table lines and vertical table lines on a table image, split the table image according to the detected horizontal table lines and vertical table lines, and perform straight line detection on the split sub-tables in a loop, so that the table forms a tree structure, and obtains the final cell detection result. The embodiment of the present invention does not rely on massive data, has a small amount of calculation, high detection accuracy, is easy to deploy on a mobile terminal, and can improve the detection accuracy of complex tables such as dense tables or special-shaped tables. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 is a flowchart of a table structure detection method according to a first embodiment of the present invention;
[0043] Figure 2 is a flow chart of a table structure detection method according to a second embodiment of the present invention;
[0044] Figure 3 is a schematic diagram of a table structure detection process according to an embodiment of the present invention;
[0045] Figure 4 The embodiment of the present invention is directed to Figure 3 The detection flow chart of the original table image (a) shown;
[0046] Figure 5 It is a structural schematic diagram of a table structured detection system according to an embodiment of the present invention;
[0047] Figure 6 is a schematic diagram of the terminal structure of an embodiment of the present invention;
[0048] Figure 7 It is a schematic diagram of the storage medium structure of an embodiment of the present invention. DETAILED DESCRIPTION
[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] The terms "first", "second" and "third" in the present invention are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first", "second" and "third" can explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. All directional indications (such as up, down, left, right, front, back...) in the embodiments of the present invention are only used to explain the relative position relationship, movement, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication also changes accordingly. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices.
[0051] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0052] See also Figure 1 , is a flow chart of a table structure detection method according to a first embodiment of the present invention. The table structure detection method according to the first embodiment of the present invention comprises the following steps:
[0053] S100: Using a straight line detection algorithm to perform table line detection on the table to be detected; wherein the table lines include horizontal table lines and vertical table lines;
[0054] In this step, the line detection algorithm is used to detect the table line of the table to be detected as follows:
[0055] S100a: grayscale the image of the table to be detected, and convert the image of the table to be detected into a grayscale image;
[0056] Among them, the embodiment of the present invention adopts opencv to perform grayscale processing on the image of the table to be detected, and the grayscale processing formula is: Gray=R*0.299+G*0.587+B*0.114; wherein Gray represents a grayscale image, and R, G, and B represent the grayscale values of the red, green, and blue channels of a color image, respectively.
[0057] S100b: Use the sobel operator to perform edge detection on the grayscale image to obtain edge detection results Ix and Iy of the grayscale image in the x direction and y direction;
[0058] The Sobel operator is a discrete differentiation operator, which is used to calculate the approximate gradient of the grayscale of an image. The larger the gradient, the more likely it is an edge. The Sobel operator obtains the gradient image of the grayscale image in the X and Y directions by taking derivatives in the horizontal and vertical directions.
[0059] S100c: performing binarization processing on the grayscale image to obtain a binary image;
[0060] The binarization process is to select the gray value of the points on the image as 0 or 255 through a threshold value, so that the entire image presents an obvious black and white effect, and obtain a binary image that can reflect the overall and local features of the image.
[0061] S100d: Use the Hough line detection algorithm to perform line detection on the binary image to obtain detected candidate lines;
[0062] S100e: Determine whether the detected candidate straight line meets the set discrimination condition. If the discrimination condition is not met, it means that the straight line is not detected. If the discrimination condition is met, execute S201f;
[0063] Among them, the discrimination conditions are specifically as follows: the overlap between the candidate straight line and the binary image is higher than a set threshold (the threshold is set to 90% in the embodiment of the present invention, and can be set specifically according to actual applications), and the angular error of the candidate straight line is less than a set degree (the degree is set to 9 degrees in the embodiment of the present invention, and can be set specifically according to actual applications).
[0064] S100f: Sort the candidate lines that meet the discrimination condition according to the overlap between the candidate lines and the binary image, and select the candidate line with the highest overlap as the final line detection result; the line is the detected horizontal table line or vertical table line.
[0065] S101: splitting the table / sub-table to be detected according to the detected table lines, and generating sub-tables corresponding to the number of table lines;
[0066] In this step, splitting the table / sub-table to be detected according to the detected table lines specifically includes:
[0067] S101 a: Perform horizontal table line detection on the table to be detected;
[0068] S101 b: Determine whether the detected horizontal table line runs through the entire table to be detected. If the horizontal table line runs through the entire table to be detected, split the table to be detected according to the detected horizontal table line; if the horizontal table line does not run through the entire table to be detected, straight line S101 c;
[0069] S101 c: Performing vertical table line detection on the table to be detected;
[0070] S101 d: Determine whether the detected vertical table line runs through the entire table to be detected. If the vertical table line runs through the entire table to be detected, split the table to be detected according to the detected vertical table line.
[0071] S102: using a straight line detection algorithm to perform table line detection on each sub-table respectively, and determining whether a table line is detected in the sub-table; if a table line is detected, re-execute S101 to split the sub-table; otherwise, execute S103;
[0072] In this step, the subtable is split specifically including:
[0073] S102a: Perform horizontal table line detection on each sub-table respectively;
[0074] S102b: Determine whether the detected horizontal table line runs through the entire sub-table. If the horizontal table line runs through the entire sub-table, split the sub-table according to the detected horizontal table line; if the horizontal table line does not run through the entire sub-table, straight line S102c;
[0075] S102c: Performing vertical table line detection on each sub-table respectively;
[0076] S102d: Determine whether the detected vertical table line runs through the entire sub-table. If so, split the sub-table according to the detected vertical table line. If not, terminate the sub-table table line detection.
[0077] S103: Generate a table structure detection result of the table image to be detected.
[0078] See also Figure 2 , is a flow chart of a table structure detection method according to a second embodiment of the present invention. The table structure detection method according to the second embodiment of the present invention comprises the following steps:
[0079] S200: Obtain a table image to be detected, and treat the entire table image to be detected as a table;
[0080] S201: Detecting horizontal table lines of a table / subtable using a straight line detection algorithm;
[0081] In this step, the horizontal table lines of the table / subtable are detected by using a straight line detection algorithm, specifically including:
[0082] S201a: grayscale the image of the table to be detected, converting the image of the table to be detected into a grayscale image;
[0083] Among them, the embodiment of the present invention adopts opencv to perform grayscale processing on the image of the table to be detected, and the grayscale processing formula is: Gray=R*0.299+G*0.587+B*0.114; wherein Gray represents a grayscale image, and R, G, and B represent the grayscale values of the red, green, and blue channels of a color image, respectively.
[0084] S201b: Use the sobel operator to perform edge detection on the grayscale image to obtain edge detection results Ix and Iy of the grayscale image in the x direction and y direction;
[0085] The Sobel operator is a discrete differentiation operator, which is used to calculate the approximate gradient of the grayscale of an image. The larger the gradient, the more likely it is an edge. The Sobel operator obtains the gradient image of the grayscale image in the X and Y directions by taking derivatives in the horizontal and vertical directions.
[0086] S201c: Binarize the grayscale image to obtain a binary image;
[0087] The binarization process is to select the gray value of the points on the image as 0 or 255 through a threshold value, so that the entire image presents an obvious black and white effect, and obtain a binary image that can reflect the overall and local features of the image.
[0088] S201d: Perform straight line detection on the binary image using the Hough straight line detection algorithm to obtain detected candidate straight lines;
[0089] S201e: Determine whether the detected candidate straight line meets the set discrimination condition. If the discrimination condition is not met, it means that the straight line is not detected; if the discrimination condition is met, execute S201f;
[0090] Among them, the discrimination conditions are specifically as follows: the overlap between the candidate straight line and the binary image is higher than a set threshold (the threshold is set to 90% in the embodiment of the present invention, and can be set specifically according to actual applications), and the angular error of the candidate straight line is less than a set degree (the degree is set to 9 degrees in the embodiment of the present invention, and can be set specifically according to actual applications).
[0091] S201 f: Sort the candidate lines that meet the discrimination condition according to the overlap between the candidate lines and the binary image, and select the candidate line with the highest overlap as the final line detection result; the line is the detected horizontal table line or vertical table line.
[0092] S202: Determine whether the detected horizontal table line runs through the entire table / sub-table. If the horizontal table line runs through the entire table / sub-table, execute S203; if the horizontal table line does not run through the entire table / sub-table, execute S204;
[0093] S203: split the table / sub-table according to the detected horizontal table lines, and re-execute S201 for each split table / sub-table;
[0094] S204: Determine whether the table / subtable has been subjected to vertical table line detection. If not, execute S205; if vertical table line detection has been performed, execute S209;
[0095] S205: Detecting the vertical table lines of the table / subtable using a straight line detection algorithm;
[0096] In this step, the process of detecting the longitudinal table lines is the same as the process of detecting the transverse table lines in S201 , and to avoid redundancy, this step will not be described again.
[0097] S206: Determine whether the detected vertical table line runs through the entire table / sub-table. If the vertical table line runs through the entire table / sub-table, execute S207; if the vertical table line does not run through the entire table / sub-table, execute S208;
[0098] S207: Split the table / sub-table according to the detected vertical table lines, and re-execute S201 for each split sub-table;
[0099] S208: Determine whether the table / subtable has been subjected to horizontal table line detection. If it has not been subjected to horizontal table line detection, execute S201 again; if it has been subjected to horizontal table line detection, execute S209;
[0100] S209: Determine whether the horizontal table line and vertical table line detection of all tables / sub-tables are completed. If the horizontal table line and vertical table line detection of all tables / sub-tables are completed, execute S210;
[0101] S210: Generate a table structure detection result of the table image to be detected.
[0102] Based on the above, the above straight line detection process is cyclically executed on each segmented sub-table, so that the table forms a tree structure, and the leaf nodes are the cells finally detected.
[0103] For ease of understanding, the table structure detection process is described in detail through the following examples. Figure 3 The figure is a schematic diagram of the table structure detection process of an embodiment of the present invention, wherein (a) is the original table image and (d) is the final table structure detection result. Figure 4 , which is the embodiment of the present invention for Figure 3 The detection flow chart of the original table image (a) shown in the figure specifically includes:
[0104] S300: Perform horizontal table line detection on the original table image (a);
[0105] S301: It is determined that no horizontal table line running through the entire original table image (a) is detected, and S302 is executed;
[0106] S302: Performing vertical table line detection on the original table image (a);
[0107] S303: Determine that the detected vertical table line runs through the entire original table image (a), and execute S304;
[0108] S304: splitting the original table image (a) into two sub-tables A and B as shown in (b) by using the detected vertical table lines;
[0109] S305: Performing horizontal table line detection and vertical table line detection on the split sub-tables A and B respectively, splitting sub-table A into two sub-tables A1 and A2 as shown in (c) according to the detected horizontal table lines, and splitting sub-table B into two sub-tables B1 and B2 as shown in (c) according to the detected vertical table lines;
[0110] S306: Perform horizontal table line detection and vertical table line detection on the split sub-tables A1, A2, B1 and B2 respectively. The horizontal table lines and vertical table lines are detected in A1, A2 and B1. The processing ends. According to the horizontal table lines detected in B2, B2 is split into two sub-tables B21 and B22 as shown in (d).
[0111] S307: Perform horizontal table line detection and vertical table line detection on the split sub-tables B21 and B22 respectively. Both horizontal table line detection and vertical table line detection are detected for B21 and B22, and the processing ends.
[0112] Based on the above, the table structure detection method of the embodiment of the present invention uses a straight line detection algorithm to detect horizontal table lines and vertical table lines on the table image, splits the table image according to the detected horizontal table lines and vertical table lines, and performs straight line detection on the split sub-tables in a loop, so that the table forms a tree structure, and obtains the final cell detection result. The embodiment of the present invention does not rely on massive data, has a small amount of calculation, high detection accuracy, is easy to deploy on the mobile terminal, and can improve the detection accuracy of complex tables such as dense tables or special-shaped tables.
[0113] In an optional implementation, it is also possible to upload the results of the table structured detection method to the blockchain.
[0114] Specifically, the corresponding summary information is obtained based on the result of the table structured detection method. Specifically, the summary information is obtained by hashing the result of the table structured detection method, such as by using the sha256s algorithm. Uploading the summary information to the blockchain can ensure its security and fairness and transparency to users. Users can download the summary information from the blockchain to verify whether the result of the table structured detection method has been tampered with. The blockchain referred to in this example is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. Blockchain (Blockchai n) is essentially a decentralized database, a string of data blocks generated by cryptographic methods, each of which contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. The blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.
[0115] See also Figure 5 , is a schematic diagram of the structure of a table structure detection system according to an embodiment of the present invention. The table structure detection system 40 according to an embodiment of the present invention comprises:
[0116] The first straight line detection module 41 is used to detect the table lines of the table to be detected by using a straight line detection algorithm; the table lines shown include horizontal table lines and vertical table lines;
[0117] Table splitting module 42: used for splitting the table to be detected according to the detected table lines, and generating sub-tables corresponding to the number of table lines;
[0118] The second straight line detection module 43 is used to perform table line detection on each sub-table respectively using a straight line detection algorithm, and determine whether a table line is detected in the sub-table. If a table line is detected, the sub-table is re-split according to the detected table line by the table splitting module 42; if no table line is detected, a table structured detection result of the table image to be detected is generated.
[0119] The table structure detection system of the embodiment of the present invention uses a straight line detection algorithm to detect horizontal table lines and vertical table lines on the table image, splits the table image according to the detected horizontal table lines and vertical table lines, and performs straight line detection on the split sub-tables in a loop, so that the table forms a tree structure, and obtains the final cell detection result. The embodiment of the present invention does not rely on massive data, has a small amount of calculation, high detection accuracy, is easy to deploy on the mobile terminal, and can improve the detection accuracy of complex tables such as dense tables or special-shaped tables.
[0120] See also Figure 6 , is a schematic diagram of a terminal structure of an embodiment of the present invention. The terminal 50 includes a processor 51 and a memory 52 coupled to the processor 51 .
[0121] The memory 52 stores program instructions for implementing the above table structure detection method.
[0122] The processor 51 is used to execute program instructions stored in the memory 52 to perform table structure detection operations.
[0123] The processor 51 may also be referred to as a CPU (Central Processing Unit). The processor 51 may be an integrated circuit chip having a signal processing capability. The processor 51 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0124] See also Figure 7 , Figure 7 Schematic diagram of the structure of the storage medium of the embodiment of the present invention. The storage medium of the embodiment of the present invention stores a program file 61 that can implement all the above methods, wherein the program file 61 can be stored in the above storage medium in the form of a software product, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform all or part of the steps of the methods of 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, or terminal devices such as computers, servers, mobile phones, tablets, etc.
[0125] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the system embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0126] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of software functional units. The above is only an implementation mode of the present invention, and does not limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the contents of the specification and drawings of the present invention, or directly or indirectly used in other related technical fields, is also included in the patent protection scope of the present invention.
Claims
1. A table structure detection method, characterized in that: include: Using a straight line detection algorithm to detect table lines on the table to be detected; the table lines include horizontal table lines and vertical table lines; Splitting the table to be detected according to the detected table lines to generate sub-tables corresponding to the number of the table lines; Using the straight line detection algorithm to perform table line detection on each sub-table respectively, and determine whether a table line is detected in the sub-table, if a table line is detected, re-splitting the sub-table according to the detected table line; if no table line is detected, generating a table structure detection result of the table image to be detected; Wherein, the use of a straight line detection algorithm to perform table line detection on the table to be detected includes: Performing grayscale processing on the table image to be detected, converting the table image to be detected into a grayscale image; Performing edge detection on the grayscale image to obtain edge detection results of the grayscale image in the x-direction and the y-direction; Binarizing the grayscale image after edge detection to obtain a binary image; Using the Hough line detection algorithm to perform line detection on the binary image to obtain candidate lines; The candidate straight lines are screened according to the set discrimination conditions to obtain the final straight line detection result; The splitting of the table to be detected according to the detected table lines comprises: Performing horizontal table line detection on the table to be detected; Determine whether the detected horizontal table line runs through the entire table to be detected. If the horizontal table line runs through the entire table to be detected, split the table to be detected according to the detected horizontal table line; if the horizontal table line does not run through the entire table to be detected, Performing vertical table line detection on the table to be detected; Determine whether the detected vertical table line runs through the entire table to be detected, and if the vertical table line runs through the entire table to be detected, split the table to be detected according to the detected vertical table line; The adopting the straight line detection algorithm to perform table line detection on each sub-table includes: Perform horizontal table line detection on each sub-table separately; Determine whether the detected horizontal table line runs through the entire sub-table. If the horizontal table line runs through the entire sub-table, split the sub-table according to the detected horizontal table line; if the horizontal table line does not run through the entire sub-table, Perform vertical table line detection on each sub-table separately; It is determined whether the detected vertical table line runs through the entire sub-table. If the vertical table line runs through the entire sub-table, the sub-table is split according to the detected vertical table line; if the vertical table line does not run through the entire sub-table, the table line detection of the sub-table is terminated.
2. The table structure detection method according to claim 1, characterized in that: The formula for graying the image of the table to be detected is: Gray=R*0.299+G*0.587+B*0.114 Among them, Gray represents the grayscale image, and R, G, and B represent the grayscale values of the red, green, and blue channels of the color image respectively.
3. The table structure detection method according to claim 1, characterized in that: The screening of the candidate straight lines according to the set discrimination conditions includes: Determine whether the detected candidate straight line meets the discrimination condition. If the discrimination condition is met, The candidate straight lines that meet the discrimination condition are sorted according to the overlap between the candidate straight lines and the binary image, and the candidate straight line with the highest overlap is selected as the final straight line detection result.
4. The table structure detection method according to claim 3, characterized in that: The specific criteria for screening candidate lines are: The overlap between the candidate straight line and the binary image is higher than a set threshold, and the angle error of the candidate straight line is less than a set degree.
5. A table structure detection system, used to implement the method of claim 1, characterized in that: include: The first straight line detection module is used to detect the table lines of the table to be detected by using a straight line detection algorithm; the table lines include horizontal table lines and vertical table lines; Table splitting module: used for splitting the table to be detected according to the detected table lines, and generating sub-tables corresponding to the number of the table lines; The second straight line detection module is used to use the straight line detection algorithm to perform table line detection on each sub-table respectively, and determine whether the table line is detected in the sub-table. If the table line is detected, the sub-table is re-split according to the detected table line by the table splitting module; if the table line is not detected, the table structure detection result of the table image to be detected is generated.
6. A terminal, characterized in that: The terminal includes a processor and a memory coupled to the processor, wherein: The memory stores program instructions for implementing the table structure detection method according to any one of claims 1 to 4; The processor is configured to execute the program instructions stored in the memory to perform the table structure detection method.
7. A storage medium, characterized in that: Program instructions executable by a processor are stored, and the program instructions are used to execute the table structure detection method according to any one of claims 1 to 4.
Citation Information
Patent Citations
High-level information security area table data information extraction method without communication interconnection
CN110309746A
Method for extracting line-containing table information in format document
CN110688825A