Hierarchical table detection and identification method and system

Through the hierarchical table detection and recognition method, by constructing binary graphs and contour detection, a list of row and column units is formed, the difficulty of identifying complex table structures in the existing technology is solved, efficient and accurate table detection and recognition is achieved, and document processing in different formats and styles is adapted to.

CN120388387APending Publication Date: 2025-07-29ECCOM NETWORK SYST CO LTD

Patent Information

Application Number
CN202510454030.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-11
Publication Date
2025-07-29

AI Technical Summary

Technical Problem

When handling complex table structures, existing table detection and recognition technologies are difficult to accurately identify hierarchical relationships and cell content, and the computing resources are consumed heavily, unable to meet the real-time requirements in actual applications, and have poor adaptability to different formats and styles.

Method used

The hierarchical table detection and recognition method is adopted. By analyzing and processing table objects, a binary graph is constructed and the cell outline information is obtained, the cell is sorted according to height and width, a row and column cell collection list is formed, and a comprehensive list is constructed through hierarchical division, the algorithm structure and model training strategy are optimized to reduce the dependence on manual labeling data.

Benefits of technology

It improves the detection and recognition ability of complex table structures, can accurately identify nested tables and merged cells, reduces computing resource consumption, improves the calculation efficiency and real-time nature of the algorithm, and enhances adaptability. It is suitable for document table detection and recognition in different formats and styles.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120388387A_ABST
    Figure CN120388387A_ABST
Patent Text Reader

Abstract

The invention provides a hierarchical table detection and recognition method and system, and the method comprises the steps: S1, analyzing and processing a table object, constructing a binary image, and obtaining the contour information of a cell; s2, according to the contour information of the cells, performing hierarchical division on the cell format to obtain a row unit set list; s3, according to the row unit set list, dividing a cell format through levels to obtain a column unit set list; and S4, performing hierarchical division on the column unit set list again, and forming a comprehensive list with a preset specification. The method can be applied to the fields of document image processing, intelligent office automation, information extraction and management and the like, is used for accurately detecting and identifying the table content in the document, and provides basic support for subsequent data processing and analysis.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer vision and pattern recognition. Specifically, it relates to a hierarchical table detection and recognition method and system. Background Art

[0002] In today's era of digital information explosion, a large amount of document data exists in the form of images or electronic documents, which contains a large number of table information. As a structured data presentation method, tables are widely used in various documents, such as financial statements, questionnaires, statistical data tables, etc. Accurately detecting and recognizing table content is crucial for the automated processing and utilization of information.

[0003] Traditional table detection and recognition methods have many limitations. Some rule-based methods require pre-setting complex table structure rules, which have poor adaptability to tables with different formats and styles and are difficult to handle diverse practical application scenarios. Although early machine learning methods have improved the accuracy of table detection to a certain extent, they often require a large amount of manually labeled data and have poor performance in dealing with complex table structures.

[0004] In recent years, deep learning technology has made remarkable progress in the field of computer vision and has been widely applied to table detection and recognition tasks. However, existing deep learning models still face challenges in dealing with complex tables with hierarchical structures. For example, for tables with complex structures such as nested tables and merged cells, it is difficult for the model to accurately identify the hierarchical relationship of the table and the content of the cells, resulting in low accuracy of detection and recognition. In addition, some models consume a large amount of computing resources and have a slow processing speed when dealing with large-scale documents, and cannot meet the real-time requirements in practical applications.

[0005] Chinese patent document with publication number CN119323799A discloses a table detection and content extraction method and system based on image processing, including the following steps: constructing a table detection model and a table structure recognition model; training the table detection model and the table structure recognition model using a public dataset and fine-tuning the table detection model and the table structure recognition model using a self-made dataset; converting the input file into a picture format and performing preprocessing; inputting the preprocessed file picture into the table detection model for feature extraction, and obtaining the border information and category information of the table in the picture according to the feature map of the input picture; according to the obtained table border information and category information for the picture.

[0006] The differences between the present invention and the prior art are as follows: In the pre - processing stage, the prior art mainly constructs and trains a model to uniformly pre - process files by converting them into pictures, with the focus on the model; the present invention has different processing methods for different file formats. For pictures, the Hough transform line detection is directly used, and for PDFs, they are first parsed and then processed according to conditions. In terms of table detection and structure recognition, the prior art relies on the model to extract features to obtain the table border and category information for structure recognition; the present invention is based on table line detection and contour detection, and determines the structure through image processing and logical judgment. In the construction of cells and table structures, the prior art does not mention in detail. The present invention sorts and groups cells by height and width multiple times, and constructs the structure through multiple rounds of operations. In the final output, the prior art does not clearly state. The present invention points out that the output Table instance is composed of multiple RowCellGroup, and each column in each RowCellGroup corresponds to an instance of ColCellGroup.

[0007] In summary, the existing table detection and recognition technologies have deficiencies in dealing with complex table structures and meeting the actual application requirements, and there is an urgent need for a more efficient, accurate and adaptable table detection and recognition method. Summary of the Invention

[0008] Aiming at the deficiencies in the prior art, the purpose of the present invention is to provide a hierarchical table detection and recognition method and system.

[0009] A hierarchical table detection and recognition method provided by the present invention includes:

[0010] Step S1: Parse and process the table object, construct a binary image, and simultaneously obtain the contour information of the cells;

[0011] Step S2: According to the contour information of the cells, divide the cell format hierarchically to obtain a list of row unit sets;

[0012] Step S3: According to the list of row unit sets, divide the cell format hierarchically to obtain a list of column unit sets;

[0013] Step S4: Hierarchically divide the list of column unit sets again and form a comprehensive list of a preset specification.

[0014] Preferably, the step S1 includes:

[0015] Step S1.1: Judge the file format of the parsing object. If it is a picture, perform the table line detection algorithm of the Hough transform to extract all table lines in the picture; if it is a pdf, let the pdf be parsed to obtain all table lines;

[0016] Step S1.2: When parsing the PDF, if an image object with a page occupancy exceeding 80% is parsed, it is regarded that the parsed object is an image, and the table line detection algorithm of the Hough transform is executed for processing; otherwise, all table lines are directly obtained.

[0017] Step S1.3: Draw a binary table image according to the obtained table lines; specifically, create a new canvas and draw all the detected table lines on the canvas.

[0018] Step S1.4: Perform contour detection on the binary table image to obtain the contour information of all cells.

[0019] Preferably, the said Step S2 includes:

[0020] Step S2.1: Sort the obtained cell contour information in descending order according to the cell height to form SortedHCellList.

[0021] Step S2.2: Initialize the row cell set list RowCellList for placing the row cell set object RowCellGroup, and export the first cell from SortedHCellList as the first reference cell.

[0022] Step S2.3: Traverse the row cell set list, and judge the relationship between the main axis stem cell of each row cell set object and the first reference cell. If they belong to the same row, add the first reference cell object to the corresponding row cell set; if the first reference cell and all the row cell set objects in the row cell set list do not belong to the same row, use the first reference cell to create a new row cell set object and add it to the row cell set list.

[0023] Export the cell objects from SortedHCellList in the preset order in turn as the new first reference cell, and repeat Step S2.3 until all cells in SortedHCellList are processed to form a new row cell set list.

[0024] Preferably, the said Step S3 includes:

[0025] Step S3.1: Sort the row cell set objects in the row cell set list RowCellList in ascending order according to x and y; where x and y are the coordinates of the upper left corner of the cell.

[0026] Step S3.2: Extract the row cell set objects from the sorted row cell set list RowCellList in order.

[0027] Step S3.3: Sort the cells in the current row cell set object in descending order of width to form a SortedWCellList list;

[0028] Step S3.4: Initialize a column cell set list ColCellList to store the column cell set object ColCellGroup in the current row cell set; Let the first cell in SortedWCellList be the second reference cell;

[0029] Step S3.5: Traverse the column cell set list, and judge the relationship between the main axis stem cell of each column cell set and the second reference cell. If they belong to the same column, add the second reference cell object to the corresponding column cell set object; If the second reference cell does not belong to the same row as all the column cell sets in the column cell set list, create a new column cell set object using the second reference cell and add it to the column cell set list;

[0030] Export the cell objects in SortedWCellList in the preset order as the new second reference cell, and repeat Step S3.5 until all cells in SortedWCellList are processed to form a new column cell set list;

[0031] Repeat Step S3.2 to Step S3.5 until all row cell set objects are extracted.

[0032] Preferably, Step S4 includes:

[0033] Step S4.1: In the formed column cell set list, obtain ColCellGroup in the preset order;

[0034] Step S4.2: Judge the cell format of ColCellGroup. If there is only one cell in the current ColCellGroup, add it to the comprehensive list in the preset order. Otherwise, after splitting the cell, repeat Step S2 until there is only one cell in all ColCellGroups;

[0035] Step S4.3: Traverse all ColCellGroup objects in the column cell set list and output the comprehensive list; Among them, in the comprehensive list, the row cell set list contains multiple RowCellGroup, and each column of each RowCellGroup corresponds to a ColCellGroup.

[0036] According to a hierarchical table detection and recognition system provided by the present invention, it includes:

[0037] Module M1: Parse and process table objects, construct a binary image, and obtain the contour information of cells at the same time;

[0038] Module M2: According to the contour information of cells, divide the cell format hierarchically to obtain a list of row cell sets;

[0039] Module M3: According to the list of row cell sets, divide the cell format hierarchically to obtain a list of column cell sets;

[0040] Module M4: Hierarchically divide the list of column cell sets again and form a comprehensive list of preset specifications.

[0041] Preferably, the module M1 includes:

[0042] Module M1.1: Judge the file format of the parsing object. If it is a picture, perform the table line detection algorithm processing of the Hough transform to extract all table lines in the picture; if it is a pdf, let the pdf be parsed to obtain all table lines;

[0043] Module M1.2: When parsing the pdf, if a picture object with a page occupancy exceeding 80% is parsed, it is regarded as the parsing object being a picture, and perform the table line detection algorithm processing of the Hough transform, otherwise, directly obtain all table lines;

[0044] Module M1.3: Draw a binary table image according to the obtained table lines; specifically, create a new canvas and draw all detected table lines on the canvas;

[0045] Module M1.4: Perform contour detection on the binary table image to obtain the contour information of all cells.

[0046] Preferably, the module M2 includes:

[0047] Module M2.1: According to the obtained contour information of cells, sort them in descending order of cell height to form SortedHCellList;

[0048] Module M2.2: Initialize the list of row cell sets RowCellList, which is used to place the row cell set object RowCellGroup, and export the first cell from SortedHCellList as the first reference cell;

[0049] Module M2.3: Traverse the list of row cell set lists, and judge the relationship between the main axis stem unit of each row cell set object and the first reference cell. If they belong to the same row, add the first reference cell object to the corresponding row cell set; if the first reference cell and all row cell set objects in the row cell set list do not belong to the same row, create a new row cell set object using the first reference cell and add it to the row cell set list;

[0050] Export the cell objects in the SortedHCellList in the preset order as the new first reference cell in turn, and repeat to trigger Module M2.3 until all cells in the SortedHCellList are processed to form a new list of row cell sets.

[0051] Preferably, the Module M3 includes:

[0052] Module M3.1: Sort the row cell set objects in the row cell set list RowCellList in ascending order according to x and y; where x and y are the coordinates of the upper left corner of the cell;

[0053] Module M3.2: Extract the row cell set objects from the sorted row cell set list RowCellList in sequence;

[0054] Module M3.3: Sort the cells of the current row cell set object in descending order of width to form a SortedWCellList list;

[0055] Module M3.4: Initialize a column cell set list ColCellList to store the column cell set object ColCellGroup in the current row cell set; let the first cell in the SortedWCellList be the second reference cell;

[0056] Module M3.5: Traverse the column cell set list, and judge the relationship between the main axis stem unit of each column cell set and the second reference cell. If they belong to the same column, add the second reference cell object to the corresponding column cell set object; if the second reference cell and all column cell sets in the column cell set list do not belong to the same row, create a new column cell set object using the second reference cell and add it to the column cell set list;

[0057] Export the cell objects in the SortedWCellList in the preset order as the new second reference cell in turn, and repeat to trigger Module M3.5 until all cells in the SortedWCellList are processed to form a new list of column cell sets;

[0058] Repeatably trigger modules M3.2 to M3.5 until all row cell set objects are extracted.

[0059] Preferably, module M4 includes:

[0060] Module M4.1: Obtain ColCellGroup in a preset order in the formed column cell set list;

[0061] Module M4.2: Determine the cell format of ColCellGroup. If there is only one cell in the current ColCellGroup, add it to the comprehensive list in a preset order. Otherwise, after splitting the cell, repeatably trigger module M2 until there is only one cell in all ColCellGroups;

[0062] Module M4.3: Traverse all ColCellGroup objects in the column cell set list and output the comprehensive list; among them, in the comprehensive list, the row cell set list contains multiple RowCellGroups, and each column of each RowCellGroup corresponds to a ColCellGroup.

[0063] Compared with the prior art, the present invention has the following beneficial effects:

[0064] 1) The present invention improves the detection and recognition ability of complex table structures, can accurately identify tables containing complex structures such as nested tables and merged cells, and accurately analyzes the hierarchical relationship and cell content of the tables.

[0065] 2) The present invention reduces the dependence on manually labeled data, improves the self-learning ability of the model by designing a reasonable algorithm architecture and training strategy, and reduces the data annotation cost and workload.

[0066] 3) The present invention improves the computational efficiency and real-time performance of the algorithm, optimizes the computational process and model structure of the algorithm, reduces the consumption of computational resources, enables it to quickly process table detection and recognition tasks in large-scale documents, and meets the real-time requirements in practical applications.

[0067] 4) The present invention enhances the generality and adaptability of the algorithm, can be applied to document table detection and recognition in different formats, styles and fields, and improves the application effect of the algorithm in various actual scenarios.

[0068] 5) The present invention can split a complete table into multiple RowCellGroups (rows), and each row can be further split into several ColCellGroups (columns), can handle non-standard tables (N*M), and can adapt to tables with different layouts for each row. Brief Description of the Drawings

[0069] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non - limiting embodiments read in conjunction with the accompanying drawings:

[0070] Figure 1 It is a flowchart of a hierarchical - based table detection and recognition method of the present invention;

[0071] Figure 2 It is a flowchart of cell contour calculation in Embodiment 1 of the present invention;

[0072] Figure 3 It is a flowchart of cell row division in Embodiment 1 of the present invention;

[0073] Figure 4 It is a schematic diagram of the construction logic of RowCellGroup in Embodiment 1 of the present invention;

[0074] Figure 5 It is a schematic diagram of the construction logic of ColCellGroup in Embodiment 1 of the present invention. Detailed implementation manners

[0075] The present invention will be described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but do not limit the present invention in any form. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present invention, several changes and improvements can still be made. These all fall within the protection scope of the present invention.

[0076] A hierarchical - based table detection and recognition method provided by the present invention includes:

[0077] Step S1: Analyze and process the table object, construct a binary image, and simultaneously obtain the contour information of the cells;

[0078] Step S2: According to the contour information of the cells, divide the cell format hierarchically to obtain a list of row unit sets;

[0079] Step S3: According to the list of row unit sets, divide the cell format hierarchically to obtain a list of column unit sets;

[0080] Step S4: Hierarchically divide the list of column unit sets again and form a comprehensive list of preset specifications.

[0081] Specifically, the said Step S1 includes:

[0082] Step S1.1: Judge the file format of the analysis object. If it is a picture, perform the table line detection algorithm processing of the Hough transform to extract all table lines in the picture; if it is a pdf, parse the pdf to obtain all table lines;

[0083] Step S1.2: When parsing the PDF, if an image object with a page occupancy exceeding 80% is parsed, it is regarded that the parsing object is an image, and the table line detection algorithm of the Hough transform is executed for processing; otherwise, all table lines are directly obtained.

[0084] Step S1.3: Draw a binary table image according to the obtained table lines. Specifically, create a new canvas and draw all the detected table lines on the canvas.

[0085] Step S1.4: Perform contour detection on the binary table image to obtain the contour information of all cells.

[0086] Specifically, the said Step S2 includes:

[0087] Step S2.1: Sort the obtained contour information of the cells in descending order according to the height of the cells to form SortedHCellList.

[0088] Step S2.2: Initialize the row cell set list RowCellList to place the row cell set object RowCellGroup, and export the first cell from SortedHCellList as the first reference cell.

[0089] Step S2.3: Traverse the row cell set list, and judge the relationship between the main axis stem cell of each row cell set object and the first reference cell. If they belong to the same row, add the first reference cell object to the corresponding row cell set; if the first reference cell and all the row cell set objects in the row cell set list do not belong to the same row, create a new row cell set object with the first reference cell and add it to the row cell set list.

[0090] Export the cell objects from SortedHCellList in the preset order in turn as the new first reference cell, and repeat Step S2.3 until all the cells in SortedHCellList are processed to form a new row cell set list.

[0091] Specifically, the said Step S3 includes:

[0092] Step S3.1: Sort the row cell set objects in the row cell set list RowCellList in ascending order according to x and y; where x and y are the coordinates of the upper left corner of the cell.

[0093] Step S3.2: Extract the row cell set objects from the sorted row cell set list RowCellList in the preset order. In a preferred embodiment, traverse each row from top to bottom, and extract the cells in each row from left to right.

[0094] Step S3.3: Sort the cells in the current row cell set object in descending order of width to form a SortedWCellList list;

[0095] Step S3.4: Initialize a column cell set list ColCellList to store the column cell set object ColCellGroup in the current row cell set; Let the first cell in SortedWCellList be the second reference cell;

[0096] Step S3.5: Traverse the column cell set list, and judge the relationship between the main axis stem cell of each column cell set and the second reference cell. If they belong to the same column, add the second reference cell object to the corresponding column cell set object; If the second reference cell does not belong to the same row as all the column cell sets in the column cell set list, create a new column cell set object using the second reference cell and add it to the column cell set list;

[0097] Export the cell objects in SortedWCellList in the preset order as the new second reference cell, and repeat Step S3.5 until all cells in SortedWCellList are processed to form a new column cell set list;

[0098] Repeat Step S3.2 to Step S3.5 until all row cell set objects are extracted.

[0099] Specifically, Step S4 includes:

[0100] Step S4.1: Obtain ColCellGroup in the formed column cell set list in the preset order;

[0101] Step S4.2: Judge the cell format of ColCellGroup. If there is only one cell in the current ColCellGroup, add it to the comprehensive list in the preset order. Otherwise, after splitting the cell, repeat Step S2 until there is only one cell in all ColCellGroups;

[0102] Step S4.3: Traverse all ColCellGroup objects in the column cell set list and output the comprehensive list; Among them, in the comprehensive list, the row cell set list contains multiple RowCellGroup, and each column of each RowCellGroup corresponds to a ColCellGroup.

[0103] Example 1

[0104] The present invention provides a hierarchical table detection and recognition algorithm method. The method for constructing a table object is as follows:

[0105] Step 1: Construct a table cell TableCell object. This object contains row (row) and col (column) to represent the position of the cell in the table, which row and which column; x, y, width, and height represent the image information of the cell, the coordinates x, y of the upper left corner, and the width and height width, height of the cell; the center coordinates center_x, center_y of the cell; the content content of the cell; the horizontal range row_span and the vertical range col_span of the cell represent how many cells are merged;

[0106] Step 2: Construct a cell set object CellGroup object. This object contains a main axis stem cell as an axis cell; a cells list is used to store the included cell objects; a single flag indicates whether there is only one cell in the current set; the upper left coordinates x, y of the upper left cell of the cell cluster;

[0107] Step 3: Construct a column cell set object ColCellGroup object. This object inherits from the CellGroup object and simultaneously adds the definition of the stem attribute. The cell with the largest width in the set is used as the stem cell to judge the relationship between columns;

[0108] Step 4: Construct a row cell set object RowCellGroup object. This object inherits from the CellGroup object and simultaneously adds the definition of the stem attribute. The cell with the highest height in the set is used as the stem cell to judge the relationship between rows;

[0109] Step 5: Construct a standard table object RegularTable, which is defined as a standard Table object. All tables that can be represented by a*b to represent the table structure are defined as a RegularTable object, where a represents the number of rows of the table and b represents the number of columns of the table;

[0110] Step 6: Construct a general Table object, which is defined as a table composed of several row RowCellGroups. Its attributes include x, y, Width, Height, RowCells, RowNum, layout, and content. Among them, x, y, Width, and Height respectively represent the pixel coordinate system at the upper left corner of the page where the table is located and the size of the table. RowCells represents the number of rows in the table (1 stem represents 1 row), RowNum represents the number of rows, layout represents the specific number of columns and the total number of cells in each row, and content represents the structural content within the table;

[0111] The table parsing method is as follows:

[0112] Step 1: Determine the file format of the parsing object. If it is a picture, perform the table line detection algorithm of the Hough transform to extract all the table lines in the picture; if it is a pdf, use the pdf parsing tool. If only one picture object is parsed and the page occupancy of this picture object exceeds 80%, we consider it an uneditable pdf and jump back to the picture processing pipeline;

[0113] Step 2: Create a new canvas with the same size as the page and draw all the detected table lines on this canvas. Perform contour detection on this binary image to obtain the contour information of all cells;

[0114] Step 3: Sort in descending order according to the height of the cells to obtain a SortedHCellList. Initialize a list of row cell sets RowCellList, which is defined as a list of multiple RowCellGroups. Export the first cell from the SortedHCellList as the candidate. Among them, the initialized RowCellGroup is empty and is used to store the RowCellGroup to be constructed. The advantage of this is that the RowCellGroup corresponding to the row can be located through the subscript index.

[0115] Step 4: Traverse the RowCellList list and judge the relationship between the main axis stem unit of each RowCellGroup and the candidate. If they belong to the same row, add this candidate object to the RowCellGroup; if this candidate does not belong to the same row as all the RowCellGroups in the RowCellList, use the candidate to create a new RowCellGroup object and add it to the RowCellList;

[0116] Step 5: If there are still cells in the SortedHCellList, export a cell object as the candidate and execute Step 4; if there are no cells in the SortedHCellList, execute Step 6;

[0117] Step 6: At this time, all cells have been assigned to a RowCellGroup. And the table is composed of these RowCellLists. Sort according to the x and y of each Row object in the RowCellList to obtain a list of RowCellGroups from top to bottom;

[0118] Step 7: Obtain a RowCellGroup object in sequence from the sorted RowCellList;

[0119] Step 8: Sort the TableCells in the current RowCellGroup in descending order according to the width of the cell to obtain a list of SortedWCellList. Initialize a ColCellList to store the column objects in the current RowCellGroup; export the topmost object TableCell in the SortedWCellList as the candidate;

[0120] Step 9: Traverse the ColCellList list, and judge the relationship between the main axis stem unit of each ColCellGroup and the candidate. If they belong to the same column, add the candidate object to the ColCellGroup; if the candidate does not belong to the same row as all ColCellGroups in the ColCellList, use the candidate to create a new ColCellGroup object and add it to the ColCellList;

[0121] Step 10: If there are still objects in the SortedWCellList, continue to export the first object TableCell as the candidate and jump to Step 9; if there are no objects in the SortedWCellList, execute Step 11;

[0122] A complete table can be regarded as composed of multiple row cell groups (formed by RowCellGroup). The column cell groups (ColCellGroup) within a row cell group can also be regarded as sub-tables. Loop until there is only one cell in a ColCellGroup. The purpose of doing this is to solve nested tables. Specifically,

[0123] Step Eleven: Obtain a ColCellGroup object in sequence from the sorted ColCellList;

[0124] Step Twelve: If there is only one cell in the current ColCellGroup, jump to Step Seventeen; otherwise, proceed to Step Thirteen;

[0125] Step Thirteen: Sort in descending order according to the height of the cells to obtain a SortedHCellList. Initialize a row cell set list RowCellList, defined as a list of multiple RowCellGroups. Export the first cell from the SortedHCellList as the candidate.

[0126] Step Fourteen: Traverse the RowCellList, and judge the relationship between the main axis stem cell of each RowCellGroup and the candidate. If they belong to the same row, add the candidate object to this RowCellGroup; if the candidate does not belong to the same row as all the RowCellGroups in the RowCellList, then create a new RowCellGroup object using the candidate and add it to the RowCellList.

[0127] Step Fifteen: If there are still cells in the SortedHCellList, export a cell object as the candidate and execute Step Fourteen; if there are no cells in the SortedHCellList, then execute Step Sixteen;

[0128] Step Sixteen: Traverse the RowCellList of the current column, output a RowCellGroup, and execute Step Eight; if the traversal is complete, then execute Step Seventeen;

[0129] Step Seventeen: If the traversal of the RowCellList of the Table is complete, then execute Step Eighteen; if there are still untraversed ones, then execute Step Seven;

[0130] Step Eighteen: Output the Table instance; it consists of multiple RowCellGroups; in each RowCellGroup, each column corresponds to an instance of a ColCellGroup;

[0131] By having each column correspond to an instance of a ColCellGroup, the following can be solved:

[0132] 1. Merging cells is divided into row merging and column merging,

[0133] First, by judging the first cell (candidate) in the first column of the row RowCellGroup and comparing it with the cells in other columns, the maximum number of cells that can be included is used as the column merging number of this cell (candidate); and so on.

[0134] Next, through the same logic, judge the row merging quantity of each cell. First, select the first column cell in the first row and compare it with each column cell in other rows. The maximum number of column cells included is used as the row merging quantity of this candidate.

[0135] 2. Judge the inclusion logic, that is, nesting:

[0136] Row inclusion: The upper and lower limits of the candidate cell with the upper left coordinate of (0, 0) are (top1, bottom1), and the upper and lower limits of the second cell are (top2, bottom2). If top1 <= top2 and bottom1 >= bottom2, it is row inclusion.

[0137] Column inclusion: Use the boundary limits of the left and right boundaries as the comparison criteria.

[0138] The present invention also provides a hierarchical table detection and recognition system. The hierarchical table detection and recognition system can be implemented by executing the process steps of the hierarchical table detection and recognition method. That is, those skilled in the art can understand the hierarchical table detection and recognition method as the preferred implementation manner of the hierarchical table detection and recognition system.

[0139] According to a hierarchical table detection and recognition system provided by the present invention, it includes: Module M1: Parse and process the table object, construct a binary image, and simultaneously obtain the contour information of the cells; Module M2: According to the contour information of the cells, divide the cell format hierarchically to obtain a list of row unit sets; Module M3: According to the list of row unit sets, divide the cell format hierarchically to obtain a list of column unit sets; Module M4: Hierarchically divide the list of column unit sets again and form a comprehensive list of preset specifications.

[0140] Specifically, the module M1 includes: Module M1.1: Determine the file format of the parsing object. If it is a picture, perform the table line detection algorithm of the Hough transform to extract all the table lines in the picture; if it is a PDF, let the PDF be parsed to obtain all the table lines. Module M1.2: When parsing the PDF, if a picture object with a page occupancy exceeding 80% is parsed, it is regarded that the parsing object is a picture, and the table line detection algorithm of the Hough transform is executed. Otherwise, directly obtain all the table lines. Module M1.3: Draw a binary table image according to the obtained table lines. Specifically, create a new canvas and draw all the detected table lines on the canvas. Module M1.4: Perform contour detection on the binary table image to obtain the contour information of all cells.

[0141] Specifically, the module M2 includes: Module M2.1: Sort the obtained cell contour information in descending order according to the cell height to form SortedHCellList. Module M2.2: Initialize the row cell set list RowCellList for placing the row cell set object RowCellGroup, and export the first cell from SortedHCellList as the first reference cell. Module M2.3: Traverse the row cell set list, and judge the relationship between the main axis stem cell of each row cell set object and the first reference cell. If they belong to the same row, add the first reference cell object to the corresponding row cell set; if the first reference cell and all the row cell set objects in the row cell set list do not belong to the same row, create a new row cell set object with the first reference cell and add it to the row cell set list. Export the cell objects from SortedHCellList in the preset order as the new first reference cell in turn, and repeat to trigger Module M2.3 until all the cells in SortedHCellList are processed to form a new row cell set list.

[0142] Specifically, the module M3 includes: Module M3.1: Sort the row cell set objects in the row cell set list RowCellList in ascending order according to x and y, where x and y are the coordinates of the upper left corner of the cell; Module M3.2: Sequentially extract the row cell set objects from the sorted row cell set list RowCellList; Module M3.3: Sort the cells of the current row cell set object in descending order of width to form a SortedWCellList list; Module M3.4: Initialize a column cell set list ColCellList to store the column cell set object ColCellGroup in the current row cell set; Use the first cell in SortedWCellList as the second reference cell; Module M3.5: Traverse the column cell set list, and judge the relationship between the main axis stem cell of each column cell set and the second reference cell. If they belong to the same column, add the second reference cell object to the corresponding column cell set object; If the second reference cell does not belong to the same row as all the column cell sets in the column cell set list, create a new column cell set object using the second reference cell and add it to the column cell set list; Export the cell objects in SortedWCellList in the preset order as the new second reference cell, and repeatedly trigger Module M3.5 until all cells in SortedWCellList are processed to form a new column cell set list; Repeatedly trigger Module M3.2 to Module M3.5 until all row cell set objects are extracted.

[0143] Specifically, the module M4 includes: Module M4.1: Obtain ColCellGroup in the preset order in the formed column cell set list; Module M4.2: Judge the cell format of ColCellGroup. If there is only one cell in the current ColCellGroup, add it to the comprehensive list in the preset order. Otherwise, after splitting the cell, repeatedly trigger Module M2 until there is only one cell in all ColCellGroups; Module M4.3: Traverse all ColCellGroup objects in the column cell set list and output the comprehensive list. In the comprehensive list, the row cell set list contains multiple RowCellGroup, and each column of each RowCellGroup corresponds to a ColCellGroup.

[0144] Those skilled in the art know that, in addition to implementing the system, its various devices, modules, and units provided by the present invention in the form of pure computer-readable program code, the method steps can be logically programmed to enable the system, its various devices, modules, and units provided by the present invention to be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers, etc. to achieve the same functions. Therefore, the system and its various devices, modules, and units provided by the present invention can be considered as a kind of hardware component, and the devices, modules, and units included therein for implementing various functions can also be regarded as the structures within the hardware component; the devices, modules, and units for implementing various functions can also be regarded as either software modules for implementing the method or structures within the hardware component.

[0145] The specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which does not affect the essence of the present invention. Without conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.

Claims

1. A hierarchical table detection and recognition method, characterized in that Including: Step S1: Parse and process the table object, construct a binary image, and obtain the contour information of the cells simultaneously; Step S2: According to the contour information of the cells, divide the cell format by hierarchy to obtain a list of row unit sets; Step S3: According to the list of row unit sets, divide the cell format by hierarchy to obtain a list of column unit sets; Step S4: Hierarchically divide the list of column unit sets again and form a comprehensive list of preset specifications.

2. The hierarchical table detection and recognition method according to claim 1, characterized in that The said Step S1 includes: Step S1.1: Judge the file format of the parsing object. If it is a picture, perform the table line detection algorithm of Hough transform to extract all the table lines in the picture; if it is a pdf, let the pdf be parsed to obtain all the table lines; Step S1.2: When parsing the pdf, if a picture object with a page occupancy exceeding 80% is parsed, it is regarded that the parsing object is a picture, and perform the table line detection algorithm of Hough transform, otherwise, directly obtain all the table lines; Step S1.3: Draw a binary table image according to the obtained table lines; specifically, create a new canvas and draw all the detected table lines on the canvas; Step S1.4: Perform contour detection on the binary table image to obtain the contour information of all the cells.

3. The hierarchical table detection and recognition method according to claim 1, wherein The said Step S2 includes: Step S2.1: According to the obtained contour information of the cells, sort them in descending order of cell height to form SortedHCellList; Step S2.2: Initialize the list of row unit sets RowCellList for placing the row cell set object RowCellGroup, and export the first cell from SortedHCellList as the first reference cell; Step S2.3: Traverse the list of row unit sets, judge the relationship between the main axis stem unit of each row cell set object and the first reference cell. If they belong to the same row, add the first reference cell object to the corresponding row cell set; if the first reference cell does not belong to the same row as all the row cell set objects in the list of row unit sets, use the first reference cell to create a new row cell set object and add it to the list of row unit sets; Export the cell objects from SortedHCellList in the preset order as the new first reference cell in turn, and repeat Step S2.3 until all the cells in SortedHCellList are processed to form a new list of row unit sets.

4. The hierarchical table detection and recognition method according to claim 1, characterized in that, The said Step S3 includes: Step S3.1: Let the row cell set objects in the list of row unit sets RowCellList be sorted in ascending order according to x and y; where x and y are the coordinates of the upper left corner of the cell; Step S3.2: Extract the row cell set objects from the sorted list of row unit sets RowCellList in sequence; Step S3.3: Sort the cells of the current row cell set object in descending order of width to form a SortedWCellList list; Step S3.4: Initialize a list of column cell set lists ColCellList to store the column cell set object ColCellGroup in the current row cell set; Let the first cell in SortedWCellList be the second reference cell; Step S3.5: Traverse the list of column cell set lists, and judge the relationship between the main axis stem cell of each column cell set and the second reference cell. If they belong to the same column, add the second reference cell object to the corresponding column cell set object; If the second reference cell and all column cell sets in the list of column cell set lists do not belong to the same row, create a new column cell set object using the second reference cell and add it to the list of column cell set lists; Export the cell objects in SortedWCellList in the preset order as the new second reference cell in turn, and repeat Step S3.5 until all cells in SortedWCellList are processed to form a new list of column cell set lists; Repeat Step S3.2 to Step S3.5 until all row cell set objects are extracted.

5. The hierarchical table detection and recognition method according to claim 1, characterized in that Step S4 includes: Step S4.1: In the formed list of column cell set lists, obtain ColCellGroup in the preset order in turn; Step S4.2: Judge the cell format of ColCellGroup. If there is only one cell in the current ColCellGroup, add it to the comprehensive list in the preset order. Otherwise, after splitting the cell, repeat Step S2 until there is only one cell in all ColCellGroups; Step S4.3: Traverse all ColCellGroup objects in the list of column cell set lists and output the comprehensive list; Among them, in the comprehensive list, the list of row cell sets contains multiple RowCellGroup, and each column of each RowCellGroup corresponds to a ColCellGroup.

6. A hierarchical table detection and recognition system, characterized in that Including: Module M1: Parse and process the table object, construct a binary image, and obtain the contour information of the cells at the same time; Module M2: According to the contour information of the cells, divide the cell format by hierarchy to obtain a list of row cell sets; Module M3: According to the list of row cell sets, divide the cell format by hierarchy to obtain a list of column cell sets; Module M4: Hierarchically divide the list of column cell sets again and form a comprehensive list of preset specifications.

7. The hierarchical table detection and recognition system according to claim 6, characterized in that The said Module M1 includes: Module M1.1: Judge the file format of the parsing object. If it is a picture, perform the table line detection algorithm processing of the Hough transform to extract all table lines in the picture; If it is a pdf, let the pdf be parsed to obtain all table lines; Module M1.2: When parsing the pdf, if a picture object with a page occupancy rate exceeding 80% is parsed, it is regarded as the parsing object being a picture, and perform the table line detection algorithm processing of the Hough transform. Otherwise, directly obtain all table lines; Module M1.3: Draw a binary table image according to the obtained table lines; Specifically, create a new canvas and draw all detected table lines on the canvas; Module M1.4: Perform contour detection on the binary table image to obtain the contour information of all cells.

8. The hierarchical table detection and recognition system according to claim 6, wherein The said module M2 includes: Module M2.1: Sort the obtained cell contour information in descending order according to the height of the cells to form SortedHCellList; Module M2.2: Initialize the row cell set list RowCellList for placing the row cell set object RowCellGroup, and export the first cell from SortedHCellList as the first reference cell; Module M2.3: Traverse the row cell set list, and judge the relationship between the main axis stem cell of each row cell set object and the first reference cell. If they belong to the same row, add the first reference cell object to the corresponding row cell set; if the first reference cell and all row cell set objects in the row cell set list do not belong to the same row, create a new row cell set object using the first reference cell and add it to the row cell set list; Export the cell objects from SortedHCellList in the preset order as the new first reference cell in turn, and repeatedly trigger module M2.3 until all cells in SortedHCellList are processed to form a new row cell set list.

9. The hierarchical table detection and recognition system according to claim 6, wherein The said module M3 includes: Module M3.1: Sort the row cell set objects in the row cell set list RowCellList in ascending order according to x and y; where x and y are the coordinates of the upper left corner of the cell; Module M3.2: Extract the row cell set objects from the sorted row cell set list RowCellList in sequence; Module M3.3: Sort the cells of the current row cell set object in descending order according to the width to form a SortedWCellList list; Module M3.4: Initialize a column cell set list ColCellList for storing the column cell set objects ColCellGroup in the current row cell set; let the first cell in SortedWCellList be the second reference cell; Module M3.5: Traverse the column cell set list, and judge the relationship between the main axis stem cell of each column cell set and the second reference cell. If they belong to the same column, add the second reference cell object to the corresponding column cell set object; if the second reference cell and all column cell set objects in the column cell set list do not belong to the same row, create a new column cell set object using the second reference cell and add it to the column cell set list; Export the cell objects from SortedWCellList in the preset order as the new second reference cell in turn, and repeatedly trigger module M3.5 until all cells in SortedWCellList are processed to form a new column cell set list; Repeatedly trigger module M3.2 to module M3.5 until all row cell set objects are extracted.

10. The hierarchical table detection and recognition system according to claim 6, wherein Module M4 includes: Module M4.1: In the list of formed column cell group sets, sequentially obtain ColCellGroup in the preset order; Module M4.2: Determine the cell format of ColCellGroup. If there is only one cell in the current ColCellGroup, add it to the comprehensive list in the preset order. Otherwise, after splitting the cells, repeatedly trigger Module M2 until there is only one cell in all ColCellGroups; Module M4.3: Traverse all ColCellGroup objects in the list of column cell group sets and output the comprehensive list; among them, in the comprehensive list, the list of row cell group sets contains multiple RowCellGroups, and each column of each RowCellGroup corresponds to a ColCellGroup.

Citation Information

Patent Citations

  • Table detection and content extraction method and system based on image processing

    CN119323799A

Cited By

  • Complex table recognition method and system

    CN121600537A

  • A complex table recognition method and system

    CN121600537B

  • Method and system for identifying grid format object in robotic process automation environment

    US12737337B2