A high-precision identification method and system for surface defects of a cable assembly
By combining the Otsu thresholding method and the gradient direction thresholding method, the degree of unevenness on the cable surface is quantified, which solves the problem of accuracy in identifying uneven defects in cable images and achieves high-precision cable surface defect identification.
Patent Information
- Application Number
- CN202511212398.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-28
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2045-08-28
AI Technical Summary
Existing image processing technologies struggle to accurately determine whether cable surface images contain uneven or concave defect areas, especially under complex backgrounds and lighting conditions. This makes it difficult to separate the cable area from the background area, impacting power grid safety.
The cable surface was segmented into bright and dark areas using the Otsu threshold method. By combining the natural light direction and gradient direction thresholds, the degree of unevenness in the local area was quantified. The K-means clustering algorithm was used to extract the cable surface area, and unevenness defects were judged by combining the alternating bright and dark areas.
It improves the accuracy of cable surface defect identification, accurately judges uneven defect areas, reduces the impact of noise, quantifies the degree of unevenness, and improves the accuracy of defect location in cable images.
Smart Images

Figure CN120747067B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing, and specifically relates to a high-precision identification method and system for surface defects of cable assemblies. Background Technology
[0002] With the development of science and technology, drones are increasingly being used in practice because they can replace the high-risk and low-efficiency operation mode of traditional manual inspections. They can quickly capture the surface condition of cables from multiple angles at high altitudes and are suitable for screening hidden dangers in complex terrains or harsh environments.
[0003] Mechanical wear, aging, or external damage can cause surface defects in in-service cables, leading to unevenness and irregularities. These defects can cause local electric field distortion, insulation degradation, and even partial discharge or short-circuit faults, threatening the safe and stable operation of the power grid. However, when using image processing technology to determine whether a cable surface image contains uneven defects, the complex outdoor background and the influence of lighting and the cable's external surface structure result in the cable area in the image consisting of bright and dark areas with significant brightness differences. This makes it difficult for current image processing technology to accurately determine whether a cable image contains uneven defects. Summary of the Invention
[0004] To address the problem that current image processing techniques struggle to accurately determine whether cable surface images contain concave or convex defect areas, this invention proposes a high-precision identification method and system for cable assembly surface defects.
[0005] To achieve the above objectives, the present invention provides the following technical solution: acquiring a cable surface image; dividing the cable surface image into several local windows of the same size, and obtaining local windows located on the cable surface based on the distribution of pixel grayscale values within each local window, thereby obtaining the cable surface region; dividing the cable surface region into bright and dark regions using the Otsu thresholding method; obtaining the direction of natural light illumination based on the distribution of pixels on the edges where the bright and dark regions intersect; dividing the cable surface region into several local regions of the same size; setting an initial gradient direction threshold, and obtaining the gradient direction threshold for each local region based on the distribution of pixel grayscale values within each local region; and further dividing the cable surface region into several local regions of the same size. The gradient difference between different pixels and the gradient direction threshold are used to obtain the approximate gradient pixel for each pixel in each local region. Based on the direction of natural light and the gradient direction of each pixel in each local region and the approximate gradient pixel, the degree of unevenness in each local region is obtained. Based on the distribution of pixels in the bright and dark areas in each local region, the local region is divided into bright local regions, dark local regions, and alternating bright and dark local regions. Based on the distribution of unevenness in the bright local regions, the dark local regions, and the alternating bright and dark local regions, it is confirmed whether there are uneven defect areas in the cable surface image.
[0006] Furthermore, the specific steps for obtaining the cable surface area are as follows: The specific calculation formula for obtaining the cable characteristic representation degree of each local window is as follows: In the formula, Indicates the first The cable characteristic representation of a local window. Indicates the first The number of pixels contained within a local window Indicates the first Within the local window, the first The grayscale value of each pixel Indicates the first The local window The grayscale value of each pixel Represents the absolute value function. Let be an exponential function with the natural constant as its base; let the number of clusters be 2. Based on the cable feature representation degree of each local window, use the K-means clustering algorithm to cluster all local windows into two clusters; the cluster with the largest mean of cable feature representation degree of all local windows in the two clusters is denoted as the cluster where the cable region is located; the local windows in the cluster where the cable region is located are denoted as local windows located on the cable surface; the pixels in the local windows located on the cable surface are denoted as cable surface pixels; based on the cable surface pixels, the cable surface region is obtained.
[0007] Furthermore, the specific steps for dividing the cable surface area into a bright area and a dark area are as follows: using the Otsu threshold method, the cable surface area is divided into two segmented areas based on the gray value of each pixel in the cable surface area; the segmented area with the largest average gray value of the pixels in the two segmented areas is recorded as the bright area, and the segmented area with the smallest average gray value of the pixels in the two segmented areas is recorded as the dark area.
[0008] Further, the specific steps for obtaining the direction of natural light illumination are as follows: Obtain the chain code of the edge where the bright and dark areas intersect; count the number of times each number appears in the chain code of the edge where the bright and dark areas intersect, and take the direction corresponding to the number that appears most frequently in the chain code of the edge where the bright and dark areas intersect as the edge extension direction; randomly select from the bright and dark areas... We take one pixel as a reference point; starting from the reference point, we extend a straight line perpendicular to the edge extension direction, resulting in several straight lines, denoted as reference lines; we construct a coordinate system with the lower left corner of the cable surface image as the origin, the horizontal axis to the right as the x-axis, and the vertical axis upward as the y-axis; the average tilt angle of all reference lines is denoted as the direction of natural light illumination; where... The preset number of pixels.
[0009] Furthermore, the specific calculation steps for obtaining the gradient direction threshold of each local region are as follows: Based on the grayscale distribution of pixels within each local region, the smoothness of each local region is obtained; the specific calculation formula for obtaining the smoothness of each local region is as follows: In the formula, Indicates the first The flatness of a local area Indicates the first The number of pixels contained in a local region Indicates the first Within the local area, the first The number of pixels contained in the 8-neighborhood of a pixel. Indicates the first Within the local area, the first Within the 8-neighborhood of the pixel, the first The grayscale value of each pixel Indicates the first Within the local area, the first Within the 8-neighborhood of the pixel, the first The grayscale value of each pixel This represents the absolute value function; based on the initial gradient direction threshold and the flatness of each local region, the gradient direction threshold for each local region is obtained; the specific calculation formula for obtaining the gradient direction threshold for each local region is as follows: In the formula, Indicates the first Gradient direction threshold for a local region This represents the initial gradient direction threshold. Indicates the first The flatness of a local area This represents the floor function. It is an exponential function with the natural constant as its base.
[0010] Furthermore, the specific calculation steps for obtaining the gradient approximate pixel point for each pixel point within each local region are as follows: [The text abruptly ends here, likely due to an incomplete sentence or a formatting error.] The gradient direction within the defect region is related to the first... Within the defect area, the first The absolute value of the difference in gradient directions of the nth pixel is less than that of the 1st pixel. Gradient direction threshold for a local region The pixel is denoted as the first pixel. Within the defect area, the first The gradient of each pixel approximates the pixel.
[0011] Furthermore, the specific calculation formula for obtaining the degree of unevenness in each local region is as follows: In the formula, Indicates the first The degree of unevenness or concavity in a local area Indicates the first The number of pixels contained in a local region Indicates the first Within the local area, the first The mean of the Euclidean distances between a pixel and all its gradient approximation pixels. Indicates the first Within the local area, the first Gradient direction of each pixel Indicates the direction of natural light. Indicates the first Within the local area, the first The first pixel The gradient approximates the gradient direction of each pixel. This represents the absolute value function.
[0012] Furthermore, the specific calculation formula for dividing the local area into bright local area, dark local area, and alternating bright and dark local area is as follows: If all pixels in a local area are pixels in the dark area, then the local area is recorded as a dark local area; if all pixels in a local area are pixels in the bright area, then the local area is recorded as a bright local area; if a local area contains pixels in both the bright and dark areas, then the local area is recorded as an alternating bright and dark local area.
[0013] Furthermore, the specific steps for confirming whether there are uneven defect areas in the cable surface image are as follows: Obtain the first... The specific formula for calculating the probability that a localized area of a bright surface is a region with uneven defects is as follows: Indicating, Indicates the first The possibility that a localized area on the glossy surface is an area with uneven defects. This represents the average level of unevenness or roughness in all localized areas of the glossy surface. Indicates the first The average value of the unevenness of a local area on a glossy surface. Represents the absolute value function; obtains the first... The specific formula for calculating the probability that a local area of the dark surface is a region with uneven defects is as follows: Indicating, Indicates the first The possibility that a localized area on the dark side is a region of unevenness or defect. This represents the average degree of relief or convexity in all localized dark areas. Indicates the first The average value of the degree of unevenness in a local area of the dark side. Represents the absolute value function; obtains the first... The specific formula for calculating the probability that a localized area with alternating light and dark areas is a region with unevenness or convexity is as follows: Indicating, Indicates the first The possibility that a localized area with alternating bright and dark areas is a region with uneven or concave defects. This represents the average degree of relief or unevenness in all alternating bright and dark local areas. Indicates the first The average value of the unevenness of a local area with alternating light and dark areas. Represents the absolute value function; if the first... The probability that a bright local area is a region with uneven defects is greater than the probability threshold. Then the first The bright surface has a localized area with uneven defects; if the first... The probability that a localized area on the dark surface is a region with uneven defects is greater than the probability threshold. Then the first The local area of the dark surface is a region of uneven defects; if the first... The probability that a localized area with alternating bright and dark areas is a region with uneven defects is greater than the probability threshold. Then the first An alternating bright and dark local area is a region of unevenness or convexity; if the cable surface image contains regions of unevenness or convexity, then there is an unevenness or convexity in the cable surface image.
[0014] This invention also provides a high-precision identification system for surface defects of cable assemblies, comprising: a data acquisition system for acquiring cable surface images; a data processing system for dividing the cable surface image into several local windows of the same size, obtaining local windows located on the cable surface based on the distribution of pixel grayscale values within each local window, thereby obtaining the cable surface region; dividing the cable surface region into bright and dark regions using the Otsu thresholding method; obtaining the direction of natural light illumination based on the distribution of pixels on the edge where the bright and dark regions intersect; dividing the cable surface region into several local regions of the same size using rectangular windows; setting an initial gradient direction threshold, and obtaining the gradient direction threshold for each local region based on the distribution of pixel grayscale values within each local region. Value; Based on the relationship between the difference in gradient direction of different pixels in each local region and the gradient direction threshold, the approximate gradient pixel of each pixel in each local region is obtained; Based on the direction of natural light illumination and the gradient direction of each pixel in each local region and the approximate gradient pixel, the degree of unevenness of each local region is obtained; Defect judgment system: Based on the distribution of pixels in the bright and dark areas in each local region, the local region is divided into bright local region, dark local region, and alternating bright and dark local region; Based on the distribution of unevenness of the bright local region, the distribution of unevenness of the dark local region, and the distribution of unevenness of the alternating bright and dark local region, it is confirmed whether there are uneven defect areas in the cable surface image.
[0015] The high-precision identification method for surface defects of cable assemblies provided by this invention has the following beneficial effects: Based on the characteristic that the surface of the cable outer sheath is a solid color area, resulting in relatively small differences in grayscale values between different cable pixels in the cable surface image, this invention extracts the cable surface region from the cable surface image based on the grayscale difference between each pixel and its surrounding pixels, solving the problem that current cable surface images simultaneously contain cable areas and background areas; Based on the characteristic that although there may be some noise interference when photographing cables, the number of pixels affected by noise in the image is small, making the noise's impact on the grayscale distribution of pixels in the image extremely small, this invention divides the cable surface region into bright areas and background areas using the Otsu thresholding method, solving the problem that segmentation results may be affected by noise and become inaccurate when segmenting the cable surface region using other methods; Based on the characteristic that the cable outer sheath surface develops scratch-like surface textures during use, and that each pixel in the surface texture area has a certain difference in grayscale value compared to its surrounding pixels, this invention quantifies the impact of external forces on each local area based on the grayscale distribution of pixels in each local area; based on the characteristic that each local area... This method calculates the gradient direction threshold for each local region affected by external forces. This addresses the issue that considering the influence of external forces on each local region when obtaining the gradient direction threshold makes the gradient direction threshold of different local regions closer to the actual situation, resulting in more accurate approximate pixels for the gradient of each pixel within each local region. Based on the characteristic that when natural light shines on the cable surface, the unevenness of the cable surface has a sudden change in height compared to the normal position, resulting in shadowed areas around the unevenness, and the gradient direction of the pixels at the edge where the shadowed area intersects with the unevenness defect is relatively similar and close to the direction of natural light, the method obtains the degree of unevenness of each local region by considering the similarity of the gradient direction of each pixel within each local region to its approximate pixel, as well as the difference between the gradient direction of different pixels and the direction of natural light. This method quantifies the degree of unevenness of each local region, improves the ability to determine whether there are unevenness defect areas in the cable surface image based on the degree of unevenness of each local region, and solves the problem that current image localization methods cannot accurately determine whether there are unevenness defects in cable surface images. Attached Figure Description
[0016] To more clearly illustrate the embodiments and design schemes of the present invention, the accompanying drawings required for this embodiment will be briefly described below. The drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1This is a flowchart of a high-precision identification method for surface defects of cable assemblies according to an embodiment of the present invention. Detailed Implementation
[0018] To enable those skilled in the art to better understand and implement the technical solutions of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. The following embodiments are only used to more clearly illustrate the technical solutions of the present invention and should not be construed as limiting the scope of protection of the present invention.
[0019] Example 1
[0020] This invention provides a high-precision method for identifying surface defects in cable assemblies, specifically as follows: Figure 1 As shown, it includes: Step S001: Obtaining an image of the cable surface.
[0021] Specifically, the flight path of the drone is set via cable routing. Data collection intervals are... High-resolution optical camera with a resolution of seconds and multi-axis gimbal for A drone with its obstacle avoidance system activated and angled at a certain degree flies along a pre-defined flight path to obtain an initial image of the cable surface, and acquires the corresponding acquisition time and location information. The preset acquisition interval in this embodiment... Preset angles of the multi-axis gimbal This example is used to illustrate the concept; other values can be set in other implementations.
[0022] Furthermore, the initial image of the cable surface is converted to grayscale, and the image after grayscale conversion is denoted as the cable surface image.
[0023] At this point, an image of the cable surface is obtained.
[0024] Step S002: Divide the cable surface image into several local windows of the same size. Based on the distribution of pixel gray values in each local window, obtain the local window located on the cable surface, and thus obtain the cable surface region.
[0025] It should be noted that since the cable surface image contains not only the cable surface area but also the background area, the cable surface area is obtained from the cable surface image.
[0026] It should be further noted that because the outer sheath of the cable is a solid color area, the grayscale value of each pixel on the cable surface is relatively similar to that of its surrounding pixels. However, the background area is more complex, resulting in a relatively large difference in grayscale value between each pixel and its surrounding pixels. Therefore, the cable surface image is divided into several windows of equal size. The cable feature representation degree of each window is obtained based on the distribution of pixel grayscale values within each window.
[0027] It should be further noted that, since each cable surface image contains only the background region and the cable surface region, and the distribution of pixel grayscale values in the background region differs significantly from that in the cable surface region, the number of clusters is set to 2. All windows in the cable surface image are clustered into two classes based on the cable feature representation of each window. The cable region within the cable surface image is obtained based on the average cable feature representation of all windows in each cluster.
[0028] Specifically, the cable surface image is divided into several... The image is divided into several local windows. Different local windows do not contain the same pixels, and all pixels in the cable surface image participate in the process of dividing the cable surface image into several local windows. The preset width of the local window in this embodiment is... This example is used to illustrate the concept; other values can be set in other implementations.
[0029] Furthermore, the specific calculation formula for obtaining the cable characteristic representation degree of each local window is as follows: In the formula, Indicates the first The cable characteristic representation of a local window. Indicates the first The number of pixels contained within a local window Indicates the first Within the local window, the first The grayscale value of each pixel Indicates the first The local window The grayscale value of each pixel Represents the absolute value function. This is an exponential function with the natural constant as its base, and in this embodiment it is used to perform an inverse proportional operation.
[0030] It should be noted that, The image shows the first [unclear] within the cable surface. The average gray level of all pixels within a local window; The larger the value, the more significant the [value]. Within the local window, the first The grayscale value of the nth pixel differs significantly from that of its surrounding pixels, i.e., the nth pixel... The likelihood of a local window containing a cable area is relatively low. The value is small; The smaller the value, the more... Within the local window, the first The grayscale distribution of the nth pixel and its surrounding pixels conforms to the characteristic that the grayscale differences between pixels within the cable area are relatively small, i.e., the nth pixel... There is a high probability that a local window contains a cable area. The value is relatively large.
[0031] Furthermore, setting the number of clusters to 2, the K-means clustering algorithm is used to cluster all local windows based on the cable feature representation of each local window, resulting in all local windows being clustered into two clusters. The use of the K-means clustering algorithm for data clustering is a well-known existing technique and will not be elaborated upon in this embodiment.
[0032] Furthermore, the cluster with the highest mean cable characteristic representation of all local windows within the two clusters is denoted as the cluster containing the cable region. Local windows within the cluster containing the cable region are denoted as local windows located on the cable surface.
[0033] Furthermore, the pixels located within a local window on the cable surface are denoted as cable surface pixels. Based on the cable surface pixels, the cable surface region is obtained.
[0034] At this point, the surface area of the cable is obtained.
[0035] Step S003: Using the Otsu thresholding method, the cable surface area is divided into a bright area and a dark area; based on the distribution of pixels on the edge where the bright and dark areas intersect, the direction of natural light is obtained; the cable surface area is divided into several local areas of the same size; an initial gradient direction threshold is set, and combined with the distribution of pixel grayscale values in each local area, the gradient direction threshold of each local area is obtained; based on the relationship between the difference in gradient direction of different pixels in each local area and the gradient direction threshold, the gradient approximate pixel of each pixel in each local area is obtained; based on the direction of natural light, the gradient direction of each pixel in each local area and the gradient approximate pixel, the degree of concavity and convexity of each local area is obtained.
[0036] It should be noted that because a cable can be approximated as a cylinder, the illumination of different pixels on the cable varies when natural light shines on it. That is, when photographing the cable surface using a drone, the surface area can be divided into a brightly lit area and a darker area. Therefore, the cable surface area is divided into two regions.
[0037] It should be further noted that when acquiring cable images using drones, the acquisition process is affected by factors such as outdoor scene interference or sensor noise, resulting in some noise in the cable images. Compared to the number of pixels unaffected by noise, the number of pixels affected by noise is relatively small, meaning the noise does not affect the peak distribution of the gray-level histogram of the cable image. Therefore, the Otsu thresholding method, which relies on the peak distribution of the gray-level histogram to segment the image, divides the cable surface area into two regions. Based on the average gray-level of all pixels in each region, the bright and dark areas are obtained.
[0038] It should be further explained that because the outermost layer of the cable is the sheath, and the material of the sheath is relatively rough compared to a mirror, the cable surface reflects natural light diffusely. This results in each pixel in the normal bright or dark areas of the cable surface having a similar grayscale value to its surrounding pixels, and the transition from bright to dark areas is relatively smooth. Consequently, the gradient direction of each pixel in the normal area is quite chaotic compared to its surrounding pixels.
[0039] It should be further explained that when a localized area has an unevenness defect, the surface structure of that area changes, meaning there is a relatively large height difference between the depression or protrusion and the surrounding normal area. This causes a shadow area to form near the unevenness defect when natural light shines on the cable surface. Since the shadow area is formed due to the effect of the unevenness defect on the cable surface when natural light shines on it, the gradient direction of the pixels at the edge where the unevenness defect area and the shadow area intersect is quite similar to the direction of natural light. Therefore, the cable surface area is divided into multiple localized areas, and the direction of natural light is obtained. Based on the distribution of the gradient direction of the pixels in each localized area, the degree of unevenness in each localized area is obtained.
[0040] It should be further explained that the bright and dark areas on the cable surface are formed under the influence of natural light. That is, the boundary between the bright and dark areas on the cable surface is affected by natural light. Therefore, a coordinate system is constructed with the lower left corner of the cable surface image as the origin, the horizontal axis pointing to the right, and the vertical axis pointing upwards. Multiple pixels are randomly selected within the bright and dark areas, and perpendicular lines are drawn from each pixel to the edges of the bright and dark areas. The average angle between all these perpendicular lines and the horizontal axis is taken as the direction of natural light.
[0041] It should be further noted that when drawing perpendicular lines to the edges of the bright and dark areas, from a microscopic perspective, the edges are not straight lines, but rather exhibit slight bends in some locations. Since chain code values describe the positional relationship between a pixel and its connected pixels, the edge chain codes of the bright and dark areas are obtained. Based on the chain code value that appears most frequently in the edge chain code, the extension direction of the edges of the bright and dark areas is obtained, and then the direction of natural light illumination is acquired.
[0042] It should be further explained that, since the gradient directions of pixels at the edges where the defective and shadowed areas intersect are quite similar, a gradient direction threshold is set to obtain pixels within each local region whose gradient directions are approximately similar to those of each individual pixel. Because the outer sheath surface of the cable experiences normal losses during actual use, and these losses vary at different locations, different gradient direction thresholds are set for different local regions based on their respective losses.
[0043] It should be further noted that during actual use, the outer sheath of the cable experiences normal losses, resulting in fine, scratch-like surface textures. These textures affect the smoothness of the cable surface. Specifically, when scratch-like surface textures appear, the grayscale values of pixels within that area are relatively disordered. Therefore, the smoothness of each local area is determined based on the distribution of pixel grayscale values. Then, the gradient direction threshold for each local area is determined based on its smoothness. Finally, the degree of unevenness in each area is calculated by combining the distribution of pixel gradient values within each local area.
[0044] Specifically, using the Otsu thresholding method, the cable surface area is divided into two segments based on the grayscale value of each pixel. The segment with the highest average grayscale value among the pixels in the two segments is designated as the bright area, and the segment with the lowest average grayscale value among the pixels in the two segments is designated as the dark area. The use of the Otsu thresholding method for image segmentation is a well-known existing technique and will not be elaborated upon in this embodiment.
[0045] Furthermore, the chain code of the edge where the bright and dark areas intersect is obtained. The frequency of each number in the chain code of the edge where the bright and dark areas intersect is counted, and the direction corresponding to the number that appears most frequently in the chain code of the edge where the bright and dark areas intersect is taken as the edge extension direction. Obtaining the chain code of an edge is a known technique and will not be described in detail in this embodiment.
[0046] Furthermore, select either the light or dark area. Each pixel is used as a reference point. Starting from the reference point, a straight line extending perpendicular to the edge extension direction is drawn from the reference point, resulting in several straight lines, denoted as reference lines. A coordinate system is constructed with the lower left corner of the cable surface image as the origin, the horizontal axis to the right as the x-axis, and the vertical axis upwards as the y-axis. The average tilt angle of all reference lines is recorded as the direction of natural light illumination. The preset number of pixels in this embodiment... This example is used for illustration; other values can be set in other embodiments. Obtaining the inclination angle of each straight line is a well-known technique and will not be described in detail in this embodiment.
[0047] Furthermore, the cable surface area is divided into several equal-sized... The rectangular region is defined as follows: When segmenting the cable surface area, if the number of pixels in a portion of the cable surface area is insufficient to fill the rectangular region, it is not padded. Furthermore, different rectangular regions do not contain the same number of pixels. The width of the rectangular region is preset in this embodiment. This example is used to illustrate the concept; other values can be set in other implementations.
[0048] Furthermore, the specific calculation formula for obtaining the flatness of each local area is as follows: In the formula, Indicates the first The flatness of a local area Indicates the first The number of pixels contained in a local region Indicates the first Within the local area, the first The number of pixels contained in the 8-neighborhood of a pixel. Indicates the first Within the local area, the first Within the 8-neighborhood of the pixel, the first The grayscale value of each pixel Indicates the first Within the local area, the first Within the 8-neighborhood of the pixel, the first The grayscale value of each pixel This represents the absolute value function.
[0049] It should be noted that, The smaller the value, the more... Within the local area, the first The closer the gray value of a pixel is to its surrounding pixels, the more similar the gray value of the i-th pixel is to the gray value of the i-th pixel. The less a local area is affected by external factors such as cracks, the better. The larger the value, the better.
[0050] Furthermore, the specific calculation formula for obtaining the gradient direction threshold for each local region is as follows: In the formula, Indicates the first Gradient direction threshold for a local region This represents the preset initial gradient direction threshold. Indicates the first The flatness of a local area This represents the floor function. This is an exponential function with the natural constant as its base, and this embodiment is used to prevent the denominator from being less than 0. Specifically, this embodiment presets an initial gradient direction threshold. The degree is used as an example for description; other values can be set in other implementations.
[0051] It should be noted that, The smaller the value, the more... The greater the impact of external damage such as scratches on the cable in a localized area, the more necessary it is to increase the gradient direction threshold for that localized area. and The larger the value, the better.
[0052] Furthermore, the gradient direction of each pixel in the cable surface region is obtained. The gradient direction within the defect region is related to the first... Within the defect area, the first The absolute value of the difference in gradient directions of the nth pixel is less than that of the 1st pixel. Gradient direction threshold for a local region The pixel is denoted as the first pixel. Within the defect area, the first The gradient of each pixel approximates the pixel.
[0053] Furthermore, obtain the first The specific formula for calculating the degree of unevenness in a local area is as follows: In the formula, Indicates the first The degree of unevenness or concavity in a local area Indicates the first The number of pixels contained in a local region Indicates the first Within the local area, the first The mean of the Euclidean distances between a pixel and all its gradient approximation pixels. Indicates the first Within the local area, the first Gradient direction of each pixel Indicates the direction of natural light. Indicates the first Within the local area, the first The first pixel The gradient approximates the gradient direction of each pixel. This represents the absolute value function.
[0054] It should be noted that, It is used to reflect the first Within the local area, the first Does the gradient direction of a pixel conform to the characteristic that the gradient direction of pixels at the intersection of the concave / convex defect region and the shadow region is similar to the direction of natural light illumination? The smaller the value, the better. The greater the likelihood that a local area is a region with uneven or concave defects; It is used to reflect the first Does a local region conform to the characteristic that the gradient directions of pixels within a defect region are relatively similar? The larger the value, the better the characteristic of the first local region. The local region should conform more closely to the gradient direction of pixels in the concave / convex defect region and the shadow region; adding 1 to the denominator is to prevent the denominator from being 0.
[0055] This gives us the degree of relief or convexity in each local area.
[0056] Step S004: Based on the distribution of pixels in the bright and dark areas of each local region, the local region is divided into bright local regions, dark local regions, and alternating bright and dark local regions; based on the distribution of the unevenness of the bright local regions, the unevenness of the dark local regions, and the unevenness of the alternating bright and dark local regions, it is confirmed whether there are uneven defect areas in the cable surface image.
[0057] It should be noted that when inspecting cables using drones, the cables are still operating normally, resulting in relatively fewer depressions and protrusions compared to normal areas. Therefore, defect areas are identified based on the degree of unevenness in each local area and the difference in the degree of unevenness across all local areas.
[0058] It should be noted that when photographing cables, the cable surface area in the image can be divided into bright and dark areas, and the difference in the influence of lighting on bright and dark areas is significant, resulting in significant differences in gradient distribution. Therefore, when determining whether each local area is a defective area, bright and dark areas are judged separately. Since some local areas contain pixels from both bright and dark areas, it is inappropriate to classify these local areas as local areas within either bright or dark areas. Therefore, local areas are divided into local areas within bright areas, local areas within dark areas, and local areas at the transition between bright and dark areas. Defective areas are then determined accordingly.
[0059] Specifically, if all pixels in a local region are pixels in the dark area, then the local region is called a dark local region; if all pixels in a local region are pixels in the light area, then the local region is called a light local region; if a local region contains pixels in both the light and dark areas, then the local region is called a light-dark alternating local region.
[0060] Furthermore, obtain the first The specific formula for calculating the probability that a localized area of a bright surface is a region with uneven defects is as follows: Indicating, Indicates the first The possibility that a localized area on the glossy surface is an area with uneven defects. This represents the average level of unevenness or roughness in all localized areas of the glossy surface. Indicates the first The average value of the unevenness of a local area on a glossy surface. This represents the absolute value function.
[0061] It should be noted that, Indicates the first The larger the value of the difference between a local bright area and the overall difference between all local bright areas, the better the result. The greater the likelihood that a bright surface area is a region with unevenness or defects.
[0062] Furthermore, if the first The probability that a bright local area is a region with uneven defects is greater than the probability threshold. Then the first The bright surface has a localized area with uneven defects; if the first... The probability that a bright local area is a region with unevenness or defects is less than or equal to the probability threshold. Then the first The bright areas are considered normal areas. In this embodiment, a preset probability threshold is used. In other implementations, it can be set to other values.
[0063] Furthermore, obtain the first The specific formula for calculating the probability that a local area of the dark surface is a region with uneven defects is as follows: Indicating, Indicates the first The possibility that a localized area on the dark side is a region of unevenness or defect. This represents the average degree of relief or convexity in all localized dark areas. Indicates the first The average value of the degree of unevenness in a local area of the dark side. This represents the absolute value function.
[0064] Furthermore, if the first The probability that a localized area on the dark surface is a region with uneven defects is greater than the probability threshold. Then the first The dark area is a region with unevenness and defects.
[0065] Furthermore, obtain the first The specific formula for calculating the probability that a localized area with alternating light and dark areas is a region with unevenness or convexity is as follows: Indicating, Indicates the first The possibility that a localized area with alternating bright and dark areas is a region with uneven or concave defects. This represents the average degree of relief or unevenness in all alternating bright and dark local areas. Indicates the first The average value of the unevenness of a local area with alternating light and dark areas. This represents the absolute value function.
[0066] Furthermore, if the first The probability that a localized area with alternating bright and dark areas is a region with uneven defects is greater than the probability threshold. Then the first The alternating bright and dark local areas are areas of uneven defects.
[0067] Furthermore, if the cable surface image contains uneven defect areas, then the corresponding cable location in the cable surface image has uneven defects, and professional personnel should be arranged to carry out inspection and repair.
[0068] This concludes the embodiment.
[0069] This embodiment also provides a high-precision identification method and system for surface defects of cable assemblies, including: a data acquisition system for acquiring images of the cable surface.
[0070] Data processing system: Divide the cable surface image into several local windows of the same size. Based on the distribution of pixel gray values in each local window, obtain the local window located on the cable surface, and thus obtain the cable surface area.
[0071] Using the Otsu thresholding method, the cable surface area is divided into bright and dark areas. The direction of natural light is determined by the distribution of pixels at the intersection of the bright and dark areas. A rectangular window is used to divide the cable surface area into several equal-sized local regions. An initial gradient direction threshold is set, and the gradient direction threshold for each local region is obtained based on the distribution of pixel grayscale values within that region. The gradient approximation pixel for each pixel within each local region is obtained based on the relationship between the difference in gradient directions of different pixels within that region and the gradient direction threshold. Finally, the degree of unevenness / convexity in each local region is determined based on the direction of natural light, the gradient direction of each pixel within each local region, and the gradient approximation pixel.
[0072] Defect Judgment System: Based on the distribution of pixels in the bright and dark areas of each local region, the local region is divided into bright local regions, dark local regions, and alternating bright and dark local regions. Based on the distribution of the unevenness of the bright local regions, the unevenness of the dark local regions, and the unevenness of the alternating bright and dark local regions, the system confirms whether there are uneven defect areas in the cable surface image.
Claims
1. A high-precision method for identifying surface defects in cable assemblies, characterized in that, include: Acquire images of the cable surface; The cable surface image is divided into several equally sized local windows. Based on the distribution of pixel grayscale values within each local window, the local windows located on the cable surface are obtained, thus defining the cable surface region. Using the Otsu thresholding method, the cable surface region is divided into bright and dark areas. The direction of natural light is determined based on the pixel distribution at the intersection of the bright and dark areas. The cable surface region is then divided into several equally sized local regions. An initial gradient direction threshold is set, and combined with the pixel grayscale value distribution within each local region, a gradient direction threshold for each local region is obtained. Based on the relationship between the gradient direction difference between different pixels within each local region and the gradient direction threshold, the approximate gradient pixel for each pixel within each local region is obtained. Finally, based on the direction of natural light, the approximate gradient value of each pixel within each local region, and the gradient direction threshold, the approximate gradient pixel is determined. The gradient direction of each pixel is used to obtain the degree of unevenness in each local region. Based on the distribution of pixels in the bright and dark areas of each local region, the local region is divided into bright local regions, dark local regions, and alternating bright and dark local regions. Based on the distribution of unevenness in the bright local regions, the dark local regions, and the alternating bright and dark local regions, it is confirmed whether there are uneven defect areas in the cable surface image. The specific steps for obtaining the direction of natural light illumination are as follows: Obtain the chain code of the edge where the bright and dark regions intersect; count the number of times each number appears in the chain code of the edge where the bright and dark regions intersect, and take the direction corresponding to the number that appears most frequently in the chain code of the edge where the bright and dark regions intersect as the edge extension direction; randomly select from the bright and dark regions... One pixel is used as a reference point; Starting from the reference point, and using the direction perpendicular to the edge extension direction as the extension direction of the line starting from the reference point, we obtain several lines, which are denoted as reference lines. A coordinate system is constructed with the lower left corner of the cable surface image as the origin, the horizontal axis pointing to the right, and the vertical axis pointing upwards. The mean of the tilt angles of all reference lines is recorded as the direction of natural light illumination. The number of pixels is preset; the specific calculation steps for obtaining the gradient direction threshold of each local region are as follows: Based on the grayscale distribution of pixels within each local region, the smoothness of each local region is obtained; the specific calculation formula for obtaining the smoothness of each local region is as follows: In the formula, Indicates the first The flatness of a local area Indicates the first The number of pixels contained in a local region Indicates the first Within the local area, the first The number of pixels contained in the 8-neighborhood of a pixel. Indicates the first Within the local area, the first Within the 8-neighborhood of the pixel, the first The grayscale value of each pixel Indicates the first Within the local area, the first Within the 8-neighborhood of the pixel, the first The grayscale value of each pixel This represents the absolute value function; based on the initial gradient direction threshold and the flatness of each local region, the gradient direction threshold for each local region is obtained; the specific calculation formula for obtaining the gradient direction threshold for each local region is as follows: In the formula, Indicates the first Gradient direction threshold for a local region This represents the initial gradient direction threshold. Indicates the first The flatness of a local area This represents the floor function. The function is an exponential function with the natural constant as its base; the specific calculation formula for the degree of concavity and convexity of each local region is as follows: In the formula, Indicates the first The degree of unevenness or concavity in a local area Indicates the first The number of pixels contained in a local region Indicates the first Within the local area, the first The mean of the Euclidean distances between a pixel and all its gradient approximation pixels. Indicates the first Within the local area, the first Gradient direction of each pixel Indicates the direction of natural light. Indicates the first Within the local area, the first The first pixel The gradient approximates the gradient direction of each pixel. This represents the absolute value function.
2. The high-precision identification method for surface defects of cable assemblies according to claim 1, characterized in that, The specific steps for obtaining the cable surface area are as follows: The specific calculation formula for obtaining the cable characteristic representation degree of each local window is as follows: In the formula, Indicates the first The cable characteristic representation of a local window. Indicates the first The number of pixels contained within a local window Indicates the first Within the local window, the first The grayscale value of each pixel Indicates the first The local window The grayscale value of each pixel Represents the absolute value function. Let be an exponential function with the natural constant as its base; let the number of clusters be 2. Based on the cable feature representation degree of each local window, use the K-means clustering algorithm to cluster all local windows into two clusters; the cluster with the largest mean of cable feature representation degree of all local windows in the two clusters is denoted as the cluster where the cable region is located; the local windows in the cluster where the cable region is located are denoted as local windows located on the cable surface; the pixels in the local windows located on the cable surface are denoted as cable surface pixels; based on the cable surface pixels, the cable surface region is obtained.
3. The high-precision identification method for surface defects of cable assemblies according to claim 1, characterized in that, The specific steps for dividing the cable surface area into a bright area and a dark area are as follows: using the Otsu threshold method, the cable surface area is divided into two segmented areas based on the gray value of each pixel in the cable surface area; the segmented area with the largest average gray value of the pixels in the two segmented areas is recorded as the bright area, and the segmented area with the smallest average gray value of the pixels in the two segmented areas is recorded as the dark area.
4. The high-precision identification method for surface defects of cable assemblies according to claim 1, characterized in that, The specific calculation steps for obtaining the gradient approximate pixel point of each pixel point in each local region are as follows: ... The gradient direction within the defect region is related to the first... Within the defect area, the first The absolute value of the difference in gradient directions of the nth pixel is less than that of the 1st pixel. Gradient direction threshold for a local region The pixel is denoted as the first pixel. Within the defect area, the first The gradient of a pixel approximates the pixel.
5. The high-precision identification method for surface defects of cable assemblies according to claim 1, characterized in that, The specific calculation formula for dividing a local area into a bright local area, a dark local area, and a bright-dark alternating local area is as follows: If all pixels in a local area are pixels in the dark area, then the local area is recorded as a dark local area; if all pixels in a local area are pixels in the bright area, then the local area is recorded as a bright local area; if a local area contains pixels in both the bright and dark areas, then the local area is recorded as a bright-dark alternating local area.
6. The high-precision identification method for surface defects of cable assemblies according to claim 1, characterized in that, The specific steps for confirming whether there are uneven defect areas in the cable surface image are as follows: Obtain the first... The specific formula for calculating the probability that a localized area of a bright surface is a region with uneven defects is as follows: In the formula, Indicates the first The possibility that a localized area on the glossy surface is an area with uneven defects. This represents the average level of unevenness or roughness in all localized areas of the glossy surface. Indicates the first The average value of the unevenness of a local area on a glossy surface. Represents the absolute value function; obtains the first... The specific formula for calculating the probability that a local area of the dark surface is a region with uneven defects is as follows: In the formula, Indicates the first The possibility that a localized area on the dark side is a region of unevenness or defect. This represents the average degree of relief or convexity in all localized dark areas. Indicates the first The average value of the degree of unevenness in a local area of the dark side. Represents the absolute value function; obtains the first... The specific formula for calculating the probability that a localized area with alternating light and dark areas is a region with unevenness or convexity is as follows: In the formula, Indicates the first The possibility that a localized area with alternating bright and dark areas is a region with uneven or concave defects. This represents the average degree of relief or unevenness in all alternating bright and dark local areas. Indicates the first The average value of the unevenness of a local area with alternating light and dark areas. Represents the absolute value function; if the first... The probability that a bright local area is a region with uneven defects is greater than the probability threshold. Then the first The bright surface has localized areas with uneven defects. If the first The probability that a localized area on the dark surface is a region with uneven defects is greater than the probability threshold. Then the first The dark area is a region with uneven defects; If the first The probability that a localized area with alternating bright and dark areas is a region with uneven defects is greater than the probability threshold. Then the first The alternating bright and dark local areas are areas of uneven defects. If the cable surface image contains areas of uneven defects, then the cable surface image contains uneven defects.
7. A high-precision identification system for surface defects in cable assemblies, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that the processor executes the computer program to implement the steps of a high-precision identification method for surface defects of a cable assembly as described in any one of claims 1-6.
Citation Information
Patent Citations
Aluminum composite plate defect detection method and system based on artificial intelligence
CN117611583A
Surface defect inspection device and surface defect inspection method
JP2019200775A