Galvanized angle steel defect detection method
By using dual-camera image acquisition and edge geometry correction, combined with adaptive segmentation and an improved convolutional network, the problems of image distortion and occlusion in the detection of galvanized angle steel were solved, achieving high-precision and robust defect identification.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- LINYI HAOZHENG IRON TOWER MFG CO LTD
- Filing Date
- 2025-12-04
- Publication Date
- 2026-05-01
AI Technical Summary
In existing technologies, the inspection of galvanized angle steel relies on human vision, which is highly subjective and has a high rate of missed detection. Machine vision inspection, on the other hand, suffers from image distortion and occlusion problems caused by the three-dimensional structure, which affect the accuracy of defect identification.
Images are acquired symmetrically using dual cameras. Image standardization is achieved through edge geometric correction and registration reconstruction. Defect features are extracted and graded by combining adaptive segmentation and an improved convolutional neural network model.
It achieves standardized acquisition of full-surface images of galvanized angle steel, improves the ability to detect minute defects, ensures high accuracy and robustness, and adapts to stable identification in complex industrial environments.
Smart Images

Figure CN121963175A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of machine vision technology, and in particular relates to a method for detecting defects in galvanized angle steel. Background Technology
[0002] Galvanized angle steel is a crucial basic material in the industrial chain of power transmission towers, building steel structures, and rail transit facilities. The quality of its surface galvanized layer directly affects the corrosion resistance and service life of the galvanized angle steel. In actual production, galvanized angle steel is prone to surface defects such as incomplete galvanizing, zinc nodules, pitting, and scratches. These defects are often characterized by small size, diverse shapes, and irregular distribution. Traditional inspection methods mainly rely on human vision, judging galvanized layer defects through manual visual inspection on an assembly line. However, this method has significant shortcomings, such as strong human subjectivity, high rate of missed detection, high repetitive labor intensity, and difficulty in ensuring inspection consistency, failing to meet the quality inspection requirements of modern steel structure manufacturing industry for high speed, high consistency, and high reliability. Existing machine vision inspection methods mainly use a single camera to analyze a certain surface area of the angle steel. However, due to the L-shaped cross-section and three-dimensional angled structure of galvanized angle steel, uncontrollable posture deviations, viewing angle distortions, surface reflections, and shadow occlusions are easily generated during the imaging process, resulting in significant geometric distortion in the captured images. Geometric distortion not only disrupts the spatial consistency of an image, but also affects subsequent defect segmentation and feature extraction capabilities of deep learning models, ultimately leading to a decrease in defect recognition accuracy. Summary of the Invention
[0003] In view of the technical problems existing in the background art, the present invention proposes a method for detecting defects in galvanized angle steel.
[0004] To achieve the above objectives, the technical solution adopted by the present invention includes the following steps:
[0005] S1. Angle steel attitude positioning and image acquisition: A dual-camera symmetrical acquisition system is set up, with the optical axes of the two cameras forming angles of 45° to 60° with the two flanges of the galvanized angle steel, and the optical axes of the two cameras intersecting at the midpoint of the edge in the plane where the angle steel edge is located; the real-time placement attitude of the angle steel is obtained through infrared positioning, and the cameras are driven to synchronously acquire surface images of the two flanges.
[0006] S2. Geometric correction of flange image: Based on the L-shaped structure features of angle steel, the edge contours in the acquired surface image are extracted, a local coordinate system is established with the edge as the reference, and the tilt distortion of the flange image is corrected by perspective transformation to obtain the orthographic projection standard image of the two flanges.
[0007] S3. Multi-faceted image registration and complete surface reconstruction: Using the extracted edge feature points as the registration reference, calculate the coordinate transformation matrix of the two flange standard images, map one flange image to the coordinate system of the other flange image, realize seamless splicing at the edge connection, and reconstruct a complete image of the entire surface of the galvanized angle steel.
[0008] S4. Defect region segmentation of galvanized layer: Based on the gray-scale uniformity characteristics of the galvanized layer, an adaptive threshold segmentation algorithm is used to segment suspected defect regions from the complete image.
[0009] S5. Input the suspected defect area image into the improved convolutional neural network model, wherein the improved convolutional neural network model includes a feature extraction module, a defect feature enhancement module, and a defect level mapping module.
[0010] The feature extraction module is used to extract basic defect features from suspected defect region images using an improved depthwise separable convolutional structure.
[0011] The defect feature enhancement module introduces a channel-space dual attention mechanism. The channel attention branch calculates weights based on the information entropy of the feature channels, focusing on high information density channels related to defects. The spatial attention branch uses adaptive pooling and convolution operations to locate the spatial position of suspected defects and enhance the feature response of the region, while suppressing low-value features corresponding to background noise and outputting target defect features with high signal-to-noise ratio.
[0012] The defect level mapping module is used to first integrate and abstract the feature dimensions of the target defect features through a fully connected layer, then input the integrated features into a Softmax classifier, and finally the classifier maps the features to a preset defect level.
[0013] Preferably, step S2, flange image geometric correction, involves extracting the edge contours from the acquired surface image based on the L-shaped structure features of the angle steel, establishing a local coordinate system with the edges as a reference, and correcting the tilt distortion of the flange image through perspective transformation to obtain the orthographic projection standard images of the two flanges.
[0014] S21. First, the acquired image is preprocessed. A Gaussian smoothing filter is applied to the acquired flange surface image to remove environmental noise interference. The filter kernel size is set to 3×3. Then, a grayscale stretching transformation is used to enhance the grayscale contrast between the edge and the flange surface. The transformation formula is: ,in The original acquired image pixel grayscale values, These are the maximum and minimum values of the original acquired image, respectively. These are the stretched pixel grayscale values;
[0015] S22. Use the improved Canny operator to enhance the grayscale difference recognition between the edge and the flange surface, and extract the complete edge contour;
[0016] S23. Locate the feature points of the edge, perform polynomial fitting on the extracted edge contour and obtain the fitting parameters using the least squares method, and identify the starting point of the edge based on the fitting results. ,end and midpoint ;
[0017] S24, using the midpoint of the edge With the origin as the coordinate system origin, the tangent direction of the fitted line on the edge is the u-axis of the local coordinate system, and the direction perpendicular to the tangent and pointing inward to the flange surface is the v-axis, establishing a two-dimensional local coordinate system; where the u-axis direction vector... Calculated using the coordinate difference between the starting and ending points of the edge: v-axis direction vector The calculation is as follows: ;
[0018] S25. Based on the geometric constraints of the L-shaped angle steel structure, the standard dimensions of the flange orthographic projection are preset, including length L and width W. Three non-collinear edge feature points are selected as the original control points in the local coordinate system. , and Target control points in the corresponding standard image , and The perspective transformation matrix M is solved by controlling point pairs. The coordinate mapping of the perspective transformation satisfies: The elements of the perspective transformation matrix M are obtained by minimizing the control point mapping error using the least squares method.
[0019] S26. Finally, substitute the local coordinates (u,v) of all pixels in the flange image into the perspective transformation coordinate mapping to obtain the corrected standard coordinates (u',v'); use bilinear interpolation to fill the pixel gray values of the corrected image; repeat the above steps to obtain the orthographic projection standard images of the two flanges respectively.
[0020] Preferably, step S22 uses an improved Canny operator to enhance the grayscale difference recognition between the edge and the flange surface, and the specific implementation of extracting the complete edge contour is as follows:
[0021] S221. First, calculate the initial gradient magnitude of the preprocessed image: ,in, These are the initial x and y gradients of the Sobel operator, respectively. A gray-level enhancement weight matrix is constructed based on the initial gradients to enhance the gray-level difference between the edge region and the flange surface. The enhancement formula is as follows: ,in, These are the pixel values of the image after grayscale stretching. This represents the maximum value of the initial gradient magnitude. This is the image after gradient-weighted enhancement;
[0022] S222. Introduce an adaptive convolution kernel to obtain the dominant gradient direction of a region by fitting the local gray-level distribution. Based on Generate three orthogonal convolution kernels, calculate the gradient magnitude using each kernel, and take the maximum value as the final gradient magnitude: ,in, These are convolution kernels in three orthogonal directions;
[0023] S223. Calculate the edge confidence level using the final gradient magnitude and local grayscale difference: ,in, The mean and variance of gray levels in a 5×5 local region centered at (x,y) are given. Based on the statistical characteristics of the edge confidence of the entire image, a high threshold is determined. and low threshold : , ,in, The high confidence threshold coefficient is used. The gradient magnitude is set as a high / low threshold ratio coefficient. Compare with the threshold to obtain strong edges, Candidate weak edges and Non-edge;
[0024] S224. Using the linearity constraint of the angle steel edge, the candidate weak edge is effectively screened, and the strong edge is fitted with a straight line to obtain the fitted straight line. The distance from each candidate weak edge pixel to the fitted straight line is calculated. Only candidate weak edges with a distance less than or equal to a set threshold are retained. Then, for the discontinuous region formed by the strong edge and the screened weak edge, edge pixels are interpolated along the direction of the fitted straight line to supplement the edge pixels, and finally a continuous and complete edge contour is obtained.
[0025] Preferably, step S3, multi-faceted image registration and complete surface reconstruction, involves using the extracted edge feature points as the registration reference, calculating the coordinate transformation matrix of the two flange standard images, mapping one flange image to the coordinate system of the other flange image, achieving seamless stitching at the edge joints, and reconstructing a complete image of the entire surface of the galvanized angle steel. The specific implementation of this method is as follows:
[0026] S31. Using the first flange image as the reference coordinate system, the second flange image needs to be mapped to the reference coordinate system through a rigid transformation. The rigid transformation matrix is: Where J is the rotation angle, Let the rotation angle and translation be the translation amount; using the rotation angle and translation amount as variables, a genetic algorithm is used to optimize and iterate with the feature point matching Euclidean distance error as the objective function to obtain the optimal rotation angle and translation amount variables, and thus the optimal rigid transformation matrix.
[0027] S32. Substitute all pixels in the second flange image into the optimal rigid transformation matrix to obtain the mapped coordinates. Then, use bilinear interpolation to fill the pixel grayscale values of the corrected image to obtain the mapped second flange image. ;
[0028] S33. Define the edge connection region R, and calculate the first flange image within R. With mapping image grayscale gradient and The grayscale values of pixels in the connecting area are calculated using a weighted fusion formula: ,when The average of the two values is taken; the grayscale values of the pixels in the connecting region and the grayscale abrupt change values of the two flange regions are calculated. ,like If the result is less than or equal to the preset threshold, the splicing effect is deemed acceptable, and a complete image of the entire surface of the galvanized angle steel is obtained.
[0029] Preferably, step S4, zinc plating layer defect region segmentation, specifically employs an adaptive threshold segmentation algorithm to segment suspected defect regions from the complete image, taking into account the grayscale uniformity characteristics of the zinc plating layer.
[0030] S41. Centered on pixel (x,y), select a local window W(x,y) and calculate the average gray value within the window. Gray-scale variance Calculate the defect anomaly degree: ,in, To avoid denominators being zero for small constants;
[0031] S42. Calculate the global mean of anomaly map A. and global standard deviation And the global grayscale mean of the complete image. Calculate the local adaptive threshold for pixel (x,y): ,in, For sensitivity coefficient; when Pixels marked as suspected defects are assigned a value of 1, while those marked as background are assigned a value of 0, thus obtaining a preliminary binary image. ;
[0032] S43. Extract the preliminary binary image. The morphological features of each connected region in the image are analyzed, including its area and perimeter. A connected region is considered a defective region if its morphological features are greater than or equal to a preset filtering threshold. This process yields a binary image of the precise defective regions. ;
[0033] S44, Finally, the binary image With full image Perform pixel-level mapping to extract the binary image. The complete image corresponding to the region marked as 1. Pixels, to obtain images of suspected defect areas .
[0034] Preferably, the feature extraction module in step S5 uses an improved depthwise separable convolutional structure to extract basic defect features from the suspected defect region image. The specific implementation of this feature extraction module is as follows:
[0035] S511, Image of suspected defect area The initial 1×1 convolutional layer maps to a C-channel feature map. Based on the scale distribution characteristics of galvanized layer defects, the map is uniformly divided into R groups according to the channel dimension. Each group corresponds to the feature extraction direction of a certain type of scale defect. Targeted filtering is achieved through grouping masks. The calculation method is as follows: ,in, Let r be the input feature map of the r-th group. This is an element-wise multiplication operation. The one-hot block mask for the r-th group;
[0036] S512, For each set of input feature maps A dynamic expansion rate mechanism based on the defect anomaly degree A(x,y) is introduced to calculate the dynamic expansion rate: ,in, Based on the basic expansion rate, This is the dilation rate adjustment coefficient; then, depthwise convolution is performed using this dynamic dilation rate to extract local defect features: ,in, This is a depthwise convolution operation;
[0037] S513. In the pointwise convolution stage, a cross-group feature interaction mechanism is introduced. The correlation weights of each group of deep convolutional features with other groups of features are calculated using the Pearson coefficient. Then, pointwise convolution is performed based on the weights to obtain the pointwise convolutional feature map. ;
[0038] S514. Weighted fusion of the pointwise convolutional feature maps of group R, followed by lightweight dimensionality compression using a 1×1 convolutional layer with ReLU activation, outputs the basic defect feature map: ,in, This is a weighted fusion feature map of R groups of pointwise convolutional features. This represents the number of output channels for the convolution.
[0039] Preferably, step S5, the defect feature enhancement module, introduces a channel-space dual attention mechanism. The channel attention branch calculates weights based on the information entropy of the feature channels, focusing on high-information-density channels related to defects. The spatial attention branch, through adaptive pooling and convolution operations, locates the spatial position of suspected defects and enhances the feature response of that region, while suppressing low-value features corresponding to background noise, outputting high signal-to-noise ratio target defect features. The specific implementation is as follows:
[0040] S521, Calculate the basic defect feature map The information entropy and grayscale contrast of each channel are used as the basis for calculation. The product of information entropy and grayscale contrast is normalized to obtain the channel weights. Channel attention vectors are then generated based on the weights of each channel. The basic features are weighted by channel-by-channel multiplication: ;
[0041] S522, to Perform dual pooling, including average pooling. and max pooling Then, the features are concatenated to obtain the dual-pooling features: Spatial information is integrated through 3×3 convolution and Sigmoid activation is applied to generate a spatial attention map. ;
[0042] S523, Enhanced feature map obtained by combining pixel-wise weighted channel-weighted features and spatial attention map: ;
[0043] S524. Perform a 1×1 convolution on the obtained enhanced feature map to compress channel redundancy and finally obtain a target defect feature map with high signal-to-noise ratio.
[0044] Compared with existing technologies, the advantages and positive effects of this invention are as follows: By employing a joint mechanism of dual-camera symmetrical acquisition, geometric constraint correction, and edge registration reconstruction, the invention fundamentally solves the problems of image distortion, occlusion, and incomplete coverage caused by the three-dimensional structure of angle steel, achieving standardized and continuous acquisition of full-surface images of galvanized angle steel. In the defect detection model, a high signal-to-noise ratio feature representation is constructed through dynamic dilated depth-separable convolution, cross-group feature interaction, and channel-space dual attention mechanism, significantly improving the detection capability of subtle defects. Combined with an anomaly-based adaptive segmentation strategy, this invention effectively suppresses interference from illumination reflection and texture noise, enabling the system to maintain high accuracy and robustness even in complex industrial environments, achieving stable identification and grade assessment of multiple types of galvanized defects. Attached Figure Description
[0045] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 This is a schematic diagram of the structural process of a defect detection method for galvanized angle steel. Detailed Implementation
[0047] To better understand the above-mentioned objectives, features, and advantages of the present invention, the present invention will be further described below in conjunction with the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in these embodiments can be combined with each other.
[0048] Numerous specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways than those described herein, and therefore the invention is not limited to the specific embodiments disclosed in the following specification.
[0049] In this embodiment, considering that traditional technologies suffer from problems such as the significant influence of subjective experience on manual inspection, high missed rate for small defects, and inability to adapt to high-speed production lines; and that conventional machine vision inspection only uses single-angle image acquisition, which is prone to incomplete surface coverage due to occlusion by the angle steel flange, and lacks targeted geometric correction schemes, resulting in severe image distortion that affects defect location accuracy, etc., this embodiment addresses these issues by achieving precise image correction through geometric structure constraints, achieving multi-faceted stitching and complete surface reconstruction through edge feature point registration, achieving high-sensitivity defect region segmentation through grayscale anomaly detection, and constructing a high-performance defect recognition network through depthwise separable convolution and dual attention mechanisms. Ultimately, this enables high-precision and high-robustness identification of galvanized angle steel defects. The specific implementation process is as follows: Figure 1 As shown.
[0050] First, the angle steel is positioned and image is acquired. A dual-camera symmetrical acquisition system is set up, with the optical axes of the two cameras forming angles of 45° to 60° with the two flanges of the galvanized angle steel, and the optical axes of the two cameras intersecting at the midpoint of the edge in the plane containing the edge of the angle steel. The real-time placement posture of the angle steel is obtained through infrared positioning, and the cameras are driven to synchronously acquire surface images of the two flanges.
[0051] To overcome the imaging distortion caused by the three-dimensional structure of the angle steel and ensure that both flange images can be converted into standard orthographic projection formats, a perspective correction method based on edge geometric constraints is proposed for the acquired surface images. Based on the L-shaped structural features of the angle steel, the edge contours are extracted from the acquired surface images. A local coordinate system is established using the edges as a reference. Perspective transformation is used to correct the tilt distortion of the flange images, resulting in standard orthographic projection images of both flanges. This is achieved by first improving the grayscale contrast between the edges and the flange surface through Gaussian filtering and grayscale stretching, followed by using an improved Canny operator to enhance the edge gradient and extract the complete edge contours. Based on this, polynomial fitting is used to obtain the spatial orientation of the edges, thereby determining key feature points such as the starting point, ending point, and midpoint of the edges. A local two-dimensional coordinate system is established based on this, and the standard orthographic projection dimensions are set according to the standard geometry of the angle steel. The perspective transformation matrix is solved using control point pairs, ultimately converting the two flange images into geometrically corrected standard orthographic projection images.
[0052] Specifically, the acquired images are first preprocessed by applying Gaussian smoothing filters to the acquired flange surface images to remove environmental noise interference. The filter kernel size is set to 3×3. Then, grayscale stretching transformation is used to enhance the grayscale contrast between the edge and the flange surface. The transformation formula is as follows: ,in The original acquired image pixel grayscale values, These are the maximum and minimum values of the original acquired image, respectively. The image shows the stretched pixel grayscale values. An improved Canny operator is used to enhance the recognition of grayscale differences between the edge and the flange surface, extracting the complete edge contour. Edge feature points are located, and polynomial fitting is performed on the extracted edge contour. The fitting parameters are obtained using the least squares method. Based on the fitting results, the starting point of the edge is identified. ,end and midpoint ; using the midpoint of the edge With the origin as the coordinate system origin, the tangent direction of the fitted line on the edge is the u-axis of the local coordinate system, and the direction perpendicular to the tangent and pointing inward to the flange surface is the v-axis, establishing a two-dimensional local coordinate system; where the u-axis direction vector... Calculated using the coordinate difference between the starting and ending points of the edge: v-axis direction vector The calculation is as follows: Based on the geometric constraints of the L-shaped angle steel structure, the standard dimensions of the flange orthographic projection are preset, including length L and width W. Three non-collinear edge feature points are selected as the original control points in the local coordinate system. , and Target control points in the corresponding standard image , and The perspective transformation matrix M is solved by controlling point pairs. The coordinate mapping of the perspective transformation satisfies: By minimizing the control point mapping error using the least squares method, the elements of the perspective transformation matrix M are obtained. Finally, the local coordinates (u,v) of all pixels in the flange image are substituted into the perspective transformation coordinate mapping to obtain the corrected standard coordinates (u',v'). Bilinear interpolation is then used to fill the pixel grayscale values of the corrected image. The above steps are repeated to obtain the orthographic projection standard images of the two flanges. This scheme effectively eliminates image distortion caused by camera angle, attitude deviation, and perspective distortion, standardizing the spatial structure of the flange surface, ensuring geometric consistency between multi-view images, and improving the stability of subsequent registration and stitching.
[0053] Specifically, the method of using the improved Canny operator to enhance the grayscale difference recognition between the edge and the flange surface and extract the complete edge contour is implemented as follows: First, the initial gradient magnitude of the preprocessed image is calculated: ,in, These are the initial x and y gradients of the Sobel operator, respectively. A gray-level enhancement weight matrix is constructed based on the initial gradients to enhance the gray-level difference between the edge region and the flange surface. The enhancement formula is as follows: ,in, These are the pixel values of the image after grayscale stretching. This represents the maximum value of the initial gradient magnitude. For the gradient-weighted enhanced image, an adaptive convolution kernel is introduced to obtain the dominant gradient direction in a local region by fitting the gray-level distribution of that region. Based on Generate three orthogonal convolution kernels, calculate the gradient magnitude using each kernel, and take the maximum value as the final gradient magnitude: ,in, These are three convolution kernels in orthogonal directions; the edge confidence score is calculated using the final gradient magnitude and local gray-level difference. ,in, The mean and variance of gray levels in a 5×5 local region centered at (x,y) are given. Based on the statistical characteristics of the edge confidence of the entire image, a high threshold is determined. and low threshold : , ,in, The high confidence threshold coefficient is used. The gradient magnitude is set as a high / low threshold ratio coefficient. Compare with the threshold to obtain strong edges, Candidate weak edges and The non-edges; using the linearity constraint of the angle steel edge, the candidate weak edges are effectively screened, and the strong edges are fitted with a straight line to obtain the fitted straight line. The distance from each candidate weak edge pixel to the fitted straight line is calculated, and only candidate weak edges with a distance less than or equal to a set threshold are retained. Then, for the discontinuous region formed by the strong edges and the screened weak edges, edge pixels are interpolated along the direction of the fitted straight line to supplement the edge pixels, and finally a continuous and complete edge contour is obtained.
[0054] Next, to achieve continuous presentation of the full surface image of the galvanized angle steel, considering the critical issues of single-wing images failing to represent the complete angle steel surface and image breaks leading to defect omissions, surface image registration and complete surface reconstruction are performed: using the extracted edge feature points as the registration reference, the coordinate transformation matrix of the two flange standard images is calculated, mapping one flange image to the coordinate system of the other flange image, achieving seamless splicing at the edge junction, and reconstructing a complete image of the entire surface of the galvanized angle steel. This is achieved by using the standard image of the first flange as a reference, and mapping the second flange image to the reference coordinate system through a rigid transformation. The rigid transformation includes two parameters: rotation and translation. In this embodiment, a genetic algorithm is used to optimize the transformation by minimizing the Euclidean distance of feature points, thereby obtaining the optimal transformation matrix. Subsequently, grayscale gradient fusion is performed on the splicing region R, and interpolation is performed at the junction of the two flange images in a weighted manner to minimize boundary abrupt changes. The final result is a continuous image of the entire bend area of the galvanized angle steel.
[0055] Specifically, using the first flange image as the reference coordinate system, the second flange image needs to be mapped to the reference coordinate system through a rigid transformation, wherein the rigid transformation matrix is: Where J is the rotation angle, The rotation angle and translation are used as variables. A genetic algorithm is used to optimize and iterate the rotation angle and translation variables with the feature point matching Euclidean distance error as the objective function to obtain the optimal rigid transformation matrix. All pixels in the second flange image are then substituted into the optimal rigid transformation matrix to obtain the mapped coordinates. Bilinear interpolation is used to fill the pixel gray values of the corrected image to obtain the mapped second flange image. Define the edge-connecting region R, and calculate the first flange image within R. With mapping image grayscale gradient and The grayscale values of pixels in the connecting area are calculated using a weighted fusion formula: ,when The average of the two values is taken; the grayscale values of the pixels in the connecting region and the grayscale abrupt change values of the two flange regions are calculated. ,like If the image quality is less than or equal to a preset threshold, the stitching effect is considered acceptable, resulting in a complete image of the entire surface of the galvanized angle steel. This step enables high-precision alignment of multi-view images, ensuring that the stitched image maintains continuity and consistency in grayscale, texture, and structure, providing high-quality input for subsequent overall defect detection and effectively avoiding missed detections due to image breakpoints.
[0056] To reduce the input complexity of the deep learning model and improve the accuracy of defect identification, an adaptive segmentation method based on local anomaly degree was adopted to address the problem of traditional threshold segmentation failure caused by strong texture and uneven illumination of the galvanized layer. Galvanized layer defect region segmentation was performed: Targeting the gray-level uniformity characteristics of the galvanized layer, an adaptive threshold segmentation algorithm was used to segment suspected defect regions from the complete image. This was implemented by calculating the gray-level mean and variance through local windows to construct a defect anomaly map. Then, an adaptive threshold was dynamically generated using global and local gray-level statistics to perform preliminary binarization of suspected defect pixels. Further connected regions were extracted, and noisy regions were filtered out based on morphological features such as area and perimeter. Finally, pixel mapping with the complete image was performed to obtain the suspected defect region image.
[0057] Specifically, a local window W(x,y) is selected centered at pixel (x,y), and the average gray value within the window is calculated. Gray-scale variance Calculate the defect anomaly degree: ,in, To avoid zero denominators for small constants; calculate the global mean of anomaly map A. and global standard deviation And the global grayscale mean of the complete image. Calculate the local adaptive threshold for pixel (x,y): ,in, For sensitivity coefficient; when Pixels marked as suspected defects are assigned a value of 1, while those marked as background are assigned a value of 0, thus obtaining a preliminary binary image. Extracting the initial binary image The morphological features of each connected region in the image are analyzed, including its area and perimeter. A connected region is considered a defective region if its morphological features are greater than or equal to a preset filtering threshold. This process yields a binary image of the precise defective regions. Finally, the binary image With full image Perform pixel-level mapping to extract the binary image. The complete image corresponding to the region marked as 1. Pixels, to obtain images of suspected defect areas This step effectively suppresses interference from lighting, reflection, and texture, enabling the system to preemptively eliminate most non-defect areas, reducing the processing burden on the AI model and improving recognition efficiency and accuracy.
[0058] Finally, to improve the accuracy and robustness of galvanized layer defect identification, images of suspected defect areas are input into an improved convolutional neural network model. This improved model includes a feature extraction module, a defect feature enhancement module, and a defect level mapping module. The feature extraction module uses an improved depthwise separable convolutional structure to extract basic defect features from the suspected defect area images. To address the problems of large parameter count, high computational cost, and susceptibility to surface texture interference in traditional convolutional structures, this module employs channel-wise convolution to filter features from each channel of the input image, enabling the network to extract basic features such as surface detail texture, grayscale differences, and edge variations at a lower computational cost. Subsequently, pointwise convolution is used to fuse the features across channels, giving the network the ability to comprehensively represent multi-dimensional information. To further enhance the perception of defects at different scales, a dynamic kernel selection mechanism is added to the depthwise separable convolution, allowing the kernel to automatically adjust the receptive field size based on the texture features of the input region, improving the model's compatibility in capturing both subtle and large-scale defects. Simultaneously, a cross-group feature interaction strategy is introduced to enable information exchange between different convolutional groups, reducing the information silo problem caused by group convolution. Specifically, the image of suspected defect areas is used... The initial 1×1 convolutional layer maps to a C-channel feature map. Based on the scale distribution characteristics of galvanized layer defects, the map is uniformly divided into R groups according to the channel dimension. Each group corresponds to the feature extraction direction of a certain type of scale defect. Targeted filtering is achieved through grouping masks. The calculation method is as follows: ,in, Let r be the input feature map of the r-th group. This is an element-wise multiplication operation. For the r-th group, use the one-hot block mask; for each group of input feature maps A dynamic expansion rate mechanism based on the defect anomaly degree A(x,y) is introduced to calculate the dynamic expansion rate: ,in, Based on the basic expansion rate, This is the dilation rate adjustment coefficient; then, depthwise convolution is performed using this dynamic dilation rate to extract local defect features: ,in, This is a depthwise convolution operation; a cross-group feature interaction mechanism is introduced in the pointwise convolution stage. The correlation weights of each group of depthwise convolution features with other groups of features are calculated using the Pearson coefficient, and then pointwise convolution is performed based on the weights to obtain the pointwise convolution feature map: The pointwise convolutional feature maps of group R are weighted and fused, and then lightweight dimensionality compression is performed through a 1×1 convolutional layer with ReLU activation function to output the basic defect feature map: ,in, This is a weighted fusion feature map of R groups of pointwise convolutional features. The number of output channels for the convolution is [value]. Through the above design, this module can extract fundamental defect features with high discriminative power and low redundancy while ensuring computational efficiency, providing reliable data support for subsequent attention enhancement and defect level mapping.
[0059] The defect feature enhancement module introduces a channel-space dual attention mechanism. The channel attention branch calculates weights based on the information entropy of the feature channels, focusing on high-information-density channels related to defects. The spatial attention branch uses adaptive pooling and convolution operations to locate the spatial position of suspected defects and enhance the feature response of that region, while suppressing low-value features corresponding to background noise, outputting high signal-to-noise ratio target defect features. The defect feature enhancement module aims to further improve the effectiveness of basic features, enabling the model to highlight key information in the defect region and suppress the influence of background noise. To achieve this goal, this module employs a channel-space dual attention mechanism, enhancing features from both the channel and spatial dimensions. Specifically, the channel attention branch calculates weights primarily based on the information entropy of the feature channels, judging the effective information density carried by comparing the entropy values of different channels. Channels with higher information entropy typically contain richer grayscale variations, texture abrupt changes, and defect-related details, thus receiving higher attention weights; channels with lower information entropy often correspond to background textures or noise and are automatically suppressed by the system. The spatial attention branch extracts spatial statistical features at different scales through adaptive pooling, and then generates a spatial attention map through lightweight convolution to accurately locate regions where defects may exist. This branch can enhance the response intensity of defect regions while reducing the influence of background factors such as light reflection and galvanized texture on the feature map. Specifically, it calculates the basic defect feature map. The information entropy and grayscale contrast of each channel are used to generate a channel attention vector based on the weight of each channel. The basic features are weighted by channel-by-channel multiplication: ;right Perform dual pooling, including average pooling. and max pooling Then, the features are concatenated to obtain the dual-pooling features: Spatial information is integrated through 3×3 convolution and Sigmoid activation is applied to generate a spatial attention map. The enhanced feature map is obtained by combining pixel-wise weighted channel-weighted features with the spatial attention map. The enhanced feature map is then subjected to 1×1 convolution to compress channel redundancy, ultimately yielding a target defect feature map with a high signal-to-noise ratio.
[0060] The defect level mapping module first integrates and abstracts the feature dimensions of the target defect features through a fully connected layer, then inputs the integrated features into a Softmax classifier, which finally maps the features to a preset defect level. Specifically, the fully connected layer first compresses and abstracts the input features, mapping the original high-dimensional features into a set of low-dimensional feature vectors with classification significance. This process not only effectively integrates scattered information in the spatial and channel dimensions but also constructs multiple potential feature combinations, enabling the system to capture structural differences between different defect types. To improve the stability of the classification process, a non-linear activation function is added after the fully connected layer, allowing the model to form more complex classification decision boundaries. The low-dimensional vectors after feature integration are then input into the Softmax classifier. Based on the response degree of the feature vectors in each category dimension, the classifier outputs the probability distribution of the corresponding defect level and finally uses the category with the highest probability as the defect level identification result. Through this module, stable and reliable multi-type defect levels can be accurately output based on the morphological features, grayscale change patterns, and texture fracture characteristics of the defects.
[0061] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments for application in other fields. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.
Claims
1. A method for detecting defects in galvanized angle steel, characterized in that, Includes the following steps: S1. Angle steel attitude positioning and image acquisition: A dual-camera symmetrical acquisition system is set up, with the optical axes of the two cameras forming angles of 45° to 60° with the two flanges of the galvanized angle steel, and the optical axes of the two cameras intersecting at the midpoint of the edge in the plane where the angle steel edge is located; the real-time placement attitude of the angle steel is obtained through infrared positioning, and the cameras are driven to synchronously acquire surface images of the two flanges. S2. Geometric correction of flange image: Based on the L-shaped structure features of angle steel, the edge contours in the acquired surface image are extracted, a local coordinate system is established with the edge as the reference, and the tilt distortion of the flange image is corrected by perspective transformation to obtain the orthographic projection standard image of the two flanges. S3. Multi-faceted image registration and complete surface reconstruction: Using the extracted edge feature points as the registration reference, calculate the coordinate transformation matrix of the two flange standard images, map one flange image to the coordinate system of the other flange image, realize seamless splicing at the edge connection, and reconstruct a complete image of the entire surface of the galvanized angle steel. S4. Defect region segmentation of galvanized layer: Based on the gray-scale uniformity characteristics of the galvanized layer, an adaptive threshold segmentation algorithm is used to segment suspected defect regions from the complete image. S5. Input the suspected defect area image into the improved convolutional neural network model, wherein the improved convolutional neural network model includes a feature extraction module, a defect feature enhancement module, and a defect level mapping module. The feature extraction module is used to extract basic defect features from suspected defect region images using an improved depthwise separable convolutional structure. The defect feature enhancement module introduces a channel-space dual attention mechanism. The channel attention branch calculates weights based on the information entropy of the feature channels, focusing on high information density channels related to defects. The spatial attention branch uses adaptive pooling and convolution operations to locate the spatial position of suspected defects and enhance the feature response of the region, while suppressing low-value features corresponding to background noise and outputting target defect features with high signal-to-noise ratio. The defect level mapping module is used to first integrate and abstract the feature dimensions of the target defect features through a fully connected layer, then input the integrated features into a Softmax classifier, and finally the classifier maps the features to a preset defect level.
2. The method for detecting defects in galvanized angle steel according to claim 1, characterized in that, Step S2, flange image geometric correction: Based on the L-shaped structural features of the angle steel, the edge contours in the acquired surface image are extracted. A local coordinate system is established with the edges as the reference. The tilt distortion of the flange image is corrected through perspective transformation to obtain the orthographic projection standard images of the two flanges. The specific implementation is as follows: S21. First, the acquired image is preprocessed. A Gaussian smoothing filter is applied to the acquired flange surface image to remove environmental noise interference. The filter kernel size is set to 3×3. Then, a grayscale stretching transformation is used to enhance the grayscale contrast between the edge and the flange surface. The transformation formula is: ,in The original acquired image pixel grayscale values, These are the maximum and minimum values of the original acquired image, respectively. These are the stretched pixel grayscale values; S22. Use the improved Canny operator to enhance the grayscale difference recognition between the edge and the flange surface, and extract the complete edge contour; S23. Locate the feature points of the edge, perform polynomial fitting on the extracted edge contour and obtain the fitting parameters using the least squares method, and identify the starting point of the edge based on the fitting results. ,end and midpoint ; S24, using the midpoint of the edge With the origin as the coordinate system origin, the tangent direction of the fitted line on the edge is the u-axis of the local coordinate system, and the direction perpendicular to the tangent and pointing inward to the flange surface is the v-axis, establishing a two-dimensional local coordinate system; where the u-axis direction vector... Calculated using the coordinate difference between the starting and ending points of the edge: v-axis direction vector The calculation is as follows: ; S25. Based on the geometric constraints of the L-shaped angle steel structure, preset the standard dimensions of the flange orthographic projection, including length L and width W. Select three non-collinear edge feature points as the original control points in the local coordinate system. , and Target control points in the corresponding standard image , and The perspective transformation matrix M is solved by controlling point pairs. The coordinate mapping of the perspective transformation satisfies: The elements of the perspective transformation matrix M are obtained by minimizing the control point mapping error using the least squares method. S26. Finally, substitute the local coordinates (u,v) of all pixels in the flange image into the perspective transformation coordinate mapping to obtain the corrected standard coordinates (u',v'); use bilinear interpolation to fill the pixel gray values of the corrected image; repeat the above steps to obtain the orthographic projection standard images of the two flanges respectively.
3. The method for detecting defects in galvanized angle steel according to claim 2, characterized in that, The specific implementation of step S22, which uses the improved Canny operator to enhance the grayscale difference recognition between the edge and the flange surface and extract the complete edge contour, is as follows: S221. First, calculate the initial gradient magnitude of the preprocessed image: ,in, These are the initial x and y gradients of the Sobel operator, respectively. A gray-level enhancement weight matrix is constructed based on the initial gradients to enhance the gray-level difference between the edge region and the flange surface. The enhancement formula is as follows: ,in, These are the pixel values of the image after grayscale stretching. This represents the maximum value of the initial gradient magnitude. This is the image after gradient-weighted enhancement; S222. Introduce an adaptive convolution kernel to obtain the dominant gradient direction of a region by fitting the local gray-level distribution. Based on Generate three orthogonal convolution kernels, calculate the gradient magnitude using each kernel, and take the maximum value as the final gradient magnitude: ,in, These are convolution kernels in three orthogonal directions; S223. Calculate the edge confidence level using the final gradient magnitude and local grayscale difference: ,in, The mean and variance of gray levels in a 5×5 local region centered at (x,y) are given. Based on the statistical characteristics of the edge confidence of the entire image, a high threshold is determined. and low threshold : , ,in, The high confidence threshold coefficient is used. The gradient magnitude is set as a high / low threshold ratio coefficient. Compare with the threshold to obtain strong edges, Candidate weak edges and Non-edge; S224. Using the linearity constraint of the angle steel edge, the candidate weak edge is effectively screened, and the strong edge is fitted with a straight line to obtain the fitted straight line. The distance from each candidate weak edge pixel to the fitted straight line is calculated. Only candidate weak edges with a distance less than or equal to a set threshold are retained. Then, for the discontinuous region formed by the strong edge and the screened weak edge, edge pixels are interpolated along the direction of the fitted straight line to supplement the edge pixels, and finally a continuous and complete edge contour is obtained.
4. The method for detecting defects in galvanized angle steel according to claim 1, characterized in that, Step S3, multi-faceted image registration and complete surface reconstruction, uses the extracted edge feature points as the registration reference. The coordinate transformation matrix of the two flange standard images is calculated, and one flange image is mapped to the coordinate system of the other flange image, achieving seamless stitching at the edge joints. The specific implementation of reconstructing a complete image of the entire surface of the galvanized angle steel is as follows: S31. Using the first flange image as the reference coordinate system, the second flange image needs to be mapped to the reference coordinate system through a rigid transformation. The rigid transformation matrix is: Where J is the rotation angle, Let the rotation angle and translation be the translation amount; using the rotation angle and translation amount as variables, a genetic algorithm is used to optimize and iterate with the feature point matching Euclidean distance error as the objective function to obtain the optimal rotation angle and translation amount variables, and thus the optimal rigid transformation matrix. S32. Substitute all pixels in the second flange image into the optimal rigid transformation matrix to obtain the mapped coordinates. Then, use bilinear interpolation to fill the pixel grayscale values of the corrected image to obtain the mapped second flange image. ; S33. Define the edge connection region R, and calculate the first flange image within R. With mapping image grayscale gradient and The grayscale values of pixels in the connecting area are calculated using a weighted fusion formula: ,when The average of the two values is taken; the grayscale values of the pixels in the connecting region and the grayscale abrupt change values of the two flange regions are calculated. ,like If the result is less than or equal to the preset threshold, the splicing effect is deemed acceptable, and a complete image of the entire surface of the galvanized angle steel is obtained.
5. The method for detecting defects in galvanized angle steel according to claim 1, characterized in that, Step S4, zinc plating defect region segmentation: Based on the grayscale uniformity characteristics of the zinc plating layer, an adaptive threshold segmentation algorithm is used to segment suspected defect regions from the complete image. The specific implementation is as follows: S41. Centered on pixel (x,y), select a local window W(x,y) and calculate the average gray value within the window. Gray-scale variance Calculate the defect anomaly degree: ,in, To avoid denominators being zero for small constants; S42. Calculate the global mean of anomaly map A. and global standard deviation And the global grayscale mean of the complete image. Calculate the local adaptive threshold for pixel (x,y): ,in, The sensitivity coefficient; when Pixels marked as suspected defects are assigned a value of 1, while those marked as background are assigned a value of 0, thus obtaining a preliminary binary image. ; S43. Extract the preliminary binary image. The morphological features of each connected region in the image are analyzed, including its area and perimeter. A connected region is considered a defective region if its morphological features are greater than or equal to a preset filtering threshold. This process yields a binary image of the precise defective regions. ; S44, Finally, the binary image With full image Perform pixel-level mapping to extract binary images. The complete image corresponding to the region marked as 1 in the middle. Pixels, to obtain images of suspected defect areas .
6. The method for detecting defects in galvanized angle steel according to claim 1, characterized in that, The feature extraction module in step S5 uses an improved depthwise separable convolutional structure to extract basic defect features from the suspected defect region image. The specific implementation of this feature extraction module is as follows: S511, Image of suspected defect area The initial 1×1 convolutional layer maps to a C-channel feature map. Based on the scale distribution characteristics of galvanized layer defects, the map is uniformly divided into R groups according to the channel dimension. Each group corresponds to the feature extraction direction of a certain type of scale defect. Targeted filtering is achieved through grouping masks. The calculation method is as follows: ,in, For the input feature map of the r-th group, This is an element-wise multiplication operation. The one-hot block mask for the r-th group; S512, For each set of input feature maps A dynamic expansion rate mechanism based on the defect anomaly degree A(x,y) is introduced to calculate the dynamic expansion rate: ,in, Based on the basic expansion rate, This is the dilation rate adjustment coefficient; then, depthwise convolution is performed using this dynamic dilation rate to extract local defect features: ,in, This is a depthwise convolution operation; S513. In the pointwise convolution stage, a cross-group feature interaction mechanism is introduced. The correlation weights of each group of deep convolutional features with other groups of features are calculated using the Pearson coefficient. Then, pointwise convolution is performed based on the weights to obtain the pointwise convolutional feature map. ; S514. Weighted fusion of the pointwise convolutional feature maps of group R, followed by lightweight dimensionality compression using a 1×1 convolutional layer with ReLU activation, outputs the basic defect feature map: ,in, The feature map is a weighted fusion of pointwise convolutional features from group R. This represents the number of output channels for the convolution.
7. The method for detecting defects in galvanized angle steel according to claim 1, characterized in that, The defect feature enhancement module in step S5 introduces a channel-space dual attention mechanism. The channel attention branch calculates weights based on the information entropy of the feature channels, focusing on high information density channels related to defects. The spatial attention branch uses adaptive pooling and convolution operations to locate the spatial position of suspected defects and enhance the feature response of that region, while suppressing low-value features corresponding to background noise, outputting high signal-to-noise ratio target defect features. The specific implementation is as follows: S521, Calculate the basic defect feature map The information entropy and grayscale contrast of each channel are used as the basis for calculation. The product of information entropy and grayscale contrast is normalized to obtain the channel weights. Channel attention vectors are then generated based on the weights of each channel. The basic features are weighted by channel-by-channel multiplication: ; S522, to Perform dual pooling, including average pooling. and max pooling Then, the features are concatenated to obtain the dual-pooling features: ; Spatial information is integrated through 3×3 convolution and Sigmoid activation is applied to generate a spatial attention map. ; S523, Enhanced feature map obtained by combining pixel-wise weighted channel-weighted features and spatial attention map: ; S524. Perform a 1×1 convolution on the obtained enhanced feature map to compress channel redundancy and finally obtain a target defect feature map with high signal-to-noise ratio.