A magnesium alloy chemical etching image detection method based on image processing

By collecting etching solution concentration and multi-frame images, combining temperature gradient and chloride ion concentration changes, dynamically adjusting weights, and using deep learning models to identify magnesium alloy chemical etching defects, the problems of high false positive and missed positive rates and high costs of existing detection methods are solved, and efficient and accurate defect detection and etching control are achieved.

CN120279010BActive Publication Date: 2025-09-19FUGU COUNTY JINCHUAN MAGNESIUM IND CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing methods for detecting defects in magnesium alloy chemical etching rely on manual visual inspection and simple instruments, which have problems such as high false positive and missed detection rates and high costs. In addition, traditional image processing methods fail to effectively distinguish the characteristic differences between different areas during the etching process, making it difficult to accurately extract subtle defects.

Method used

By collecting the etching solution concentration and multiple frames of etching images, calculating the comprehensive inter-class variance, combining the temperature gradient and chloride ion concentration changes of the etching image blocks, dynamically adjusting the weights, and using a deep learning model to identify defect information, image segmentation and defect detection are achieved.

Benefits of technology

The accuracy of magnesium alloy chemical etching defect detection is improved, the false positive and missed positive rates are reduced, hardware costs and computing resource consumption are reduced, precise control of the etching process is ensured, and product quality is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120279010B_ABST
    Figure CN120279010B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of image processing technology, and in particular to a magnesium alloy chemical etching image detection method based on image processing. The method comprises: collecting etching solution concentration and multiple consecutive frames of images; dividing the image into multiple image blocks; for any image block, calculating its comprehensive inter-class variance based on the variance of the image block's temperature gradient, etching solution concentration, and inter-class variance; determining an optimal segmentation threshold for the image block based on the comprehensive inter-class variance; performing threshold segmentation on the image block based on the optimal segmentation threshold to obtain a foreground area of ​​the image block; splicing the foreground areas of multiple image blocks to obtain an etching image after threshold segmentation; and identifying defect information in the etching image using a deep learning model. The present invention incorporates the variance of etching solution concentration and temperature gradient into the calculation of the comprehensive inter-class variance, measures regional differences in image blocks, accurately segments the foreground area, provides clear data for defect identification, and reduces misjudgments and missed detections of images.
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 in particular to a magnesium alloy chemical etching image detection method based on image processing. Background Art

[0002] Chemical etching of magnesium alloys is an important processing method that selectively removes material from the surface of magnesium alloys through a specific chemical reaction, thereby achieving a specific shape, size, and surface properties. However, due to the active chemical properties of magnesium alloys, they are easily oxidized during the etching process, which can easily lead to minor defects such as microcracks and pores on the surface. Given that these potential defects can adversely affect the performance and quality of magnesium alloy products, defect detection after chemical etching of magnesium alloys is particularly necessary.

[0003] Traditional methods for detecting defects in magnesium alloy chemical etching rely primarily on manual visual inspection and simple instrumentation. These two methods have significant limitations in modern industrial mass production. Manual visual inspection requires significant experience and concentration from the inspector, and prolonged work can easily lead to visual fatigue, resulting in missed detections or misjudgments. While simple instrumentation can improve detection accuracy to a certain extent, the process is cumbersome and requires high operator expertise. Furthermore, the instrumentation is expensive and has high maintenance costs.

[0004] In recent years, image processing-based lighting efficiency detection methods have gained increasing attention. Related technologies typically analyze the etched surface of magnesium alloys as a whole, ignoring the differences in properties between different regions of the surface due to etching severity and environmental variations. This causes subtle defect features in different regions to interfere with each other, making it difficult to accurately extract subtle defects such as microcracks and tiny pores from complex backgrounds, leading to misjudgments or omissions. Summary of the Invention

[0005] In order to solve the technical problem that subtle defects on the surface of magnesium alloy etching are easily misjudged or missed, the present invention provides a magnesium alloy chemical etching image detection method based on image processing, which comprises:

[0006] Collecting the etching solution concentration and multiple frames of etching images during the etching process; dividing the etching images into blocks to obtain multiple etching image blocks;

[0007] For any of the etching image blocks, the comprehensive inter-class variance is calculated, and the comprehensive inter-class variance satisfies the relationship: ,in, is the segmentation threshold, is the comprehensive inter-class variance corresponding to the segmentation threshold, is the variance of the temperature gradient of the etched image patch, 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 etched image block based on the comprehensive inter-class variance; performing threshold segmentation on the etched image block based on the optimal segmentation threshold to obtain a foreground area of ​​the etched image block;

[0008] The foreground areas of the plurality of etching image blocks are spliced ​​together 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.

[0009] This method collects etching solution concentration and multiple consecutive etching images, incorporates the etching solution concentration into the calculation of comprehensive inter-class variance, and corrects the inter-class variance by combining it with the variance of the temperature gradient of the etching image blocks. Compared to calculating the inter-class variance based solely on image grayscale, this method comprehensively considers the impact of the variance of etching solution concentration and temperature gradient on image features, more accurately measuring regional differences in image blocks. This allows the determined optimal segmentation threshold to accurately distinguish foreground from background, precisely segmenting the foreground area, providing high-quality data for defect identification and reducing the rate of false positives and missed detections. Furthermore, the variance of the temperature gradient can keenly capture local temperature changes, making it more sensitive to minor defects and helping to discover easily overlooked defects.

[0010] 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 、 Calculate the analysis time and the previous acquisition time Change value ; Calculate the weight of the etched image block ;in, is the chloride ion concentration and Preset synergy factors for changing values; 、 is the normalized chloride ion concentration and Change value, () is the hyperbolic tangent function, is the preset feedback parameter value.

[0011] 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 etched surface; Changing values ​​can affect the chemical properties of the etching solution and the progress of the etching reaction. Collecting these two parameters and using them in weight calculation allows the detection method to more comprehensively consider the impact of various factors during the etching process on image features. This segmentation threshold, determined by weighting adjustments based on a comprehensive consideration of these multiple factors, can more accurately distinguish defective areas from the background in the image, thereby improving defect detection accuracy and reducing missed detections and misjudgments.

[0012] As a further improvement of the method of the present invention, the concentration of the standardized etching solution is ;in, is the concentration of the etching solution during the etching process, is the minimum permissible concentration of the etching solution, It is the maximum permissible concentration of the etching solution.

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

[0014] As another improvement of the method of the present invention, the standardized chloride ion concentration and The change value is the Z-score standardization or Min-Max standardization method for chloride ion concentration and The change values ​​are obtained by standardization.

[0015] As another improvement to the method of the present invention, the calculation of the variance of the temperature gradient of the etched image block includes: further 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 block; calculating the mean of the temperature gradients; and calculating the variance of the temperature gradient of the infrared thermal image block based on the mean; the variance of the temperature gradient of the etched image block is the variance of the temperature gradient of the corresponding infrared thermal image block.

[0016] By segmenting the infrared thermal image into blocks, we can focus on specific parts of the etched area. Different etched image blocks may correspond to different etching conditions and microstructures. By calculating the temperature gradient variance of each infrared thermal image block, we can capture the thermal characteristics of these local areas in detail. This helps to detect subtle temperature differences that are easily overlooked in an overall observation, thereby more accurately locating areas where defects may occur.

[0017] 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 multiple temperature data during the etching process; calculating the temperature gradient based on the multiple temperature data by the central difference method; and calculating the variance of the temperature gradient by a variance calculation formula.

[0018] The amount of data processing required for discrete temperature points is relatively small. The central difference method and variance calculation are simple to implement and have low computational complexity, making them suitable for real-time online testing. This method not only meets the need for rapid analysis of the temperature state of the etching process, but also effectively reduces computing resource usage, improves detection efficiency, and reduces hardware costs and computing resource consumption.

[0019] As another improvement to the method of the present invention, identifying defect information of the threshold-segmented etching image using a deep learning model includes: performing defect detection using the deep learning model, outputting a defect probability and defect information for the threshold-segmented etching image; and stopping etching when the defect probability exceeds a defect threshold. The defect information includes defect coordinates, defect type, and defect size. Defect types include pitting and cracking.

[0020] The deep learning model can perform a detailed analysis of etching images and accurately assess the potential risk of defects. By setting a reasonable defect threshold and combining it with the defect probability output by the model, it can determine when to stop etching, ensuring the appropriate etching level. This not only meets the etching process's requirements for surface shape and size, but also avoids excessive defects caused by over-etching. Furthermore, when the defect probability output by the deep learning model exceeds the defect threshold, etching is immediately stopped. This can also effectively avoid continuing etching when a high probability of defects already exists on the magnesium alloy surface, preventing defects from further expanding or worsening. This reduces product scrapping due to severe defects and improves the quality and pass rate of the final product.

[0021] The beneficial effects of the present invention are as follows: by collecting etching solution concentration and multiple frames of etching images, the present invention incorporates etching solution concentration into comprehensive inter-class variance calculation, and corrects inter-class variance in combination with the temperature gradient of the etching image block. Compared with the calculation based on image grayscale alone, it can more comprehensively consider the influence of factors on image features, accurately measure the regional differences of image blocks, accurately segment the foreground area, provide clear data for defect identification, and reduce misjudgment and missed judgment. At the same time, the chloride ion concentration and The value is used for weight calculation to make the segmentation threshold more accurate, further comprehensively consider the etching factors, improve the accuracy of defect detection, and effectively reduce missed detection and misjudgment. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 The present invention provides a flowchart of a magnesium alloy chemical etching image detection method based on image processing. DETAILED DESCRIPTION

[0023] This embodiment provides a magnesium alloy chemical etching image detection method based on image processing, such as Figure 1 As shown, the method includes steps S100 to S700:

[0024] Step S100: collecting etching solution concentration and multiple consecutive etching images during the etching process.

[0025] Specifically, to detect defects in magnesium alloy chemical etching, it is necessary to collect etching data and continuous multi-frame etching images. Regarding etching images, a camera is used to capture etching images of the etched area during the etching process. Etching images at multiple time points are also required to capture the optical characteristics of the magnesium alloy's etched surface. Regarding etching solution concentration, a liquid concentration acquisition device is required to collect the etching solution concentration.

[0026] For the etching image, grayscale processing is also required to convert it into a grayscale image to reduce the complexity of subsequent calculations.

[0027] Step S200: Divide the etching image into blocks to obtain a plurality of etching image blocks.

[0028] Specifically, because the surface condition of a magnesium alloy chemically etched area can vary from location to location, block processing better captures these local variations. Different etched image blocks have distinct characteristics, reflecting the effectiveness and potential issues of the chemical etching in different areas. By analyzing each etched image block individually, we can gain a more comprehensive understanding of the quality of the entire etched area, without overlooking important local information through overall averaging.

[0029] The specific block division method can be implemented by, for example, uniform block division, which divides the etching image into a number of equal-sized sub-blocks according to a fixed size and spacing. For example, the etching image is divided into a 10×10 grid, and each grid unit is an etching image block.

[0030] Step S300: For any etched image block, calculate its comprehensive inter-class variance.

[0031] To elaborate, the present invention is an improvement on the Otsu algorithm. The Otsu algorithm is an adaptive threshold determination method for image segmentation. Its core concept is to analyze the image's grayscale histogram to find an optimal threshold that maximizes the inter-class variance between the foreground and background components after segmenting the image. A larger inter-class variance indicates a more pronounced difference between the foreground and background components after segmentation using that threshold, which translates to a better segmentation result.

[0032] The present invention makes corrections to the calculation of inter-class variance, and the corrected comprehensive inter-class variance The calculation formula is:

[0033] ,

[0034] in, is the segmentation threshold, is the comprehensive inter-class variance corresponding to the segmentation threshold, is the variance of the temperature gradient of the etched image patch, is the standardized etching solution concentration, is the preset weight, is the inter-class variance corresponding to the segmentation threshold;

[0035] The variance of the temperature gradient and the concentration of the etching solution are introduced into this formula as constraints to correct the inter-class variance. The temperature fluctuation during the etching process can reflect the activity of the corrosion reaction. For example, the temperature gradient will increase significantly due to the heat release or uneven heat dissipation of the corrosion reaction at cracks or pores. The concentration of the etching solution directly affects the corrosion rate. Therefore, these two factors are two important indicators that affect whether defects occur in the chemical etching process of magnesium alloys. The present invention calculates the comprehensive inter-class variance by introducing these two factors. This calculation can improve the problem in the Otsu algorithm that it is difficult to distinguish areas with similar grayscale but different physical properties by relying solely on grayscale information. The calculation of the comprehensive inter-class variance of the present invention ultimately affects the optimal segmentation threshold of threshold segmentation, which can more sensitively detect defective areas and avoid missed detection and false detection of defects.

[0036] The comprehensive inter-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; the other is the inter-class variance of the etched image block. We will now introduce them one by one.

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

[0038] First, the setting and calculation of weights are explained. The weights are used to balance the contribution of the synergistic term between the temperature gradient and the etching solution concentration and the grayscale feature to the segmentation. The larger the weight, the more significant the influence of the variance of the temperature gradient and the etching solution concentration; conversely, the segmentation relies more on the grayscale information.

[0039] As mentioned in step 100, multiple etching images are collected during the time period, so each etching image has a corresponding etching image block. The initial value of the weight of the etching image block of the first etching image collected can be set based on an empirical value, such as 0.3.

[0040] The weight values ​​at subsequent moments can be set not only based on experience, but also calculated based on data from the etching process, such as the chloride ion concentration in the etching area. and etching area The change value is calculated. The specific calculation includes: recording the acquisition time of the etching image where the etching image block being calculated is located as the current time, and recording the acquisition time before the current time as the previous time; using the weight value of the previous time, the weight value of the current time is calculated. The weight value of the current time :

[0041] ;

[0042] in, is the weight at the current moment, is the weight value at the previous moment, is the chloride ion concentration at the current moment and Preset synergy factor for changing values , 、 is the normalized chloride ion concentration and Change value, () is the hyperbolic tangent function, is the variance of the temperature gradient of the etched image patch, is the standardized etching solution concentration, is the inter-class variance of the etching image patch at the current moment, is the preset feedback parameter value.

[0043] In the calculation of this formula, the weight value can be dynamically updated according to the etching history data. The dynamic update mechanism of the weight is to balance the chloride ion concentration and The synergistic effect of the change value. The change value is the current moment and the previous moment For example, when the chloride ion concentration is higher, the corrosiveness is stronger. The value decreases, that is Change value <0 will accelerate the corrosion reaction. Therefore, when the chloride ion concentration is high and When the chloride ion concentration is low and stable, the corresponding normalized product term increases, indicating that the corrosion environment has deteriorated. At this time, the weight needs to be increased to detect the defect area more sensitively. This design can dynamically adapt to the corrosion environment and suppress false detection. When the product term decreases, the weight of the temperature gradient needs to be reduced, and more reliance is placed on grayscale information.

[0044] for , is the chloride ion concentration and The preset synergy factor of the change value is an influencing factor on the dynamic weight, which is determined through experience and is set to 0.5, for example.

[0045] about 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 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 towards the traditional Otsu term, thereby ensuring 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 towards the synergistic term between the temperature gradient and the etching solution concentration, thereby ensuring priority response to the real-time physical state, especially the temperature effect, and avoiding segmentation failure caused by parameter drift. It is used for radiation () function's value range,

[0046] Assume that Setting it to 0.5 ensures that () The range of the function is mapped to .

[0047] The above describes the setting and calculation of weights. Next, it describes how to calculate the variance of the temperature gradient of the etched image block.

[0048] There are two implementation methods for calculating the variance of the temperature gradient of the etched image block.

[0049] The first implementation method is to calculate with the help of thermal imaging images.

[0050] Specifically, infrared thermal images during the etching process are collected and divided into blocks to obtain multiple infrared thermal image blocks; the temperature gradients in the horizontal and vertical directions of the infrared thermal image blocks are calculated; the mean of the temperature gradients of the infrared thermal image blocks is calculated; and 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 its corresponding infrared thermal image block.

[0051] By segmenting the infrared thermal image and calculating the temperature gradient variance, we can focus on the etched area, capture subtle thermal variations, and accurately locate minute temperature differences. The temperature gradient variance reveals the temperature uniformity of the etched area. Since uneven temperatures can easily lead to defects, this method can keenly identify abnormal temperature areas, providing a key basis for defect location and significantly improving the ability to detect small defects.

[0052] To elaborate, infrared thermal imaging equipment is first needed to capture infrared thermal images of the magnesium alloy during the chemical etching process to obtain the temperature distribution on its surface. In infrared thermal images, which contain temperature information, the pixel value represents the temperature.

[0053] Next, the infrared thermal image block is divided into multiple infrared thermal image blocks. It should be noted that the infrared thermal image and the aforementioned etching image must be acquired at the same time, with the same acquisition area and image size. This ensures a one-to-one correspondence between the etching image blocks and the infrared thermal image blocks after division, and also ensures that the variance of the temperature gradient calculated from the infrared thermal image block is the same as the variance of the temperature gradient of the corresponding etching image block.

[0054] Next, calculate the temperature changes in the horizontal and vertical directions to get the temperature gradient. The calculation formula is:

[0055] ;

[0056] in, is the pixel coordinate, are adjacent pixels in the infrared thermal image block The temperature value, is the pixel point in the infrared thermal image block The temperature value.

[0057] Vertical gradient The calculation formula is:

[0058] ;

[0059] in, is the pixel coordinate, is the pixel point in the infrared thermal image block The temperature value, is the pixel point in the infrared thermal image block The temperature value.

[0060] Furthermore, the mean temperature gradient of the infrared thermal image block is calculated. The mean calculation needs to be based on the pixel point The total gradient is calculated as follows:

[0061] ;

[0062] Mean temperature gradient The calculation formula is:

[0063] ;

[0064] Among them, M and Nare the height and width of the infrared thermal image block respectively.

[0065] Finally, the variance of the infrared thermal image block is calculated based on the temperature gradient :

[0066] .

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

[0068] Specifically, a plurality of temperature data are collected during the etching process; a temperature gradient is calculated based on the plurality of temperature data by using a central difference method; and a variance of the temperature gradient is calculated by using a variance calculation formula.

[0069] Collecting discrete temperature points during the etching process allows real-time capture of temperature changes within the etching area. Using the central difference method to calculate temperature gradients can more accurately quantify spatial temperature trends. Compared to other simple difference methods, it offers greater noise suppression and can more realistically reflect the temperature distribution within the etching area, providing a reliable basis for analyzing the thermal state of the etching process.

[0070] To expand on this, we first collect the temperature data of the etching image block at the same time through the temperature sensor. As the etching process progresses, a set of discrete data points will be formed. , k It is k time, It is k Temperature data at the moment, n is the number of temperature data collected by the temperature sensor.

[0071] Next, the temperature gradient is calculated using the central difference method ,like:

[0072] ;

[0073] in, It is Temperature data at the moment, It is Temperature data at the moment, is the interval between temperature data points.

[0074] Finally, the variance of the temperature gradient is calculated according to the variance calculation formula :

[0075] ;

[0076] in, is the mean temperature gradient.

[0077] The calculation of the variance sum and preset weight of the temperature gradient of the etching image block is described above. Here, the etching solution concentration data is described.

[0078] Specifically, in order to eliminate the dimension effect, it is necessary to calculate the chloride ion concentration and The change value is normalized by Z-score normalization method or Min-Max normalization method. In addition, regarding the etching solution concentration mentioned above , the concentration of the etching solution after the collection is not used directly, but the concentration of the etching solution after Min-Max standardization:

[0079] ;

[0080] in, is the concentration of the etching solution collected during the etching process, is the minimum permissible concentration of etching solution, It is the maximum permissible concentration of etching solution.

[0081] Factor 2: Inter-class variance of etched image patches.

[0082] Specifically, the calculation of the inter-class variance of the image block still uses the inter-class variance calculation formula of the Otsu algorithm in the prior art, and the present invention does not improve it. Here is a brief description of how to calculate it. For each etching image block, the frequency of occurrence of each gray value is counted to obtain the grayscale histogram of each etching image block. Assume that the grayscale range of any etching image block is , is the total number of gray levels, then the probability of each gray value appearing The calculation formula is:

[0083] ;

[0084] in, is the grayscale value of the pixel, The gray value is The number of pixels, N is the total number of pixels in the etched image block.

[0085] Then traverse all possible thresholds , the etching image is divided into two parts: foreground and background. The grayscale value range of the foreground pixel is , the grayscale value range of background pixels is . Calculate the between-class variance:

[0086] ;

[0087] in, is the proportion of background pixels in the etched image block, is the proportion of foreground pixels in the etched image block, is the average gray value of background pixels, is the average gray value of foreground pixels;

[0088] ;

[0089] ;

[0090] ;

[0091] .

[0092] In summary, this is the calculation principle of comprehensive inter-class variance.

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

[0094] To expand on this, the comprehensive 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 comprehensive inter-class variance , It is the optimal segmentation threshold calculated by etching the image block.

[0095] Step S500 : performing threshold segmentation on the etched image block based on the optimal segmentation threshold to obtain a foreground area of ​​the etched image block.

[0096] Specifically, the optimal segmentation threshold for each etched image block is obtained according to the above process. All pixels within the etched image block are binarized based on the optimal segmentation threshold. If 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. Ultimately, each etched image block can obtain a foreground region after Otsu segmentation.

[0097] Step S600: splicing the foreground areas of multiple etching image blocks to obtain an etching image after threshold segmentation.

[0098] All foreground areas are spliced ​​in the order of their etching image blocks to obtain the etching image after threshold segmentation.

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

[0100] To elaborate, a multimodal feature fusion deep learning model commonly used in the prior art, such as the YOLO5 model, is selected to detect magnesium alloy chemical etching defects. Model training is required first. The specific process is: collect magnesium alloy chemical etching images with etching defects and their grayscale data, temperature, and depth data, merge the above content into a multi-channel image, mark the location and category of the defects, and generate the data set required for training. Use the above data set to train the YOLO5 model. After the model training is completed, the model is used to detect defects in images during and after etching, and output the detected defect information and defect probability.

[0101] The reason why grayscale, temperature, and depth data were chosen as training datasets is related to the characteristics of the defect types. Defects such as edge burrs, uneven etching, and foreign matter contamination have significant multimodal feature differences in grayscale, temperature, and depth data. For example, edge burrs appear as localized protrusions in depth data, while temperature data shows abnormal thermal gradients. Uneven etching areas appear as alternating light and dark patches in grayscale images, accompanied by non-uniform temperature distribution. Foreign matter contamination appears as a height difference from the substrate in the depth channel, and the grayscale value deviates from the normal etching texture.

[0102] It should be noted that the present invention makes differentiated settings for defects detected during the etching process and when the etching is completed.

[0103] For the etching image after threshold segmentation during the etching process, a defect probability threshold is set. The YOLO5 model focuses on detecting defect types that are highly distinguishable from normal etching traces. When the defect probability output by the model exceeds the defect threshold, feedback is provided to the etching machine to stop etching.

[0104] In addition, specific defect information is required. The highly distinguishable defect types mentioned above include edge burrs caused by residual etching solution or insufficient sidewall protection, uneven etching caused by local temperature anomalies, and foreign matter contamination.

[0105] The YOLO5 model performs a comprehensive inspection of the etched image after threshold segmentation at the completion of etching. This not only detects defect types that are highly distinguishable from normal etching traces, but also expands the defect types to include complex defects such as pitting and cracks. If defects are detected in the image, the current magnesium alloy chemical etching is deemed unqualified and defect information is output. This defect information includes detailed information such as defect coordinates, defect type, and defect size. Defect types include the aforementioned pitting, cracks, edge burrs, uneven etching, and foreign matter contamination.

[0106] While several embodiments of the present invention have been shown and described herein, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Numerous modifications, variations, and alternatives will occur to those skilled in the art without departing from the concept and spirit of the present invention. It should be understood that various alternatives to the embodiments of the present invention described herein may be employed in practicing the present invention.

Claims

1. A magnesium alloy chemical etching image detection method based on image processing, characterized in that: include: Collect etching solution concentration and continuous multiple-frame etching images during the etching process; Dividing the etching image into blocks to obtain a plurality of etching image blocks; For any etching image block, calculate its comprehensive inter-class variance, which satisfies the relationship: ,in, is the segmentation threshold, is the comprehensive inter-class variance corresponding to the segmentation threshold, is the variance of the temperature gradient of the etched image patch, is the standardized etching solution concentration, is the preset weight, is the inter-class variance corresponding to the segmentation threshold; determining an optimal segmentation threshold for the etched image block based on the comprehensive inter-class variance; Performing threshold segmentation on the etching image block based on an optimal segmentation threshold to obtain a foreground area of ​​the etching image block; Splicing the foreground areas of multiple etching image blocks to obtain an etching image after threshold segmentation; Identify defect information of the etching image after the threshold segmentation through a deep learning model; The setting of the preset weight includes: the initial value of the weight of the etching image block of the first etching image collected is set to 0.3 according to experience, and the weight value at subsequent moments is calculated based on the data during the etching process, which includes collecting the chloride ion concentration of the etching area corresponding to the etching image block. and value; The acquisition time of the etching image where the etching image block is located is recorded as the analysis time, and the weight of the corresponding image block in the etching image at the acquisition time before the analysis time is obtained. 、 value; Calculate the analysis time and the previous acquisition time Change value ; The weight of the etched image block is calculated, and the weight satisfies the relationship: ; in, is the chloride ion concentration and Preset synergy factors for changing values; 、 is the normalized chloride ion concentration and Change value, () is the hyperbolic tangent function, is the preset feedback parameter value; The identifying defect information of the etching image after the threshold segmentation by a deep learning model includes: Perform defect detection using the deep learning model, and output defect probability and defect information of the etching image after the threshold segmentation; When the defect probability is greater than the defect threshold, etching is stopped.

2. The magnesium alloy chemical etching image detection method based on image processing according to claim 1, characterized in that: The standardized etching solution concentration ; in, is the concentration of the etching solution during the etching process, is the minimum permissible concentration of the etching solution, It is the maximum permissible concentration of the etching solution.

3. The magnesium alloy chemical etching image detection method based on image processing according to claim 1, characterized in that: The determining of the optimal segmentation threshold of the etched image block based on the comprehensive inter-class variance includes: The maximum value of the comprehensive inter-class variance of the etched image block is calculated, and the threshold corresponding to the maximum value of the comprehensive inter-class variance is the optimal segmentation threshold.

4. The magnesium alloy chemical etching image detection method based on image processing according to claim 1, characterized in that: The standardized chloride ion concentration and The change value is the Z-score standardization or Min-Max standardization method for chloride ion concentration and The change values ​​are obtained by standardization.

5. The magnesium alloy chemical etching image detection method 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: It also collects infrared thermal images and divides 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 block; calculating a mean value of the temperature gradient; Calculating the variance of the temperature gradient of the infrared thermal image block 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.

6. The magnesium alloy chemical etching image detection method 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 a plurality of temperature data during the etching process; calculating a temperature gradient by a central difference method based on the plurality of temperature data; The variance of the temperature gradient is calculated using a variance calculation formula.

7. The magnesium alloy chemical etching image detection method based on image processing according to claim 1, characterized in that: The defect information includes defect coordinates, defect type, and defect size.

8. The magnesium alloy chemical etching image detection method based on image processing according to claim 7, characterized in that: The defect types include: pitting and cracks.

Citation Information

Patent Citations

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

    CN109993736A

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

    CN117314893A