Table extraction method and system, electronic equipment and storage medium
By generating a mask map and performing erosion and expansion, combined with corner point coordinates for matching, the problem of poor compatibility of table extraction methods in the existing technology is solved, efficient extraction and backfilling of various types of tables is achieved, and extraction accuracy and efficiency are improved. .
Patent Information
- Application Number
- CN202410644274.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-23
- Publication Date
- 2024-09-06
AI Technical Summary
Table extraction methods in the prior art have poor compatibility and cannot adapt to tables with diverse structures and forms, resulting in poor extraction results.
Generate a mask map through the corner coordinates of the text area in the table image, perform erosion and expansion to obtain the corner coordinates of the cell, and match the corner coordinates of the text area and cells to achieve table extraction and backfilling.
It realizes the cell extraction of various types of tables, improves the accuracy and efficiency of extraction, overcomes the defects of poor compatibility and poor extraction effect in traditional solutions, and has strong practicality and compatibility.
Smart Images

Figure CN118609148A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a table extraction method, system, electronic equipment and storage medium. Background Art
[0002] Document form processing is something people often face in their daily work and daily life. However, for the sake of aesthetics and ease of viewing, most forms currently exist in non-editable forms, such as pictures, scanned files, etc. This makes it very difficult to extract forms and the electronicization of form information is difficult.
[0003] At present, the extraction of tables, information entry, and proofreading in non-editable documents are mostly done manually, which inevitably consumes a lot of time and energy, and there are also great operational risks. Based on this, automated table extraction methods have emerged, but the current table extraction methods cannot adapt to tables with diverse structures and changing forms. They have poor compatibility and cannot extract various types of tables, and the results are often worrying. Summary of the invention
[0004] The present invention provides a table extraction method, system, electronic device and storage medium, which are used to solve the defects of poor compatibility of the table extraction method in the prior art, inability to adapt to tables of various forms, and poor extraction effect, break through the limitation of table types, realize various types of table extraction, and ensure the extraction effect.
[0005] The present invention provides a table extraction method, comprising:
[0006] Determine the table image to be extracted;
[0007] Performing text detection on the table image to obtain text areas in the table image and the coordinates of corner points of each text area;
[0008] Based on the corner point coordinates of each text area, a mask image of the table image is generated, and the mask image is corroded and expanded to obtain the corner point coordinates of the cells in the table image;
[0009] Based on the corner point coordinates of each text area, the corner point coordinates of each cell, and the text content of each text area, the table corresponding to the table image is determined.
[0010] According to a table extraction method provided by the present invention, the mask image of the table image is generated based on the corner point coordinates of each text area, and the mask image is corroded and expanded to obtain the corner point coordinates of the cells in the table image, including:
[0011] Generate a single-channel image based on the coordinates of the corner points of the table in the table image;
[0012] Determine a mask image of the table image based on the corner point coordinates of each text area and the single-channel image;
[0013] Determining a target size based on an image size of the mask image;
[0014] The mask image is corroded and expanded by using a convolution kernel of the target size to obtain the corner point coordinates of the cells in the table image.
[0015] According to a table extraction method provided by the present invention, the determining of the table corresponding to the table image based on the corner point coordinates of each text area, the corner point coordinates of each cell, and the text content of each text area includes:
[0016] Based on the coordinates of the corner points of the text regions and the coordinates of the corner points of the cells, the text regions are matched with the cells to obtain the corresponding relationship between the text regions and the cells;
[0017] Based on the corresponding relationship and the text content of each text area, the text content is inserted into each cell to obtain a table corresponding to the table image.
[0018] According to a table extraction method provided by the present invention, the correspondence between any text area and a cell is determined based on the following steps:
[0019] Based on the coordinates of the corner points of the any text area and the coordinates of the corner points of the cells, determining the area of the overlapped region between the any text area and the cells;
[0020] From each overlapping region, the overlapping region with the largest area is selected as the target overlapping region, and the cell corresponding to the target overlapping region is used as the cell corresponding to any text region to obtain the corresponding relationship between any text region and the cell.
[0021] According to a table extraction method provided by the present invention, the step of determining a table image to be extracted includes:
[0022] Get the initial table image;
[0023] Performing seal detection on the initial table image to obtain the seal area and seal color in the initial table image;
[0024] Based on the seal color, channel filtering is performed on the seal area in the initial table image to obtain the table image.
[0025] According to a table extraction method provided by the present invention, the method of performing channel filtering on the seal area in the initial table image based on the seal color to obtain the table image includes:
[0026] Based on the seal color, channel filtering is performed on the seal area in the initial table image to obtain a target table image;
[0027] Performing table detection on the target table image to obtain original corner point coordinates of the table area in the target table image;
[0028] Based on the original corner point coordinates, determine the target corner point coordinates, and based on the target corner point coordinates, perform perspective transformation on the table area in the target table image;
[0029] Direction recognition is performed on the table area obtained by perspective transformation, and angle correction is performed on the table area obtained by perspective transformation based on the recognition result to obtain the table image.
[0030] According to a table extraction method provided by the present invention, the table corresponding to the table image is determined, and then the method further includes:
[0031] Displaying the table image and the table on the same screen;
[0032] When a proofreading operation is received for any cell in the displayed table, the method jumps from the any cell in the table to a cell corresponding to the any cell in the table image based on the corner point coordinates of the cells.
[0033] The present invention also provides a table extraction system, comprising:
[0034] An image determination unit, used for determining a table image to be extracted;
[0035] A text detection unit, used to perform text detection on the table image to obtain text areas in the table image and the coordinates of corner points of each text area;
[0036] An erosion and dilation unit, used to generate a mask image of the table image based on the corner point coordinates of each text area, and perform erosion and dilation on the mask image to obtain the corner point coordinates of the cells in the table image;
[0037] The table extraction unit is used to determine the table corresponding to the table image based on the corner point coordinates of each text area, the corner point coordinates of each cell, and the text content of each text area.
[0038] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the table extraction methods described above when executing the program.
[0039] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the table extraction method described in any one of the above is implemented.
[0040] The table extraction method, system, electronic device and storage medium provided by the present invention generate a mask image through the corner point coordinates of the text area in the table image, and corrode and expand the mask image to obtain the corner point coordinates of each cell, breaking the restriction of table type on table extraction and realizing cell extraction of various tables. On this basis, the text content of each text area is backfilled in combination with the corner point coordinates of each text area to obtain the table corresponding to the table image, overcoming the defects of poor compatibility of the table extraction method in the traditional scheme, inability to adapt to tables of various forms and poor extraction effect, realizing various types of table extraction, improving extraction accuracy and extraction efficiency, and being easy to implement and deploy, with strong practicality and good compatibility. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0042] Figure 1 It is a flow chart of the table extraction method provided by the present invention;
[0043] Figure 2 is an example diagram of a table image provided by the present invention;
[0044] Figure 3 is an example diagram of a table corresponding to the table image provided by the present invention;
[0045] Figure 4 It is an overall flow chart of the table extraction method provided by the present invention;
[0046] Figure 5 It is a structural schematic diagram of the table extraction system provided by the present invention;
[0047] Figure 6 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] In recent years, neural networks and deep learning technologies have made great breakthroughs and have been widely used in many fields. The implementation of neural networks has theoretical guarantees. However, extracting tables from non-editable documents is still a complex problem. The main reason is that the structure of tables is diverse and the form is changeable. This means that the table extraction method needs to adapt to this changeable table to ensure the extraction effect. However, the current extraction methods often find it difficult to achieve this, which leads to poor adaptability and poor results.
[0050] In short, in actual use, the borders of tables are diverse, and borders are an important feature of tables. Therefore, variable borders (such as full borders, half borders, no borders, etc.) will lead to diverse structures and varied forms of tables. Tables with diverse structures and varied forms put forward higher requirements on the compatibility of current extraction methods, which are often difficult to achieve at present.
[0051] In this regard, the present invention provides a table extraction method, which aims to extract the corner point coordinates of each cell through the corner point coordinates of the text area in the table image, breaking the restriction of table type on table extraction, realizing cell extraction of various types of tables, and on this basis, backfilling is performed based on the text content to obtain the table corresponding to the table image, realizing various types of table extraction, improving the extraction accuracy and extraction efficiency, and having strong practicality and good compatibility. Figure 1 It is a flow chart of the table extraction method provided by the present invention, such as Figure 1 As shown, the execution subject of the method is a table extraction system, and the method includes:
[0052] Step 110, determining the table image to be extracted;
[0053] Step 120, performing text detection on the table image to obtain text regions in the table image and the coordinates of corner points of each text region.
[0054] Specifically, before performing table extraction, it is first necessary to determine the table image to be extracted, which contains the extraction object, that is, the table to be extracted. In order to ensure the pertinence and accuracy of table extraction and avoid wrong lines, garbled characters, etc., in the embodiment of the present invention, each table image only contains a single table and does not contain text information outside the table.
[0055] The table image to be extracted may be an image in the form of a document, that is, a document image, or an image cut / separated from a scanned document, or a picture, which is not specifically limited in the embodiment of the present invention.
[0056] It can be understood that in the actual table extraction process, after the user uploads the document containing the extraction object, the table extraction system receives the document and can analyze the document, analyze its document information, and determine the document type. If the uploaded document is a picture, the table image can be determined based on this, pending the subsequent table extraction process; conversely, if the uploaded document is not a picture but a document, the document can be parsed to obtain the table image, that is, the scanned file (such as a PDF (Portable Document Format) file) can be parsed to cut it into single-page images, and the image containing the extraction object can be selected therefrom to obtain the table image.
[0057] Since a document often contains more than a single table, and the tables are not necessarily distributed in a concentrated manner, there may be multiple table images to be extracted. In the case of multiple table images, it is necessary to perform table extraction on the table images one by one to extract the table in each table image, thereby completing the table extraction for the entire document.
[0058] Here, the table image can be obtained by the user by capturing the table in the paper document through the image capture device, or it can be downloaded by the user from the Internet, or received through network communication, or it can be intercepted by the user from historical files. For example, financial statements can be searched / finded from the company's annual report files, and the table image can be separated or intercepted from the financial statements.
[0059] After obtaining the table image, text detection can be performed on the table image to locate the text area in the table image and determine the coordinates of the corner points of each text area. That is, the area where the text is located in the table image can be determined through text detection, and the text area can be segmented to determine the position of the corner points of the text area based on this, that is, determine the positions of the four corner points of each text area in the table image, thereby obtaining the coordinates of the four corner points of the text area.
[0060] Here, specifically, a text detection model can be used to perform text detection on a table image to obtain the text area in the table image and determine the coordinates of the corner points of each text area. That is, the table image can be input into the text detection model, so that the text detection model performs text detection on the input table image, and outputs the text areas therein accordingly, and then determines the coordinates of the corner points of each text area. The text detection model here can adopt the DB (Differentiable Binarization) text detection algorithm, which can directly locate the area where the text is located and segment the text area. Then, the coordinates of the four corner points of the text area, that is, the coordinates of the corner points of each text area, can be determined by OpenCV.
[0061] Step 130, generating a mask image of the table image based on the corner point coordinates of each text area, and performing erosion and dilation on the mask image to obtain the corner point coordinates of the cells in the table image;
[0062] Step 140, based on the corner point coordinates of each text area, the corner point coordinates of each cell, and the text content of each text area, determine the table corresponding to the table image.
[0063] Specifically, after obtaining the corner point coordinates of each text area through step 120, the cell position can be determined based on this to obtain the corner point coordinates of each cell, and on this basis, combined with the corner point coordinates of each text area and the text content of each text area, the extracted table is determined, that is, the table corresponding to the table to be extracted in the table image.
[0064] It can be understood that after obtaining the corner point coordinates of each text area, the corner point coordinates of each cell in the table in the table image can be determined based on the corner point coordinates, that is, a MASK image can be generated based on the corner point coordinates of each text area in the table image, that is, the mask image corresponding to the table image, and then, on this basis, the corrosion and expansion methods can be used to extract the table separators to determine the table structure, thereby obtaining the corner point coordinates of each cell in the table image.
[0065] Specifically, considering the position of the table frame line division, that is, the fact that there is no text at the intersection of the frame lines in the table, the embodiment of the present invention can use the corner point position of each text area to determine the position that does not contain text content, and connect the dividing frame lines in the place without text content to determine the intersection of each dividing frame line, so that the corner point coordinates of each cell can be obtained.
[0066] Here, specifically, a mask map of the table image can be generated based on the corner point coordinates of each text area. That is, the corner point positions of each text area in the table image can be used to generate a mask map of the size of the table, so that the frame line information of the table in the table image can be determined based on this mask map, thereby extracting the corner point coordinates of each cell in the table.
[0067] That is, after obtaining the mask image of the table image, the embodiment of the present invention can use the corrosion and expansion method to process the mask image to obtain the corner coordinates of each cell. Specifically, the mask image can be corroded and expanded to determine the table frame line in the mask image, thereby obtaining the frame line information of the table in the table image. Then, the intersection of the table frame line and the coordinates at the intersection can be determined based on this frame line information, thereby obtaining the corner coordinates of each cell.
[0068] It is noteworthy that the method adopted in the embodiment of the present invention for parsing the table structure is based on image morphology. A mask map is generated through the corner point coordinates of each text area, and then the mask map is corroded and expanded to obtain the corner point coordinates of each cell. This process is related to the position of the text area in the table image, but has nothing to do with the table type. No matter how varied the frame lines of the table are or what type they are, the table structure can be parsed to extract the frame line information, and then the corner point coordinates of each cell are determined, thus realizing structural parsing of various types of tables and cell extraction of various types of tables, breaking the dependence on the table outline and breaking the limitation of the table type on table extraction. It has strong adaptability and compatibility, and improves the accuracy and feasibility of table extraction.
[0069] Furthermore, after extracting the corner point coordinates of each cell, the table in the table image, that is, the table to be extracted, can be extracted based on the corner point coordinates, as well as the corner point coordinates and text content of each text area. That is, the text content of each text area can be determined first, and then the matching relationship between each text area and each cell area can be determined based on the corner point coordinates of each text area and the corner point coordinates of each cell, so that the text content can be filled into the corresponding cell based on this matching relationship, and finally the table to be extracted is generated.
[0070] Specifically, here the text content of each text area can be identified first, that is, text recognition can be performed on each text area to obtain the text content corresponding to each text area. Specifically here, text recognition can be performed using a text recognition model in a deep learning model, that is, each text area can be input into the text recognition model, so that the text recognition model performs text recognition on each input text area to obtain the recognition result of each text area, and output it accordingly, and finally the text content of each text area output by the text recognition model can be obtained.
[0071] Here, the text recognition model can be an existing trained model, or a pre-built initial model, based on which samples and labels are applied for training. The initial model can be constructed on the basis of a convolutional recurrent neural network (CRNN).
[0072] Subsequently, the table corresponding to the table image can be determined based on the text content of each identified text area, as well as the corner point coordinates of each text area and the corner point coordinates of each cell. That is, considering that the cells and text content in the table are often corresponding, even if there is no text content in some cells, there are still corresponding areas, but the text content of the area is empty. Based on this, in an embodiment of the present invention, the matching relationship between each text area and each cell area can be first determined through the corner point coordinates of each text area and the corner point coordinates of each cell, that is, the corresponding relationship between the two, so that it can be clear which cell each text area corresponds to through this corresponding relationship. In other words, it is necessary to determine the cell into which each text content needs to be filled, so as to insert the text content accordingly, that is, the text content of each text area can be filled into the corresponding cell according to the matching relationship, and finally the table corresponding to the table image can be obtained.
[0073] In an embodiment of the present invention, a top-down approach is adopted when backfilling the text content of a table. By matching the corner point coordinates of each cell with the corner point coordinates of each text area, the correspondence between the two is determined, and the text is backfilled based on the correspondence, thereby obtaining a table corresponding to the table image. This not only ensures the accuracy of text content insertion, but also improves the efficiency of text backfilling. The larger the scale of the table, the more obvious its efficiency is. In addition, this method occupies small computing resources, has strong operability, and has strong practicality.
[0074] The table extraction method provided by the present invention generates a mask image through the corner point coordinates of the text area in the table image, and corrodes and expands the mask image to obtain the corner point coordinates of each cell, breaking the restriction of the table type on the table extraction and realizing the cell extraction of various tables. On this basis, the text content of each text area is backfilled in combination with the corner point coordinates of each text area to obtain the table corresponding to the table image, overcoming the defects of the poor compatibility of the table extraction method in the traditional scheme, being unable to adapt to tables of various forms and having poor extraction effect, realizing the extraction of various types of tables, improving the extraction accuracy and efficiency, and being easy to implement and deploy, with strong practicality and good compatibility.
[0075] Based on the above embodiment, step 130 includes:
[0076] Generate a single-channel image based on the coordinates of the corner points of the table in the table image;
[0077] Based on the corner coordinates of each text area and the single-channel image, a mask map of the table image is determined;
[0078] Determine the target size based on the image size of the mask image;
[0079] The mask image is corroded and expanded through the convolution kernel of the target size to obtain the corner coordinates of the cells in the table image.
[0080] Specifically, in step 130, a mask image of the table image is generated according to the corner coordinates of each text area, and the mask image is corroded and expanded to obtain the corner coordinates of the cells in the table image. In essence, the image morphology method is used to find the position information of each cell through the position information (corner coordinates) of each text area. This process specifically includes:
[0081] First, a mask image corresponding to the table image can be generated according to the position information of each text area. The area corresponding to each text area in the mask image is black, that is, the pixel value is 0, and the area not corresponding to the text area is white, that is, the pixel value is 255.
[0082] Specifically, a single-channel image may be generated according to the coordinates of the corner points of the table in the table image, that is, an image of the table size and with pixel values of 255 is generated with reference to the coordinates of the corner points of the table in the table image, that is, a pure white single-channel image of the same size as the table is obtained;
[0083] The pure white single-channel image is then processed to set the pixel values of the corner point coordinates of each text area in the corresponding area to zero, that is, the area corresponding to each text area in the single-channel image corresponding to the table image is determined through the corner point coordinates of each text area, and the pixel values of this part of the area are set to zero to fill it with black, thereby obtaining a mask image.
[0084] Subsequently, the mask image can be eroded and expanded to obtain the frame line information of the table in the table image, and then the intersection points of the table frame lines and the coordinates of the intersection points can be determined based on the frame line information, thereby obtaining the corner point coordinates of each cell.
[0085] That is, after obtaining the mask image, the mask image can be eroded by a convolution kernel to determine the table frame line in the mask image, thereby obtaining the frame line information of the table in the table image. Specifically, a convolution kernel with a length equal to the length and width of the mask image can be used to perform an erosion operation to obtain the table frame line, and the coordinates of the corner points of each cell can be determined based on the table frame line.
[0086] Specifically, the size of the convolution kernel used for the erosion operation can be determined first here, and in order to ensure the accuracy of the obtained table frame line, in an embodiment of the present invention, a convolution kernel that matches the size of the table needs to be used for the erosion operation, and the size of the mask image is consistent with the size of the table. Therefore, the size of the convolution kernel can be determined according to the size of the mask image, that is, the size of the mask image can be used as the target size, and the mask image can be eroded by the convolution kernel of this target size. Specifically, the mask image can be eroded using a convolution kernel with a length equal to the length of the mask image and a convolution kernel with a length equal to the width of the mask image, respectively, to obtain the horizontal and vertical frame lines of the table; then, on this basis, OpenCV is used to determine the corner point position (corner point coordinates) of each cell, that is, the coordinates of the four corner points of each cell.
[0087] For example, when the length of the mask image is W and the width is H, the convolution kernel with a length of W can be used to perform an erosion operation on the mask image to obtain the horizontal frame line of the table in the mask image, and the convolution kernel with a length of H can be used to perform an erosion operation on the mask image to obtain the vertical frame line of the table. By superimposing the horizontal frame line and the vertical frame line, the overall frame line of the table, that is, the frame line information of the table, can be obtained.
[0088] In an embodiment of the present invention, based on an image morphology method, the coordinates of the corner points of each cell are extracted on the basis of the coordinates of the corner points of each text area, thereby realizing cell extraction of various types of tables, breaking the restrictions of the table type on cell extraction, and breaking away from the dependence on the table outline, so that the determination of the cell position is only related to the position of the text area and has nothing to do with the table type. No matter how changeable the frame lines of the table are or what type they are, it is able to parse the table structure, thereby extracting the frame line information, and then determining the corner point coordinates of each cell. It has extremely strong adaptability and compatibility, and improves the accuracy and feasibility of table extraction.
[0089] Based on the above embodiment, step 140 includes:
[0090] Based on the coordinates of the corner points of each text area and the coordinates of the corner points of each cell, each text area and each cell are matched to obtain the corresponding relationship between each text area and each cell;
[0091] Based on the corresponding relationship and the text content of each text area, the text content is inserted into each cell to obtain a table corresponding to the table image.
[0092] Specifically, in step 140, the process of determining the table corresponding to the table image according to the corner point coordinates of each cell, and the corner point coordinates and text content of each text area includes:
[0093] It is understandable that after parsing the table structure through image morphology methods and obtaining the corner coordinates of each cell, the table in the table image can be extracted based on the corner coordinates, as well as the corner coordinates and text content of each text area.
[0094] Specifically, the text content of each text area can be determined here, that is, text recognition can be performed on each text area to obtain the text content corresponding to each text area. The text recognition process here can be implemented by the text recognition model in the deep learning model, and then the matching relationship between each text area and each cell area is determined based on the corner point coordinates of each text area and the corner point coordinates of each cell, so that the text content can be filled into the corresponding cell according to this matching relationship, and finally the required extracted table is generated.
[0095] That is, the matching relationship between each text area and each cell area can be determined based on the corner point coordinates of each text area and the corner point coordinates of each cell. That is, the corner point coordinates of each text area and the corner point coordinates of each cell can be used as a reference to match each text area and each cell to determine the cell corresponding to each text area, thereby obtaining the corresponding relationship between the two. That is, the corresponding relationship between each text area and each cell can be obtained through area matching based on corner point coordinates.
[0096] Here, through this correspondence, it can be clear which cell each text area corresponds to. In other words, the cell into which the text content of each text area needs to be filled can be determined based on this correspondence, so that the subsequent text backfilling process can proceed steadily and orderly.
[0097] Afterwards, the table corresponding to the table image can be determined based on this correspondence and the text content of each text area, that is, the text content can be inserted based on this correspondence to obtain the table corresponding to the table image. Specifically, the text content can be inserted into each cell based on this correspondence and the text content of each text area, that is, the text content of each text area is filled into the corresponding cell to obtain the table corresponding to the table image.
[0098] Based on the above embodiment, the correspondence between any text area and a cell is determined based on the following steps:
[0099] Based on the coordinates of the corner points of the text area and the coordinates of the corner points of each cell, determining the area of the overlapping region between the text area and each cell;
[0100] From each overlapping region, the overlapping region with the largest area is selected as the target overlapping region, and the cell corresponding to the target overlapping region is used as the cell corresponding to the text region, so as to obtain the corresponding relationship between the text region and the cell.
[0101] Specifically, the process of determining the correspondence between any text area and a cell includes:
[0102] Considering the accuracy of matching between text content and cells in actual application, in the embodiment of the present invention, the intersection method is adopted to perform matching based on the principle of maximum intersection to obtain the corresponding relationship between each text area and each cell.
[0103] Based on this, in an embodiment of the present invention, the corner point coordinates of the text area and the corner point coordinates of each text area can first be used to calculate the overlapping area to determine whether there is an overlapping area between the text area and each cell area. If there is an overlapping area, the area area of the overlapping area is calculated. If there is no overlapping area, the area area of the overlapping area can be recorded as 0, thereby obtaining the area area of the overlapping area between the text area and each cell.
[0104] After that, according to the principle of maximum intersection, based on the area of the overlapping area, the overlapping area with the largest area can be selected from each overlapping area as the target overlapping area, and the cell corresponding to the target overlapping area can be used as the cell corresponding to the text area. In short, the cell with the largest intersection is selected as the cell corresponding to the text area, that is, the cell into which the text content of the text area needs to be filled. After obtaining the correspondence between each text area and each cell, the text backfill can be performed from top to bottom based on this correspondence to fill each text content into the corresponding cell, thereby obtaining a table corresponding to the table image.
[0105] In the embodiment of the present invention, according to the maximum intersection principle, a top-down approach is adopted when backfilling the text content of a table. By determining the cells corresponding to each text area, the text is backfilled to obtain a table corresponding to the table image. This not only ensures the accuracy of text content insertion, but also greatly improves the efficiency of text backfilling. The efficiency is more obvious on larger tables. In addition, this text backfilling method has extremely fast recognition, small resource usage, strong operability, and strong practicality.
[0106] Based on the above embodiment, step 110 includes:
[0107] Get the initial table image;
[0108] Perform seal detection on the initial table image to obtain the seal area and seal color in the initial table image;
[0109] Based on the seal color, channel filtering is performed on the seal area in the initial table image to obtain a table image.
[0110] Specifically, in step 110, the process of determining the table image to be extracted specifically includes:
[0111] Taking into account that most of the current documents, especially those containing reports, are usually stamped with company seals to ensure the validity of the information, that is, most documents are covered with bright red or blue seals. The presence of the seal will not only affect the parsing of the table structure, but also affect text recognition, thereby reducing the accuracy of the text content. Therefore, in an embodiment of the present invention, before parsing the table structure and recognizing the text content, it is necessary to erase the seal to ensure the accuracy of the subsequent table structure parsing and text recognition.
[0112] In view of this, in an embodiment of the present invention, when determining the table image to be extracted, it is first necessary to obtain the initial table image. The initial table image here can be understood as an unprocessed table image, that is, the table image directly uploaded by the user and obtained by the table extraction system, or the image containing the table obtained by directly parsing and separating the scanned file uploaded by the user.
[0113] Next, the initial table image can be subjected to seal erasure to fade / remove the seal therein, thereby obtaining a table image after the seal is faded / erased, that is, the initial table image can be subjected to seal detection to detect the area where the seal is located and the color of the seal, thereby obtaining the detection result, namely the seal area and the seal color.
[0114] Specifically, the target detection model can be used here to detect the seal in the initial table image to detect the position and color of the seal, so as to obtain the seal color (red or blue) and the position of the seal (the upper left corner coordinates and the lower right corner coordinates of the seal) output by the target detection model, and the seal area can be determined accordingly. The target detection model here can be a general high-performance detection model, for example, the open source model yolov8.
[0115] Subsequently, channel filtering can be performed on the seal area to erase / fade the seal, thereby obtaining a table image after the seal is erased, that is, the table image to be extracted. That is, the color of the seal is filtered by channel filtering to achieve the purpose of erasing / fading the seal. Specifically, channel filtering can be performed on the seal area according to the seal color to obtain the filtered image, that is, the table image to be extracted.
[0116] Specifically, the seal area can be color filtered here, so that when the seal color is red, the G and B channels are filtered and only the R channel is retained; correspondingly, when the seal color is blue, the R and G channels are filtered and only the B channel is retained (the image can be represented by three channels of R, G, and B), thereby obtaining a filtered single-channel regional image corresponding to the seal area, and then the single-channel regional image can be restored to three channels (R, G, B), and replaced with the original seal area, thereby obtaining a replaced table image, that is, the table image to be extracted. Here, the seal area in the initial table image is actually backfilled using channel filtering and restored to a three-channel regional image, thereby obtaining the table image to be extracted.
[0117] It should be noted that, in the table image after the seal erasure process, the seal can be basically erased or significantly faded, so as to avoid the impact on the subsequent table structure analysis and text recognition to the greatest extent.
[0118] In an embodiment of the present invention, from the perspective of implementation during actual use, a seal that may be present in an initial table image is erased / faded to obtain a table image after the seal is faded / erased, and table extraction is performed based on this table image, thereby avoiding cell extraction errors and text content recognition errors caused by seals, and ensuring the accuracy of table structure parsing during the table extraction process and the accuracy of subsequent text recognition.
[0119] Based on the above embodiment, based on the seal color, channel filtering is performed on the seal area in the initial table image to obtain a table image, including:
[0120] Based on the seal color, channel filtering is performed on the seal area in the initial table image to obtain the target table image;
[0121] Perform table detection on the target table image to obtain the original corner point coordinates of the table area in the target table image;
[0122] Based on the original corner point coordinates, the target corner point coordinates are determined, and based on the target corner point coordinates, a perspective transformation is performed on a table area in the target table image;
[0123] Direction recognition is performed on the table area obtained by perspective transformation, and angle correction is performed on the table area obtained by perspective transformation based on the recognition result to obtain a table image.
[0124] Taking into account the actual operation process, improper shooting operation, scanning equipment failure, etc., the obtained table image will be distorted and the picture background will be messy. That is, due to abnormal conditions in the scanning and shooting process, the obtained table image will inevitably appear unclear, skewed, miscut, etc., and these problems will increase the difficulty of subsequent table extraction, reduce the accuracy of table structure analysis and text recognition, and result in poor table extraction effect.
[0125] Based on this, in the embodiment of the present invention, after the seal is erased / faded, the table image after the seal is erased / faded needs to be processed to correct the distortion and remove the messy background, so as to obtain the final table image to be extracted.
[0126] Specifically, first, channel filtering can be performed on the seal area in the initial table image according to the seal color to filter the color of the seal area, so as to achieve the purpose of erasing / fading the seal, thereby obtaining the erased / faded table image. Since the table image at this time cannot be directly used as the final table image for table extraction, it needs to be further processed. Therefore, it can be called the target table image at this time.
[0127] Then, the target table image can be subjected to table detection to locate the table area therein and determine the corner point positions of the table area, that is, the coordinates of the four corner points of the table area, and the coordinates of the four corner points detected at this time are regarded as the original corner point coordinates of the table area.
[0128] Specifically, since a document usually consists of a header, a footer, a main text, an image, a table, etc., and the table image separated therefrom often also carries these table components, in order to remove background interference, in an embodiment of the present invention, table detection can be first performed on the target table image obtained in the previous step to determine the table area and extract the coordinates of the four corner points of the table area. Specifically, a corner point detection model can be used to perform table detection on the target table image to regress the coordinates of the four corner points of the table in the image (the four corner points in a clockwise direction starting from the upper left corner point) and use them as the original corner point coordinates.
[0129] Among them, the backbone and neck of the corner detection model use the original structure of yolov8-tiny, but the detection head is adjusted. The detection head no longer regresses the center coordinates and length and width values, but the coordinates of the four corner points of the table. The reason is that in order to enable the subsequent distortion correction to be carried out in sequence, when the table is detected through the corner detection model, the coordinates of the four corner points of the table area must be obtained, rather than the center coordinates, so as to ensure the sequential execution of distortion correction. And the loss function of the adjusted corner detection model uses Wing Loss and BCE Loss (Binary CrossEntropy Loss) binary cross entropy loss.
[0130] Afterwards, the table distortion correction can be performed based on the extracted original corner point coordinates to correct the deformation of the area, thereby obtaining a corrected table image. Specifically, the original corner point coordinates can be used to first determine the corresponding target corner point coordinates, that is, referring to the original corner point coordinates, taking the maximum values in each direction to determine the minimum rectangle that can surround the table area, and taking the coordinates of the minimum rectangle (the upper left corner point coordinates are (0, 0)) as the target corner point coordinates, and then the table area can be deformed and corrected based on the target corner point coordinates to obtain the corrected table area. Specifically, perspective transformation can be used for extraction and correction to obtain the table area after perspective transformation and extract it. The table frame line of the extracted table area is horizontal and vertical, and the distortion is corrected by perspective transformation to eliminate the interference caused by deformation.
[0131] In an embodiment of the present invention, corner point detection is performed based on the improved target detection model to obtain the original corner point coordinates, and the target corner point coordinates are determined accordingly, so that perspective transformation can be performed according to the target corner point coordinates to obtain a corrected image, eliminating the interference of image deformation on the subsequent table extraction process, and improving the accuracy and efficiency of table extraction.
[0132] Furthermore, taking into account problems such as shooting errors and table size, the table in the acquired table image is not 0° upward, but has a certain rotation angle (such as a table that is too large will be rotated 90°). In order to further improve the efficiency of subsequent text recognition and enhance recognition accuracy, in an embodiment of the present invention, the angle of the table can be corrected before the final table image is determined to convert it into an image with the text 0° upward, that is, the text is rotated to be positive to obtain the final table image to be extracted.
[0133] Specifically, after obtaining the table area after perspective transformation, that is, the table area corrected and extracted by perspective transformation, the table area can be directionally identified to identify the rotation angle of the text in the table area, thereby obtaining the recognition result. Here, specifically, an angle detection model can be used to perform direction identification on the table area, thereby obtaining the rotation angle output by the angle detection model.
[0134] Among them, the angle detection model is a classification model, such as the mobilenetv3 model, and the loss function used in model training is a cross entropy loss function based on label smoothing.
[0135] After obtaining the rotation angle output by the model (any one of 0, 90, 180, 270°), the table area obtained by perspective transformation can be angle corrected according to the rotation angle to obtain a table image. Since the rotation angle obtained by model detection is a clockwise rotation angle, the table area can be rotated counterclockwise by the same angle as the rotation angle to achieve angle correction and obtain the corrected table area, which is used as the final table image to be extracted.
[0136] Based on the above embodiment, the table corresponding to the table image is determined, and then the following steps are further included:
[0137] Display the table image and table on the same screen;
[0138] When a proofreading operation is received for any cell in the displayed table, based on the corner coordinates of each cell, the cell in the table is jumped to the cell corresponding to the cell in the table image.
[0139] Specifically, considering that after the table extraction is completed, in order to ensure the consistency of the extracted table with the table in the original table image, manual proofreading is often required, so as to complete the extraction and entry of the table in the entire non-editable document and realize the electronicization of the table. However, the current processing of tables in non-editable documents mostly only involves the aforementioned table extraction, while ignoring post-processing. When faced with huge table data, subsequent manual proofreading often requires a lot of time and effort, which reduces the efficiency of entering table information and electronicization of the table, and slows down the process. In short, the lack of a suitable proofreading mechanism during manual proofreading after the extraction is completed will result in a lot of time spent on verification and proofreading.
[0140] Based on this, it is proposed in an embodiment of the present invention that after the table corresponding to the table image is extracted, the table image and the table can be displayed on the same screen, so that the proofreader can see the displayed table image and the extracted table on the same display screen, thereby facilitating the proofreader to check and proofread to confirm the accuracy of the information in the extracted table.
[0141] Furthermore, after completing the display of the table image and the table, if the proofreader needs to confirm whether the text content of any cell in the extracted table is incorrect, he can enter a proofreading operation at this time. The proofreading operation here can be any one of a click operation, a sliding operation, a check operation, etc. The table extraction system can receive this proofreading operation and can jump based on the proofreading operation. Since the corner point coordinates of each cell are obtained through the aforementioned table extraction, the corner point coordinates can be used as a reference for cell jumping at this time. That is, based on the corner point coordinates of each cell, the proofreader can jump from the cell where the proofreader enters the proofreading operation to the corresponding cell in the table image, so that the proofreader can compare and check the contents of the cells before and after the jump to confirm whether the recognized text content is incorrect, thereby completing the proofreading of the cell.
[0142] In an embodiment of the present invention, after the table in the table image is obtained through table extraction, a display method is also provided to facilitate verification and checking by proofreaders. The table image and the extracted table can be displayed on the same display screen, and when a proofreading operation is received, the screen jumps from the current proofreading position to the corresponding cell in the table image. This can help proofreaders to quickly match each cell in the table, thereby facilitating the verification of the text content identified in each cell to confirm whether there is an error, and then corresponding adjustments can be made, thereby realizing the rapid entry of the table and ensuring the accuracy and validity of the entered table information.
[0143] The following uses the table extraction system processing flow as an example to illustrate the above process:
[0144] Figure 2 is an example diagram of a table image provided by the present invention, Figure 3 is an example diagram of a table corresponding to the table image provided by the present invention, such as Figure 2 and Figure 3 As shown, after table image preprocessing (seal erasure, distortion correction and angle correction), table image text detection, image morphological-based structural analysis and text backfilling based on the maximum intersection principle, the table corresponding to the table image can be obtained, realizing the conversion from table image to table structured data. However, considering the ease of use in practical use, there is still a serious problem, that is, in the actual application process, there must be a manual review process for the recognized tables. If the aforementioned process is only to convert the table in the table image into Excel, the subsequent review pressure on the proofreaders is still very high, especially when faced with tables with huge amounts of data, such as annual reports, corporate financial statements, etc. The proofreaders need to compare each cell one by one, which is not only very cumbersome but also prone to errors.
[0145] Based on this, in order to achieve real cost reduction and efficiency improvement, it is imperative to propose an effective post-processing mechanism. In short, only when it is easy to identify and the proofreader reviews it after the identification is completed, can the manual workload be greatly reduced. For example, assuming that the manual extraction of the table in the table image takes 30 minutes, if the table is automatically extracted and subsequently manually reviewed, it can be reduced to 10 minutes. However, if an effective verification mechanism is used to facilitate proofreaders to check and verify, the entire process can be directly reduced to 1 minute. In this way, real cost reduction and efficiency improvement can be achieved, and the entire process can achieve maximum energy efficiency and have obvious advantages.
[0146] That is, after the aforementioned table extraction, the table corresponding to the table image can be obtained, that is, the json information of each table image recognition result can be obtained, which contains the corner coordinates of each cell and its corresponding text content. Then, the table extraction system backend can integrate them, that is, integrate the table image and the corresponding table, and give the integrated information to the front end, which can display the received information, such as split window display, with the table image on the left and the extracted table on the right (such as Figure 2 The table image shown can be displayed on the left side of the display, and the right side corresponds to the display Figure 3 The table shown in the figure can obtain all the information recognized from the table image by sliding the progress bar) so that the proofreader can check and proofread. After clicking any cell in the table at the front end, the proofreader can jump to the corresponding cell in the table image, so as to confirm whether the recognized text content is wrong by comparing the information before and after the jump, so as to confirm or correct it.
[0147] It is worth noting that the text content in each cell of the displayed table can be edited, confirmed and exported. In addition, the text content in each cell of the displayed table can be displayed separately, that is, the text area with low confidence in text recognition can be highlighted when displayed, so that the proofreader can know at a glance that there is doubt here and needs to be checked in detail, which can further save proofreading time and ensure proofreading efficiency and effectiveness.
[0148] In the embodiment of the present invention, the Pipeline is comprehensive and takes into account multiple aspects from document input to actual use. It can not only effectively improve the accuracy, effectiveness and compatibility of table extraction, but also simplify the subsequent review work, facilitate the review by proofreaders, achieve cost reduction and efficiency improvement at the practical application level, solve the difficulties in the application of table extraction solutions, and can be directly put into use. It is also easy to implement and deploy, which can reduce the manpower costs of enterprises, improve the operating efficiency of enterprises, and reduce operational risks.
[0149] Figure 4It is the overall flow chart of the table extraction method provided by the present invention, such as Figure 4 As shown, the method includes:
[0150] Step 400, obtaining an initial table image;
[0151] Step 411, performing seal detection on the initial table image to obtain the seal area and seal color in the initial table image;
[0152] Step 412, based on the seal color, channel filtering is performed on the seal area in the initial table image to obtain a target table image;
[0153] Step 413, performing table detection on the target table image to obtain the original corner point coordinates of the table area in the target table image;
[0154] Step 414, determining the target corner point coordinates based on the original corner point coordinates, and performing perspective transformation on the table area in the target table image based on the target corner point coordinates;
[0155] Step 415, performing direction recognition on the table area obtained by perspective transformation, and performing angle correction on the table area obtained by perspective transformation based on the recognition result to obtain a table image;
[0156] Step 420, performing text detection on the table image to obtain text regions in the table image and the coordinates of corner points of each text region;
[0157] Step 431, generating a single-channel image based on the coordinates of the corner points of the table in the table image;
[0158] Step 432, determining a mask image of the table image based on the corner point coordinates of each text region and the single-channel image;
[0159] Step 433, based on the image size of the mask image, determine the target size; use the convolution kernel of the target size to erode and dilate the mask image to obtain the corner point coordinates of the cells in the table image;
[0160] Step 441, based on the coordinates of the corner points of each text area and the coordinates of the corner points of each cell, each text area and each cell are matched to obtain a corresponding relationship between each text area and each cell;
[0161] Step 442, based on the corresponding relationship and the text content of each text area, the text content is inserted into each cell to obtain a table corresponding to the table image.
[0162] Among them, the correspondence between any text area and a cell is determined based on the following steps: based on the corner point coordinates of the text area and the corner point coordinates of each cell, the area of the overlapping area between the text area and each cell is determined; from each overlapping area, the overlapping area with the largest area is selected as the target overlapping area, and the cell corresponding to the target overlapping area is used as the cell corresponding to the text area, so as to obtain the correspondence between the text area and the cell.
[0163] Determine the table to which the table image corresponds, followed by:
[0164] The table image and the table are displayed on the same screen; when a proofreading operation is received for any cell in the displayed table, based on the corner point coordinates of each cell, the cell in the table is jumped to the cell corresponding to the cell in the table image.
[0165] The method provided by the embodiment of the present invention generates a mask image through the corner point coordinates of the text area in the table image, and corrodes and expands the mask image to obtain the corner point coordinates of each cell, breaking the restriction of the table type on table extraction and realizing the cell extraction of various tables. On this basis, the text content of each text area is backfilled in combination with the corner point coordinates of each text area to obtain the table corresponding to the table image, overcoming the defects of poor compatibility of the table extraction method in the traditional scheme, inability to adapt to tables of various forms, and poor extraction effect, realizing various types of table extraction, improving extraction accuracy and extraction efficiency, and being easy to implement and deploy, with strong practicality and good compatibility.
[0166] The table extraction system provided by the present invention is described below. The table extraction system described below and the table extraction method described above can be referenced to each other.
[0167] Figure 5 is a structural diagram of the table extraction system provided by the present invention, such as Figure 5 As shown, the system includes:
[0168] An image determination unit 510, used to determine a table image to be extracted;
[0169] A text detection unit 520, configured to perform text detection on the table image to obtain text regions in the table image and coordinates of corner points of each text region;
[0170] An erosion and dilation unit 530 is used to generate a mask image of the table image based on the corner point coordinates of each text area, and perform erosion and dilation on the mask image to obtain the corner point coordinates of the cells in the table image;
[0171] The table extraction unit 540 is used to determine the table corresponding to the table image based on the corner point coordinates of each text area, the corner point coordinates of each cell, and the text content of each text area.
[0172] The table extraction system provided by the present invention generates a mask image through the corner point coordinates of the text area in the table image, and corrodes and expands the mask image to obtain the corner point coordinates of each cell, breaking the restriction of the table type on table extraction and realizing the cell extraction of various tables. On this basis, the text content of each text area is backfilled in combination with the corner point coordinates of each text area to obtain the table corresponding to the table image, overcoming the defects of poor compatibility of the table extraction method in the traditional scheme, inability to adapt to tables of various forms, and poor extraction effect, realizing various types of table extraction, improving extraction accuracy and extraction efficiency, and being easy to implement and deploy, with strong practicality and good compatibility.
[0173] Based on the above embodiment, the corrosion expansion unit 530 is used to:
[0174] Generate a single-channel image based on the coordinates of the corner points of the table in the table image;
[0175] Determine a mask image of the table image based on the corner point coordinates of each text area and the single-channel image;
[0176] Determining a target size based on an image size of the mask image;
[0177] The mask image is corroded and expanded by using a convolution kernel of the target size to obtain the corner point coordinates of the cells in the table image.
[0178] Based on the above embodiment, the table extraction unit 540 is used to:
[0179] Based on the coordinates of the corner points of the text regions and the coordinates of the corner points of the cells, the text regions are matched with the cells to obtain the corresponding relationship between the text regions and the cells;
[0180] Based on the corresponding relationship and the text content of each text area, the text content is inserted into each cell to obtain a table corresponding to the table image.
[0181] Based on the above embodiment, the table extraction unit 540 is used to:
[0182] Based on the coordinates of the corner points of the any text area and the coordinates of the corner points of the cells, determining the area of the overlapped region between the any text area and the cells;
[0183] From each overlapping region, the overlapping region with the largest area is selected as the target overlapping region, and the cell corresponding to the target overlapping region is used as the cell corresponding to any text region to obtain the corresponding relationship between any text region and the cell.
[0184] Based on the above embodiment, the image determination unit 510 is used to:
[0185] Get the initial table image;
[0186] Performing seal detection on the initial table image to obtain the seal area and seal color in the initial table image;
[0187] Based on the seal color, channel filtering is performed on the seal area in the initial table image to obtain the table image.
[0188] Based on the above embodiment, the image determination unit 510 is used to:
[0189] Based on the seal color, channel filtering is performed on the seal area in the initial table image to obtain a target table image;
[0190] Performing table detection on the target table image to obtain original corner point coordinates of the table area in the target table image;
[0191] Based on the original corner point coordinates, determine the target corner point coordinates, and based on the target corner point coordinates, perform perspective transformation on the table area in the target table image;
[0192] Direction recognition is performed on the table area obtained by perspective transformation, and angle correction is performed on the table area obtained by perspective transformation based on the recognition result to obtain the table image.
[0193] Based on the above embodiment, the system further includes a display unit, which is used to:
[0194] Displaying the table image and the table on the same screen;
[0195] When a proofreading operation is received for any cell in the displayed table, the method jumps from the any cell in the table to a cell corresponding to the any cell in the table image based on the corner point coordinates of the cells.
[0196] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute the table extraction method, which includes: determining a table image to be extracted; performing text detection on the table image to obtain text areas in the table image and the corner point coordinates of each text area; generating a mask image of the table image based on the corner point coordinates of each text area, and performing corrosion and expansion on the mask image to obtain the corner point coordinates of the cells in the table image; determining the table corresponding to the table image based on the corner point coordinates of each text area, the corner point coordinates of each cell, and the text content of each text area.
[0197] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0198] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the table extraction method provided by the above-mentioned methods, and the method includes: determining a table image to be extracted; performing text detection on the table image to obtain text areas in the table image, and corner point coordinates of each text area; based on the corner point coordinates of each text area, generating a mask image of the table image, and performing erosion and dilation on the mask image to obtain corner point coordinates of cells in the table image; based on the corner point coordinates of each text area, the corner point coordinates of each cell, and the text content of each text area, determining the table corresponding to the table image.
[0199] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the table extraction method provided by the above-mentioned methods, the method comprising: determining a table image to be extracted; performing text detection on the table image to obtain text areas in the table image, and corner point coordinates of each text area; generating a mask image of the table image based on the corner point coordinates of each text area, and performing erosion and dilation on the mask image to obtain corner point coordinates of cells in the table image; determining a table corresponding to the table image based on the corner point coordinates of each text area, the corner point coordinates of each cell, and the text content of each text area.
[0200] The system embodiment described above is merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art may understand and implement it without creative work.
[0201] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0202] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A table extraction method, It is characterized in that include: Determine the table image to be extracted; Performing text detection on the table image to obtain text areas in the table image and the coordinates of corner points of each text area; Based on the corner point coordinates of each text area, a mask image of the table image is generated, and the mask image is corroded and expanded to obtain the corner point coordinates of the cells in the table image; Based on the corner point coordinates of each text area, the corner point coordinates of each cell, and the text content of each text area, the table corresponding to the table image is determined.
2. The table extraction method according to claim 1, It is characterized in that The step of generating a mask image of the table image based on the corner point coordinates of each text area, and performing corrosion and expansion on the mask image to obtain the corner point coordinates of cells in the table image includes: Generate a single-channel image based on the coordinates of the corner points of the table in the table image; Determine a mask image of the table image based on the corner point coordinates of each text area and the single-channel image; Determining a target size based on an image size of the mask image; The mask image is corroded and expanded by using a convolution kernel of the target size to obtain the corner coordinates of the cells in the table image.
3. The table extraction method according to claim 1, It is characterized in that The determining, based on the corner point coordinates of each text area, the corner point coordinates of each cell, and the text content of each text area, the table corresponding to the table image includes: Based on the coordinates of the corner points of the text regions and the coordinates of the corner points of the cells, the text regions are matched with the cells to obtain the corresponding relationship between the text regions and the cells; Based on the corresponding relationship and the text content of each text area, the text content is inserted into each cell to obtain a table corresponding to the table image.
4. The table extraction method according to claim 3, It is characterized in that The correspondence between any text area and a cell is determined based on the following steps: Based on the coordinates of the corner points of the any text area and the coordinates of the corner points of the cells, determining the area of the overlapped region between the any text area and the cells; From each overlapping region, the overlapping region with the largest area is selected as the target overlapping region, and the cell corresponding to the target overlapping region is used as the cell corresponding to any text region to obtain the corresponding relationship between any text region and the cell.
5. The table extraction method according to any one of claims 1 to 4, It is characterized in that The step of determining the table image to be extracted comprises: Get the initial table image; Performing seal detection on the initial table image to obtain the seal area and seal color in the initial table image; Based on the seal color, channel filtering is performed on the seal area in the initial table image to obtain the table image.
6. The table extraction method according to claim 5, It is characterized in that The step of performing channel filtering on the seal area in the initial table image based on the seal color to obtain the table image comprises: Based on the seal color, channel filtering is performed on the seal area in the initial table image to obtain a target table image; Performing table detection on the target table image to obtain original corner point coordinates of the table area in the target table image; Based on the original corner point coordinates, determine the target corner point coordinates, and based on the target corner point coordinates, perform perspective transformation on the table area in the target table image; Direction recognition is performed on the table area obtained by perspective transformation, and angle correction is performed on the table area obtained by perspective transformation based on the recognition result to obtain the table image.
7. The table extraction method according to any one of claims 1 to 4, It is characterized in that The step of determining the table corresponding to the table image further includes: Displaying the table image and the table on the same screen; When a proofreading operation is received for any cell in the displayed table, the method jumps from the any cell in the table to a cell corresponding to the any cell in the table image based on the corner point coordinates of the cells.
8. A table extraction system, It is characterized in that include: An image determination unit, used for determining a table image to be extracted; A text detection unit, used to perform text detection on the table image to obtain text areas in the table image and the coordinates of corner points of each text area; An erosion and dilation unit, used to generate a mask image of the table image based on the corner point coordinates of each text area, and perform erosion and dilation on the mask image to obtain the corner point coordinates of the cells in the table image; The table extraction unit is used to determine the table corresponding to the table image based on the corner point coordinates of each text area, the corner point coordinates of each cell, and the text content of each text area.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the table extraction method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the table extraction method according to any one of claims 1 to 7 is implemented.
