A method for determining the type of document image table
Through a variety of judgment rules and strategies, combined with the preprocessing and detection of table images, the table type can be accurately determined, which solves the problems of low table recognition accuracy and poor adaptability in the existing technology and realizes efficient and accurate table type determination.
Patent Information
- Application Number
- CN202510865310.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-26
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2045-06-26
AI Technical Summary
Existing table recognition technology has problems such as low recognition accuracy, high computational cost, low efficiency and poor adaptability when processing different types of tables. In particular, it may cause misjudgment in wired tables with unclear lines, difficult to judge wireless table boundaries and complex table structures.
The algorithm uses a variety of judgment rules and strategies to pre-process the table image, detect horizontal and vertical lines, and determine the table type based on the mean grayscale value of the pixels. This includes setting thresholds and ratio judgments, building a vertical line list, traversing the horizontal and vertical line areas, calculating the table line area height and row height standard deviation, and determining whether the table type is wired, wireless, or tilted.
The accuracy and efficiency of table type determination are improved, the computational complexity is reduced, the system is adaptable to document images of different formats, and it can accurately distinguish table types in the presence of interference lines and poor image quality.
Smart Images

Figure CN120375402B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of document image processing and recognition, and in particular to a method for determining the type of a document image table. Background Art
[0002] In many fields, such as document processing and information extraction, it is often necessary to identify and analyze tables in documents. As a structured data presentation format, tables are widely used in various documents, such as financial statements, statistical reports, and questionnaires. However, there are many different types of tables in documents. Common tables are generally divided into wired tables, wireless tables, and tilted tables for photographing, and they have different contours. When faced with the differences between different table types, table recognition technology often needs to be directional to adapt to the processing methods of different types of tables.
[0003] Existing table recognition technologies face numerous challenges when handling different types of tables. While wired tables are relatively easy to recognize, recognition accuracy can drop significantly when lines are unclear, interference lines are present, or the table image quality is poor. Furthermore, due to the lack of distinct dividing lines in wireless tables, existing methods often struggle to accurately determine table boundaries and cell divisions, leading to erroneous or incomplete information extraction. For example, Chinese patent application number "CN202310010871.0" proposes a classification method based on physical line density. However, this method lacks adaptability to mixed-line tables (such as partially wired / wireless) and image distortion scenarios, easily leading to misclassification. For documents containing complex table structures, patent application number "CN202211524881.8" introduces a key field annotation strategy, but lacks dynamic modeling of semantically relevant features of wireless tables, making it difficult to ensure robust classification of sparse line tables.
[0004] In addition, current table type determination methods mostly rely on complex machine learning models or large amounts of manually annotated data, which have high computational costs, low efficiency, and poor adaptability to document images from different sources and formats.
[0005] Therefore, developing an efficient, accurate and universal method for determining the table type of document images has important practical significance. Summary of the Invention
[0006] In view of the above-mentioned deficiencies in the current determination of the table type in document images, the present invention provides a method for determining the table type in document images, which can efficiently and accurately determine the type of the table in the document image, overcome the deficiencies of the existing technology in table type determination, improve the accuracy and efficiency of table recognition and enhance the adaptability to document images of different formats.
[0007] To achieve the above objectives, the embodiments of the present invention adopt the following technical solutions:
[0008] A method for determining the type of a document image table, comprising:
[0009] Preprocessing the original table document image to obtain a preprocessed table document image;
[0010] Using a table detection algorithm to detect and extract the pre-processed table document image to obtain a table image;
[0011] Detecting the table image using a table line detection method to obtain a first horizontal line list and a first vertical line list;
[0012] determining a table type according to the first horizontal line list and the first vertical line list, and ending the determination if the determination is successful;
[0013] The table type is determined according to the grayscale mean of all pixels in the table image.
[0014] According to one aspect of the present invention, determining a table type according to the first horizontal line list and the first vertical line list includes:
[0015] Set the first horizontal line number threshold and the first vertical line number threshold;
[0016] Obtain the number of horizontal lines in the first horizontal line list and the number of vertical lines in the first vertical line list;
[0017] If the number of horizontal lines is less than the first horizontal line number threshold or the number of vertical lines is less than the first vertical line number threshold, it is determined that the table type is a wireless table.
[0018] According to one aspect of the present invention, determining a table type according to the first horizontal line list and the first vertical line list includes:
[0019] Set the left and right border ratios of the vertical line horizontal axis area;
[0020] Obtaining the left and right boundaries of the vertical line area according to the left and right boundary ratios of the vertical line horizontal coordinate area;
[0021] Construct a second vertical line list, wherein the second vertical line list is initialized to be empty;
[0022] Adding the vertical lines in the first vertical line list whose midpoint coordinates are located in the vertical line area to the second vertical line list;
[0023] Determine whether the table type is a wireless table according to the second vertical line list.
[0024] According to one aspect of the present invention, determining whether the table type is a wireless table according to the second vertical line list includes:
[0025] Set the second vertical line number threshold;
[0026] Get the number of vertical lines in the second vertical line list;
[0027] If the number of vertical lines in the second vertical line list is not greater than the second vertical line number threshold, it is determined that the table type is a wireless table.
[0028] According to one aspect of the present invention, determining whether the table type is a wireless table according to the second vertical line list includes:
[0029] Set the length ratio of the first vertical line;
[0030] Obtaining a first vertical line length according to the first vertical line length ratio;
[0031] Obtain the number of vertical lines in the second vertical line list whose length is not less than the length of the first vertical line;
[0032] Get the judgment threshold;
[0033] If the number of vertical lines in the second vertical line list whose lengths are not less than the first vertical line length is less than the determination threshold, the table type is determined to be a wireless table.
[0034] According to one aspect of the present invention, determining a table type according to the first horizontal line list and the first vertical line list includes:
[0035] Set the length ratio of the first horizontal line;
[0036] Obtaining a first horizontal line length according to the first horizontal line length ratio;
[0037] Obtain the number of horizontal lines in the first horizontal line list whose length is not less than the first horizontal line length;
[0038] Set the second horizontal line quantity threshold;
[0039] If the product of the number of horizontal lines in the first horizontal line list whose length is not less than the first horizontal line length and the second horizontal line number threshold is less than the number of horizontal lines in the first horizontal line list, the table type is determined to be a wireless table.
[0040] According to one aspect of the present invention, determining a table type according to the first horizontal line list and the first vertical line list includes:
[0041] Setting an initial value of the y coordinate of the upper boundary of the first horizontal line area and an initial value of the y coordinate of the lower boundary of the first horizontal line area, wherein the initial value of the y coordinate of the upper boundary of the first horizontal line area is infinite, and the initial value of the y coordinate of the lower boundary of the first horizontal line area is infinitesimal;
[0042] Traversing the horizontal lines in the first horizontal line list;
[0043] Update the y coordinate of the upper boundary of the first horizontal line area by comparing the y coordinates of the left and right endpoints of the horizontal line with the y coordinate of the upper boundary of the first horizontal line area;
[0044] Update the y coordinate of the lower boundary of the first horizontal line area by comparing the y coordinates of the left and right endpoints of the horizontal line with the y coordinate of the lower boundary of the first horizontal line area;
[0045] Set the initial value of the y coordinate of the upper boundary of the vertical line area and the initial value of the y coordinate of the lower boundary of the vertical line area, wherein the initial value of the y coordinate of the upper boundary of the vertical line area is infinite, and the initial value of the y coordinate of the lower boundary of the vertical line area is infinitesimal;
[0046] Traversing the vertical lines in the first vertical line list;
[0047] Update the y coordinate of the upper boundary of the vertical line area by comparing the y coordinate of the upper endpoint of the vertical line with the y coordinate of the upper boundary of the vertical line area;
[0048] Update the y coordinate of the lower boundary of the vertical line area by comparing the y coordinate of the lower endpoint of the vertical line with the y coordinate of the lower boundary of the vertical line area;
[0049] Obtaining the y coordinate of the upper boundary of the table line area according to the y coordinate of the upper boundary of the first horizontal line area and the y coordinate of the upper boundary of the vertical line area;
[0050] Obtaining the y coordinate of the lower boundary of the table line area according to the y coordinate of the lower boundary of the first horizontal line area and the y coordinate of the lower boundary of the vertical line area;
[0051] Obtaining the height of the table line area according to the upper boundary coordinates and the lower boundary coordinates of the table line area;
[0052] Set the table area height threshold;
[0053] If the table line area height is greater than the table area height threshold, determining that the table type is a wireless table;
[0054] Set the third vertical line number threshold;
[0055] If the number of vertical lines in the first vertical line list is less than the third vertical line number threshold, it is determined that the table type is a wireless table.
[0056] According to one aspect of the present invention, determining a table type according to the first horizontal line list and the first vertical line list includes:
[0057] Obtain a table row height list according to the first horizontal line list;
[0058] Obtaining a row height list standard deviation according to the table row height list;
[0059] Set the row height standard deviation threshold;
[0060] If the row height table standard deviation is greater than the row height standard deviation threshold, it is determined that the type of the table is a wireless table.
[0061] According to one aspect of the present invention, determining a table type according to the first horizontal line list and the first vertical line list includes:
[0062] Set the length ratio of the second horizontal line;
[0063] Obtaining the length of the second horizontal line according to the ratio of the width of the table image to the length of the second horizontal line;
[0064] Acquire a second horizontal line list according to the first horizontal line list and the second horizontal line length;
[0065] Set the third horizontal line quantity threshold;
[0066] If the number of horizontal lines in the second horizontal line list is less than the third horizontal line number threshold, it is determined that the type of the table is a wired table.
[0067] According to one aspect of the present invention, determining a table type according to the first horizontal line list and the first vertical line list includes:
[0068] Acquire a second horizontal line area according to the first horizontal line list;
[0069] Get the height of the second horizontal line area;
[0070] Set the length ratio of the second vertical line;
[0071] Obtaining a second vertical line length according to the second vertical line length ratio and the second horizontal line area height;
[0072] Obtain a third vertical line list according to the first vertical line list;
[0073] Setting the first inclined vertical line slope threshold;
[0074] Obtain the number of vertical lines in the third vertical line list whose slopes are not less than the first inclined vertical line slope threshold;
[0075] Set the fourth vertical line number threshold;
[0076] If the number of vertical lines in the third vertical line list whose slopes are not less than the first inclined vertical line slope threshold is not less than the fourth vertical line number threshold, the type of the table is determined to be a photographing tilt table.
[0077] According to one aspect of the present invention, determining a table type according to the first horizontal line list and the first vertical line list includes:
[0078] Setting the second vertical line slope threshold;
[0079] Obtain the number of vertical lines in the third vertical line list whose slopes are not less than the second inclined vertical line slope threshold;
[0080] Set the fifth vertical line number threshold;
[0081] If the number of vertical lines in the third vertical line list whose slopes are not less than the second inclined vertical line slope threshold is less than the fifth vertical line number threshold, it is determined that the type of the table is a wired table.
[0082] According to one aspect of the present invention, determining the table type according to the grayscale mean value of all pixels in the table image includes:
[0083] Performing image grayscale processing on the table image using a grayscale method to obtain a grayscale table image;
[0084] Calculating the grayscale mean of all pixels in the grayscale table image;
[0085] Set grayscale threshold;
[0086] If the grayscale mean is less than the grayscale threshold, it is determined that the type of the table is a photographing tilt table.
[0087] According to one aspect of the present invention, if the table type is determined to be neither a wired table nor a photographic tilt table based on the first horizontal line list and the first vertical line list, and the table type is determined to be neither a photographic tilt table nor a photographic tilt table based on the grayscale mean of all pixels in the table image, then the table type is determined to be a wired table.
[0088] Advantages of the implementation of the present invention: First, the present invention uses a variety of judgment rules and strategies to determine the type of table from multiple angles, and can accurately distinguish between wired tables and wireless tables in document images of different qualities, thereby improving the accuracy of table type determination. Secondly, the method has low computational complexity and does not require complex machine learning models and a large amount of manually labeled data. It can quickly complete the determination of the table type, thereby improving processing efficiency. Thirdly, the method of the present invention does not rely on a specific document format or table style, has good adaptability to document images of different sources and formats, and can be widely used in various document processing scenarios. Finally, when processing document images with unclear table lines, interference lines, or poor image quality, the present invention can effectively overcome the influence of interference factors through the comprehensive application of a variety of judgment rules, thereby ensuring the accuracy and robustness of table type determination. BRIEF DESCRIPTION OF THE DRAWINGS
[0089] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only 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.
[0090] Figure 1 A schematic flow chart of a method for determining the type of a document image table according to the present invention;
[0091] Figure 2 This is a flow chart of determining the table type according to the first horizontal line list and the first vertical line list according to the present invention. DETAILED DESCRIPTION
[0092] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0093] like Figure 1 The following is a flow chart showing a method for determining the type of a table in a document image according to an embodiment of the present invention. The method is used to determine the type of a table in a document image and includes the following steps:
[0094] Step S1: pre-processing the original table document image to obtain a pre-processed table document image.
[0095] The preprocessing in the above steps is a common pre-operation in image processing, which refers to the process of scaling the image and performing rotation correction.
[0096] Here, the original table document image is denoted as I, and the pre-processed table document image is denoted as I1. The pre-processing process includes scaling and de-skew operations, thereby obtaining the pre-processed table document image I1.
[0097] Step S2: Use a table detection algorithm to detect and extract the pre-processed table document image I1 to obtain a table image.
[0098] The table detection algorithm mentioned here is a common method for detecting tables in images. See L.Hao, L. Gao, X. Yi and Z. Tang, "A Table Detection Method for PDF DocumentsBased on Convolutional Neural Networks," 2016 12th IAPR Workshop on DocumentAnalysis Systems (DAS), Santorini, Greece, 2016, pp. 287-292, doi: 10.1109 / DAS.2016.23.
[0099] Here, the table image is recorded as I t , table image I t The height is denoted as h t , table image I t The width is denoted as w t .
[0100] Step S3: Use table line detection method to detect the table image I t Perform detection to obtain the first horizontal line list and the first vertical line list.
[0101] The table line detection method mentioned here is a common method for detecting table frame lines in images. See Y. Tian, C. Gao and X. Huang, "Table frame line detection in lowquality document images based on Hough transform," The 2014 2nd International Conference on Systems and Informatics (ICSAI 2014), Shanghai, China, 2014, pp. 818-822, doi: 10.1109 / ICSAI.2014.7009397.
[0102] Here, the first horizontal line is marked as L h1 , the first vertical line list is recorded as L v1 .
[0103] Step S4: According to the first horizontal line list L h1 and the first vertical line list L v1 Determines the type of table in a table image.
[0104] according to Figure 2 As shown, determining the type of a table in a table image according to the first horizontal line list and the first vertical line list specifically includes the following steps:
[0105] It should be noted that the determination steps are performed sequentially, with each step representing an independent determination method. If the determination method successfully determines the form type (wireless form or tilted photo form), the determination ends; otherwise, the subsequent determinations continue. If all determination steps fail to determine the form type, the form is determined to be a wired form.
[0106] Step S41: Determine the table type according to the number of table lines. If the determination is successful, the determination process ends.
[0107] The determination process includes the following steps:
[0108] Step S41a: setting a first horizontal line quantity threshold and a first vertical line quantity threshold.
[0109] Here, the first horizontal line number threshold is recorded as N ht1 , the first vertical line number threshold is recorded as N vt1 In the embodiment of the present invention, N ht1 and N vt1 The value of is 2.
[0110] Step S41b: Get the first horizontal line list L h1 The number of horizontal lines and the first vertical line list L v1 The number of vertical lines in .
[0111] Here, the first horizontal line list L h1 The number of horizontal lines is N h1 , first vertical line list L v1 The number of vertical lines is recorded as N v1 The way to obtain it is to calculate the first horizontal line list L h1 and the first vertical line list L v1 The number of data in.
[0112] Step S41c: If the number of horizontal lines in the first horizontal line list is N h1 Less than the first horizontal line number threshold N ht1 or the number of vertical lines N in the first vertical line list v1 Less than the first vertical line number threshold N vt1 , then the table type is determined to be a wireless table.
[0113] That is, if N h1 <N ht1 or N v1 <N vt1 , then it is determined that the table type in the document image is a wireless table.
[0114] Step S42: Obtain a second vertical line list and determine the type of the table in the table image according to the second vertical line list.
[0115] First, set the effective area height threshold, which is denoted as h va In the embodiment of the present invention, h va The value is 200.
[0116] Note that, to handle exceptions, if the height h of the table image t Not greater than the effective area height threshold h va (ie h t ≤h va ), then abandon this step to determine the type of the table in the table image and continue to determine it through subsequent methods. Otherwise, execute the following steps:
[0117] To obtain the second vertical line list, you first need to remove the first vertical line list L. v1 The vertical boundary line in , and then implement it through the following steps:
[0118] Step S421a: setting the left border ratio and the right border ratio of the vertical line horizontal coordinate area.
[0119] Here, the left boundary ratio of the vertical line horizontal coordinate area is recorded as r bl , the right boundary ratio of the vertical line horizontal coordinate area is recorded as r br In the embodiment of the present invention, r bl The value of r is 0.1, br The value of is 0.9.
[0120] Step S421b: According to the left edge ratio r of the vertical line horizontal coordinate area bl and right border ratio r br Get the left and right x-coordinates of the vertical line area.
[0121] In the embodiment of the present invention, the left boundary x-coordinate of the vertical line region is used to represent the left boundary of the vertical line region, and the right boundary x-coordinate of the vertical line region is used to represent the right boundary of the vertical line region.
[0122] Here, the x-coordinate of the left boundary of the vertical line area is marked as x bl , the x coordinate of the right boundary of the vertical line area is marked as x br .
[0123] According to the left boundary ratio r of the vertical line horizontal coordinate area bl Get the x coordinate of the left boundary of the vertical line area bl The calculation formula is: bl =r bl *w t .
[0124] According to the right boundary ratio r of the vertical line horizontal coordinate area br Get the x coordinate of the right border of the vertical line area br The calculation formula is: br =r br *w t .
[0125] Step S421c: construct a second vertical line list, which is initialized to be empty.
[0126] Here, the second vertical line list is recorded as L v2 , L v2 Initialized to empty.
[0127] Step S421d: List the first vertical line L v1 The vertical lines whose midpoint coordinates are located in the vertical line area are added to the second vertical line list.
[0128] In the embodiment of the present invention, the first vertical line list L is obtained by loop traversal. v1 If the x-coordinate of the midpoint of the vertical line is at the x-coordinate of the left edge of the vertical line area, bl and the x-coordinate of the right boundary x br If the vertical line is between , then add it to the second vertical line list L v2 middle.
[0129] The specific steps are as follows:
[0130] Step S421d1: Set the first loop variable i a , the first loop variable i a The initial value is set to 1, Indicates the first vertical line list L v1 The i-th a vertical lines, Indicates a vertical line The x-coordinate of the midpoint.
[0131] Step S421d2: If the first loop variable i a >N v1 , then the loop ends.
[0132] Among them, N v1 Indicates the first vertical line list L v1 The number of vertical lines in .
[0133] Step S421d3: If <x bl or >x br , jump to step S421d5.
[0134] Step S421d4: vertical line Add the second vertical line list L v2 .
[0135] Step S421d5: Set the first loop variable i a The value of is increased by 1 and the process goes to step S421d2.
[0136] From the above process, we can see that after the loop ends (when ia>Nv1), the vertical line in the first vertical line list whose midpoint x coordinate is between the x coordinate of the left boundary and the x coordinate of the right boundary of the vertical line area will be added to the second vertical line list L v2 middle.
[0137] There are two specific methods for determining the type of the table in the table image based on the second vertical line list:
[0138] First, according to the second vertical line list L v2 The number of vertical lines in the table determines the table type. If the determination is successful, the determination process ends, including:
[0139] Step S422a: Setting a second vertical line quantity threshold.
[0140] Here, the second vertical line number threshold is recorded as N vt2 In the embodiment of the present invention, N vt2 The value is 0.
[0141] Step S422b: Obtain the number of vertical lines in the second vertical line list.
[0142] Here, the second vertical line list L v2 The number of vertical lines is recorded as N v2 , understandable, N v2 The value of the second vertical line list L v2 The number of data in.
[0143] Step S422c: If the number of vertical lines in the second vertical line list is N v2 Not greater than the second vertical line number threshold N vt2 , then the table type is determined to be a wireless table.
[0144] That is, if ≤ , then it is determined that the table in the document image is a wireless table.
[0145] Second, according to the second vertical line list L v2 The number of vertical lines exceeding the preset threshold determines the table type. If the determination is successful, the determination process ends, including:
[0146] Step S423a: setting a first vertical line length ratio.
[0147] Here, the length ratio of the first vertical line is recorded as r v1 In the embodiment of the present invention, r v1 The value is 0.8.
[0148] Step S423b: According to the first vertical line length ratio r v1 Get the length of the first vertical line.
[0149] Here, the length of the first vertical line is recorded as , according to the first vertical line length ratio r v1 Get the length of the first vertical line The calculation formula is: =h t *r v1 (h t For table image I t height).
[0150] Step S423c: Obtain the second vertical line list L v2 The length of the vertical line in the is not less than the length of the first vertical line The number of vertical lines.
[0151] Here, the number of vertical lines in the second vertical line list whose length is not less than the length of the first vertical line is recorded as c v1 , c v1 The initial value of is 0.
[0152] In the embodiment of the present invention, obtaining c v1 The value can be achieved as follows:
[0153] Step S423c1: Set the second loop variable , the second loop variable The initial value is set to 1, Indicates the second vertical line list L v2 The vertical lines, Indicates a vertical line length.
[0154] Step S423c2: If the second loop variable >N v2 , then the loop ends.
[0155] Among them, N v2 Indicates the second vertical line list L v2 The number of vertical lines.
[0156] Step S423c3: If < , jump to step S423c5.
[0157] Step S423c4: c v1 The value of is increased by 1.
[0158] Step S423c5: Set the second loop variable The value of is increased by 1 and jump to step S423c2.
[0159] From the above process, we can see that after the cycle ends (when >N v2 ), c v1 The value of is the number of vertical lines in the second vertical line list whose length is not less than the length of the first vertical line.
[0160] Step S423d: Obtain the determination threshold.
[0161] In the embodiment of the present invention, the rule for determining the threshold is to obtain 2 and the second vertical line list L v2 The mathematical formula for the determination threshold is: According to mathematical rules, the value of this judgment threshold can be 0, 1 or 2.
[0162] Step S423e: If the second vertical line list L v2 The length of the vertical line in the number c is not less than the length of the first vertical line v1 Less than the judgment threshold , then the table is determined to be a wireless table.
[0163] That is, if c v1 < , then the table is determined to be a wireless table.
[0164] Step S43: determining the table type according to the number of horizontal lines in the first horizontal line list whose length exceeds a preset threshold, and ending the determination process if the determination is successful.
[0165] The specific steps are:
[0166] Step S43a: Setting the first horizontal line length ratio.
[0167] Here, the length ratio of the first horizontal line is recorded as r h1 In the embodiment of the present invention, r h1 The value is 0.8.
[0168] Step S43b: According to the first horizontal line length ratio r h1 Get the length of the first horizontal line.
[0169] Here, the length of the first horizontal line is l h1 , according to the first horizontal line length ratio, the first horizontal line length l is obtained h1 The formula is: h1 =w t *rh1 .
[0170] Step S43c: Obtain the first horizontal line list whose length is not less than the first horizontal line length l h1 The number of horizontal lines.
[0171] Here, the number of horizontal lines in the first horizontal line list whose length is not less than the length of the first horizontal line is recorded as c h1 .
[0172] In the present invention, c h1 The initial value is set to 0, and c h1 The value can be achieved by the following steps:
[0173] Step S43c1: Set the third loop variable , the third loop variable The initial value of is set to 1, Indicates the first horizontal line list L h1 The horizontal line, Indicates a horizontal line length.
[0174] Step S43c2: If >N h1 , then the loop ends.
[0175] Among them, N h1 Indicates the first horizontal line list L h1 The number of horizontal lines in .
[0176] Step S43c3: If <l h1 , then jump to step S43c5.
[0177] Step S43c4: c h1 The value of is increased by 1.
[0178] Step S43c5: Set the third loop variable The value of is increased by 1 and the process goes to step S43c2.
[0179] From the above process, we can see that when the cycle ends (when >N h1 When the length of the horizontal line in the first horizontal line list is not less than the number of the first horizontal line length is recorded in c h1 middle.
[0180] Step S43d: Setting a second horizontal line quantity threshold.
[0181] Here, the second horizontal line number threshold is recorded as Nht2. In the embodiment of the present invention, N ht2 The value is 6.
[0182] Step S43e: If the length of the horizontal line in the first horizontal line list is not less than the number of horizontal lines c of the first horizontal line length h1 The second horizontal line number threshold N ht2 The product of is less than the number of lines N in the first line list h1 , then the table type is determined to be a wireless table.
[0183] That is, if c h1 *N ht2 <N h1 , then the table type is determined to be a wireless table.
[0184] Step S44: According to the first horizontal line list L h1 The horizontal and first vertical lines in the list L v1 The table type is determined by the height of the table line area formed by the vertical lines in the table. If the determination is successful, the determination process ends.
[0185] The specific steps include:
[0186] Step S44a: Acquire the first horizontal line area.
[0187] In the embodiment of the present invention, obtaining the first horizontal line area can be achieved by obtaining the upper boundary y coordinate and the lower boundary y coordinate of the first horizontal line area.
[0188] Here, the y coordinate of the upper boundary of the first horizontal line area is marked as y ubh1 , the y coordinate of the lower boundary of the first horizontal line area is marked as y dbh1 .
[0189] In the embodiment of the present invention, the upper boundary y coordinate y of the first horizontal line area is obtained. ubh1 and the y coordinate of the lower boundary of the first horizontal line area dbh1 This can be achieved by following the steps below:
[0190] Step S44a1: setting the initial value of the y-coordinate of the upper boundary and the initial value of the y-coordinate of the lower boundary of the first horizontal line area.
[0191] The initial value of the upper boundary y coordinate is infinite, and the initial value of the lower boundary y coordinate is infinitesimal. ubh1 The initial value of y is infinite, dbh1 The initial value is infinitesimal.
[0192] Step S44a2: traverse the first horizontal line list L h1 The horizontal line in .
[0193] Step S44a3: Update the y coordinate of the upper boundary of the first horizontal line area by comparing the y coordinates of the left and right endpoints of the horizontal line with the y coordinate of the upper boundary of the first horizontal line area.
[0194] Step S44a4: Update the y coordinate of the lower boundary of the first horizontal line area by comparing the y coordinates of the left and right endpoints of the horizontal line with the y coordinate of the lower boundary of the first horizontal line area.
[0195] The above steps S44a2, S44a3 and S44a4 can be implemented by the following loop logic:
[0196] Step a: Set the fourth loop variable i d , the fourth loop variable i d The initial value is 1, let Indicates the first horizontal line list L h1 The i-th d horizontal line, Indicates a horizontal line The y coordinate of the left endpoint, let Indicates a horizontal line The y coordinate of the right endpoint;
[0197] Step b: If i d >N h1 , then the loop ends.
[0198] Among them, N h1 Indicates the first horizontal line list L h1 The number of horizontal lines in .
[0199] Step c: If y ubh1 > , then y ubh1 The value of .
[0200] Step d: If y ubh1 > , then y ubh1 The value of .
[0201] Step e: If y dbh1 < , then y dbh1 The value of .
[0202] Step f: If y dbh1 < , then y dbh1 The value of .
[0203] Step g: Set the fourth loop variable i d Increase the value of by 1 and skip to step b.
[0204] From the above process, we can see that when the cycle ends (when i d >Nh1 ), the y coordinate y of the upper boundary of the first horizontal line area will be obtained ubh1 and the y coordinate of the lower boundary of the first horizontal line area dbh1 Among them, y ubh1 The value is the first horizontal line list L h1 The minimum value of the y coordinate of the left endpoint and the right endpoint of the horizontal line; y dbh1 The value is the first horizontal line list L h1 The maximum y-coordinate of the left and right endpoints of the left endpoint of the center horizontal line.
[0205] Step S44b: Acquire the vertical line area.
[0206] Similarly, in the embodiment of the present invention, obtaining the vertical line area can be achieved by obtaining the upper boundary y coordinate and the lower boundary y coordinate of the vertical line area.
[0207] Here, the y coordinate of the upper boundary of the vertical line area is marked as y ubv , the y coordinate of the lower boundary of the vertical line area is marked as y dbv .
[0208] In this embodiment of the present invention, the upper boundary y coordinate y of the vertical line area is obtained. ubv and the lower boundary y coordinate y dbv This can be achieved by following the steps below:
[0209] Step S44b1: setting the initial value of the y-coordinate of the upper boundary and the initial value of the y-coordinate of the lower boundary of the vertical line area.
[0210] The initial value of the upper boundary y coordinate is infinite, and the initial value of the lower boundary y coordinate is infinitesimal. ubv The initial value of y is infinite, dbv The initial value of is infinitesimal.
[0211] Step S44b2: traverse the first vertical line list L v1 The vertical line in .
[0212] Step S44b3: Update the y coordinate of the upper boundary of the vertical line area by comparing the y coordinate of the upper endpoint of the vertical line with the y coordinate of the upper boundary of the vertical line area.
[0213] Step S44b4: updating the y coordinate of the lower boundary of the vertical line area by comparing the y coordinate of the lower endpoint of the vertical line with the y coordinate of the lower boundary of the vertical line area.
[0214] The above steps S44b2, S44b3 and S44b4 can be implemented by the following loop logic:
[0215] Step a: Set the fifth loop variable i e , the fifth loop variable i eThe initial value is 1, let Indicates the first vertical line list L v1 The i e vertical lines, Indicates a vertical line The y coordinate of the upper endpoint, let Indicates a vertical line The y-coordinate of the lower endpoint.
[0216] Step b: If i e >N v1 , the loop ends.
[0217] Among them, N v1 For the first vertical line list L v1 The number of vertical lines in .
[0218] Step c: If y ubv > , then y ubv The value of .
[0219] Step d: If y dbv < , then y dbv The value of .
[0220] Step e: Set the fifth loop variable i e The value of is increased by 1, and jump to step b;
[0221] From the above process, we can see that when the cycle ends (when i e >N v1 ), the y coordinate of the upper boundary of the vertical line area will be obtained ubv and the y coordinate of the lower boundary of the vertical line area dbv Among them, y ubv The value is the first vertical line list L v1 The minimum y-coordinate value of the endpoints on the midline; y dbv The value is the first vertical line list L v1 The maximum y-coordinate of the lower endpoints of the vertical line.
[0222] Step S44c: Acquire the table line area according to the first horizontal line area and the vertical line area.
[0223] Similarly, in the embodiment of the present invention, the table line area can be obtained by determining the y coordinate of the upper boundary and the y coordinate of the lower boundary of the table line area.
[0224] In the embodiment of the present invention, the specific steps of obtaining the table line area include:
[0225] Step S44c1: According to the y coordinate y of the upper boundary of the first horizontal line area ubh1and the y coordinate of the upper boundary of the vertical line area ubv , get the y coordinate of the upper boundary of the table line area.
[0226] Here, the y coordinate of the upper boundary of the table line area is marked as y ub Get y ub The mathematical formula is: ub =min(y ubh1 ,y ubv ).
[0227] Step S44c2: According to the y coordinate y of the lower boundary of the first horizontal line area dbh1 and the y coordinate of the lower boundary of the vertical line area dbv , get the y coordinate of the lower boundary of the table line area.
[0228] Here, the y coordinate of the lower boundary of the table line area is marked as y db Get y db The mathematical formula is: db =max(y dbh1 ,y dbv ).
[0229] Step S44d: According to the upper boundary y coordinate y of the table line area ub and the y coordinate of the lower boundary of the table line area db , get the table line area height.
[0230] Here, the height of the table line area is recorded as h ta Get h ta The mathematical formula is: h ta =y db -y ub .
[0231] Step S44e: Setting the table area height threshold.
[0232] Here, the table area height threshold is recorded as h mt In the embodiment of the present invention, h mt The value is 120.
[0233] Step S44f: If the table line area height h ta Greater than the table area height threshold h mt , then the table type is determined to be a wireless table.
[0234] That is, if h ta >h mt , then the table type is determined to be a wireless table.
[0235] Step S44g: Setting a third vertical line quantity threshold.
[0236] Here, the third vertical line number threshold is recorded as Nvt3 In the embodiment of the present invention, N vt3 The value is 3.
[0237] Step S44h: If the number of vertical lines in the first vertical line list is less than the third vertical line number threshold, the table type is determined to be a wireless table.
[0238] That is, if N v1 <N vt3 , then the table type is determined to be a wireless table.
[0239] Step S45: According to the first horizontal line list L h1 The spacing between adjacent horizontal lines in the table is used to obtain the table row height list, and the table type is determined based on the table row height list. If the determination is successful, the determination process ends.
[0240] Here, the table row height is recorded as L rh In this embodiment of the present invention, the table row height list L rh For the first horizontal line list L h1 The set of adjacent horizontal line spacing in L rh This can be achieved by following the steps below:
[0241] Step S451a: Construct a table row height list, which is initialized to empty.
[0242] That is, L rh Initialized to empty.
[0243] Step S451b: Loop through the horizontal lines in the first horizontal line list.
[0244] Step S451c: Obtain the y coordinates of the center points of adjacent horizontal lines.
[0245] Step S451d: Obtain the row height according to the y coordinate of the center point of the adjacent horizontal line.
[0246] Step S451e: Add the row height to the table row height list.
[0247] In this embodiment, the above steps S451b, S451c, S451d and S451e can be implemented by the following loop logic:
[0248] Step a: Set the sixth loop variable i f , the sixth loop variable i f The initial value is set to 2, Indicates the first horizontal line list L h1 The i-th f horizontal line, Indicates a horizontal line The y coordinate of the center point;
[0249] Step b: If the sixth loop variable i f >N h1 , then the loop ends.
[0250] Among them, N h1 For the first horizontal line list L h1 The number of horizontal lines in .
[0251] Step c: Get the spacing between adjacent horizontal lines.
[0252] Here, the distance between adjacent horizontal lines is recorded as , Indicates a horizontal line and horizontal lines The spacing, The calculation formula is: = - .
[0253] Step d: Add table row height list L rh middle.
[0254] Step e: Set the sixth loop variable i f Increase the value of by 1 and skip to step b.
[0255] From the above process, we can see that after the cycle ends (when i f >N h1 When the first horizontal line list is added to the table row height list L rh middle.
[0256] In the embodiment of the present invention, determining the table type according to the table row height list is specifically determining the table type according to the standard deviation of the table row height list.
[0257] The specific steps for determining the table type based on the standard deviation of all row heights in the table row height list are as follows:
[0258] Step S452a: According to the table row height list L rh Get the average row height of all rows in .
[0259] Here, the mean row height is recorded as , The calculation formula is:
[0260]
[0261] Step S452b: Obtain the standard deviation of the row height list based on the row height mean.
[0262] Here, the standard deviation of the row height list is recorded as d rh , d rh The calculation formula is:
[0263]
[0264] Step S452c: Set the row height standard deviation threshold.
[0265] Here, the row height standard deviation threshold is recorded as d rht In the embodiment of the present invention, d rht The value is 120.
[0266] Step S452d: If the row height list standard deviation d rh Greater than the row height standard deviation threshold d rht , then the type of the table is determined to be a wireless table.
[0267] That is, if d rh >d rht , then the type of the table is determined to be a wireless table.
[0268] Step S46: Determine the table type based on the table line length, slope, and image grayscale mean. If the determination is successful, the determination process ends.
[0269] Among them, the table type can be divided into four cases based on the table line length, slope and image grayscale mean, which will be discussed below:
[0270] Step S461: Determine the table type by the table line length. If the determination is successful, the determination process ends.
[0271] In the embodiment of the present invention, the specific process of determining the table type by table line length includes the following steps:
[0272] Step S461a: Setting the second horizontal line length ratio.
[0273] Here, the length ratio of the second horizontal line is recorded as r h2 .
[0274] Step S461b: Based on the width w of the table image t and the ratio of the length of the second horizontal line r h2 Get the length of the second horizontal line.
[0275] Here, the length of the second horizontal line is l h2 , according to the width w of the table image t and the ratio of the length of the second horizontal line r h2 The formula for getting the length of the second horizontal line is: l h2 =w t *r h2 .
[0276] Step S461c: According to the first horizontal line list L h1Get the second horizontal line list.
[0277] Here, the second horizontal line is marked as L h2 Get L h2 The specific process includes:
[0278] Step S461c1: Construct a second horizontal line list, which is initialized to empty.
[0279] That is, construct L h2 , L h2 Initialized to empty.
[0280] Step S461c2: traverse the first horizontal line list L h1 If the length of the horizontal line is not less than the length of the second horizontal line l h2 , then add the horizontal line to the second horizontal line list L h2 .
[0281] The above step S461c2 can be implemented by the following loop logic:
[0282] Step a: Set the seventh loop variable i g , the seventh loop variable i g The initial value of is set to 1, Indicates the first horizontal line list L h1 The i-th g horizontal line, Indicates a horizontal line length.
[0283] Step b: If the seventh loop variable i g >N h1 , then the loop ends.
[0284] Among them, N h1 For the first horizontal line list L h1 The number of horizontal lines in .
[0285] Step c: If <l h2 , then skip to step e.
[0286] Step d: Place the horizontal line Add the second horizontal line list L h2 .
[0287] Step e: Set the seventh loop variable i g Increase the value of by 1 and skip to step b.
[0288] From the above process, we can see that after the cycle ends (when i g >N h1 When ), the first horizontal line list L h1The length of the middle horizontal line should not be less than the length of the second horizontal line l h2 The horizontal line (i.e. ≥l h2 ) will be added to the second horizontal line list L h2 middle.
[0289] Step S461d: Setting the third horizontal line quantity threshold.
[0290] Here, the third horizontal line number threshold is recorded as N ht3 In the embodiment of the present invention, N ht3 The value is 3.
[0291] Step S461e: If the number of horizontal lines in the second horizontal line list is N h2 Less than the third horizontal line number threshold N ht3 , then the type of the table is determined to be a wired table.
[0292] That is, if N h2 <N ht3 , then the type of the table is determined to be a wired table.
[0293] If the type of the table cannot be determined through the above steps, continue with the subsequent determination.
[0294] Step S462: Determine the type of the table based on the length and slope of the table line. If the determination is successful, the determination process ends.
[0295] In the embodiment of the present invention, determining the type of a table based on the length and slope of a table line specifically includes the following steps:
[0296] Step S462a: According to the first horizontal line list L h1 Get the second horizontal line area.
[0297] In an embodiment of the present invention, the second horizontal line area can be obtained by determining the y coordinates of the upper boundary and the lower boundary of the second horizontal line area. The specific steps of obtaining the second horizontal line area include:
[0298] Step S462a1: construct a second horizontal line area, the initial value of the y coordinate of the upper boundary of the second horizontal line area is infinity, and the initial value of the y coordinate of the lower boundary of the second horizontal line area is infinitesimal.
[0299] Here, the y coordinate of the upper boundary of the second horizontal line area is marked as y ubh2 The y coordinate of the lower boundary of the second horizontal line area is marked as y dbh2 ,y ubh2 The initial value of y is infinite, dbh2 The initial value of is infinitesimal.
[0300] Step S462a2: traverse the first horizontal line list L h1If the length of the horizontal line is not less than the second horizontal line length, the upper boundary y coordinate and the lower boundary y coordinate of the second horizontal line area are updated according to the y coordinates of the left and right endpoints of the horizontal line.
[0301] The above step S462a2 can be implemented by the following loop logic:
[0302] Step a: Set the eighth loop variable i h , the eighth loop variable i h The initial value of is set to 1, Indicates the second horizontal line list L h2 The i-th h horizontal line, Indicates a horizontal line The length of Indicates a horizontal line Left endpoint Coordinates, let Indicates a horizontal line The y-coordinate of the right endpoint.
[0303] Step b: If the eighth loop variable i h >N h2 , then the loop ends.
[0304] Among them, N h2 For the second horizontal line list L h2 The number of horizontal lines in .
[0305] Step c: If < y ubh2 , then y ubh2 Set the value of .
[0306] Step d: If < y ubh2 , then y ubh2 Set the value of .
[0307] Step e: If > y dbh2 , then y dbh2 Set the value of .
[0308] Step f: If > y dbh2 , then y dbh2 Set the value of .
[0309] Step g: Set the eighth loop variable i h Increase the value of by 1 and skip to step b.
[0310] From the above process, we can see that after the cycle ends (when i h >N h2 When , the upper and lower y coordinates of the second horizontal line area will also be updated. ubh2 The value is the second horizontal line list L h2 The minimum value of the y coordinate of the left endpoint and the right endpoint of the horizontal line; y dbh2 The value is the second horizontal line list L h2 The maximum y-coordinate of the left and right endpoints of the left endpoint of the center horizontal line.
[0311] Step S462b: Obtain the height of the second horizontal line area.
[0312] Specifically, according to the upper boundary y coordinate y of the second horizontal line area ubh2 and the lower boundary y coordinate y dbh2 Get the height of the second horizontal line area.
[0313] Here, the height of the second horizontal line area is recorded as h ha , the mathematical formula for obtaining the height of the horizontal line area is: h ha =y dbh2 -y ubh2 .
[0314] Step S462c: setting the second vertical line length ratio.
[0315] Here, the length ratio of the second vertical line is recorded as r v2 In the embodiment of the present invention, r v2 The value is 0.5.
[0316] Step S462d: According to the second vertical line length ratio r v2 and the second horizontal line area height h ha Get the length of the second vertical line.
[0317] Here, the height of the second vertical line area is recorded as l v2 , the mathematical formula for obtaining the height of the horizontal line area is: l v2 =h ha *r v2 .
[0318] Step S462e: Obtain a third vertical line list according to the first vertical line list.
[0319] In the embodiment of the present invention, obtaining the third vertical line list according to the first vertical line list can be achieved by the following steps:
[0320] Step S462e1: Construct a third vertical line list, which is initialized to be empty.
[0321] Here, the third vertical line list is recorded as L v3 , Lv3 Initialized to empty.
[0322] Step S462e2: traverse the first vertical line list L v1 If the length of the vertical line is not less than the length of the second vertical line l v2 , then add the vertical line to the third vertical line list L v3 middle.
[0323] The above step S462e2 can be implemented by the following loop logic:
[0324] Step a: Set the ninth loop variable , the ninth loop variable The initial value of is set to 1, Indicates the first vertical line list The vertical lines, Indicates a vertical line length.
[0325] Step b: If the ninth loop variable > , then the loop ends.
[0326] in, Indicates the first vertical line list The number of vertical lines in .
[0327] Step c: If <l v2 , then skip to step e.
[0328] Step d: Place the vertical line Add the third vertical line list L v3 .
[0329] Step e: Set the ninth loop variable i i Increase the value of by 1 and skip to step b.
[0330] From the above process, we can see that after the cycle ends (when >N v1 ), the third vertical line list L v3 The length of the middle vertical line is not less than ( ≥l v2 ) The length of the second vertical line l v2 The vertical line will be added to the third vertical line list L v3 middle.
[0331] Step S462f: setting a first inclined vertical line slope threshold.
[0332] Here, the first inclined vertical line slope threshold is denoted as s1. In the embodiment of the present invention, the value of s1 is 0.015.
[0333] Step S462g: Setting a fourth vertical line quantity threshold.
[0334] Here, the fourth vertical line number threshold is recorded as N vt4 In the embodiment of the present invention, N vt4 The value is 4.
[0335] Step S462h: obtaining the number of vertical lines in the third vertical line list whose slopes are not less than the first inclined vertical line slope threshold s1 by loop traversal.
[0336] Here, the number of vertical lines in the third vertical line list whose slopes are not less than the first inclined vertical line slope threshold s1 is recorded as c v2 The specific steps to obtain include:
[0337] Step S462h1: Set the tenth loop variable i j , the tenth loop variable i j The initial value is set to 1, Indicates the third vertical line list L v3 The i-th j vertical lines, Indicates a vertical line The x coordinate of the upper endpoint, let Indicates a vertical line The y coordinate of the upper endpoint, let Indicates a vertical line The x coordinate of the lower endpoint, let Indicates a vertical line The y coordinate of the lower endpoint.
[0338] The above step S462h1 can be implemented by the following loop logic:
[0339] Step a: If the tenth loop variable i j >N v3 , then the loop ends.
[0340] Step b: Calculate vertical lines slope.
[0341] Here, the vertical line The slope is recorded as , slope The calculation formula is: ,in( ≠ ).
[0342] Step c: If < s1, then skip to step e.
[0343] Step d: Change c v2 The value of is increased by 1.
[0344] Step e: Set the ninth loop variable i i Increase the value of by 1 and skip to step a.
[0345] From the above process, we can see that after the cycle ends (when i j >N v3 When the slope of the vertical line in the third vertical line list is not less than the first inclined vertical line slope threshold s1, the number of vertical lines is recorded in c v2 middle.
[0346] Step S462i: If the number of vertical lines c v2 Not less than the fourth vertical line number threshold N vt4 , then the type of the table is determined to be a photographic tilt table.
[0347] That is, if c v2 ≥ N vt3 , then the type of the table is determined to be a photographic tilt table.
[0348] If the type of the table cannot be determined through the above steps, continue with the subsequent determination.
[0349] Step S463: Determine the type of the table using the second inclined vertical line slope threshold and the fifth vertical line quantity threshold. If the determination is successful, terminate the determination process.
[0350] The method of determining the type of the table by using the second inclined vertical line slope threshold and the fifth vertical line quantity threshold specifically includes:
[0351] Step S463a: setting a second inclined vertical line slope threshold.
[0352] Here, the second inclined vertical line slope threshold is recorded as s2. In the embodiment of the present invention, the value of s2 is 0.005.
[0353] Step S463b: Obtain the third vertical line list L v3 The number of vertical lines whose slope is not less than the second inclined vertical line slope threshold s2.
[0354] Here, the third vertical line list L v3 The number of vertical lines whose slope is not less than the second inclined vertical line slope threshold is recorded as c v3 , c v3 The initial value of is 0.
[0355] The above step S463b can be implemented by the following loop logic:
[0356] Step a: Set the eleventh loop variable , the eleventh loop variable The initial value is set to 1, Indicates the third vertical line list in the th vertical line, let represent the vertical line of the upper endpoint x coordinate, let represent the vertical line of the upper endpoint y coordinate, let represent the vertical line of the lower endpoint x coordinate, let represent the vertical line of the lower endpoint y coordinate.
[0357] Step b: If the eleventh loop variable > N v3 , then end the loop.
[0358] Step c: Obtain the slope of the vertical line[[ID=3!]]
[0359] Here, the slope of the vertical line is recorded as , the slope The calculation formula is: , where ( ≠ ).
[0360] Step d: If < s2, then jump to step f.
[0361] Step e: Increase the value of c v3 by 1.
[0362] Step f: Increase the value of the eleventh loop variable by 1, and jump to step b.
[0363] As can be seen from the above process, after the loop ends (when > N[[ID=6!]] v3 ), the number of vertical lines in the third vertical line list whose slopes are not less than the slope threshold s2 of the second inclined vertical line is recorded in c v3 .
[0364] Step S463c: Set the threshold for the number of the fifth vertical lines.
[0365] Here, the threshold for the number of the fifth vertical lines is denoted as N vt5 . In the embodiment of the present invention, N vt5 takes the value of 3.
[0366] Step S463d: If the number of vertical lines in the third vertical line list L v3 [[ID=X7]]whose slopes are not less than the slope threshold s2 of the second inclined vertical line is less than the threshold for the number of the fifth vertical lines N vt5 , then the type of the table is determined to be a wired table.
[0367] If the type of the table cannot be determined through the above steps, the type of the table is determined by the image grayscale mean. The specific determination process includes the following steps.
[0368] Step S464: Determine the type of the table based on the grayscale threshold. If the determination is successful, end the determination process.
[0369] The type of the table is determined based on the grayscale mean of all pixels in the table image. Specifically, the type of the table includes:
[0370] Step S464a: Setting the grayscale threshold.
[0371] Here, the grayscale threshold is recorded as v g In the embodiment of the present invention, v g The value is 150.
[0372] Step S464b: Table image I t The grayscale method is used to grayscale the image to obtain a grayscale table image.
[0373] Here, the grayscale table image is recorded as I g .
[0374] Step S464c: Calculate grayscale table image I g The grayscale mean of all pixels in the image is less than the grayscale threshold v. g , then the type of the table is determined to be a photographic tilt table.
[0375] Here, the grayscale mean is recorded as v avg That is, if v avg <v g , then the type of the table is determined to be a photographic tilt table.
[0376] Step S47: If the type of the table still cannot be determined by the above determination method, the type of the table is determined to be a wired table.
[0377] Specifically, if the type of the table cannot be determined by various determination methods from step S41 to step S46 , the type of the table is determined to be a wired table.
[0378] Advantages of the implementation of the present invention: First, the present invention uses a variety of judgment rules and strategies to judge the form type from multiple angles, and can accurately distinguish between wired forms and wireless forms in document images of different qualities, thereby improving the accuracy of form type judgment. Secondly, the method has low computational complexity and does not require complex machine learning models and a large amount of manually labeled data. It can quickly complete the judgment of the form type, thereby improving processing efficiency. Thirdly, the method of the present invention does not rely on a specific document format or table style, has good adaptability to document images of different sources and formats, and can be widely used in various document processing scenarios. Finally, when processing document images with unclear table lines, interference lines, or poor image quality, the present invention can effectively overcome the influence of interference factors through the comprehensive application of a variety of judgment rules, thereby ensuring the accuracy and robustness of form type judgment. In short, the document image table type judgment method of the present invention has high industrial application value.
[0379] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present invention should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.
Claims
1. A method for determining the type of a document image table, characterized in that: include: Preprocessing the original table document image to obtain a preprocessed table document image; Using a table detection algorithm to detect and extract the pre-processed table document image to obtain a table image; Detecting the table image using a table line detection method to obtain a first horizontal line list and a first vertical line list; determining a table type according to the first horizontal line list and the first vertical line list, and ending the determination if the determination is successful; Otherwise, the table type is determined according to the grayscale mean of all pixels in the table image; Determining the table type according to the first horizontal line list and the first vertical line list includes: determining the table type from multiple angles using multiple judgment rules and strategies to determine whether the table type is a wired table, a wireless table, or a tilted photographing table; Determining the table type according to the first horizontal line list and the first vertical line list includes: Setting an initial value of the y coordinate of the upper boundary of the first horizontal line area and an initial value of the y coordinate of the lower boundary of the first horizontal line area, wherein the initial value of the y coordinate of the upper boundary of the first horizontal line area is infinite, and the initial value of the y coordinate of the lower boundary of the first horizontal line area is infinitesimal; Traversing the horizontal lines in the first horizontal line list; Update the y coordinate of the upper boundary of the first horizontal line area by comparing the y coordinates of the left and right endpoints of the horizontal line with the y coordinate of the upper boundary of the first horizontal line area; Update the y coordinate of the lower boundary of the first horizontal line area by comparing the y coordinates of the left and right endpoints of the horizontal line with the y coordinate of the lower boundary of the first horizontal line area; Set the initial value of the y coordinate of the upper boundary of the vertical line area and the initial value of the y coordinate of the lower boundary of the vertical line area, wherein the initial value of the y coordinate of the upper boundary of the vertical line area is infinite, and the initial value of the y coordinate of the lower boundary of the vertical line area is infinitesimal; Traversing the vertical lines in the first vertical line list; Update the y coordinate of the upper boundary of the vertical line area by comparing the y coordinate of the upper endpoint of the vertical line with the y coordinate of the upper boundary of the vertical line area; Update the y coordinate of the lower boundary of the vertical line area by comparing the y coordinate of the lower endpoint of the vertical line with the y coordinate of the lower boundary of the vertical line area; Obtaining the y coordinate of the upper boundary of the table line area according to the y coordinate of the upper boundary of the first horizontal line area and the y coordinate of the upper boundary of the vertical line area; Obtaining the y coordinate of the lower boundary of the table line area according to the y coordinate of the lower boundary of the first horizontal line area and the y coordinate of the lower boundary of the vertical line area; Obtaining the height of the table line area according to the upper boundary coordinates and the lower boundary coordinates of the table line area; Set the table area height threshold; If the table line area height is greater than the table area height threshold, determining that the table type is a wireless table; Set the third vertical line number threshold; If the number of vertical lines in the first vertical line list is less than the third vertical line number threshold, determining that the table type is a wireless table; Determining the table type according to the first horizontal line list and the first vertical line list includes: Obtain a table row height list according to the first horizontal line list; Obtaining a row height list standard deviation according to the table row height list; Set the row height standard deviation threshold; If the row height list standard deviation is greater than the row height standard deviation threshold, determining that the type of the table is a wireless table; The method of determining the table type according to the grayscale mean of all pixels in the table image includes: Performing image grayscale processing on the table image using a grayscale method to obtain a grayscale table image; Calculating the grayscale mean of all pixels in the grayscale table image; Set grayscale threshold; If the grayscale mean is less than the grayscale threshold, it is determined that the type of the table is a photographing tilt table.
2. The document image table type determination method according to claim 1, characterized in that: Determining a table type according to the first horizontal line list and the first vertical line list includes: Set the first horizontal line number threshold and the first vertical line number threshold; Obtain the number of horizontal lines in the first horizontal line list and the number of vertical lines in the first vertical line list; If the number of horizontal lines is less than the first horizontal line number threshold or the number of vertical lines is less than the first vertical line number threshold, it is determined that the table type is a wireless table.
3. The method for determining the document image table type according to claim 1, wherein: Determining a table type according to the first horizontal line list and the first vertical line list includes: Set the left and right border ratios of the vertical line horizontal axis area; Obtaining the left and right boundaries of the vertical line area according to the left and right boundary ratios of the vertical line horizontal coordinate area; Construct a second vertical line list, wherein the second vertical line list is initialized to be empty; Adding the vertical lines in the first vertical line list whose midpoint coordinates are located in the vertical line area to the second vertical line list; Determine whether the table type is a wireless table according to the second vertical line list.
4. The method for determining the document image table type according to claim 3, wherein: Determining whether the table type is a wireless table according to the second vertical line list includes: Set the second vertical line number threshold; Get the number of vertical lines in the second vertical line list; If the number of vertical lines in the second vertical line list is not greater than the second vertical line number threshold, it is determined that the table type is a wireless table.
5. The method for determining the document image table type according to claim 3, wherein: Determining whether the table type is a wireless table according to the second vertical line list includes: Set the length ratio of the first vertical line; Obtaining a first vertical line length according to the first vertical line length ratio; Obtain the number of vertical lines in the second vertical line list whose length is not less than the length of the first vertical line; Get the judgment threshold; If the number of vertical lines in the second vertical line list whose lengths are not less than the first vertical line length is less than the determination threshold, the table type is determined to be a wireless table.
6. The method for determining the document image table type according to claim 1, wherein: Determining a table type according to the first horizontal line list and the first vertical line list includes: Set the length ratio of the first horizontal line; Obtaining a first horizontal line length according to the first horizontal line length ratio; Obtain the number of horizontal lines in the first horizontal line list whose length is not less than the first horizontal line length; Set the second horizontal line quantity threshold; If the product of the number of horizontal lines in the first horizontal line list whose length is not less than the first horizontal line length and the second horizontal line number threshold is less than the number of horizontal lines in the first horizontal line list, the table type is determined to be a wireless table.
7. The method for determining the document image table type according to claim 1, wherein: Determining a table type according to the first horizontal line list and the first vertical line list includes: Set the length ratio of the second horizontal line; Obtaining the length of the second horizontal line according to the ratio of the width of the table image to the length of the second horizontal line; Acquire a second horizontal line list according to the first horizontal line list and the second horizontal line length; Set the third horizontal line quantity threshold; If the number of horizontal lines in the second horizontal line list is less than the third horizontal line number threshold, it is determined that the type of the table is a wired table.
8. The method for determining the document image table type according to claim 1, wherein: Determining a table type according to the first horizontal line list and the first vertical line list includes: Acquire a second horizontal line area according to the first horizontal line list; Get the height of the second horizontal line area; Set the length ratio of the second vertical line; Obtaining a second vertical line length according to the second vertical line length ratio and the second horizontal line area height; Obtain a third vertical line list according to the first vertical line list; Setting the first inclined vertical line slope threshold; Obtain the number of vertical lines in the third vertical line list whose slopes are not less than the first inclined vertical line slope threshold; Set the fourth vertical line number threshold; If the number of vertical lines in the third vertical line list whose slopes are not less than the first inclined vertical line slope threshold is not less than the fourth vertical line number threshold, the type of the table is determined to be a photographing tilt table.
9. The method for determining the document image table type according to claim 8, wherein: Determining a table type according to the first horizontal line list and the first vertical line list includes: Setting the second vertical line slope threshold; Obtain the number of vertical lines in the third vertical line list whose slopes are not less than the second inclined vertical line slope threshold; Set the fifth vertical line number threshold; If the number of vertical lines in the third vertical line list whose slopes are not less than the second inclined vertical line slope threshold is less than the fifth vertical line number threshold, it is determined that the type of the table is a wired table.
10. The method for determining the document image table type according to claim 1, wherein: If the table type is determined to be neither a wired table nor a photographing tilt table according to the first horizontal line list and the first vertical line list, and the table type is determined to be neither a wired table nor a photographing tilt table according to the grayscale mean of all pixels in the table image, the table type is determined to be a wired table.
Citation Information
Patent Citations
A method, system, and computer device for extracting tables from a document.
CN115713775B
A method for extracting tender document analysis tables
CN115906763B
PDF framed table extraction method based on image information
CN110163030A
Form recognition method and device in image, electronic equipment and storage medium
CN111814722A
Self-adaptive scanning document image inclination angle detection method
CN115619845A