An electrical equipment drawing automatic segmentation method
By employing methods such as boundary removal, automatic threshold selection, and region merging, the problems of inaccurate segmentation and low efficiency in electrical equipment drawings have been solved, achieving efficient and automatic segmentation of electrical equipment drawings and improving recognition speed and accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- STATE GRID HUBEI EXTRA HIGH VOLTAGE CO
- Filing Date
- 2022-09-16
- Publication Date
- 2026-06-19
AI Technical Summary
Existing image segmentation algorithms suffer from slow recognition speed, error-proneness, and low efficiency in electrical equipment drawings. In particular, when electrical drawings contain small, numerous, and simple components, traditional methods struggle to effectively segment and identify each circuit module.
By employing boundary removal, automatic threshold selection, and region merging, the method identifies images in electrical equipment drawings, performs grayscale and binarization preprocessing to remove redundant boundaries, automatically selects segmentation thresholds using threshold selection rules, and combines region merging technology to accurately segment the location information of each circuit module.
It effectively removes redundant boundary areas in electrical equipment drawings, solves the problem of misjudgment of segmentation positions, improves the accuracy and efficiency of segmentation, simplifies the operation process, reduces human intervention, and realizes efficient automatic segmentation of electrical equipment drawings.
Smart Images

Figure CN116109651B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of teaching aids for moral and social studies courses, and specifically relates to an automatic segmentation method for electrical equipment drawings. Background Technology
[0002] The development of computer technology in recent years has promoted the intelligentization of power systems, but the level of digitalization in power systems still needs to be improved, specifically in two aspects: information visualization and intelligent operation across time and space. Information visualization of power systems, presented through intuitive 3D visualization models, can provide users with an immersive viewing environment. Currently, 3D models of power equipment can only cover the main structure, such as the equipment's outer shell and large mechanical components. Due to the large quantity and complexity of the internal secondary systems, manual identification and reconstruction modeling are clearly not feasible for engineering purposes. Therefore, solutions for the programmatic generation and modeling of minute components and secondary cables based on information extracted from traditional drawings have attracted attention.
[0003] Furthermore, workers still heavily rely on paper drawings during the installation, commissioning, and maintenance of electrical equipment. With industrial development, the number of electrical drawings has increased dramatically, exacerbating the problems of heavy workload, error-proneness, and low efficiency associated with manually referring to paper drawings for training, equipment analysis, fault analysis, and safety management during maintenance. Developing intelligent recognition technology for secondary system electrical drawings, transforming two-dimensional drawings into structured information through drawing recognition, and digitizing two-dimensional drawings to overcome the shortcomings of two-dimensional paper drawings, also has significant engineering value.
[0004] Electrical drawings contain numerous small and diverse components. Directly identifying components on the drawing can lead to confusion in identifying and storing identical components and their terminals within different circuit modules. Furthermore, electrical drawings have high resolution and contain a large amount of information. Inputting the entire electrical drawing into an intelligent recognition network can slow down the recognition process or even cause crashes due to excessive information storage. Compared to other images, electrical drawings have fewer colors, clear separation between background and foreground, and simple image composition. Therefore, it is necessary to employ appropriate image segmentation methods based on these key characteristics of electrical drawings.
[0005] Traditional image segmentation algorithms fall into three categories: edge detection, region segmentation, and thresholding. Edge detection utilizes sharp changes in pixel grayscale values at image edges to detect target objects, thus completing the image segmentation task. However, the grayscale values of pixels within the target image do not change drastically. Electrical drawings are mostly composed of lines and text. For a circuit module, not only do the outer edge pixels exhibit drastic grayscale value changes, but there are also many locations with drastic grayscale value changes within the internal pixels. Using edge detection can lead to severe segmentation problems within the circuit module. Region segmentation identifies pixel regions containing similar grayscale values, textures, and other features, and clusters these pixels according to their grayscale levels to segment the image. Region segmentation methods are divided into region growing and region splitting / merging. Region growing segmentation offers good accuracy and efficiency, but it typically requires manual selection of initial seed points and multiple traversals of pixels in the drawing, increasing the complexity of the task in electrical drawing applications and potentially leading to over-segmentation. Thresholding segmentation uses specific thresholds to segment pixels in an image based on their varying grayscale values. Its main advantage is its simplicity and efficiency; it typically considers only the grayscale value of pixels and ignores other characteristics, making it suitable for scenarios requiring high computational efficiency and featuring simple drawing structures. Electrical drawings, however, have simple structures, but the elements within them do not possess distinct pixel grayscale characteristics, making thresholding segmentation incompatible with these element characteristics.
[0006] Current image segmentation algorithms incorporate intelligent algorithms into traditional methods, improving accuracy and efficiency. However, most existing intelligent image segmentation algorithms focus on separating foreground objects from the background. Foreground and background objects often exhibit a wide variety of colors and rich textures, resulting in segmented regions that are mostly color blocks with similar colors and textures. Electrical drawings, on the other hand, contain only black lines representing components and circuits against a white background. They have fewer color variations and textures, and the black lines are closely spaced against the white background. Therefore, a simpler and more efficient method is needed for modular segmentation of electrical drawings. Summary of the Invention
[0007] The purpose of this invention is to provide an automatic segmentation method for electrical equipment drawings to solve the problems mentioned in the background art.
[0008] To achieve the above objectives, the present invention provides the following technical solution: an automatic segmentation method for electrical equipment drawings, comprising the following steps:
[0009] S1: Identify images in electrical equipment drawings, and then perform grayscale and binarization preprocessing on the images;
[0010] S2: Remove the boundaries from the binary image obtained above;
[0011] S3: Then, the image is segmented by automatically selecting the segmentation threshold using the set threshold selection rules, thereby obtaining the rectangular box information containing the loop module;
[0012] S4: Merge the regions of the rectangle obtained above to obtain accurate location information of each loop module;
[0013] S5: Use location information to extract and store the images of each loop module.
[0014] Preferably, in step S2, the boundary removal operation specifically involves:
[0015] The pixel information of an electrical equipment drawing can be represented as a w×h matrix. Where a ij represents the pixel value of the i-th column and j-th row, and w and h represent the width and height of the image;
[0016] The pixels in the preprocessed drawing are marked as the representation of objects and backgrounds, with the background represented by 0 and the foreground by 1, as shown in Equation (2). The number of foreground pixels in each row and column is calculated, which is the total pixel size. The calculation process is shown in Equations (3) and (4).
[0017]
[0018]
[0019]
[0020] In the formula, q ij Let be the category of the pixel in the j-th row and i-th column; w be the length of the image; h be the height of the image; S be the height of the image. j S represents the total pixel value of the j-th row; i This represents the total pixel value of the i-th column;
[0021] The image after foreground and background marking is represented as matrix A', and the drawing features are represented as a two-dimensional array z[w, h], where the 3-dimensional vector p ij =[q ij ,x ij ,y ij ] T Three features that describe pixels in an image, q ij The binary features representing pixels, x and y represent the horizontal and vertical coordinates of the pixel, respectively. Matrix A' is represented by equation (5), and the two-dimensional array z[w, h] is represented by equation (6):
[0022]
[0023]
[0024] The column feature matrix w of the binary image is constructed as shown in equation (7), where x i y is the x-coordinate corresponding to column i, and the row feature matrix h is shown in equation (8), where y j It is the y-coordinate corresponding to row j, and then using S j S i The features are used to filter the data, and the filtered row and column position information is stored in an array. The filtering rule is: if S... j If >(w-200), then y at this time j Store in array L[j]; if S i >(h-200), then x at this time i Store in array W[i]:
[0025]
[0026]
[0027] Finally, the position information stored in the array is used to generate the 3D vector p of all pixels within the bounding box region. ij =[q ij ,x ij ,y ij ] T The binary eigenvalue in q ij Set to 0, p of pixels outside the bounding box region ij Keeping the vector unchanged, we eventually obtain a new 3D vector p′ describing pixel i in the image. ij =[q′ ij ,x ij ,y ij ] T This achieves the effect of removing redundant boundary information.
[0028] In any of the above schemes, the preferred method for selecting the segmentation threshold in step S3 is as follows:
[0029] First, the pixel blocks of each column of the binary image A' are scanned column by column. Based on the column feature matrix w of the binary image established by the boundary removal module, the statistical results of the projection of the image pixels in the vertical direction are obtained. The column projection results are obtained by using the first row of the w matrix as the vertical coordinate and the second row as the horizontal coordinate.
[0030] First, take the first row of the column feature matrix w and sort them in ascending order, then perform calculations on the sorted results;
[0031] Take a number from the sequence w[1,:] as the comparison value, compare all the other numbers in w[1,:] with the comparison value, place the numbers smaller than the comparison value before the comparison value, and the numbers larger than the comparison value after the comparison value. If the number of elements before the comparison value is greater than (w*1 / 5), then only the sequence before the comparison value is sorted; otherwise, after this comparison, the comparison value is in the middle position of the sequence. Recursively sort the subsequences smaller than the comparison value and the subsequences larger than the comparison value, and use the number of elements before the comparison value and the size of (w*1 / 5) to determine the stopping condition. Finally, you can quickly get the first (w*1 / 5) numbers after the ascending sort of w[1,:].
[0032] After obtaining the first (w*1 / 5) values in ascending order, calculate their average value as the threshold X. The formula for calculating the column threshold is shown in equation (9):
[0033]
[0034] In the formula, x j Let w[1,:] be the j-th value after sorting w[1,:] in ascending order; w is the length of the image.
[0035] Preferably, in any of the above schemes, the image segmentation method in step S3 is as follows:
[0036] The starting column position information x of the loop module is determined by comparing the width between the position where the vertical pixel is less than the threshold and the previous position where the vertical pixel is greater than the threshold. start_i and end column position information x end_i The position information of the start and end columns of each column module is recorded in the form of structured information to complete the row segmentation of the drawing. Finally, the column containing multiple loop modules is row segmented, and the row segmentation is referenced to the column segmentation.
[0037] In any of the above schemes, it is preferred that, in step S4, the merging of the segmented regions involves first merging the listed regions and then merging the other regions, including:
[0038] Column region merging directly calculates the boundary distance between every two adjacent rectangles in the same column obtained from image segmentation, i.e., calculating (y start_2 -y end_1 ), where y end_1 This refers to the vertical coordinates of the lower boundary of the upper position rectangle, y. start_2 This refers to the vertical coordinates of the upper boundary of the lower position rectangle. start_2 -y end_1 When the value is less than the set value, it is determined to be an area that needs to be merged. The smallest bounding rectangle of the two rectangles is taken to obtain the rectangular area after column merging.
[0039] The basic steps for merging row regions are as follows:
[0040] 1) Take a rectangular area from the left column and a rectangular area from the right column, and determine whether there are overlapping rows between their starting and ending rows. If there are overlapping rows, proceed to the next step; otherwise, the two rectangular areas do not need to be merged.
[0041] 2) Calculate the intersection-union ratio (IUR) of the row positions of these two rectangular regions. The calculation method is shown in Equation (10). Use the IUR to determine whether the rectangular regions are potential merging locations. If so, proceed to the next step. If not, these two rectangular regions do not need to be merged.
[0042]
[0043] In the formula, y start_3 This refers to the vertical coordinates of the top boundary of the left-column rectangle; y end_3 This provides the vertical coordinates of the bottom boundary of the left-column rectangle; y start_4 This refers to the vertical coordinates of the top boundary of the right-hand rectangle; y end_4 This provides the vertical coordinates of the bottom boundary of the right-column rectangle.
[0044] 3) Calculate the horizontal distance between the left and right rectangle boundaries, i.e., calculate (x_start4-x_end3), where x_end3 is the right boundary of the left rectangle and x_start4 is the left boundary of the right rectangle. When the distance between the two boundaries is less than the set value, take the smallest bounding rectangle of the two rectangle regions to obtain the row-merged rectangle region.
[0045] The technical effects and advantages of this invention are as follows: 1. The automatic segmentation method for electrical equipment drawings uses boundary removal to remove the outermost redundant boundary areas in the electrical equipment drawings, thus solving the problem of misjudgment of segmentation positions caused by boundary areas in subsequent segmentation of the drawings;
[0046] 2. The image segmentation method, which sorts and selects values of row and column pixels and calculates the average to select the threshold, is adopted to replace the manual threshold selection method in the projection method for image segmentation. This solves the problems of cumbersome operation, long time consumption and unstable segmentation results caused by the need to modify the threshold multiple times in different drawings.
[0047] 3. The region merging method is adopted. By judging the distance between the rectangular borders of adjacent rows and columns, the rectangles are merged to eliminate the influence of over-segmentation, which can make the segmented loop modules have better accuracy. Attached Figure Description
[0048] Figure 1 Drawings of Class I electrical equipment according to the present invention;
[0049] Figure 2This is a drawing of a Class II electrical device according to the present invention;
[0050] Figure 3 This is a diagram showing the error detection results during the boundary box region segmentation of the present invention.
[0051] Figure 4 This is a partial column projection result diagram of the present invention;
[0052] Figure 5 This is a comparison diagram of common sorting algorithms used in this invention;
[0053] Figure 6 This is a flowchart of the quicksort algorithm of the present invention;
[0054] Figure 7 This is the calculation process for the start and end column position information of the present invention;
[0055] Figure 8 This is an over-segmentation diagram of the rectangular region of the present invention;
[0056] Figure 9 This is a flowchart illustrating the electrical equipment drawing segmentation process of the present invention.
[0057] Figure 10 This is the signal circuit diagram of the 10kV outgoing line cabinet electrical equipment of the present invention;
[0058] Figure 11 This is the signal circuit diagram of the 10kV sectional isolation cabinet electrical equipment of the present invention;
[0059] Figure 12 This is the signal circuit diagram of the 10kV sectional switchgear electrical equipment of the present invention. Detailed Implementation
[0060] The specific embodiments of the present invention will be further described below with reference to the accompanying drawings. It should be noted that these descriptions are for the purpose of aiding understanding the present invention, but do not constitute a limitation thereof. Furthermore, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0061] Class I electrical equipment drawings have pixels clustered in each module, exhibiting row and column characteristics. The pixel distribution characteristics of this type of drawing can be used as the basis for drawing segmentation. Drawings with narrow spacing, tightly packed pixels, and no overall row and column characteristics but some localized row and column characteristics are classified as Class II electrical equipment drawings. Figure 1 , 2 As shown. In Class II electrical equipment drawings, the row and column characteristics of each circuit module are not obvious, but some boundaries have a certain degree of continuity. The boundary continuity of this type of drawing can be used as the basis for drawing division.
[0062] Currently, projection-based image segmentation algorithms are widely used in text segmentation. These algorithms segment lines and characters based on the projection density of the image in both horizontal and vertical directions. Generally, line segmentation is performed first, using pixel results to determine the start and end lines of each text line. Then, column pixel results are used to determine whether the current blank area is a gap between characters or between structures within the same character, based on the width of the blank area. The most common approach to line and character segmentation is thresholding, where a threshold is typically selected manually based on experience, and the number of pixels determines whether a line belongs to a text line or is part of a character.
[0063] Algorithm improvements
[0064] The preprocessed electrical drawings of Class I electrical equipment are characterized by clear display and distinct separation of each circuit module. The electrical equipment drawing segmentation method based on projection segmentation algorithm proposed in this paper uses a boundary removal module to remove redundant information, sorts the row and column projection statistics results and sets threshold selection rules to achieve automatic threshold selection, and uses a region merging module to eliminate the influence of over-segmentation. Finally, this method is used to segment each circuit module and obtain their location information.
[0065] Boundary Removal
[0066] The pixel information of an electrical equipment drawing can be represented as a w×h matrix. Where a ij represents the pixel value of the i-th column and j-th row, and w and h represent the width and height of the image.
[0067] Due to the inherent characteristics of electrical equipment drawings, these drawings contain bounding box regions consisting of two outer rectangles and the numbers between them. These bounding box regions can cause misjudgments or omissions in subsequent segmentation operations. Therefore, it is necessary to identify and remove these bounding box regions from the binary image. Figure 2 As shown.
[0068] The total number of pixels in the row and column containing the two rectangular bounding boxes of the bounding box region is much larger than that in other rows and columns, and the thickness of the rectangles varies. The boundary width of the largest rectangle is 1 pixel, and the boundary width of the second largest rectangle is 3-4 pixels. Based on this characteristic, the boundary removal method in this paper first marks the pixels in the preprocessed drawing as the representation of objects and backgrounds, with the background represented by 0 and the foreground by 1, as shown in Equation (2). Then, the number of foreground pixels in each row and column is calculated, which is the total pixel size. The calculation process is shown in Equations (3) and (4).
[0069]
[0070]
[0071]
[0072] In the formula, q ij Let be the category of the pixel in the j-th row and i-th column; w be the length of the image; h be the height of the image; S be the height of the image. j S represents the total pixel value of the j-th row; i This represents the total pixel value of the i-th column.
[0073] This paper represents the image after foreground and background marking as matrix A′, and the drawing features as a two-dimensional array z[w, h], where the 3-dimensional vector p ij =[q ij ,x ij ,y ij ] T Three features that describe pixels in an image, q ij The binary feature representing the pixel is represented by x and y, which represent the horizontal and vertical coordinates of the pixel, respectively. The matrix A′ is represented by equation (5), and the two-dimensional array z[w, h] is represented by equation (6).
[0074]
[0075]
[0076] The column feature matrix w of the binary image is constructed as shown in equation (7), where x i y is the x-coordinate corresponding to column i, and the row feature matrix h is shown in equation (8), where y j It is the ordinate of row j. Then use S j S i The features are used to filter the data, and the filtered row and column position information is stored in an array. The filtering rule is as follows: If S j If >(w-200), then y at this time j Store in array L[j]; if S i >(h-200), then x at this time i Store it in array W[i].
[0077]
[0078]
[0079] Finally, the position information stored in the array is used to generate the 3D vector p of all pixels within the bounding box region. ij =[q ij ,x ij ,y ij ] T The binary eigenvalue in q ij Set to 0, p of pixels outside the bounding box regionij Keeping the vector unchanged, we eventually obtain a new 3D vector p′ describing pixel i in the image. ij =[q′ ij ,x ij ,y ij ] T This achieves the effect of removing redundant boundary information.
[0080] Threshold selection
[0081] The algorithm proposed in this paper sorts the row and column projection statistics based on the arrangement characteristics of each circuit module in the electrical drawing and sets threshold selection rules to achieve automatic threshold selection. The threshold is then used to perform column segmentation and row segmentation of the image.
[0082] First, the pixel blocks of each column of the binary image A′ are scanned column by column. Based on the column feature matrix w of the binary image established by the boundary removal module, the statistical results of the vertical projection of the image pixels are obtained. The column projection results are obtained by using the first row of the w matrix as the ordinate and the second row as the abscissa. Some projection results are shown below. Figure 4 As shown.
[0083] Then, an automatic threshold calculation method is used to ensure that the threshold does not rely on human experience. The automatic threshold calculation method involves first taking the first row of the column feature matrix w and sorting it in ascending order, and then calculating the threshold on the sorted result. Common sorting algorithms are compared in terms of their effectiveness. Figure 5 As shown. The sorting algorithm with a time complexity of O(nlogn) is better than the one with a time complexity of O(n... 2 The quicksort algorithm is more suitable for sorting large-scale data. For the same data size, quicksort is much more efficient than heapsort, and the difference in efficiency widens as the data size increases, making quicksort's advantage more pronounced. Although quicksort is an unstable algorithm, its instability lies in the possibility of changing the relative positions of elements with the same value. For the statistical results of image pixels in the vertical or horizontal direction of electrical equipment drawings, the probability of elements with the same value is very low, making the instability of the quicksort algorithm less apparent when used in electrical equipment drawings.
[0084] Therefore, this algorithm utilizes the principle of quicksort and adds a stopping condition to the original quicksort algorithm, setting the sorting to stop when the first (w*1 / 5) of the numbers in the group w[1,:] are reached. The flowchart is as follows. Figure 6 As shown.
[0085] Take a number from the sequence w[1,:] as the comparison value. Compare all other numbers in w[1,:] with this comparison value, placing those smaller than the comparison value before it and those larger than it after it. If the number of elements before the comparison value is greater than (w*1 / 5), then only the sequence before the comparison value is sorted; otherwise, after this comparison, the comparison value is in the middle position of the sequence. Recursively sort the subsequences smaller than and larger than the comparison value, and use the number of elements before the comparison value to compare with (w*1 / 5) to determine the stopping condition. Finally, you can quickly obtain the first (w*1 / 5) numbers after sorting w[1,:] in ascending order.
[0086] After obtaining the first (w*1 / 5) values in ascending order, calculate their average as the threshold X. The formula for calculating the column threshold is shown in equation (9):
[0087]
[0088] In the formula, x j Let w[1,:] be the j-th value after sorting w[1,:] in ascending order; w is the length of the image.
[0089] Then, the width between the position where the vertical pixel is less than the threshold and the previous position where the vertical pixel is greater than the threshold is compared to find the starting column position information x of the loop module. start_i and end column position information x end_i The algorithm records the position information of the start and end columns of each column module in the form of structured information to complete the row segmentation of the drawing. The algorithm flow is as follows: Figure 7 As shown. Finally, the columns containing multiple loop modules are row-segmented, and the algorithm for row-segmentation is similar to that for column-segmentation.
[0090] Regional merger
[0091] The drawing segmentation process involves scanning and projecting pixels row by row or column by column. The prevalence of blank backgrounds in each loop module inevitably leads to some issues during image segmentation, such as… Figure 8 The oversegmentation phenomenon shown refers to the segmentation of images that originally belonged to the same loop module. Therefore, this paper designs a rectangular region merging module to merge regions belonging to the same loop to eliminate the effect of oversegmentation.
[0092] After the image segmentation module completes, the location information is stored in the array in column order. The rectangular region merging module merges column regions first and then row regions.
[0093] Column region merging directly calculates the boundary distance between every two adjacent rectangles in the same column obtained from image segmentation, i.e., calculating (y start_2 -y end_1 ). Where yend_1 This refers to the vertical coordinates of the lower boundary of the upper position rectangle, y. start_2 This provides the vertical coordinates of the upper boundary of the rectangle at the lower position. When (y... start_2 -y end_1 When the value is less than the set value, it is determined to be a region that needs to be merged. The smallest bounding rectangle of the two rectangles is taken to obtain the rectangular region after column merging.
[0094] Row region merging first checks the rectangular regions of every two adjacent columns twice, and only merges them if they are identified as rectangles to be merged. The basic steps of row region merging are as follows:
[0095] 1) Take one rectangular area from the left column and one from the right column, and determine whether there are overlapping rows between their starting and ending rows. If there are overlapping rows, proceed to the next step; otherwise, the two rectangular areas do not need to be merged.
[0096] 2) Calculate the intersection-union ratio of the row positions of the two rectangular regions. The calculation method is shown in Equation (10). Use the intersection-union ratio to determine whether the rectangular region is a potential merging position. If it is, proceed to the next step. If not, the two rectangular regions do not need to be merged.
[0097]
[0098] In the formula, y start_3 This refers to the vertical coordinates of the top boundary of the left-column rectangle; y end_3 This provides the vertical coordinates of the bottom boundary of the left-column rectangle; y start_4 This refers to the vertical coordinates of the top boundary of the right-hand rectangle; y end_4 This provides the vertical coordinates of the bottom boundary of the right-hand rectangle.
[0099] 3) Calculate the horizontal distance between the left and right rectangle boundaries, i.e., calculate (x_start4 - x_end3). Here, x_end3 is the right boundary of the left rectangle, and x_start4 is the left boundary of the right rectangle. When the distance between the two boundaries is less than a set value, the smallest bounding rectangle of the two rectangles is taken to obtain the merged rectangle region.
[0100] To demonstrate the applicability of the proposed method to segmentation of Class I electrical equipment drawings, this section explores the impact of different experimental objects on the results. The algorithm presented in this paper is used to segment different Class I electrical equipment drawings. Signal loop drawings of three types of Class I electrical equipment—10kV outgoing line cabinets, 10kV sectional isolation cabinets, and 10kV sectional switchgear—are selected for the experiment. The experimental results are as follows: Figure 10-12As shown, this method has a good segmentation effect on different Class I electrical equipment drawings, and can accurately and clearly obtain each circuit module.
[0101] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. An automatic electrical equipment drawing segmentation method, characterized by: Includes the following steps: S1: Identify images in electrical equipment drawings, and then perform grayscale and binarization preprocessing on the images; S2: Remove the boundaries from the binary image obtained in step S1 above; S3: Then, the image is segmented by automatically selecting the segmentation threshold using the set threshold selection rules, thereby obtaining the rectangular box information containing the loop module; S4: Merge the regions of the rectangle obtained above to obtain accurate location information of each loop module; S5: Use location information to extract and store the images of each loop module; In step S2, the boundary removal operation specifically involves: Represent the pixel information of an electrical equipment drawing as a w×h matrix. ; Where a ij represents the pixel value of the i-th column and j-th row, and w and h represent the width and height of the image; The pixels in the preprocessed drawing are labeled as objects and backgrounds, with 0 representing the background and 1 representing the foreground, as shown in Equation (2). The number of foreground pixels in each row and column is calculated, which is the total pixel size. The calculation process is shown in Equations (3) and (4). ; ; ; In the formula, q ij S represents the category of the pixel in the j-th row and i-th column; j This represents the total pixel value of the j-th row; S i Total pixel value for the i-th column; The image after foreground and background marking is represented as matrix A', and the drawing features are represented as a two-dimensional array z[w, h], where the 3-dimensional vector p ij =[q ij ,x ij ,y ij ] T Three features that describe pixels in an image, q ij The binary features representing pixels, x and y represent the horizontal and vertical coordinates of the pixel, respectively. Matrix A' is represented by equation (5), and the two-dimensional array z[w, h] is represented by equation (6): ; ; The column feature matrix W of the binary image is constructed as shown in equation (7), where x i y is the x-coordinate corresponding to column i, and the row feature matrix H is shown in equation (8), where y j It is the y-coordinate corresponding to row j, and then using S j S i The features are used to filter the data, and the filtered row and column position information is stored in an array. The filtering rule is: if S... j If >(w-200), then y at this time j Store in array H[j]; if S i >(h-200), then x at this time i Store in array W[i]: ; ; Finally, the position information stored in the array is used to generate the 3D vector p of all pixels within the bounding box region. ij =[q ij ,x ij ,y ij ] T The binary eigenvalue in q ij Set to 0, p of pixels outside the bounding box region ij Remaining unchanged, we eventually obtain a new 3D vector p' describing pixel i in the image. ij =[q' ij ,x ij ,y ij ] T This achieves the effect of removing redundant boundary information.
2. The automatic segmentation method for electrical equipment drawings according to claim 1, characterized in that: In step S3, the method for selecting the segmentation threshold is as follows: First, the pixel blocks of each column of the binary image A' are scanned column by column. Based on the column feature matrix W of the binary image established by the boundary removal module, the statistical results of the projection of the image pixels in the vertical direction are obtained. The column projection results are obtained by using the first row of the W matrix as the vertical coordinate and the second row as the horizontal coordinate. First, take the first row of the column feature matrix W and sort it in ascending order, then perform calculations on the sorted results; Take a number from the sequence w[1,:] as the comparison value, compare all the other numbers in w[1,:] with the comparison value, place the numbers smaller than the comparison value before the comparison value, and the numbers larger than the comparison value after the comparison value. If the number of elements before the comparison value is greater than (w*1 / 5), then only the sequence before the comparison value is sorted; otherwise, after this comparison, the comparison value is in the middle position of the sequence. Recursively sort the subsequences smaller than the comparison value and the subsequences larger than the comparison value, and use the number of elements before the comparison value and the size of (w*1 / 5) to determine the stopping condition. Finally, you can quickly get the first (w*1 / 5) numbers after the ascending sort of w[1,:]. After obtaining the first (w*1 / 5) values in ascending order, calculate their average as the threshold.
3. The method of claim 2, wherein: In step S3, the image segmentation method is as follows: The starting column position information x of the loop module is determined by comparing the width between the position where the vertical pixel is less than the threshold and the previous position where the vertical pixel is greater than the threshold. start_i and end column position information x end_i The column segmentation of the drawing is completed by recording the position information of the start and end columns of each column module in the form of structured information. Finally, the column containing multiple loop modules is segmented into rows, and the row segmentation is referenced to the column segmentation.
4. The method of claim 1, wherein: In step S4, the merging of the segmented regions involves first merging the listed regions and then merging the merged regions, including: Column region merging directly calculates the boundary distance between every two adjacent rectangles in the same column obtained from image segmentation, i.e., calculating (y start_2 -y end_1 ), where y end_1 This refers to the vertical coordinates of the lower boundary of the upper position rectangle, y. start_2 This refers to the vertical coordinates of the upper boundary of the lower position rectangle. start_2 -y end_1 When the value is less than the set value, it is determined to be an area that needs to be merged. The smallest bounding rectangle of the two rectangles is taken to obtain the rectangular area after column merging. The basic steps for merging row regions are as follows: 1) Take a rectangular area from the left column and a rectangular area from the right column, and determine whether there are overlapping rows between their starting and ending rows. If there are overlapping rows, proceed to the next step; otherwise, the two rectangular areas do not need to be merged. 2) Calculate the intersection-union ratio (IUR) of the row positions of these two rectangular regions. The calculation method is shown in Equation (10). Use the IUR to determine whether the rectangular regions are potential merging locations. If so, proceed to the next step. If not, these two rectangular regions do not need to be merged. ; In the formula, y start_3 This refers to the vertical coordinates of the top boundary of the left-column rectangle; y end_3 This provides the vertical coordinates of the bottom boundary of the left-column rectangle; y start_4 This refers to the vertical coordinates of the top boundary of the right-hand rectangle; y end_4 This provides the vertical coordinates of the bottom boundary of the right-column rectangle. 3) Calculate the horizontal distance between the left and right rectangle boundaries, i.e., calculate (x_start4-x_end3), where x_end3 is the right boundary of the left rectangle and x_start4 is the left boundary of the right rectangle. When the distance between the two boundaries is less than the set value, take the smallest bounding rectangle of the two rectangle regions to obtain the row-merged rectangle region.