A method and system for collecting corrosion damage points of metal materials based on machine vision technology
By using a multispectral light source array and deep learning technology, combined with sub-pixel edge detection and 3D reconstruction algorithms, the problem of inaccurate corrosion detection and evaluation in existing technologies has been solved, and high-precision acquisition and 3D quantitative analysis of metal corrosion damage points have been achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SOUTHWEST TECHNICAL ENGINEERING RESEARCH INSTITUTE OF CHINA SOUTH IND GROUP
- Filing Date
- 2026-04-03
- Publication Date
- 2026-05-26
AI Technical Summary
Existing machine vision-based metal corrosion detection technologies struggle to highlight subtle corrosion features of different depths and types, lack sufficient positioning accuracy, cannot meet micron-level damage analysis requirements, and lack the ability to recover depth information and utilize spatial distribution information of corrosion areas, leading to inaccurate corrosion assessments.
A multispectral light source array is used to illuminate the surface of the metal material in segments. Combined with an industrial camera, images of the corrosion area under different spectral bands are collected. Preliminary contour information of corrosion damage points is extracted through deep learning and sub-pixel edge detection algorithms. Three-dimensional reconstruction and density clustering algorithms are used to identify corrosion patterns and generate a corrosion level assessment report.
It enables high-precision acquisition and three-dimensional quantitative analysis of metal corrosion damage points, improving the automation level and assessment accuracy of corrosion detection.
Smart Images

Figure CN122090167A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of machine vision technology, and in particular to a method and system for collecting corrosion damage points of metal materials based on machine vision technology. Background Technology
[0002] Accurate acquisition and quantitative assessment of corrosion damage in metallic materials are crucial for ensuring structural safety in infrastructure, aerospace, and marine engineering. Traditional manual visual inspection methods are inefficient and highly subjective, making them unsuitable for large-scale inspections. Existing machine vision-based corrosion detection technologies largely rely on single visible light imaging, extracting corrosion areas through grayscale thresholding or edge detection operators. However, these methods are susceptible to interference from lighting variations, surface reflections, and oxidation, leading to high false detection rates. With the development of multispectral imaging technology, some studies have attempted to identify corrosion products through differences in spectral reflectance across different wavelengths. However, existing methods still have the following shortcomings: First, they often use fixed light sources, making it difficult to highlight the subtle features of different depths and types of corrosion. Second, the accuracy of corrosion contour localization is insufficient, typically limited to pixel-level segmentation, failing to meet the needs of micron-level damage analysis. Third, there is a lack of effective recovery of corrosion area depth information, keeping the quantitative assessment of corrosion damage at a two-dimensional level, unable to obtain true corrosion morphology and geometric parameters. Fourth, they fail to fully utilize the spatial distribution information of corrosion points for corrosion pattern recognition, making it difficult to distinguish between uniform corrosion and localized pitting corrosion, thus hindering the scientific determination of corrosion levels. Summary of the Invention
[0003] The purpose of this invention is to provide a method and system for collecting corrosion damage points of metal materials based on machine vision technology, so as to overcome the shortcomings of the existing technology, realize high-precision collection and three-dimensional quantitative analysis of metal corrosion damage points, and improve the automation level and evaluation accuracy of corrosion detection.
[0004] One embodiment of this application provides a method for acquiring corrosion damage points in metallic materials based on machine vision technology, the method comprising: The surface of the metal material to be tested is illuminated in segments by a multispectral light source array, and the corrosion area image sequence under different spectral bands is acquired simultaneously by an industrial camera to generate an original image set containing spectral features and spatial information. The original image set is subjected to semantic segmentation of the erosion region based on deep learning to extract the preliminary contour information of the erosion damage points. At the same time, the sub-pixel edge detection algorithm is combined to refine the localization of the erosion contour and generate a binary mask image of the erosion damage points. Based on the binarized mask image, a three-dimensional reconstruction algorithm is used to restore the depth information of the corroded area, calculate the geometric feature parameters of each corrosion damage point, and generate a set of corrosion damage points with quantized attributes. Based on the set of corrosion damage points, a density clustering algorithm is used to identify the spatial distribution pattern of discrete corrosion points, distinguish between uniform corrosion and localized corrosion areas, and generate an analysis report that includes corrosion level assessment and distribution heatmap.
[0005] Optionally, the step of segmenting the surface of the metal material to be tested using a multispectral light source array and simultaneously acquiring image sequences of the corrosion area under different spectral bands using an industrial camera to generate an original image set containing spectral features and spatial information includes: Based on the type and corrosion characteristics of the metal material, the band combination of the multispectral light source array is configured, including the ultraviolet band, visible light band and infrared band, to generate a light source band configuration scheme; Based on the light source band configuration scheme, the multispectral light source array is controlled to illuminate the surface under test in segments. Each band is illuminated independently and the illumination parameters are recorded to generate segmented illumination timing control commands. The industrial camera is synchronously triggered to acquire images of the corrosion area under each illumination band. The camera maintains a fixed position and focal length to ensure that the spatial position of the images is consistent, and the original corrosion images of each band are generated. Image registration and band alignment are performed on the original corrosion images of each band to eliminate the slight shifts caused by the switching of light sources, and finally generate an original image set containing spectral features and spatial information.
[0006] Optionally, the step of performing deep learning-based semantic segmentation of the eroded regions on the original image set to extract preliminary contour information of the eroded damage points, and simultaneously combining a sub-pixel edge detection algorithm to refine the localization of the eroded contours, generating a binary mask image of the eroded damage points, includes: The original image set is preprocessed by data augmentation and normalization, and the image size and contrast are adjusted to meet the input requirements of the deep learning model to generate preprocessed image data. The preprocessed image data is input into the pre-trained U-Net semantic segmentation network, and the pixel-level classification results of the eroded region are extracted through the encoder-decoder structure to generate a preliminary segmentation mask for the eroded region. A subpixel edge detection algorithm is applied to the initial segmentation mask of the eroded area. The Canny operator combined with the polynomial fitting method is used to perform subpixel-level localization of the eroded contour and generate a refined eroded contour. Based on the refined erosion contour, the image is binarized, with pixels in the eroded area marked as 1 and pixels in the non-eroded area marked as 0, ultimately generating a binarized mask image of the erosion damage points.
[0007] Optionally, the step of recovering depth information of the corroded area using a 3D reconstruction algorithm based on the binarized mask image, calculating the geometric feature parameters of each corrosion damage point, and generating a set of corrosion damage points with quantized attributes includes: Based on the binary mask image, the two-dimensional coordinates and contour information of each corrosion damage point are extracted. The connected component analysis algorithm is used to mark the independent corrosion point regions and generate a set of connected components of corrosion points. A photometric stereo 3D reconstruction algorithm is applied to the connected components of each corrosion point, and the depth information of the corrosion area is recovered by combining the illumination change information in the multispectral image sequence to generate a corrosion point depth map. The geometric feature parameters of each corrosion damage point are calculated based on the corrosion point depth map, including corrosion area, maximum depth, average depth and volume, and a geometric feature vector of the corrosion point is generated. The geometric feature vectors of corrosion points are associated with and stored with the two-dimensional coordinates of the corresponding corrosion points to construct a set of corrosion damage points that includes spatial location and quantification attributes.
[0008] Optionally, based on the set of corrosion damage points, a density clustering algorithm is used to identify the spatial distribution pattern of discrete corrosion points, distinguishing between uniform corrosion and localized corrosion areas, and generating an analysis report including corrosion level assessment and distribution heatmap, including: The spatial coordinates and geometric feature parameters of all corrosion points are extracted from the corrosion damage point set. The DBSCAN density clustering algorithm is used to perform spatial clustering analysis on the corrosion points to generate corrosion point clustering results. Based on the corrosion point clustering results, the corrosion point density and coverage of each cluster are calculated. The corrosion type is determined by combining the geometric features of the corrosion points, and uniform corrosion areas and local corrosion areas are distinguished to generate corrosion type classification results. Based on the corrosion type classification results and the geometric characteristics of corrosion points, the corrosion level of each area is determined with reference to the preset corrosion level assessment standard, including levels of slight corrosion, moderate corrosion and severe corrosion, and corrosion level assessment results are generated. By integrating the spatial distribution of corrosion points, corrosion type classification results, and corrosion level assessment results, a corrosion distribution heat map and a structured analysis report are generated, and the final output is an analysis report containing a visualized heat map and quantitative assessment.
[0009] Another embodiment of this application provides a system for acquiring corrosion damage points in metallic materials based on machine vision technology, the system comprising: The acquisition module is used to illuminate the surface of the metal material under test in segments through a multispectral light source array, and to simultaneously acquire image sequences of the corrosion area under different spectral bands using an industrial camera, generating a raw image set containing spectral features and spatial information. The extraction module is used to perform semantic segmentation of the eroded region based on deep learning on the original image set, extract the preliminary contour information of the eroded damage points, and at the same time combine the sub-pixel edge detection algorithm to refine the eroded contours and generate a binary mask image of the eroded damage points. The generation module is used to recover the depth information of the corrosion area based on the binarized mask image using a three-dimensional reconstruction algorithm, calculate the geometric feature parameters of each corrosion damage point, and generate a set of corrosion damage points with quantized attributes. The identification module is used to identify the spatial distribution pattern of discrete corrosion points based on the set of corrosion damage points using a density clustering algorithm, distinguish between uniform corrosion and local corrosion areas, and generate an analysis report that includes corrosion level assessment and distribution heatmap.
[0010] Another embodiment of this application provides a storage medium storing a computer program, wherein the computer program is configured to execute the method described in any of the preceding claims when running.
[0011] Another embodiment of this application provides an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the method described in any of the preceding claims.
[0012] Compared with existing technologies, the present invention provides a method for collecting corrosion damage points of metal materials based on machine vision technology, which can achieve high-precision collection and three-dimensional quantitative analysis of metal corrosion damage points, thereby improving the automation level and evaluation accuracy of corrosion detection. Attached Figure Description
[0013] Figure 1 A hardware structure block diagram of a computer terminal for a method of acquiring corrosion damage points of metal materials based on machine vision technology, provided in an embodiment of the present invention; Figure 2 A flowchart illustrating a method for collecting corrosion damage points in metallic materials based on machine vision technology, provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of a metal material corrosion damage point acquisition system based on machine vision technology, provided as an embodiment of the present invention. Detailed Implementation
[0014] The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0015] The present invention first provides a method for collecting corrosion damage points of metal materials based on machine vision technology. This method can be applied to electronic devices, such as computer terminals, specifically ordinary computers.
[0016] The following detailed explanation uses a computer terminal as an example. Figure 1 This is a hardware structure block diagram of a computer terminal for a method of acquiring corrosion damage points in metallic materials based on machine vision technology, provided as an embodiment of the present invention. Figure 1 As shown, the computer device includes a processor, memory, and network interface connected via a system bus, wherein the memory may include non-volatile storage media and internal memory.
[0017] See Figure 2 The present invention provides a method for collecting corrosion damage points of metallic materials based on machine vision technology, which may include the following steps: S201 uses a multispectral light source array to provide segmented illumination to the surface of the metal material to be tested, and uses an industrial camera to simultaneously acquire image sequences of the corrosion area under different spectral bands, generating an original image set containing spectral features and spatial information. Specifically, based on the type and corrosion characteristics of the metal material, the band combination of the multispectral light source array can be configured, including the ultraviolet band, visible light band and infrared band, to generate a light source band configuration scheme; The core of this step is to combine the inherent properties and corrosion characteristics of the metal material under test to complete the band matching and parameter setting of the multispectral light source array, forming a light source band configuration scheme adapted to the current testing scenario, and providing accurate parameter basis for subsequent segmented illumination. The specific implementation method is as follows: Before implementing band configuration, it is essential to accurately determine the type and corrosion characteristics of the metal materials. These materials primarily include common industrial materials such as carbon steel, stainless steel, aluminum alloys, and copper alloys. Different materials exhibit significant differences in surface optical reflectance characteristics and the spectral absorption features of their corrosion products. For example, the corrosion products of carbon steel are mainly iron oxides, exhibiting characteristic absorption peaks in the ultraviolet and near-infrared bands. Intergranular corrosion of stainless steel displays obvious texture differences in the visible green band, while pitting corrosion products of aluminum alloys show more pronounced reflectance changes in the ultraviolet band. Corrosion characteristics are mainly categorized into uniform corrosion, localized pitting corrosion, crevice corrosion, and intergranular corrosion. Uniform corrosion has a relatively smooth surface spectral response, while localized corrosion creates localized spectral abrupt changes in specific bands. Preliminary analysis of the material and corrosion morphology allows for the identification of spectral bands sensitive to corrosion damage, preventing invalid bands from being used for illumination acquisition.
[0018] The multispectral light source array is divided into three core bands: ultraviolet, visible, and infrared. The ultraviolet band has a wavelength range of 200nm to 400nm, which can highlight the optical differences between corrosion products on the metal surface and the substrate material, and improve the identification of weak corrosion points. The visible band has a wavelength range of 400nm to 760nm, covering three sub-bands: red, green, and blue, and is used to restore the spatial contour and texture details of the corrosion area. The infrared band selects the near-infrared range, with a wavelength range of 760nm to 2500nm, which can penetrate the surface slight corrosion and capture the structural information of deep corrosion. The band combination configuration requires selecting the characteristic center wavelength within each interval and setting the bandwidth parameter. The bandwidth refers to the wavelength coverage range of a single light source band. The smaller the value, the higher the spectral purity and the corresponding improvement in detection accuracy. In the example, for the scenario of local pitting corrosion on carbon steel, the configured band combination is as follows: ultraviolet center wavelength λ_1=365nm, bandwidth Δλ_1=10nm; visible green band center wavelength λ_2=550nm, bandwidth Δλ_2=20nm; near-infrared band center wavelength λ_3=1064nm, bandwidth Δλ_3=30nm. The three bands form a complementary spectral detection system.
[0019] The light source band configuration scheme needs to integrate all parameters in a standardized format. The scheme includes core contents such as material type identification, corrosion type labeling, band number, center wavelength, bandwidth, and spectral response priority. The accuracy of all wavelength parameters is controlled within 1nm, and the accuracy of bandwidth parameters is controlled within 2nm to ensure that the subsequent light source control module can accurately parse and execute. After the scheme is generated, the parameter rationality will be verified to eliminate unreasonable configurations such as wavelength overlap and bandwidth exceeding the range of light source hardware. Finally, a light source band configuration scheme that can be directly used for lighting control will be formed.
[0020] Based on the light source band configuration scheme, the multispectral light source array is controlled to illuminate the surface under test in segments. Each band is illuminated independently and the illumination parameters are recorded to generate segmented illumination timing control commands. The core of this step is to drive a multispectral light source array to achieve independent illumination for each wavelength band based on the generated light source band configuration scheme, synchronously record key parameters during the illumination process and convert them into time-series control commands, ensuring that the illumination of each wavelength band does not interfere with each other and that the parameters are traceable. The specific implementation method is as follows: The multispectral light source array adopts a distributed independent light source structure, with each band corresponding to a set of independent illumination units. The core logic of segmented illumination is to sequentially activate the illumination units of individual bands according to the order in the band configuration scheme, with only one band light source activated at a time, thus eliminating the spectral aliasing problem caused by simultaneous illumination of multiple bands. The timing parameters of the illumination sequence need to be precisely set. The illumination duration T for a single band is set to 100ms. This duration ensures stable exposure for the industrial camera while preventing excessively long illumination times from causing the metal surface temperature to rise and affecting optical characteristics. The band switching interval ΔT is set to 5ms for stable start-up and shutdown of the light source, eliminating light intensity fluctuations at the moment of switching.
[0021] During the lighting process, various lighting parameters need to be recorded in real time. These parameters are the core indicators characterizing the lighting state and mainly include three categories: light intensity, lighting angle, and lighting uniformity. Light intensity refers to the luminous flux received per unit area of the surface under test, measured in lux. In the example, the ultraviolet light intensity I_1 = 800 lux, the visible light intensity I_2 = 1200 lux, and the infrared intensity I_3 = 600 lux. The light intensity of different wavelengths is adjusted according to the material's reflectivity to avoid overexposure or underexposure. The lighting angle refers to the angle between the light source's emission direction and the normal to the metal surface under test, uniformly set to θ = 45°. This angle can create a suitable contrast between light and shadow, highlighting the unevenness of the corrosion area. Lighting uniformity refers to the consistency of light intensity distribution within the test area, ranging from 0 to 1. The closer to 1, the more uniform the lighting. In this test, the lighting uniformity was controlled above 0.9 to ensure that there were no significant differences in brightness across the entire test surface.
[0022] The segmented lighting timing control command integrates the lighting sequence, time parameters, and lighting parameters into an executable control signal. The command uses pulse timing encoding, sequentially labeling the start time, duration, light intensity, and illumination angle of each band according to the ultraviolet, visible, and infrared bands. The timing accuracy of the command is controlled within 1ms to ensure synchronization between light source switching and camera acquisition. During command generation, the timing logic is verified to avoid issues such as repeated band starts and time parameter conflicts. The final generated timing control command can be directly transmitted to the light source driver module to achieve automated segmented lighting.
[0023] The industrial camera is synchronously triggered to acquire images of the corrosion area under each illumination band. The camera maintains a fixed position and focal length to ensure that the spatial position of the images is consistent, and the original corrosion images of each band are generated. The core of this step is to synchronously trigger an industrial camera to acquire images based on the timing signals of segmented illumination. By fixing the camera hardware parameters, the spatial coordinates of images in different spectral bands are ensured to be perfectly aligned, ultimately generating the original corrosion images corresponding to each spectral band. The specific implementation method is as follows: The industrial camera and multispectral light source array employ a hardware synchronous triggering mode. The light source drive module outputs a high-level trigger signal to the camera acquisition module simultaneously with the activation of each illumination band, with the trigger delay time controlled within 1ms. This ensures a perfect match between the camera exposure time and the illumination time of each band, preventing image loss or incomplete spectral feature capture due to timing discrepancies. The camera is fixed directly above the metal surface under test, and the working distance L (the vertical distance from the camera lens to the surface) is set to 500mm. This distance covers the entire detection area while ensuring sufficient image resolution for corrosion point detection.
[0024] The camera's optical parameters remained constant throughout the process: a focal length (f) of 25mm and an aperture (F) of 8. This fixed focal length and aperture prevented spatial displacement caused by image scaling and changes in depth of field. The camera's image resolution was set to 2048×2048 pixels, with a single pixel size of p=5.5μm. This pixel-level spatial positioning accuracy met the requirements for subsequent erosion contour extraction. During each illumination band, the camera acquired only a single frame of grayscale image. No adjustments were made to parameters such as automatic exposure or autofocus during acquisition. The image acquisition parameters for all bands were completely consistent, ensuring a one-to-one correspondence between pixel coordinates in images from different bands, eliminating issues such as viewpoint shift and geometric distortion.
[0025] After each band is acquired, a unique identifier is added to each original corrosion image. The identifier includes information such as band type, acquisition sequence number, and exposure parameters. The images are stored in lossless grayscale format, preserving complete spectral response grayscale value information. The grayscale value ranges from 0 to 255. The larger the value, the stronger the reflected light from the lower surface in that band. Corroded areas will show lower grayscale values due to stronger light absorption. By using grayscale differences, the corroded areas can be initially distinguished from normal metal substrates. Finally, original corrosion images corresponding to the ultraviolet, visible, and infrared bands are generated, providing basic data for subsequent image registration.
[0026] Image registration and band alignment are performed on the original corrosion images of each band to eliminate the slight shifts caused by the switching of light sources, and finally generate an original image set containing spectral features and spatial information.
[0027] The core of this step is to correct the slight spatial shifts in the original images of different spectral bands using image registration algorithms, achieving pixel-level alignment of all spectral band images, and integrating spectral features and spatial location information to form a standardized original image set. The specific implementation method is as follows: During light source switching, sub-pixel-level image shifts may occur due to mechanical vibration and thermal expansion and contraction of the light source. The shift amount is usually less than 1 pixel. If not corrected, it will lead to deviations in subsequent spectral feature fusion. Therefore, a feature point-based image registration algorithm is needed to complete the band alignment. First, reference feature points are extracted from the original corrosion image in the visible light band. Corner points and texture change points in the image are selected as feature matching references. The number of feature points extracted is no less than 500 to ensure the robustness of the registration. Then, corresponding feature points are extracted from the ultraviolet and infrared band images respectively. Corresponding feature points between images of different bands are found through feature vector matching.
[0028] The image transformation matrix H is calculated based on the corresponding feature points. The transformation matrix contains four core parameters: horizontal translation Δx, vertical translation Δy, rotation angle α, and scaling factor s. The translation is used to correct the linear offset in the horizontal and vertical directions, the rotation angle is used to correct small angular deflections, and the scaling factor is used to eliminate the imaging scale difference between bands. In the example, the calculated values of Δx = 0.3 pixels, Δy = 0.2 pixels, and α = 0.05° for the ultraviolet band relative to the reference image, and Δx = 0.4 pixels, Δy = 0.1 pixels, and α = 0.03° for the infrared band. All offset parameters are controlled at the sub-pixel level.
[0029] Geometric transformations are performed on the ultraviolet and infrared band images based on the transformation matrix. A bilinear interpolation algorithm is then used for pixel resampling. During resampling, the grayscale information and spatial texture of the original image are preserved to avoid image blurring or information loss. After registration, the pixel coordinates of all band images are perfectly aligned, with pixels at the same spatial location corresponding to response values in different spectral bands. Finally, the three registered band images are integrated along the spectral dimension to construct a three-dimensional data structure. The two-dimensional plane represents the image spatial information, and the third dimension represents the spectral band features, forming an original image set containing spectral features and spatial information. All data within the image set retains the original grayscale accuracy and spatial coordinate information, and can be directly input into subsequent deep learning segmentation models for processing.
[0030] S202, perform deep learning-based semantic segmentation of the erosion region on the original image set, extract the preliminary contour information of the erosion damage points, and at the same time combine the sub-pixel edge detection algorithm to refine the erosion contour positioning and generate a binary mask image of the erosion damage points. Specifically, the original image set can be preprocessed with data augmentation and normalization, and the image size and contrast can be adjusted to meet the input requirements of the deep learning model to generate preprocessed image data. The core of this step is to standardize and preprocess the raw image set acquired through multispectral acquisition. This involves expanding the effective sample features through data augmentation, normalizing and unifying the data distribution, and adjusting the image size and contrast to match the input specifications of the deep learning model. This eliminates scale and brightness differences between images, laying a data foundation for accurate inference in the subsequent semantic segmentation model. The specific implementation method is as follows: The original image set contains images of metal corrosion areas under different wavelengths of ultraviolet, visible, and infrared light. These images exhibit uneven brightness, varying scales, and scattered feature distributions. Directly inputting them into a deep learning model leads to decreased segmentation accuracy; therefore, preprocessing is necessary for data normalization. Data augmentation is the primary preprocessing step, aiming to expand the sample diversity of corrosion features by applying geometric and brightness transformations to the original images. This enhances the model's ability to generalize and recognize corrosion areas under different shooting angles and lighting conditions. Specifically, three augmentation methods are employed: random rotation, horizontal flipping, and brightness fine-tuning. The random rotation angle is set between 0° and 15°, simulating the slight pose shifts during industrial camera shooting and avoiding distortion of corrosion spatial features due to excessive rotation angles. Horizontal flipping maintains the spatial topology of the corrosion area, only mirroring the image pixel distribution, effectively increasing the number of samples. Brightness fine-tuning is controlled between 0.8 and 1.2 times the original brightness to adapt to brightness fluctuations under multispectral illumination, simulating corrosion image features under different lighting intensities in actual detection. After data augmentation, all images are resized uniformly. The input size of the deep learning model is fixed at 512 pixels × 512 pixels. Therefore, the scaling ratio S_1 needs to be calculated based on the resolution of the original image. S_1 is the ratio of the target size to the long side of the original image. If the long side of the original image is 2048 pixels, then S_1 is 0.25. The scaling is completed by bilinear interpolation algorithm. This algorithm can preserve the erosion details of the image edges and avoid the blurring of the outline caused by pixel interpolation. After scaling, all images match the size requirements of the model input.
[0031] The contrast adjustment stage employs a gamma transform algorithm to optimize image contrast. The gamma transform coefficient γ_1 is set to 1.2. When γ_1 is greater than 1, it can improve the contrast of corrosion features in the dark areas of the image, weaken the reflective interference of the metal substrate, and make the pixel difference between the outline of the corrosion damage points and the background more significant, facilitating feature extraction by the subsequent model. Normalization maps image pixel values to a fixed numerical range, eliminating the numerical distribution deviation caused by differences in spectral response between different spectral bands. A mean-variance normalization method is used, setting the normalized mean μ_1 to 0.5 and the variance σ_1 to 0.5. This converts the pixel grayscale values of the original image from 0 to 255 into floating-point values from -1 to 1. μ_1 represents the central reference of the pixel values, and σ_1 controls the dispersion of the values. The unified numerical distribution can accelerate the convergence speed of the deep learning model and improve segmentation efficiency. Throughout the preprocessing process, image denoising is performed simultaneously using a 3×3 Gaussian filter to remove Gaussian noise generated during multispectral acquisition. The filtered image retains the core texture features of the eroded areas while eliminating irrelevant noise. After all preprocessing operations are completed, the processed multispectral images are integrated in band order, with each image labeled with its corresponding band identifier and pixel values. This results in preprocessed image data with a uniform format and well-defined features, which can be directly input into a semantic segmentation network for inference calculations.
[0032] The preprocessed image data is input into the pre-trained U-Net semantic segmentation network, and the pixel-level classification results of the eroded region are extracted through the encoder-decoder structure to generate a preliminary segmentation mask for the eroded region. The core of this step is to use a pre-trained U-Net network to perform pixel-level semantic segmentation on the preprocessed image. The encoder extracts deep visual features of the eroded region, and the decoder restores the spatial resolution of the feature map, achieving pixel-level differentiation between the eroded region and the metal substrate. This outputs a preliminary segmentation mask, providing basic segmentation results for subsequent contour refinement. The specific implementation is as follows: The pre-trained U-Net semantic segmentation network is a deep learning model optimized for industrial image segmentation. Its encoder-decoder structure is adapted to the feature extraction requirements of multispectral corrosion images. The encoder consists of four stacked convolutional modules and pooling layers. Each convolutional module contains two 3×3 convolutional kernels, with the number of kernels being 64, 128, 256, and 512 respectively. Convolutional operations are used to extract spectral, texture, and contour features of the corrosion region. The pooling layer uses max pooling with a 2×2 kernel size. Downsampling compresses the feature map size while preserving core corrosion features, reducing the computational cost of the model. The encoder has learned a large number of general features of metal corrosion images during the pre-training stage, including the pixel distribution patterns of corrosion points with different corrosion degrees and morphologies. Therefore, it can quickly adapt to the corrosion features of the metal material being detected, avoiding the time-consuming and inaccurate problems caused by training from scratch.
[0033] The preprocessed image data is input into the encoder sequentially by band. After each convolution operation, a nonlinear transformation is introduced through the ReLU activation function to enhance the model's ability to fit complex corrosion features. The encoder finally outputs a deep feature map with dimensions of 32×32×512. This feature map condenses the core semantic information of the corrosion region and removes irrelevant background features of the metal substrate. The decoder part has a symmetrical structure with the encoder, consisting of four deconvolutional layers and skip connection modules. The deconvolutional layers are used to upsample the deep feature map, gradually restoring the spatial resolution of the feature map. The skip connection modules concatenate the shallow features of the corresponding layers of the encoder with the upsampled feature map of the decoder. The shallow features contain detailed information of the corrosion contour, which can compensate for the edge features lost during the upsampling process and improve the integrity of the segmented contour. The decoder finally outputs a 512-pixel × 512-pixel feature map with the same size as the input image. The number of channels in the feature map is compressed to 1 by a 1×1 convolution kernel. Then, the output value of each pixel is mapped to the range of 0 to 1 by the Sigmoid activation function. The closer the value is to 1, the higher the probability that the pixel belongs to the eroded area. The closer the value is to 0, the higher the probability that it belongs to the metal substrate.
[0034] A pixel classification probability threshold P_1 is set to 0.5. Pixels with a probability greater than or equal to 0.5 in the output feature map are marked as eroded region pixels, and pixels with a probability less than 0.5 are marked as non-eroded region pixels. After pixel-level classification, all classification results are integrated to generate a preliminary eroded region segmentation mask. This mask is a single-channel grayscale image, with eroded regions showing a distribution of bright pixels and non-eroded regions showing a distribution of low-brightness pixels. Although the overall segmentation of the eroded region has been completed, the edge contours have pixel-level coarseness, requiring further optimization through sub-pixel processing. The spatial resolution of the mask is kept consistent with the preprocessed image to ensure spatial matching accuracy for subsequent contour localization.
[0035] A subpixel edge detection algorithm is applied to the initial segmentation mask of the eroded area. The Canny operator combined with the polynomial fitting method is used to perform subpixel-level localization of the eroded contour and generate a refined eroded contour. The core of this step is to extract the pixel-level edges of the initial segmentation mask using the Canny operator, and then use a polynomial fitting algorithm to improve the edge positioning accuracy to the sub-pixel level, correcting the rough edges of the initial segmentation contour, restoring the true and fine contours of the erosion damage points, and eliminating the contour deviation caused by pixel-level segmentation. The specific implementation method is as follows: Subpixel edge detection algorithms are the core technology for improving the accuracy of erosion contour localization. First, the Canny operator performs coarse pixel-level edge localization, then polynomial fitting achieves fine subpixel-level localization. These two steps are seamlessly integrated to refine the contour. The application of the Canny operator requires setting high and low thresholds T_h and T_l. T_h is set to 100, and T_l to 50. T_h, the high threshold, is used to filter strong edge pixels, while T_l, the low threshold, is used to retain weak edge pixels connected to strong edges. The difference between the two thresholds controls the continuity of the edges, preventing breaks in the erosion contour. First, the initial segmentation mask is Gaussian smoothed using a 5×5 Gaussian kernel to remove pixel noise. After smoothing, the gradient magnitude and gradient direction of the image are calculated. The gradient magnitude reflects the edge strength of a pixel, and the gradient direction determines the edge extension trend. Non-maximum suppression is used to retain pixels with the largest gradient magnitude, and redundant pixels on the edges are removed to obtain a single-pixel-width erosion edge. Subsequently, edge pixels are connected by dual threshold detection. Pixels with gradient magnitude greater than T_h are identified as reliable erosion edges. Pixels with gradient magnitude between T_l and T_h and connected to reliable edges are added as edge pixels. Isolated weak edge pixels are directly removed. Finally, a pixel-level erosion edge contour is obtained. This contour has outlined the basic shape of the erosion damage point, but the positioning accuracy is only at the level of a single pixel, which cannot meet the accuracy requirements of erosion geometric feature calculation.
[0036] Polynomial fitting is used to elevate pixel-level edges to the sub-pixel level. It selects the grayscale values of each pixel on the eroded edge and its 3×3 neighborhood as fitting data, setting the polynomial order N_1 to 2nd order. A 2nd order polynomial can accurately fit the curve shape of the edge, avoiding overfitting problems caused by higher order polynomials. A two-dimensional grayscale distribution function is constructed centered on the edge pixel. The polynomial coefficients are solved using the least squares method to fit the grayscale extrema at the edge. The coordinates of these extrema are the sub-pixel level edge coordinates. The sub-pixel positioning accuracy P_1 can reach 0.01 pixels, far exceeding the pixel-level positioning accuracy, accurately capturing the minute concavity and tortuosity features of the eroded contour. For different eroded damage points, including point-like and sheet-like erosion edges, polynomial fitting can adaptively adjust the fitting parameters, preserving the detailed features of the contour while eliminating false edges caused by noise in the initial segmentation mask. After completing the sub-pixel localization of all edge points, the sub-pixel edge points are connected sequentially according to the connectivity of the eroded region. Isolated edge noise points are eliminated, and the connections are integrated to form a continuous, smooth, and refined erosion contour. This contour completely restores the true boundary of the metal corrosion damage points without pixel-level jagged edges or offsets, providing an accurate contour basis for subsequent binarization mask generation.
[0037] Based on the refined erosion contour, the image is binarized, with pixels in the eroded area marked as 1 and pixels in the non-eroded area marked as 0, ultimately generating a binarized mask image of the erosion damage points.
[0038] The core of this step is to perform binarization of the image based on the refined erosion contour. By setting a binarization threshold, eroded and non-eroded areas are distinguished, and the image is transformed into a binary mask containing only 0 and 1. This clarifies the pixel range of erosion damage points and provides standardized region identifiers for subsequent 3D reconstruction and geometric feature calculation. The specific implementation method is as follows: The refined erosion contour precisely defines the boundary between the eroded area and the metal substrate. Binarization processing requires using this contour as a reference to classify and label all pixels within the image. A contour-filling binarization algorithm is employed, which avoids misjudgments caused by global threshold binarization, ensuring that the labeling of the eroded area accurately matches the refined contour. First, all sub-pixel coordinates of the refined erosion contour are traversed, mapping the contour coordinates to a 512 pixel × 512 pixel image coordinate system. A scanline algorithm is then used to fill and label the pixel areas inside the contour. The scanline traverses line by line from the top to the bottom of the image, determining whether each row of pixels is inside the refined erosion contour. Pixels inside the contour are identified as eroded area pixels and assigned a value of 1, while pixels outside the contour are identified as non-eroded area pixels and assigned a value of 0.
[0039] During binarization, the contour boundary determination error E_1 is set to 0.005 pixels. This error value is suitable for the positioning accuracy of sub-pixel contours, ensuring that the boundary pixels are marked without omission or overflow, and avoiding pixel loss or substrate mislabeling in the eroded area. For multiple independent erosion damage points, the contours of different eroded areas are distinguished by connected component recognition logic, and the interior of each independent contour is filled separately to ensure that the binarized markings of different eroded points are independent and do not interfere with each other. After marking all pixels, a single-channel binarized image is generated. The image contains only two pixel values: 1 and 0. The set of pixels with the value 1 constitutes the complete area of the eroded damage point, and the set of pixels with the value 0 represents the uncorroded metal substrate. This image is the binarized mask image of the eroded damage point.
[0040] After generation, the integrity of the binarized mask image is checked to see if the pixel distribution of the eroded area matches the refined erosion contour, and whether there are isolated 1-valued noise points or missing contours. After the check is passed, the mask image retains complete spatial location information and regional range information, which can be directly used for subsequent erosion point connected component analysis and 3D reconstruction calculation, providing standardized regional identification data for erosion geometric feature extraction.
[0041] S203, Based on the binarized mask image, a three-dimensional reconstruction algorithm is used to restore the depth information of the corrosion area, calculate the geometric feature parameters of each corrosion damage point, and generate a set of corrosion damage points with quantized attributes. Specifically, the two-dimensional coordinates and contour information of each corrosion damage point can be extracted based on the binary mask image, and the independent corrosion point regions can be marked by the connected component analysis algorithm to generate a set of connected components of corrosion points; The core of this step is to extract the basic spatial information of the corrosion damage points and divide them into independent regions based on the generated binary mask image of the corrosion damage points. Then, a connected component analysis algorithm is used to classify discrete corrosion pixels into independent corrosion damage regions, providing accurate region division criteria for subsequent depth information recovery. The specific implementation method is as follows: The binarized mask image is the core input data for this step. The image contains only two pixel values: pixels in eroded areas are uniformly marked with a value of 1, and pixels in non-eroded areas are uniformly marked with a value of 0. The image uses a Cartesian coordinate system for spatial positioning, with the origin set at the top-left pixel of the image, the horizontal axis as the x_0 axis, and the vertical axis as the y_0 axis. The minimum precision unit of pixel coordinates is 0.5px, which can accurately represent the spatial position of each pixel in the image. First, the binarized mask image is scanned row by row and pixel by pixel to filter out all eroded area pixels with a value of 1. The x_0 and y_0 axis coordinates corresponding to each eroded pixel are recorded, thus completing the initial extraction of the two-dimensional coordinates of all eroded damage points. During the scanning process, a pixel value judgment threshold P_0 is set to 1. Only pixels with a value equal to this threshold are judged as eroded pixels and their coordinates are recorded, avoiding the mis-extraction of pixels in non-eroded areas.
[0042] After extracting the two-dimensional coordinates, a contour tracing algorithm is used to extract the contour information of the corrosion damage points. This algorithm connects discrete corrosion pixels into a closed contour curve by tracing the boundary direction of pixels in the corrosion region. The contour curve is composed of continuous pixel coordinate points, which can completely delineate the external boundary shape of a single corrosion damage region. The accuracy of contour extraction is controlled within 1px, ensuring that the contour lines are unbroken and without offset, and completely restoring the actual contour features of the corrosion damage points. Subsequently, an 8-neighborhood connected component analysis algorithm is introduced to label the extracted corrosion pixels and contour information. The core judgment rule of this algorithm is to take the current corrosion pixel as the center and determine whether its eight adjacent pixels (up, down, left, right, and four diagonal directions) are all corrosion pixels. If the adjacent pixels meet the corrosion pixel judgment condition, they are classified into the same connected region. The judgment threshold T_1 of the neighborhood matching is set to 1, that is, only adjacent pixels with a pixel value of 1 can complete the connected matching.
[0043] During algorithm execution, a unique region identifier ID is assigned to each independent connected erosion region, numbered sequentially starting from ID_1. Simultaneously, the total number of pixels, the coordinate range of the minimum bounding rectangle, and the complete contour coordinate sequence are recorded for each connected region. The minimum bounding rectangle is used to quickly define the spatial extent of the erosion region; the coordinates of the top-left and bottom-right corners of the rectangle correspond to the extreme coordinates of the connected region, intuitively reflecting the size and location of the erosion region. After marking the connected regions of all erosion regions, the identifier ID, 2D pixel coordinate set, contour closure curve data, and minimum bounding rectangle parameters of each independent erosion connected region are integrated and stored in order according to the identifier ID. This ultimately generates a set of erosion point connected regions. This set completely includes the basic spatial information of all independent erosion damage regions in the image, with no region omissions or duplicate markings, clearly defining processing units for subsequent 3D depth information recovery.
[0044] A photometric stereo 3D reconstruction algorithm is applied to the connected components of each corrosion point, and the depth information of the corrosion area is recovered by combining the illumination change information in the multispectral image sequence to generate a corrosion point depth map. The core of this step is to use a photometric stereo 3D reconstruction algorithm to fuse illumination difference information from multispectral lighting into the already defined connected regions of corrosion points. This transforms the two-dimensional corrosion contour information into three-dimensional depth data, generating a corrosion point depth map that characterizes the degree of corrosion depression. This provides depth-dimensional data support for the calculation of geometric feature parameters. The specific implementation method is as follows: The photometric stereoscopic 3D reconstruction algorithm is the core technology for achieving depth recovery of corroded areas. Based on the Lambertian diffuse reflection model, this algorithm constructs the mathematical relationship between illumination and surface reflection. It requires no additional 3D scanning equipment, relying solely on illumination variation information from different bands in a multispectral image sequence to complete depth calculation. The algorithm's depth calculation accuracy is controlled within 0.01 mm, enabling precise capture of minute corrosion indentations on the metal surface. The multispectral image sequence includes illumination images in three bands: ultraviolet, visible, and infrared. Each band corresponds to a set of independent illumination direction parameters. The illumination direction vectors are set as follows: L_1 for the ultraviolet band, L_2 for the visible band, and L_3 for the infrared band. The zenith angles of these three direction vectors are 30°, 45°, and 60°, and the azimuth angles are 0°, 90°, and 180°, respectively. Different illumination angles create differentiated light and shadow distributions on the corroded metal surface, which is the key basis for depth recovery.
[0045] During algorithm execution, a single corrosion point connected component is used as the processing unit. The pixel grayscale value of the corresponding position in the three spectral band images of this connected component is extracted. The grayscale value reflects the reflection intensity of the corrosion surface under different illuminations. Combined with the preset metal material surface reflectivity parameter ρ_0, which is set to 0.8, representing the diffuse reflection ratio of the metal substrate to multispectral light, the surface normal vector of each pixel in the corrosion area is calculated by solving a system of linear equations. The surface normal vector can characterize the tilt of the corrosion surface and is a key intermediate data for depth calculation. The depth recovery process adopts an iterative calculation method. The iteration convergence threshold ε_1 is set to 0.01mm. When the depth difference between two adjacent iterations is less than this threshold, the depth calculation result is considered to have converged, the iteration stops, and the final depth value is output. The physical unit of the depth value is millimeters, and the value directly corresponds to the corrosion pit depth of the metal surface. The depth value of non-corrosion areas is uniformly set to 0, representing that there is no corrosion pit on the surface.
[0046] After calculating the depth of all pixels in a single eroded connected region, the depth values are mapped and arranged according to the pixel coordinates of the original image to generate an erosion point depth map with the same resolution as the original image. The depth map uses a grayscale gradient to visualize the depth information; the larger the depth value, the higher the grayscale value of the eroded depression area, and the smaller the depth value, the lower the grayscale value, which can intuitively distinguish the depth of erosion. The above depth calculation and mapping operation is performed one by one for each eroded connected region, finally generating a complete erosion point depth map. This depth map completely preserves the three-dimensional depth features of each eroded damage point, corresponding one-to-one with the two-dimensional spatial coordinates, without missing or distorted depth data, laying a data foundation for the subsequent quantitative calculation of geometric feature parameters.
[0047] The geometric feature parameters of each corrosion damage point are calculated based on the corrosion point depth map, including corrosion area, maximum depth, average depth and volume, and a geometric feature vector of the corrosion point is generated. The core of this step is to quantitatively calculate the geometry of each independent corrosion damage point based on the depth data and spatial coordinate information in the corrosion point depth map, and extract four core feature parameters: corrosion area, maximum depth, average depth, and volume. These discrete parameters are then integrated into a standardized feature vector to achieve a digital quantitative representation of the corrosion damage point. The specific implementation method is as follows: Before calculating the geometric feature parameters, an image physical calibration coefficient K_1 is first introduced to convert pixel coordinates to actual physical dimensions. This coefficient is 0.01 mm / px, representing the physical length of 0.01 mm on the actual metal surface corresponding to a single pixel in the image. Squaring this coefficient yields an area calibration coefficient K_2 of 0.0001 mm² / px², used to convert the number of pixels into the actual corrosion area, ensuring that the calculation results conform to the measurement standards of the actual size of the metal material. First, the corrosion area parameter is calculated. For a single corrosion point connected region, the total number of pixels N_1 with a depth value greater than 0 in the depth map is counted. The total number of pixels is multiplied by the area calibration coefficient K_2 to obtain the actual corrosion area S of the corrosion damage point. The calculation formula is S = N_1 × K_2. The calculation result is rounded to two decimal places to accurately reflect the actual coverage area of the corrosion region.
[0048] Next, the maximum depth and average depth parameters are calculated. The maximum depth, D_max, is the maximum depth value of all pixels in the depth map of the corroded connected region, representing the deepest depression of the corrosion damage point and a key indicator for judging the severity of corrosion. The average depth, D_avg, is the arithmetic mean of all effective depth values in the connected region. It is calculated by summing all depth values in the connected region and dividing by the total number of effective pixels, N_1. It can characterize the overall depression level of the corroded area. Both depth parameters are rounded to two decimal places, and the unit is uniformly millimeters. Next, the corrosion volume parameter, V, is calculated. This parameter reflects the volume of material loss caused by corrosion. It is calculated by multiplying the corrosion area by the average depth, with the formula V = S × D_avg. The volume unit is cubic millimeters, and the calculation result is also rounded to two decimal places, intuitively quantifying the degree of material loss caused by corrosion.
[0049] Taking a typical localized corrosion damage point as an example, the total number of effective pixels N_1 in this connected region is 1600. The calculated corrosion area S = 1600 × 0.0001 = 0.16 mm², the maximum depth D_max in the depth map is 1.35 mm, the average depth D_avg is 0.72 mm, and the corrosion volume V = 0.16 × 0.72 = 0.1152 mm³. After calculating the four geometric feature parameters, the corrosion area, maximum depth, average depth, and volume are combined in a fixed order to construct a four-dimensional geometric feature vector of the corrosion point, represented in vector form as [S, D_max, D_avg, V]. Each parameter carries a corresponding physical unit identifier. The vector format is standardized and there are no missing parameters, which can completely characterize the geometric morphological features of a single corrosion damage point, providing quantitative data for subsequent spatial distribution identification and corrosion level assessment.
[0050] The geometric feature vectors of corrosion points are associated with and stored with the two-dimensional coordinates of the corresponding corrosion points to construct a set of corrosion damage points that includes spatial location and quantification attributes.
[0051] The core of this step is to fuse and correlate the spatial location information of corrosion damage points with their quantified geometric features. All corrosion point data is integrated using a standardized storage method to construct a corrosion damage point set that combines spatial localization and attribute quantification. This provides a complete dataset for subsequent density clustering analysis and corrosion report generation. The specific implementation method is as follows: First, the physical transformation rules for the two-dimensional coordinates of corrosion points are determined. The previously extracted pixel two-dimensional coordinates are converted into actual physical coordinates using the image calibration coefficient K_1. The lower left corner of the metal surface under test is taken as the origin of the actual physical coordinate system, with the horizontal direction as the X-axis and the vertical direction as the Y-axis. The unit of physical coordinates is millimeters. The center physical coordinates (X_c, Y_c) of a single corrosion point are calculated by averaging the coordinates of all pixels in the connected region, representing the core spatial location of the corrosion damage point on the metal surface. The coordinate precision is retained to two decimal places to ensure accurate spatial positioning. Subsequently, an association mapping relationship for corrosion point data is established. The unique identifier ID of each corrosion connected region is used as the association primary key. The center physical coordinates, complete contour physical coordinates, and corrosion point geometric feature vectors corresponding to this ID are bound one by one to ensure that each set of quantified features can accurately correspond to the specific corrosion location on the metal surface without any association misalignment or data confusion.
[0052] The storage process adopts a standardized text storage mode without format dependency, and arranges data in ascending order of corrosion point identifier ID. Each data record contains four modules: identifier ID, central physical coordinates, contour coordinate sequence, and geometric feature vector. The modules are separated by fixed delimiters to facilitate fast reading and parsing by subsequent algorithms. The data integrity is checked during storage. The check items include the range of coordinate values, the rationality of feature parameters, and the uniqueness of correlation relationships. The check threshold is set as follows: the coordinate value does not exceed the actual size of the surface to be measured, the depth parameter is non-negative, and the volume parameter matches the area and depth. Data that fails the check will be recalculated and corrected to ensure the accuracy and validity of the final stored data.
[0053] After integrating the associated data of all corrosion damage points, a corrosion damage point set is finally constructed. This dataset fully contains the spatial location information and quantitative geometric attributes of each corrosion damage point. It can not only clearly identify the distribution location of corrosion points on the metal surface, but also accurately reflect the damage degree characteristics such as area, depth, and volume of corrosion. The data structure is clear and logically coherent, and can be directly used as input data for density clustering algorithms. It supports the subsequent work of corrosion distribution pattern recognition, corrosion type differentiation, and grade assessment, and provides complete data support for the comprehensive analysis of corrosion damage of metallic materials.
[0054] S204. Based on the set of corrosion damage points, a density clustering algorithm is used to identify the spatial distribution pattern of discrete corrosion points, distinguish between uniform corrosion and local corrosion areas, and generate an analysis report that includes corrosion level assessment and distribution heatmap.
[0055] Specifically, the spatial coordinates and geometric feature parameters of all corrosion points can be extracted from the corrosion damage point set, and the DBSCAN density clustering algorithm can be used to perform spatial clustering analysis on the corrosion points to generate corrosion point clustering results. The core of this step is to screen effective data from the established set of corrosion damage points, extract the spatial location and quantified geometric features of the corrosion points, and use the DBSCAN density clustering algorithm to achieve spatial clustering of the corrosion points. Finally, clustering results that characterize the distribution and clustering features of the corrosion points are generated, laying the data foundation for subsequent corrosion type differentiation. The specific implementation method is as follows: The corrosion damage point set is a structured data set that integrates the two-dimensional spatial coordinates and geometric feature parameters of corrosion points. Before performing the extraction operation, the set is first cleaned to remove invalid corrosion point data caused by image noise, sub-pixel positioning errors, or three-dimensional reconstruction deviations. The criterion for invalid data is that the corrosion area is less than 0.01 square millimeters. Such data belongs to pseudo-corrosion interference points and does not have the actual meaning of corrosion damage characterization. The data retained after cleaning are all valid corrosion point data. Subsequently, the cleaned set is traversed, and the core parameters of each valid corrosion point are extracted one by one. The spatial coordinates are the x_p and y_p values of the corrosion point in the image pixel coordinate system. x_p represents the horizontal position of the pixel, and y_p represents the vertical position of the pixel. The coordinate precision is sub-pixel level, and the values are retained to two decimal places, which can accurately reflect the planar position of the corrosion point on the metal surface. The geometric feature parameters include corrosion area S_i, maximum depth D_max_i, average depth D_avg_i, and corrosion volume V_i. S_i is in square millimeters and is used to characterize the coverage area of the corrosion point on the metal surface. D_max_i is in micrometers and represents the deepest value of the recessed area of the corrosion point. D_avg_i is the arithmetic mean of all depth pixels in the corrosion point area. V_i is in cubic millimeters and is the sum of the corrosion volume in the three-dimensional space of the corrosion point. The four types of parameters together constitute the quantitative characteristics of the corrosion point.
[0056] After extraction, the spatial coordinates of all valid corrosion points are integrated into a spatial feature vector P_i=(x_p_i,y_p_i), which serves as the input for the DBSCAN density clustering algorithm. This algorithm does not require pre-setting the number of clusters and can automatically divide clustering regions based on the spatial density of corrosion points, adapting to the random distribution of corrosion points on metal surfaces. The algorithm relies on two core parameters: the neighborhood radius Eps and the minimum number of points MinPts. The neighborhood radius Eps is set to 15 pixels, representing the area within 15 pixels centered on a given corrosion point as the neighborhood of that point. The pixel distance is also converted to actual physical distance, with 1 pixel corresponding to 0.02 millimeters, ensuring that the clustering results closely match the real spatial scale of the metal surface. The minimum number of points MinPts is set to 8, representing the minimum number of corrosion points required in the neighborhood of a core point, and is a key threshold for distinguishing core points, boundary points, and noise points.
[0057] During algorithm execution, all unvisited corrosion points are first marked. The number of corrosion points in the neighborhood of each point is calculated sequentially. If the number of corrosion points in the neighborhood is greater than or equal to MinPts, the point is marked as a core point. Then, all corrosion points in the neighborhood are included in the same cluster. The neighborhood is then recursively expanded using density reachability rules, grouping all spatially connected corrosion points into the same cluster. Isolated corrosion points that cannot be included in any cluster are marked as noise points. After the algorithm finishes running, corrosion point clustering results are generated. These results are stored in structured data format, including cluster numbers, the total number of corrosion points in each cluster, the cluster affiliation identifier for each corrosion point, and a set of noise points. Each cluster corresponds to a corrosion point aggregation area on the metal surface, while noise points are scattered, independent corrosion points. The spatial partitioning accuracy of the clustering results reaches sub-pixel level, fully presenting the spatial aggregation pattern of corrosion points.
[0058] Based on the corrosion point clustering results, the corrosion point density and coverage of each cluster are calculated. The corrosion type is determined by combining the geometric features of the corrosion points, and uniform corrosion areas and local corrosion areas are distinguished to generate corrosion type classification results. The core of this step is to perform quantitative parameter calculations based on the corrosion point clustering results. By combining corrosion point density, coverage area, and geometric features, classification rules are established to accurately distinguish between uniform corrosion and localized corrosion areas, resulting in standardized corrosion type classification results. The specific implementation method is as follows: First, for the effective clusters in the corrosion point clustering results, after removing noise points, core parameters are calculated. First, the corrosion point density ρ_k of each cluster is calculated. ρ_k is the ratio of the number of effective corrosion points N_k in the k-th cluster to the actual coverage area A_k of that cluster, in units of points per square millimeter. N_k is the total number of corrosion points in the cluster after cleaning. A_k is obtained by fitting the minimum bounding rectangle to the spatial coordinates of all corrosion points within the cluster. The maximum and minimum values of x_p and y_p of the corrosion points within the cluster are extracted, converted to actual physical dimensions, and then the length and width of the rectangle are calculated. The product of these two values is A_k, in square millimeters. Next, the coverage area of the cluster is calculated, characterized by spatial extension L_k. L_k is the diagonal length of the minimum bounding rectangle, in millimeters. The value directly reflects the extent of corrosion on the metal surface; a larger value indicates a wider corrosion distribution.
[0059] After calculating the density and coverage, the geometric mean values of corrosion points within each cluster are further calculated, including the average corrosion area S_avg_k, the average maximum depth D_max_avg_k, and the average corrosion volume V_avg_k. These three mean values are the arithmetic mean of the parameters corresponding to all corrosion points within the cluster, and can comprehensively characterize the degree of corrosion damage of the cluster. Based on the above parameters, corrosion type determination rules are established. The criteria for uniform corrosion are: corrosion point density ρ_k greater than 0.5 per square millimeter, spatial extension L_k greater than 50 millimeters, and the average corrosion area S_avg_k less than 0.2 square millimeters and the average maximum depth D_max_avg_k less than 50 micrometers. These corrosion points are densely distributed and have a wide coverage area. Individual corrosion points are small in size and shallow in depth, exhibiting a large-area uniform distribution morphological characteristic. Localized corrosion is divided into two types: pitting corrosion and patchy corrosion. The criteria for pitting corrosion are: a density of corrosion pits ρ_k less than 0.2 per square millimeter, a spatial extension L_k less than 10 millimeters, and an average maximum depth D_max_avg_k greater than 100 micrometers within the cluster. It is characterized by deep individual corrosion pits, small size, and scattered distribution. The criteria for patchy corrosion are: a density of corrosion pits ρ_k between 0.2 and 0.5 per square millimeter, a spatial extension L_k between 10 and 50 millimeters, and an average corrosion area S_avg_k greater than 0.2 square millimeters within the cluster. It is characterized by corrosion pits concentrated in localized small areas, forming obvious corrosion patches.
[0060] Noise points that do not form clusters are uniformly classified as scattered local corrosion points due to their lack of spatial aggregation characteristics. To avoid classification errors caused by parameter thresholds, threshold buffers are set: ±0.03 points per square millimeter for density and ±1 millimeter for ductility. Clusters within these buffers are determined by combining the corrosion characteristics of adjacent areas. After all areas are classified, a corrosion type classification result is generated. This result is divided according to the physical regions of the metal surface, labeling each region as either uniform corrosion or localized corrosion, and also indicating the sub-type of localized corrosion. The corresponding cluster number and core parameters are associated, achieving millimeter-level classification accuracy and precisely matching the actual corrosion morphology of the metal material.
[0061] Based on the corrosion type classification results and the geometric characteristics of corrosion points, the corrosion level of each area is determined with reference to the preset corrosion level assessment standard, including levels of slight corrosion, moderate corrosion and severe corrosion, and corrosion level assessment results are generated. The core of this step is to establish grading standards based on differences in corrosion types, and to quantitatively determine the corrosion level of each area based on the geometric characteristics of corrosion points, generating corrosion assessment results including three levels: slight, moderate, and severe. This provides a quantitative basis for analyzing the degree of corrosion damage. The specific implementation method is as follows: The pre-defined corrosion level assessment standard is formulated in conjunction with the metal material corrosion engineering testing specifications. Different judgment thresholds are set for uniform corrosion and localized corrosion to eliminate the influence of corrosion type differences on the level assessment. For uniform corrosion areas, the average corrosion depth D_avg_total and corrosion amount per unit area M_ave are used for joint judgment. D_avg_total is the overall mean value of the average depth of all corrosion points in the uniform corrosion area, in micrometers, and M_ave is the ratio of the total corrosion volume to the total area of the area, in cubic millimeters per square millimeter. The criteria for determining a slight corrosion level are: D_avg_total less than 20 micrometers and M_ave less than 0.01 cubic millimeters per square millimeter. At this level, only a shallow and uniform oxidation corrosion occurs on the metal surface, without affecting the structural strength of the material. The criteria for determining a moderate corrosion level are: D_avg_total between 20 and 80 micrometers and M_ave between 0.01 and 0.05 cubic millimeters per square millimeter. The corrosion layer thickness increases, and slight peeling occurs on the metal surface. The criteria for determining a severe corrosion level are: D_avg_total greater than 80 micrometers and M_ave greater than 0.05 cubic millimeters per square millimeter. Uniform corrosion penetrates deep into the material surface, resulting in significant material loss.
[0062] For localized corrosion areas, judgment rules are set according to sub-types. For pitting localized corrosion, the maximum corrosion depth D_max_single is used as the core parameter, while for patchy localized corrosion, the average corrosion area S_avg_cluster and the total corrosion volume V_total are used as core parameters. Slight pitting localized corrosion is defined as D_max_single less than 50 micrometers, indicating a shallow pit depth; moderate localized corrosion is defined as D_max_single between 50 and 150 micrometers, where the pit depth has a certain impact on the local properties of the material; severe localized corrosion is defined as D_max_single greater than 150 micrometers, where the pit easily induces stress concentration in the material. Slight localized corrosion is characterized by a cluster size of less than 0.3 square millimeters and a total volume of less than 0.05 cubic millimeters, with extremely small corrosion patches. Moderate localized corrosion is characterized by a cluster size of 0.3 to 0.8 square millimeters and a total volume of 0.05 to 0.2 cubic millimeters. Severe localized corrosion is characterized by a cluster size of greater than 0.8 square millimeters and a total volume of greater than 0.2 cubic millimeters, with corrosion patches causing significant damage to the local structure of the material.
[0063] Before rating, extreme outliers deviating from the mean by three times the standard deviation in geometric characteristic parameters are removed to ensure the objectivity of the assessment results. For critical areas crossing different rating levels, a weighted scoring method is used for comprehensive judgment, with average depth accounting for 0.6, corrosion volume accounting for 0.3, and corrosion area accounting for 0.1. A total weighted score below 30 indicates slight corrosion, 30 to 70 indicates moderate corrosion, and above 70 indicates severe corrosion. After rating all areas, a corrosion rating assessment result is generated. This result divides the metal surface into multiple assessment units, each labeled with corrosion type, corrosion level, and core judgment parameters. Parameter values are retained to two decimal places, achieving micron-level accuracy and clearly reflecting the degree of corrosion damage in different areas.
[0064] By integrating the spatial distribution of corrosion points, corrosion type classification results, and corrosion level assessment results, a corrosion distribution heat map and a structured analysis report are generated, and the final output is an analysis report containing a visualized heat map and quantitative assessment.
[0065] The core of this step is to integrate three types of core data: corrosion spatial distribution, type classification, and level assessment. A corrosion distribution heatmap is generated through visualization rendering, and a hierarchical structured report is written. The final output is a corrosion analysis report that combines intuitive visualization with precise quantitative attributes. The specific implementation method is as follows: First, multi-dimensional data integration was conducted, linking the spatial coordinates of corrosion points, corrosion type classification data, and corrosion level assessment data to establish a unified database of metal surface corrosion information. Each record in the database includes the pixel coordinates of the corrosion point, the actual physical coordinates, the corrosion type, the corrosion level, and geometric feature parameters. The data format is unified as a combination of numerical and text types, adapting to the needs of visualization rendering and text generation. Subsequently, a corrosion distribution heatmap was rendered. Using the original multispectral image of the metal surface under test as the base map, the image pixel coordinate system was precisely matched with the actual physical coordinate system, with the matching error controlled within 0.01 mm, ensuring that the heatmap completely corresponds to the actual corrosion location.
[0066] The heatmap uses a color gradient to map corrosion level and intensity, with standardized color mapping rules: light blue-green areas are used for slightly corroded regions, with color saturation increasing slightly with corrosion severity; moderately corroded areas are used for orange-yellow areas with moderate saturation; and severely corroded areas are used for deep red areas with the highest saturation. The density and depth of corrosion points are represented by the superposition of color shades; the greater the density and depth, the darker the color. To enhance the visual effect of the heatmap, a Gaussian blur algorithm is used to smooth the clustered regions, with a blur radius set to 3 pixels to eliminate pixel-level abrupt boundaries, resulting in a continuous and natural corrosion distribution. Additionally, solid white lines with a width of 1 pixel are used to mark the boundaries between uniform and localized corrosion areas, clearly distinguishing different corrosion types.
[0067] The structured analysis report adopts a hierarchical writing structure. The opening provides an overview of the overall corrosion situation of the surface under test, including the total number of corrosion points, the proportion of uniform corrosion and localized corrosion area, and the proportion of each corrosion level area. The middle part elaborates on the corrosion type in separate chapters, explaining the distribution range of uniform corrosion areas, average corrosion parameters and the basis for level determination, the cluster distribution of localized corrosion areas, the corrosion parameters of each cluster, and the sub-types and levels. All quantitative data are labeled with units and retained to two decimal places. The concluding part gives a comprehensive evaluation of corrosion damage, analyzing the corrosion distribution pattern and potential material damage risk.
[0068] Finally, the corrosion distribution heatmap and structured analysis report are integrated and output. The visualized heatmap is presented as a color overlay image, which can quickly locate severely corroded areas. The quantitative assessment text is embedded in the report, fully presenting corrosion parameter statistics, level determination details, type classification summary, and other content. The final output analysis report balances intuitiveness and accuracy, allowing users to quickly grasp the overall corrosion distribution through visualized images and clearly define the specific degree of corrosion damage through quantitative data, comprehensively presenting all the results of the collection and analysis of corrosion damage points in metallic materials.
[0069] Another embodiment of the present invention provides a system for acquiring corrosion damage points of metallic materials based on machine vision technology, see [link to documentation]. Figure 3The system may include: The acquisition module 301 is used to illuminate the surface of the metal material to be tested in segments through a multispectral light source array, and to simultaneously acquire image sequences of the corrosion area under different spectral bands using an industrial camera, thereby generating an original image set containing spectral features and spatial information. The extraction module 302 is used to perform semantic segmentation of the erosion region based on deep learning on the original image set, extract the preliminary contour information of the erosion damage points, and at the same time combine the sub-pixel edge detection algorithm to refine the erosion contour and generate a binary mask image of the erosion damage points. The generation module 303 is used to recover the depth information of the corrosion area by using a three-dimensional reconstruction algorithm based on the binarized mask image, calculate the geometric feature parameters of each corrosion damage point, and generate a set of corrosion damage points with quantized attributes. The identification module 304 is used to identify the spatial distribution pattern of discrete corrosion points based on the corrosion damage point set using a density clustering algorithm, distinguish between uniform corrosion and local corrosion areas, and generate an analysis report that includes corrosion level assessment and distribution heat map.
[0070] This invention also provides a storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.
[0071] This invention also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0072] The above description, based on the embodiments shown in the figures, details the structure, features, and effects of the present invention. The above description is only a preferred embodiment of the present invention, but the present invention is not limited to the scope of implementation shown in the figures. Any changes made in accordance with the concept of the present invention, or equivalent embodiments modified to have equivalent changes, that do not exceed the spirit covered by the specification and figures, should be within the protection scope of the present invention.
Claims
1. A method for acquiring corrosion damage points in metallic materials based on machine vision technology, characterized in that, The method includes: The surface of the metal material to be tested is illuminated in segments by a multispectral light source array, and the corrosion area image sequence under different spectral bands is acquired simultaneously by an industrial camera to generate an original image set containing spectral features and spatial information. The original image set is subjected to semantic segmentation of the erosion region based on deep learning to extract the preliminary contour information of the erosion damage points. At the same time, the sub-pixel edge detection algorithm is combined to refine the localization of the erosion contour and generate a binary mask image of the erosion damage points. Based on the binarized mask image, a three-dimensional reconstruction algorithm is used to restore the depth information of the corroded area, calculate the geometric feature parameters of each corrosion damage point, and generate a set of corrosion damage points with quantized attributes. Based on the set of corrosion damage points, a density clustering algorithm is used to identify the spatial distribution pattern of discrete corrosion points, distinguish between uniform corrosion and localized corrosion areas, and generate an analysis report that includes corrosion level assessment and distribution heatmap.
2. The method according to claim 1, characterized in that, The process involves segmented illumination of the metal surface under test using a multispectral light source array, and simultaneous acquisition of image sequences of the corrosion area under different spectral bands using an industrial camera, generating an original image set containing spectral features and spatial information, including: Based on the type and corrosion characteristics of the metal material, the band combination of the multispectral light source array is configured, including the ultraviolet band, visible light band and infrared band, to generate a light source band configuration scheme; Based on the light source band configuration scheme, the multispectral light source array is controlled to illuminate the surface under test in segments. Each band is illuminated independently and the illumination parameters are recorded to generate segmented illumination timing control commands. The industrial camera is synchronously triggered to acquire images of the corrosion area under each illumination band. The camera maintains a fixed position and focal length to ensure that the spatial position of the images is consistent, and the original corrosion images of each band are generated. Image registration and band alignment are performed on the original corrosion images of each band to eliminate the slight shifts caused by the switching of light sources, and finally generate an original image set containing spectral features and spatial information.
3. The method according to claim 2, characterized in that, The process of performing deep learning-based semantic segmentation of eroded regions on the original image set to extract preliminary contour information of eroded damage points, and simultaneously using a sub-pixel edge detection algorithm to refine the eroded contour localization, generating a binarized mask image of the eroded damage points, includes: The original image set is preprocessed by data augmentation and normalization, and the image size and contrast are adjusted to meet the input requirements of the deep learning model to generate preprocessed image data. The preprocessed image data is input into the pre-trained U-Net semantic segmentation network, and the pixel-level classification results of the eroded region are extracted through the encoder-decoder structure to generate a preliminary segmentation mask for the eroded region. A subpixel edge detection algorithm is applied to the initial segmentation mask of the eroded area. The Canny operator combined with the polynomial fitting method is used to perform subpixel-level localization of the eroded contour and generate a refined eroded contour. Based on the refined erosion contour, the image is binarized, with pixels in the eroded area marked as 1 and pixels in the non-eroded area marked as 0, ultimately generating a binarized mask image of the erosion damage points.
4. The method according to claim 3, characterized in that, The step of restoring depth information of the corroded area using a 3D reconstruction algorithm based on the binarized mask image, calculating the geometric feature parameters of each corrosion damage point, and generating a set of corrosion damage points with quantized attributes includes: Based on the binary mask image, the two-dimensional coordinates and contour information of each corrosion damage point are extracted. The connected component analysis algorithm is used to mark the independent corrosion point regions and generate a set of connected components of corrosion points. A photometric stereo 3D reconstruction algorithm is applied to the connected components of each corrosion point, and the depth information of the corrosion area is recovered by combining the illumination change information in the multispectral image sequence to generate a corrosion point depth map. The geometric feature parameters of each corrosion damage point are calculated based on the corrosion point depth map, including corrosion area, maximum depth, average depth and volume, and a geometric feature vector of the corrosion point is generated. The geometric feature vectors of corrosion points are associated with and stored with the two-dimensional coordinates of the corresponding corrosion points to construct a set of corrosion damage points that includes spatial location and quantification attributes.
5. The method according to claim 4, characterized in that, Based on the set of corrosion damage points, a density clustering algorithm is used to identify the spatial distribution pattern of discrete corrosion points, distinguishing between uniform corrosion and localized corrosion regions, and generating an analysis report that includes corrosion level assessment and a distribution heatmap, including: The spatial coordinates and geometric feature parameters of all corrosion points are extracted from the corrosion damage point set. The DBSCAN density clustering algorithm is used to perform spatial clustering analysis on the corrosion points to generate corrosion point clustering results. Based on the corrosion point clustering results, the corrosion point density and coverage of each cluster are calculated. The corrosion type is determined by combining the geometric features of the corrosion points, and uniform corrosion areas and local corrosion areas are distinguished to generate corrosion type classification results. Based on the corrosion type classification results and the geometric characteristics of corrosion points, the corrosion level of each area is determined with reference to the preset corrosion level assessment standard, including levels of slight corrosion, moderate corrosion and severe corrosion, and corrosion level assessment results are generated. By integrating the spatial distribution of corrosion points, corrosion type classification results, and corrosion level assessment results, a corrosion distribution heat map and a structured analysis report are generated, and the final output is an analysis report containing a visualized heat map and quantitative assessment.
6. A system for acquiring corrosion damage points in metallic materials based on machine vision technology, characterized in that, The system includes: The acquisition module is used to illuminate the surface of the metal material under test in segments through a multispectral light source array, and to simultaneously acquire image sequences of the corrosion area under different spectral bands using an industrial camera, generating a raw image set containing spectral features and spatial information. The extraction module is used to perform semantic segmentation of the eroded region based on deep learning on the original image set, extract the preliminary contour information of the eroded damage points, and at the same time combine the sub-pixel edge detection algorithm to refine the eroded contours and generate a binary mask image of the eroded damage points. The generation module is used to recover the depth information of the corrosion area based on the binarized mask image using a three-dimensional reconstruction algorithm, calculate the geometric feature parameters of each corrosion damage point, and generate a set of corrosion damage points with quantized attributes. The identification module is used to identify the spatial distribution pattern of discrete corrosion points based on the set of corrosion damage points using a density clustering algorithm, distinguish between uniform corrosion and local corrosion areas, and generate an analysis report that includes corrosion level assessment and distribution heatmap.
7. The system according to claim 6, characterized in that, The acquisition module is specifically used for: Based on the type and corrosion characteristics of the metal material, the band combination of the multispectral light source array is configured, including the ultraviolet band, visible light band and infrared band, to generate a light source band configuration scheme; Based on the light source band configuration scheme, the multispectral light source array is controlled to illuminate the surface under test in segments. Each band is illuminated independently and the illumination parameters are recorded to generate segmented illumination timing control commands. The industrial camera is synchronously triggered to acquire images of the corrosion area under each illumination band. The camera maintains a fixed position and focal length to ensure that the spatial position of the images is consistent, and the original corrosion images of each band are generated. Image registration and band alignment are performed on the original corrosion images of each band to eliminate the slight shifts caused by the switching of light sources, and finally generate an original image set containing spectral features and spatial information.
8. The system according to claim 7, characterized in that, The extraction module is specifically used for: The original image set is preprocessed by data augmentation and normalization, and the image size and contrast are adjusted to meet the input requirements of the deep learning model to generate preprocessed image data. The preprocessed image data is input into the pre-trained U-Net semantic segmentation network, and the pixel-level classification results of the eroded region are extracted through the encoder-decoder structure to generate a preliminary segmentation mask for the eroded region. A subpixel edge detection algorithm is applied to the initial segmentation mask of the eroded area. The Canny operator combined with the polynomial fitting method is used to perform subpixel-level localization of the eroded contour and generate a refined eroded contour. Based on the refined erosion contour, the image is binarized, with pixels in the eroded area marked as 1 and pixels in the non-eroded area marked as 0, ultimately generating a binarized mask image of the erosion damage points.
9. A storage medium, characterized in that, The storage medium stores a computer program, wherein the computer program is configured to execute the method of any one of claims 1-5 when it is run.
10. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the method of any one of claims 1-5.