Image wired table detection method, apparatus, computer equipment and storage medium

By acquiring the binary image of the wired table image, detecting candidate line segments and filtering out those that do not meet the requirements for thickness and angle, and using the trained model to generate the table wireframe, the problem of low accuracy in wired table detection in existing technologies is solved, and fast and accurate table detection is achieved.

CN116721434BActive Publication Date: 2026-04-03HUNAN XINGHAN DIGITAL INTELLIGENCE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-23
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

Existing table detection methods have low accuracy when dealing with wired tables, especially those with multiple rows or columns, making it difficult to quickly and accurately identify table regions.

Method used

By acquiring a binary image of a wired table, candidate line segments are detected, and line segments that do not meet the requirements for thickness and angle are filtered out. The trained model is used to predict the category and generate table wireframes. Table detection is performed by combining image processing and deep learning techniques.

Benefits of technology

It enables fast and accurate detection of wired tables, reduces the impact of changes in table size and line count, and improves detection accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116721434B_ABST
    Figure CN116721434B_ABST
Patent Text Reader

Abstract

This invention relates to the field of computer vision technology, and provides a method, apparatus, computer device, and storage medium for detecting wired tables in images. The method includes: acquiring a binary image of a wired table image; detecting candidate line segments based on the binary image; determining the external connectivity contours of connected pixels for each candidate line segment in the binary image; filtering candidate line segments that do not meet preset thickness requirements based on the external connectivity contours; widening and standardizing each candidate line segment and inputting it into a trained model to predict a category; filtering non-table line segments from the candidate line segments based on the category; filtering candidate line segments that do not meet angle requirements based on the slope; and generating a wireframe of the table based on the remaining candidate line segments after filtering, thus obtaining a wired table. This method can detect wired tables quickly and accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer vision technology, and particularly relates to a method, apparatus, computer device, and storage medium for detecting wired tables in images. Background Technology

[0002] Tables are an important form of information presentation. By organizing complex data into a standardized structure, they facilitate information retrieval, comparison, and analysis, and have become an indispensable element in daily information-based office work. However, in practical applications, for ease of transmission and reading, tables are usually transmitted in PDF or image formats. This means that computers cannot directly understand table information, requiring manual extraction and processing. Given the sheer number and diverse styles of tables in the information age, manual processing is tedious and time-consuming, making the understanding of tables in PDF or image formats a pressing issue.

[0003] Currently, with the rapid development of technology, table understanding technology has ushered in a period of rapid growth, becoming a research hotspot in both academia and industry. Based on current research progress, table understanding technology can be divided into table detection and table recognition. Table detection refers to locating table regions from an image, and is a prerequisite for table recognition. Common table detection methods include object detection-based methods and semantic segmentation-based methods. However, due to the wide variation in table sizes, especially wired tables, which can range from a few rows to hundreds of rows, object detection models and semantic segmentation models are prone to incomplete table region detection, reducing the accuracy of wired table detection. Summary of the Invention

[0004] Therefore, it is necessary to provide a method, apparatus, computer device, and storage medium for fast and accurate wired table detection of images, addressing the aforementioned technical problems.

[0005] This invention provides a method for detecting wired tables in an image, comprising:

[0006] Obtain a binary image of the wired table image, and detect candidate straight line segments based on the binary image;

[0007] Determine the outer connected contour of each candidate straight line segment in the binary image, and filter out the candidate straight line segments that do not meet the preset thickness requirements based on the outer connected contour.

[0008] After widening and standardizing each candidate line segment, the data are input into the trained model to predict the category. Based on the category, non-table line segments are filtered out from the candidate line segments.

[0009] Candidate straight line segments that do not meet the angle requirements are filtered from each candidate straight line segment according to the slope.

[0010] The wireframe of the table is generated based on the remaining candidate line segments after filtering, resulting in a wired table.

[0011] In one embodiment, obtaining a binary image of the wired table image and detecting candidate straight lines based on the binary image includes:

[0012] Otsu's method is used to perform adaptive threshold segmentation on wired table images to obtain binary images;

[0013] Reverse the binary image to obtain an inverted binary image;

[0014] Line detection is performed on the binary image and the inverted binary image to obtain candidate straight lines.

[0015] In one embodiment, determining the outer connectivity contour of each candidate straight line segment in the binary image, and filtering the candidate straight line segments that do not meet the preset thickness requirement based on the outer connectivity contour, includes:

[0016] Find the set of pixels in the binary image that are connected to the candidate straight line segment;

[0017] Contour fitting of the pixel set determines the externally connected contour, resulting in the externally connected contour pixel set;

[0018] Calculate the straight-line distance between each pixel in the set of externally connected contour pixels and the candidate straight-line segment, and calculate the standard deviation of each straight-line distance;

[0019] Candidate line segments whose difference between the straight-line distance and the standard deviation is greater than the thickness threshold are eliminated.

[0020] In one embodiment, the step of widening and standardizing each candidate line segment and then inputting it into a trained model to predict a category, and filtering non-table line segments from the candidate line segments according to the category, includes:

[0021] Extend the candidate straight line segment by its starting point and ending point to obtain the extended coordinates;

[0022] A coordinate system is constructed based on the origin, the extension length, and the distance between the starting point coordinates and the ending point coordinates as a standard point. The extended coordinates are used as the base points, and the transformation matrix is ​​calculated based on the standard points and the base points.

[0023] After standardizing the wired table image using the transformation matrix, the corresponding sub-image region is extracted to obtain the line segment sub-image of the candidate straight line segment;

[0024] The line segment subgraph is input into the trained model to predict the category, and the candidate straight line segments that are classified as non-table line segments are removed.

[0025] In one embodiment, the step of extending the candidate straight line segment from its start and end points to obtain the extended coordinates includes:

[0026] The extension length is determined by the product of the length of the candidate straight line segment and the length threshold.

[0027] Using the starting point and the ending point as centers, extend the line along the vertical direction of the candidate straight line segment to both sides based on the extension length to obtain the extension coordinates.

[0028] In one embodiment, filtering candidate straight line segments that do not meet the angle requirement from each of the candidate straight line segments based on the slope includes:

[0029] Based on the slope of each candidate straight line segment, the candidate straight line segments are clustered to determine horizontal and vertical line segments;

[0030] Calculate the standard slope of each horizontal line segment and each vertical line segment to obtain the standard slope of the horizontal line and the standard slope of the vertical line.

[0031] The angle difference is calculated based on the slope of the horizontal line segment and the standard slope of the horizontal line, and the angle difference is calculated based on the slope of the vertical line segment and the standard slope of the vertical line.

[0032] Candidate straight line segments whose angle difference is greater than the angle threshold are filtered out.

[0033] In one embodiment, generating a wireframe of a table based on the remaining candidate line segments after filtering to obtain a wired table includes:

[0034] Construct a blank binary image with the same size as the wired table image;

[0035] Based on the remaining candidate line segments after filtering, straight lines are drawn in the blank binary image to obtain a table line image;

[0036] After dilating and eroding the table line image, connected regions are found, and the table border is drawn based on the minimum bounding rectangle of the connected regions to obtain a line table.

[0037] An image wired table detection device, comprising:

[0038] The line detection module is used to acquire a binary image of a line table image and detect candidate line segments based on the binary image.

[0039] The coarse-fine filtering module is used to determine the outer connected contour of each candidate straight line segment in the binary image, and filter the candidate straight line segments that do not meet the preset coarse-fine requirements according to the outer connected contour.

[0040] The model filtering module is used to broaden and standardize each candidate line segment and then input it into the trained model to predict the category, and filter out non-table line segments from the candidate line segments according to the category.

[0041] An angle filtering module is used to filter candidate straight line segments that do not meet the angle requirements from each of the candidate straight line segments according to the slope.

[0042] The wireframe generation module is used to generate the wireframe of the table based on the remaining candidate line segments after filtering, resulting in a wired table.

[0043] The present invention also provides a computer device, the computer device including a processor and a memory, the memory storing a computer program, the processor executing the computer program to implement the steps of the image wired table detection method described above.

[0044] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the image wired table detection method described in any of the preceding claims.

[0045] The aforementioned method, apparatus, computer device, and storage medium for detecting wired tables in images acquire a binary image of the wired table image. Based on the binary image, candidate line segments are detected. The outer connected contours of the connected pixels in the binary image for each candidate line segment are determined, and line segments that do not meet the preset thickness requirements are filtered out. Simultaneously, each candidate line segment is widened and standardized before being input into a trained model to predict and filter candidate line segments classified as non-table line segments. Line segments that do not meet the angle requirements are also filtered out based on their slope. The remaining candidate line segments are then used to generate the wireframe of the table to obtain the wired table. This method analyzes and filters lines based on the lines themselves, as well as their thickness and angle characteristics, to ultimately obtain the table region. Compared to object detection and semantic segmentation methods, it is less affected by changes in table size and the number of lines, thus achieving fast and accurate wired table detection. Attached Figure Description

[0046] Figure 1 This is an application environment diagram of an image wired table detection method in one embodiment.

[0047] Figure 2 This is a flowchart illustrating an image wired table detection method in one embodiment.

[0048] Figure 3 This is a structural block diagram of an image wired table detection device in one embodiment. Detailed Implementation

[0049] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0050] The image wired table detection method provided in this application can be applied to, for example... Figure 1 In the application environment shown, the application environment involves a terminal 102 and a server 104. The terminal 102 communicates with the server 104 via a network. The terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices, and the server 104 can be implemented as a standalone server or a server cluster consisting of multiple servers.

[0051] When terminal 102 receives an image wired table detection instruction, it can implement the above-described image wired table detection method independently. Alternatively, terminal 102 can send the image wired table detection instruction to the communicating server 104, and server 104 can implement the above-described image wired table detection method. Taking server 104 as an example, specifically, server 104 acquires the binary image of the wired table image and detects candidate line segments based on the binary image; server 104 determines the outer connectivity contour of each candidate line segment's connected pixels in the binary image, and filters out candidate line segments that do not meet the preset thickness requirements based on the outer connectivity contour; server 104 widens and standardizes each candidate line segment and inputs it into the trained model to predict the category, and filters out non-table line segments from the candidate line segments based on the category; server 104 filters out candidate line segments that do not meet the angle requirements based on the slope; server 104 generates the wireframe of the table based on the remaining candidate line segments after filtering, thus obtaining the wired table.

[0052] In one embodiment, such as Figure 2 As shown, a method for detecting wired tables in an image is provided. Taking the application of this method to a server as an example, the method includes the following steps:

[0053] Step S201: Obtain the binary image of the wired table image, and detect candidate straight line segments based on the binary image.

[0054] Among them, candidate line segments refer to line segments selected from the line table image.

[0055] Specifically, upon receiving a wired table detection instruction, the corresponding wired table image is first acquired. Then, image processing is performed on the wired table image to obtain a binary image, which can be obtained by adaptive thresholding of the wired table image. Finally, line detection is performed on the binary image to obtain candidate line segments.

[0056] In one embodiment, step S201 includes: performing adaptive threshold segmentation on the wired table image using the Otsu method to obtain a binary image; inverting the binary image to obtain an inverted binary image; and performing line detection on the binary image and the inverted binary image to obtain candidate straight lines.

[0057] Specifically, for the line table image I, adaptive thresholding can be performed using the Otsu method to obtain a binary image Ib1. Simultaneously, considering the diversity of table line colors, there might be cases where the line color and text color differ, so the binary image Ib1 can be inverted to obtain an inverted binary image Ib2. Then, line detection is performed on the two binary images Ib1 and Ib2 respectively to obtain candidate line segments. Line detection can employ any existing method; this embodiment preferably uses Hough line detection. The candidate line segments obtained in this embodiment can be recorded as Lc={l1,l2,……,ln}, where each candidate line segment li={(x1,y1),(x2,y2),θ,Ib}, (x1,y1),(x2,y2) are the coordinates of the two starting points of the candidate line segment, θ is the slope of the candidate line segment, and Ib is the source binary image of the candidate line segment.

[0058] Step S202: Determine the outer connected contour of each candidate straight line segment in the connected pixels of the binary image, and filter out the candidate straight line segments that do not meet the preset thickness requirements based on the outer connected contour.

[0059] In this context, connected pixels refer to pixels in the binary image that are connected to the candidate line segments. Externally connected contours refer to the outer contour obtained based on all connected pixels. Preset thickness requirements are the width requirements set for the lines based on actual conditions. Filtering refers to removing line segments.

[0060] Specifically, after obtaining candidate line segments through line detection, some of these segments may not be table line segments, so filtering is necessary. This embodiment filters lines based on the consistency of line thickness in the table. That is, firstly, a set of pixels connected to the candidate line segments is obtained in the binary image, and the outer connectivity contour is determined using this set of connected pixels. The thickness of the candidate line segments is then measured based on this outer connectivity contour, and candidate line segments that do not meet the preset thickness requirements are filtered out and eliminated.

[0061] In one embodiment, step S202 includes: finding a set of pixels connected to the candidate straight line segment from the binary image; determining the externally connected contour by fitting the set of pixels to the contour, and obtaining the set of pixels with the externally connected contour; calculating the straight-line distance between each pixel in the set of pixels with the externally connected contour and the candidate straight line segment, and calculating the standard deviation of each straight-line distance; and removing candidate straight line segments whose difference between the straight-line distance and the standard deviation is greater than the thickness threshold.

[0062] Specifically, for any candidate line segment li = {(x1,y1),(x2,y2),θ,Ib} in Lc, firstly, find all pixels connected to the candidate line segment li from the corresponding Ib, obtaining the set of connected pixels. Secondly, use contour fitting to find the corresponding outer connected contour of this set of connected pixels, thus obtaining the set of outer connected contour pixels, which can be denoted as C = {(xc1,yc1),(xc2,yc2),……,(xck,yck)}. Then, sequentially extract each outer connected contour pixel (xck,yck) from C, and calculate the linear distance dis between it and the candidate line segment. ck The formula for calculating straight-line distance is as follows:

[0063] After obtaining the straight-line distances between all pixels in C and the candidate line segments, the standard deviation of the straight-line distances is calculated. Finally, the standard deviation is compared with a set thickness threshold. If the difference between the straight-line distance of a candidate line segment li and the standard deviation is greater than the thickness threshold, the line segment li is considered an invalid line segment that does not meet the preset thickness requirements and is removed from Lc. In this embodiment, based on actual conditions, a thickness threshold of 5 is preferably set.

[0064] Step S203: After widening and standardizing each candidate line segment, input it into the trained model to predict the category, and filter out non-table line segments from the candidate line segments according to the category.

[0065] In this context, widening refers to incorporating pixel information from the surrounding area of ​​the line segment. Standardization refers to performing a standardization operation on the image. Non-table line segments are those that do not belong to the original table of lines. The model is a pre-trained neural network model for predicting line segment categories, and the output predicted category can be represented by a label. For example, label 0 represents a non-table line segment, and label 1 represents a table line segment.

[0066] Specifically, while filtering candidate straight line segments based on thickness and orientation, this embodiment also filters non-table line segments using a neural network. The corresponding line segment sub-images are extracted from the original line table image and input into the model to predict the category. It is important to note that before inputting the candidate straight line segments into the model, they need to be widened and the image standardized. This is because in real-world scenarios, lines are typically narrow straight lines with arbitrary directions, such as vertical, horizontal, or tilted at an angle. Directly inputting these into the neural network would normalize the image size, leading to severe line segment distortion. Therefore, this embodiment widens the line segments so that the widened image includes not only the pixel information of the line segment but also the pixel information of its surrounding area, enriching the semantic features of the line segment image. Simultaneously, standardization through perspective transformation avoids line distortion, preserving the original image features, thereby reducing model training difficulty and improving classification accuracy.

[0067] In one embodiment, step S203 includes: extending the candidate straight line segment by its starting point and ending point to obtain extended coordinates; constructing coordinates as standard points based on the origin, extension length, and the distance between the starting point coordinates and the ending point coordinates, and using the extended coordinates as base points, calculating a transformation matrix based on the standard points and base points; standardizing the line table image using the transformation matrix and then cropping the corresponding sub-image region to obtain the line segment sub-image of the candidate straight line segment; inputting the line segment sub-image into the trained model to predict the category, and removing candidate straight line segments whose category is not a table line segment.

[0068] Specifically, firstly, based on the starting point (x1, y1) and ending point (x2, y2), the extended coordinates are obtained as (x1l, y1l), (x1r, y1r), (x2l, y2l), and (x2r, y2r). Secondly, coordinates are constructed as standard points for the transformation matrix calculation based on the origin 0, the extension length B, and the distance D between the starting and ending point coordinates. These standard points include: (0, 0), (0, 2×B), (D, 0), and (D, 2×B). The formula for calculating the distance D between the starting and ending point coordinates is as follows:

[0069]

[0070] Simultaneously, using the extended coordinates (x1l, y1l), (x1r, y1r), (x2l, y2l), and (x2r, y2r) as the base points, the transformation matrix M is calculated. Then, the line table image I is normalized using the transformation matrix M to obtain a normalized image. The corresponding sub-image region is extracted from the normalized image as the line segment sub-image of the candidate line segment. That is, the bounding box coordinates of the extracted sub-image region are (0, 0), (0, 2×B), (D, 0), and (D, 2×B). Finally, the extracted line segment sub-image is input into the trained neural network model for category prediction. If the model predicts that it is a non-table line segment, the corresponding candidate line segment is removed from Lc. In addition, the image size can be scaled according to actual needs before inputting into the neural network model. In this embodiment, the line segment sub-image is preferably scaled to (56, 28) before being input into the neural network. The neural network can be any existing neural network for category prediction. In this embodiment, the VGG neural network is preferred.

[0071] In one embodiment, extending the candidate straight line segment to obtain the extended coordinates by taking the start and end points of the line segment includes: determining the extension length based on the product of the length of the candidate straight line segment and a length threshold; and extending the line segment to both sides along the vertical direction of the candidate straight line segment based on the extension length, with the start and end points as the centers, to obtain the extended coordinates.

[0072] Specifically, for any candidate line segment li = {(x1,y1),(x2,y2),θ,Ib} in Lc, with the starting coordinates (x1,y1) and ending coordinates (x2,y2) as centers, extend B pixels to both sides along the vertical direction of the candidate line segment, obtaining the extended coordinates (x1l,y1l), (x1r,y1r) corresponding to the starting coordinates (x1,y1), and the extended coordinates (x2l,y2l), (x2r,y2r) corresponding to the ending coordinates. Here, B is 0.25 times the length of the candidate line segment. That is, the product of the length of the candidate line segment and the length threshold of 0.25 is used as the extension length B.

[0073] Step S204: Filter out candidate straight line segments that do not meet the angle requirements from each candidate straight line segment according to the slope.

[0074] Specifically, due to the nature of tables, the tilt angle of table lines is usually within a fixed range. Once it exceeds a certain angle range, it is very likely that it is not a line in the table. Therefore, this embodiment further filters candidate line segments in Lc based on preset angle requirements. Since the angle of a line segment can usually be determined based on its slope, candidate lines that do not meet the angle requirements can be accurately screened out and filtered out by using the slope.

[0075] In one embodiment, step S204 includes: clustering each candidate straight line segment based on the slope of each candidate straight line segment to determine horizontal and vertical line segments; calculating the standard slope of each horizontal and vertical line segment to obtain the standard slope of the horizontal line and the standard slope of the vertical line; calculating the corresponding angle difference based on the slope of the horizontal line segment and the standard slope of the horizontal line, and calculating the corresponding angle difference based on the slope of the vertical line segment and the standard slope of the vertical line; and filtering candidate straight line segments whose angle difference is greater than an angle threshold.

[0076] Specifically, for all candidate straight line segments in Lc, their slopes θ are extracted, and clustering functions are used to cluster the candidate straight line segments based on their slopes θ. The lines in the table are typically divided into horizontal and vertical lines, so in this embodiment, the number of clustering categories is set to 2. Clustering divides the candidate straight line segments into horizontal and vertical segments. Then, for all horizontal line segments, the median of their slopes θ is taken as the standard slope of the horizontal line segment, thus obtaining the standard slope of the horizontal line. The angle difference between the slope angle and the corresponding angle of the standard horizontal slope is calculated for each horizontal line segment. If the angle difference is greater than the angle threshold, it indicates that it does not meet the preset angle requirement and is an invalid line segment; therefore, the invalid horizontal line segment is removed from Lc. Similarly, for vertical line segments, the same method is used to remove invalid vertical line segments from Lc. That is, the median of the slopes of all vertical line segments is taken as the standard slope of the vertical line segment, thus obtaining the standard slope of the vertical line. Similarly, the slope angle of each vertical line segment is calculated sequentially, and the angle difference between the slope angle and the standard slope angle of the vertical line is calculated. If the angle difference is greater than the angle threshold, the segment is filtered out. In this embodiment, the angle threshold is preferably 15 degrees, that is, line segments with an angle difference greater than 15 degrees are filtered out.

[0077] Step S205: Generate the wireframe of the table based on the remaining candidate line segments after filtering, and obtain the wired table.

[0078] Specifically, after filtering out line segments in Lc that do not meet the requirements through a series of methods such as thickness, angle, and neural networks, the remaining candidate line segments are the lines in the table. Therefore, the wireframe of the table can be generated based on the remaining candidate line segments after filtering, thus obtaining the line table in the line table image.

[0079] In one embodiment, step S205 includes: constructing a blank binary image with the same size as the wired table image; drawing straight lines in the blank binary image based on the remaining candidate line segments after filtering to obtain a table line image; dilating and eroding the table line image to find connected regions, and drawing the table border based on the minimum bounding rectangle of the connected regions to obtain a wired table.

[0080] Specifically, first, a blank binary image with the same size as the wired table image I is constructed, meaning all pixels in the constructed binary image have a value of 0. Then, one candidate line segment is sequentially selected from the remaining candidate line segments, and the corresponding line is drawn on the blank binary image using a drawing function, with the pixel color set to 255, thus obtaining the table line image. Next, morphological operations of dilation and erosion are performed on the obtained table line image. In this embodiment, a 7x7 Gaussian kernel is preferably used for dilation and erosion to obtain a new image. Finally, a connected component search method is used on the new image to obtain a series of connected components. For each connected component, its minimum bounding rectangle is calculated, and this minimum bounding rectangle is used as the table's border, resulting in a series of table coordinates. At this point, the table lines and table borders are determined, thus accurately obtaining the wired table in the wired table image.

[0081] The aforementioned wired table detection method addresses the issue of inaccurate region detection in real-world scenarios due to the diverse table sizes. This is because methods based on object detection and semantic segmentation often suffer from variations in table size. Instead, this method combines traditional image processing techniques with deep learning to directly analyze and filter table lines. This approach analyzes and filters lines based on their inherent characteristics, such as thickness and angle, to ultimately identify the table regions. Compared to object detection and semantic segmentation methods, this method is less affected by variations in table size and the number of lines, thus achieving fast and accurate wired table detection.

[0082] It should be understood that, although Figure 2 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figure 2 At least some of the steps in the process may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but may be executed at different times. The execution order of these steps or stages is not necessarily sequential, but may be executed in turn or alternately with other steps or at least some of the steps or stages in other steps.

[0083] In one embodiment, such as Figure 3 As shown, an image wired table detection device is provided, comprising:

[0084] The line detection module 301 is used to acquire a binary image of a line table image and detect candidate line segments based on the binary image.

[0085] The coarse-fine filtering module 302 is used to determine the outer connectivity contour of each candidate straight line segment in the connected pixels of the binary image, and filter the candidate straight line segments that do not meet the preset coarse-fine requirements based on the outer connectivity contour.

[0086] The model filtering module 303 is used to broaden and standardize each candidate line segment before inputting it into the trained model to predict the category, and to filter non-table line segments from the candidate line segments according to the category.

[0087] Angle filtering module 304 is used to filter candidate straight line segments that do not meet the angle requirements from each candidate straight line segment according to the slope.

[0088] The wireframe generation module 305 is used to generate the wireframe of the table based on the remaining candidate straight line segments after filtering, so as to obtain a wired table.

[0089] In one embodiment, the line detection module 301 is further configured to perform adaptive threshold segmentation on the wired table image using the Otsu method to obtain a binary image; invert the binary image to obtain an inverted binary image; and perform line detection on the binary image and the inverted binary image to obtain candidate lines.

[0090] In one embodiment, the coarse-fine filtering module 302 is further configured to find a set of pixels connected to the candidate straight line segments from the binary image; determine the externally connected contour by fitting the set of pixels to obtain the set of pixels of the externally connected contour; calculate the straight-line distance between each pixel in the set of pixels of the externally connected contour and the candidate straight line segments, and calculate the standard deviation of each straight-line distance; and remove the candidate straight line segments whose difference between the straight-line distance and the standard deviation is greater than the coarse-fine threshold.

[0091] In one embodiment, the model filtering module 303 is further configured to extend the candidate straight line segments by their start and end points to obtain extended coordinates; construct coordinates as standard points based on the origin, extension length, and the distance between the start and end coordinates, and use the extended coordinates as base points to calculate a transformation matrix based on the standard and base points; after standardizing the line table image using the transformation matrix, extract the corresponding sub-image region to obtain the line segment sub-image of the candidate straight line segments; input the line segment sub-image into the trained model to predict the category, and remove the candidate straight line segments whose category is not a table line segment.

[0092] In one embodiment, the model filtering module 303 is further configured to determine the extension length based on the product of the length of the candidate straight line segment and the length threshold; and extend the extension length along the vertical direction of the candidate straight line segment to both sides, with the starting point and the ending point as the center, to obtain the extension coordinates.

[0093] In one embodiment, the angle filtering module 304 is further configured to cluster each candidate straight line segment based on the slope of each candidate straight line segment to determine horizontal and vertical line segments; calculate the standard slope of each horizontal and vertical line segment respectively to obtain the standard slope of the horizontal line and the standard slope of the vertical line; calculate the corresponding angle difference based on the slope of the horizontal line segment and the standard slope of the horizontal line, and calculate the corresponding angle difference based on the slope of the vertical line segment and the standard slope of the vertical line; and filter out candidate straight line segments whose angle difference is greater than the angle threshold.

[0094] In one embodiment, the wireframe generation module 305 is further configured to construct a blank binary image with the same size as the wired table image; draw straight lines in the blank binary image based on the remaining candidate straight line segments after filtering to obtain a table line image; dilate and erode the table line image to find connected regions, and draw the table border based on the minimum bounding rectangle of the connected regions to obtain a wired table.

[0095] Specific limitations regarding the image wired table detection device can be found in the limitations of the image wired table detection method described above, and will not be repeated here. Each module in the aforementioned image wired table detection device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the aforementioned image wired table detection method embodiments. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms.

[0096] In one embodiment, a computer device is provided, which may be a server, including a processor, memory, and a network interface. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements an image wired table detection method. Exemplarily, the computer program may be divided into one or more modules, one or more of which are stored in memory and executed by the processor to complete the invention. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program in the computer device.

[0097] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the computer device, connecting various parts of the computer device via various interfaces and lines.

[0098] The memory can be used to store the computer programs and / or modules. The processor implements various functions of the computer device by running or executing the computer programs and / or modules stored in the memory and by calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, RAM, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0099] Those skilled in the art will understand that the computer device structure shown in this embodiment is only a partial structure related to the present invention and does not constitute a limitation on the computer device to which the present invention is applied. A specific computer device may include more or fewer components, or combine certain components, or have different component arrangements.

[0100] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the image wired table detection method described in any of the above embodiments.

[0101] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the image wired table detection method described in any of the above embodiments.

[0102] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.

[0103] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above 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.

[0104] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A method for detecting wired tables in an image, characterized in that, include: Obtain a binary image of the wired table image, and detect candidate straight line segments based on the binary image; Determine the outer connected contour of each candidate straight line segment in the binary image, and filter out the candidate straight line segments that do not meet the preset thickness requirements based on the outer connected contour. After widening and standardizing each candidate straight line segment, it is input into the trained model to predict the category. Non-table line segments are then filtered from the candidate straight line segments according to the category. Specifically, this includes: extending the line segments from their start and end points to obtain extended coordinates; constructing coordinates as standard points based on the origin, extension length, and the distance between the start and end coordinates; using the extended coordinates as base points; calculating a transformation matrix based on the standard points and base points; standardizing the line table image using the transformation matrix and then cropping the corresponding sub-image region to obtain the line segment sub-image of the candidate straight line segments; inputting the line segment sub-image into the trained model to predict the category, and removing candidate straight line segments whose category is non-table line segments. Candidate straight line segments that do not meet the angle requirements are filtered from each candidate straight line segment according to the slope. The wireframe of the table is generated based on the remaining candidate line segments after filtering, resulting in a wired table.

2. The method according to claim 1, characterized in that, The step of obtaining a binary image of a wired table image and detecting candidate straight lines based on the binary image includes: Otsu's method is used to perform adaptive threshold segmentation on wired table images to obtain binary images; Reverse the binary image to obtain an inverted binary image; Line detection is performed on the binary image and the inverted binary image to obtain candidate straight lines.

3. The method according to claim 1, characterized in that, The step of determining the outer connected contour of each candidate straight line segment in the binary image, and filtering out candidate straight line segments that do not meet the preset thickness requirements based on the outer connected contour, includes: Find the set of pixels in the binary image that are connected to the candidate straight line segment; Contour fitting of the pixel set determines the externally connected contour, resulting in the externally connected contour pixel set; Calculate the straight-line distance between each pixel in the set of externally connected contour pixels and the candidate straight-line segment, and calculate the standard deviation of each straight-line distance; Candidate line segments whose difference between the straight-line distance and the standard deviation is greater than the thickness threshold are eliminated.

4. The method according to claim 1, characterized in that, The step of extending the candidate straight line segment to obtain the extended coordinates by using the start and end points of the line segment includes: The extension length is determined by the product of the length of the candidate straight line segment and the length threshold. Using the starting point and the ending point as centers, extend the line along the vertical direction of the candidate straight line segment to both sides based on the extension length to obtain the extension coordinates.

5. The method according to claim 1, characterized in that, The step of filtering candidate straight line segments that do not meet the angle requirements from each candidate straight line segment based on the slope includes: Based on the slope of each candidate straight line segment, the candidate straight line segments are clustered to determine horizontal and vertical line segments; Calculate the standard slope of each horizontal line segment and each vertical line segment to obtain the standard slope of the horizontal line and the standard slope of the vertical line. The angle difference is calculated based on the slope of the horizontal line segment and the standard slope of the horizontal line, and the angle difference is calculated based on the slope of the vertical line segment and the standard slope of the vertical line. Candidate straight line segments whose angle difference is greater than the angle threshold are filtered out.

6. The method according to claim 1, characterized in that, The process of generating a wireframe for a table based on the remaining candidate line segments after filtering, resulting in a wired table, includes: Construct a blank binary image with the same size as the wired table image; Based on the remaining candidate line segments after filtering, straight lines are drawn in the blank binary image to obtain a table line image; After dilating and eroding the table line image, connected regions are found, and the table border is drawn based on the minimum bounding rectangle of the connected regions to obtain a line table.

7. An image wired table detection device, characterized in that, include: The line detection module is used to acquire a binary image of a line table image and detect candidate line segments based on the binary image. The coarse-fine filtering module is used to determine the outer connected contour of each candidate straight line segment in the binary image, and filter the candidate straight line segments that do not meet the preset coarse-fine requirements according to the outer connected contour. The model filtering module is used to widen and standardize each candidate line segment before inputting it into the trained model to predict the category, and to filter non-table line segments from the candidate line segments according to the category; specifically, it is used to extend the line segments with the start and end points of the candidate line segments to obtain the extended coordinates; construct coordinates as standard points based on the origin, the extension length, and the distance between the start and end coordinates, and use the extended coordinates as base points to calculate the transformation matrix based on the standard points and the base points; After standardizing the wired table image using the transformation matrix, the corresponding sub-image region is extracted to obtain the line segment sub-image of the candidate straight line segment; the line segment sub-image is input into the trained model to predict the category, and the candidate straight line segments whose category is not table line segment are removed. An angle filtering module is used to filter candidate straight line segments that do not meet the angle requirements from each of the candidate straight line segments according to the slope. The wireframe generation module is used to generate the wireframe of the table based on the remaining candidate line segments after filtering, resulting in a wired table.

8. A computer device comprising a processor and a memory, the memory storing a computer program, characterized in that, The processor is used to execute the computer program to implement the image wired table detection method according to any one of claims 1-6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the image wired table detection method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Method and device for determining image definition and storage medium

    CN112700407A

  • Information extraction method and device, equipment and storage medium

    CN114120345A