Preprocessing method suitable for liquid-phase plasma discharge spark image recognition
By combining the rolling ball algorithm and grayscale standard deviation, the problem of segmentation of small target discharge spark images under complex backgrounds is solved, and efficient segmentation and recognition of spark images are achieved.
Patent Information
- Application Number
- CN202411799933.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2044-12-09
AI Technical Summary
Existing threshold segmentation methods cannot accurately segment small target discharge spark images in complex backgrounds with high gray levels, uneven image brightness, and multi-peak gray level histograms, resulting in poor segmentation performance.
An uneven background is removed by using a background correction method based on the rolling ball algorithm. An automatic thresholding method based on gray mean and gray standard deviation is used to segment the image by finding the optimal segmentation threshold.
The contrast between the background and the target area was improved, and the grayscale histogram of the spark image was transformed from multi-peaked to single-peaked, achieving better segmentation results and improving the accuracy of spark target identification.
Smart Images

Figure CN119741328B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing technology and relates to a preprocessing method for image recognition of liquid phase plasma discharge sparks. Background Technology
[0002] The technology of generating plasma through discharge in a liquid phase to achieve specific processing effects has wide applications in material surface modification, environmental hazardous waste treatment, and biological sterilization. Plasma discharge in the liquid phase produces discharge phenomena such as sparks and arcs, and corresponding evolution processes. These discharge phenomena are important indicators of the reaction state of the process. Plasma electrolytic oxidation is a liquid-phase plasma discharge processing technology for surface modification of light metal materials. Its characteristic is the formation of a ceramic film layer on the material surface, which possesses excellent properties such as high hardness, good wear resistance, corrosion resistance, and high-temperature shock resistance. During this reaction, dense and random spark generation and annihilation phenomena occur, continuously evolving in terms of the number of sparks and discharge intensity. Feature extraction of discharge sparks is of great value for process monitoring, but the dynamic and complex nature of the discharge process makes image recognition a technical challenge. Under complex background conditions such as spark evolution and liquid phase fluctuations, image segmentation technology is a key link in this image recognition, especially the accurate segmentation of small target discharge sparks in complex backgrounds. In "Fast Calculation of Segmentation Threshold under Otsu's Criterion (Thresholding Method Based on Inter-Class Variance)," He Zhiyong determined a threshold conforming to the Otsu criterion by searching for thresholds equal to the integer part of the average of the intra-class means of the two classes, achieving better segmentation results for small target gradient images. In "Otsu Segmentation Method Based on Small Target Pre-extraction," Li Xu employed a target pre-extraction method based on target edge information, using the Otsu method to segment images with potential target regions, thus achieving effective detection of small infrared targets in complex backgrounds. "Research on Dragon Fruit Image Segmentation Based on Otsu Algorithm and Morphology" and "Research on Image Segmentation Algorithm Based on Otsu Algorithm and Mathematical Morphology" first used the traditional Otsu algorithm to segment the target and background, then applied morphological methods for filtering and noise removal, improving the segmentation effect. The traditional Otsu algorithm performs best in images with a single-peaked or double-peaked grayscale histogram.
[0003] In real-world scenarios, liquid-phase plasma electrolytic oxidation occurs in a solution, which is affected by uneven illumination, bubble interference, and dynamic changes during the reaction process. This leads to uneven background brightness, low contrast between the target and background areas, overlapping grayscale values, and a three- or multi-peak grayscale histogram. For segmenting small target discharge sparks in real-world scenarios, traditional morphological methods using erosion and dilation can make the spark image overly smooth and blurry at the edges, making it difficult to distinguish between bright noise and spark points, and resulting in missed extraction of spark points at image edges. Since the Otsu algorithm calculates inter-class variance based on the grayscale differences between different regions of the image, uneven illumination can cause these differences to reflect illumination variations rather than the true distinction between foreground and background, leading to threshold deviations and failing to achieve optimal segmentation results. Summary of the Invention
[0004] The purpose of this invention is to provide a preprocessing method suitable for image recognition of liquid phase plasma discharge sparks, which solves the problem that existing threshold segmentation methods cannot accurately segment small target discharge sparks in complex backgrounds with high gray levels, uneven image brightness, and multi-peak gray level histograms.
[0005] The technical solution adopted in this invention is a preprocessing method suitable for image recognition of liquid phase plasma discharge sparks, specifically including the following steps:
[0006] Step 1: Use an industrial camera to take pictures of the workpiece surface to obtain the spark image to be processed;
[0007] Step 2: Convert the spark image obtained in Step 1 to grayscale to obtain a grayscale histogram.
[0008] Step 3: Perform background correction on the spark image to be processed after grayscale conversion in Step 2 using a background correction method based on the rolling ball algorithm;
[0009] Step 4: The optimal segmentation threshold is obtained by using an automatic thresholding method based on grayscale mean and grayscale standard deviation. The sparks and background in the spark image processed in Step 3 are then segmented to obtain the target spark image.
[0010] The invention is further characterized by:
[0011] The specific process of step 2 is as follows:
[0012] The colors of the pixels in the spark image obtained in step 1 are converted to grayscale using a weighted average method, as shown in the following formula:
[0013] I(x, y) = 0.3I R (x, y) + 0.59I G (x, y) + 0.11I B(x, y) (1)
[0014] Where x represents the vertical position of the pixel in the image, and y represents the horizontal position of the pixel in the image; I R (x, y), I G (x, y), I B (x, y) represent the values of the red, green, and blue components of the pixel at position (x, y), respectively.
[0015] The specific process of step 3 is as follows:
[0016] Step 3.1: Use the background correction technique based on the rolling ball algorithm to estimate the background of the spark image;
[0017] Step 3.2: Obtain the corrected image F based on the background estimation result obtained in Step 3.1, and remove uneven background pixels from the spark image.
[0018] The specific process of step 3.1 is as follows:
[0019] Step 3.1.1: Define a spherical mask with radius R. This mask is used to determine the neighborhood region of each position (i, j) in the image, as shown in the following formula:
[0020]
[0021] Where x and y are the horizontal and vertical distances from any position other than position (i, j) to position (i, j);
[0022] Step 3.1.2: Define the image to be processed after grayscale conversion in step 2 as I, with a size of M×N. First, expand the image horizontally, increasing the width by 2R pixels. The horizontally expanded image I... PX The dimensions will become (M+4R)×N, and the formula for horizontal expansion is as follows:
[0023]
[0024] Then, the horizontally expanded image I... PX Vertical expansion is performed, increasing the height by 2R pixels. The vertically expanded image I P The dimensions will become (M+4R)×(N+4R), and the formula for vertical expansion is as follows:
[0025]
[0026] Step 3.1.3: Create a local background matrix Q, with the same size as the original image I defined in step 3.1.2;
[0027] Step 3.1.4: For each pixel (i, j) in the image, define a window W(i, j) centered at (i, j) with a size of (2R+1)×(2R+1);
[0028] Step 3.1.5: Extract all pixel values within the mask centered at (i, j), forming a set S, denoted as:
[0029] S = {S1,S2,…,S} n}(5)
[0030] Among them, S m This represents the m-th pixel value in the set, where n is the total number of pixel values in the set.
[0031] Step 3.1.6: Sort all pixel values in set S from step 3.1.5 in descending order to obtain a new set.
[0032]
[0033] in,
[0034] Step 3.1.7, calculate the set in step 3.1.6. The median value is calculated using the following formula:
[0035]
[0036] Step 3.1.8: Within the window W(i, j) defined in step 3.1.4, apply the spherical mask defined in step 3.1.1, considering only pixels with a mask value of 1. Set the median value of these pixels to the value at position (i, j) in the image, and place it into the local background matrix Q to obtain the non-uniform background C, with a size of M×N. This achieves the extraction of the non-uniform background of the spark image, as shown in the following formula:
[0037] C(i,j)=median{I P (i,j)mask(i,j)=1}(8).
[0038] The specific process of step 3.2 is as follows:
[0039] Subtract the non-uniform background C obtained in step 3.1.8 from the image I to be processed as defined in step 3.1.2 to obtain the corrected image F, which has a size of M×N. This process removes non-uniform background pixels from the spark image, as shown in the following formula:
[0040] F(i,j)=I(i,j)-C(i,j)(9).
[0041] The specific process of Step 4 is as follows:
[0042] Step 4.1, obtain the optimal segmentation threshold k by using the automatic threshold segmentation method based on the grayscale mean and grayscale standard deviation;
[0043] Step 4.2, normalize the optimal threshold k obtained in Step 4.1 to get the normalized optimal threshold k n :
[0044] Step 4.3, calculate the optimal segmentation threshold T according to the average grayscale value All ave and the maximum inter-class standard deviation ICV t ;
[0045] Step 4.4, segment the image into a binary image by using the optimal segmentation threshold T.
[0046] The specific process of Step 4.1 is as follows:
[0047] Step 4.1.1, initialize the threshold variable t, and traverse each grayscale level of the image. The formula is as follows:
[0048] t ∈ {0, 1, 2, …, 255} (10)
[0049] Step 4.1.2, initialize the total grayscale value and total number of pixels of part A and part B, that is, the total grayscale value H of part A A = 0, the total number of pixels N of part A A = 0, the total grayscale value H of part B B = 0, the total number of pixels N of part B B = 0;
[0050] Step 4.1.3, traverse each pixel point F(i, j) of the corrected image F obtained in Step 3.2. If the pixel value is less than the threshold variable, that is, F(i, j) < t, then N A = N A + 1, H A = H A + F(i, j); Otherwise, if the pixel point is greater than or equal to the threshold variable, that is, F(i, j) ≥ t, then N B = N B + 1, H B = H B + F(i, j);
[0051] Step 4.1.4, calculate the pixel ratios P A and P B , as well as the average grayscale values A ave and B ave ;
[0052] Step 4.1.5: Calculate the average gray value All of the corrected image F obtained in step 3.2. ave The formula is as follows:
[0053]
[0054] Step 4.1.6: Calculate the inter-class standard deviation (ICV) at the current threshold t using a threshold segmentation algorithm based on inter-class standard deviation.
[0055]
[0056] Step 4.1.7: Compare the current inter-class standard deviation (ICV) with the previous maximum inter-class standard deviation (ICV). t If ICV > ICV t Then update ICV t And record the current threshold t as the optimal threshold k.
[0057] In step 4.3, the average gray value All ave Maximum inter-class standard deviation (ICV) t The following linear relationship exists between the optimal segmentation threshold T and the target segmentation threshold:
[0058] T = All ave +k n *ICV t (13).
[0059] The specific process of step 4.4 is as follows: Segment the image into a binary image using the optimal segmentation threshold T:
[0060] T = T[i,j,p(i,j),f(i,j)](14)
[0061] Where i,j represent the horizontal and vertical coordinates of a pixel, p(i,j) represents the local characteristics of the pixel, and f(i,j) represents the grayscale value of the pixel. The image after thresholding is a binary image, defined as:
[0062]
[0063] The beneficial effects of this invention are as follows: Addressing the challenges of a relatively small target area for discharge sparks, a large background area, uneven background brightness in the spark image, low contrast between the background and target areas, and a three- or multi-peaked gray-level histogram of the spark sample, this invention first removes most of the unevenly bright background using a background correction method based on a rolling ball algorithm. This improves the contrast between the background and target areas while transforming the multi-peaked gray-level histogram of the spark image into a single-peaked characteristic. Based on this, an automatic thresholding method based on inter-class standard deviation is proposed. The maximum inter-class standard deviation is calculated, and the linear relationship between the gray-level mean of the spark image and the maximum inter-class standard deviation is used to make the segmentation threshold approximate the right edge of the single-mode histogram, achieving better segmentation results. Attached Figure Description
[0064] Figure 1 This is a flowchart of the preprocessing method for liquid phase plasma discharge spark image recognition according to the present invention;
[0065] Figures 2(a) to 2(c) These are, respectively, the spark images to be processed captured by the camera at reaction times of 3 min, 8 min, and 16 min in the preprocessing method for liquid phase plasma discharge spark image recognition applicable to this invention;
[0066] Figures 3(a) to 3(f) This invention provides grayscale images and 3D surface maps of spark samples with reaction times of 3 min, 8 min, and 16 min in a preprocessing method for recognizing spark images of liquid-phase plasma discharge.
[0067] Figures 4(a) to 4(i) This is a comparison image of the effect after background correction in the preprocessing method for image recognition of liquid phase plasma discharge sparks in this invention;
[0068] Figure 5 This is the undersegmentation effect of the traditional threshold segmentation method based on inter-class variance, as shown in Figure 4(a).
[0069] Figures 6(a) to 6(d) This is a diagram showing the spark image threshold segmentation effect when the k value is 0.1, 0.3 and adaptively calculated 0.19 in the preprocessing method for spark image recognition of liquid phase plasma discharge according to the present invention. Detailed Implementation
[0070] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.
[0071] Example 1
[0072] This invention relates to a preprocessing method for liquid-phase plasma discharge spark image recognition, such as... Figure 1 As shown, it includes the following steps:
[0073] Step 1: A high-resolution color area array industrial camera with a resolution of 4383×3288, JHUM1400s, is used to take pictures of the workpiece surface. Figures 2(a), 2(b), and 2(c) are the spark images of the workpiece to be processed taken by the camera at reaction times of 3 min, 8 min, and 16 min, respectively.
[0074] Step 2: Convert the spark image obtained in Step 1 to grayscale to obtain a grayscale histogram.
[0075] Step 3: Perform background correction on the spark image to be processed after grayscale conversion in Step 2 using a background correction method based on the rolling ball algorithm;
[0076] Step 4: The optimal segmentation threshold is obtained by the automatic thresholding method based on gray mean and gray standard deviation. The spark and background of the spark image to be processed after the background correction method based on rolling ball algorithm are segmented to obtain the target spark image.
[0077] Example 2
[0078] Step 2 involves converting the colors of pixels in the spark image captured in Step 1 to grayscale using a weighted average method. The conversion formula is as follows:
[0079] I(x, y) = 0.3I R (x, y) + 0.59I G (x, y) + 0.11I B (x, y) (1)
[0080] Where x represents the vertical position of the pixel in the image, y represents the horizontal position of the pixel in the image, and I(x, y) represents the gray value of the point (x, y). R (x, y), I G (x, y), I B (x, y) represent the values of the red, green, and blue components of the pixel at position (x, y), respectively.
[0081] A 3D surface map of a grayscale image is a technique that converts a two-dimensional grayscale image into a three-dimensional surface representation. In a grayscale image, the grayscale value of each pixel typically represents the height information of that point. In a 3D surface map of a grayscale image, the height information of each pixel can be visually observed, such as... Figures 3(a) to 3(f) As shown, Figure 3(a) is the grayscale image of Figure 2(a) after grayscale processing in step 2, and Figure 3(d) is the 3D surface image corresponding to Figure 3(a); similarly, Figure 3(b) and Figure 3(c) are the grayscale images of Figure 2(b) and Figure 2(c) after grayscale processing in step 2, respectively, and Figure 3(e) and Figure 3(f) are the 3D surface images corresponding to Figure 3(b) and Figure 3(c);
[0082] Specifically, due to the uneven brightness of the spark image to be processed, traditional image segmentation can lead to the extraction of background as sparks in areas with excessively high brightness, while sparks may not be extracted in areas with excessively low brightness. Therefore, it is necessary to homogenize the brightness of the spark image. Furthermore, the proportion of low-grayscale pixels reflecting background areas in the image is too large, which not only reduces the average grayscale value of the spark image but also increases its contrast, affecting the determination of the optimal threshold. By removing these background pixels, the multi-peak image multi-threshold segmentation problem is transformed into a single-peak image single-threshold segmentation problem, making the Otsu method suitable for segmenting small target spark images.
[0083] Example 3
[0084] The specific process of step 3 is as follows:
[0085] Step 3.1: Use the background correction technique based on the rolling ball algorithm to estimate the background of the spark image;
[0086] Step 3.1.1: Define a spherical mask with radius R, which is set to 20 in the experiment. This mask is used to determine the neighborhood of each location (i, j) in the image. The formula is as follows:
[0087]
[0088] Where x and y are the horizontal and vertical distances from any position other than position (i, j) to position (i, j).
[0089] Step 3.1.2: Perform image boundary expansion. Define the image to be processed after grayscale conversion in step 2 as I (I can be considered as a two-dimensional array), with a size of M×N. In the experiment, M=175 and N=192. First, expand the image horizontally, increasing the width by 2R pixels. Then, the horizontally expanded image I... PX The dimensions will become (M+4R)×N, which is 255×192. The formula for horizontal expansion is as follows:
[0090]
[0091] Then, the horizontally expanded image I... PX By vertically expanding the image by 2R pixels in height, the vertically expanded image I... P The dimensions will become (M+4R)×(N+4R), which is 255×272. The formula for vertical expansion is as follows:
[0092]
[0093] Step 3.1.3: Create a local background matrix Q. The size of the matrix is the same as the original image I defined in step 3.1.2. The values in this matrix are zero, which is equivalent to a background with no pixels and the same size as the original image I.
[0094] Step 3.1.4: For each pixel (i, j) in the image, define a window W(i, j) centered at (i, j) with a size of (2R+1)×(2R+1), i.e., 41×41.
[0095] Step 3.1.5: Extract all pixel values within the mask centered at (i, j), forming a set S. S can be represented as:
[0096] S = {S1,S2,…,S} n}(5)
[0097] Among them, S m This represents the m-th pixel value in the set, where n is the total number of pixel values in the set.
[0098] Step 3.1.6: Sort all pixel values in set S from step 3.1.5 in descending order to obtain a new set.
[0099]
[0100] in,
[0101] Step 3.1.7, calculate the set in step 3.1.6. The median value is calculated using the following formula:
[0102]
[0103] Step 3.1.8: Within the window W(i, j) defined in step 3.1.4, apply the spherical mask defined in step 3.1.1, considering only pixels with a mask value of 1. Set the median value of these pixels to the value at position (i, j) in the image, and place it into the local background matrix Q to obtain the non-uniform background C, with a size of M×N. The mathematical formula for extracting the non-uniform background of the spark image is as follows:
[0104] C(i,j)=median{I P (i,j)mask(i,j)=1}(8)
[0105] Example 4
[0106] Step 3.2: Subtract the non-uniform background C obtained in step 3.1.8 from the image to be processed I defined in step 3.1.2 to obtain the corrected image F, with a size of M×N. The removal of non-uniform background pixels in the spark image is achieved using the following formula:
[0107] F(i,j)=I(i,j)-C(i,j) (9)
[0108] The above processing method removes most of the uneven background, improves the contrast between the background and target areas, and also transforms the grayscale histogram of the spark image from multi-peaked to uni-peaked. The 3D surface maps and grayscale histograms of the original image, the local background image, and the corrected image are shown below. Figures 4(a) to 4(i) As shown, a spark image with uneven illumination and bubble interference is selected. Figures 4(a), 4(b), and 4(c) are the original grayscale image, the grayscale image of the uneven background, and the corrected grayscale image, respectively, reflecting the process of the background correction method. Figures 4(d), 4(e), and 4(f) are the 3D surface maps corresponding to Figures 4(a), 4(b), and 4(c), respectively, which can intuitively show the process of the background correction method removing redundant background pixels. Figures 4(g), 4(h), and 4(i) are the grayscale histograms corresponding to Figures 4(a), 4(b), and 4(c), respectively, which can intuitively show that the background correction method overcomes the deficiency of the Otsu's method, which directly uses the Otsu's method, in accurately segmenting images with uneven brightness backgrounds.
[0109] Specifically, after the background correction method, the gray-level histogram of the spark image changes from multi-peaked to uni-peaked, satisfying the requirement that the image gray-level histogram should exhibit obvious bi-peak or uni-peak characteristics when using the Otsu method to obtain a single threshold. However, due to the relatively small size of the spark target area, the low contrast between the background and target areas, and the overlap between the gray-level values of the background and target pixels, even though the background correction method effectively improves the contrast between the background and target areas and improves the segmentation effect of the Otsu method to some extent, the problem still exists that the obtained optimal threshold is slightly lower than the ideal threshold, leading to under-segmentation. Figure 5 As shown. To address the above problems, this invention proposes an automatic threshold segmentation method based on inter-class standard deviation.
[0110] Example 5
[0111] Step 4.1: Obtain the optimal segmentation threshold k using an automatic thresholding method based on grayscale mean and grayscale standard deviation;
[0112] Step 4.1.1: Initialize the threshold variable t and set its traversal range to 0 to 255, that is, traverse every gray level of the image, as shown in the following formula:
[0113] t ∈ {0, 1, 2, …, 255}(10)
[0114] Step 4.1.2, initialize the total gray value and total number of pixels of part A and part B, that is, the total gray value H of part A A = 0, the total number of pixels N of part A A = 0, the total gray value H of part B B = 0, the total number of pixels N of part B B = 0;
[0115] Step 4.1.3, traverse each pixel point F(i, j) of the corrected image F obtained in step 3.2. If the pixel value is less than the threshold variable, that is, F(i, j) < t, then N A = N A + 1, H A = H A + F(i, j); Otherwise, if the pixel point is greater than or equal to the threshold variable, that is, F(i, j) ≥ t, then N B = N B + 1, H B = H B + F(i, j);
[0116] Step 4.1.4, calculate the pixel ratios P A and P B (A is the pixel points below the variable t, B is the pixel points above the variable t), and the average gray values A ave and B ave :
[0117]
[0118] Step 4.1.5, calculate the average gray value All of the corrected image F obtained in step 3.2 ave , the formula is as follows:
[0119]
[0120] Step 4.1.6, use the threshold segmentation algorithm based on between-class standard deviation to calculate the between-class standard deviation ICV under the current threshold t:
[0121]
[0122] Step 4.1.7, compare the current between-class standard deviation ICV with the previous maximum between-class standard deviation ICV t :
[0123] If ICV > ICV t , then update ICV tThe current threshold t is recorded as the optimal threshold k. In the experiment, the optimal threshold k was calculated to be 48.64, where the optimal threshold k corresponds to the total gray value H of the intermediate variable A in this experiment. A =713.42, the total number of pixels N in part A A =30999, the total grayscale value H of part B B = 946.07, the total number of pixels N in part B B =2601, average gray value A ave and B ave The pixel ratios P for parts A and B are 5.87 and 92.75 respectively. A and P B The average gray values of image F are 0.923 and 0.077, respectively. ave The maximum inter-class standard deviation (ICV) is 12.59. t It is 539.12;
[0124] Example 6
[0125] Step 4.2: Normalize the optimal threshold k obtained in Step 4.1 to obtain the normalized optimal threshold k. n =0.19, the formula is as follows:
[0126]
[0127] When dealing with and segmenting the background and target spark regions—two regions with different gray-level distributions—considering the image's gray-level mean and standard deviation is a feasible approach. The target spark region's gray-level values lie to the right of the histogram's mean, while the background region's gray-level values lie to the left. Therefore, the mean can be considered as a reference standard for extracting the target spark. Based on the characteristics of spark images, the average gray-level value of the target spark must be greater than the mean; however, the specific deviation from the mean depends on the contrast between the foreground and background of the spark image, i.e., the standard deviation.
[0128] In this invention, the inter-class standard deviation is used to reflect the uniformity of gray-level distribution in the spark image. A larger inter-class standard deviation between the background and the target indicates a greater distance between the two parts constituting the image, resulting in more segmentation of the target and background, and better segmentation performance. Therefore, segmentation that maximizes the inter-class standard deviation implies the lowest probability of misclassification. During threshold segmentation of differential gray-level images, after numerous repeated experiments and observations, it was found that the average gray-level value All of the differential gray-level images... ave Maximum inter-class standard deviation (ICV) t There is a certain linear relationship between the selection of the optimal segmentation threshold T and the selection of the threshold.
[0129] Step 4.3, Average Gray Value All ave Maximum inter-class standard deviation (ICV)t The following linear relationship exists between the optimal segmentation threshold T and the target segmentation threshold:
[0130] T = All ave +k n *ICV t (14)
[0131] Step 4.4, k n The value is set to 0.19, and then the image is segmented into a binary image using the optimal segmentation threshold T:
[0132] T = T[i,j,p(i,j),f(i,j)](15)
[0133] In the above formula, i,j represent the horizontal and vertical coordinates of the pixel, p(i,j) represents the local characteristics of the pixel, and f(i,j) represents the gray value of the pixel. The image after thresholding is a binary image, defined as:
[0134]
[0135] Pixels represented by 0 are used as target sparks, and then target spark features are extracted. Different k... n The effect of threshold segmentation of values is shown in the figure. Figures 6(a) to 6(d) As shown, Figure 6(a) is the original grayscale image of Figure 4(a), and Figure 6(b) is the grayscale image of k. n Figure 6(c) shows the effect of spark image thresholding with a value of 0.1. n The image thresholding effect of the spark image with a value of 0.3 is shown in Figure 6(d). n The image shows the spark image thresholding effect with an adaptively calculated value of 0.19. A comparison shows that the automatic thresholding method based on inter-class standard deviation adaptively calculates k... n A value of 0.19 can achieve good segmentation results when segmenting an image.
[0136] By employing the above methods, this invention addresses the challenges of a relatively small target area for the discharge spark, a large background area, low contrast between the background and target areas, and a three- or multi-peak gray-level histogram in the discharge spark samples. First, background correction removes most of the non-uniform background, improving the contrast between the background and target areas while transforming the multi-peak gray-level histogram of the spark image into a single-peak characteristic. Based on this, an automatic thresholding method based on inter-class standard deviation is proposed. The maximum inter-class standard deviation is calculated, and by utilizing the linear relationship between the gray-level mean of the spark image and the maximum inter-class standard deviation, the optimal segmentation threshold is made closer to the right edge of the single-mode histogram, achieving better segmentation results. This improves the accuracy of identifying the reaction state of plasma electrolytic oxidation and facilitates more precise control of the reaction process.
Claims
1. A pre-processing method suitable for liquid plasma discharge spark image recognition, characterized in that: Specifically comprising the following steps: Step 1, using an industrial camera to take pictures of the workpiece surface to obtain a spark image to be processed; Step 2, the spark image obtained by shooting in step 1 is grayed to obtain a gray histogram; Step 3, the background correction method based on the rolling ball algorithm is used to correct the background of the spark image to be processed in step 2; Step 4, the optimal segmentation threshold is obtained based on the automatic threshold segmentation method of gray mean and gray standard deviation, and the spark and background in the spark image processed in step 3 are segmented to obtain a target spark image; The specific process of step 4 is: Step 4.1, the optimal segmentation threshold k is obtained based on the automatic threshold segmentation method of gray mean and gray standard deviation; The specific process of step 4.1 is: Step 4.1.1, initialize the threshold variable t, and traverse each gray level of the image, as follows: (1) Step 4.1.2, initialize total gray value and total pixel number of A part and B part, i.e. total gray value of A part = 0, total pixel number of A part = 0, total gray value of B part = 0, total pixel number of B part = 0; Step 4.1.3, traversing each pixel of the corrected image F obtained from step 3.2 If the pixel value is less than the threshold variable, i.e. t, then +1, + ; Otherwise, the pixel point is greater than or equal to the threshold variable, that is, t, then = +1, = + ; Step 4.1.4, calculating the pixel ratio of A part and B part and and the average gray value and ; Step 4.1.5, calculating the average gray value of the corrected image F obtained in step 3.2 The formula is as follows: (2) Step 4.1.6, compute the inter-class standard deviation under the current threshold t using the inter-class standard deviation based thresholding algorithm : (3) Step 4.1.7, compare current inter-class standard deviation to previous maximum inter-class standard deviation : if then update and record current threshold t as optimal threshold k; Step 4.2, normalizing the optimal threshold k obtained in step 4.1 to obtain a normalized optimal threshold : Step 4.3, according to the average gray value with the maximum inter-class variance find the optimal segmentation threshold T; Step 4.4, the image is segmented into a binary image using the best segmentation threshold T.
2. The pre-processing method suitable for liquid-phase plasma discharge spark image recognition according to claim 1, characterized in that: The specific process of step 2 is: The color of the pixel point in the spark image obtained by shooting in step 1 is converted into gray scale by weighted average method, as follows: (4) where x represents the vertical position of the pixel point in the image, and y represents the horizontal position of the pixel point in the image; represents the gray value of the (x, y) point, , , respectively represent the values of the red, green and blue components of the pixel point at the position (x, y).
3. The pre-processing method suitable for liquid-phase plasma discharge spark image recognition according to claim 2, characterized in that: The specific process of step 3 is: Step 3.1, the background estimation of the spark image is performed using the background correction technology based on the rolling ball algorithm; Step 3.2, the corrected image F is obtained according to the background estimation result obtained in step 3.1, and the non-uniform background pixel points in the spark image are removed.
4. The pre-processing method suitable for liquid plasma discharge spark image recognition according to claim 3, characterized in that: The specific process of step 3.1 is: Step 3.1.1, define a sphere mask with radius R, which is used to determine the field region of each position in the image, as follows: Step 3.1.2, define a sphere mask with radius R, which is used to determine the field region of each position in the image, as follows: (5) wherein x, y is the horizontal and vertical distance from any other position in the image to position ; Step 3.1.2, define the image to be processed after step 2 graying as I, the size is First, expand the image in the horizontal direction, increase the width of 2R pixels, the size of the horizontally expanded image will become (M+4R) N, the formula for horizontal expansion is as follows: (6) Then the horizontally expanded image Vertical expansion is performed, increasing the height by 2R pixels. The vertically expanded image... The dimensions will become (M+4R). (N+4R), the formula for vertical expansion is as follows: (7) Step 3.1.3, create a local background matrix Q, which is equal in size to the original image I defined in step 3.1.2; Step 3.1.
4. For each pixel in the image, define a window centered at with size ; Step 3.1.5, extract all the pixel values in the mask centered at form a set S, S is represented as: (8) wherein, denotes the mth pixel value in the set, is the total number of pixel values in the set; Step 3.1.6, sort all the pixel values in the set S in step 3.1.5 in descending order to get a new set ; (9) wherein ; Step 3.1.
7. Calculate the median of the set in step 3.1.6, using the following formula: Step 3.1.
7. Calculate the median of the set in step 3.1.6, using the following formula: (10) Step 3.1.8, the window defined in step 3.1.4 Inside, the application defined in step 3.1.1 sphere mask, only consider the mask value of 1 pixel, the median of these pixels set to the value of the image in the position Put into the local background matrix Q, get uneven background C, size , the realization of spark image uneven background extraction, the formula is as follows: (11)。 5. The pre-processing method suitable for liquid plasma discharge spark image recognition according to claim 4, characterized in that: The specific process of step 3.2 is: Subtracting the non-uniform background C obtained from step 3.1.8 from the image to be processed I defined in step 3.1.2, a corrected image F is obtained, with a size of , the non-uniform background pixels of the spark image are removed, and the formula is as follows: (12)。 6. The pre-processing method suitable for liquid plasma discharge spark image recognition according to claim 1, characterized in that: In step 4.3, the average gray value , the maximum inter-class variance and the optimal segmentation threshold T have the following linear relationship: (13)。 7. The pre-processing method suitable for liquid plasma discharge spark image recognition according to claim 1, characterized in that: The specific process of step 4.4 is to segment the image into a binary image using the best segmentation threshold T: (14) wherein, represents the horizontal and vertical coordinates of a pixel, represents the local characteristics of a pixel, represents the gray value of a pixel, and the image after thresholding is a binary image, defined as: (15)。
Citation Information
Patent Citations
Intelligent electric meter chip image binarization processing method based on adaptive mixed threshold
CN111986222A
Otsu thresholding method with mask
CN113870182A