Table image analysis method, device, computer equipment and storage medium
By projection algorithm, the table image of the table line is pre -processed and analyzed, and the problem that cannot be parsed in the existing technology cannot be parsed in the existing technology, and the effective extraction and generation of the table structure and data are realized.
Patent Information
- Application Number
- CN201910115443.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-02-13
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2039-02-13
AI Technical Summary
The prior art cannot effectively analyze and extract table images without table lines.
The table image is pre -processed by projection algorithm, including two -value processing, removing horizontal and vertical lines, and subsequent horizontal and vertical projection to obtain the table layout and identify the character content to generate the form.
It realizes the extraction of table structure and data from table images without table lines, solves the problem in the existing technology that only table images with table lines can be parsed, and improves the flexibility and applicability of analysis.
Smart Images

Figure CN109948440B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer processing technology, and in particular to a table image parsing method, device, computer equipment and storage medium. Background Art
[0002] Tables are commonly used data carriers in documents. Tables are increasingly used in our daily lives. The data expressed in the form of tables can be vivid and intuitive, and the expression is concise. At present, most companies, especially IT, banking, finance and other industries, have to deal with an astonishing number of tables every day. In actual applications, we will encounter some documents containing tables in PDF format or picture format or table image format without table lines at all. In these cases, when we need to edit the table, we cannot operate it. Therefore, the analysis and recognition of tables is an important project in computer document processing, which can bring great convenience to our work. At present, the analysis and recognition of tables are widely used in various occasions, such as commercial and government agencies, and table recognition has high research and application value.
[0003] However, the existing table recognition technology has at least the following defects:
[0004] The existing technical solution is to parse the table based on the situation where there are table lines. When there are no table lines in the table format picture, the table cannot be extracted. Summary of the invention
[0005] The present invention provides a table image parsing method and a corresponding device, which mainly realizes the extraction of table structure and table data from a table image without table lines through a projection algorithm, solving the problem that the prior art can only perform table parsing on table images with table lines.
[0006] The present invention also provides a computer device and a readable storage medium for executing the table image parsing method of the present invention.
[0007] In order to solve the above problems, the present invention adopts the following technical solutions:
[0008] In a first aspect, the present invention provides a table image parsing method, the method comprising:
[0009] Input a table image and preprocess the table image;
[0010] Performing horizontal and vertical projection on the preprocessed table image to obtain a target table layout of the table image;
[0011] Character contents in the target table layout are identified, and a table of the table image is generated according to the character contents and the target table layout.
[0012] Specifically, the input table image and preprocessing the table image include:
[0013] Binarizing the table image to obtain a binary image;
[0014] Detecting horizontal lines in the binary image and removing the horizontal lines;
[0015] Detect vertical lines and remove the detected vertical lines.
[0016] Specifically, the binarization process of the table image to obtain a binary image includes:
[0017] Performing grayscale processing on the table image to obtain a grayscale image;
[0018] The binary image is obtained by applying the maximum stable extreme value region algorithm to the grayscale image.
[0019] Specifically, the horizontally projecting and vertically projecting the preprocessed table image to obtain a target table layout of the table image includes:
[0020] Perform horizontal projection on the preprocessed table image to obtain the row cutting area;
[0021] Perform vertical projection on the preprocessed table image to obtain the column cutting area;
[0022] The table image is segmented according to the row cutting area and the column cutting area to generate the target table layout and a plurality of cell images.
[0023] Preferably, the step of identifying the character content in the target table layout and generating the table of the table image according to the character content and the target table layout includes:
[0024] Draw a table frame structure of the table image according to the target table layout;
[0025] Recognizing character content in the cell image;
[0026] The character contents are filled into the table frame structure accordingly to generate a table of the table image.
[0027] Specifically, before horizontally projecting and vertically projecting the preprocessed table image to obtain the target table layout of the table image, the process includes:
[0028] The preprocessed table image is laterally expanded to make the regions connected.
[0029] Specifically, it also includes:
[0030] Detecting whether the table image contains grid lines;
[0031] If the table image contains grid lines, extracting the original table layout of the table image;
[0032] The original table layout is compared with the target table layout to verify the target table layout.
[0033] In a second aspect, the present invention provides a table image parsing device, the method comprising:
[0034] An input module, used for inputting a table image and preprocessing the table image;
[0035] A projection module, used for performing horizontal and vertical projection on the preprocessed table image to obtain a target table layout of the table image;
[0036] A generating module is used to identify the character content in the target table layout, and generate a table of the table image according to the character content and the target table layout.
[0037] In a third aspect, the present invention provides a computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the table image parsing method described in any one of the first aspects are implemented.
[0038] In a fourth aspect, the present invention provides a computer device, characterized in that it includes a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor executes the steps of the table image parsing method as claimed in any one of the claims in the first aspect.
[0039] Compared with the prior art, the technical solution of the present invention has at least the following advantages:
[0040] 1. The present invention provides a table image parsing method, which includes inputting a table image and preprocessing the table image; horizontally projecting and vertically projecting the preprocessed table image to obtain a target table layout of the table image; identifying the character content in the target table layout, and generating a table of the table image according to the character content and the target table layout. The present invention can extract the table structure and table data from a table image without table lines through a projection algorithm, thus solving the problem that the prior art can only parse a table image with table lines.
[0041] 2. The present invention can also detect whether the table image contains grid lines; if the table image contains grid lines, the original table layout of the table image is extracted; the original table layout is compared with the target table layout to verify the target table layout. Specifically, the comparison result of the present invention can be the difference points between the target table layout and the original table layout. When it is detected that the number of the difference points exceeds a preset value, it is determined that the acquired row cutting area or the column cutting area is inaccurate, and the row cutting area and the column cutting area are re-acquired and the target table layout is regenerated. The present invention not only realizes the parsing of table images without table lines, but also realizes the verification and adjustment of the parsed tables, thereby improving the applicability and flexibility of the solution. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 A flowchart of a table image parsing method in one embodiment;
[0043] Figure 2 A grayscale image generated in one embodiment;
[0044] Figure 3 A binary image generated in one embodiment;
[0045] Figure 4 A horizontal line detection map generated in one embodiment;
[0046] Figure 5 A horizontal line removal image generated in one embodiment;
[0047] Figure 6 A vertical line detection map generated in one embodiment;
[0048] Figure 7 A vertical line-removed image generated in one embodiment;
[0049] Figure 8 A denoised image generated in one embodiment;
[0050] Fig. 9 A row cutting area map generated in one embodiment;
[0051] Fig.10 A lateral region connectivity graph generated in one embodiment;
[0052] Fig.11 A column cut region diagram generated for one embodiment;
[0053] Fig.12 It is a structural block diagram of a table image parsing device in one embodiment;
[0054] Fig.13FIG. 4 is a block diagram of the internal structure of a computer device in one embodiment.
[0055] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings in conjunction with the embodiments. DETAILED DESCRIPTION
[0056] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0057] In some of the processes described in the specification and claims of the present invention and the above-mentioned figures, multiple operations that appear in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this article or executed in parallel. The sequence numbers of the operations, such as S11, S12, etc., are only used to distinguish between different operations, and the sequence numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., do not represent the order of precedence, and do not limit the "first" and "second" to be different types.
[0058] It will be understood by those of ordinary skill in the art that, unless expressly stated, the singular forms "a", "an", "said" and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.
[0059] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those generally understood by those skilled in the art in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as here.
[0060] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the drawings in the embodiments of the present invention, wherein the same or similar reference numerals throughout represent the same or similar elements or elements with the same or similar functions. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0061] See also Figure 1 , an embodiment of the present invention provides a table image parsing method, such as Figure 1 As shown, the method comprises the following steps:
[0062] S11, input a table image, and pre-process the table image.
[0063] In an embodiment of the present invention, the table image may be a photo of a table captured by a camera device or a table image captured by screenshot, such as a table image captured in a PDF document. The present invention pre-processes the table image, specifically including the following steps:
[0064] Step 1: binarize the table image to obtain a binary image.
[0065] This step specifically includes the following two sub-steps:
[0066] A1. Grayscale the table image to generate a grayscale image. Please refer to Figure 2 , Figure 2 A grayscale image is generated in one embodiment.
[0067] A2. Apply the MSER (Maximum Stable Extreme Region Detection) algorithm to the grayscale image to obtain the binary image. Figure 3 , Figure 3 In one embodiment, a binary image is generated. Figure 3 The binary image includes a plurality of small rectangular boxes, and the small rectangular boxes are the positions where the characters in the table image are located.
[0068] The basic principle of the MSER algorithm is to perform a binary processing on a grayscale image (grayscale value is 0-255) by taking a threshold, and the threshold increases from 0 to 255. The increase of the threshold is similar to the rise of the water surface in the watershed algorithm. As the water surface rises, some shorter hills will be submerged. If you look down from the sky, the earth is divided into two parts: land and water, which is similar to a binary image. In all the binary images obtained, some connected areas in the image change very little or even no change, then this area is called the maximum stable extreme value area.
[0069] The above scheme can only detect the black area of the grayscale image, but not the white area, so it is necessary to invert the original image and then perform a binarization process with a threshold value ranging from 0 to 255. These two operations are also called MSER+ and MSER-.
[0070] The MSER algorithm is currently considered to be the best performing method for detecting affine invariant regions. It uses different grayscale thresholds to binarize the image to obtain the most stable region. It has the following three characteristics: it is invariant to affine changes in image grayscale, it supports stability in relative grayscale changes in the region, and it can detect regions of different sizes with different degrees of refinement.
[0071] In a possible design, the steps of extracting the maximum extreme value stable region of MSER include: pixel sorting, extreme value region generation, stable region determination, region fitting and region normalization.
[0072] Step 2: Detect the horizontal lines in the binary image and remove the horizontal lines.
[0073] Step 2 specifically includes the following sub-steps:
[0074] B1. Performing horizontal line detection on the binary image, specifically detecting the horizontal lines by horizontal corrosion and expansion, and generating a horizontal line detection image.
[0075] Please refer to Figure 4 , Figure 4 A horizontal line detection diagram generated in one embodiment.
[0076] like Figure 4 As shown, the horizontal line detection image includes 4 short lines and 7 long lines. The detected horizontal lines are horizontal interference lines. For example, there may be two small rectangular boxes connected together in the binary image to form a horizontal line. These horizontal lines will interfere with the subsequent table drawing and need to be removed.
[0077] B2. Remove the horizontal lines of the horizontal line detection image to generate a horizontal line removal image. Figure 5 , Figure 5 In one embodiment, a horizontal line removal diagram is generated. Figure 5 as well as Figure 3 It can be seen that Figure 5 For Figure 3 The interfering horizontal lines are removed on the basis of
[0078] Step 3: Detect vertical lines and remove the detected vertical lines.
[0079] Step three specifically includes the following sub-steps:
[0080] C1. Performing vertical line detection on the horizontal line removal image, specifically detecting vertical lines by vertical corrosion and expansion to generate a vertical line detection image.
[0081] Please refer to Figure 6 , Figure 6 : is a vertical line detection diagram generated in one embodiment. Figure 6 As shown, the vertical line detection image includes 5 lines. Similarly, the vertical lines are also interference lines and need to be removed.
[0082] C2, according to the detected vertical line Figure 5 The vertical lines in are removed to generate a vertical line removed graph.
[0083] Please refer to Figure 7 , Figure 7 1 is a graph generated by removing vertical lines in one embodiment. Figure 7 as well as Figure 5 It can be seen that Figure 7 For Figure 5 The interfering vertical lines on the far left and far right are removed.
[0084] C3, vertically corrode the vertical line removal image to remove noise, and generate a denoised image, such as Figure 8 shown.
[0085] S12, performing horizontal projection and vertical projection on the preprocessed table image to obtain a target table layout of the table image.
[0086] In the embodiment of the present invention, after the denoised image is generated, the denoised image is horizontally projected to obtain a horizontal row cutting area, thereby generating a row cutting area map.
[0087] Please refer to Fig. 9 , Fig. 9 In one embodiment, the row cutting area diagram generated by the present invention is shown in FIG. Fig. 9 As shown, the row cutting area diagram includes a white area and a black area, wherein the black area is the background part of the table image, and the white area is the row cutting area. The row cutting area is the area where text exists.
[0088] Furthermore, the present invention provides the row cutting area diagram, that is, Figure 7 Perform lateral expansion to connect the regions and obtain a lateral region connectivity graph.
[0089] Please refer to Fig.10 , Fig.10In one embodiment, the lateral area connectivity graph generated by the present invention is shown in FIG. Fig.10 As shown, the horizontal area connectivity graph includes a white area and a black area, wherein the white area is the background area of the table image, and the black area is the area where text exists on the table image.
[0090] Furthermore, the present invention provides the lateral region connectivity graph, i.e. Fig. 9 Perform vertical projection to obtain the vertical column cutting area and obtain a column cutting area map.
[0091] Please refer to Fig.11 , Fig.11 In one embodiment, the column cutting area diagram generated by the present invention is shown in FIG. Fig.11 As shown, the column cutting area diagram includes a white area and a black area, wherein the white area is the column cutting area, which is Fig.10 The black area in the projection is obtained, and the black area is the background area, which is Fig.10 The white area in is projected.
[0092] In an embodiment of the present invention, the table image can be vertically projected by Python computer programming language. In a possible design, the present invention can specifically utilize the opencv cross-platform computer vision library to vertically project the table image.
[0093] Furthermore, in an embodiment of the present invention, the table image is segmented according to the row cutting area and the column cutting area to obtain a plurality of white rectangular areas, and the target table layout is determined according to the distribution and number of the white rectangular areas, wherein the target table layout includes at least the number of rows and columns of the table. Specifically, the number of white rectangular areas in a row can be used as the number of columns of the target table layout, and the number of white rectangular areas in a column can be used as the number of rows of the target table layout.
[0094] The white rectangular area is a cell image obtained by segmenting the table image. A table is drawn according to the white rectangular area to obtain a table form of the table image.
[0095] S13: Identify character content in the target table layout, and generate a table of the table image according to the character content and the target table layout.
[0096] In the embodiment of the present invention, the white rectangular area obtained by segmenting the row segmentation area and the column segmentation area is the cell image of the table image, and the character content in the cell image is further recognized by using an OCR recognition model.
[0097] Furthermore, after obtaining the number of rows and columns of the table image, a table frame structure of the table image is drawn, and the character contents in each identified cell image are correspondingly filled into the cells of the drawn table frame structure to obtain an editable table of the table image.
[0098] Preferably, the present invention can also detect whether the table image contains grid lines; if the table image contains grid lines, the original table layout of the table image is extracted; the original table layout is compared with the target table layout to obtain a comparison result to verify the target table layout. The comparison result can be the difference between the target table layout and the original table layout, for example, different numbers of rows and different numbers of columns. When the comparison result shows that there are differences between the target table layout and the original table layout, it is determined that the target table layout is inaccurate.
[0099] In another embodiment, if the number of compared difference points exceeds a preset error range, it is determined that the acquisition of the row cutting area or the column cutting area is inaccurate, and it is necessary to reacquire the row cutting area and the column cutting area to adjust the target table layout to regenerate the table of the table image.
[0100] Please refer to Fig.12 In another embodiment, the present invention provides a table image parsing device, comprising:
[0101] The input module 11 is used for inputting a table image and preprocessing the table image.
[0102] In an embodiment of the present invention, the table image may be a photo of a table captured by a camera device or a table image captured by screenshot, such as a table image captured in a PDF document. The present invention pre-processes the table image, specifically including the following steps:
[0103] Step 1: binarize the table image to obtain a binary image.
[0104] This step specifically includes the following two sub-steps:
[0105] A1. Grayscale the table image to generate a grayscale image. Please continue to refer to Figure 2 , Figure 2 A grayscale image is generated in one embodiment.
[0106] A2. Apply the MSER (Maximum Stable Extreme Region Detection) algorithm to the grayscale image to obtain the binary image. Figure 3 , Figure 3 In one embodiment, a binary image is generated. Figure 3 The binary image includes a plurality of small rectangular boxes, and the small rectangular boxes are the positions where the characters in the table image are located.
[0107] The basic principle of the MSER algorithm is to perform a binary processing on a grayscale image (grayscale value is 0-255) by taking a threshold, and the threshold increases from 0 to 255. The increase of the threshold is similar to the rise of the water surface in the watershed algorithm. As the water surface rises, some shorter hills will be submerged. If you look down from the sky, the earth is divided into two parts: land and water, which is similar to a binary image. In all the binary images obtained, some connected areas in the image change very little or even no change, then this area is called the maximum stable extreme value area.
[0108] The above scheme can only detect the black area of the grayscale image, but not the white area, so it is necessary to invert the original image and then perform a binarization process with a threshold value ranging from 0 to 255. These two operations are also called MSER+ and MSER-.
[0109] The MSER algorithm is currently considered to be the best performing method for detecting affine invariant regions. It uses different grayscale thresholds to binarize the image to obtain the most stable region. It has the following three characteristics: it is invariant to affine changes in image grayscale, it supports stability in relative grayscale changes in the region, and it can detect regions of different sizes with different degrees of refinement.
[0110] In a possible design, the steps of extracting the maximum extreme value stable region of MSER include: pixel sorting, extreme value region generation, stable region determination, region fitting and region normalization.
[0111] Step 2: Detect the horizontal lines in the binary image and remove the horizontal lines.
[0112] Step 2 specifically includes the following sub-steps:
[0113] B1. Performing horizontal line detection on the binary image, specifically detecting the horizontal lines by horizontal corrosion and expansion, and generating a horizontal line detection image.
[0114] Please continue to refer to Figure 4 , Figure 4 A horizontal line detection diagram generated in one embodiment.
[0115] like Figure 4 As shown, the horizontal line detection image includes 4 short lines and 7 long lines. The detected horizontal lines are horizontal interference lines. For example, there may be two small rectangular boxes connected together in the binary image to form a horizontal line. These horizontal lines will interfere with the subsequent table drawing and need to be removed.
[0116] B2. Remove the horizontal lines of the horizontal line detection image to generate a horizontal line removal image. Figure 5 , Figure 5 In one embodiment, a horizontal line removal diagram is generated. Figure 5 as well as Figure 3 It can be seen that Figure 5 For Figure 3 The interfering horizontal lines are removed on the basis of
[0117] Step 3: Detect vertical lines and remove the detected vertical lines.
[0118] Step three specifically includes the following sub-steps:
[0119] C1. Performing vertical line detection on the horizontal line removal image, specifically detecting vertical lines by vertical corrosion and expansion to generate a vertical line detection image.
[0120] Please continue to refer to Figure 6 , Figure 6 : is a vertical line detection diagram generated in one embodiment. Figure 6 As shown, the vertical line detection image includes 5 lines. Similarly, the vertical lines are also interference lines and need to be removed.
[0121] C2, according to the detected vertical line Figure 5 The vertical lines in are removed to generate a vertical line removed graph.
[0122] Please continue to refer to Figure 7 , Figure 7 1 is a graph generated by removing vertical lines in one embodiment. Figure 7 as well as Figure 5 It can be seen that Figure 7 For Figure 5 The interfering vertical lines on the far left and far right are removed.
[0123] C3, vertically corrode the vertical line removal image to remove noise, and generate a denoised image, such as Figure 8 shown.
[0124] The projection module 12 is used to perform horizontal projection and vertical projection on the preprocessed table image to obtain a target table layout of the table image.
[0125] In the embodiment of the present invention, after the denoised image is generated, the denoised image is horizontally projected to obtain a horizontal row cutting area, thereby generating a row cutting area map.
[0126] Please continue to refer to Fig. 9 , Fig. 9In one embodiment, the row cutting area diagram generated by the present invention is shown in FIG. Fig. 9 As shown, the row cutting area diagram includes a white area and a black area, wherein the black area is the background part of the table image, and the white area is the row cutting area. The row cutting area is the area where text exists.
[0127] Furthermore, the present invention provides the row cutting area diagram, that is, Figure 7 Perform lateral expansion to connect the regions and obtain a lateral region connectivity graph.
[0128] Please continue to refer to Fig.10 , Fig.10 In one embodiment, the lateral area connectivity graph generated by the present invention is shown in FIG. Fig.10 As shown, the horizontal area connectivity graph includes a white area and a black area, wherein the white area is the background area of the table image, and the black area is the area where text exists on the table image.
[0129] Furthermore, the present invention provides the lateral region connectivity graph, i.e. Fig. 9 Perform vertical projection to obtain the vertical column cutting area and obtain a column cutting area map.
[0130] Please continue to refer to Fig.11 , Fig.11 In one embodiment, the column cutting area diagram generated by the present invention is shown in FIG. Fig.11 As shown, the column cutting area diagram includes a white area and a black area, wherein the white area is the column cutting area, which is Fig.10 The black area in the projection is obtained, and the black area is the background area, which is Fig.10 The white area in is projected.
[0131] In an embodiment of the present invention, the table image can be vertically projected by Python computer programming language. In a possible design, the present invention can specifically utilize the opencv cross-platform computer vision library to vertically project the table image.
[0132] Furthermore, in an embodiment of the present invention, the table image is segmented according to the row cutting area and the column cutting area to obtain a plurality of white rectangular areas, and the target table layout is determined according to the distribution and number of the white rectangular areas, wherein the target table layout includes at least the number of rows and columns of the table. Specifically, the number of white rectangular areas in a row can be used as the number of columns of the target table layout, and the number of white rectangular areas in a column can be used as the number of rows of the target table layout.
[0133] The white rectangular area is a cell image obtained by segmenting the table image. A table is drawn according to the white rectangular area to obtain a table form of the table image.
[0134] The generating module 13 is used to identify the character content in the target table layout, and generate a table of the table image according to the character content and the target table layout.
[0135] In the embodiment of the present invention, the white rectangular area obtained by segmenting the row segmentation area and the column segmentation area is the cell image of the table image, and the character content in the cell image is further recognized by using an OCR recognition model.
[0136] Furthermore, after obtaining the number of rows and columns of the table image, a table frame structure of the table image is drawn, and the character contents in each identified cell image are correspondingly filled into the cells of the drawn table frame structure to obtain an editable table of the table image.
[0137] Preferably, the present invention can also detect whether the table image contains grid lines; if the table image contains grid lines, the original table layout of the table image is extracted; the original table layout is compared with the target table layout to obtain a comparison result to verify the target table layout. The comparison result can be the difference between the target table layout and the original table layout, for example, different numbers of rows and different numbers of columns. When the comparison result shows that there are differences between the target table layout and the original table layout, it is determined that the target table layout is inaccurate.
[0138] In another embodiment, if the number of compared difference points exceeds a preset error range, it is determined that the acquisition of the row cutting area or the column cutting area is inaccurate, and it is necessary to reacquire the row cutting area and the column cutting area to adjust the target table layout to regenerate the table of the table image.
[0139] In another embodiment, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the table image parsing method described in any technical solution is implemented. Wherein, the computer-readable storage medium includes but is not limited to any type of disk (including floppy disk, hard disk, optical disk, CD-ROM, and magneto-optical disk), ROM (Read-Only Memory), RAM (Random Access Memory), EPROM (EraSable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory, magnetic card or optical card. That is, the storage device includes any medium that can store or transmit information in a readable form by a device (for example, a computer, a mobile phone), which can be a read-only memory, a disk or an optical disk, etc.
[0140] A computer-readable storage medium provided by an embodiment of the present invention can realize inputting a table image, preprocessing the table image; horizontally projecting and vertically projecting the preprocessed table image to obtain a target table layout of the table image; identifying character content in the target table layout, and generating a table of the table image according to the character content and the target table layout. The present invention can extract the table structure and table data from a table image without table lines through a projection algorithm, solving the problem that the prior art can only perform table parsing on table images with table lines.
[0141] Furthermore, in yet another embodiment, the present invention provides a computer device, such as Fig.13 As shown, the computer device includes a processor 303, a memory 305, an input unit 307, a display unit 309 and other devices. Those skilled in the art can understand that Fig.13The structural devices shown do not constitute a limitation on all computer devices, and may include more or fewer components than shown, or combine certain components. The memory 305 can be used to store the application 301 and various functional modules, and the processor 303 runs the application 301 stored in the memory 305, thereby executing various functional applications and data processing of the device. The memory 305 can be an internal memory or an external memory, or include both internal and external memories. The internal memory may include a read-only memory (ROM), a programmable ROM (PROM), an electrically programmable ROM (EPROM), an electrically erasable programmable ROM (EEPROM), a flash memory, or a random access memory. The external memory may include a hard disk, a floppy disk, a ZIP disk, a U disk, a magnetic tape, etc. The memory disclosed in the present invention includes but is not limited to these types of memories. The memory 305 disclosed in the present invention is only used as an example and not as a limitation.
[0142] The input unit 307 is used to receive the input of the signal and the keyword input by the user. The input unit 307 may include a touch panel and other input devices. The touch panel can collect the user's touch operation on or near it (such as the user's operation on or near the touch panel using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program; other input devices may include but are not limited to one or more of a physical keyboard, a function key (such as a playback control key, a switch key, etc.), a trackball, a mouse, a joystick, etc. The display unit 309 can be used to display the information input by the user or the information provided to the user and various menus of the computer device. The display unit 309 can be in the form of a liquid crystal display, an organic light emitting diode, etc. The processor 303 is the control center of the computer device, which uses various interfaces and lines to connect various parts of the entire computer, and executes various functions and processes data by running or executing software programs and / or modules stored in the memory 303, and calling data stored in the memory. Fig.13 The one or more processors 303 shown in FIG. 1 are capable of executing, implementing Fig.12 The functions of the input module 11, the projection module 12 and the generation module 13 are shown in FIG.
[0143] In one embodiment, the computer device includes a memory 305 and a processor 303, wherein the memory 305 stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor 303 executes the steps of a table image parsing method described in the above embodiment.
[0144] A computer device provided by an embodiment of the present invention can realize inputting a table image, preprocessing the table image; horizontally projecting and vertically projecting the preprocessed table image to obtain a target table layout of the table image; identifying the character content in the target table layout, and generating a table of the table image according to the character content and the target table layout. The present invention can extract the table structure and table data from a table image without table lines through a projection algorithm, solving the problem that the prior art can only perform table parsing on table images with table lines.
[0145] In another embodiment, the present invention can also detect whether the table image contains grid lines; if the table image contains grid lines, the original table layout of the table image is extracted; the original table layout is compared with the target table layout to verify the target table layout. Specifically, the comparison result of the present invention can be the difference points between the target table layout and the original table layout. When it is detected that the number of the difference points exceeds a preset value, it is determined that the acquired row cutting area or the column cutting area is inaccurate, and the row cutting area and the column cutting area are re-acquired and the target table layout is regenerated. The present invention not only realizes the parsing of table images without table lines, but also realizes the verification and adjustment of the parsed table, thereby improving the applicability and flexibility of the solution.
[0146] The computer-readable storage medium provided in the embodiment of the present invention can implement the embodiment of the above-mentioned table image parsing method. For specific function implementation, please refer to the description in the method embodiment, which will not be repeated here.
[0147] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0148] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0149] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A table image analysis method, characterized in that: The method comprises: Inputting a table image and preprocessing the table image, including: binarizing the table image to obtain a binary image; detecting horizontal lines in the binary image and removing the horizontal lines; detecting vertical lines and removing the detected vertical lines; The preprocessed table image is expanded horizontally to make the regions connected; Performing horizontal and vertical projection on the preprocessed table image to obtain a target table layout of the table image; Character contents in the target table layout are identified, and a table of the table image is generated according to the character contents and the target table layout.
2. The table image analysis method according to claim 1, characterized in that: The step of binarizing the table image to obtain a binary image includes: Performing grayscale processing on the table image to obtain a grayscale image; The binary image is obtained by applying the maximum stable extreme value region algorithm to the grayscale image.
3. The table image analysis method according to claim 1, characterized in that: The step of horizontally projecting and vertically projecting the preprocessed table image to obtain a target table layout of the table image includes: Perform horizontal projection on the preprocessed table image to obtain the row cutting area; Perform vertical projection on the preprocessed table image to obtain the column cutting area; The table image is segmented according to the row cutting area and the column cutting area to generate the target table layout and a plurality of cell images.
4. The table image analysis method according to claim 3, characterized in that: The step of identifying character contents in the target table layout and generating a table of the table image according to the character contents and the target table layout includes: Draw a table frame structure of the table image according to the target table layout; Recognizing character content in the cell image; The character contents are correspondingly filled into the table frame structure to generate a table of the table image.
5. The table image analysis method according to claim 1, characterized in that: Also includes: Detecting whether the table image contains grid lines; If the table image contains grid lines, extracting the original table layout of the table image; The original table layout is compared with the target table layout to verify the target table layout.
6. A table image analysis device, characterized in that: The device comprises: The input module is used to input a table image and pre-process the table image, including: binarizing the table image to obtain a binary image; detecting horizontal lines in the binary image and removing the horizontal lines; detecting vertical lines and removing the detected vertical lines; A projection module is used to perform horizontal expansion on the preprocessed table image to make the area connected; it is also used to perform horizontal projection and vertical projection on the preprocessed table image to obtain a target table layout of the table image; A generating module is used to identify the character content in the target table layout, and generate a table of the table image according to the character content and the target table layout.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the table image parsing method according to any one of claims 1 to 5.
8. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor executes the steps of the table image parsing method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Table parsing method and device in document image
CN108416279A
Table vector analysis method and apparatus for PDF document
CN108446264A