A machine vision-based method for detecting defects in a galvanized layer on a surface of an electric iron accessory
By constructing a multi-scale Gabor filter bank and nonlinear gain weights, combined with dual-threshold hysteresis segmentation, the problem of distinguishing between zinc flower texture interference and real crack defects was solved, achieving high accuracy and robustness in the detection of galvanized layer defects in power iron accessories.
Patent Information
- Application Number
- CN202610224817.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-25
- Publication Date
- 2026-07-14
AI Technical Summary
Existing Gabor filter-based defect detection technologies cannot effectively distinguish between zinc flower texture interference on the surface of power railway accessories and actual crack defects, resulting in inaccurate detection results.
By constructing a multi-scale Gabor filter bank, utilizing the ridge phase asymmetry index and the neighborhood texture topological consistency coefficient, combined with nonlinear gain weighting and dual-threshold hysteresis segmentation, accurate differentiation of zinc flower grain boundaries and cracks and defect detection can be achieved.
It improves the accuracy of detecting defects in the galvanized layer of power railway accessories, effectively suppresses interference from zinc flower texture, preserves the true defect characteristics, and enhances the robustness and accuracy of detection.
Smart Images

Figure CN122391055A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of machine vision and image data processing technology, specifically to a machine vision-based method for detecting defects in the galvanized layer on the surface of electric railway accessories. Background Technology
[0002] As critical connecting components in power grid transmission lines, the quality of power grid iron fittings directly affects the safe and stable operation of the grid. To enhance corrosion resistance, the surface of power grid iron fittings is typically treated with hot-dip galvanizing. During the production quality inspection process, strict defect detection of the galvanized layer surface is required to promptly identify and reject workpieces with quality problems such as incomplete plating, scratches, and cracks.
[0003] Currently, automated inspection technology based on machine vision has been widely applied in this field. Its typical process includes image acquisition, preprocessing, feature extraction, and defect classification. A significant characteristic of the hot-dip galvanizing process is the formation of zinc flower crystal textures with random geometric shapes on the surface of the workpiece. These zinc flower grains have smooth surfaces, strong specular reflection properties, and their grain boundaries appear as sharp edges with high contrast in optical imaging.
[0004] Existing defect detection technologies typically employ Gabor filters to extract texture features from workpiece surfaces. These filters leverage the sensitivity of Gabor filters to specific directions and frequencies to enhance potential defect signals. However, Gabor filters primarily operate based on the amplitude response of local grayscale gradients, lacking the ability to discern deep semantic attributes of the texture. On high-quality galvanized surfaces, normal zinc spangle grain boundaries often exhibit high-frequency edge features remarkably similar to linear defects (such as scratches and cracks). When these normal grain boundary textures accidentally coincide with a pre-set defect detection filter in terms of direction and scale, the filter generates a high-amplitude spurious response. This prevents the algorithm from effectively distinguishing between physical defects and inherent material textures, leading to the misclassification of normal zinc spangles as scratches or cracks, thus reducing the accuracy of defect detection results.
[0005] Therefore, there is an urgent need for a detection method that can accurately distinguish between real defects and zinc flower patterns, while preserving defect characteristics while suppressing strong background interference. Summary of the Invention
[0006] To address the problem that existing Gabor filters cannot effectively distinguish between zinc flower texture interference and actual crack defects on the surface of power railway accessories, leading to inaccurate defect detection results, this invention proposes a machine vision-based method for detecting defects in the zinc plating layer on the surface of power railway accessories. This method includes:
[0007] A grayscale image of the galvanized layer on the surface of the electric railway accessory is obtained; a Gabor filter bank containing multiple directions and multiple scales is constructed, and convolution operation is performed on the grayscale image. The real and imaginary parts of the convolution response of each pixel in the grayscale image at different scales and directions are obtained respectively. Based on the difference between the real and imaginary parts, the ridge phase asymmetry index of the pixel is constructed to characterize the probability that the pixel belongs to a linear defect with phase symmetry characteristics. Based on the spatial distribution of the ridge phase asymmetry index of all pixels in the grayscale image, the local structure tensor of each pixel is calculated, and the local structure tensor is decomposed to determine the neighborhood dominant direction of the pixel. Based on the difference between the neighborhood dominant direction of each pixel and the neighborhood dominant direction of its neighboring pixels, the neighborhood texture topology consistency coefficient of the pixel is constructed. The nonlinear gain weight of the pixel is constructed using the neighborhood texture topology consistency coefficient. The comprehensive amplitude energy of the pixel determined by the Gabor filter bank is modulated. A semantically enhanced defect saliency map is generated based on the comprehensive amplitude energy of all pixels after modulation. The defect saliency map is segmented by double threshold hysteresis, and the defect detection results of the galvanized layer on the surface of the electric railway accessory are output.
[0008] This technical solution utilizes a multi-scale Gabor filter bank to perform physical convolution operations. Essentially, it uses a set of microscopic probes with specific frequencies and orientations to resonate with the image texture, thereby extracting all potential linear structure energies. A ridge phase asymmetry index is constructed based on the phase difference between the real and imaginary parts. This index effectively distinguishes between zinc flower grain boundaries, which manifest as step signals, and crack centers, which manifest as ridge signals, from a physical optics perspective, achieving preliminary screening of linear features. Furthermore, by calculating the local structure tensor and performing feature decomposition, the dominant texture direction of each pixel in its local neighborhood is accurately analyzed, thus establishing the microscopic vector field of texture flow. Based on this, a neighborhood texture topological consistency coefficient is introduced. This coefficient utilizes the essential difference that real physical cracks necessarily maintain directional continuity in space, while background zinc flower textures exhibit random directional variations in space, transforming simple grayscale recognition into verification of the coherence of topological structures. Finally, by constructing nonlinear gain weights to modulate the original amplitude energy and combining it with a dual-threshold hysteresis segmentation strategy, a signal gating system with physical semantic understanding capability is essentially constructed. This system suppresses high-contrast cluttered backgrounds while enhancing and accurately extracting weak but continuous defect signals, thus improving the robustness of detection.
[0009] Preferably, the ridge phase asymmetry index of a pixel satisfies the following relationship:
[0010] in, For the grayscale image, the first Ridge phase asymmetry index per pixel The total number of scales, The total number of directions, For the first The pixel at the th point The first scale and the first The real part of the convolutional response in each direction. For the first The pixel at the th point The first scale and the first The imaginary part of the convolutional response in each direction. To prevent positive numbers with a denominator of 0.
[0011] This technical solution utilizes the phase characteristics of Gabor transform in the frequency domain to achieve refined feature separation. Through this physical screening based on phase symmetry, the algorithm can significantly reduce the false edge interference generated by zinc flower grain boundaries at the source stage of feature extraction, providing a high-purity linear structure probability distribution map for subsequent topology analysis.
[0012] Preferably, based on the spatial distribution of the ridge phase asymmetry index of all pixels in the grayscale image, the local structure tensor of each pixel is calculated, including: for each pixel, calculating the gradient value of the ridge phase asymmetry index in the horizontal direction and the gradient value in the vertical direction to form the gradient vector of the pixel; calculating the matrix product of the gradient vector and the transpose of the pixel to obtain the gradient outer product matrix of the pixel; and performing spatial convolution smoothing on the gradient outer product matrix using a preset Gaussian smoothing kernel, and determining the smoothed gradient outer product matrix as the local structure tensor of the pixel.
[0013] Preferably, the method for determining the dominant neighborhood direction of a pixel by performing eigenvalue decomposition on the local structure tensor is as follows: performing eigenvalue decomposition on the local structure tensor to obtain a non-negative first eigenvalue and second eigenvalue, a first eigenvector corresponding to the first eigenvalue and a second eigenvector corresponding to the second eigenvalue, wherein the first eigenvector and the second eigenvector are mutually orthogonal; selecting the eigenvector corresponding to the larger of the first eigenvalue and the second eigenvalue as the dominant neighborhood direction of the pixel, so as to characterize the gradient principal direction with the most drastic gray-level change in the local neighborhood of the pixel.
[0014] Preferably, the neighborhood texture topology consistency coefficient of a pixel is constructed based on the following relationship:
[0015] in, For the grayscale image The neighborhood texture topological consistency coefficient of each pixel. This is an indicator of the ridge phase asymmetry of the pixel. It is a natural exponential function. For the first The total number of neighboring pixels of a pixel The index of the neighboring pixels. For the first The first pixel The dominant direction of each neighboring pixel's neighborhood. For the first The dominant direction of the neighborhood of each pixel It is a sine function. For the first The first pixel Ridge phase asymmetry index of neighboring pixels.
[0016] This technical solution constructs a nonlinear decay mechanism through an exponential function. By analyzing the geometric deviation between the center pixel and neighboring pixels in the dominant direction of the neighborhood, it introduces the ridge phase asymmetry index of the neighboring pixels as an adaptive weighting factor. Only when the texture elements in the local area are both significant and have directional consistency are they judged as potential crack structures, thereby achieving accurate suppression of background noise.
[0017] Preferably, the method for constructing the nonlinear gain weight of a pixel using the neighborhood texture topological consistency coefficient is as follows: A nonlinear mapping model with S-shaped step response characteristics is constructed; a physical boundary threshold for defining the background texture and linear defects, and a morphological adjustment parameter for controlling the model's response sensitivity are configured for the nonlinear mapping model; the neighborhood texture topological consistency coefficient of each pixel is used as an independent variable input to the nonlinear mapping model, and the independent variable is mapped to the nonlinear gain weight of the pixel through the model's S-shaped step response characteristics; the nonlinear mapping model is configured to: nonlinearly compress independent variables below the physical boundary threshold to generate inhibitory weights approaching 0, and nonlinearly saturate independent variables above the physical boundary threshold to generate enhancing weights approaching 1.
[0018] This technical solution utilizes a nonlinear mapping model to construct gain weights. Its purpose is to transform continuously changing topological consistency coefficients into gating signals with clear physical decision-making significance. This nonlinear transformation effectively stretches the contrast between defects and the background, transforming ambiguous probabilistic features into clear signal enhancement or suppression instructions, thus laying the foundation for generating defect saliency maps with high signal-to-noise ratios.
[0019] Preferably, the method for modulating the comprehensive amplitude energy of the pixel determined by the Gabor filter bank is as follows: The real and imaginary parts of the convolution response of the pixel at different scales and directions are obtained using the Gabor filter bank and superimposed to obtain the comprehensive amplitude energy of the pixel; the nonlinear gain weight of the pixel is used as a control signal to reconstruct the comprehensive amplitude energy of the pixel using a weighted average, employing a signal gating modulation strategy: if the neighborhood texture topology consistency coefficient of the pixel is higher than a preset neighborhood texture topology consistency coefficient threshold, a signal fidelity gain is generated to preserve the physical energy response; if the neighborhood texture topology consistency coefficient of the pixel is not higher than the preset neighborhood texture topology consistency coefficient threshold, a signal masking gain is generated to suppress the physical energy response.
[0020] This technical solution achieves the fusion of frequency domain features and spatial semantic features. This modulation operation does not change the physical intensity distribution of the original signal, but selectively transmits it according to the reliability of its topology, thereby maximizing the signal-to-noise ratio of the target signal relative to the background noise while preserving the physical details of the defects.
[0021] Preferably, generating a semantically enhanced defect saliency map based on the comprehensive amplitude energy modulated by all pixels involves generating an image of the same size as the grayscale image, where the pixel value of each pixel is the comprehensive amplitude energy modulated by that pixel.
[0022] Preferably, the dual-threshold hysteresis segmentation based on the defect saliency map includes: constructing a dual-threshold hysteresis segmentation strategy based on the statistical distribution of the comprehensive amplitude energy of all pixels modulated in the defect saliency map; performing topological connectivity analysis on the defect saliency map using the dual-threshold hysteresis segmentation strategy, including: locking high-confidence defect skeletons through a preset first comprehensive amplitude energy threshold, and recovering weak defect ends in the connected neighborhood of the defect skeletons through a preset second comprehensive amplitude energy threshold; and removing isolated background noise based on preset connectivity constraints to generate a binarized defect detection result.
[0023] Preferably, the defect detection results of the galvanized layer on the surface of the electric iron accessory are output, including: performing morphological connected component analysis on the binarized defect detection results to obtain multiple connected components; constructing multiple geometric descriptors that can characterize the physical morphology of the defect; constructing multidimensional morphological constraints based on all geometric descriptors; and determining the connected components with defects and the defect type based on the multidimensional morphological constraints.
[0024] The present invention has the following effects: This invention constructs a ridge phase asymmetry index to distinguish between real defects with linear characteristics and zinc flower grain boundaries with step characteristics from the underlying logic of physical optics. By calculating the neighborhood texture topological consistency coefficient, it utilizes the difference between the directional continuity of scratches and the disorder of zinc flower textures to filter out random noise caused by grain intersections. By semantic weighting to retain the original energy and combining it with dual-threshold hysteresis segmentation, it ensures that real discontinuous and subtle scratches can be effectively enhanced and detected, thereby improving the accuracy of defect detection in the galvanized layer of power railway accessories. Attached Figure Description
[0025] Figure 1 This is a schematic diagram of the method flow of the present invention; Figure 2 This is a grayscale image of the zinc plating layer on the surface of the electric iron accessory of the present invention; Figure 3 It is a composite amplitude energy map extracted from existing Gabor filter banks; Figure 4 This is a semantic enhancement saliency map generated by the present invention based on the modulation of the neighborhood texture topological consistency coefficient. Detailed Implementation
[0026] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0027] refer to Figure 1 This invention provides a machine vision-based method for detecting defects in the galvanized layer on the surface of power railway accessories, comprising: S1: Obtain a grayscale image of the galvanized layer on the surface of the electric railway accessory. Perform convolution operations through Gabor filter banks of multiple directions and scales to obtain the real and imaginary parts of the convolution response of each pixel at different scales and directions, so as to construct the ridge phase asymmetry index of the pixel.
[0028] First, images of the galvanized layer on the surface of the electric railway accessories were acquired and preprocessed to obtain grayscale images. To capture defects at different physical scales, a system was constructed based on this grayscale image, containing... One direction and To ensure that a Gabor filter bank of various scales can effectively respond to target features, it is necessary to obtain the average physical diameter and image resolution of the zinc flower grains on the zinc plating surface. Based on the average physical diameter and image resolution, a minimum wavelength parameter is calculated to ensure that the Gabor filter's bandwidth can cover the minute features within the zinc flower grain boundaries. Corresponding to wavelengths Each pixel covers a frequency band ranging from minor scratches to wider cracks. directional interval is ,cover arrive The spatial orientation can cover anisotropic linear defect characteristics. With the above parameter configuration, the Gabor filter bank can form a dense detection grid in the frequency domain and spatial domain.
[0029] Subsequently, the filter bank is used to perform convolution operations on the grayscale image, and the real and imaginary parts of the convolution response of each pixel at different scales and directions are obtained. When the texture features at a certain point in the grayscale image match the current filter parameters in width and direction, the two will resonate strongly and output a very large response value; otherwise, if the texture is messy or mismatched, a very small response value is output. This step realizes the preliminary physical screening of potential features.
[0030] Next, the modulus calculation is performed: the response of a Gabor filter is a complex number containing a real part and an imaginary part. In actual imaging, a crack may appear as a white background with a black line, or it may appear as a black background with a white line depending on the angle of illumination. These two cases are opposite in mathematical phase representation, appearing as positive and negative, but the physical texture intensity they represent is consistent. Calculating the modulus of the complex number aims to eliminate the influence of phase shift and retain only the physical intensity of the signal.
[0031] Finally, full-band energy aggregation is performed to determine the overall amplitude energy: for each pixel in the grayscale image, the moduli calculated at all scales and in all directions are summed to obtain the overall amplitude energy of that pixel. The overall amplitude energy does not distinguish between specific texture orientations; it simply reflects whether there is a significant texture change at that pixel. At this point, the overall amplitude energy is high for both pixels with crack defects and pixels at the edge of normal zinc spangle textures.
[0032] To further distinguish between linear defects and normal zinc flower boundaries, after obtaining multi-scale convolution responses, considering that real scratches or cracks usually appear as ridges or valleys of a certain width in optical images, this structure corresponds to phase symmetry features (i.e., strong even symmetry components) in signal processing; while zinc flower grain boundaries usually appear as step edges between grains with different reflectivities, this structure corresponds to phase antisymmetry features (i.e., strong odd symmetry components).
[0033] Therefore, by utilizing this physical law, an index that can quantify phase symmetry can be constructed to distinguish between defects and background from the components of the signal, and to initially eliminate pseudo-defect interference.
[0034] Specifically, for each pixel in a grayscale image, the ridge phase asymmetry index is calculated:
[0035] in, For the grayscale image Ridge phase asymmetry index per pixel The total number of scales, The total number of directions, For the first The pixel at the th point The first scale and the first The real part of the convolution response in each direction reflects the even-symmetric components of the signal (ridge / valley features). For the first The pixel at the th point The first scale and the first The imaginary part of the convolution response in each direction reflects the odd symmetric components (edge features) of the signal. To prevent positive numbers with a denominator of 0.
[0036] This relationship utilizes the phase characteristics of the Gabor transform in the frequency domain to achieve refined feature separation. The boundary of zinc flower crystals usually exhibits step-like edge features, with the imaginary part energy dominating in the frequency domain response; while defects such as cracks or scratches usually exhibit lines with a certain width, i.e. ridge features, with the real part energy dominating and the phase remaining highly consistent across different scales.
[0037] The numerator term, by calculating the difference between the absolute values of the real and imaginary responses and introducing a non-negative truncation operation, mathematically suppresses the imaginary-dominated step edge response while enhancing the real-dominated symmetrical ridge response. The denominator term, acting as an energy normalization factor, eliminates the influence of local image contrast variations on the index value, ensuring that the index reflects only the structural properties of the texture rather than its brightness attributes.
[0038] Therefore, the calculated ridge phase asymmetry index is used to reflect the probability that a pixel belongs to a linear defect with phase symmetry characteristics. The larger the ridge phase asymmetry index, the stronger the ridge feature of the pixel, indicating that the pixel is more likely to be in a linear defect region. The smaller the ridge phase asymmetry index, the more the pixel tends to be at a step edge or flat region, and the more likely it is to be at the boundary of a zinc flower crystal.
[0039] By accumulating contributions from all scales and directions and utilizing the competition between real and imaginary parts, soft classification of signal types was achieved. This resulted in the suppression of high-frequency edge responses caused by zinc flower grain boundaries while preserving the true scratch signal, providing high-purity feature maps for subsequent processing.
[0040] S2: Based on the spatial distribution of the ridge phase asymmetry index, a local structure tensor is constructed and feature decomposition is performed to determine the neighborhood dominant direction of the pixel. Based on the difference in the neighborhood dominant direction, the neighborhood texture topological consistency coefficient is determined.
[0041] After determining the phase features of a single pixel, given the possibility of isolated noise or subtle defects with indistinct local phase features in the image, directly calculating the gradient of a single pixel is often susceptible to interference from imaging noise or minute texture fluctuations, leading to unstable orientation estimation. Real scratches have spatial continuity and directional consistency, meaning that the gradient directions of adjacent pixels often point in the same direction, while zinc flower texture networks are chaotic, with their gradient directions changing drastically in local areas.
[0042] Therefore, this step aims to introduce spatial topological constraints, use structural tensors to analyze the directional distribution within the local neighborhood, and construct a consistency coefficient. The purpose is to leverage the prior knowledge that textures are ordered to further clean the feature map, enhance continuous defects, and suppress cluttered backgrounds.
[0043] First, a local structure tensor is constructed based on the ridge phase asymmetry index: For each pixel, the gradient values of the ridge phase asymmetry index in the horizontal and vertical directions are calculated to form the gradient vector of that pixel. The matrix product of the gradient vector and its transpose is then calculated to obtain the gradient outer product matrix of that pixel. A preset Gaussian smoothing kernel with a standard deviation of 1.5 is used. The gradient direction of a single pixel is highly susceptible to fluctuations caused by imaging noise or the randomness of zinc flower microtextures. Therefore, the scale of the Gaussian smoothing kernel needs to be slightly larger than the average edge width of the zinc flower grain boundary to eliminate local random directional noise through weighted averaging and extract the dominant texture flow direction in the neighborhood, thereby ensuring the robustness of subsequent topological consistency analysis. The gradient outer product matrix is then spatially convolved and smoothed using the Gaussian smoothing kernel, and the smoothed gradient outer product matrix is used as the local structure tensor of that pixel.
[0044] Thus, by constructing a local structure tensor, the gradient information of a single pixel is transformed into statistical features of the texture flow direction in a local region. The gradient vectors of the phase index in the horizontal and vertical directions are calculated, and then the gradient outer product matrix is constructed. This step maps the direction information of the gradient vector to the tensor space. A Gaussian smoothing kernel is introduced to perform spatial convolution processing on the outer product matrix. This operation is physically equivalent to performing a weighted statistical average within the neighborhood of the pixel. The overall texture trend within the neighborhood is used to correct the instantaneous gradient direction of the center point. Through this tensor diffusion mechanism, random directional fluctuations caused by local noise can be smoothed out, thereby stably extracting the dominant texture direction within the neighborhood of the pixel, providing a foundation for subsequent accurate calculation of the consistency of texture direction.
[0045] Then, feature decomposition based on the local structure tensor is used to determine the dominant neighborhood direction of the pixel. In mathematics, the structure tensor matrix is a positive semi-definite symmetric matrix. Eigenvalue decomposition yields two orthogonal eigenvectors and their corresponding eigenvalues describing the local geometry. The eigenvector corresponding to the larger eigenvalue points precisely in the direction of the most dramatic change in local image grayscale or feature indicators—the normal direction of the texture edge. The eigenvector corresponding to the smaller eigenvalue points to the tangent direction of the texture extension. Selecting the eigenvector corresponding to the larger eigenvalue as the dominant neighborhood direction essentially locks the gradient principal axis of the local texture. Compared to directly using the tangent direction, the gradient principal axis has higher numerical stability, especially when dealing with blurred or low-contrast edges, and can more accurately represent the geometric normal information of the texture. This ensures that subsequent steps comparing the texture directions of different pixels are based on a precise and physically meaningful geometric benchmark, avoiding the failure of topological consistency analysis due to direction estimation errors.
[0046] Therefore, for each pixel, the local structure tensor of the pixel is subjected to eigenvalue decomposition to obtain a non-negative first eigenvalue and second eigenvalue, a first eigenvector corresponding to the first eigenvalue and a second eigenvector corresponding to the second eigenvalue, and the first eigenvector and the second eigenvector are mutually orthogonal; the eigenvector corresponding to the larger of the first eigenvalue and the second eigenvalue is selected as the dominant direction of the neighborhood of the pixel to characterize the gradient principal direction of the most drastic gray-level change in the local neighborhood of the pixel.
[0047] Finally, determine the neighborhood texture topology consistency coefficient of each pixel:
[0048] in, For the grayscale image The neighborhood texture topology consistency coefficient of a pixel reflects the degree of order of the pixel and its neighborhood texture. The larger the neighborhood texture topology consistency coefficient, the more likely the pixel is in a linear structure with a consistent direction, and the smaller the coefficient, the more likely the pixel is in a messy texture. The first grayscale image Ridge phase asymmetry index per pixel It is a natural exponential function. For the first The total number of neighboring pixels of a pixel The index of the neighboring pixels. For the first The first pixel The dominant direction of each neighboring pixel's neighborhood. For the first The dominant direction of the neighborhood of each pixel. It is a sine function. For the first The first pixel Ridge phase asymmetry index of neighboring pixels.
[0049] In this relation, As a basic item, it reflects the probability that the pixel belongs to a linear defect. The larger the value, the stronger the ridge phase asymmetry feature of the pixel itself, and the higher the basic probability of it belonging to a linear structure such as a potential crack or grain boundary.
[0050] In this relation, the exponent term A nonlinear adjustment factor based on topology was constructed, which adjusts the value of the first pixel based on the topological consistency of its neighboring pixels. The saliency intensity of each pixel is adjusted: the larger the value of the exponent term, the closer it is to 1, which means that the neighborhood texture direction is highly coordinated, confirming a continuous structure; the smaller the value of the exponent term, the closer it is to 0, which means that the neighborhood texture is disordered, confirming interference noise.
[0051] Specifically, the physical logic for each item is as follows: It is a geometric deviation term, reflecting the first The geometric deviation between a pixel and its neighboring pixels in the dominant direction of the neighborhood represents the degree of directional conflict in physical space. The larger the geometric deviation, the more perpendicular the textures of the two pixels tend to be, indicating a severe conflict; the smaller the deviation, the more parallel the textures of the two pixels tend to be, indicating a consistent direction.
[0052] Introducing the ridge phase asymmetry index of neighboring pixels As an adaptive confidence-gated weight, it is used to effectively filter the degree of directional conflict, realizing the intelligent logic of analyzing directional consistency only when neighborhood features are significant. This effectively avoids the interference of unstructured noise on topology analysis. Its core physical logic lies in constructing a difference penalty mechanism based on feature saliency. When neighboring pixels have a high ridge phase asymmetry index A larger value indicates that the neighboring pixel is physically a significant structural feature point within a high signal-to-noise ratio region. However, if the dominant neighborhood direction of this neighboring pixel deviates significantly from the dominant neighborhood direction of the center pixel, then... If the deviation is large, it is considered a valid structural contradiction, and the algorithm uses the larger deviation. This amplifies the attenuation effect of the conflict on the neighborhood texture topological consistency coefficient, thereby strongly suppressing messy zinc flower texture responses. When neighboring pixels are in flat areas or background areas, When the value approaches 0, even if the dominant neighborhood direction of the neighboring pixel itself deviates significantly from the dominant neighborhood direction of the center pixel, The deviation is large, and it is also considered invalid random noise, utilizing weights that approach 0. The effects of directional conflicts are automatically masked to prevent background noise from disrupting the topological continuity score of the real crack.
[0053] The final effect is that if the first A neighboring pixel of a given pixel has a high ridge saliency. If it is very large, it indicates that it is a strong feature point. In this case, if its direction is not consistent with the center point, A large value indicates strong interference from messy textures in the region. The more likely the pixel is to be located at an intersecting zinc flower grain boundary, the larger the product of the two becomes. The overall nonlinearity of the function decreases and approaches 0, thus affecting the fundamental terms. The intensity attenuation suppresses strong linear textures like zinc flower grain boundaries. Conversely, if the orientation of neighboring pixels is consistent with the height of the center point, The noise is very small, or the neighboring pixels themselves are background noise. If the noise is very small, and the random direction of the noise is not of reference value, then the smaller the product of the two becomes, the closer it is to 0. The overall nonlinearity of the function increases and approaches 1, thereby achieving the effect on the fundamental terms. The strength is preserved.
[0054] In summary, by multiplying single-point features with neighborhood statistical features, a leap from independent pixel judgment to joint verification of local neighborhoods is achieved. Only those pixels that have both phase symmetry (image line) and spatial orientation consistency (continuity) are retained, thereby improving the confidence of subsequent defect detection.
[0055] If a pixel has a large ridge phase asymmetry index, and its neighboring pixels also have large ridge phase asymmetry indices and are in the same direction, the larger the neighborhood texture topology consistency coefficient, the more likely the pixel is to be in a real linear defect region. If a neighboring pixel has a large ridge phase asymmetry index but is in a chaotic direction, the smaller the neighborhood texture topology consistency coefficient, the more likely the pixel is to be in a real zinc flower grain boundary region.
[0056] S3: Modulate the overall amplitude energy of the pixel determined by the Gabor filter bank using the neighborhood texture topology consistency coefficient to generate a semantically enhanced defect saliency map.
[0057] After obtaining a highly reliable neighborhood texture topological consistency coefficient, although it can distinguish defects from the background well, the neighborhood texture topological consistency coefficient itself is a probability value that has undergone multiple nonlinear transformations, which may lose some grayscale energy details in the original image (such as the depth of defects).
[0058] To obtain a final defect detection result that is both pure and preserves texture details, this step aims to feed the extracted semantic information back to the original signal and modulate it. This is equivalent to adding a smart filtering operation to the original image, allowing only pixels in the defect area to pass through. Finally, a dual threshold hysteresis technique is used to solve the weak connectivity problem.
[0059] First, the non-linear gain weights of pixels are constructed using the neighborhood texture topological consistency coefficient: A nonlinear mapping model with S-shaped step response characteristics is constructed. This model is configured with a physical boundary threshold to define the background texture and linear defects, and a morphological adjustment parameter to control the model's response sensitivity. The physical boundary threshold clearly defines the critical point in the consistency probability of background clutter and defect signals, while the morphological adjustment parameter controls the sensitivity of state transitions. The neighborhood texture topological consistency coefficient of each pixel is used as an independent variable input to the nonlinear mapping model. The S-shaped step response characteristics of the model map the independent variables to nonlinear gain weights for that pixel. The nonlinear mapping model is configured to perform the following physical filtering logic: nonlinear compression is applied to independent variables below the physical boundary threshold to generate inhibitory weights approaching 0; nonlinear saturation is applied to independent variables above the physical boundary threshold to generate enhancing weights approaching 1.
[0060] Then, using the nonlinear gain weight of the pixel as a control signal, the comprehensive amplitude energy of the pixel is reconstructed by weighting. The signal gating modulation strategy is configured as follows: if the neighborhood texture topology consistency coefficient of the pixel is higher than the preset neighborhood texture topology consistency coefficient threshold, a signal fidelity gain is generated to preserve the physical energy response; if the neighborhood texture topology consistency coefficient of the pixel is not higher than the preset neighborhood texture topology consistency coefficient threshold, a signal shielding gain is generated to suppress the physical energy response.
[0061] Specifically, the following relationship is satisfied:
[0062] In this formula, This represents the final defect saliency map value. For the first The combined amplitude energy of each pixel reflects the original intensity of the image texture. The part in parentheses on the right is a non-linear mapping model based on the Sigmoid function, which calculates the neighborhood texture topological consistency coefficient of each pixel. As the independent variable, it is mapped to a nonlinear gain weight. It is an adjustment coefficient that controls the steepness of the control function. It is a natural constant. It is the threshold of the neighborhood texture topology consistency coefficient.
[0063] This formula constructs a soft-threshold signal gating system based on the Sigmoid function, realizing a nonlinear mapping from the original energy field to semantic enhancement. This reflects the original texture intensity of the pixel in the Gabor frequency domain. It contains a mixture of high-energy real defects and high-energy zinc flower grain boundary interference, relying solely on The two cannot be distinguished; the brackets together constitute a non-linear gain weight: the neighborhood texture topological consistency coefficient of the pixel. As the independent variable, 0.5 is the physical boundary threshold, which is the critical point that defines the background cluttered texture and the foreground linear defect texture. The steepness of the function was controlled, i.e., the sensitivity of the switch was adjusted. The larger the threshold, the more drastic the change in the sigmoid curve near the threshold, and the stronger its ability to distinguish between blurred regions. The value is set between 10 and 20, with 15 being preferred, because... The steepness of the nonlinear mapping function is determined by setting a larger value, which makes the Sigmoid function exhibit a step-like response characteristic around the threshold of 0.5. This ensures that when the neighborhood texture topological consistency coefficient is slightly lower than the threshold (corresponding to zinc flower texture), the gain weight rapidly decays to 0, thereby completely suppressing background interference. When the neighborhood texture topological consistency coefficient is slightly higher than the threshold (corresponding to crack), the gain weight rapidly saturates to 1, thereby maximizing the preservation of the defect signal and achieving high-contrast binarization segmentation pre-enhancement.
[0064] Thus, through a mathematical nonlinear compression and saturation mechanism, a rigorous physical selection logic is executed: when a pixel is in the zinc flower background region, At this point, the exponent term The rapid increase leads to a dramatic increase in the denominator, causing the nonlinear gain weight to decrease and approach 0. The gate is closed, regardless of the original No matter how strong the noise is, it will be suppressed, thus achieving the shielding of high-intensity background noise.
[0065] When a pixel is located in a crack defect area At this point, the exponent term As the value rapidly decreases and approaches 0, the denominator approaches 1, the nonlinear gain weight increases to saturation, and then approaches 1. The gate opens, allowing access. Non-destructive testing achieves physical fidelity of weak defect signals, preserving details of grayscale variations within linear defects.
[0066] In summary, this adjustment method constructs an intelligent filter based on physical topology cognition, which completely eliminates zinc spangle interference while preserving the true physical characteristics of linear defects to the greatest extent.
[0067] Finally, a semantically enhanced defect saliency map is generated based on the combined amplitude energy modulated by all pixels. The defect saliency map has the same size as the grayscale image, the only difference being that the pixel value of each pixel in the defect saliency map is the combined amplitude energy modulated by that pixel.
[0068] S4: Perform double-threshold hysteresis segmentation based on the defect saliency map to determine the defect detection results.
[0069] After obtaining the semantically enhanced defect saliency map, an adaptive dual-threshold hysteresis segmentation strategy based on statistical distribution is adopted in order to transform the continuously changing energy field into a defined binary defect region, aiming to solve the common discontinuity problem of cracks in imaging.
[0070] First, histogram statistical analysis is performed on the modulated energy of all pixels in the defect saliency map. Based on the statistical distribution, the system selects the top 5% to 10% quantiles of non-zero pixel energy values as a high threshold. This high threshold serves as a stringent physical threshold to identify pixels in the image with extremely high energy and confidence, marking them as high-confidence defect skeletons. The physical significance of this step is to ensure the accuracy of the detection results; that is, any pixel selected by the high threshold must be a real defect core, and not a noise false alarm.
[0071] Subsequently, a low threshold was set as a certain proportion of the high threshold, specifically 0.4 times the high threshold. Recursive topological connectivity tracing was then performed within the 8-neighborhood of each pixel in the defined defect skeleton. For any pixel adjacent to the skeleton, if its modulated composite amplitude energy was higher than the low threshold, it was identified as a natural extension or weak tip of the defect and included in the defect region. This strategy effectively recovered the tails of linear defects that were below the high threshold due to signal attenuation, ensuring the integrity of the linear defects. Isolated pixels between the high and low thresholds but without physical connection to the defect skeleton were identified as background noise and removed, thus generating a clean binary defect mask.
[0072] Next, in order to further improve the reliability of the detection results to meet the requirements of industrial applications, the system performs final morphological and geometric feature analysis on the generated binarized results to remove artifacts and output the specific defect type.
[0073] A two-pass scanning method is used to label the connected components of the binary image. Each spatially connected set of foreground pixels is extracted as an independent connected domain. For each connected domain, the system calculates a geometric descriptor that can accurately represent its physical shape, focusing on pixel area and length, width and slenderness calculated based on the minimum bounding rectangle. It is particularly important to note that calculating the minimum bounding rectangle instead of the ordinary axis-aligned rectangle is crucial because real cracks are often obliquely distributed. The minimum bounding rectangle can rotate with the defect direction, thus most realistically reflecting the aspect ratio of the defect.
[0074] Based on the aforementioned geometric descriptors, the system performs multi-dimensional morphological constraint screening: First, it performs denoising constraints, identifying tiny connected regions with pixel areas smaller than a preset area threshold (preferably set to 5 pixels) as non-structural spots caused by sensor thermal noise or surface dust, and directly discarding them. Second, it performs classification constraints, determining the physical properties of the remaining connected regions based on aspect ratio. If the aspect ratio of the connected region is higher than a preset morphological threshold (preferably set to 3.0), it indicates that the defect exhibits elongated characteristics and is classified as a linear crack defect. If the aspect ratio of the connected region is lower than the morphological threshold and the compactness is high, it indicates that the defect shape tends to be circular or square, and the system classifies it as point-like peeling or porosity defects.
[0075] Ultimately, the output includes detection results containing precise location coordinates, geometric contours, and specific defect types, achieving a complete leap from pixel-level segmentation to object-level semantic cognition.
[0076] To visually demonstrate the advantages of the method of this invention in suppressing zinc spangle interference and preserving weak defects, the following is in conjunction with the appendix. Figures 2 to 4 Comparative analysis: like Figure 2 As shown, the image intuitively demonstrates the typical working conditions of hot-dip galvanized surfaces of electric railway accessories. The image is filled with zinc flower grains of various shapes and uneven brightness. The boundaries of these grains appear as sharp edges with high contrast in grayscale space, forming an extremely complex and textured background. Under naked-eye observation, real micro-cracks are often submerged in these messy zinc flower textures and are extremely difficult to identify. This is the physical root cause of the false detections that traditional machine vision algorithms are prone to.
[0077] like Figure 3As shown, the composite amplitude energy distribution of all pixels extracted using only a multi-scale Gabor filter bank is displayed. It can be seen that although the Gabor filter captures the potential crack signal, the zinc flower grain boundaries also have high-frequency edge features, which cause them to have a strong frequency domain response with the filter. This results in the entire image being filled with high-brightness artifact noise. The signal intensity of the crack signal and the background noise are on the same order of magnitude, resulting in an extremely low signal-to-noise ratio. It is impossible to effectively distinguish between structural defects and unstructured textures by relying solely on the frequency domain amplitude features.
[0078] like Figure 4 As shown, a salience diagram illustrating the defects of the present invention is presented, and... Figure 3 In contrast, Figure 4 Background noise is significantly suppressed, and the entire background area appears as a pure black. This is because the neighborhood texture topological consistency coefficient introduced in this invention plays a gating role: although zinc flower grain boundaries have high energy, their random orientation and topological discontinuity cause their gain weight to be nonlinearly compressed to 0, achieving shielding. Meanwhile, real cracks, due to their spatial directional continuity, have their gain weight saturated to 1, achieving signal fidelity. Ultimately, cracks in the image are accurately preserved, enabling accurate extraction of weak defect signals.
[0079] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A machine vision-based method for detecting defects in the galvanized layer on the surface of electric railway accessories, characterized in that, include: A grayscale image of the galvanized layer on the surface of the electric railway accessory is obtained; a Gabor filter bank containing multiple directions and multiple scales is constructed, and convolution operation is performed on the grayscale image. The real and imaginary parts of the convolution response of each pixel in the grayscale image at different scales and directions are obtained respectively. Based on the difference between the real and imaginary parts, the ridge phase asymmetry index of the pixel is constructed to characterize the probability that the pixel belongs to a linear defect with phase symmetry characteristics. Based on the spatial distribution of the ridge phase asymmetry index of all pixels in the grayscale image, the local structure tensor of each pixel is calculated, and the local structure tensor is decomposed to determine the neighborhood dominant direction of the pixel. Based on the difference between the neighborhood dominant direction of each pixel and the neighborhood dominant direction of its neighboring pixels, the neighborhood texture topology consistency coefficient of the pixel is constructed. The nonlinear gain weight of the pixel is constructed using the neighborhood texture topology consistency coefficient. The comprehensive amplitude energy of the pixel determined by the Gabor filter bank is modulated. A semantically enhanced defect saliency map is generated based on the comprehensive amplitude energy of all pixels after modulation. The defect saliency map is segmented by double threshold hysteresis, and the defect detection results of the galvanized layer on the surface of the electric railway accessory are output.
2. The method for detecting defects in the galvanized layer on the surface of power railway accessories according to claim 1, characterized in that, The ridge phase asymmetry index of a pixel satisfies the following relationship: ; in, For the grayscale image, the first Ridge phase asymmetry index per pixel The total number of scales, The total number of directions, For the first The pixel at the th point The first scale and the first The real part of the convolutional response in each direction. For the first The pixel at the th point The first scale and the first The imaginary part of the convolutional response in each direction. To prevent positive numbers with a denominator of 0.
3. The method for detecting defects in the galvanized layer on the surface of power railway accessories according to claim 1, characterized in that, Based on the spatial distribution of the ridge phase asymmetry index of all pixels in the grayscale image, the local structure tensor of each pixel is calculated, including: For each pixel, calculate the gradient values of the ridge phase asymmetry index in the horizontal and vertical directions to form the gradient vector of the pixel; calculate the matrix product of the gradient vector and the transpose of the pixel to obtain the gradient outer product matrix of the pixel; use a preset Gaussian smoothing kernel to perform spatial convolution smoothing on the gradient outer product matrix, and determine the smoothed gradient outer product matrix as the local structure tensor of the pixel.
4. The method for detecting defects in the galvanized layer on the surface of power railway accessories according to claim 1, characterized in that, The method for determining the dominant neighborhood direction of a pixel by performing eigenvalue decomposition on the local structure tensor is as follows: Eigenvalue decomposition is performed on the local structure tensor to obtain non-negative first and second eigenvalues, first eigenvectors corresponding to the first eigenvalues, and second eigenvectors corresponding to the second eigenvalues. The first and second eigenvectors are orthogonal to each other. The eigenvector corresponding to the larger of the first and second eigenvalues is selected as the dominant neighborhood direction of the pixel to characterize the gradient direction with the most drastic gray-level changes in the local neighborhood of the pixel.
5. The method for detecting defects in the galvanized layer on the surface of power railway accessories according to claim 1, characterized in that, The neighborhood texture topological consistency coefficient of a pixel is constructed based on the following relationship: ;in, For the grayscale image, the first The neighborhood texture topological consistency coefficient of each pixel. This is an indicator of the ridge phase asymmetry of the pixel. It is a natural exponential function. For the first The total number of neighboring pixels of a pixel The index of the neighboring pixels. For the first The first pixel The dominant direction of each neighboring pixel's neighborhood. For the first The dominant direction of the neighborhood of each pixel It is a sine function. For the first The first pixel Ridge phase asymmetry index of neighboring pixels.
6. The method for detecting defects in the galvanized layer on the surface of power railway accessories according to claim 1, characterized in that, The method for constructing the nonlinear gain weight of a pixel using the neighborhood texture topological consistency coefficient is as follows: A nonlinear mapping model with S-shaped step response characteristics is constructed. A physical boundary threshold for defining the background texture and linear defects, and morphological adjustment parameters for controlling the model's response sensitivity are configured for the nonlinear mapping model. The neighborhood texture topological consistency coefficient of each pixel is used as an independent variable input to the nonlinear mapping model. The independent variable is mapped to the nonlinear gain weight of the pixel through the model's S-shaped step response characteristics. The nonlinear mapping model is configured to: nonlinearly compress independent variables below the physical boundary threshold to generate inhibitory weights approaching 0, and nonlinearly saturate independent variables above the physical boundary threshold to generate enhancing weights approaching 1.
7. The method for detecting defects in the galvanized layer on the surface of power railway accessories according to claim 1, characterized in that, The method for modulating the overall amplitude energy of the pixel determined by the Gabor filter bank is as follows: The real and imaginary parts of the convolution response of the pixel at different scales and directions are obtained using a Gabor filter bank and then superimposed to obtain the comprehensive amplitude energy of the pixel. The nonlinear gain weight of the pixel is used as a control signal to reconstruct the comprehensive amplitude energy of the pixel using a signal gating modulation strategy: if the neighborhood texture topology consistency coefficient of the pixel is higher than the preset neighborhood texture topology consistency coefficient threshold, a signal fidelity gain is generated to preserve the physical energy response; if the neighborhood texture topology consistency coefficient of the pixel is not higher than the preset neighborhood texture topology consistency coefficient threshold, a signal masking gain is generated to suppress the physical energy response.
8. The method for detecting defects in the galvanized layer on the surface of power railway accessories according to claim 7, characterized in that, The semantically enhanced defect saliency map generated based on the comprehensive amplitude energy modulated by all pixels is an image of the same size as the grayscale image, in which the pixel value of each pixel is the comprehensive amplitude energy modulated by that pixel.
9. The method for detecting defects in the galvanized layer on the surface of power railway accessories according to claim 1, characterized in that, Dual-threshold hysteresis segmentation based on defect saliency maps includes: Based on the statistical distribution of the comprehensive amplitude energy of all pixels in the defect saliency map after modulation, a dual-threshold hysteresis segmentation strategy is constructed. The dual-threshold hysteresis segmentation strategy is used to perform topological connectivity analysis on the defect saliency map, including: locking the high-confidence defect skeleton by using a preset first comprehensive amplitude energy threshold, and recovering the weak defect ends in the connected neighborhood of the defect skeleton by using a preset second comprehensive amplitude energy threshold; removing isolated background noise based on preset connectivity constraints to generate binarized defect detection results.
10. The method for detecting defects in the galvanized layer on the surface of power railway accessories according to claim 9, characterized in that, Output the defect detection results of the galvanized layer on the surface of the power iron accessories, including: Morphological connected component analysis is performed on the binarized defect detection results to obtain multiple connected components; multiple geometric descriptors that can characterize the physical morphology of defects are constructed, multidimensional morphological constraints are constructed based on all geometric descriptors, and connected components with defects and defect types are determined based on multidimensional morphological constraints.