High-voltage switch shell stain detection method and system based on machine vision

By calculating the stain sensitivity gradient index and constructing a dynamic prior-gated diffuse reflection conversion network, the problem of stain omission in high-voltage switch housing surface reflection model under dynamic changes in specular-to-diffuse reflection conversion technology was solved, thus improving the accuracy of stain detection in high-voltage switch housing.

CN120876477BActive Publication Date: 2025-12-05SHAANXI JINXIN ELECTRIC APPLIANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511383903.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-26
Publication Date
2025-12-05
Estimated Expiration
2045-09-26

AI Technical Summary

Technical Problem

Existing specular-to-diffuse reflection conversion technology cannot adapt to the dynamic changes in the reflection model of the high-voltage switch housing surface caused by localized stains, leading to the risk of missed stain detection.

Method used

By calculating the stain sensitivity gradient index and fusing multi-scale gradient intensity and direction consistency information, a dynamic prior-gated diffuse reflection transformation network is constructed. This network combines geometric and color features to quantify the deviation of surface reflectance characteristics, achieving pixel-level weighted fusion and dynamically adjusting the fusion ratio between the standard diffuse reflection and adaptive diffuse reflection prediction branches.

Benefits of technology

Accurately identifying potential stain areas on the surface of high-voltage switch housings avoids misjudging structural edges as stains, thus improving the accuracy of high-voltage switch housing cleaning quality inspection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120876477B_ABST
    Figure CN120876477B_ABST
Patent Text Reader

Abstract

The present application belongs to the technical field of image processing, and particularly relates to a high-voltage switch shell stain detection method and system based on machine vision, which comprises the following steps: acquiring a multi-view gray-scale image of a high-voltage switch shell, calculating a stain sensitivity gradient index of a pixel point by fusing multi-scale gradient intensity and direction consistency information, generating a local reflection non-ideal weight in combination with a color correlation index, constructing a dynamic prior gate diffuse reflection conversion network, performing pixel-level weighted fusion on a standard diffuse reflection prediction branch and an adaptive diffuse reflection prediction branch based on the local reflection non-ideal weight to obtain a diffuse reflection image, and performing stain detection based on the diffuse reflection image. The present application effectively solves the problem that the traditional method misjudges the stain texture on the surface of the high-voltage switch shell as highlight to be removed, and improves the accuracy of high-voltage switch shell stain detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology. More specifically, this invention relates to a machine vision-based method and system for detecting contaminants on high-voltage switch housings. Background Technology

[0002] High-voltage switchgear is a critical control and protection device in power systems. During production, its casing requires rigorous cleaning to remove processing residues, oil, metal shavings, and other contaminants. Incomplete cleaning can lead to decreased insulation performance, partial discharge, or even equipment malfunction during operation. Therefore, precise visual inspection of the cleaned casing surface before putting it into use to confirm the absence of residual dirt is crucial for ensuring product quality and operational safety.

[0003] In recent years, automated inspection technologies based on machine vision have gradually replaced manual visual inspection, becoming the mainstream solution. Among them, Specular-to-Diffuse Translation for Multi-view Reconstruction (S2D-Net) technology is widely used to address the image quality degradation problem of high-voltage switch metal / composite material housings under strong reflective conditions caused by water stains and cleaning agent residues after cleaning. This technology aims to convert multi-view images of objects with specular reflection into diffuse reflection images, thereby restoring the true surface texture obscured by highlights and providing clearer input for subsequent stain identification.

[0004] However, in practical applications, existing specular-to-diffuse conversion techniques have significant limitations: they process the entire image using globally uniform network parameters, assuming all regions follow the same diffuse reflection model. But in high-voltage switch housing scenarios, local areas may contain incompletely cleaned oil films, metal debris, or cleaning agent residue. These contaminants alter the material's optical reflection behavior—for example, residual oil films enhance specular reflection and change chromaticity response, while metal debris exhibits non-Lambertian diffuse reflection characteristics. In such cases, traditional specular-to-diffuse conversion models still treat the clean surface as a priori, causing the true texture of the contaminated areas to be over-smoothed during the conversion process, making it impossible to accurately identify in subsequent detection and thus increasing the risk of missed contaminant detection. Summary of the Invention

[0005] To address the technical problem that existing specular-to-diffuse reflection conversion technology cannot adapt to the dynamic changes in the reflection model caused by localized stains on the surface of high-voltage switch housings, resulting in inaccurate reflection processing of stained areas and thus the risk of missed stain detection, this invention provides solutions in the following aspects.

[0006] In a first aspect, the present invention provides a machine vision-based method for detecting contaminants on high-voltage switch housings, comprising:

[0007] Acquire a grayscale image of the high-voltage switch housing; determine the stain sensitivity gradient index of each pixel based on the gradient intensity and gradient direction consistency coefficient of each pixel in the grayscale image under different filtering scales; obtain the local reflection non-ideal weight of each pixel based on the stain sensitivity gradient index and color correlation index; construct a dynamic prior-gated diffuse reflection transformation network containing a standard diffuse reflection prediction branch and an adaptive diffuse reflection prediction branch; perform pixel-level weighted fusion of the outputs of the standard diffuse reflection prediction branch and the adaptive diffuse reflection prediction branch based on the local reflection non-ideal weight to obtain a diffuse reflection image; perform stain detection based on the diffuse reflection image and output the stain segmentation result.

[0008] This invention accurately identifies potential stain areas on the surface of high-voltage switch housings by calculating the stain sensitivity gradient index and fusing multi-scale gradient intensity and direction consistency information, avoiding the problem of traditional methods misjudging structural edges as stains. Based on this, it generates local reflection non-ideal weights and combines geometric and color features to quantify the degree to which surface reflection characteristics deviate from the ideal model, providing a scientific basis for dynamic processing. Furthermore, it constructs a dynamic prior-gated diffuse reflection conversion network, enabling the system to automatically adjust the fusion ratio of the standard diffuse reflection prediction branch and the adaptive diffuse reflection prediction branch according to the local reflection non-ideal weights. When the weights are close to 0, the standard diffuse reflection prediction branch is prioritized for processing clean areas to ensure efficiency; when the weights are close to 1, the adaptive diffuse reflection prediction branch is prioritized for processing stain areas to preserve the true texture. This effectively solves the problem of traditional specular-to-diffuse reflection conversion technology misjudging stain textures as specular interference and resulting in excessive smoothing, thus improving the accuracy of high-voltage switch housing cleaning quality detection.

[0009] Preferably, the different filtering scales include: using standard deviations of... The three Gaussian kernels are used to perform Gaussian filtering on the grayscale image.

[0010] Preferably, the gradient direction consistency coefficient satisfies the expression: ;in, Indicates the first Pixels at each scale The gradient direction consistency coefficient; Represents pixels The neighborhood window; For pixels The coordinates of the pixels within the neighborhood window; For the first Pixels at each scale The principal gradient direction vector of the neighborhood window and the pixels within the neighborhood window The angle between the gradient vectors; For pixels The number of pixels contained within the neighborhood window; It is a cosine function.

[0011] Preferably, the stain sensitivity gradient index satisfies the expression: ;in, Represents pixels The stain sensitivity gradient index; Indicates the first Pixels at each scale The gradient vector; Indicates the first Pixels at each scale The principal gradient direction vector of the neighborhood window; Indicates the first Pixels at each scale The gradient direction consistency coefficient; Indicates the number of scales; This represents the vector dot product operator; Represents the absolute value symbol.

[0012] Preferably, the method for obtaining the principal gradient direction vector is as follows: construct a data matrix from the gradient vectors of all pixels within the neighborhood window of the pixel, calculate the covariance matrix of the data matrix, select the eigenvector corresponding to the largest eigenvalue in the covariance matrix, and normalize it to a unit vector as the principal gradient direction vector of the neighborhood window of the pixel.

[0013] This invention employs a multi-scale analysis strategy, fusing analysis results from three scales to comprehensively cover various stain features ranging from microscopic to large-area, avoiding the missed detection problems that may occur with single-scale analysis. This invention integrates gradient intensity and direction consistency information, considering both local structural strength and assessing the degree of gradient direction disorder, thereby accurately distinguishing true stain areas from structural edges or noise interference. This improves the reliability and adaptability of stain detection on high-voltage switch housings and provides a precise foundation for stain area identification in the subsequent construction of dynamic prior-gated diffuse reflection conversion networks.

[0014] Preferably, the method for obtaining the color correlation index is as follows: converting the high-voltage switch housing image to the HSV color space, and extracting the three channels of hue (H), saturation (S), and brightness (V); the color correlation index of the pixel satisfies the expression: ;in, Represents pixels Color correlation index; Represents pixels of Correlation coefficient between hue H and saturation S within the neighborhood; This represents the brightness value of a pixel; Represents the absolute value symbol.

[0015] This invention effectively captures the unique color features of oil film and other contaminant areas by converting high-voltage switch housing images to the HSV color space and obtaining the color correlation index. It effectively solves the technical problem that traditional methods cannot distinguish between oil film contaminants and normal metal surface reflections, and provides key color feature support for the subsequent calculation of the weight of local reflection non-ideality, thereby improving the accuracy of high-voltage switch housing contaminant detection.

[0016] Preferably, the local reflection non-ideality weight satisfies the expression: ;in, Represents pixels The weight of local reflection non-ideal; Represents pixels The normalized stain sensitivity gradient index; Represents pixels Color correlation index; , Indicates the weighting coefficient; This is the offset; This is the scaling factor.

[0017] This invention achieves precise quantification of the surface reflection characteristics of high-voltage switch housings by using local reflection non-ideal weighting. It can dynamically adjust the diffuse reflection conversion strategy according to the degree of regional contamination, emphasizing efficient processing in clean areas, preserving the true texture in contaminated areas, and achieving smooth transitions in transition areas. This effectively solves the problem of traditional methods misinterpreting oil films and other contaminants as specular interference and thus over-smoothing the surface.

[0018] Preferably, the method for constructing the dynamic prior-gated diffuse transformation network includes: loading a pre-trained S2D-Net model as the basic architecture, retaining its encoder part as a shared feature extractor; constructing a dual-branch decoding structure, including: a standard diffuse prediction branch: the structure is the same as the original S2D-Net decoder; and an adaptive diffuse prediction branch: a lightweight CNN structure containing 3 layers of 3×3 convolutions followed by a ReLU activation function.

[0019] This invention constructs a dual-branch network and achieves pixel-level dynamic switching based on the weights of local reflection non-ideality. In clean areas, it emphasizes the standard diffuse reflection prediction branch to improve efficiency, while in stained areas, it emphasizes the adaptive diffuse reflection prediction branch to preserve the true texture. In transition areas, it achieves smooth fusion, thereby effectively avoiding the problem of traditional methods misjudging oil films and other stains as specular interference and over-smoothing them.

[0020] Preferably, the method for acquiring the diffuse reflection image is as follows: ;in, Represents pixels The final diffuse reflectance value; Represents the pixel points of the standard diffuse prediction branch output. Diffuse reflection component; Represents the pixel output of the adaptive diffuse prediction branch. Diffuse reflection component; Represents pixels The local reflection non-ideal weights are used to construct the diffuse reflection image by taking the final diffuse reflection values ​​of all pixels in the grayscale image.

[0021] Secondly, the present invention provides a machine vision-based high-voltage switch housing stain detection system, including a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the above-mentioned machine vision-based high-voltage switch housing stain detection method is implemented.

[0022] By adopting the above technical solution, the above-mentioned machine vision-based high-voltage switch housing stain detection method is generated into a computer program and stored in a memory for loading and execution by a processor. This allows for the creation of a terminal device based on the memory and processor, facilitating its use.

[0023] The beneficial effects of this invention are as follows: By calculating the stain sensitivity gradient index and fusing multi-scale gradient intensity and direction consistency information, this invention accurately identifies potential stain areas on the surface of high-voltage switch housings, avoiding the problem of traditional methods misjudging structural edges as stains. Furthermore, by generating local reflection non-ideal weights and combining geometric and color features, the degree to which surface reflection characteristics deviate from the ideal model is quantified, providing a scientific basis for dynamic processing. Then, a dynamic prior-gated diffuse reflection conversion network is constructed, enabling the system to automatically adjust the fusion ratio of the standard diffuse reflection prediction branch and the adaptive diffuse reflection prediction branch according to the local reflection non-ideal weights. When the weight is close to 0, the standard diffuse reflection prediction branch is prioritized for processing clean areas to ensure efficiency; when the weight is close to 1, the adaptive diffuse reflection prediction branch is prioritized for processing stain areas to preserve the true texture. This effectively solves the problem of traditional specular-to-diffuse reflection conversion technology misjudging stain textures as specular interference and resulting in excessive smoothing, thus improving the accuracy of high-voltage switch housing cleaning quality detection. Attached Figure Description

[0024] Figure 1 This is a flowchart illustrating the machine vision-based high-voltage switch housing stain detection method of the present invention;

[0025] Figure 2This is a flowchart illustrating step S2 of the machine vision-based high-voltage switch housing stain detection method in this invention. Detailed Implementation

[0026] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0027] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0028] This invention discloses a machine vision-based method for detecting contaminants on high-voltage switch housings, referring to... Figure 1 This includes steps S1-S3:

[0029] S1. Acquire images of the high-voltage switch housing and perform preprocessing to obtain a grayscale image of the high-voltage switch housing.

[0030] After production and cleaning, the high-voltage switch housing is usually placed in a clean room or production line. Industrial-grade RGB cameras are used for image acquisition. Specifically, 3-5 industrial cameras are evenly arranged around the housing, the focal length is adjusted to make the housing surface clear, and the shooting angle must be perpendicular to the housing surface to avoid perspective distortion. The high-voltage switch housing images are acquired from multiple perspectives through the industrial cameras.

[0031] It should be noted that the production site is subject to interference factors such as changes in ambient light and reflections from cleaning fluid, which can affect the subsequent processing results if the original images are used directly. Therefore, this invention performs denoising and white balance correction on the high-voltage switch housing images from various viewpoints. The high-voltage switch housing images after denoising and white balance correction are denoised as follows: . For RGB images, this invention performs specular-to-diffuse conversion processing on images from various viewing angles. The images are converted to grayscale to obtain grayscale images from different viewpoints.

[0032] Specifically, nonlocal mean filtering and the gray-world method are used to denoise and correct the white balance of the high-voltage switchgear image. Alternatively, other filtering and white balance correction algorithms can be used to denoise and correct the white balance of the high-voltage switchgear image.

[0033] S2. Determine the stain sensitivity gradient index of pixels in the grayscale image from each viewpoint, and obtain the local reflectance non-ideal weight of pixels by combining the color correlation index. Perform pixel-level weighted fusion on the outputs of the standard diffuse reflection prediction branch and the adaptive diffuse reflection prediction branch in the dynamic prior gated diffuse reflection transformation network to obtain the final diffuse reflection value of the pixel.

[0034] Specifically, the flowchart for step S2 is as follows: Figure 2 As shown, steps S201-S204 are included:

[0035] S201. Determine the stain sensitivity gradient index of each pixel in the grayscale image based on the gradient intensity and gradient direction consistency coefficient at different filtering scales.

[0036] It should be noted that the microstructure of the contaminated areas (such as oil stains and metal debris) and clean areas of the high-voltage switch housing differs significantly, resulting in different gradient response characteristics. The clean surface exhibits a consistent edge direction, displaying the regular texture gradient inherent in the metal substrate itself. However, due to microstructural changes (oil film filling pores, debris accumulation, etc.), the grayscale changes of local pixels in the contaminated areas are chaotic, leading to disordered gradient directions. Therefore, this invention utilizes grayscale images of the high-voltage switch housing... The gradient distribution features of the pixels are used to obtain the stain sensitivity gradient index of each pixel in order to identify potential stain areas.

[0037] Specifically, for a grayscale image at any viewpoint, Gaussian blurring is performed on the grayscale image using Gaussian kernels of different scales to obtain Gaussian blurred images at different scales.

[0038] It should be noted that the standard deviations used in this embodiment are as follows: The three Gaussian kernels are used for blurring, among which Corresponding to the characteristics of minor stains (such as tiny oil droplets, minor scratches). Corresponds to medium-scale stain characteristics (such as medium-sized oil stains). For larger areas of contamination (such as areas of accumulated metal debris), multi-scale analysis can comprehensively capture contamination information of different sizes on the shell surface. In other embodiments, implementers can set the number of Gaussian kernel scales and specific parameter values ​​according to the actual implementation situation.

[0039] Furthermore, the Sobel operator is used to calculate the gradient of the Gaussian blurred images at different scales, resulting in gradient images at different scales. In other embodiments, implementers can select gradient detection algorithms, such as the Prewitt operator or the Scharr operator, depending on the actual implementation situation.

[0040] Furthermore, for any pixel in the gradient image at any scale, a system is constructed centered on that pixel. A neighborhood window of a given size is used. Principal component analysis (PCA) is employed to extract the dominant direction of the gradient vector within the neighborhood window of a pixel. Specifically, the gradient vectors of all pixels within the neighborhood window are used to construct a data matrix. The covariance matrix of the data matrix is ​​calculated, and the eigenvector corresponding to the largest eigenvalue in the covariance matrix is ​​selected and normalized to a unit vector. This eigenvector serves as the dominant gradient direction vector within the neighborhood window of that pixel, representing the main direction of the gradient distribution within the neighborhood window. The neighborhood size is preset and can be set by the implementer according to the actual implementation situation. In this embodiment, M=15 is preferred to ensure that the neighborhood window can contain enough local structural information, while avoiding the increase in computational complexity and blurring of local features caused by an excessively large neighborhood window.

[0041] Furthermore, for any pixel in a gradient image at any scale, the gradient direction consistency coefficient of that pixel is calculated based on the angle between the principal gradient direction vector of the pixel's neighborhood window and the gradient vectors of all pixels within that neighborhood window.

[0042]

[0043] in, Indicates the first Pixels at each scale The gradient direction consistency coefficient is used to quantify the degree of concentration of gradient directions within the neighborhood window; Represents pixels The neighborhood window; For pixels The coordinates of the pixels within the neighborhood window; For the first Pixels at each scale The principal gradient direction vector of the neighborhood window and the pixels within the neighborhood window The angle between the gradient vectors; For pixels The number of pixels contained within the neighborhood window; It is a cosine function.

[0044] It should be noted that, due to the gradient direction of the image, Periodicity (i.e., gradient vector) and (representing the same edge features), therefore this invention adopts Calculate the gradient direction consistency coefficient to avoid incorrectly judging opposite directions (angle ≈ 180°) as inconsistent directions.

[0045] At the edges of the clean metal surface structure, the edge direction is consistent, exhibiting the regular texture gradient of the metal substrate itself. The gradient direction is highly consistent, resulting in a high gradient direction consistency coefficient at the edge region of the clean metal surface structure. The gradient consistency coefficient is close to 1; however, in stained areas (such as areas of oil diffusion or metal debris), changes in microstructure cause gradient direction disorder, resulting in a gradient direction consistency coefficient that is close to 1. Significantly reduced; in smooth areas of clean metal surfaces, due to noise, the gradient directions of pixels may be randomly distributed, resulting in a lower gradient direction consistency coefficient. The gradient direction consistency coefficient of a pixel is relatively low. Therefore, the larger the gradient direction consistency coefficient of a pixel, the more likely the pixel is located at the edge of the clean metal surface structure, and the smaller the gradient direction consistency coefficient of a pixel, the more likely the pixel is located in the stained area or the smooth area of ​​the clean metal surface.

[0046] Furthermore, based on the projection intensity of the pixel's gradient vector along the principal gradient direction and the pixel's gradient direction consistency coefficient, the stain sensitivity gradient exponent of the pixel is obtained:

[0047]

[0048] in, Represents pixels The stain sensitivity gradient index; Indicates the first Pixels at each scale The gradient vector; Indicates the first Pixels at each scale The principal gradient direction vector of the neighborhood window; Indicates the first Pixels at each scale The gradient direction consistency coefficient; Indicates the number of scales. This represents the vector dot product operator; Represents the absolute value symbol.

[0049] Represents pixels The projection length of the gradient vector on the principal gradient direction of its neighborhood window reflects the structural strength of the pixel along the principal gradient direction. Indicates the degree of gradient direction disorder; if the pixel Located in stained areas (such as areas of oil diffusion or metal debris), changes in the surface microstructure of the stained area (oil film filling pores, debris accumulation, etc.) cause detectable changes in local grayscale, making... Maintaining a moderate to high level, while the stains cause gradient direction disorder, resulting in a lower gradient direction consistency coefficient. Significantly reduced, A larger value results in a higher stain sensitivity gradient index for the stained area due to the product of the two values. Significantly increased; if pixel points Located at the edges of clean metal surface structures (such as bolt outlines, flange connections, and markings), significant grayscale jumps occur due to changes in the physical structure of the metal surface, resulting in… The gradient is relatively large, and at the same time, the edges of the structure have a highly consistent gradient direction, resulting in a high gradient direction consistency coefficient. Approaching 1, Approaching 0, the product of the two makes the stain sensitivity gradient exponential at the edge of the structure close to 0. Keep at a low level; if pixels Located in a smooth area of ​​a clean metal surface (such as a uniform metal surface), where there is no obvious change in grayscale, The value is very low, although noise may cause the gradient direction to be randomly distributed, making Lower It is relatively high, but due to the gradient strength term The product of the two is very small, and the product remains low, resulting in a low stain sensitivity gradient exponent in the smooth region. The value is relatively small. Therefore, when the stain sensitivity gradient index is low... When the size is larger, the number of pixels The more likely it is to be in a stained area.

[0050] S202. Obtain the local reflection non-ideal weight of the pixel based on the stain sensitivity gradient index and color correlation index of the pixel.

[0051] It should be noted that contamination on the surface of the high-voltage switch housing not only disrupts the gradient direction but also alters the surface's optical reflection characteristics. Ideally, a clean metal surface follows a standard specular reflection model, but contaminated areas (such as oil films or metal debris) disrupt this ideal reflection characteristic, causing traditional specular-to-diffuse conversion techniques to misinterpret real contamination textures as highlights and oversmooth them. Therefore, this invention, based on the contamination sensitivity gradient index obtained in step S201 and combined with color space analysis, derives the local reflection non-ideal weight of each pixel. This weight is used to quantify the degree to which the reflection characteristics of each pixel on the high-voltage switch housing deviate from the ideal reflection model, providing a crucial basis for subsequent dynamic diffuse reflection conversion.

[0052] Specifically, the stain sensitivity gradient index is normalized:

[0053]

[0054] in, Represents pixels Normalized stain sensitivity gradient index; Represents pixels The stain sensitivity gradient index; Represents a grayscale image The set of stain sensitivity gradient indices of all pixels in the image; Represents the maximum value function. Indicates obtaining a grayscale image The maximum value among all pixels' stain sensitivity gradient exponents is used to... Scale to the [0,1] interval.

[0055] It should be noted that oil films and other stains exhibit unique color characteristics in the HSV color space: high saturation, a specific tonal range, and low brightness. These characteristics are difficult to capture directly in the RGB color space. Therefore, this invention uses the high-voltage switch housing image after noise reduction and white balance processing in step S1. The color space is converted to HSV color space, and hue, saturation, and brightness features are extracted to calculate the color correlation index.

[0056] Specifically, the high-voltage switch housing image after noise reduction and white balance processing in step S1 is... Convert from RGB color space to HSV color space and extract the three channels: hue (H), saturation (S), and brightness (V).

[0057] Furthermore, based on the correlation between hue and saturation within the pixel's neighborhood and the brightness information, the color correlation index of the pixel is calculated:

[0058]

[0059] in, Represents pixels Color correlation index; Represents pixels of Correlation coefficient between hue H and saturation S within the neighborhood; This represents the brightness value of a pixel (range 0~255). This indicates an absolute value. It should be noted that the oil film area typically exhibits high... This is because the oil film causes an iridescent effect, making hue and saturation highly correlated, while brightness is reduced; whereas on a clean metal surface, the correlation between hue and saturation is low and brightness is high, making... The value is relatively small.

[0060] It should be noted that a 3×3 neighborhood was chosen in this embodiment to calculate the correlation coefficient because this size can capture local color changes while avoiding excessive noise interference. In other embodiments, implementers can adjust the neighborhood size according to the actual image resolution and stain characteristics, but it is recommended to use a size between 2×2 and 5×5 to balance local feature capture and noise resistance.

[0061] Furthermore, based on the normalized stain sensitivity gradient index and color correlation index of the pixel, the local reflection non-ideal weights of the pixel are generated:

[0062]

[0063] in, Represents pixels The local reflection non-ideal weights are used to control the fusion ratio of the standard model and the adaptive model in the subsequent diffuse reflection transformation process; Represents pixels Normalized stain sensitivity gradient index; Represents pixels Color correlation index; , This represents a weighting coefficient used to balance the relative importance of geometric and color features; its empirical value is... , ; This is the offset used to adjust the center point of the weight distribution; its empirical value is 0.5. This is a scaling factor used to control the steepness of the sigmoid function; an empirical value of 5 is recommended. Implementers can also adjust the weighting coefficients based on actual implementation requirements. , Offset and scaling factor However, to ensure the rationality and stability of the weight distribution for non-ideal local reflections, the weighting coefficients must meet the following requirements. Offset The scaling factor should be within the range of [0.3, 0.7]. It should be within the range of [3,7].

[0064] It should be noted that this invention uses the Sigmoid function to... Mapping ensures Strictly limited to the (0,1) interval, with local reflection non-ideal weights. In areas close to 0 or 1, the function changes smoothly, ensuring stability in the treatment of clean and heavily soiled areas. In the intermediate area... The function changes steeply, making the local reflection non-ideal weights more sensitive to small changes in the degree of staining.

[0065] S203. Construct a dynamic prior-gated diffuse reflection transformation network that includes a standard diffuse reflection prediction branch and an adaptive diffuse reflection prediction branch. Based on the weights of local reflectance non-ideality, perform pixel-level weighted fusion of the outputs of the standard diffuse reflection prediction branch and the adaptive diffuse reflection prediction branch to obtain the final diffuse reflection value of the pixel.

[0066] It should be noted that S2D-Net uses globally uniform network parameters to process the entire image, assuming that all regions follow the same reflection model. However, in the detection of high-voltage switch housings, the reflection characteristics of different regions differ significantly: clean areas are close to the ideal reflection model, while stained areas deviate significantly from this model. If the same set of parameters is used for all regions, the true texture of stained areas will be misjudged as highlights and over-smoothed, resulting in missed stains. Therefore, this invention constructs a dynamic prior-gated diffuse reflection transformation network based on the local reflection non-ideal weights obtained in step S202, realizing differentiated processing of regions with different reflection characteristics, and ensuring that the true stain texture is not mistakenly deleted in the preprocessing stage.

[0067] Specifically, the process of constructing a dynamic prior-gated diffuse reflection transformation network includes:

[0068] First, a pre-trained S2D-Net model is loaded as the basic architecture, retaining its encoder portion as a shared feature extractor. This encoder consists of eight convolutional layers (C64-C128-C256-C512-C512-C512-C512), each followed by a ReLU activation function. Downsampling is achieved through convolution operations with a stride of 2 to progressively extract multi-scale features from the image. It should be noted that using a pre-trained model significantly reduces the training data requirement while maintaining basic feature extraction capabilities, making it particularly suitable for the limited sample size required in power equipment inspection.

[0069] Furthermore, a dual-branch decoding structure is constructed:

[0070] 1. Standard diffuse reflection prediction branch: The structure is the same as the original S2D-Net decoder, consisting of 8 decoding layers. Each stage first achieves upsampling through 2×2 transposed convolution (stride=2), then performs channel concatenation with the feature map of the corresponding layer of the encoder to achieve skip connections, and finally refines the features through convolutional layers.

[0071] 2. Adaptive diffuse reflection prediction branch: Lightweight CNN structure, containing 3 layers of 3×3 convolutions (ReLU activation).

[0072] It should be noted that the adaptive diffuse reflection prediction branch in this embodiment uses a shallower network structure because stained areas typically have more complex reflective properties, but overfitting needs to be avoided. In other embodiments, implementers can adjust the network depth according to the actual complexity of the stain, but it is recommended not to exceed 5 layers to control computational overhead.

[0073] Furthermore, for grayscale images from three adjacent viewpoints, these three grayscale images are connected along the spatial axis and then input into the dynamic prior-gated diffuse reflection transformation network. The standard diffuse reflection prediction branch outputs the diffuse reflection components from the three viewpoints, while the adaptive diffuse reflection prediction branch also outputs the diffuse reflection components from the three viewpoints.

[0074] Based on the weighting of local reflectance non-ideality, the diffuse reflectance components of the standard diffuse reflectance prediction branch output at any viewpoint and the diffuse reflectance components of the corresponding viewpoint output by the adaptive diffuse reflectance prediction branch are fused at the pixel level to obtain the final diffuse reflectance value of the pixel at that viewpoint:

[0075]

[0076] in, Represents pixels The final diffuse reflectance value; Represents the pixel points of the standard diffuse prediction branch output. Diffuse reflection component; Represents the pixel output of the adaptive diffuse prediction branch. Diffuse reflection component; Represents pixels The weight of local reflection non-ideal. When When close to 0, the number of pixels The final diffuse reflection value focuses more on the standard diffuse reflection prediction branch, thus ensuring processing efficiency and stability. This is because clean metal surface areas follow an ideal reflection model, and the standard diffuse reflection prediction branch can efficiently and accurately separate diffuse reflection without damaging the surface texture; when When it is close to 1, the pixel The final diffuse reflectance value focuses more on the adaptive diffuse reflectance prediction branch, thus ensuring that the true texture of the stained area is not misjudged as diffuse reflectance deletion, because stained areas such as oil film and carbonization deviate significantly from the ideal reflectance model and require specially optimized processing strategies; when When the range is in the middle, the standard diffuse reflection prediction branch and the adaptive diffuse reflection prediction branch are fused together according to their weight ratios to achieve a smooth transition, avoid image artifacts caused by abrupt changes in processing strategy, and balance processing accuracy and efficiency.

[0077] The diffuse reflection values ​​of all pixels under the same viewpoint constitute the diffuse reflection image under that viewpoint.

[0078] S3. Stain detection based on diffuse reflection images.

[0079] Specifically, the present invention uses the U-Net++ model for stain detection. The information of the U-Net++ model includes: the input of the U-Net++ model is a diffuse reflection image, the output is a stain segmentation map, the training set is diffuse reflection images of high voltage switch housing images under different scenes and angles, and the annotation information is a stain region mask.

[0080] The diffuse reflection images obtained in step S2 from each viewpoint are input into the trained U-Net++ model to output a stain segmentation map. The stain segmentation map is a binary image, where 1 represents the stain region and 0 represents the background region.

[0081] This completes the detection of contaminants on high-voltage switch housings.

[0082] This invention also discloses a machine vision-based high-voltage switch housing stain detection system, including a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement the machine vision-based high-voltage switch housing stain detection method according to this invention.

[0083] The system also includes other components well known to those skilled in the art, such as communication buses and communication interfaces, the settings and functions of which are known in the art and will not be described in detail here.

Claims

1. A method for detecting dirt on a high-voltage switch housing based on machine vision, characterized in that The method comprises the following steps: An image of the high-voltage switch shell is acquired; A pixel's stain sensitivity gradient index is determined according to the gradient intensity and the gradient direction consistency coefficient of each pixel in the gray image under different filter scales, and the stain sensitivity gradient index satisfies the expression: ; in, Represents pixels The stain sensitivity gradient index; Indicates the first Pixels at each scale The gradient vector; Indicates the first Pixels at each scale The principal gradient direction vector of the neighborhood window; Indicates the first Pixels at each scale The gradient direction consistency coefficient; Indicates the number of scales; This represents the vector dot product operator; Indicates the absolute value symbol; A pixel's local reflection non-ideal weight is acquired according to the pixel's stain sensitivity gradient index and the color correlation index, and the local reflection non-ideal weight satisfies the expression: ; wherein, represents a local reflection non-ideality weight of the pixel point ; represents a normalized stain sensitivity gradient index of the pixel point ; represents a color correlation index of the pixel point ; , represents a weight coefficient; is an offset; is a scaling factor; A dynamic prior gated diffuse reflectance conversion network containing a standard diffuse reflectance prediction branch and an adaptive diffuse reflectance prediction branch is constructed, comprising: A pre-trained S2D-Net model is loaded as a basic architecture, and the encoder part thereof is reserved as a shared feature extractor; A double-branch decoding structure is constructed, comprising: The standard diffuse reflectance prediction branch: the structure is the same as the original S2D-Net decoder; The adaptive diffuse reflectance prediction branch: a light-weight CNN structure containing three layers of 3x3 convolution followed by a ReLU activation function; Based on the local reflection non-ideal weight, the outputs of the standard diffuse reflectance prediction branch and the adaptive diffuse reflectance prediction branch are pixel-level weighted fused to obtain a diffuse reflectance image; Based on the diffuse reflectance image, stain detection is performed to output a stain segmentation result.

2. The machine vision-based high-voltage switch housing stain detection method of claim 1, wherein, The different filter scales comprise: Three Gaussian kernels with standard deviations of are used to filter the gray-scale image respectively.

3. The machine vision-based high voltage switch housing stain detection method of claim 1, wherein, The gradient direction consistency coefficient satisfies the expression: ; in, Indicates the first Pixels at each scale The gradient direction consistency coefficient; Represents pixels The neighborhood window; For pixels The coordinates of the pixels within the neighborhood window; For the first Pixels at each scale The principal gradient direction vector of the neighborhood window and the pixels within the neighborhood window The angle between the gradient vectors; For pixels The number of pixels contained within the neighborhood window; It is a cosine function.

4. The machine vision-based high-voltage switch housing stain detection method of claim 3, wherein, The method for obtaining the main gradient direction vector is: All the gradient vectors of the pixels in the neighborhood window of the pixel are formed into a data matrix, the covariance matrix of the data matrix is calculated, the eigenvector corresponding to the maximum eigenvalue in the covariance matrix is selected and normalized into a unit vector, and the unit vector is taken as the main gradient direction vector of the neighborhood window of the pixel.

5. The machine vision-based high voltage switch housing stain detection method of claim 1, wherein, The method for obtaining the color correlation index is: The high-voltage switch shell image is converted to the HSV color space, and the hue H, saturation S and brightness V channels are extracted; The color correlation index of the pixel satisfies the expression: ; wherein, represents a color correlation index of a pixel point ; represents a correlation coefficient of hue H and saturation S within a neighborhood of a pixel point ; represents a luminance value of a pixel point; represents an absolute value sign.​ 6. The machine vision-based high voltage switch housing stain detection method of claim 1, wherein, The method for obtaining the diffuse reflectance image is: ; wherein, represents the final diffuse reflection value of a pixel point ; represents the pixel point of the standard diffuse reflection prediction branch output; represents the pixel point of the adaptive diffuse reflection prediction branch output; represents the local reflection non-ideality weight of a pixel point ; The final diffuse reflectance values of all the pixels in the gray image are formed into a diffuse reflectance image.

7. A machine vision based high voltage switch housing stain detection system characterized by, The method comprises the following steps: A processor and a memory are provided, and the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the method for detecting stains on a high-voltage switch shell based on machine vision according to any one of claims 1-6 is realized.

Citation Information

Patent Citations

  • Method for solving high-light pollution of Go image

    CN108090950A

  • Surface dirty image recognition method applied to window cleaning robot and related device

    CN120472414A