Magnesium alloy chemical etching image detection method based on image processing

By collecting the concentration and temperature gradient of the etching liquid and combining with deep learning models, the chemical etching image detection of magnesium alloys is optimized, and the missed judgment problem of magnesium alloy etching defect detection in the prior art is solved, and the detection accuracy and equipment efficiency are improved.

CN120279010AActive Publication Date: 2025-07-08FUGU COUNTY JINCHUAN MAGNESIUM IND CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510748896.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-06
Publication Date
2025-07-08
Estimated Expiration
2045-06-06

AI Technical Summary

Technical Problem

In the prior art, the detection method for chemical etching defects of magnesium alloys has a high misjudgment rate, making it difficult to accurately identify small defects, and has high equipment cost and complex operation.

Method used

By acquiring the etching liquid concentration and multi-frame etching images, combining the temperature gradient and chloride ion concentration of the etched image block, calculating the variance between the comprehensive class, dynamically adjusting the weight, using deep learning models to identify defect information, and optimizing image segmentation and defect detection.

Benefits of technology

It improves the accuracy of chemical etching defect detection of magnesium alloys, reduces the rate of misjudgment and misjudgment, reduces hardware costs, adapts to dynamic changes in the etching process, and ensures etching quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120279010A_ABST
    Figure CN120279010A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image processing, in particular to a magnesium alloy chemical etching image detection method based on image processing, which comprises the following steps: collecting etching liquid concentration and continuous multi-frame images; partitioning the image to obtain a plurality of image blocks; for any image block, calculating the comprehensive between-class variance of the image block through the variance of the temperature gradient of the image block, the etching liquid concentration and the between-class variance; determining an optimal segmentation threshold value of the image block based on the comprehensive between-class variance; performing threshold segmentation on the image block based on the optimal segmentation threshold to obtain a foreground region of the image block; splicing the foreground regions of the plurality of image blocks to obtain an etched image after threshold segmentation; and identifying defect information of the etched image through a deep learning model. According to the method, the variance of the etching solution concentration and the temperature gradient is fused into calculation of the comprehensive between-class variance, the image block region difference is measured, the foreground region is accurately segmented, clear data is provided for defect identification, and misjudgment and missed judgment of the image are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and particularly to a method for detecting magnesium alloy chemical etching images based on image processing. Background Art

[0002] Magnesium alloy chemical etching, as an important processing method, refers to selectively removing part of the material on the surface of magnesium alloy through specific chemical reactions, so that the magnesium alloy can obtain specific shapes, sizes, and surface properties. However, due to the active chemical properties of magnesium alloy, it is extremely easy to be oxidized during the etching process, and thus it is easy to generate micro-cracks, pores and other micro-defects on its surface. In view of the fact that these potential defects will have an adverse impact on the performance and quality of magnesium alloy products, it is particularly necessary to detect the defects after magnesium alloy chemical etching.

[0003] Traditional methods for detecting magnesium alloy chemical etching defects mainly rely on manual visual inspection and simple instrument inspection. These two methods have obvious limitations in modern industrial mass production. Manual visual inspection has extremely high requirements for the experience and concentration of inspectors. Long-term work is likely to cause visual fatigue, resulting in missed detection or misjudgment. Although simple instrument inspection can improve the accuracy of detection to a certain extent, the detection process is cumbersome, has high requirements for the professional skills of operators, and the instrument equipment is expensive and has high maintenance costs.

[0004] In recent years, the illumination efficiency detection method based on image processing has gradually received attention. In related technologies, the etched surface of magnesium alloy is usually analyzed as a whole, ignoring the characteristic differences caused by the etching degree and environmental differences in different regions of the surface during the etching process. This makes the subtle defect features in different regions interfere with each other, making it difficult to accurately extract subtle defects with strong concealment such as micro-cracks and micro-pores from the complex background, resulting in misjudgment or missed detection. Summary of the Invention

[0005] To solve the above technical problem that subtle defects on the etched surface of magnesium alloy are prone to misjudgment and missed detection, the present invention provides a method for detecting magnesium alloy chemical etching images based on image processing. The method includes: Collecting the etching solution concentration and multiple consecutive frames of etching images during the etching process; dividing the etching images into blocks to obtain a plurality of etching image blocks; For any one of the etching image blocks, calculating its comprehensive between-class variance, and the comprehensive between-class variance satisfies the relational expression: , where is the segmentation threshold, is the comprehensive between-class variance corresponding to the segmentation threshold, is the variance of the temperature gradient of the etching image block, is the standardized etching solution concentration, is the preset weight, is the inter-class variance corresponding to the segmentation threshold; determining the optimal segmentation threshold of the etching image block based on the comprehensive inter-class variance; performing threshold segmentation on the etching image block based on the optimal segmentation threshold to obtain a foreground area of ​​the etching image block; The foreground areas of the plurality of etching image blocks are spliced ​​to obtain an etching image after threshold segmentation; and defect information of the etching image after threshold segmentation is identified through a deep learning model.

[0006] The present invention collects etching solution concentration and continuous multiple-frame etching images, integrates etching solution concentration into comprehensive inter-class variance calculation, and corrects inter-class variance in combination with the variance of temperature gradient of etching image block. Compared with calculating inter-class variance based only on image grayscale, this method comprehensively considers the influence of variance of etching solution concentration and temperature gradient on image features, and more accurately measures regional differences of image blocks, so that the determined optimal segmentation threshold can accurately distinguish foreground from background, accurately segment foreground area, provide high-quality data for defect identification, and reduce false positive and false negative rate. At the same time, the variance of temperature gradient can keenly capture local temperature changes, is more sensitive to tiny defect detection, and helps to discover defects that are easily overlooked.

[0007] As a further improvement of the method of the present invention, the setting of the preset weight includes: further collecting the chloride ion concentration of the etching area corresponding to the etching image block and Value; record the acquisition time of the etching image where the etching image block is located as the analysis time, and obtain the weight of the corresponding image block in the etching image at the previous acquisition time of the analysis time , Value; Calculate the analysis time and the previous collection time Change value ; Calculate the weight of the etching image block ;in, is the chloride ion concentration and Preset synergy factors for changing values; 、 is the normalized chloride concentration and Change value, () is the hyperbolic tangent function, is the preset feedback parameter value.

[0008] Chloride ion concentration and The change value is an important parameter that affects the chemical etching process of magnesium alloys. Chloride ions will accelerate the corrosion of magnesium alloys, resulting in different defect morphologies on the etching surface; The changing values will affect the chemical properties of the etching solution and the progress of the etching reaction. These two parameters are collected and used for weight calculation, enabling the detection method to more comprehensively consider the influence of various factors during the etching process on the image features. Thus, the segmentation threshold determined based on the weights adjusted after comprehensively considering more factors can more accurately distinguish the defective areas in the image from the background, thereby improving the accuracy of defect detection and reducing the situations of missed detection and misjudgment.

[0009] As a further improvement of the method of the present invention, the standardized etching solution concentration ; wherein, is the etching solution concentration during the etching process, is the minimum permitted concentration of the etching solution, is the maximum permitted concentration of the etching solution.

[0010] As a further improvement of the method of the present invention, determining the optimal segmentation threshold of the etching image block based on the comprehensive between-class variance includes: calculating the maximum value of the comprehensive between-class variance of the etching image block, and the threshold corresponding to the maximum value of the comprehensive between-class variance is the optimal segmentation threshold.

[0011] As another improvement of the method of the present invention, the standardized chloride ion concentration and the changing values are obtained by normalizing the chloride ion concentration and the changing values through the Z-score normalization or Min-Max normalization method.

[0012] As another improvement of the method of the present invention, the calculation of the variance of the temperature gradient of the etching image block includes: also collecting an infrared thermal image and dividing it into blocks to obtain a plurality of infrared thermal image blocks; calculating the temperature gradients in the horizontal and vertical directions of the infrared thermal image blocks; calculating the mean value of the temperature gradients; calculating the variance of the temperature gradient of the infrared thermal image blocks based on the mean value; the variance of the temperature gradient of the etching image block is the variance of the temperature gradient of its corresponding infrared thermal image block.

[0013] Dividing the infrared thermal image into blocks can focus on each local part of the etching area. Different etching image blocks may correspond to different etching conditions and microstructures. By calculating the variance of the temperature gradient of each infrared thermal image block, the thermal change characteristics of these local areas can be carefully captured. This helps to discover the tiny temperature differences that are easily overlooked in the overall observation, thereby more accurately locating the areas where defects may occur.

[0014] As another improvement of the method of the present invention, the calculation of the variance of the temperature gradient of the etched image block includes: further collecting a plurality of temperature data during the etching process; calculating the temperature gradient by the central difference method based on the plurality of temperature data; calculating the variance of the temperature gradient by the variance calculation formula.

[0015] The amount of discrete temperature point data processed is relatively small. The central difference method and variance calculation are relatively simple in algorithm implementation, with low computational complexity, and are suitable for real-time online detection scenarios. This method can not only meet the requirement of quickly analyzing the temperature state of the etching process, but also effectively reduce the occupation of computing resources, improve the detection efficiency, and reduce the hardware cost and consumption of computing resources.

[0016] As another improvement of the method of the present invention, identifying the defect information of the etched image after threshold segmentation by the deep learning model includes: using the deep learning model for defect detection and outputting the defect probability and defect information of the etched image after threshold segmentation; when the defect probability is greater than the defect threshold, stop etching. The defect information includes defect coordinates, defect types, and defect sizes. The defect types include: pitting corrosion, crack.

[0017] The deep learning model can conduct a detailed analysis of the etched image and accurately evaluate the potential risks of defects. By setting a reasonable defect threshold and combining the defect probability output by the model, it can be determined when to stop etching, ensuring that the etching degree is just right, which not only meets the requirements of the etching process for surface shape, size, etc., but also does not generate too many defects due to over-etching. In addition, when the defect probability output by the deep learning model is greater than the defect threshold, stop etching immediately. It can also effectively avoid continuing to etch when there is a high probability of defects on the magnesium alloy surface, prevent the defects from further expanding or deteriorating, thereby reducing the product scrapping caused by serious defects and improving the quality and qualification rate of the final product.

[0018] The beneficial effects of the present invention are as follows: The present invention collects the etching solution concentration and multiple frames of etched images, incorporates the etching solution concentration into the calculation of the comprehensive between-class variance, and combines the temperature gradient of the etched image block to correct the between-class variance. Compared with only calculating based on the image gray level, it can more comprehensively consider the influence of factors on the image features, accurately measure the regional differences of the image blocks, accurately segment the foreground region, provide clear data for defect recognition, and reduce misjudgment and missed judgment. At the same time, collecting the chloride ion concentration and value for weight calculation makes the segmentation threshold more accurate, further comprehensively considers the etching factors, improves the accuracy of defect detection, and effectively reduces the situations of missed detection and misjudgment. Description of the Drawings

[0019] Figure 1 It is a flowchart of a method for detecting magnesium alloy chemical etching images based on image processing provided by an embodiment of the present invention. Specific Embodiment

[0020] This embodiment provides a method for detecting magnesium alloy chemical etching images based on image processing. As Figure 1 shown, this method includes steps S100 - S700: Step S100, collect the etching solution concentration and multiple consecutive frames of etching images during the etching process.

[0021] To elaborate, for defect detection of magnesium alloy chemical etching, it is necessary to collect etching data and multiple consecutive frames of etching images. Regarding the etching images, a shooting device is used to collect the etching images of the etching area during the etching process, and it is necessary to collect the etching images at multiple time points to capture the optical characteristics of the magnesium alloy etching surface. Regarding the etching solution concentration, a liquid concentration collection device is used to collect the etching solution concentration.

[0022] For the etching images, grayscale processing is also required to convert them into grayscale images to reduce the complexity of subsequent calculations.

[0023] Step S200, divide the etching image into multiple etching image blocks.

[0024] To elaborate, since the surface conditions of the magnesium alloy chemical etching area may vary at different positions, block processing can better capture these local changes. Different etching image blocks have different characteristics, reflecting the effects and potential problems of chemical etching in different areas. By analyzing each etching image block separately, a more comprehensive understanding of the quality of the entire etching area can be obtained, without ignoring important local information due to overall averaging.

[0025] Specifically, the block method can be implemented by, for example, uniform blocking, dividing the etching image into several equal-sized sub-blocks according to a fixed size and spacing. For example, divide the etching image into a 10×10 grid, and each grid cell is an etching image block.

[0026] Step S300, for any etching image block, calculate its comprehensive between-class variance.

[0027] To elaborate, the present invention is an improvement on the Otsu algorithm. First, the Otsu algorithm is introduced here. The Otsu algorithm is an adaptive threshold determination method in the field of image segmentation. Its core idea is to find an optimal threshold by analyzing the grayscale histogram of the image, so that after dividing the image into foreground and background parts, the between-class variance between these two parts is the largest. The larger the between-class variance, the more obvious the difference between the foreground and background after segmentation using this threshold, which means the better the segmentation effect.

[0028] The present invention corrects the calculation of the between-class variance, and the corrected comprehensive between-class variance The calculation formula is as follows: , wherein, is the segmentation threshold, is the comprehensive between-class variance corresponding to the segmentation threshold, is the variance of the temperature gradient of the etched image block, is the standardized concentration of the etching solution, is the preset weight, is the between-class variance corresponding to the segmentation threshold; In this formula, the variance of the temperature gradient and the concentration of the etching solution are introduced as constraint terms to correct the between-class variance. The temperature fluctuation during the etching process can reflect the activity degree of the corrosion reaction. For example, at cracks or pores, due to uneven heat release or heat dissipation during the corrosion reaction, the temperature gradient will increase significantly. And the concentration of the etching solution directly affects the corrosion rate. Therefore, these two factors are two important indicators affecting whether defects occur in the chemical etching process of magnesium alloys. The present invention calculates the comprehensive between-class variance by introducing these two factors, and this calculation can improve the problem that it is difficult to distinguish regions with similar gray levels but different physical characteristics only relying on gray level information in the Otsu algorithm. The calculation of the comprehensive between-class variance of the present invention ultimately affects the optimal segmentation threshold of threshold segmentation, and can more sensitively detect defect regions, avoiding missed detection and false detection of defects.

[0029] The comprehensive between-class variance in this formula is affected by two factors. One is the variance of the temperature gradient of the etched image block, its etching solution concentration, and the preset weight, and the other is the between-class variance of the etched image block. Now, they will be introduced one by one.

[0030] Factor 1: The variance of the temperature gradient of the etched image block, its etching solution concentration, and the preset weight.

[0031] First, the setting and calculation of the weight will be described. The weight is used to balance the contributions of the temperature gradient and the etching solution concentration collaborative term and the gray level feature to the segmentation. The greater the weight, the more significant the influence of the variance of the temperature gradient and the etching solution concentration; conversely, the segmentation depends more on the gray level information.

[0032] As mentioned in step 100, multiple etched images during the etching process will be collected. Therefore, each etched image will have a corresponding etched image block. For the initial value of the weight of the etched image block of the first collected etched image, it can be set according to an empirical value, such as 0.3.

[0033] For the weight values at subsequent moments, they can not only be set according to experience, but also be calculated based on the data during the etching process, such as through the chloride ion concentration in the etched area and the The change value is calculated. The specific calculation includes: recording the acquisition moment of the etching image where the etching image block being calculated is located as the current moment, and the previous acquisition moment of the current moment as the previous moment; calculating the weight value of the current moment through the weight value of the previous moment. The weight value of the current moment : ; Among them, is the weight of the current moment, is the weight value of the previous moment, is the chloride ion concentration at the current moment and the preset cooperation factor of the change value , 、 is the standardized chloride ion concentration and the change value, ( ) is the hyperbolic tangent function, is the variance of the temperature gradient of the etching image block, is the standardized etching solution concentration, is the between-class variance of the etching image block at the current moment, is the preset feedback parameter value.

[0034] In the calculation of this formula, the weight value can be dynamically updated according to the etching historical data. The dynamic update mechanism of the weight is to balance the cooperation effect of the chloride ion concentration and the change value. Among them, the change value is the at the current moment and at the previous moment The difference. For example, when the chloride ion concentration is higher, the corrosiveness is stronger. When the change value <0 will accelerate the corrosion reaction. Therefore, when the chloride ion concentration is high and significantly decreases, the corresponding standardized product term increases, indicating that the corrosion environment deteriorates. At this time, the weight needs to be enhanced to more sensitively detect the defect area. Such a design can dynamically adapt to the corrosion environment and suppress false detections. When the chloride ion concentration is low and stable the product term decreases, and the weight of the temperature gradient needs to be reduced, relying more on the gray information.

[0035] For , is the preset cooperation factor of the chloride ion concentration and the change value. It is the influencing factor for the dynamic weight and is determined by experience. For example, it is set to 0.5.

[0036] Regarding The meaning is that according to the temperature gradient of the etching image block and the etching solution concentration synergistic term With traditional Otsu items The proportion at the current moment is used to adjust the dynamic weight factor in real time In this way, when the process is stable, that is, the synergistic term between the temperature gradient and the etching solution concentration is small, the weight is tilted toward the traditional Otsu term to ensure the stability of the segmentation result; when the process fluctuates, that is, the synergistic term between the temperature gradient and the etching solution concentration is large, the weight is tilted toward the synergistic term between the temperature gradient and the etching solution concentration to ensure priority response to the real-time physical state, especially the temperature effect, to avoid segmentation failure caused by parameter drift. It is used for radiation () function range, Assume that Setting it to 0.5 ensures that () The range of the function is mapped to .

[0037] The above describes the setting and calculation of weights, and then describes how to calculate the variance of the temperature gradient of the etching image block.

[0038] There are two implementations for calculating the variance of the temperature gradient of the etched image block.

[0039] The first implementation method is: calculation with the help of thermal imaging images.

[0040] Specifically, infrared thermal images during the etching process are collected and divided into blocks to obtain multiple infrared thermal image blocks; the temperature gradients of the infrared thermal image blocks in the horizontal and vertical directions are calculated; the mean of the temperature gradients of the infrared thermal image blocks is calculated; the variance of the temperature gradients of the infrared thermal image blocks is calculated based on the mean; the variance of the temperature gradient of the etching image block is the variance of the temperature gradient of the corresponding infrared thermal image block.

[0041] By dividing the infrared thermal image into blocks and calculating the temperature gradient variance, we can focus on the local etching area, capture subtle thermal change characteristics, and accurately locate small temperature differences. The temperature gradient variance can reveal the temperature uniformity of the etching area. Since uneven temperature can easily cause defects, this method can keenly lock the abnormal temperature area, provide a key basis for defect location, and significantly improve the ability to detect small defects.

[0042] To elaborate, firstly, infrared thermal imaging equipment is needed to collect infrared thermal images of magnesium alloy during chemical etching, so as to obtain the temperature field distribution on its surface. In infrared thermal images, which contain temperature information, the pixel value represents the temperature.

[0043] Secondly, the infrared thermal image block is segmented into multiple infrared thermal image blocks. It should be noted that the infrared thermal image and the etching image mentioned above need to be collected at the same moment, and the collection area and image size are the same. This can ensure that the segmented etching image blocks and infrared thermal image blocks correspond one by one, and at the same time ensure that the variance of the temperature gradient calculated from the infrared thermal image block is the variance of the temperature gradient of the corresponding etching image block.

[0044] Next, calculate the temperature changes in the horizontal and vertical directions to obtain the temperature gradient. The horizontal direction gradient The calculation formula is: ; Where is the pixel coordinate, is the temperature value of adjacent pixels in the infrared thermal image block, is the temperature value of the pixel in the infrared thermal image block.

[0045] The vertical direction gradient The calculation formula is: ; Where is the pixel coordinate, is the temperature value of the pixel in the infrared thermal image block, is the temperature value of the pixel in the infrared thermal image block.

[0046] Furthermore, calculate the mean value of the temperature gradient of the infrared thermal image block. The mean value calculation needs to be based on the total gradient of the pixel . The total gradient calculation formula is: ; The mean value of the temperature gradient The calculation formula is: ; Where M and N are the height and width of the infrared thermal image block respectively.

[0047] Finally, calculate the variance of the infrared thermal image block according to the temperature gradient : .

[0048] The second implementation method is: calculate based on the discrete temperature points during the etching process.

[0049] Specifically, collect multiple temperature data during the etching process; calculate the temperature gradient by the central difference method based on the multiple temperature data; calculate the variance of the temperature gradient through the variance calculation formula.

[0050] Collecting discrete temperature points during the etching process can capture the temperature change situation in the etching area in real time. Calculating the temperature gradient by the central difference method can more accurately quantify the spatial change trend of the temperature. Compared with other simple difference methods, it has stronger noise suppression ability and can more truly reflect the temperature distribution characteristics in the etching area, providing a reliable basis for analyzing the thermal state of the etching process.

[0051] To elaborate, first collect the temperature data of the etching image block at the same moment through a temperature sensor. As the etching process progresses, a set of discrete data points will be formed , k is the k moment, is the k temperature data at the n moment, and

[0052] is the number of temperature data collected by the temperature sensor. , such as: ; where is the temperature data at the moment, is the temperature data at the

[0053] Finally, calculate the variance of the temperature gradient according to the variance calculation formula : ; where is the mean value of the temperature gradient.

[0054] The above text explains the calculation of the variance of the temperature gradient of the etching image block and the preset weight. Here, the etching solution concentration data is explained.

[0055] Specifically, in order to eliminate the influence of dimension, it is necessary to perform standardization processing on the chloride ion concentration and change value. The standardization processing method is the Z-score standardization method or the Min-Max standardization method. In addition, regarding the etching solution concentration mentioned above, the directly used is not the collected etching solution concentration, but the etching solution concentration after Min-Max standardization processing: ; Among them, is the concentration of the etching solution during the etching process collected, is the minimum allowable concentration of the etching solution, is the maximum allowable concentration of the etching solution.

[0056] Factor 2: The between-class variance of the etched image blocks.

[0057] Specifically, the calculation of the between-class variance of the image blocks still uses the formula for calculating the between-class variance of the Otsu algorithm in the prior art, and the present invention does not improve it. Here, a brief description of how to calculate it is given. For each etched image block, the frequency of each gray value appearance is counted to obtain the gray histogram of each etched image block. Assume that the gray level range of any etched image block is , is the total number of gray levels, then the probability of each gray value appearance is calculated by the formula: ; where is the gray value of the pixel point, is the number of pixel points with the gray value of , N is the total number of pixels of the etched image block.

[0058] Then, all possible thresholds are traversed, and the etched image is divided into a foreground and a background. The gray value range of the foreground pixels is , and the gray value range of the background pixels is . Calculate the between-class variance: ; where is the proportion of the background pixels in the etched image block, is the proportion of the foreground pixels in the etched image block, is the average gray value of the background pixels, is the average gray value of the foreground pixels; ; ; ; .

[0059] In summary, it is the calculation principle of the comprehensive between-class variance.

[0060] Step S400, determining the optimal segmentation threshold of the etched image block based on the comprehensive between-class variance. It includes: calculating the maximum value of the comprehensive between-class variance of the etched image block at the current moment, and the threshold corresponding to the maximum value of the comprehensive between-class variance is the optimal segmentation threshold.

[0061] Specifically, the inter-class variance is adjusted in real time according to the dynamically adjusted weights, and all possible segmentation thresholds are traversed. Find the threshold that maximizes the inter-class variance. , This is the optimal segmentation threshold calculated from the etched image patches.

[0062] Step S500: Perform threshold segmentation on the etched image patches based on the optimal segmentation threshold to obtain the foreground region of the etched image patches.

[0063] Specifically, the optimal segmentation threshold for each etched image patch is obtained according to the above process, and all pixels in the etched image patch are binarized according to the optimal segmentation threshold. When the pixel value is greater than the optimal segmentation threshold, it is set as the foreground region; otherwise, it is set as the background region. Finally, a foreground region after Otsu segmentation can be obtained for each etched image patch.

[0064] Step S600: Stitch the foreground regions of multiple etched image patches to obtain the etched image after threshold segmentation.

[0065] Stitch all the foreground regions in the order of their etched image patches to obtain the etched image after threshold segmentation.

[0066] Step S700: Identify the defect information of the etched image after threshold segmentation through a deep learning model.

[0067] Specifically, a multi-modal feature fusion deep learning model commonly used in the prior art, such as the YOLO5 model, is selected to detect the chemical etching defects of magnesium alloys. Model training is required first. The specific process is as follows: Collect the chemical etching images of magnesium alloys with etching defects and their grayscale data, temperature, and depth data, merge the above content into a multi-channel image, label the positions and categories of the defects, and generate the dataset required for training. Use the above dataset to train the YOLO5 model. After the model training is completed, use the model to detect the defects in the images during and after the etching process, and output the detected defect information and defect probability.

[0068] Regarding why grayscale data, temperature, and depth data are selected as the training dataset, it is related to the characteristics of the defect types. Defects such as edge burrs, uneven etching, and foreign object contamination have significant multi-modal feature differences in grayscale, temperature, and depth data. For example, edge burrs appear as local protrusions in depth data, and the temperature data shows abnormal thermal gradients; the uneven etching area presents alternating bright and dark patches in the grayscale image, accompanied by non-uniform temperature distribution; foreign object contamination shows a height difference from the substrate in the depth channel, and the grayscale value deviates from the normal etching texture.

[0069] It should be noted that the present invention makes differential settings for the defects detected during the etching process and at the end of the etching.

[0070] For the etched image after threshold segmentation during the etching process, a defect probability threshold will be set, and the YOLO5 model will focus on detecting defect types with high distinguishability from normal etching traces. When the defect probability output by the model is greater than the defect threshold, it can be fed back to the etching machine to stop the etching.

[0071] In addition, specific defect information of the defect needs to be given. The above-mentioned defect types with high distinguishability include edge burrs caused by residual etching solution or insufficient sidewall protection, uneven etching caused by local temperature anomalies, foreign object contamination, and so on.

[0072] For the etched image after threshold segmentation at the end of the etching, the YOLO5 model will conduct a comprehensive detection. At this time, not only will it detect defect types with high distinguishability from normal etching traces, but also the defect types will be extended, such as including complex defects like pitting corrosion and cracks. If it is detected that there are defects in the image, it is determined that the current chemical etching of the magnesium alloy is unqualified, and defect information is output, including detailed information such as defect coordinates, defect types, and defect sizes. The defect types include the pitting corrosion, cracks, edge burrs, uneven etching, foreign object contamination, and other defects mentioned above.

[0073] Although this specification has shown and described multiple embodiments of the present invention, it is obvious to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will think of many changes, alterations, and alternative ways without departing from the spirit and concept of the present invention. It should be understood that various alternative solutions to the embodiments of the present invention described herein can be adopted in the process of practicing the present invention.

Claims

1. A method for detecting images of chemical etching of magnesium alloys based on image processing, characterized in that, Including: Collecting the etching solution concentration and multiple consecutive frames of etching images during the etching process; Dividing the etching images into blocks to obtain multiple etching image blocks; For any one of the etched image blocks, calculate its comprehensive between-class variance, and the comprehensive between-class variance satisfies the relational expression: , where is the segmentation threshold,[ is the comprehensive between-class variance corresponding to the segmentation threshold,[ is the variance of the temperature gradient of the etched image block,[ is the standardized etching solution concentration,[ is the preset weight,[ is the between-class variance corresponding to the segmentation threshold; Determining the optimal segmentation threshold of the etching image blocks based on the comprehensive between-class variance; Performing threshold segmentation on the etching image blocks based on the optimal segmentation threshold to obtain the foreground regions of the etching image blocks; Stitching the foreground regions of multiple etching image blocks to obtain the threshold-segmented etching image; Identifying the defect information of the threshold-segmented etching image through a deep learning model.

2. The method for detecting magnesium alloy chemical etching images based on image processing according to claim 1, characterized in that, The setting of the preset weight includes: The chloride ion concentration of the etching area corresponding to the etched image block is also collected and value; Record the acquisition moment of the etching image where the etched image block is located as the analysis moment, and obtain the weight of the corresponding image block in the etching image at the previous acquisition moment of the analysis moment , value; Calculate the change value ; Calculating the weight of the etching image block, and the weight satisfies the relational expression: ; Among them, is the preset cofactor of the chloride ion concentration and the change value; 、 are the standardized chloride ion concentration and the change value, () is the hyperbolic tangent function, is the preset feedback parameter value.

3. The method for detecting the chemical etching image of magnesium alloy based on image processing according to claim 1, wherein, The standardized etching solution concentration ; Among them, is the concentration of the etching solution during the etching process, is the minimum allowable concentration of the etching solution, is the maximum allowable concentration of the etching solution.

4. The method for detecting magnesium alloy chemical etching images based on image processing according to claim 1, characterized in that, The determining of the optimal segmentation threshold of the etching image blocks based on the comprehensive between-class variance includes: Calculating the maximum value of the comprehensive between-class variance of the etching image blocks, and the threshold corresponding to the maximum value of the comprehensive between-class variance is the optimal segmentation threshold.

5. The method for detecting magnesium alloy chemical etching images based on image processing according to claim 2, characterized in that The standardized chloride ion concentration and the change value are obtained by normalizing the chloride ion concentration and the change value using the Z-score normalization or Min-Max normalization method.

6. The method for detecting magnesium alloy chemical etching images based on image processing according to claim 1, characterized in that The calculation of the variance of the temperature gradient of the etching image block includes: Also collecting infrared thermal images and dividing them into blocks to obtain multiple infrared thermal image blocks; Calculating the temperature gradients in the horizontal and vertical directions of the infrared thermal image blocks; Calculating the mean value of the temperature gradients; Calculating the variance of the temperature gradient of the infrared thermal image blocks based on the mean value; The variance of the temperature gradient of the etching image block is the variance of the temperature gradient of its corresponding infrared thermal image block.

7. The method for detecting magnesium alloy chemical etching images based on image processing according to claim 1, wherein The calculation of the variance of the temperature gradient of the etching image block includes: Also collecting multiple temperature data during the etching process; Calculating the temperature gradient based on the multiple temperature data by the central difference method; Calculating the variance of the temperature gradient through the variance calculation formula.

8. The method for detecting the chemical etching image of magnesium alloy based on image processing according to claim 1, wherein The identifying of the defect information of the threshold-segmented etching image through the deep learning model includes: Using the deep learning model for defect detection and outputting the defect probability and defect information of the threshold-segmented etching image; When the defect probability is greater than the defect threshold, stop etching.

9. The method for detecting magnesium alloy chemical etching images based on image processing according to claim 1, wherein The defect information includes defect coordinates, defect type, and defect size.

10. The method for detecting images of chemical etching of magnesium alloys based on image processing according to claim 9, characterized in that, The defect type includes: pitting corrosion, crack.

Citation Information

Patent Citations

  • Electrical equipment thermal imaging segmentation dissimilarity finding method based on improved weighted otsu algorithm

    CN109993736A

  • Method for etching radio frequency area by using laser beam based on LMC process

    CN116984747A

  • Photovoltaic steel structure component quality detection method based on image processing

    CN117314893A

  • Thermal analysis method for liquid film on surface of substrate of photoetching machine

    CN117554410A

  • Clock part etching quality detection method and system

    CN119600024A