A method, apparatus and electronic device for generating an insulator mask
Patent Information
- Application Number
- CN202611071141.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-20
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2046-07-20
AI Technical Summary
[0005]本申请提供了一种绝缘子掩膜的生成方法、装置和电子设备,能够解决传统的图像分割方法对绝缘子的复杂形状的适应性较差,易受背景干扰的问题,提升绝缘子掩膜的生成精度
[0016]本申请实施例通过定向边界框快速定位绝缘子区域,有效聚焦目标并初步排除无关背景干扰,缓解了背景复杂性问题。基于采样点的行数对定向边界框进行纵向分割,根据动态的二值化阈值确定纵向分割后定向边界框包含的区域内绝缘子的初步分割掩膜,该方式得到的初步分割掩膜能够初步贴合绝缘子的鱼骨状结构。因此,从初步分割掩膜中沿第一方向提取一系列的宽度值和中心点坐标等几何特征,能够自适应处理长宽比和方向变化,进一步减少背景干扰,提升后续掩膜生成的精度和形状适应性。最终,通过对中心点坐标进行拟合获得表征绝缘子主轴走向的轴线方程,并基于轴线方程和每一宽度值准确地生成绝缘子的高质量的掩膜,为后续基于掩膜的温度提取提供了准确可靠的区域基础。这一流程利用绝缘子自身的形态先验(长条状、宽度相对一致)进行几何建模与重建,解决了依赖全局像素级分割一致性的传统图像分割方法对绝缘子复杂形状的适应性差、易受背景干扰、无法有效处理其长宽比和方向变化导致的易产生过分割或欠分割的问题。另外,该方法无需依赖大规模标注数据,泛化能力强,解决了数据稀缺为基于深度学习的方法带来的训练困难的问题。
Smart Images

Figure CN122597405B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a method, apparatus and electronic device for generating an insulator mask. Background Technology
[0002] In the field of power system operation and maintenance, insulators, as key equipment supporting conductors and isolating potentials, are crucial to the safety of the power grid. Insulators typically consist of a shaft and multiple discs, exhibiting unique herringbone or string-like geometric features from a specific viewing angle. Due to long-term exposure to electrical, thermal, and mechanical stresses, insulators may experience abnormal temperature rises, which is an important early sign of potential failure. Therefore, accurate temperature monitoring of insulators is a core requirement for achieving condition-based early warning and fault prevention.
[0003] Most solutions typically rely on visible light or infrared images, using image segmentation methods to extract the target region of the insulator and then analyze its temperature distribution. However, currently used traditional image segmentation methods (such as thresholding and edge detection) are poorly adapted to the complex shapes of insulators and are easily affected by background interference (such as conductors, towers, or other equipment), resulting in low-quality and insufficient-accurate segmentation masks.
[0004] Therefore, there is an urgent need for a segmentation scheme that can improve the generation accuracy of insulator masks. Summary of the Invention
[0005] This application provides a method, apparatus, and electronic device for generating an insulator mask, which can solve the problems of poor adaptability of traditional image segmentation methods to the complex shape of insulators and susceptibility to background interference, thereby improving the generation accuracy of the insulator mask.
[0006] Firstly, a method for generating an insulator mask is provided, comprising: Determine the oriented bounding box of the region where the insulator is located based on the target image containing the insulator; Based on the sampling points, the oriented bounding box is segmented vertically, and the preliminary segmentation mask of the insulators in the region contained in the vertically segmented oriented bounding box is determined according to the dynamic binarization threshold. Determine the width values of the initial segmentation mask at multiple vertical coordinates along the first direction, where the first direction is parallel to the long side of the oriented bounding box; the width value is the effective area width of the initial segmentation mask. Based on each width value and the coordinates of the sampling points contained in the row corresponding to the corresponding width value of the preliminary segmentation mask, determine the coordinates of the center point of the effective area of the preliminary segmentation mask in the row corresponding to each width value; By fitting the coordinates of each center point, the axis equation characterizing the insulator's main shaft is obtained; The mask for the insulator is generated based on each width value and the axis equation.
[0007] In one feasible design, the oriented bounding box is longitudinally segmented based on sampling points. A preliminary segmentation mask for insulators within the region encompassed by the longitudinally segmented oriented bounding box is determined according to a dynamic binarization threshold, including: Based on the parameters of the oriented bounding box, sampling is performed along the first direction and the second direction within the region contained by the oriented bounding box to generate a set of sampling points, wherein the second direction is perpendicular to the first direction; The region formed by the set of sampling points is longitudinally divided into multiple sub-regions along the first direction; Based on the gray-level distribution characteristics of sampling points in each sub-region, the binarization threshold corresponding to each sub-region is dynamically determined. Binarize the corresponding sub-region according to the binarization threshold of each sub-region to generate a binarization mask for each sub-region; The binarized masks of each sub-region are stitched together to generate a preliminary segmentation mask covering the insulator.
[0008] In a feasible design, for each sub-region, the binarization threshold corresponding to each sub-region is dynamically determined based on the gray-level distribution characteristics of the sampling points within each sub-region, including: The sub-region is divided into four secondary sub-regions along the second direction; The average gray value of the two middle secondary sub-regions is determined to be the first average gray value; The average gray value of the two secondary sub-regions located on both sides is determined to be the second average gray value; Determine the grayscale difference between the first average grayscale value and the second average grayscale value; If the grayscale difference is greater than zero, the binarization threshold is determined using the following formula: ; in, For the index of the sub-region, Subregion The first average gray value, For adjustment coefficients, Subregion The corresponding grayscale difference, Indicates the binarization threshold; If the grayscale difference is less than or equal to zero, the binarization threshold is determined using the following formula: ; in, Subregion The second average gray value, This is the adjustment coefficient.
[0009] In one feasible design, the width values of the initial segmentation mask at multiple vertical coordinates along a first direction are determined, including: If the grayscale difference is greater than zero, the region formed by the sampling points with grayscale values greater than or equal to the binarization threshold is determined as the effective region of the preliminary segmentation mask; If the grayscale difference is less than or equal to zero, the region formed by the sampling points whose grayscale values are less than or equal to the binarization threshold is determined as the effective region of the preliminary segmentation mask. The width of the effective area of the initial segmentation mask at each ordinate along the first direction is determined as the width value of the initial segmentation mask at the corresponding ordinate along the first direction.
[0010] In a feasible design, a mask for the insulator is generated based on each width value and the axis equation, including: Clustering is performed on the width value sequence to obtain at least two clusters, where the width value sequence is a sequence composed of each width value; Select the cluster with the most data points from at least two clusters as the target cluster; The average width value of each width value in the target cluster is determined as the standard width of the insulator's mask; The rectangular region to be constructed is constructed by extending half the standard width along both sides of the vertical center line, using the straight line represented by the axis equation as the vertical center line. The rectangular region is mapped onto the target image to obtain the mask corresponding to the insulator on the target image.
[0011] In one feasible design, a rectangular region is mapped onto the target image to obtain a mask corresponding to the insulator on the target image, including: Determine the coordinates of the four vertices of the oriented bounding box; Determine the coordinates of the four vertices of the rectangular region; Construct an affine transformation matrix based on the coordinates of the four vertices of the oriented bounding box and the four vertices of the rectangular region; Based on the affine transformation matrix, coordinate mapping is performed on the rectangular region to obtain the mask corresponding to the insulator on the target image.
[0012] In a feasible design, the axis equation characterizing the insulator's principal axis is obtained by fitting the coordinates of each center point, including: The coordinates of each center point are linearly fitted using the least squares method to obtain the preliminary axis equation; Determine the fitting residual of each center point relative to the initial axis equation; Center points where the fitted residuals are greater than the residual threshold are identified as outliers; Remove outliers from each center point to obtain the remaining center points; The coordinates of the remaining center points are linearly fitted using the least squares method to obtain the axis equation characterizing the insulator's main shaft.
[0013] In one feasible design, before dividing the region consisting of the set of sampling points longitudinally into multiple sub-regions along a first direction, the method further includes: Determine whether each sampling point in the sampling point set is located within the boundary range of the target image; Remove sampling points from the set of sampling points that are not located within the boundary of the target image.
[0014] Secondly, an apparatus for generating an insulator mask is provided, comprising: The directional bounding box determination module is used to determine the directional bounding box of the region where the insulator is located based on the target image containing the insulator; The preliminary segmentation mask determination module is used to longitudinally segment the oriented bounding box based on sampling points, and determine the preliminary segmentation mask of the insulators in the region contained in the longitudinally segmented oriented bounding box according to a dynamic binarization threshold. The width value determination module is used to determine the width values of the preliminary segmentation mask at multiple vertical coordinates along the first direction, where the first direction is the direction parallel to the long side of the oriented bounding box; the width value is the effective area width of the preliminary segmentation mask. The center point determination module is used to determine the coordinates of the center point of the effective area of the preliminary segmentation mask in the row corresponding to each width value, based on the coordinate values of the sampling points contained in the row corresponding to each width value of the preliminary segmentation mask. The axis equation determination module is used to obtain the axis equation characterizing the main shaft of the insulator by fitting the coordinates of each center point; The mask generation module is used to generate a mask for the insulator based on each width value and the axis equation.
[0015] Thirdly, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of any of the foregoing embodiments of the method for generating an insulator mask.
[0016] This application embodiment uses a directional bounding box to quickly locate the insulator region, effectively focusing on the target and initially eliminating irrelevant background interference, thus alleviating the problem of background complexity. The directional bounding box is vertically segmented based on the number of rows of sampling points. A preliminary segmentation mask for the insulator within the region contained in the vertically segmented directional bounding box is determined according to a dynamic binarization threshold. This preliminary segmentation mask can initially fit the herringbone structure of the insulator. Therefore, extracting a series of geometric features such as width values and center point coordinates along the first direction from the preliminary segmentation mask can adaptively handle aspect ratio and directional changes, further reducing background interference and improving the accuracy and shape adaptability of subsequent mask generation. Finally, by fitting the center point coordinates, an axis equation characterizing the direction of the insulator's main axis is obtained. Based on the axis equation and each width value, a high-quality mask for the insulator is accurately generated, providing an accurate and reliable regional basis for subsequent mask-based temperature extraction. This process utilizes the insulator's own morphological priors (elongated shape with relatively consistent width) for geometric modeling and reconstruction, solving the problems of traditional image segmentation methods that rely on global pixel-level segmentation consistency, such as poor adaptability to complex insulator shapes, susceptibility to background interference, and inability to effectively handle oversegmentation or undersegmentation caused by changes in aspect ratio and orientation. Furthermore, this method does not require large-scale labeled data, exhibits strong generalization ability, and overcomes the training difficulties caused by data scarcity for deep learning-based methods. Attached Figure Description
[0017] To more clearly illustrate the technical solution of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a schematic flowchart illustrating an exemplary method for generating an insulator mask provided in an exemplary embodiment of this application; Figure 2 This is a schematic diagram of an image coordinate system of an OBB provided in an exemplary embodiment of this application; Figure 3 This is a schematic diagram of a sampling of an insulator region provided in an exemplary embodiment of this application; Figure 4 This is a sampled grayscale image containing an insulator provided in an exemplary embodiment of this application; Figure 5 This is a schematic diagram of an example region and secondary sub-regions provided in an exemplary embodiment of this application; Figure 6 This is a preliminary segmentation mask for binarization of an insulator provided in an exemplary embodiment of this application; Figure 7This is a schematic diagram of an example width value provided by an exemplary embodiment of this application; Figure 8 This is a schematic diagram of the center point distribution of an example insulator provided in an exemplary embodiment of this application; Figure 9 This is a schematic diagram of a straight line representing the axis equation corresponding to a center point, provided in an exemplary embodiment of this application. Figure 10 This is a schematic diagram of a rectangular region provided in an exemplary embodiment of this application; Figure 11 This is an example of a mask region effect on a target image provided by an exemplary embodiment of this application; Figure 12 This is a schematic diagram of an insulator mask generation apparatus provided in an exemplary embodiment of this application. Detailed Implementation
[0019] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0020] Currently, although methods exist for training deep learning models using large amounts of labeled data and then using these models to detect insulator masks, the scarcity and varied shapes of insulator image datasets make model training difficult and generalization capabilities weak. Furthermore, the fishbone-like or string-like structure of insulators makes it difficult for generalized rectangular bounding box-based segmentation algorithms to effectively adapt to changes in aspect ratio and orientation, easily leading to oversegmentation or undersegmentation. The lack of high-precision segmentation masks also results in inaccurate temperature extraction from insulator regions, affecting thermal imaging analysis and hindering real-time, reliable temperature monitoring.
[0021] To address the aforementioned problems, this application provides a method for generating an insulator mask, such as... Figure 1 As shown, the method includes: S110, Determine the oriented bounding box of the region where the insulator is located based on the target image containing the insulator.
[0022] For example, to obtain a target image containing insulators, the size of the target image is... , Indicates width, in pixels. The height is represented in pixels. Then, the insulator region is located by applying object detection methods (such as oriented bounding box-based detection) to the target image, generating an Oriented Bounding Box (OBB). An OBB is defined as a rotated rectangle, with parameters including the center point coordinates. ,length (Unit: pixels), Width Rotation angle (Unit: degrees), where, Represents the center point Axis coordinates (also known as horizontal coordinates) Represents the center point The axis coordinate (also known as the vertical coordinate) is centered at the pixel point located at the center of the OBB.
[0023] Unless otherwise specified, pixels are represented in pixel coordinates in this application.
[0024] S120: Based on sampling points, the oriented bounding box is longitudinally segmented, and the preliminary segmentation mask of the insulators within the region contained in the longitudinally segmented oriented bounding box is determined according to the dynamic binarization threshold.
[0025] In one feasible design, the longitudinal segmentation of the oriented bounding box based on sampling points is achieved by determining the initial segmentation mask of the insulators within the region contained in the longitudinally segmented oriented bounding box according to a dynamic binarization threshold: Based on the parameters of the oriented bounding box, sampling is performed along the first direction and the second direction within the region contained by the oriented bounding box to generate a set of sampling points, wherein the second direction is perpendicular to the first direction; The region formed by the set of sampling points is longitudinally divided into multiple sub-regions along the first direction; Based on the gray-level distribution characteristics of sampling points in each sub-region, the binarization threshold corresponding to each sub-region is dynamically determined. Binarize the corresponding sub-region according to the binarization threshold of each sub-region to generate a binarization mask for each sub-region; The binarized masks of each sub-region are stitched together to generate a preliminary segmentation mask covering the insulator.
[0026] For example, the method further includes: Determine whether each sampling point in the sampling point set is located within the boundary range of the target image; Remove sampling points from the set of sampling points that are not located within the boundary of the target image.
[0027] The above example ensures that all sampling points are valid, avoiding mask distortion caused by boundary extrapolation. A sampling point can be understood as a pixel after sampling.
[0028] like Figure 2 As shown, the first direction is the coordinate system of the image where OBB is located. The axial direction (also known as the length direction of the OBB frame, the main axis direction, or the longitudinal direction), the second direction is The axial direction (also known as the width direction of the OBB frame, the secondary axial direction, or the lateral direction). Sampling along the first direction. One point, Sampling along the second direction (secondary axis direction) One point, This generates a set of sampling points, which together form a fishbone-shaped sampling region. Sampling point coordinates. The parameters of the oriented bounding box can be calculated using linear interpolation formulas (1) and (2): , formula (1); , formula (2); in, Sampling points Axis coordinates Sampling points Axis coordinates This indicates the index of the sampling point along the x-axis. Indicates the sampling point is at Index along the axis, , .
[0029] Determine whether each sampling point satisfies and If this condition is not met, it means the OBB box exceeds the image boundary, and the sampling point is not located within the boundary of the target image; therefore, the sampling point needs to be deleted. In actual images containing insulators, the distribution of the sampling point set corresponding to the insulator can be referenced... Figure 3 (The number of samples has been reduced to better illustrate the effect.) The region (or subplot) formed by the set of sample points can be found in the reference image. Figure 4 .
[0030] Then, as Figure 5 As shown, the region formed by the set of sampling points is divided along the first direction (i.e., vertically). Sub-regions This indicates the number of sub-regions contained within the region formed by the set of sampling points, with each sub-region consisting of 10 rows of pixels. For each sub-region k, k represents the index of the sub-region. By analyzing the grayscale distribution characteristics of the sampling points contained within the region, the binarization threshold corresponding to sub-region k is dynamically determined. Then, based on the binarization threshold corresponding to sub-region k... Binarize the sub-region k. This represents the binarization threshold, generating a binarization mask for sub-region k. , This represents the binarized mask of sub-region k. The binarized masks of each sub-region are then... The images are spliced together to generate a preliminary segmentation mask B covering the insulator. B represents the preliminary segmentation mask generated by splicing the binary masks of each sub-region. Figure 4 See the corresponding preliminary segmentation mask B for binarization. Figure 6 .
[0031] The above embodiments generate a dense and structured set of sampling points by performing herringbone-shaped sampling within a directional bounding box along the main axis (i.e., the first direction) and the secondary axis (i.e., the second direction) of the insulator. This sampling method can closely fit the elongated, multi-disc geometry of the insulator, effectively focusing on the target area and reducing interference from background pixels. Subsequently, the sampling area is divided into multiple sub-regions along the main axis, and an adaptive binarization threshold is independently determined within each sub-region based on its grayscale distribution characteristics. This enables locally optimal segmentation for different sections of the insulator (e.g., brighter discs and darker shafts), overcoming the shortcomings of a single global threshold for uneven grayscale distribution. Finally, by stitching together the binary masks generated from each sub-region, a complete and coherent preliminary segmentation mask is formed. This series of operations significantly improves the accuracy of the mask's fit to the actual shape of the insulator, providing a high-quality regional foundation for subsequent temperature extraction.
[0032] In a feasible design, for each sub-region, the binarization threshold corresponding to each sub-region is dynamically determined based on the gray-level distribution characteristics of the sampling points within each sub-region in the following way: The sub-region is divided into four secondary sub-regions along the second direction; The average gray value of the two middle secondary sub-regions is determined to be the first average gray value; The average gray value of the two secondary sub-regions located on both sides is determined to be the second average gray value; Determine the grayscale difference between the first average grayscale value and the second average grayscale value; specifically, subtract the second average grayscale value from the first average grayscale value to obtain the grayscale difference.
[0033] If the grayscale difference is greater than zero, the binarization threshold is determined using the following formula (3): , formula (3); Where k is the index of the sub-region. This represents the first average gray value of sub-region k. For adjustment coefficients, This represents the grayscale difference corresponding to sub-region k. Indicates the binarization threshold; If the grayscale difference is less than or equal to zero, the binarization threshold is determined using the following formula (4): , formula (4); in, This represents the second average gray value of sub-region k. This is the adjustment coefficient.
[0034] like Figure 5 As shown, sub-region k is evenly divided into four secondary sub-regions along the second direction, including secondary sub-region 1, secondary sub-region 2, secondary sub-region 3, and secondary sub-region 4. The number of pixels in the middle secondary sub-regions 2 and 3 is... The number of pixels in the secondary sub-regions 1 and 4 located on both sides is The first average gray value is determined using the following formula (5). : , formula (5); Where (i,j) represents the row index and column index of the pixel. Subregion The set consisting of the indices of the pixels in the two secondary sub-regions located in the middle. Indicates sampling point ( The grayscale value of ).
[0035] The second average gray value is determined using the following formula (6). : , formula (6); in, Subregion The set consists of the indices of the pixels in the two secondary sub-regions located on both sides.
[0036] The grayscale difference between the first average grayscale value and the second average grayscale value is determined using the following formula (7). : , formula (7); according to Choose either formula (3) or formula (4) to determine the binarization threshold of subregion k. ,in, The value can be set to 0.2. The value can be set to 0.3. If A positive value means that the gray level of the middle area is relatively higher than that of the edge area (i.e., high gray level); otherwise, it means that the gray level of the middle area is relatively lower than that of the edge area (i.e., low gray level).
[0037] Furthermore, the binarized threshold is implemented using the following formula (8). Binarize the sampling points within sub-region k: , formula (8); in, Indicates sampling point ( The corresponding binarized grayscale value. Based on this, This is a binary image composed of each sampling point within sub-region k after binarization. This indicates a conditional judgment. This indicates that the default output value is 0 in other cases.
[0038] The above embodiment first precisely divides the sub-region into four equal parts along the width direction (second direction), and distinguishes between the middle part and the two side edge parts, effectively establishing a grayscale contrast model between the "target" (insulator body) and the "background" within a local area. By calculating and comparing the difference between the first average grayscale value and the second average grayscale value, it can intelligently determine whether the current sub-region belongs to "bright target dark background" (…). (greater than zero) or "dark target with bright background" ( In scenarios where the threshold is less than or equal to zero, two different threshold calculation formulas are adaptively selected and applied based on different scenarios: a higher threshold is used for bright targets, and a lower threshold is used for dark targets. This suppresses the background and ensures that only high-confidence target pixels are retained. This method dynamically adjusts the threshold based on local gray-level relationships, which can effectively overcome the interference caused by uneven global or local illumination and complex and variable backgrounds. This makes the binarization process no longer a rigid global segmentation, but a local optimization with scene awareness capabilities, thereby greatly reducing the occurrence of missegmentation (classifying the background as the target) and missed segmentation (classifying the target as the background), laying the foundation for generating a high-precision preliminary segmentation mask for insulators. In summary, the above embodiments improve the accuracy of the preliminary segmentation mask in capturing the true contour of the insulator and its anti-interference ability by introducing local gray-level contrast analysis and adaptive threshold decision mechanism.
[0039] S130, determine the width values of the preliminary segmentation mask at multiple vertical coordinates along the first direction.
[0040] The first direction is parallel to the long side of the oriented bounding box, and the width value is the effective area width of the initial segmentation mask.
[0041] In one feasible design, the width values of the initial segmentation mask at multiple vertical coordinates along the first direction are determined in the following way: If the grayscale difference is greater than zero, the region formed by the sampling points with grayscale values greater than or equal to the binarization threshold is determined as the effective region of the preliminary segmentation mask; If the grayscale difference is less than or equal to zero, the region formed by the sampling points whose grayscale values are less than or equal to the binarization threshold is determined as the effective region of the preliminary segmentation mask. The width of the effective area of the initial segmentation mask at each ordinate along the first direction is determined as the width value of the initial segmentation mask at the corresponding ordinate along the first direction.
[0042] like Figure 7 As shown, after obtaining the initial segmentation mask through sampling processing, the width value at the ordinate i (i.e., the i-th sampling position, or the i-th row) along the first direction is... The following formula (9) is used to determine: , formula (9); in, Indicates the initial segmentation mask sampling points ( The grayscale value after binarization of ). This represents a sampling point with a grayscale value of 1, i.e., an effective value within the valid region. Indicates the initial segmentation mask The set of column indices of the sampling points with a gray value of 1 after binarization in the i-th row. This represents the maximum value in the set of column indices. This represents the minimum value in the set of column indices.
[0043] Formula (8) is passed The effective region of the preliminary segmentation mask was determined by the sampling points with a gray value of 1 after binarization. Specifically, if the gray-level difference is greater than zero, then the effective region of the preliminary segmentation mask consists of sampling points with a gray value greater than or equal to the binarization threshold. Sampling points with a gray value less than the binarization threshold (i.e., those with a gray value of 0 in the preliminary segmentation mask) are excluded. The region formed by the sampling points whose gray values are less than or equal to the binarization threshold is the invalid region of the initial segmentation mask; if the gray value difference is less than or equal to zero, then the region formed by the sampling points whose gray values are less than or equal to the binarization threshold is the valid region of the initial segmentation mask, and the region formed by the sampling points whose gray values are greater than the binarization threshold (i.e., those with a gray value of 0 in the initial segmentation mask) is the invalid region of the initial segmentation mask. The area formed by these regions is the invalid region of the initial segmentation mask.
[0044] Formula (9) accurately determines the width value corresponding to each sampling position by calculating the difference between the maximum and minimum column numbers of the effective area of the preliminary segmentation mask in the i-th row, based on the determination of the effective area.
[0045] Based on the determination of the effective area, the above embodiments can accurately determine the width value of the preliminary segmentation mask at the corresponding vertical coordinate along the first direction.
[0046] S140, based on each width value and the coordinates of the sampling points contained in the row corresponding to the corresponding width value of the preliminary segmentation mask, determine the coordinates of the center point of the effective area of the preliminary segmentation mask in the row corresponding to each width value.
[0047] For example, the center point of the initial segmentation mask in the i-th row is determined using the following formula (10). , This represents the x-axis coordinate of the center point of the initial segmentation mask in the i-th row. The y-coordinate of the center point of the initial segmentation mask in the i-th row is: , formula (10); Formula (10) accurately finds the geometric center of the initial segmentation mask in the i-th row using a weighted average method. Weights This ensures that only pixels considered as targets (insulators) contribute to the calculation of the center point, thus enabling the calculated center point to more accurately represent the true position of the insulator in that row. Figure 6 The distribution of the center points of the corresponding rows for each width value in the initial segmentation mask is shown in the figure. Figure 8 .
[0048] S150, by fitting the coordinates of each center point, obtains the axis equation characterizing the insulator's main shaft.
[0049] In a feasible design, this is achieved by fitting the coordinates of each center point to obtain the axis equation characterizing the insulator's main shaft: The coordinates of each center point are linearly fitted using the least squares method to obtain the preliminary axis equation; Determine the fitting residual of each center point relative to the initial axis equation; Center points where the fitted residuals are greater than the residual threshold are identified as outliers; Remove outliers from each center point to obtain the remaining center points; The coordinates of the remaining center points are linearly fitted using the least squares method to obtain the axis equation characterizing the insulator's main shaft.
[0050] For example, for all center points By performing linear fitting on the coordinates, a preliminary axis equation is obtained. The parameters a and b are solved using the least squares method, as shown in the following formula (11): , formula (11); in, , .
[0051] The center point is calculated using the following formula (12). Fitting residuals relative to the initial axis equation : , formula (12); residual standard deviation 2 times, that is The residual threshold is used to determine and remove outliers.
[0052] The coordinates of the remaining center points are linearly fitted using the least squares method to obtain the axis equation characterizing the insulator's main shaft. Figure 8 The straight line represented by the axis equation corresponding to the center point is shown in the figure. Figure 9 .
[0053] The above embodiment uses the least squares method to perform linear fitting on all center points to obtain an initial axis. Then, by calculating the fitting residuals of each point, it identifies abnormal center points with large deviations caused by local segmentation errors, background interference, or structural noise, and deletes them according to the residual threshold, thereby filtering out unreliable data. Finally, based on the remaining set of center points, least squares fitting is performed again to ensure that the final axis equation is free from the interference of abnormal points and can accurately reflect the true direction and position of the insulator's main axis.
[0054] S160 generates the insulator mask based on the width value at each vertical coordinate and the axis equation.
[0055] The output mask is used for subsequent temperature mapping. By extracting the temperature values of pixels within the mask area from the infrared image, statistical analysis or visualization can be performed to monitor the insulator temperature and provide early fault warnings.
[0056] In a feasible design, the insulator mask is generated based on the width value at each ordinate and the axis equation in the following way: Clustering is performed on the width value sequence to obtain at least two clusters. The width value sequence is a sequence of width values at each ordinate. Select the cluster with the most data points from at least two clusters as the target cluster; The average width value of each width value in the target cluster is determined as the standard width of the insulator's mask; The rectangular region to be constructed is constructed by extending half the standard width along both sides of the vertical center line, using the straight line represented by the axis equation as the vertical center line. The rectangular region is mapped onto the target image to obtain the mask region corresponding to the insulator on the target image. The mask for generating insulators is generated based on the mask region.
[0057] For example, the width value sequence is clustered in the following way: The K-means clustering algorithm was used to perform cluster analysis on the width value sequence.
[0058] For example, the K-means clustering algorithm is used for width value sequences. Clustering is performed to obtain at least two clusters. The clustering objective is to minimize the variance within the clusters, as shown in formula (13) below: , formula (13); in, The number of clusters can be set to 2; q represents the index of the cluster. This represents the q-th cluster, which is composed of the width values assigned to that cluster. This represents the cluster center of the q-th cluster, which is usually the average of the width values within the cluster.
[0059] Then, the largest cluster (i.e., the cluster containing the most width values) is selected as the target cluster, and the average value of each width value in the target cluster is taken as the standard width of the insulator, as shown in the following formula (14): , formula (14); in, Indicates the standard width. Indicates the largest cluster, This indicates the number of width values in the largest cluster.
[0060] Furthermore, taking the straight line represented by the axis equation as the centerline, extend along the length direction. A rectangular region is generated, which can be represented by the following formula (15): , formula (15); in, Represents a rectangular area. This represents the pixels within a rectangular area. The formula defines the final insulator mask. The construction rule is: "The perpendicular distance to the centerline represented by the axis equation is less than or equal to the standard width". The pixel of the condition "half of" The collection of these elements constitutes the final mask area.
[0061] Figure 9 The rectangular area generated by expanding the straight line See Figure 10 .
[0062] rectangular area Mapping onto the target image yields the mask region corresponding to the insulator on the target image (see...). Figure 11 The mask area is then filled with the true value 1, and other areas are filled with the false value 0, generating a binarized mask. This mask can accurately cover the main structure of the insulator and effectively suppress background interference and edge blurring.
[0063] The above embodiments effectively distinguish and eliminate interference from abnormal width values caused by segmentation errors or background adhesion by performing cluster analysis on the width value sequence, classifying the width values into different categories. By selecting the cluster with the most data points as the target cluster and calculating its average value, the standard width of the main body of the insulator (such as the typical disc area) can be robustly extracted, avoiding the deviation caused by outliers when directly averaging all width values. Based on the axis equation obtained by accurate fitting and the standard width, a rectangular region is constructed symmetrically on both sides with the axis as the center line, ensuring that the final mask has a regular, continuous and consistent geometric shape. Mapping this rectangular region back to the original image coordinate system, a high-quality segmentation mask that accurately matches the actual spatial position and scale of the insulator is finally generated, improving the mask's representation accuracy of the true shape of the insulator and its robustness to noise.
[0064] In one feasible design, the rectangular region is mapped onto the target image to obtain the mask region corresponding to the insulator on the target image, which is achieved by the following method: Determine the coordinates of the four vertices of the oriented bounding box; Determine the coordinates of the four vertices of the rectangular region; Construct an affine transformation matrix based on the coordinates of the four vertices of the oriented bounding box and the four vertices of the rectangular region; Based on the affine transformation matrix, coordinate mapping is performed on the rectangular region to obtain the mask corresponding to the insulator on the target image.
[0065] For example, the coordinates of the four vertices of the oriented bounding box are determined by the following formulas (16) and (17): , formula (16); , formula (17); Where d is the index of the vertex coordinates, and its value is 1, 2, 3 or 4. ( ) represents the normalized coordinates. The horizontal coordinate represents the normalized coordinates, and all values are +1 or -1. The vertical coordinates represent the normalized coordinates, and all values are +1 or -1. This represents the x-coordinate of vertex d. This represents the y-coordinate of the vertex d.
[0066] The above example constructs an affine transformation matrix based on the coordinates of the four vertices of the oriented bounding box and the coordinates of the four vertices of the rectangular region to achieve pixel-level accurate mapping, thereby accurately obtaining the mask corresponding to the insulator on the target image.
[0067] This application embodiment uses a directional bounding box to quickly locate the insulator region, effectively focusing on the target and initially eliminating irrelevant background interference, thus alleviating the problem of background complexity. The directional bounding box is vertically segmented based on the number of rows of sampling points. A preliminary segmentation mask for the insulator within the region contained in the vertically segmented directional bounding box is determined according to a dynamic binarization threshold. This preliminary segmentation mask can initially fit the herringbone structure of the insulator. Therefore, extracting a series of geometric features such as width values and center point coordinates along the first direction from the preliminary segmentation mask can adaptively handle aspect ratio and directional changes, further reducing background interference and improving the accuracy and shape adaptability of subsequent mask generation. Finally, by fitting the center point coordinates, an axis equation characterizing the direction of the insulator's main axis is obtained. Based on the axis equation and each width value, a high-quality mask for the insulator is accurately generated, providing an accurate and reliable regional basis for subsequent mask-based temperature extraction. This process utilizes the insulator's own morphological priors (elongated shape with relatively consistent width) for geometric modeling and reconstruction, solving the problems of traditional image segmentation methods that rely on global pixel-level segmentation consistency, such as poor adaptability to complex insulator shapes, susceptibility to background interference, and inability to effectively handle oversegmentation or undersegmentation caused by changes in aspect ratio and orientation. Furthermore, this method does not require large-scale labeled data, exhibits strong generalization ability, and overcomes the training difficulties caused by data scarcity for deep learning-based methods.
[0068] like Figure 12 As shown, this application also provides an apparatus for generating an insulator mask, comprising: The directional bounding box determination module is used to determine the directional bounding box of the region where the insulator is located based on the target image containing the insulator; The preliminary segmentation mask determination module is used to longitudinally segment the oriented bounding box based on sampling points, and determine the preliminary segmentation mask of the insulators in the region contained in the longitudinally segmented oriented bounding box according to a dynamic binarization threshold. The width value determination module is used to determine the width values of the preliminary segmentation mask at multiple vertical coordinates along the first direction, where the first direction is the direction parallel to the long side of the oriented bounding box; the width value is the effective area width of the preliminary segmentation mask. The center point determination module is used to determine the coordinates of the center point of the effective area of the preliminary segmentation mask in the row corresponding to each width value, based on the coordinate values of the sampling points contained in the row corresponding to each width value of the preliminary segmentation mask. The axis equation determination module is used to obtain the axis equation characterizing the main shaft of the insulator by fitting the coordinates of each center point; The mask generation module is used to generate a mask for the insulator based on each width value and the axis equation.
[0069] In a feasible design, the preliminary segmentation mask determination module achieves longitudinal segmentation of the oriented bounding box based on sampling points, and determines the preliminary segmentation mask of the insulators within the region contained in the longitudinally segmented oriented bounding box according to a dynamic binarization threshold: Based on the parameters of the oriented bounding box, sampling is performed along the first direction and the second direction within the region contained by the oriented bounding box to generate a set of sampling points, wherein the second direction is perpendicular to the first direction; The region formed by the set of sampling points is longitudinally divided into multiple sub-regions along the first direction; Based on the gray-level distribution characteristics of sampling points in each sub-region, the binarization threshold corresponding to each sub-region is dynamically determined. Binarize the corresponding sub-region according to the binarization threshold of each sub-region to generate a binarization mask for each sub-region; The binarized masks of each sub-region are stitched together to generate a preliminary segmentation mask covering the insulator.
[0070] In a feasible design, for each sub-region, the initial segmentation mask determination module dynamically determines the binarization threshold corresponding to each sub-region based on the gray-level distribution characteristics of the sampling points within each sub-region in the following way: The sub-region is divided into four secondary sub-regions along the second direction; The average gray value of the two middle secondary sub-regions is determined to be the first average gray value; The average gray value of the two secondary sub-regions located on both sides is determined to be the second average gray value; Determine the grayscale difference between the first average grayscale value and the second average grayscale value; If the grayscale difference is greater than zero, the binarization threshold is determined using the following formula: ; Where k is the index of the sub-region. This represents the first average gray value of sub-region k. For adjustment coefficients, This represents the grayscale difference corresponding to sub-region k. Indicates the binarization threshold; If the grayscale difference is less than or equal to zero, the binarization threshold is determined using the following formula: ; in, This represents the second average gray value of sub-region k. This is the adjustment coefficient.
[0071] In a feasible design, the width value determination module is implemented by determining the width values of the initial segmentation mask at multiple vertical coordinates along the first direction in the following way: If the grayscale difference is greater than zero, the region formed by the sampling points with grayscale values greater than or equal to the binarization threshold is determined as the effective region of the preliminary segmentation mask; If the grayscale difference is less than or equal to zero, the region formed by the sampling points whose grayscale values are less than or equal to the binarization threshold is determined as the effective region of the preliminary segmentation mask. The width of the effective area of the initial segmentation mask at each ordinate along the first direction is determined as the width value of the initial segmentation mask at the corresponding ordinate along the first direction.
[0072] In one feasible design, the mask generation module generates the insulator mask based on each width value and the axis equation in the following way: Clustering is performed on the width value sequence to obtain at least two clusters, where the width value sequence is a sequence composed of each width value; Select the cluster with the most data points from at least two clusters as the target cluster; The average width value of each width value in the target cluster is determined as the standard width of the insulator's mask; The rectangular region to be constructed is constructed by extending half the standard width along both sides of the vertical center line, using the straight line represented by the axis equation as the vertical center line. The rectangular region is mapped onto the target image to obtain the mask corresponding to the insulator on the target image.
[0073] In a feasible design, the mask generation module maps a rectangular region onto the target image to obtain the mask corresponding to the insulator on the target image in the following way: Determine the coordinates of the four vertices of the oriented bounding box; Determine the coordinates of the four vertices of the rectangular region; Construct an affine transformation matrix based on the coordinates of the four vertices of the oriented bounding box and the four vertices of the rectangular region; Based on the affine transformation matrix, coordinate mapping is performed on the rectangular region to obtain the mask corresponding to the insulator on the target image.
[0074] In a feasible design, the axis equation determination module is implemented by fitting the coordinates of each center point to obtain the axis equation characterizing the insulator's main shaft: The coordinates of each center point are linearly fitted using the least squares method to obtain the preliminary axis equation; Determine the fitting residual of each center point relative to the initial axis equation; Center points where the fitted residuals are greater than the residual threshold are identified as outliers; Remove outliers from each center point to obtain the remaining center points; The coordinates of the remaining center points are linearly fitted using the least squares method to obtain the axis equation characterizing the insulator's main shaft.
[0075] In one feasible design, before longitudinally dividing the region formed by the set of sampling points into multiple sub-regions along a first direction, the preliminary segmentation mask determination module is also used for: Determine whether each sampling point in the sampling point set is located within the boundary range of the target image; Remove sampling points from the set of sampling points that are not located within the boundary of the target image.
[0076] Other implementation methods and effects of the above-described device are described in the embodiments of the insulator mask generation method, and will not be repeated here.
[0077] This application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method embodiments described in S110-S160 above.
[0078] The basic principles of this application have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this application are merely examples and not limitations, and should not be considered as essential features of each embodiment of this application. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the application to the necessity of employing the aforementioned specific details for implementation.
[0079] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0080] The block diagrams of devices, apparatuses, devices, and systems involved in this application are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as “comprising,” “including,” “having,” etc., are open-ended terms meaning “including but not limited to,” and are used interchangeably with them. The terms “or” and “and” as used herein refer to the terms “and / or,” and are used interchangeably with them unless the context clearly indicates otherwise. The term “such as” as used herein refers to the phrase “such as but not limited to,” and is used interchangeably with it.
[0081] It should also be noted that in the apparatus, equipment, and methods of this application, the components or steps can be disassembled and / or recombined. These disassemblies and / or recombinations should be considered as equivalent solutions of this application.
[0082] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this application. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of this application. Therefore, this application is not intended to be limited to the aspects shown herein, but rather to be accorded the widest scope consistent with the principles and novel features disclosed herein.
[0083] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this application to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations thereof.
Claims
1. A method for generating an insulator mask, characterized in that, include: Determine the oriented bounding box of the region where the insulator is located based on the target image containing the insulator; Based on sampling points, the oriented bounding box is vertically segmented, and a preliminary segmentation mask for the insulators within the region contained in the vertically segmented oriented bounding box is determined according to a dynamic binarization threshold; wherein, the step of vertically segmenting the oriented bounding box based on sampling points and determining the preliminary segmentation mask for the insulators within the region contained in the vertically segmented oriented bounding box according to a dynamic binarization threshold includes: Based on the parameters of the oriented bounding box, sampling is performed along the first direction and the second direction within the area contained in the oriented bounding box to generate a set of sampling points, wherein the second direction is perpendicular to the first direction; The region formed by the set of sampling points is longitudinally divided into multiple sub-regions along the first direction; Based on the gray-level distribution characteristics of sampling points in each sub-region, the binarization threshold corresponding to each sub-region is dynamically determined. Binarize the corresponding sub-region according to the binarization threshold of each sub-region to generate a binarization mask for each sub-region; The binarized masks of each sub-region are stitched together to generate a preliminary segmentation mask covering the insulator; Determine the width values of the preliminary segmentation mask at multiple vertical coordinates along a first direction, where the first direction is parallel to the long side of the oriented bounding box; the width values are the effective area widths of the preliminary segmentation mask. Based on each width value and the coordinates of the sampling points contained in the row corresponding to the corresponding width value of the preliminary segmentation mask, determine the coordinates of the center point of the effective area of the preliminary segmentation mask in the row corresponding to each width value; By fitting the coordinates of each center point, the axis equation characterizing the insulator's main shaft is obtained; The mask for the insulator is generated based on each width value and the axis equation.
2. The method according to claim 1, characterized in that, For each sub-region, the step of dynamically determining the binarization threshold corresponding to each sub-region based on the grayscale distribution characteristics of the sampling points within each sub-region includes: The sub-region is divided into four secondary sub-regions along the second direction; The average gray value of the two middle secondary sub-regions is determined to be the first average gray value; The average gray value of the two secondary sub-regions located on both sides is determined to be the second average gray value; Determine the grayscale difference between the first average grayscale value and the second average grayscale value; If the grayscale difference is greater than zero, the binarization threshold is determined using the following formula: ; in, For the index of the sub-region, Subregion The first average gray value, For adjustment coefficients, Subregion The corresponding grayscale difference, Indicates the binarization threshold; If the grayscale difference is less than or equal to zero, the binarization threshold is determined using the following formula: ; in, Subregion The second average gray value, This is the adjustment coefficient.
3. The method according to claim 2, characterized in that, Determining the width values of the preliminary segmentation mask at multiple vertical coordinates along the first direction includes: If the grayscale difference is greater than zero, the region formed by the sampling points whose grayscale values are greater than or equal to the binarization threshold is determined as the effective region of the preliminary segmentation mask. If the grayscale difference is less than or equal to zero, the region formed by the sampling points whose grayscale values are less than or equal to the binarization threshold is determined as the effective region of the preliminary segmentation mask. The width of the effective area of the preliminary segmentation mask at each vertical coordinate along the first direction is determined as the width value of the preliminary segmentation mask at the corresponding vertical coordinate along the first direction.
4. The method according to any one of claims 1-3, characterized in that, The step of generating the mask for the insulator based on each width value and the axis equation includes: Clustering is performed on the width value sequence to obtain at least two clusters, wherein the width value sequence is a sequence composed of each width value; Select the cluster with the most data points from the at least two clusters as the target cluster; The average width value of each width value in the target cluster is determined as the standard width of the insulator's mask. Using the straight line represented by the axis equation as the vertical center line of the rectangular region to be constructed, extend half of the standard width on each side of the vertical center line to construct the rectangular region; The rectangular region is mapped onto the target image to obtain the mask corresponding to the insulator on the target image.
5. The method according to claim 4, characterized in that, The step of mapping the rectangular region onto the target image to obtain the mask corresponding to the insulator on the target image includes: Determine the coordinates of the four vertices of the oriented bounding box; Determine the coordinates of the four vertices of the rectangular region; Based on the coordinates of the four vertices of the oriented bounding box and the coordinates of the four vertices of the rectangular region, construct an affine transformation matrix; Based on the affine transformation matrix, coordinate mapping is performed on the rectangular region to obtain the mask corresponding to the insulator on the target image.
6. The method according to any one of claims 1-3, characterized in that, The process of fitting the coordinates of each center point to obtain the axis equation characterizing the insulator's main shaft includes: The coordinates of each center point are linearly fitted using the least squares method to obtain the preliminary axis equation; Determine the fitting residual for each center point relative to the preliminary axis equation; Center points where the fitted residuals are greater than the residual threshold are identified as outliers; Remove outliers from each center point to obtain the remaining center points; The coordinates of the remaining center points are linearly fitted using the least squares method to obtain the axis equation characterizing the main shaft of the insulator.
7. The method according to claim 1, characterized in that, Before dividing the region formed by the set of sampling points longitudinally into multiple sub-regions along the first direction, the method further includes: Determine whether each sampling point in the sampling point set is located within the boundary range of the target image; Remove sampling points from the set of sampling points that are not located within the boundary range of the target image.
8. An apparatus for generating an insulator mask, characterized in that, include: An orientation bounding box determination module is used to determine the orientation bounding box of the region where the insulator is located based on a target image containing the insulator; A preliminary segmentation mask determination module is used to longitudinally segment the oriented bounding box based on sampling points, and determine a preliminary segmentation mask for the insulators within the region contained in the longitudinally segmented oriented bounding box according to a dynamic binarization threshold; wherein, the step of longitudinally segmenting the oriented bounding box based on sampling points and determining the preliminary segmentation mask for the insulators within the region contained in the longitudinally segmented oriented bounding box according to a dynamic binarization threshold includes: Based on the parameters of the oriented bounding box, sampling is performed along the first direction and the second direction within the area contained in the oriented bounding box to generate a set of sampling points, wherein the second direction is perpendicular to the first direction; The region formed by the set of sampling points is longitudinally divided into multiple sub-regions along the first direction; Based on the gray-level distribution characteristics of sampling points in each sub-region, the binarization threshold corresponding to each sub-region is dynamically determined. Binarize the corresponding sub-region according to the binarization threshold of each sub-region to generate a binarization mask for each sub-region; The binarized masks of each sub-region are stitched together to generate a preliminary segmentation mask covering the insulator; The width value determination module is used to determine the width values of the preliminary segmentation mask at multiple vertical coordinates along a first direction, wherein the first direction is parallel to the long side of the oriented bounding box; the width value is the effective area width of the preliminary segmentation mask. The center point determination module is used to determine the coordinates of the center point of the effective area of the preliminary segmentation mask in the row corresponding to each width value based on each width value and the coordinate values of the sampling points contained in the row corresponding to the corresponding width value of the preliminary segmentation mask. The axis equation determination module is used to obtain the axis equation characterizing the main shaft of the insulator by fitting the coordinates of each center point; A mask generation module is used to generate a mask for the insulator based on each width value and the axis equation.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method for generating an insulator mask as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Insulator defect detection method and system based on rotating target detection
CN121437414A
Multi-background-view-angle fused insulator defect area positioning method and system
CN121527004A