Table structure intelligent extraction method and system for water conservancy engineering images
By improving the HAWP model and clustering algorithm, the problems of accuracy and robustness in extracting table structures from water conservancy engineering images were solved, and efficient and accurate automatic extraction of table structures was achieved.
Patent Information
- Application Number
- CN202511477033.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-16
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2045-10-16
AI Technical Summary
Existing technologies have low accuracy and poor robustness when automatically extracting table structures from complex water conservancy engineering images. They are unable to accurately distinguish table lines and handle line breaks and noise interference, and have weak generalization ability.
An improved HAWP model is used to predict candidate line segments. By combining clustering, filtering and merging operations, the outer boundary of the table is determined, the row and column structure and merged cells are identified, and a complete table structure model is generated. A row and column network model is established by calculating the intersection points.
It improves the accuracy and robustness of table structure extraction, reduces line breaks and noise interference, and realizes the automatic extraction of table structures from complex engineering drawings.
Smart Images

Figure CN120976952B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image table extraction technology, and in particular to an intelligent extraction method, system, storage medium and electronic device for table structures of water conservancy engineering images. Background Technology
[0002] Images of hydraulic engineering projects often contain tabular structures to present information such as engineering parameters and material lists, including reinforcement detail tables. These tables use a regular grid of rows and columns to divide cells, carrying key information and facilitating data retrieval within the drawings.
[0003] However, automatically extracting such table structures from complex engineering drawings is quite challenging. Traditional methods typically rely on image processing algorithms, such as the Canny operator, for edge detection, followed by Hough transform to detect straight lines in an attempt to reconstruct the table grid. However, in practical applications, engineering drawings contain numerous lines and symbols in addition to tables, and edge detection methods like Canny generate many interfering edges, making it difficult to accurately distinguish table lines. Secondly, scanning noise or printing defects often cause broken or missing table lines. While Hough transform can detect straight lines, it performs poorly with broken or discontinuous lines, easily missing detections or producing distorted line detection results. Furthermore, traditional methods heavily rely on manually setting thresholds and rules, resulting in weak generalization ability and difficulty in maintaining stable operation on drawings of different formats. For example, when table lines are partially covered by text or contain merged cells, edge- and morphology-based algorithms often fail to properly identify the complete table structure. Therefore, existing extraction methods suffer from low accuracy and poor robustness in complex drawings, making them unsuitable for practical engineering needs. Summary of the Invention
[0004] This application provides an intelligent extraction method, system, storage medium, and electronic device for table structures in water conservancy engineering images, which can improve the accuracy and robustness of table structure extraction.
[0005] This application provides an intelligent method for extracting table structures from water conservancy engineering images, including:
[0006] Acquire images of water conservancy projects and preprocess the images;
[0007] The preprocessed water conservancy project image is input into the improved HAWP model to obtain the predicted candidate line segments;
[0008] Clustering is performed on the candidate line segments to obtain a preliminary table frame set of line segments;
[0009] After a second screening of the line segments excluded during the clustering process, they are re-added to the initial table frame line segment set. The initial table frame line segment set of the line segments added after the second screening is then merged with broken line segments and redundant and isolated line segments are removed to obtain the updated table line segment set.
[0010] Determine the outer boundaries of the table, analyze the internal row and column structure and row height and column width distribution, identify merged cell areas, and generate a complete table structure model;
[0011] Calculate all intersections of horizontal and vertical lines, establish a cell coordinate system, transform the complete table structure model into two-dimensional matrix data, and generate a row and column network model.
[0012] This application also provides an intelligent extraction system for table structures in water conservancy engineering images, including:
[0013] An acquisition and preprocessing module is used to acquire images of water conservancy projects and preprocess the images of water conservancy projects.
[0014] The candidate line segment prediction module is used to input the preprocessed water conservancy project image into the improved HAWP model to obtain the predicted candidate line segments.
[0015] The line segment clustering module is used to perform clustering operations on the candidate line segments to obtain a preliminary table framework set of line segments.
[0016] The line segment processing module is used to perform secondary screening on the line segments excluded during the clustering process and then re-add them to the initial table frame line segment set. The module then performs operations such as merging broken line segments, removing redundant and isolated line segments from the initial table frame line segment set of the line segments that have been added after secondary screening, to obtain the updated table line segment set.
[0017] The boundary determination module is used to determine the outer boundary of the table, analyze the internal row and column structure and row height and column width distribution of the table, identify merged cell areas, and generate a complete table structure model.
[0018] The row and column network model generation module is used to calculate all intersections of horizontal and vertical lines, establish a cell coordinate system, and transform the complete table structure model into two-dimensional matrix data to generate a row and column network model.
[0019] This application also provides a computer-readable storage medium storing multiple instructions adapted for loading by a processor to execute any of the above-described intelligent extraction methods for table structures of water conservancy engineering images.
[0020] This application also provides an electronic device, including a processor and a memory, wherein the processor is electrically connected to the memory, the memory is used to store instructions and data, and the processor is used in the steps of the intelligent extraction method for table structure of water conservancy engineering images as described in any of the above claims.
[0021] This application provides an intelligent method, system, storage medium, and electronic device for extracting table structures from water conservancy engineering images. Based on the engineering image, this application predicts candidate line segments and performs a series of clustering operations, merging, redundancy removal, and de-isolation processing on the candidate line segments to obtain a set of table line segments. By determining the table's outer boundaries, row height, column width, and identifying intersection points, a row-column network model is obtained. This application can automatically extract table structures from complex engineering drawings, improving the accuracy and robustness of table structure extraction and reducing the occurrence of broken or missing table lines. Attached Figure Description
[0022] The technical solution and other beneficial effects of this application will become apparent from the following detailed description of specific embodiments in conjunction with the accompanying drawings.
[0023] Figure 1 A flowchart of an intelligent extraction method for table structures of water conservancy project images provided in an embodiment of this application.
[0024] Figure 2 The image is a preprocessed image of a water conservancy project provided for an embodiment of this application.
[0025] Figure 3 A schematic diagram of the structure of the improved HAWP model provided in the embodiments of this application.
[0026] Figure 4 The generated candidate line segments are provided for the embodiments of this application.
[0027] Figure 5 The clustering results provided for the embodiments of this application.
[0028] Figure 6 The result of adding missing line segments provided in the embodiments of this application.
[0029] Figure 7 The merged table segments provided in the embodiments of this application.
[0030] Figure 8 This is a schematic diagram showing the comparison before and after nonmaximum suppression processing provided in the embodiments of this application.
[0031] Figure 9 The table structure line extraction results provided in the embodiments of this application.
[0032] Figure 10The result of processing the table content lines provided in the embodiments of this application.
[0033] Figure 11 The row and column grid model provided for the embodiments of this application.
[0034] Figure 12 This is a schematic diagram of the structure of an intelligent extraction system for table-structured water conservancy project images provided in an embodiment of this application.
[0035] Figure 13 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0036] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0037] This application provides an intelligent extraction method, system, storage medium, and electronic device for table structures in water conservancy engineering images. The intelligent extraction system for table structures in water conservancy engineering images provided in this application can be integrated into an electronic device, such as a terminal or server. The terminal can include a tablet computer, laptop computer, personal computer (PC), microprocessor box, or other devices.
[0038] Please see Figure 1 , Figure 1 The flowchart illustrates an intelligent extraction method for table structures in water conservancy engineering images, provided in this application embodiment. This method, applied in electronic devices, includes the following steps:
[0039] S1: Acquire images of water conservancy projects and preprocess them.
[0040] Specifically, the acquired images of water conservancy projects (scanned copies or photographs of water conservancy project drawings) typically contain colored backgrounds and noise. During processing, the image is first converted to grayscale to reduce color interference. Then, adaptive binarization and contrast enhancement are performed to create a clear contrast between the table lines and the background, making them easier for subsequent network models to detect. A bilateral filtering denoising algorithm is used to remove noise such as paper texture and stains, preserving the clarity of the lines. For drawings with rotation or tilt, geometric correction is performed, using the largest quadrilateral border of the drawing to rotate and align the image, ensuring that the table lines are as horizontal or vertical as possible. After these processes, the output is a clean and corrected image, with clearer and more continuous table lines, preparing for line detection in the subsequent depth model. Figure 2 The image is a preprocessed image of a water conservancy project provided for an embodiment of this application.
[0041] S2. Input the preprocessed water conservancy project image into the improved HAWP model to obtain the predicted candidate line segments.
[0042] Figure 3 A schematic diagram of the structure of the improved HAWP model provided in the embodiments of this application is shown below. Figure 3 As shown, the improved HAWP model includes a backbone feature extraction network, a table structure feature perception branch, an attraction field prediction module, and a confidence prediction head;
[0043] The improved HAWP model processing procedure includes:
[0044] S21, the preprocessed water conservancy project image is input into the backbone feature extraction network for multi-scale feature extraction and fusion to obtain a fused feature map.
[0045] The backbone feature extraction network uses a multi-layer convolutional structure to extract low-level texture features and high-level semantic features from the image. Specifically, the backbone feature extraction network adopts a Feature Pyramid Network (FPN) structure, which can extract image features at different scales: low-level features retain rich detailed textures to characterize the edge contours of lines; high-level features aggregate global semantic information, highlighting candidate regions for the distribution of table lines (referring to the region range corresponding to the potential line segments). Through this multi-scale feature representation, the model simultaneously captures the edge details and region layout of line segments at both fine-grained and global levels, providing a rich information foundation for subsequent line segment detection. After the above multi-scale feature maps are output by the FPN structure, they are fused with low-level texture features and high-level semantic features through skip-connections (residual connections) to form a unified fused feature map F. This fused feature map simultaneously encodes low-level texture features and high-level semantic structural information, serving as the direct input feature map for the attraction field prediction module. Its channel dimension encodes image structural information under different receptive fields.
[0046] S22, input the fused feature map into the table structure feature perception branch to obtain the table structure feature map.
[0047] S23, perform channel-wise feature weighting on the fused feature map and the table structure feature map to obtain the enhanced fused feature map.
[0048] The table structure-aware feature branch takes the fused feature map extracted by the FPN as input and outputs a table structure feature map. This map encodes the structural information of the table's line segments, such as the arrangement and intersection of horizontal and vertical lines, enabling the network to perceive the table grid layout. Within the overall network, this branch acts as a parallel branch to the backbone feature extraction network: it receives the fused feature map extracted by the backbone network and extracts salient feature representations of the grid structure through convolution and attention mechanisms. By expanding the receptive field and capturing long-range dependencies, this branch enhances the representation of global patterns such as parallel horizontal and vertical lines in the feature map. The resulting structure feature map is then applied to the fused feature map F through channel-wise feature weighting (element-wise multiplication), forming an enhanced fused feature map that serves as input to the attraction field prediction module, improving the recognition ability of line segments within the table structure.
[0049] S24. The enhanced fused feature map is input into the attraction field prediction module to obtain candidate line segments.
[0050] Step S24 includes the following steps:
[0051] S241, predict the relative offset vector between the two line segment endpoints corresponding to each pixel, and generate the endpoint offset vector field;
[0052] S242, normalize and directionally encode the endpoint offset vector field to obtain the attraction field vector field;
[0053] S243, perform a nonlinear transformation mapping on the attraction field vector field to obtain candidate line segments.
[0054] The Attraction Field Decoder takes the enhanced fused feature map F as input and establishes an "attraction mapping" from pixels to line segment endpoints, achieving spatial modeling of image pixel-to-line segment endpoint pairs. Specifically, for each image pixel p, it predicts the relative offset vectors of its two corresponding line segment endpoints. The process generates an endpoint offset vector field. The attraction field vector field is composed of this offset vector field. The attraction field vector is obtained by normalizing and directional encoding the offset vector. The attraction vector of each pixel represents its attraction relationship to the endpoint of a potential line segment, reflecting the cooperative trend among structural pixels. After the attraction field vectors of all pixels are aggregated, they are mapped to a set of potential line segments through a nonlinear transformation. In the attraction field offset vector field, the predicted offset vector of each pixel points to a specific convergence point. The "convergence point" refers to the target position where the pixel finally lands after moving along the offset vector direction. This position is usually located on a table line segment (it may be a projection point on the line segment, or the endpoint / intersection of the line segment when the pixel is near the end of the line segment). The convergence point is obtained by adding the pixel's original coordinates to its offset vector. This calculation directly yields the image coordinates to which the pixel is attracted. If the pixel's position is iteratively moved along the offset vector direction, the pixel will gradually converge to the center or endpoint of the line segment, demonstrating the aggregation effect of the attraction field on the pixels. For example, a pixel near a table line will have its offset vector pull it onto the corresponding table line segment; similarly, multiple adjacent pixels, guided by their respective offset vectors, often converge at the endpoints or intersections of the same line segment (the intersections of table lines are the corners of table cells). These convergence points are the convergence points in the attraction field. Based on these convergence points, line segment endpoints are identified. Candidate line segments are generated through endpoint pairing and connectivity analysis, establishing a mapping relationship from pixel-level features to line segment-level structure, and finally outputting the candidate line segments.
[0055] S25, perform region-aligned pooling operation on the enhanced fused feature map along the line segment position to extract pixel features and obtain candidate line segment feature vectors.
[0056] ROI Align (Region Alignment Pooling) is performed on the position of the line segment on the enhanced fused feature map. The pixel features covering the line segment are extracted and summarized into a fixed-length vector representation to obtain the candidate line segment feature vector.
[0057] S26. Input the feature vector of the candidate line segment into the confidence prediction head to obtain the existence probability of each candidate line segment.
[0058] The confidence prediction head typically consists of several fully connected layers, which output the probability of existence of each candidate line segment based on the input line segment feature vector. This provides a basis for subsequent screening. The confidence prediction head output is an initial set of line segments: each candidate line segment is composed of... Representing the endpoint coordinates, this forms a preliminary result set of candidate structural line segments. Figure 4 The generated candidate line segments are provided for the embodiments of this application.
[0059] S3 performs clustering operations on the candidate line segments to obtain a preliminary table framework set of line segments.
[0060] In one embodiment, step S3 includes the following steps:
[0061] S31, calculate the Euclidean length and angle of each line segment, and use the density-based DBSCAN clustering algorithm to coarsely cluster the candidate line segments to obtain several line segment clusters.
[0062] Coarse clustering of line segments based on spatial location is performed, incorporating the spatial relationships between line segments for cluster analysis. The Euclidean length of each line segment is calculated. Calculate the angle of a line segment using the arctangent function. Define a distance measurement function between line segments, taking into account the following factors:
[0063] (1) Endpoint distance: When two line segments are very close to each other, the distance between their endpoints or extensions should be less than a preset threshold. When the interval between the end point of one line segment and the start point of another line segment is within a few pixels, they can be considered to be spatially connected.
[0064] (2) Projection overlap: Project the line segments onto the horizontal and vertical axes respectively. If the overlapping area of the two line segments on the projection axis reaches a certain proportion, it indicates that they are collinear or aligned in that direction. If the projection lengths of the two line segments overlap significantly in the horizontal direction, it can be determined that they may belong to the same horizontal straight line.
[0065] (3) Parallel spacing: Consider whether the line segments are similar in direction (the difference in direction angle is within the threshold) and are arranged parallel to each other. If two line segments are almost parallel and the vertical distance between them is very small (e.g., only a few pixels apart, much smaller than the size of a table cell), they may be duplicate detections of the same table edge or adjacent segments.
[0066] Based on the above criteria, the density-based DBSCAN clustering algorithm is used to cluster all line segments: any line segment that is in its... If another line segment satisfying the distance criterion is found in the neighborhood, the two are grouped into the same cluster. The clustering process recursively merges line segments with adjacency into the same cluster. Through this aggregation based on spatial location relationships, the algorithm automatically groups line segments that are spatially connected and have similar directions together.
[0067] S32, sort the elements within the line segment cluster according to the angle of the line segment to obtain a preliminary table framework of line segment set.
[0068] After clustering, several line segment clusters are obtained, each representing a set of line segments that may form the edges of the same grid. Elements within a cluster are sorted by their angle: if the cluster corresponds to horizontally arranged line segments, their alignment is checked from top to bottom according to their vertical coordinates; if the cluster corresponds to vertically arranged line segments, they are sorted from left to right according to their horizontal coordinates. Compared to the input set of line segments, the number of output line segments is significantly reduced, and these line segments have been preliminarily grouped according to spatial direction (without relying on pre-defined angle thresholds for classification). Figure 5 The clustering results provided for the embodiments of this application.
[0069] S4. After a second screening of the line segments excluded during the clustering process, the line segments are re-added to the initial table frame line segment set. The initial table frame line segment set of the line segments added after the second screening is then subjected to operations such as merging broken line segments, removing redundant and isolated line segments, to obtain the updated table line segment set.
[0070] The issue of subtle and isolated line segments overlooked during the aforementioned coarse clustering process can be addressed through more refined feature analysis and structural correlation. These line segments, which should belong to the table but were missed during the initial screening, are reintegrated into the table structure. In hydraulic engineering drawings, due to image quality issues or broken line segments, some short or isolated line segments are often incorrectly removed during coarse clustering, resulting in an incomplete table structure.
[0071] In one embodiment, step S4 includes the following steps:
[0072] S41, calculate the distance from the line segments excluded during the coarse clustering process to the table boundary, analyze the spacing between adjacent row lines or column lines of the preliminary table frame line set, and when the spacing is greater than the average spacing, determine that there are key line segments that have been missed, and re-add the missed line segments.
[0073] The line segments excluded in the coarse clustering undergo secondary screening and feature extraction. For line segments whose length does not meet the coarse clustering threshold (e.g., horizontal lines shorter than 30% of the image width or vertical lines shorter than 30% of the image height) or which were excluded due to isolation, their likelihood of becoming table structure lines is reassessed. Specifically, the system uses the identified table boundaries as a reference to calculate the distance of each short line segment to the table boundary, determining whether it is located within the table area or adjacent to the table boundary. Simultaneously, it also checks whether the extension of the short line segment intersects with other structure lines of the table.
[0074] The system performs correlation analysis and reconstruction between line segments based on the regularity of the table structure. As a highly regular structure, tables typically exhibit a uniform distribution of row and column lines. Based on this characteristic, the system compares and analyzes the spacing distribution between adjacent row or column lines in identified tables. When a spacing significantly exceeds the average (more than 1.5 times) and an excluded short line segment is found within that area, the system determines that the short line segment may be a missed table separator line.
[0075] For short or broken line segments identified as part of the table structure through the above analysis, they are integrated with the main table frame. The integration process must consider the connection relationships between line segments and the overall consistency of the table. For multiple line segments identified as the same table line but with breaks, the system will perform a merging operation, treating them as a single line segment; for short line segments near the table boundary, it is determined whether they are extensions of the boundary line, and if so, they are merged into the boundary line. Figure 6 The result of adding missing line segments provided in the embodiments of this application.
[0076] S42, sort the line segments in each cluster according to the coordinates of their left endpoints from smallest to largest, and merge the line segments whose distance between the endpoints of two adjacent line segments is less than a preset distance threshold.
[0077] Merge short line segments within the same cluster into continuous long lines to reduce line fragmentation. For each cluster... First, sort the line segments within a cluster based on the midpoint coordinates or approximate direction. In clusters with a clear horizontal tendency, sort by the left endpoint x-coordinate of the line segments from smallest to largest; in clusters with a clear vertical tendency, sort by the upper endpoint y-coordinate of the line segments from smallest to largest.
[0078] The sorted list of line segments is traversed. If the distance between the endpoints of two adjacent line segments is less than a preset threshold (10 pixels) or there is partial overlap, they are merged into a single, longer line segment. The starting point of the merged line segment is taken from the leftmost / topmost coordinate of the two segments, and the ending point is taken from the rightmost / bottommost coordinate. If two line segments overlap in a small interval, only one line segment is retained, and the duplicate parts are removed. After merging each cluster, only a few long line segments or even just one remain, significantly reducing the number of fragments and laying a solid foundation for subsequent structure determination. Figure 7 The merged table segments provided in the embodiments of this application.
[0079] S43, calculate the number of intersections or proximity points of each line segment with other clusters or line segments. If a line segment intersects with other line segments only at a certain point, then the line segment is determined to be an isolated line segment and removed.
[0080] Isolated line segments are removed to eliminate those that are difficult to form a grid and do not connect with other lines. Within or between clusters, the number of intersections or nearest neighbors of each line segment with other clusters / segments is calculated. If a line segment intersects with other line segments only at a single point, or has no possibility of forming a cell, it is considered noise or irrelevant labeling. If only one line segment is retained in the same cluster, and that line segment is very far from other identified clusters and cannot form a closed grid region with them, it can be marked as an isolated line segment and removed. After de-isolation, only valid line segments that form some connectivity with other candidate line segments at multiple intersections are retained, further cleaning up stray interference.
[0081] When a line segment is incomplete or broken, but its end is "close" to other line segments or table areas, the overall continuity is restored through a certain interpolation / extrapolation strategy. Trigger determination: For line segments If the endpoint of a line segment is less than a certain threshold (5-15 pixels) from the direction of another line segment's extension, it can be inferred that the two lines should theoretically intersect or be collinear, but are not actually connected due to noise or missing data. Extend the end of the line segment forward along its original direction until it "meets" the endpoint / midpoint of the other line segment; or directly insert a new short line segment between them (its length being the endpoint spacing). If the gap is too large (exceeding 50% of the average cell length), it is considered a shortage not solely caused by noise, and is not forcibly filled to avoid incorrectly connecting originally unrelated line segments.
[0082] S44: Calculate the directional angle, endpoint distance, and overlap ratio between two line segments, and determine whether there is a redundant line segment based on the directional angle, endpoint distance, and overlap ratio.
[0083] Geometric redundancy removal is performed to prevent adjacent or overlapping line segments from repeatedly covering the same real structural boundary. First, candidate segments are sorted by confidence level from highest to lowest, and then processed sequentially. For the current candidate segment... Iterate through the set of retained line segments. All To determine whether redundancy exists, the criteria include:
[0084] (1) Direction angle If the difference in direction angle between two line segments ;
[0085] (2) Endpoint distance: If the distance between the endpoints of two line segments is less than the tolerance (5 pixels);
[0086] (3) Overlap ratio: The overlap of the two line segments in the projection direction exceeds 70%;
[0087] If any two of the above three conditions are met, the segment is considered redundant, and only the one with the higher confidence level is retained. Non-redundant segments are then added to the output set sequentially. In the middle, all candidate segments are traversed and processed. The non-maximum suppression step compresses the candidate space, avoiding overlapping segments that could lead to chaotic intersection points and redundant mesh node generation, thus improving robustness. The output is the set of line segments processed by non-maximum suppression. The line segments exhibit good independence and strong representativeness. Figure 8 This is a schematic diagram showing the comparison before and after nonmaximum suppression processing provided in the embodiments of this application.
[0088] S5 determines the outer boundaries of the table, analyzes the internal row and column structure and row height and column width distribution, identifies merged cell areas, and generates a complete table structure model.
[0089] In one embodiment, step S5 includes the following steps:
[0090] S51, extract the outermost line segments from the set of horizontal lines and the set of vertical lines as the four boundary lines of the table.
[0091] The outer boundary frame of the table is determined by extracting the outermost line segments from the set of horizontal and vertical lines as the four boundary lines of the table: the top boundary (the horizontal line with the smallest y-coordinate), the bottom boundary (the horizontal line with the largest y-coordinate), the left boundary (the vertical line with the smallest x-coordinate), and the right boundary (the vertical line with the largest x-coordinate). These four boundary lines form the rectangular outer frame of the table, and their aspect ratio and area are checked to ensure that they conform to the basic characteristics of a table.
[0092] S52: Arrange all horizontal lines in ascending order of vertical coordinate to form a row boundary sequence, and arrange vertical lines in ascending order of horizontal coordinate to form a column boundary sequence. Identify the distance between horizontal lines to obtain the row height, and identify the distance between vertical lines to obtain the column width.
[0093] Analyze the row and column structure within the table. Arrange all horizontal lines in ascending order of y-coordinate to form a row boundary sequence, and arrange vertical lines in ascending order of x-coordinate to form a column boundary sequence. Calculate the vertical distance between adjacent rows and the horizontal distance between adjacent columns, analyzing the distribution patterns of row height and column width. By statistically analyzing these distance values, identify the standard row height and column width of the table, providing a basis for determining the regularity of the table and identifying merged cells.
[0094] S53: When the spacing between two rows is significantly greater than the row height, merge the cells to generate a complete table structure model.
[0095] Further detection of merged cells primarily involves analyzing outliers in row and column spacing. When the spacing between two rows is significantly greater than the standard row height (e.g., exceeding 1.8 times), merged cells spanning multiple rows may exist; similarly, outliers in column spacing are identified by analyzing them. The starting position and span information of each merged cell are recorded to prepare for subsequent processing.
[0096] Based on the row and column analysis and merged cell detection results, a complete table structure model is generated, including the number of rows and columns, coordinate information, standard row height and column width data, and information on all merged cells. Figure 9 The table structure line extraction results provided in the embodiments of this application are as follows. Figure 10 The result of processing the table content lines provided in the embodiments of this application.
[0097] S6 calculates all intersections of horizontal and vertical lines, establishes a cell coordinate system, transforms the complete table structure model into two-dimensional matrix data, and generates a row and column network model.
[0098] In one embodiment, step S6 includes the following steps:
[0099] S61, Statistically analyze the directional distribution of all line segments to determine row lines and column lines.
[0100] Analyze the directional distribution of all line segments. If a portion of the line segments are approximately horizontal (with angle differences less than a certain threshold), they can be considered candidate "row" lines; if another portion are approximately vertical, they can be considered candidate "column" lines. Sort the "row" lines from top to bottom according to their vertical coordinates, and sort the "column" lines from left to right according to their horizontal coordinates. This determines that the table has N horizontal lines and M vertical lines, theoretically corresponding to N-1 rows and M-1 columns of grid cells (if the top, bottom, left, and right borders are included, then it is an N-row × M-column grid boundary line).
[0101] S62, calculate the intersection of each horizontal line and each vertical line one by one, and treat the rectangular area enclosed by two adjacent horizontal lines and two adjacent vertical lines as a single cell in the order from left to right and from top to bottom.
[0102] S63 describes the coordinate range of cells based on a two-dimensional matrix and generates a row and column grid model.
[0103] Calculate the intersection points of each horizontal line and each vertical line one by one. If a tiny gap at the end of a line segment prevents a perfect fit, automatic matching within a 5-10 pixel range is allowed to construct the "intersection point." Following a left-to-right, top-to-bottom order, the rectangular area enclosed by two adjacent horizontal lines and two adjacent vertical lines is considered a single cell. The coordinates of the top-left and bottom-right corners of each cell are recorded. , If an internal dividing line is missing in a certain area, it indicates that the cell may be merged and can be marked accordingly. The horizontal lines from top to bottom can be numbered Row_0, Row_1, …, Row_{N-1}; the vertical lines from left to right can be numbered Col_0, Col_1, …, Col_{M-1}. If a two-dimensional matrix is used, the coordinate range of the cell in the i-th row and j-th column is stored in the array cell[i][j]. For merged cells, an additional field can be set to record their span, such as “row_span”:2, “col_span”:3. This invention ultimately reconstructs the table lines in the engineering drawings into a topologically complete row and column grid model and generates normalized data containing row and column information and cell coordinate boundaries. Figure 11 The row and column grid model provided for the embodiments of this application.
[0104] Based on the method described in the above embodiments, this embodiment will further describe it from the perspective of an intelligent extraction system for table structures of water conservancy project images. This intelligent extraction system for table structures of water conservancy project images can be implemented as an independent entity or integrated into an electronic device. The electronic device can be a terminal, server, or other devices. The terminal can include a tablet computer, a laptop computer, a personal computer (PC), a microprocessor box, or other devices.
[0105] Please see Figure 12 , Figure 12 This application provides a detailed description of an intelligent extraction system for table structures in water conservancy engineering images, applicable to electronic devices. This intelligent extraction system for table structures in water conservancy engineering images may include:
[0106] An acquisition and preprocessing module is used to acquire images of water conservancy projects and preprocess the images of water conservancy projects.
[0107] The candidate line segment prediction module is used to input the preprocessed water conservancy project image into the improved HAWP model to obtain the predicted candidate line segments.
[0108] The line segment clustering module is used to perform clustering operations on the candidate line segments to obtain a preliminary table framework set of line segments.
[0109] The line segment processing module is used to perform secondary screening on the line segments excluded during the clustering process and then re-add them to the initial table frame line segment set. The module then performs operations such as merging broken line segments, removing redundant and isolated line segments from the initial table frame line segment set of the line segments that have been added after secondary screening, to obtain the updated table line segment set.
[0110] The boundary determination module is used to determine the outer boundary of the table, analyze the internal row and column structure and row height and column width distribution of the table, identify merged cell areas, and generate a complete table structure model.
[0111] The row and column network model generation module is used to calculate all intersections of horizontal and vertical lines, establish a cell coordinate system, and transform the complete table structure model into two-dimensional matrix data to generate a row and column network model.
[0112] In specific implementation, the above modules and / or units can be implemented as independent entities, or they can be arbitrarily combined and implemented as the same or several entities. For the specific implementation of the above modules and / or units, please refer to the previous method embodiments. For the specific beneficial effects that can be achieved, please also refer to the beneficial effects in the previous method embodiments, which will not be repeated here.
[0113] In addition, this application also provides an electronic device, which may be a computer, tablet computer, or other similar device. This electronic device can implement the steps of any embodiment of the intelligent extraction method for table structures of water conservancy engineering images provided in this application. Therefore, it can achieve the beneficial effects of any intelligent extraction method for table structures of water conservancy engineering images provided in this invention, as detailed in the preceding embodiments, and will not be repeated here.
[0114] Figure 13 A specific structural block diagram of an electronic device provided in an embodiment of the present invention is shown. This electronic device can be used to implement the intelligent extraction method for table structures of water conservancy engineering images provided in the above embodiments. The electronic device 500 can be a terminal, server, or other device. The terminal can include a tablet computer, laptop computer, personal computer (PC), microprocessor box, or other devices.
[0115] RF circuit 510 is used to receive and transmit electromagnetic waves, converting electromagnetic waves into electrical signals and vice versa, thereby enabling communication with communication networks or other devices. RF circuit 510 may include various existing circuit elements used to perform these functions, such as antennas, radio frequency transceivers, digital signal processors, encryption / decryption chips, subscriber identity modules (SIM cards), memory, etc. RF circuit 510 can communicate with various networks such as the Internet, corporate intranets, and wireless networks, or communicate with other devices via wireless networks. The aforementioned wireless networks may include cellular telephone networks, wireless local area networks (WLANs), or metropolitan area networks (MANs). The aforementioned wireless networks may use various communication standards, protocols, and technologies, including but not limited to Global System for Mobile Communication (GSM), Enhanced Data GSM Environment (EDGE), Wideband Code Division Multiple Access (WCDMA), Code Division Multiple Access (CDMA), Time Division Multiple Access (TDMA), Wireless Fidelity (Wi-Fi) (such as IEEE 802.11a, IEEE 802.11b, IEEE 802.11g, and / or IEEE 802.11n), Voice over Internet Protocol (VoIP), Worldwide Interoperability for Microwave Access (Wi-Max), other protocols for email, instant messaging, and short messages, and any other suitable communication protocols, including those that have not yet been developed.
[0116] The memory 520 can be used to store software programs and modules, such as the program instructions / modules corresponding to those in the above embodiments. The processor 580 executes various functional applications and data processing by running the software programs and modules stored in the memory 520, such as taking pictures with the front-facing camera, processing the captured images, and switching the display colors of the content displayed on the screen. The memory 520 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 520 may further include memory remotely located relative to the processor 580, and these remote memories can be connected to the electronic device 500 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0117] The input unit 530 can be used to receive input numeric or character information, and to generate a keyboard and mouse related to user settings and function control.
[0118] Display unit 540 can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces, which can be composed of graphics, text, icons, video, and any combination thereof. Display unit 540 may include display panel 541, which may optionally be configured in the form of LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), or other similar forms.
[0119] Audio circuitry 560, speaker 561, and microphone 562 provide an audio interface between the user and electronic device 500. Audio circuitry 560 converts received audio data into electrical signals and transmits them to speaker 561, where speaker 561 converts them into sound signals for output. Conversely, microphone 562 converts collected sound signals into electrical signals, which are then received by audio circuitry 560, converted back into audio data, and processed by processor 580. The audio data is then transmitted via RF circuitry 510 to, for example, another terminal, or output to memory 520 for further processing. Audio circuitry 560 may also include an earphone jack to facilitate communication between external headphones and electronic device 500.
[0120] Electronic device 500, through transmission module 570 (e.g., Wi-Fi module), can help users receive requests, send information, etc., providing users with wireless broadband internet access. Although transmission module 570 is shown in the figure, it is understood that it is not an essential component of electronic device 500 and can be omitted as needed without changing the essence of the invention.
[0121] The processor 580 is the control center of the electronic device 500. It connects to various parts of the phone via various interfaces and lines, and performs various functions and processes data of the electronic device 500 by running or executing software programs and / or modules stored in the memory 520, and by calling data stored in the memory 520, thereby providing overall monitoring of the electronic device. Optionally, the processor 580 may include one or more processing cores; in some embodiments, the processor 580 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may also not be integrated into the processor 580.
[0122] Electronic device 500 also includes a power supply 590 (such as a battery) that supplies power to various components. In some embodiments, the power supply may be logically connected to processor 580 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 590 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0123] Although not shown, the electronic device 500 also includes cameras (such as front-facing cameras and rear-facing cameras), Bluetooth modules, etc., which will not be described in detail here. Specifically, in this embodiment, the display unit of the electronic device is a touch screen display, and the mobile terminal also includes a memory and one or more programs, wherein one or more programs are stored in the memory and configured to be executed by one or more processors. One or more programs contain instructions for performing the following operations:
[0124] Acquire images of water conservancy projects and preprocess the images;
[0125] The preprocessed water conservancy project image is input into the improved HAWP model to obtain the predicted candidate line segments;
[0126] Clustering is performed on the candidate line segments to obtain a preliminary table frame set of line segments;
[0127] After a second screening of the line segments excluded during the clustering process, they are re-added to the initial table frame line segment set. The initial table frame line segment set of the line segments added after the second screening is then merged with broken line segments and redundant and isolated line segments are removed to obtain the updated table line segment set.
[0128] Determine the outer boundaries of the table, analyze the internal row and column structure and row height and column width distribution, identify merged cell areas, and generate a complete table structure model;
[0129] Calculate all intersections of horizontal and vertical lines, establish a cell coordinate system, transform the complete table structure model into two-dimensional matrix data, and generate a row and column network model.
[0130] In practice, the above modules can be implemented as independent entities or combined in any way to be implemented as the same or several entities. For the specific implementation of the above modules, please refer to the previous method implementation examples, which will not be repeated here.
[0131] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor. Therefore, embodiments of the present invention provide a storage medium storing multiple instructions that can be loaded by a processor to execute the steps of any embodiment of the intelligent extraction method for table structures of water conservancy engineering images provided by the present invention.
[0132] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0133] Since the instructions stored in the storage medium can execute the steps in any embodiment of the intelligent extraction method for table structure of water conservancy project images provided in the embodiments of the present invention, the beneficial effects that any intelligent extraction method for table structure of water conservancy project images provided in the embodiments of the present invention can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.
[0134] The above provides a detailed description of the intelligent extraction method, system, storage medium, and electronic device for table structures of water conservancy engineering images provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for intelligent extraction of table structure from water conservancy images, characterized in that, The method comprises: acquiring a water conservancy image and preprocessing the water conservancy image; inputting the preprocessed water conservancy image into an improved HAWP model to obtain predicted candidate line segments; the improved HAWP model comprises a backbone feature extraction network, a table structure feature perception branch, an attraction field prediction module and a confidence prediction head; the processing process of the improved HAWP model comprises: inputting the preprocessed water conservancy image into the backbone feature extraction network to perform multi-scale feature extraction and fusion to obtain a fused feature map; inputting the fused feature map into the table structure feature perception branch to obtain a table structure feature map; performing a feature weighting operation on the fused feature map and the table structure feature map channel by channel to obtain an enhanced fused feature map; inputting the enhanced fused feature map into the attraction field prediction module to obtain candidate line segments; performing a region alignment pooling operation on the enhanced fused feature map along the line segment position to extract pixel features to obtain a candidate line segment feature vector; inputting the candidate line segment feature vector into the confidence prediction head to obtain the existence probability of each candidate line segment; performing a clustering operation on the candidate line segments to obtain a preliminary table framework line segment set; after secondary screening, the line segments excluded in the clustering process are readded to the preliminary table framework line segment set, and the preliminary table framework line segment set to which the line segments after secondary screening are added is subjected to a merging broken line segment, redundant and isolated line segment removal operation to obtain an updated table line segment set; determining a table external boundary, analyzing a table internal row and column structure and row height and column width distribution, and identifying a merged cell region to generate a complete table structure model; calculating all horizontal line and vertical line intersection points, establishing a cell coordinate system, converting the complete table structure model into two-dimensional matrix data and generating a row and column network model.
2. The method for intelligent extraction of table structure from water conservancy images according to claim 1, characterized in that, inputting the enhanced fused feature map into the attraction field prediction module to obtain candidate line segments, comprising: predicting the relative offset vectors of the two line segment endpoints corresponding to each pixel point to generate an endpoint offset vector field; normalizing and directionally encoding the endpoint offset vector field to obtain an attraction field vector field; performing nonlinear transformation mapping on the attraction field vector field to obtain candidate line segments. 3.The method of claim 1, wherein, performing a clustering operation on the candidate line segments to obtain a preliminary table framework line segment set, comprising: calculating the Euclidean length and angle of each line segment, and performing coarse clustering on the candidate line segments based on a density-based DBSCAN clustering algorithm to obtain a plurality of line segment clusters; sorting the elements in the line segment clusters according to the angles of the line segments to obtain a preliminary table framework line segment set.
4. The method for intelligent extraction of table structure from water conservancy images according to claim 3, characterized in that, after secondary screening, the line segments excluded in the clustering process are readded to the preliminary table framework line segment set, and the preliminary table framework line segment set to which the line segments after secondary screening are added is subjected to a merging broken line segment, redundant and isolated line segment removal operation to obtain an updated table line segment set, comprising: The distance of the excluded line segment in the coarse clustering process to the table boundary is calculated, the interval between adjacent row lines or column lines of the preliminary table frame line set is analyzed, when the interval is greater than the average interval, it is determined that there is a key line segment missing, and the missing line segment is re-added; The line segments in each cluster are sorted in ascending order according to the left endpoint coordinates, and the line segments with a distance between the endpoints of adjacent two line segments less than a preset distance threshold are merged; The number of intersection points or the number of close points of each line segment with other clusters or line segments is calculated, and if a line segment only intersects with other line segments at a point, the line segment is determined as an isolated line segment and removed; The direction angle, endpoint distance and overlap ratio between two line segments are calculated, and whether there is a redundant line segment is determined based on the direction angle, the endpoint distance and the overlap ratio.
5. The method for intelligent extraction of table structure from water conservancy images according to claim 1, characterized in that, The table external boundary is determined, the table internal row and column structure and the row height and column width distribution are analyzed, and the merged cell area is identified, and a complete table structure model is generated, including: The outermost line segments are extracted from the horizontal line set and the vertical line set as the four boundary lines of the table; All horizontal lines are arranged in ascending order of the longitudinal coordinate to form a row boundary sequence, and the vertical lines are arranged in ascending order of the horizontal coordinate to form a column boundary sequence, the distance value between the horizontal lines is identified to obtain the row height, and the distance value between the vertical lines is identified to obtain the column width; When the interval between two rows is obviously greater than the row height, the merged cell is generated, and a complete table structure model is generated.
6. The method for intelligent extraction of table structure from water conservancy images according to claim 5, characterized in that, All horizontal line and vertical line intersection points are calculated, a cell coordinate system is established, the complete table structure model is converted into a two-dimensional matrix data and a row and column network model is generated, including: The direction distribution of all line segments is counted to determine the row lines and column lines; The intersection points of each horizontal line and each vertical line are calculated one by one, and the rectangular area surrounded by adjacent two horizontal lines and adjacent two vertical lines is regarded as a cell according to the order from left to right and from top to bottom; The coordinate range of the cell is described based on the two-dimensional matrix, and a row and column grid model is generated.
7. A system for intelligent extraction of table structure from waterworks images, the system for intelligent extraction of table structure from waterworks images being used to implement the method for intelligent extraction of table structure from waterworks images according to claim 1, characterized by, It includes: An acquisition and preprocessing module is configured to acquire a water conservancy engineering image and pre-process the water conservancy engineering image; A candidate line segment prediction module is configured to input the pre-processed water conservancy engineering image into an improved HAWP model to obtain predicted candidate line segments; A line segment clustering module is configured to perform clustering operations on the candidate line segments to obtain a preliminary table frame line segment set; A line segment processing module is configured to re-add the line segments excluded in the clustering process to the preliminary table frame line segment set after secondary screening, perform merged broken line segment, redundant and isolated line segment removal operations on the preliminary table frame line segment set after the secondary screening to obtain an updated table line segment set; A boundary determination module is configured to determine a table external boundary, analyze a table internal row and column structure and a row height and column width distribution, identify a merged cell area, and generate a complete table structure model; A row and column network model generation module is configured to calculate all horizontal line and vertical line intersection points, establish a cell coordinate system, convert the complete table structure model into a two-dimensional matrix data, and generate a row and column network model.
8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a plurality of instructions adapted to be loaded by a processor to execute the intelligent extraction method of the table structure of the water conservancy engineering image according to any one of claims 1 to 6.
9. An electronic device, comprising: The processor and the memory are included, the processor is electrically connected with the memory, the memory is used for storing instructions and data, and the processor is used for executing the steps in the intelligent extraction method of the table structure of the water conservancy engineering image according to any one of claims 1 to 6.
Citation Information
Patent Citations
Image table structure identification method and system, terminal and storage medium
CN112036232A
Text image table structure acquisition method and device and electronic equipment
CN116758568A