Extraction method for electrical drawing dotted line connecting line
By preprocessing and refining electrical drawings, combined with connected domain splitting and filtering, accurate extraction of dotted connecting lines is achieved, solving the problem of inaccurate dotted line extraction in existing technologies and improving the efficiency of data extraction and analysis.
Patent Information
- Application Number
- CN202510912572.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-03
- Publication Date
- 2025-10-17
AI Technical Summary
Existing technologies have difficulty in accurately extracting dotted connection lines in electrical drawings, resulting in low accuracy and efficiency in data extraction and analysis.
By preprocessing the electrical drawings, performing thinning operations and connecting domain splitting, merging dashed line groups that meet the threshold, and filtering dashed line segments based on distance and intersection points, accurate extraction of dashed connecting lines is achieved.
The accuracy and efficiency of extracting dotted connecting lines in electrical drawings are improved, the interference of single solid lines is reduced, and the robustness is enhanced.
Smart Images

Figure CN120808383A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing method, and particularly relates to an extraction method for electrical drawing dotted line connection lines. BACKGROUND
[0002] Traditional drawing analysis methods are mostly used for recognizing continuous solid line connection relationship, however, in actual engineering drawings, dotted lines are widely used to represent control signal loop, virtual connection or logical relationship between special function modules, and accurate extraction of the dotted lines plays an irreplaceable role in complete understanding of electrical system topology. The line type recognition method based on image processing in the prior art usually adopts a solution of Hough transform combined with line type template matching, but has significant limitations in the face of dotted line features: firstly, the traditional edge detection algorithm is sensitive to discrete line segments, and is easy to misjudge a single dotted line as multiple independent line segments; secondly, the conventional morphological processing method is difficult to effectively maintain the complete topology of the dotted lines when there are crossing and overlapping elements in the drawing; thirdly, the mainstream line segment clustering algorithm (such as the improved method based on DBSCAN) has poor adaptability to the interval of dotted lines, and is easy to produce a broken phenomenon when the drawing scaling ratio changes or the scanning quality is poor. In addition, the existing deep learning scheme performs well in solid line recognition, but is limited by the sparseness of dotted line samples and the difficulty of labeling, and the classification accuracy in the mixed scene of solid and dotted lines is generally very low. SUMMARY
[0003] The technical problem to be solved by the present application is how to provide an extraction method for electrical drawing dotted line connection lines, which can realize accurate extraction of the dotted line connection lines, so as to improve the accuracy and efficiency of data extraction and analysis.
[0004] To solve the above technical problems, the technical scheme adopted by the present application is: an extraction method for electrical drawing dotted line connection lines, comprising the following steps:
[0005] S1: processing the electrical drawing to obtain a to-be-detected image with dotted line connection lines, and removing part of non-dotted line segment noise;
[0006] S2: performing a thinning operation on the to-be-detected image with dotted line connection lines, reacquiring connected domains and splitting each connected domain into multiple horizontal line segments and vertical line segments according to the coordinate values of the connected domains;
[0007] S3: merging dotted line groups with a distance not exceeding a set threshold, and after the coordinates are merged, further extracting all the dotted line groups from three dimensions of interval, pixel ratio and length;
[0008] S4: grouping and filtering the obtained dotted line segments according to the intersection of the distance threshold and the extension line, to obtain the final dotted line connection lines.
[0009] The beneficial effects produced by the above technical scheme are: 1) the method realizes the rapid extraction of the dashed connection line in the electrical drawing, and improves the accuracy and efficiency of the electrical drawing connection data extraction and analysis. 2) The method analyzes the dashed connection line of the electrical image from the interval, pixel ratio and length, and improves the robustness in the dashed connection line extraction process. 3) The method uses the combination of spatial index and connected domain label to combine the dashed line, and adds the filtering of the number, reduces the interference of single solid line, and improves the accuracy and efficiency of the dashed connection line detection result. BRIEF DESCRIPTION OF DRAWINGS
[0010] The application will be further described in detail below in combination with the drawings and specific embodiments.
[0011] Figure 1 is the main flowchart of the method described in the embodiments of the application;
[0012] Figure 2 is the flowchart of the method described in the embodiments of the application;
[0013] Figure 3 is the image of the graphic element and text detection result in the method described in the embodiments of the application;
[0014] Figure 4 is the inverse binary image in the method described in the embodiments of the application;
[0015] Figure 5 is the dashed connection line to be detected image in the method described in the embodiments of the application;
[0016] Figure 6 is the thinned image obtained by the thinning operation in the method described in the embodiments of the application;
[0017] Figure 7 is the candidate dashed line segment group in the horizontal direction in the method described in the embodiments of the application;
[0018] Figure 8 is the candidate dashed line segment group in the vertical direction in the method described in the embodiments of the application;
[0019] Figure 9 is the spatial index map in the method described in the embodiments of the application;
[0020] Figure 10 is the final dashed connection line result in the method described in the embodiments of the application. DETAILED DESCRIPTION
[0021] With reference to the accompanying drawings, the technical solutions in the embodiments of the present application will be described clearly and completely. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0022] In the following description, many specific details are set forth in order to provide a thorough understanding of the present application. However, the present application can be practiced according to other embodiments that do not require the specific details described herein. Therefore, the present application is not limited to the embodiments described herein but rather encompasses all embodiments that would be treated as falling within the scope of the present application.
[0023] Generally, as shown in Figure 1 , the embodiment of the present application discloses a method for extracting dashed connection lines of electrical drawings, which comprises the following steps
[0024] Firstly, the electrical drawing needs to be processed to obtain a dashed connection line to-be-detected image, and part of non-dashed line segment noise is removed. The processing process includes detecting the graph elements (conventional elements), the text area, image inversion binarization, establishing the association relationship between the remaining connected domains and the graph elements, and the text.
[0025] Then, the dashed connection line to-be-detected image is thinned, the connected domain is re-acquired, and each connected domain is split into multiple horizontal line segments and vertical line segments according to the coordinate values. Then, the dashed line groups whose coordinates do not exceed a set threshold (such as 3 pixels) are merged, the number of line segments in subsequent processing is reduced, and misplacement caused by image thinning can be avoided. After the coordinates are merged, all the dashed line groups are further extracted from the three dimensions of interval, pixel ratio and length.
[0026] Finally, the obtained dashed line segments are grouped and filtered according to the intersection of the distance threshold and the extension line, and the final connection line can be accurately obtained.
[0027] The present application will be further described below with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solutions of the present application, and cannot limit the protection scope of the present application.
[0028] Figure 2 The detailed flow chart of the method for extracting dashed connection lines of electrical drawings according to the embodiment of the present application is shown in the figure, which comprises the following steps:
[0029] Step 1: YOLOv5 target detection algorithm is used to detect the graph elements (conventional elements) and the text area in the electrical drawing. The detection results of the graph elements and the text are shown in Figure 3 ;
[0030] Step 2, inverse binarization operation is performed on the input image, that is, the pixel value in the image is compared with a set threshold (220), and then the pixel value is set to 0 or 255 according to the comparison result:
[0031]
[0032] The result of inverse binarization is shown in Figure 4 .
[0033] Step 3, the detection result of the graphic element and the text in the inverse binarization result image is overlaid;
[0034] Step 4, the connected domain object is extracted, the association between the graphic element, the text detection region and the connected domain is established according to the label of the non-zero connected domain in the graphic element, the text detection region, and then the connected domain which has no association with the graphic element and the text is filtered, to obtain a candidate region image for the dotted line connection relationship detection, and the result is shown in Figure 5 .
[0035] Step 5, the binary image is refined by using Zhang-Suen algorithm, the algorithm target is to repeatedly delete the edge pixels of the image without destroying the connectivity until the skeleton of 1 pixel width is obtained, mainly including the following two sub-iterations:
[0036] (1) for each pixel P (x, y) in the image, if the following 4 conditions are met, mark this pixel:
[0037] 2≤B(P1)≤6;
[0038] A(P1)=1;
[0039] P2*P4*P6=0;
[0040] P4*P6*P8=0;
[0041] Wherein, P1, P2,..., P8 are 8-neighborhood pixels of P, B(P1) is the number of foreground points (surrounding black pixel points) in the 8-neighborhood of pixel P(x, y), and A(P1) is the number of foreground-background transitions.
[0042] (2) for each pixel P (x, y) in the image, if the following 4 conditions are met, mark this pixel:
[0043] 2≤B(P1)≤6;
[0044] A(P1)=1;
[0045] P2*P4*P8=0;
[0046] P2*P6*P8=0;
[0047] (3) delete all the pixels marked in the first sub-iteration (step (1)) and the second sub-iteration (step (2));
[0048] (4) repeat the above steps until no pixel can be deleted.
[0049] The skeleton map obtained by the refinement is shown in Fig. 4. Figure 6
[0050] Step 6, re-extract the connected domain in the refined image, and then split each connected domain into multiple horizontal line segments and vertical line segments.
[0051] Step 7, group the horizontal line segments (vertical line segments) whose distance is not more than a set threshold (such as 3 pixels) into a group.
[0052] Step 8, according to the number of line segments in each line segment group, the case is handled as follows:
[0053] (1) there is only one line segment in the line segment group, which is retained and added to the candidate dotted line list;
[0054] (2) there are only two line segments in the line segment group, first calculate the length of each line segment and the interval between the line segments, if the interval is greater than 3 times the length of the longest line segment among the two line segments, it is determined that the two line segments are not a group, otherwise further calculate the average length of the two line segments, if there is a line segment less than half of the average length, it is also determined that the two line segments are not a group, and the two line segments are split into two groups of single line segments to form a dotted line;
[0055] (3) the number of line segments in the line segment group is greater than two, for the first two line segments, the condition in (2) is judged, if they belong to the same dotted line, the line segments do not need to be split, the interval between the line segments is recorded, then the interval between the second line segment and the third line segment is calculated, and the average of all the intervals recorded before is compared with the current interval, if the difference between the current interval and the average of all the intervals recorded before is greater than 0.5 times the average, the pixel ratio is determined, first the end point coordinates of the current line segment and its adjacent front and rear line segments are obtained, then the head connection area and the tail connection area of the two line segments are cut from the original drawing, and the total number of pixels and the number of white pixels (usually representing the background or blank area) in each cut area are counted to obtain the proportion of white pixels, if the pixel ratio is high, it indicates that the line segments need to be split, otherwise they are grouped.
[0056] Otherwise, the condition in (2) is iterated to judge the next two line segments until the place where the line segments do not need to be split is found, and then the condition of not splitting is judged. Among them, Figure 7 is a candidate dotted line segment group in the horizontal direction; Figure 8 To form candidate dash line segments in vertical direction.
[0057] Step 9, to establish spatial index for the end points of each line segment in candidate dash line group, the result of spatial index is shown in Fig. 6. Figure 9
[0058] Step 10, to merge dash line groups with connection relationship according to distance and connected domain label information, to obtain new dash line group and filter out groups only composed of single line segment, finally the required dash line connection line can be obtained, the result is shown in Fig. 7. Figure 10
Claims
1. A method for extracting dotted connecting lines from electrical drawings, characterized in that The steps include: S1: Process the electrical drawing to obtain an image to be inspected with dashed connecting lines, and remove some non-dashed line segment noise; S2: performing a thinning operation on the image to be detected with dotted connecting lines, re-obtaining the connected domain and splitting it into multiple horizontal and vertical line segments according to the coordinate value of each connected domain; S3: Merge the dashed line groups whose coordinates do not exceed the set threshold. After the coordinates are merged, further extract all the dashed line groups based on the three dimensions of interval, pixel ratio and length. S4: Grouping and filtering the obtained dashed line segments according to the distance threshold and the intersection of the extended lines to obtain the final dashed connecting lines.
2. The method for extracting dotted connecting lines from electrical drawings according to claim 1, wherein: The step S1 specifically includes: Use the YOLOv5 target detection algorithm to detect the areas where the graphics and text are located in the electrical drawings; Perform an inverse binarization operation on the input image, compare the pixel values in the image with the set threshold, and then set the pixel value to 0 or 255 based on the comparison result: Overlay the detection results of the primitives and texts in the inverse binarization result image; Connected domain objects are extracted, and the association relationship between them and the connected domain is established according to the labels of the non-zero connected domains in the primitive and text detection area. Then, the connected domains that are not associated with the primitives and texts are filtered out to obtain the candidate area image for dotted line connection relationship detection.
3. The method for extracting dotted connecting lines from electrical drawings according to claim 1, wherein: The step S2 specifically includes: The Zhang-Suen algorithm is used to refine the binary image, which is used to repeatedly delete image edge pixels without destroying connectivity until a 1-pixel-wide skeleton is obtained; The connected domains are re-extracted from the thinned image, and each connected domain is then split into multiple horizontal and vertical line segments.
4. The method for extracting dotted connecting lines from electrical drawings according to claim 3, wherein: The method for obtaining a 1-pixel-wide skeleton comprises the following steps: 1) In the first iteration, for each pixel P(x,y) in the image, mark this pixel if it meets the following four conditions: 2≤B(P1)≤6; A(P1)=1; P2*P4*P6=0; P4*P6*P8=0; Where P1, P2, ... P8 are the 8-neighborhood pixels of P, B(P1) is the number of foreground points in the 8-neighborhood of pixel P(x, y), and A(P1) is the number of foreground-background transitions. 2) In the second iteration, for each pixel P(x,y) in the image, mark this pixel if it meets the following four conditions: 2≤B(P1)≤6; A(P1)=1; P2*P4*P8=0; P2*P6*P8=0; 3) Delete all pixels marked in the first and second sub-iterations; 4) Repeat the above steps until no pixels can be deleted.
5. The method for extracting dotted connecting lines from electrical drawings according to claim 1, wherein: The step S3 specifically includes: Among all the horizontal and vertical line segment groups, those whose distance does not exceed the set threshold are grouped together; Process according to the number of line segments in each line segment group; Create a spatial index for the endpoint of each line segment in the candidate dashed line group.
6. The method for extracting dotted connecting lines from electrical drawings according to claim 5, wherein: The method for processing according to the number of line segments in each line segment group comprises the following steps: 1) If there is only one line segment in the line segment group, it is retained and added to the candidate dashed line list; 2) If there are exactly two line segments in a line segment group, first calculate the length of each line segment and the interval between the line segments. If the interval is greater than three times the length of the longest line segment of the two line segments, the two line segments are considered not to be a group. Otherwise, further calculate the average length of the two line segments. If one line segment is less than half the average length, the two line segments are also considered not to be a group and are split into two groups of dashed lines consisting of single line segments. 3) If there are more than two line segments in a line segment group, the first two line segments are judged according to the conditions in 2). If they belong to the same group of dotted lines, the line segments do not need to be split. The interval between the line segments is recorded, and then the interval between the second line segment and the third line segment is calculated. The current interval is then compared with the average of all previously recorded intervals. If the set conditions are met, the pixel ratio is determined. First, the endpoint coordinates of the current line segment and its adjacent preceding and following line segments are obtained. Then, the head connection area and the tail connection area of the two line segments are intercepted from the original drawing. The total number of pixels and the number of white pixels in each intercepted area are counted to obtain the proportion of white pixels. If the pixel ratio is higher than the set threshold, it indicates that the line segments need to be split. Otherwise, they are grouped together. Otherwise, iterate the conditions in 2) to judge the next two line segments in sequence until a place where the line segment does not need to be split is found, and then judge according to the conditions of not splitting.
7. The method for extracting dotted connecting lines from electrical drawings according to claim 6, wherein: The set conditions are: The difference between the current interval and the mean of all previous segment intervals is greater than 0.5 times the mean.
8. The method for extracting dotted connecting lines from electrical drawings according to claim 1, wherein: The step S4 specifically includes: The connected dashed line groups are merged according to the distance and connected domain label information to obtain new dashed line groups and the groups consisting of only a single line segment are filtered out to finally obtain the required dashed connecting lines.