A Data Labeling Method for AI-P&ID Image Recognition
By reshaping the P&ID map and applying adaptive linewidth correction, combined with a deep convolutional neural network model, the problem of inaccurate pipeline centerline extraction in existing technologies is solved, achieving stable centerline extraction and topology restoration.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI GELUE SOFTWARE TECH CO LTD
- Filing Date
- 2026-04-23
- Publication Date
- 2026-06-26
AI Technical Summary
Existing technologies cannot accurately extract pipeline centerlines in Piping and Instrumentation Diagrams (P&IDs), leading to broken skeleton nodes, positional drift, or redundant pseudo-connection points, thus disrupting the pipeline topology.
A method is adopted to address inconsistent line width conditions, including regional reshaping, adaptive line width correction, centerline prediction, and skeleton node differential analysis. By reshaping the region, measuring the local line width, compensating for width compression or expansion, extracting the centerline, and judging the connection status of skeleton nodes, gap backfilling and pseudo-connection point removal are achieved.
It improves the stability of centerline extraction and topology restoration, avoids skeleton breakage and pseudo-connection points, and ensures the integrity of pipeline topology.
Smart Images

Figure CN122090213B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of graphic annotation technology, and more specifically, to a data annotation method for AI-P&ID graphic recognition. Background Technology
[0002] Piping and Instrumentation Diagrams (P&IDs) are important engineering drawings used in process industries such as chemical, petrochemical, pharmaceutical, power, and metallurgy to describe process flows and pipeline instrument layouts. With the advancement of industrial automation and digitalization, the demand for intelligent parsing, structured representation, and data annotation of P&ID diagrams is increasing. Traditional P&ID diagram recognition methods are mostly based on morphological thinning algorithms, skeleton extraction, and image segmentation techniques to extract center lines and analyze nodes in the image.
[0003] The existing technology has the following shortcomings:
[0004] Currently, existing technologies mainly rely on traditional morphological skeleton algorithms and global image processing methods. Due to the presence of multi-layered intersecting pipelines, complex drawing forms, and inconsistent line widths in P&ID graphs, it is impossible to accurately extract the pipeline centerline and restore the pipeline topology. This results in broken skeleton nodes, positional drift, or redundant pseudo-connection points, thus destroying the integrity of the pipeline topology. Therefore, an AI-P&ID graph recognition data annotation method is proposed. Summary of the Invention
[0005] To overcome the aforementioned deficiencies of the prior art, embodiments of the present invention provide a data annotation method for AI-P&ID graphic recognition. By employing methods such as region reshaping for inconsistent line widths, adaptive line width correction, centerline prediction, and skeleton node differential analysis, the P&ID image is reshaped into regions, local line width is measured, width compression or expansion compensation is performed, centerline extraction is conducted, and skeleton node connection status is determined. This achieves gap backfilling, pseudo-connection point removal, and semantic annotation association to solve the problems mentioned in the background art.
[0006] To achieve the above objectives, the present invention provides the following technical solution: a data annotation method for AI-P&ID image recognition, comprising the following steps:
[0007] Step S1: Reshape the P&ID map to be tested to obtain multiple reshaped regions. Detect the minimum bounding rectangle of the lines in each reshaped region. Measure the width of the minimum bounding rectangle and the edge gradient spacing to generate the local line width.
[0008] Step S2: Based on the local line width, perform width compression or expansion compensation processing on the lines of the reshaped area, predict the center line of the processed P&ID map to be tested to generate a preliminary center line, and obtain the skeleton node information of the preliminary center line.
[0009] Step S3: Detect the local principal direction and adjacent interval length of each skeleton node in the remodeling area, calculate the cross direction difference of the skeleton nodes based on the local principal direction, and generate the skeleton node density of each remodeling area based on the adjacent interval length.
[0010] Step S4: Determine the connection status of skeleton nodes by combining the difference in cross directions and the density of skeleton nodes. If the connection status is broken, fill the gaps in the skeleton nodes. Count the number of skeleton nodes in each remodeling area and select to remove pseudo-connection points or semantically label and associate them in each remodeling area.
[0011] In a preferred embodiment, in step S1, the P&ID map to be tested is reshaped to obtain multiple reshaped regions:
[0012] The Otsu thresholding algorithm is used to binarize the P&ID image under test.
[0013] All connected regions are extracted using eight-neighbor connectivity analysis;
[0014] Merge adjacent pipeline pixels through morphological dilation operations;
[0015] The expanded connected region is directly used as the initial reshaped region;
[0016] For each region, convex hull calculation is performed and the region is expanded outward by 5 pixels to form the final reshaped region;
[0017] The minimum bounding box of the line pixel set of each reshaped region is calculated by traversing all angles using the rotating caliper algorithm, and is used as the minimum bounding rectangle of the line of each reshaped region.
[0018] Extract the pixel coordinates of the four vertices of the minimum bounding rectangle of each reshaped region's lines, and calculate the distance between the two endpoints of the short side using the distance formula to obtain the width of the minimum bounding rectangle of each reshaped region.
[0019] In a preferred embodiment, in step S1, a scan line is set along the vertical direction of the short side of the minimum bounding rectangle, and the gray-level gradient value of each pixel on the scan line is calculated by the Sobel gradient operator.
[0020] The positions of the two boundary points corresponding to the maximum gradient are determined by the non-maximum suppression algorithm.
[0021] The distance between two boundary points is calculated using the distance formula and used as the edge gradient spacing of each reshaped region.
[0022] The width of the minimum bounding rectangle and the edge gradient spacing of each reshaped region are standardized to obtain the width factor and spacing factor.
[0023] The local line width of each reshaped area is calculated by combining the width factor and the spacing factor using a weighted summation method.
[0024] In a preferred embodiment, in step S2, if the local line width is greater than or equal to a preset standard line width threshold, it is determined that the line width of the reshaped area will be compressed.
[0025] If the local line width is less than the preset standard line width threshold, it is determined that expansion compensation processing will be performed on the lines of the reshaped area;
[0026] Width compression refers to an image processing method that performs morphological shrinkage on the lines of the reshaped region to reduce the line pixel width and approximate the standard single pixel width.
[0027] Dilation compensation processing is an image processing method that performs morphological expansion operations on the lines of the reshaped area to increase the line pixel width and fill the gaps between breaks.
[0028] In a preferred embodiment, in step S2, the processed P&ID map to be tested is used as the input feature for centerline prediction and input into a pre-trained deep convolutional neural network model to obtain a preliminary centerline.
[0029] By performing topological analysis on the preliminary centerline, all skeleton nodes in the preliminary centerline are identified, and their attribute information is classified and recorded to obtain skeleton node information.
[0030] By performing eight-neighbor connectivity analysis on the preliminary centerline of each reshaped region, the number of neighbor connectivity points of each pixel on the preliminary centerline of each reshaped region is obtained.
[0031] Whether to remove a skeleton node is determined based on the number of connected neighbors.
[0032] In a preferred embodiment, in step S3, a skeleton node of the preliminary centerline of a reshaping region is selected as the target node;
[0033] A local line segment set is formed by taking 5 consecutive skeleton pixels on each side of the center line centered on the target node.
[0034] The pixel coordinates of the local line segment set are fitted with a straight line using the least squares method. The arctangent of the slope of the fitted line is calculated to obtain the included angle in radians. The included angle in radians is multiplied by the conversion coefficient to obtain the direction angle value, which is used as the local main direction of the skeleton node.
[0035] For the connection point, the above fitting is performed on each branch direction, and the direction of the longest branch is taken as the local principal direction of the skeleton node.
[0036] Repeat the above steps to obtain the local principal direction of each skeleton node in each remodeled region.
[0037] In a preferred embodiment, in step S3, a skeleton node of the initial centerline of a remodeling area is selected, and the distance between the skeleton node and the two adjacent skeleton nodes in the direction of the initial centerline of the remodeling area is calculated by the distance calculation formula. The average distance between the skeleton node and the two adjacent skeleton nodes is taken to obtain the adjacent interval length of the skeleton node.
[0038] Repeat the above steps to obtain the adjacent interval length of each skeleton node in each remodeling area;
[0039] The average direction of a reshaped region is obtained by averaging the local principal directions of each skeleton node within the reshaped region.
[0040] The absolute value of the difference between the local principal direction and the average direction of each skeleton node in the remodeling area is taken as the degree of difference in the intersection direction of each skeleton node in the remodeling area.
[0041] Repeat the above steps to obtain the cross-direction difference of each skeleton node in each remodeled area;
[0042] The average interval length of a remodeled region is obtained by averaging the adjacent interval lengths of each skeleton node within the remodeled region.
[0043] The reciprocal of the average interval length of the reshaped region is taken as the skeleton node density of the reshaped region;
[0044] Repeat the above steps to obtain the skeleton node density of each reshaped region.
[0045] In a preferred embodiment, in step S4, the cross-direction difference and skeleton node density of each skeleton node in each remodeling region are standardized to obtain the difference factor and density factor.
[0046] The connection state value of each skeleton node is calculated by combining the difference factor and the density factor. The calculation formula is as follows: ,in, As a difference factor, Density factor These are the connection status values for each skeleton node.
[0047] In a preferred embodiment, in step S4, if the connection status value of the skeleton node is greater than or equal to a preset connection status threshold, and the skeleton node is an endpoint, then the connection status of the skeleton node is determined to be broken, and the gap of the skeleton node is backfilled.
[0048] If the connection status value of a skeleton node is greater than or equal to a preset connection status threshold, and the skeleton node is a connection point or a path point, then the connection status of the skeleton node is determined to be a pseudo-connection status.
[0049] If the connection status value of a skeleton node is less than the preset connection status threshold, the connection status of the skeleton node is determined to be stable.
[0050] Count the number of skeleton nodes in each remodeled area.
[0051] In a preferred embodiment, in step S4, the number of skeleton nodes in each remodeling region is compared with a preset skeleton node number threshold for determination:
[0052] If the number of skeleton nodes in the remodeled area is greater than or equal to the preset skeleton node number threshold, then pseudo-connection point removal is performed on the remodeled area.
[0053] If the number of skeleton nodes in the reshaped region is less than the preset skeleton node number threshold, then semantic annotation association is performed on the reshaped region.
[0054] The technical effects and advantages of this invention are as follows:
[0055] This invention obtains multiple reconstructed regions by reshaping the P&ID image under test. It detects the minimum bounding rectangle of the lines in each region and measures its width and edge gradient spacing to generate local linewidths. Based on these local linewidths, it performs width compression or expansion compensation on the lines in the reconstructed regions. It then predicts the centerline of the processed image to obtain a preliminary centerline and extracts skeleton node information. It detects the local principal direction and adjacent interval length of skeleton nodes in each reconstructed region, calculates the cross-direction difference based on the local principal direction, and generates skeleton node density based on the adjacent interval length. It combines the cross-direction difference and skeleton node density to determine the connection status of skeleton nodes. In cases of breakage, it performs gap filling and selects to remove pseudo-connection points or semantically label and associate them based on the number of skeleton nodes in the region. Through region reshaping for inconsistent linewidths, adaptive linewidth correction, and skeleton node differentiation analysis, it improves the stability of centerline extraction and topology restoration, avoiding skeleton breakage, pseudo-connection points, and node drift. Attached Figure Description
[0056] Figure 1 This is a flowchart illustrating the implementation of an AI-P&ID image recognition data annotation method according to the present invention.
[0057] Figure 2 This is a schematic diagram illustrating the steps of a data annotation method for AI-P&ID graphic recognition according to the present invention. Detailed Implementation
[0058] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0059] This invention obtains multiple reshaped regions by reshaping the P&ID image under test, detects the minimum bounding rectangle of the lines in each region and measures its width and edge gradient spacing to generate local linewidths, performs width compression or expansion compensation on the lines in the reshaped regions based on the local linewidths, predicts the centerline of the processed image to obtain a preliminary centerline and extracts skeleton node information, detects the local principal direction and adjacent interval length of the skeleton nodes in each reshaped region, calculates the cross direction difference based on the local principal direction, and generates skeleton node density based on the adjacent interval length. The connection status of skeleton nodes is judged by combining the cross direction difference and skeleton node density. In the broken state, gap backfilling is performed, and pseudo-connection point removal or semantic annotation association is selected according to the number of skeleton nodes in the region. This invention achieves regional reshaping, adaptive linewidth correction and skeleton node difference analysis for linewidth inconsistency conditions.
[0060] Example 1, as Figures 1 to 2 As shown, a data annotation method for AI-P&ID image recognition includes the following steps:
[0061] Step S1: Reshape the P&ID map to be tested to obtain multiple reshaped regions. Detect the minimum bounding rectangle of the lines in each reshaped region. Measure the width of the minimum bounding rectangle and the edge gradient spacing to generate the local line width.
[0062] Step S2: Based on the local line width, perform width compression or expansion compensation processing on the lines of the reshaped area, predict the center line of the processed P&ID map to be tested to generate a preliminary center line, and obtain the skeleton node information of the preliminary center line.
[0063] Step S3: Detect the local principal direction and adjacent interval length of each skeleton node in the remodeling area, calculate the cross direction difference of the skeleton nodes based on the local principal direction, and generate the skeleton node density of each remodeling area based on the adjacent interval length.
[0064] Step S4: Determine the connection status of skeleton nodes by combining the difference in cross directions and the density of skeleton nodes. If the connection status is broken, fill the gaps in the skeleton nodes. Count the number of skeleton nodes in each remodeling area and select to remove pseudo-connection points or semantically label and associate them in each remodeling area.
[0065] The specific implementation is as follows:
[0066] In step S1, during the automatic parsing task of P&ID map, the lines in the drawing often exhibit characteristics such as inconsistent width, blurred edges, and local breakpoints due to differences in drawing methods, changes in archiving formats, or the influence of scanning noise. The parsing process relies on stable line structure information. To ensure that subsequent centerline prediction and skeleton extraction can be based on the real line shape, the image area needs to be reshaped in the early stage of processing, and the line width and edge gradient spacing within the reshaped area need to be accurately measured.
[0067] The P&ID map to be tested is reshaped into regions, and multiple reshaped regions are obtained.
[0068] The specific regional restructuring process is as follows:
[0069] The Otsu thresholding algorithm is used to binarize the P&ID image under test.
[0070] All connected regions are extracted using eight-neighbor connectivity analysis;
[0071] Merge adjacent pipeline pixels through morphological dilation operations;
[0072] The expanded connected region is directly used as the initial reshaped region;
[0073] For each region, convex hull calculation is performed and the region is expanded outward by 5 pixels to form the final reshaped region;
[0074] It should be noted that P&ID stands for Piping and Instrumentation Diagram, an engineering diagram used in process industries such as chemical, petrochemical, pharmaceutical, power, and metallurgy; Otsu's thresholding algorithm is an adaptive thresholding method for image binarization, which automatically determines the optimal segmentation threshold by maximizing the inter-class variance between foreground and background pixels; Eight-neighbor connected component analysis is an image processing algorithm used to identify and label interconnected pixel regions in binary images; Morphological dilation is a structuring element-based image processing algorithm used to expand the boundaries of foreground regions in binary images; Adjacent pipeline pixels refer to a set of multiple foreground pixels in a P&ID image that are spatially adjacent and belong to the same pipeline pattern but are temporarily separated due to drawing discontinuities, scanning noise, or thresholding errors; Convex hull calculation is a computational geometry algorithm used to find the smallest convex polygon that can completely enclose a given set of points.
[0075] The minimum bounding box of the line pixel set of each reshaped region is calculated by traversing all angles using the rotating caliper algorithm, and is used as the minimum bounding rectangle of the line of each reshaped region.
[0076] Extract the pixel coordinates of the four vertices of the minimum bounding rectangle of each reshaped region's lines, calculate the distance between the two endpoints of the short side using the distance formula, and obtain the width of the minimum bounding rectangle of each reshaped region.
[0077] Set the scan line along the vertical direction of the short side of the minimum bounding rectangle, and calculate the gray-level gradient value of each pixel on the scan line using the Sobel gradient operator;
[0078] The positions of the two boundary points corresponding to the maximum gradient are determined by the non-maximum suppression algorithm.
[0079] The distance between two boundary points is calculated using the distance formula and used as the edge gradient spacing of each reshaped region.
[0080] The width of the minimum bounding rectangle and the edge gradient spacing of each reshaped region are standardized to obtain the width factor and spacing factor.
[0081] The local line width of each reshaped area is calculated by combining the width factor and the spacing factor. The calculation formula is as follows: ,in, For width factor, For spacing factor, and To preset the weighting coefficients, The local line width for each reshaped area;
[0082] It should be noted that the preset weighting coefficients can be adaptively set based on the stability of linewidth measurement, edge gradient consistency, and historical data calibration results.
[0083] Local linewidth reflects the actual drawing width of lines within the reshaped area and their relative thickness in the image; the larger the local linewidth value, the thicker the lines in that area, which may be main lines or emphasized parts; the smaller the local linewidth value, the thinner the lines in that area, which may be branch lines or secondary pipelines.
[0084] It needs to be explained that the rotating caliper algorithm is a computational geometry algorithm for calculating the minimum area bounding rectangle of a two-dimensional point set, used to calculate the minimum area bounding box of the pixel set of each reshaped region; the distance formula refers to the mathematical formula for calculating the Euclidean distance between two points, used to calculate the distance between the positions of two boundary points; the scan line refers to a virtual straight line set in a specific direction in the image, with the vertical direction of the short side of the minimum bounding rectangle as the reference direction, and multiple parallel lines are generated as scan lines by translating from one edge of the rectangle to the other side at equal intervals; the Sobel gradient operator is a discrete difference operator for image edge detection, used to calculate the gray-level gradient value of each pixel on the scan line; the non-maximum suppression algorithm is an algorithm for thinning edges in the gradient magnitude image, used to determine the positions of the two boundary points corresponding to the maximum gradient value; the normalization processing methods include, but are not limited to, standard linear transformation based on interval scaling, statistical Z-Score normalization method, or normalization method based on nonlinear mapping function, and the application methods of normalization processing will not be elaborated here.
[0085] By performing region reshaping on the P&ID map and accurately measuring local line widths, the line structure is standardized, improving the input quality for subsequent centerline prediction and topology analysis.
[0086] In step S2, during the P&ID map parsing process, lines may exhibit uneven width, local breaks, and blurred edges due to differences in scanning quality and drawing specifications, affecting the stability of centerline extraction. To ensure that the depth model can obtain a clear and consistent line structure, it is necessary to perform width compression or dilation compensation based on the local line width to make the image lines tend to have a uniform width. The image after width correction can improve the continuity of centerline prediction and topology preservation ability.
[0087] The local line width is compared with the preset standard line width threshold for judgment:
[0088] If the local line width is greater than or equal to the preset standard line width threshold, then it is determined that the line width of the reshaped area will be compressed.
[0089] If the local line width is less than the preset standard line width threshold, it is determined that expansion compensation processing will be performed on the lines of the reshaped area;
[0090] It should be noted that the preset standard line width threshold can be set according to the P&ID drawing specifications, scanning resolution, historical line width statistics, and target pipeline recognition accuracy requirements; width compression processing refers to the image processing method that performs morphological shrinkage operation on the lines in the reshaped area when the local line width is determined to be greater than or equal to the preset standard line width threshold, in order to reduce the line pixel width and approach the standard single pixel width; dilation compensation processing refers to the image processing method that performs morphological expansion operation on the lines in the reshaped area when the local line width is determined to be less than the preset standard line width threshold, in order to increase the line pixel width and fill the gaps between breaks.
[0091] The processed P&ID map to be tested is used as the input feature for centerline prediction. This feature is input into a pre-trained deep convolutional neural network model to obtain the initial centerline. The convolutional neural network model consists of multiple convolutional layers, upsampling layers, skip connection layers and the final centerline regression layer. It can automatically extract the spatial continuity features and local thin line pattern information of the pipeline structure, thereby generating a centerline response result that is close to the real pipeline topology.
[0092] The model training process includes the following steps:
[0093] Data preparation: Collect a large number of historical P&ID image samples and their corresponding manually annotated centerline data. Match the feature matrix of each image after width correction with the real centerline annotation to form input data and supervision label pairs;
[0094] Data preprocessing: The input feature matrix is standardized, and Gaussian diffusion is performed on the true centerline labels to ensure that the centerline targets maintain a learnable continuous response region during training;
[0095] Training strategy: Supervised learning method is adopted, with the input feature matrix as the model input and the real center line annotation as the training label. The loss function is a joint loss consisting of pixel-level binary cross-entropy and Dice loss, so as to simultaneously measure the pixel consistency and overall shape coherence of the center line.
[0096] Model optimization: The weight parameters of the convolutional neural network are updated through backpropagation algorithm, and the joint loss function value is reduced round by round; cosine annealing strategy is adopted during training to improve the convergence efficiency and generalization ability of the model in complex scenarios.
[0097] Model validation: Evaluate the model's performance on independent validation datasets in terms of centerline coherence, breakage rate, and pseudo-connection generation rate to ensure that the model can stably extract the initial centerline;
[0098] Skeleton node information is obtained by performing topological analysis on the preliminary centerline, identifying all skeleton nodes in the preliminary centerline, and classifying and recording their attribute information.
[0099] It should be noted that Gaussian diffusion is a data preprocessing technique that smooths binary centerline labels. It spreads the original single-pixel-width centerline into a band-like region with a continuous grayscale distribution by applying a two-dimensional Gaussian kernel to each pixel. Supervised learning is a machine learning method used to train a model using existing input-output samples, enabling the model to predict or classify new data. Pixel-level binary cross-entropy is a loss function used for binary image segmentation, comparing the model's predictions with the true labels pixel by pixel. Dice loss is an image segmentation loss function based on the Dice coefficient, measuring the overlap between the predicted segmented region and the real region. Backpropagation is the most commonly used optimization algorithm for training artificial neural networks, used to calculate the gradient of the loss function relative to the network weights and update the weights to reduce prediction errors. Cosine annealing is a learning rate scheduling method that dynamically adjusts the learning rate during training using a cosine function.
[0100] By performing eight-neighbor connectivity analysis on the preliminary centerline of each reshaped region, the number of neighbor connectivity points of each pixel on the preliminary centerline of each reshaped region is obtained.
[0101] If the number of connected nodes in the neighborhood is 0, the pixel is determined to be an isolated noise point and is removed during the skeleton node recognition process.
[0102] If the number of connected neighbors is 1, then the pixel is determined to be an endpoint in the skeleton node;
[0103] If the number of connected neighbors is 2, then the pixel is determined to be a path point in the skeleton node;
[0104] If the number of connected neighbors is greater than or equal to 3, then the pixel is determined to be a connection point in the skeleton node.
[0105] It should be explained that an endpoint is a node in the skeleton topology that is connected to only one adjacent skeleton pixel, representing the starting point, ending point, or break point of a pipeline; a path point is a node in the skeleton topology that is connected to two adjacent skeleton pixels, representing a normal passage point on the pipeline centerline, which does not cause changes to the topology and is only used to maintain the geometric continuity of the centerline; a connection point is a node in the skeleton topology that is connected to three or more adjacent skeleton pixels, representing the key topological location where pipelines intersect, branch, or merge, and is an important node in the pipeline network structure.
[0106] By performing width compression or expansion compensation based on local linewidth and generating a preliminary centerline using a depth model, the centerline becomes more stable in terms of continuity and structural fidelity, which is beneficial for obtaining accurate skeleton node information.
[0107] In step S3, during the centerline structure analysis, the orientation and spacing of each skeleton node are often affected by local noise and line segment bending. It is necessary to quantify its main direction and adjacent spacing to extract stable directional differences and node density, so as to provide a reliable geometric basis for subsequent connection status determination and gap backfilling.
[0108] Select a skeleton node of the initial centerline of a reshaping region as the target node;
[0109] A local line segment set is formed by taking 5 consecutive skeleton pixels on each side of the center line centered on the target node.
[0110] The pixel coordinates of the local line segment set are fitted with a straight line using the least squares method. The arctangent of the slope of the fitted line is calculated to obtain the included angle in radians. The included angle in radians is multiplied by the conversion coefficient to obtain the direction angle value, which is used as the local main direction of the skeleton node.
[0111] For the connection point, the above fitting is performed on each branch direction, and the direction of the longest branch is taken as the local principal direction of the skeleton node.
[0112] Repeat the above steps to obtain the local principal direction of each skeleton node in each remodeled region;
[0113] Select a skeleton node on the initial centerline of a remodeling region, calculate the distance between the skeleton node and its two adjacent skeleton nodes in the direction of the initial centerline of the remodeling region using the distance calculation formula, and take the average of the distances to the two adjacent skeleton nodes to obtain the adjacent interval length of the skeleton node.
[0114] Repeat the above steps to obtain the adjacent interval length of each skeleton node in each remodeling area;
[0115] The average direction of a reshaped region is obtained by averaging the local principal directions of each skeleton node within the reshaped region.
[0116] The absolute value of the difference between the local principal direction and the average direction of each skeleton node in the remodeling area is taken as the degree of difference in the intersection direction of each skeleton node in the remodeling area.
[0117] Repeat the above steps to obtain the cross-direction difference of each skeleton node in each remodeled area;
[0118] The average interval length of a remodeled region is obtained by averaging the adjacent interval lengths of each skeleton node within the remodeled region.
[0119] The reciprocal of the average interval length of the reshaped region is taken as the skeleton node density of the reshaped region;
[0120] Repeat the above steps to obtain the skeleton node density of each reshaped region.
[0121] It needs to be explained that the least squares method is a mathematical optimization method used to find the best-fitting straight line for a set of data points; the conversion coefficient is the proportional constant between radians and angles. This coefficient is determined by mathematical definition, does not need to be set, and is directly used for all radian-to-angle conversion calculations.
[0122] By calculating the local principal direction, adjacent interval length, directional difference degree, and node density of the skeleton nodes, the geometric characteristics of each node are quantitatively described, which facilitates the reliable determination of their connection status in the future.
[0123] In step S4, during centerline correction, skeleton nodes often exhibit directional shifts, density anomalies, or local pseudo-branches. It is necessary to determine whether nodes maintain a reasonable structure through connection state quantification to support fracture backfilling, pseudo-connection cleanup, and regional semantic association.
[0124] The difference in the intersection direction and the density of the skeleton nodes in each remodeling region are standardized to obtain the difference factor and density factor.
[0125] The connection state value of each skeleton node is calculated by combining the difference factor and the density factor. The calculation formula is as follows: ,in, As a difference factor, Density factor These are the connection status values for each skeleton node;
[0126] The connection status value reflects the stability of the topological position of each skeleton node in the remodeling area and is used to measure whether different nodes maintain reasonable connection in the same spatial structure. The larger the connection status value, the more obvious the comprehensive anomaly between the difference in the crossing direction of the node and the density of the skeleton nodes in the area. The topological position deviation increases, and the overall pipeline structure may face risks such as breakage or false connection.
[0127] The connection status value of each skeleton node is compared with the preset connection status threshold for determination:
[0128] If the connection status value of the skeleton node is greater than or equal to the preset connection status threshold, and the skeleton node is an endpoint, then the connection status of the skeleton node is determined to be broken, and the gap of the skeleton node is backfilled.
[0129] If the connection status value of the skeleton node is greater than or equal to the preset connection status threshold, and the skeleton node is a connection point or path point, then the connection status of the skeleton node is determined to be a pseudo-connection status.
[0130] If the connection status value of the skeleton node is less than the preset connection status threshold, the connection status of the skeleton node is determined to be stable.
[0131] Count the number of skeleton nodes in each remodeled area;
[0132] The number of skeleton nodes in each remodeled region is compared with the preset skeleton node number threshold for judgment:
[0133] If the number of skeleton nodes in the remodeled area is greater than or equal to the preset skeleton node number threshold, then pseudo-connection point removal is performed on the remodeled area.
[0134] If the number of skeleton nodes in the reshaped region is less than the preset skeleton node number threshold, then semantic annotation association is performed on the reshaped region.
[0135] It should be explained that the preset connection status threshold can be set according to the topological complexity of the P&ID drawing, the historical node connection stability data, and the fault tolerance accuracy requirements of the target pipeline structure; the preset skeleton node quantity threshold can be set according to the graphic density of the P&ID drawing, the statistical distribution of nodes in the historical area, and the target topological simplification requirements; gap backfilling refers to the process of supplementing the missing centerline pixels between the node and its adjacent nodes through interpolation or path extension algorithms when the skeleton node is determined to be in a broken state, thereby restoring the continuity of the pipeline topology; pseudo connection point removal refers to the process of deleting skeleton nodes and their abnormal connection branches that do not conform to the actual pipeline structure through topology cleaning algorithms when there are redundant or erroneous connection relationships in the determined area; semantic annotation association refers to the process of logically matching skeleton nodes with engineering symbols such as equipment, valves, and instruments in the P&ID drawing and assigning corresponding engineering semantic labels to the nodes.
[0136] By calculating connection states, backfilling fractures, removing pseudo-connection points, and associating with semantic annotations, the centerline topology is improved and purified, ultimately forming a structural expression that better reflects the actual pipeline relationships.
[0137] Finally, it should be noted that in this paper, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations.
[0138] Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0139] In this document, the singular forms “a,” “an,” and “the” may also include the plural forms unless the context clearly indicates otherwise. It should also be understood that terms such as “comprising / including” or “having” specify the presence of the stated features, integrals, steps, operations, components, parts, or combinations thereof, but do not preclude the possibility of the presence or addition of one or more other features, integrals, steps, operations, components, parts, or combinations thereof. Meanwhile, the term “and / or” as used in this specification includes any and all combinations of the associated listed items.
[0140] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referred to each other.
[0141] The above description of the disclosed embodiments will enable those skilled in the art to make or use various modifications to these embodiments. It will be readily apparent to those skilled in the art that the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data annotation method for AI-P&ID image recognition, characterized in that: Includes the following steps: Step S1: Reshape the P&ID map to be tested to obtain multiple reshaped regions. Detect the minimum bounding rectangle of the lines in each reshaped region. Measure the width of the minimum bounding rectangle and the edge gradient spacing to generate the local line width. Step S2: Based on the local line width, perform width compression or expansion compensation processing on the lines of the reshaped area, predict the center line of the processed P&ID map to be tested to generate a preliminary center line, and obtain the skeleton node information of the preliminary center line. Step S3: Detect the local principal direction and adjacent interval length of each skeleton node in the remodeling area, calculate the cross direction difference of the skeleton nodes based on the local principal direction, and generate the skeleton node density of each remodeling area based on the adjacent interval length. In step S3, a skeleton node of the initial centerline of a reshaping area is selected. The distance between the skeleton node and the two adjacent skeleton nodes in the direction of the initial centerline of the reshaping area is calculated using the distance calculation formula. The average of the distances to the two adjacent skeleton nodes is used to obtain the adjacent interval length of the skeleton node. Repeat the above steps to obtain the adjacent interval length of each skeleton node in each remodeling area; The average direction of a reshaped region is obtained by averaging the local principal directions of each skeleton node within the reshaped region. The absolute value of the difference between the local principal direction and the average direction of each skeleton node in the remodeling area is taken as the degree of difference in the intersection direction of each skeleton node in the remodeling area. Repeat the above steps to obtain the cross-direction difference of each skeleton node in each remodeled area; The average interval length of a remodeled region is obtained by averaging the adjacent interval lengths of each skeleton node within the remodeled region. The reciprocal of the average interval length of the reshaped region is taken as the skeleton node density of the reshaped region; Repeat the above steps to obtain the skeleton node density of each remodeled region; Step S4: Determine the connection status of skeleton nodes by combining the difference in cross directions and the density of skeleton nodes. If the connection status is broken, fill the gaps in the skeleton nodes. Count the number of skeleton nodes in each remodeling area and select to remove pseudo-connection points or semantically label and associate them in each remodeling area.
2. The data annotation method for AI-P&ID image recognition according to claim 1, characterized in that: In step S1, the P&ID map to be tested is reshaped to obtain multiple reshaped regions: The Otsu thresholding algorithm is used to binarize the P&ID image under test. All connected regions are extracted using eight-neighbor connectivity analysis; Merge adjacent pipeline pixels through morphological dilation operations; The expanded connected region is directly used as the initial reshaped region; For each region, convex hull calculation is performed and the region is expanded outward by 5 pixels to form the final reshaped region; The minimum bounding box of the line pixel set of each reshaped region is calculated by traversing all angles using the rotating caliper algorithm, and is used as the minimum bounding rectangle of each reshaped region line. Extract the pixel coordinates of the four vertices of the minimum bounding rectangle of each reshaped region's lines, and calculate the distance between the two endpoints of the short side using the distance formula to obtain the width of the minimum bounding rectangle of each reshaped region.
3. The data annotation method for AI-P&ID image recognition according to claim 2, characterized in that: In step S1, a scan line is set along the vertical direction of the short side of the minimum bounding rectangle, and the gray-level gradient value of each pixel on the scan line is calculated by the Sobel gradient operator. The positions of the two boundary points corresponding to the maximum gradient are determined by the non-maximum suppression algorithm. The distance between two boundary points is calculated using the distance formula and used as the edge gradient spacing of each reshaped region. The width of the minimum bounding rectangle and the edge gradient spacing of each reshaped region are standardized to obtain the width factor and spacing factor. The local line width of each reshaped area is calculated by combining the width factor and the spacing factor using a weighted summation method.
4. The data annotation method for AI-P&ID image recognition according to claim 1, characterized in that: In step S2, if the local line width is greater than or equal to the preset standard line width threshold, it is determined that the line width compression processing is performed on the reshaped area. If the local line width is less than the preset standard line width threshold, it is determined that expansion compensation processing will be performed on the lines of the reshaped area; Width compression refers to an image processing method that performs morphological shrinkage on the lines of the reshaped region to reduce the line pixel width and approximate the standard single pixel width. Dilation compensation processing is an image processing method that performs morphological expansion operations on the lines of the reshaped area to increase the line pixel width and fill the gaps between breaks.
5. The data annotation method for AI-P&ID image recognition according to claim 4, characterized in that: In step S2, the processed P&ID map to be tested is used as the input feature for centerline prediction and input into the pre-trained deep convolutional neural network model to obtain the preliminary centerline. By performing topological analysis on the preliminary centerline, all skeleton nodes in the preliminary centerline are identified, and their attribute information is classified and recorded to obtain skeleton node information. By performing eight-neighbor connectivity analysis on the preliminary centerline of each reshaped region, the number of neighbor connectivity points of each pixel on the preliminary centerline of each reshaped region is obtained. Whether to remove a skeleton node is determined based on the number of connected neighbors.
6. The data annotation method for AI-P&ID image recognition according to claim 1, characterized in that: In step S3, a skeleton node of the preliminary centerline of a reshaping region is selected as the target node; A local line segment set is formed by taking 5 consecutive skeleton pixels on each side of the center line centered on the target node. The pixel coordinates of the local line segment set are fitted with a straight line using the least squares method. The arctangent of the slope of the fitted line is calculated to obtain the included angle in radians. The included angle in radians is multiplied by the conversion coefficient to obtain the direction angle value, which is used as the local main direction of the skeleton node. For the connection point, the above fitting is performed on each branch direction, and the direction of the longest branch is taken as the local principal direction of the skeleton node. Repeat the above steps to obtain the local principal direction of each skeleton node in each remodeled region.
7. The data annotation method for AI-P&ID image recognition according to claim 1, characterized in that: In step S4, the cross-direction difference and skeleton node density of each skeleton node in each remodeling region are standardized to obtain the difference factor and density factor. The connection state value of each skeleton node is calculated by combining the difference factor and the density factor. The calculation formula is as follows: ,in, As a difference factor, Density factor These are the connection status values for each skeleton node.
8. The data annotation method for AI-P&ID image recognition according to claim 7, characterized in that: In step S4, if the connection status value of the skeleton node is greater than or equal to the preset connection status threshold, and the skeleton node is an endpoint, then the connection status of the skeleton node is determined to be broken, and the gap of the skeleton node is backfilled. If the connection status value of a skeleton node is greater than or equal to a preset connection status threshold, and the skeleton node is a connection point or a path point, then the connection status of the skeleton node is determined to be a pseudo-connection status. If the connection status value of a skeleton node is less than the preset connection status threshold, the connection status of the skeleton node is determined to be stable. Count the number of skeleton nodes in each remodeled area.
9. The data annotation method for AI-P&ID image recognition according to claim 8, characterized in that: In step S4, the number of skeleton nodes in each remodeled region is compared with a preset skeleton node number threshold for determination: If the number of skeleton nodes in the remodeled area is greater than or equal to the preset skeleton node number threshold, then pseudo-connection point removal is performed on the remodeled area. If the number of skeleton nodes in the reshaped region is less than the preset skeleton node number threshold, then semantic annotation association is performed on the reshaped region.