Preprocessing method suitable for liquid-phase plasma discharge spark image recognition
By using the rolling ball algorithm to perform background correction in liquid plasma discharge spark image recognition, and combining the automatic threshold segmentation method of gray mean and standard deviation, the problem of small-target spark segmentation in complex backgrounds is solved, and efficient spark image segmentation and reaction state recognition are achieved.
Patent Information
- Application Number
- CN202411799933.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-12-09
AI Technical Summary
The existing threshold segmentation method cannot accurately segment small target discharge sparks under complex backgrounds with high grayscale levels, uneven image brightness, and multi-modal grayscale histogram.
The background correction method based on the rolling ball algorithm is used to remove the background with uneven brightness, improve the contrast between the background area and the target area, and obtain the optimal segmentation threshold through an automatic threshold segmentation method based on the grayscale mean and grayscale standard deviation to realize the segmentation of sparks and backgrounds.
The grayscale histogram of the spark image is converted from multiple peaks to single peaks through background correction, which improves the segmentation effect, allowing small-target discharge sparks to be accurately segmented, and improves the accuracy of identifying the plasma electrolytic oxidation reaction state.
Smart Images

Figure CN119741328A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of image processing and relates to a preprocessing method suitable for liquid plasma discharge spark image recognition. Background Art
[0002] The technology of generating plasma by discharge in the liquid phase to achieve specific processing effects has a wide range of uses in the fields of material surface modification, environmental hazardous waste treatment, and biological sterilization. Plasma discharge in the liquid phase will produce discharge phenomena such as sparks and arcs and the corresponding evolution process. These discharge phenomena are important representations of the reaction state of the process. Plasma electrolytic oxidation is a liquid phase plasma discharge machining technology that achieves surface modification on the surface of light metal materials. Its characteristic is that a ceramic film layer is formed on the surface of the material, which has excellent properties such as high hardness, good wear resistance, corrosion resistance and high temperature impact resistance. In the reaction process, dense and random spark generation and annihilation phenomena will occur, and the number of sparks and discharge intensity will continue to evolve. The feature extraction of discharge sparks is of great value for process monitoring, but the image recognition of the discharge process becomes a technical difficulty due to the dynamic and complexity of the discharge process. Under complex background conditions such as spark evolution and liquid phase fluctuations, image segmentation technology is a key link in the image recognition, especially the accurate segmentation of small target discharge sparks under complex backgrounds. In "Fast Calculation of Segmentation Thresholds under Otsu (Threshold Segmentation Method Based on Inter-class Variance) Criteria", He Zhiyong searches for a threshold equal to the integer part of the average of the two class means, and determines a threshold that meets the Otsu criterion, which has a better segmentation effect on small target gradient images; in "Otsu Segmentation Method Based on Small Target Pre-extraction", Li Xu uses a method of pre-extracting targets based on target edge information, and uses the Otsu method to segment images with potential target areas to achieve effective detection of infrared small 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 use the traditional Otsu algorithm to segment the target and background, and then use morphological methods to filter and remove noise, which improves the segmentation effect. The traditional Otsu algorithm works best when processing images with single-peak or double-peak grayscale histograms.
[0003] In actual scenes, since liquid plasma electrolytic oxidation occurs in the solution, it will be disturbed by uneven illumination, bubble interference, and dynamic changes in the reaction process, resulting in uneven image background brightness, low contrast between the target area and the background area, overlapping grayscale value distribution, and grayscale histogram showing three peaks or multiple peaks. For the segmentation problem of small target discharge sparks in actual scenes, the erosion and expansion in traditional morphological methods will make the spark image too smooth and the edges blurred, making it difficult to distinguish between highlight noise and spark points, and missing the extraction of spark points at the edge of the image. Since the Otsu algorithm calculates the inter-class variance based on the grayscale value difference of different areas in the image, if the illumination conditions of the image are uneven, it may cause this difference to reflect the change of illumination more than the real difference between the foreground and the background, causing the calculated threshold deviation and failing to achieve the optimal segmentation effect. Summary of the invention
[0004] The purpose of the present invention is to provide a preprocessing method suitable for liquid plasma discharge spark image recognition, which solves the problem that the existing threshold segmentation method cannot accurately segment small target discharge sparks in a complex background with high grayscale, uneven image brightness and multi-peak grayscale histogram.
[0005] The technical solution adopted by the present invention is a preprocessing method suitable for liquid plasma discharge spark image recognition, which specifically includes the following steps:
[0006] Step 1: Use an industrial camera to take a picture of the workpiece surface to obtain a spark image to be processed;
[0007] Step 2, graying the spark image obtained in step 1 to obtain a grayscale histogram;
[0008] Step 3, using a background correction method based on a rolling ball algorithm to perform background correction on the grayscaled spark image to be processed in step 2;
[0009] Step 4, the optimal segmentation threshold is obtained based on the automatic threshold segmentation method of gray mean and gray standard deviation, and the sparks and background in the spark image processed in step 3 are segmented to obtain the target spark image.
[0010] The present invention is also characterized in that:
[0011] The specific process of step 2 is:
[0012] The color of the pixel points in the spark image obtained in step 1 is converted into grayscale using the weighted average method. The formula is as follows:
[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; R (x,y),I G (x,y),I B (x, y) represents 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:
[0016] Step 3.1, using the background correction technology 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 the uneven background pixels in the spark image.
[0018] The specific process of step 3.1 is:
[0019] Step 3.1.1, define a spherical mask with a radius of R. This mask is used to determine the area of each position (i, j) in the image. The formula is as follows:
[0020]
[0021] Where x, y are the horizontal and vertical distances from any other position in the image except 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 of 2R pixels. The horizontally expanded image I PX The size will become (M+4R)×N, and the formula for horizontal expansion is as follows:
[0023]
[0024] Then the image I obtained after horizontal expansion PX Expand vertically, increase the height of 2R pixels, and the image I after vertical expansion P The size 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, the matrix size is equal to 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 in the mask centered at (i, j) to form a set S, which is expressed as:
[0029] S={S1,S2,…,S n}(5)
[0030] Among them, S m represents the mth pixel value in the set, and n is the total number of pixel values in the set;
[0031] Step 3.1.6, sort all pixel values in the set S in 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 as follows:
[0035]
[0036] Step 3.1.8, within the window W(i, j) defined in step 3.1.4, apply the sphere mask defined in step 3.1.1, only consider the pixels with mask value 1, set the median of these pixels as the value of position (i, j) in the image, put them into the local background matrix Q, and obtain the uneven background C with a size of M×N, so as to realize the extraction of the uneven background of the spark image. The formula is as follows:
[0037] C(i,j)=median{I P (i,j)mask(i,j)=1}(8).
[0038] The specific process of step 3.2 is:
[0039] Subtract the uneven 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, which can eliminate the uneven background pixels of the spark image. The formula is as follows:
[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 the automatic threshold segmentation method based on the gray mean and gray 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, obtain the optimal segmentation threshold T according to the average gray value All ave and the maximum between-class standard deviation ICV t ;
[0045] Step 4.4, segment the image into a binary image with 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 gray level of the image. The formula is as follows:
[0048] t ∈ {0, 1, 2,..., 255} (10)
[0049] 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;
[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 gray 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, use the threshold segmentation algorithm based on the inter-class standard deviation to calculate the inter-class standard deviation ICV under the current threshold t:
[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 There is the following linear relationship with the optimal segmentation threshold T:
[0058] T=All ave +k n *ICV t (13).
[0059] The specific process of step 4.4 is: Use the optimal segmentation threshold T to segment the image into a binary image:
[0060] T=T[i,j,p(i,j),f(i,j)](14)
[0061] Among them, i, j represent the horizontal and vertical coordinates of the pixel, p(i, j) represents the local characteristics of the pixel, f(i, j) represents the pixel gray value, and the image after thresholding is a binary image, which is defined as:
[0062]
[0063] The beneficial effect of the present invention is that, in view of the relatively small target area of the discharge spark, the large background area, the uneven background brightness of the spark image, the low contrast between the background area and the target area, and the grayscale histogram of the spark sample presenting three peaks or multiple peaks, the present invention first removes most of the background with uneven brightness through a background correction method based on a rolling ball algorithm, thereby improving the contrast between the background area and the target area and converting the grayscale histogram of the spark image from multiple peaks to single peak characteristics. On this basis, an automatic threshold segmentation method based on inter-class standard deviation is proposed, the maximum inter-class standard deviation is calculated, and through the linear relationship between the grayscale mean of the spark image and the maximum inter-class standard deviation, the segmentation threshold is approached to the right edge of the single-mode histogram, thereby achieving a better segmentation effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] Figure 1 It is a flow chart of a preprocessing method applicable to liquid plasma discharge spark image recognition of the present invention;
[0065] Figure 2(a) to Figure 2(c) They are respectively spark images to be processed captured by a camera when the reaction time is 3 min, 8 min, and 16 min in the preprocessing method for liquid phase plasma discharge spark image recognition of the present invention;
[0066] Figure 3(a) to Figure 3(f) It is a grayscale image and a 3D surface map of the spark sample when the reaction time is 3min, 8min and 16min in the preprocessing method for liquid phase plasma discharge spark image recognition of the present invention;
[0067] Figure 4(a) to Figure 4(i) This is a comparison diagram of the effects after background correction in the preprocessing method for liquid plasma discharge spark image recognition according to the present invention;
[0068] Figure 5 This is the under-segmentation effect diagram of Figure 4(a) in the traditional threshold segmentation method based on inter-class variance;
[0069] Figure 6(a) to Figure 6(d) It is a spark image threshold segmentation effect diagram when the k value in the preprocessing method for liquid plasma discharge spark image recognition of the present invention is 0.1, 0.3 and 0.19 calculated by adaptive calculation. DETAILED DESCRIPTION
[0070] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0071] Example 1
[0072] The present invention is applicable to the preprocessing method of liquid plasma discharge spark image recognition, such as Figure 1 As shown, the following steps are included:
[0073] Step 1: Use a JHUM1400s high-resolution color array industrial camera with a resolution of 4383×3288 to take photos of the workpiece surface. Figure 2(a), Figure 2(b), and Figure 2(c) are the spark images to be processed taken by the camera when the response time is 3 minutes, 8 minutes, and 16 minutes, respectively.
[0074] Step 2, graying the spark image obtained in step 1 to obtain a grayscale histogram;
[0075] Step 3, using a background correction method based on a rolling ball algorithm to perform background correction on the grayscaled spark image to be processed in step 2;
[0076] Step 4, the optimal segmentation threshold is obtained based on the automatic threshold segmentation method of grayscale mean and grayscale standard deviation, and the sparks and background of the spark image to be processed after the background correction method based on the rolling ball algorithm is operated are segmented to obtain the target spark image.
[0077] Example 2
[0078] The specific process of step 2 is: convert the color of the pixel points in the spark image obtained in step 1 into grayscale by weighted average method, and the conversion formula is:
[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, I(x, y) represents the grayscale value of the point (x, y), and I R (x,y),I G (x,y),I B (x, y) represents the values of the red, green, and blue components of the pixel at position (x, y), respectively.
[0081] The 3D surface plot 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 usually represents the height information of the point. In the 3D surface plot of a grayscale image, the height information of each pixel can be intuitively seen, such as Figure 3(a) to Figure 3(f) As shown, FIG3(a) is a grayscale image of FIG2(a) after grayscale processing in step 2, and FIG3(d) is a 3D surface image corresponding to FIG3(a); similarly, FIG3(b) and FIG3(c) are grayscale images of FIG2(b) and FIG2(c) after grayscale processing in step 2, respectively, and FIG3(e) and FIG3(f) are 3D surface images corresponding to FIG3(b) and FIG3(c);
[0082] Specifically, due to the uneven brightness of the spark image to be processed, the use of traditional image segmentation will cause the background to be extracted as sparks in areas with too high brightness, while the sparks cannot be extracted in areas with too low brightness. Therefore, the brightness of the spark image needs to be uniform. In addition, the proportion of these low-grayscale pixels reflecting the background area in the image is too large, which not only reduces the average grayscale value of the spark image, but also increases the contrast of the spark image, affecting the determination of the optimal threshold. By eliminating these background pixels, the multi-peak image multi-threshold segmentation problem is converted into a single-peak image single-threshold segmentation problem, making the Otsu method suitable for the segmentation problem of small target discharge spark images.
[0083] Example 3
[0084] The specific process of step 3 is:
[0085] Step 3.1, using the background correction technology based on the rolling ball algorithm to estimate the background of the spark image;
[0086] Step 3.1.1, define a spherical mask with a radius of R. In the experiment, R is 20. This mask is used to determine the area of each position (i, j) in the image. The formula is as follows:
[0087]
[0088] Wherein, x, y are the horizontal coordinate distance and vertical coordinate distance from any other position in the image except the position (i, j) to the position (i, j).
[0089] Step 3.1.2, expand the image boundary, define the image to be processed after grayscale in step 2 as I (I can be regarded as a two-dimensional array), the size is M×N, in the experiment M=175, N=192. First, expand the image horizontally, increase the width of 2R pixels, then the image I after horizontal expansion PX The size will become (M+4R)×N, that is, 255×192, and the formula for horizontal expansion is as follows:
[0090]
[0091] Then the image I obtained after horizontal expansion PX Expand vertically and increase the height by 2R pixels. Then the vertically expanded image I P The size will become (M+4R)×(N+4R), that is, 255×272. The formula for vertical expansion is as follows:
[0092]
[0093] Step 3.1.3, create a local background matrix Q, the matrix size is equal to the original image I defined in step 3.1.2, the value in this matrix is zero, which is equivalent to a background with no pixels and the size of 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 in the mask centered at (i, j) to form a set S. S can be expressed as:
[0096] S={S1,S2,…,S n}(5)
[0097] Among them, S m represents the mth pixel value in the set, and n is the total number of pixel values in the set.
[0098] Step 3.1.6, sort all pixel values in the set S in 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 as follows:
[0102]
[0103] Step 3.1.8, in the window W(i, j) defined in step 3.1.4, apply the sphere mask defined in step 3.1.1, only consider the pixels with mask value 1, set the median of these pixels as the value of position (i, j) in the image, put them into the local background matrix Q, and get the uneven background C with a size of M×N. The mathematical formula for extracting the uneven 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 uneven 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 spark image is eliminated with the formula as follows:
[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 area and the target area, and converts the grayscale histogram of the spark image from multi-peak to single-peak characteristics. The 3D surface map and grayscale histogram of the original image, local background image and corrected image are shown in Figure 2. Figure 4(a) to Figure 4(i) As shown in the figure, a spark image with uneven illumination and bubble interference is selected. Figure 4(a), Figure 4(b), and Figure 4(c) are the original grayscale image, the uneven background grayscale image, and the corrected grayscale image, respectively, which reflect the process of the background correction method; Figure 4(d), Figure 4(e), and Figure 4(f) are the 3D surface images corresponding to Figure 4(a), Figure 4(b), and Figure 4(c), respectively, which can intuitively show the process of the background correction method removing redundant background pixels; Figure 4(g), Figure 4(h), and Figure 4(i) are the grayscale histograms corresponding to Figure 4(a), Figure 4(b), and Figure 4(c), respectively, which can intuitively show that the background correction method overcomes the deficiency that the image segmentation method directly using the maximum inter-class variance method (Otsu) cannot accurately segment images with uneven brightness backgrounds.
[0109] Specifically, after the background correction method is used, the grayscale histogram of the spark image changes from multi-peak to single-peak characteristics, which meets the requirement that the image grayscale histogram should show obvious bimodal or single-peak characteristics when using the Otsu method to obtain a single threshold. However, since the target area of the spark is relatively small, the contrast between the background area and the target area is low, and the grayscale values of the pixels in the background area overlap with the grayscale values of the pixels in the target area, even if the contrast between the background area and the target area is effectively improved by the background correction method, the segmentation effect of the Otsu method is improved to a certain extent, but there is still a problem that the optimal threshold is slightly lower than the ideal threshold, resulting in under-segmentation, such as Figure 5 In view of the above problems, the present invention proposes an automatic threshold segmentation method based on inter-class standard deviation.
[0110] Example 5
[0111] Step 4.1, the optimal segmentation threshold k is obtained by the automatic threshold segmentation method based on the 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, the formula is as follows:
[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 the inter-class standard deviation to calculate the inter-class standard deviation ICV under the current threshold t:
[0121]
[0122] Step 4.1.7, compare the current inter-class standard deviation ICV with the previous maximum inter-class standard deviation ICV t :
[0123] If ICV > ICV t , then update ICV tAnd record the current threshold t as the optimal threshold k. The optimal threshold k is calculated in the experiment to be 48.64, where the total gray value H of the intermediate variable A part corresponding to the optimal threshold k in this experiment is A =713.42, the total number of pixels in part A is N A =30999, the total gray value of part B is H B =946.07, the total number of pixels in part B is N B =2601, average gray value A ave and B ave The pixel ratios of part A and part B are 5.87 and 92.75 respectively. A and P B They are 0.923 and 0.077 respectively, and the average grayscale value of image F is ave The maximum inter-class standard deviation ICV is 12.59. t 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] In processing and segmenting the background area and the target spark area, two different grayscale distribution areas, considering the grayscale mean and grayscale standard deviation of the image is a feasible method. The grayscale value of the target spark area is to the right of the mean in the histogram, and the grayscale value of the background area is to the left of the mean. The mean can be considered as a reference standard for extracting the target spark. According to the characteristics of the spark image, the average grayscale value of the target spark must be greater than the mean, but the specific deviation from the mean depends on the contrast between the foreground and background of the spark image, that is, the standard deviation.
[0128] The present invention uses the inter-class standard deviation to reflect the uniformity of the grayscale distribution of the spark image. The larger the inter-class standard deviation between the background and the target, the larger the distance between the two parts of the image, the more the target and the background are segmented, and the better the segmentation effect. Therefore, the segmentation with the largest inter-class standard deviation means the smallest probability of misclassification. In the process of threshold segmentation of the difference grayscale image, after a large number of repeated experiments and observations and analysis, it is found that the average grayscale value of the difference grayscale image is ave , maximum inter-class standard deviation ICV t There is a certain linear relationship with the selection of the optimal segmentation threshold T.
[0129] Step 4.3, average gray value All ave , maximum inter-class standard deviation ICVt There is the following linear relationship with the optimal segmentation threshold T:
[0130] T=All ave +k n *ICV t (14)
[0131] Step 4.4, k n The value is 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 and 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, which is defined as:
[0134]
[0135] The pixels represented by 0 are the target sparks, and then the target spark features are extracted. n The effect of threshold segmentation of the value is shown in the figure Figure 6(a) to Figure 6(d) As shown, Figure 6(a) is the original grayscale image of Figure 4(a), and Figure 6(b) is the k n The spark image threshold segmentation effect with a value of 0.1. Figure 6(c) is the k n The spark image threshold segmentation effect with a value of 0.3. Figure 6(d) is the k n The spark image threshold segmentation effect diagram with the adaptively calculated value of 0.19. By comparison, it can be seen that the k value adaptively calculated by the automatic threshold segmentation method based on the inter-class standard deviation is n =0.19 segmentation image can get better segmentation effect.
[0136] Through the above methods, the present invention aims at the case where the target area of the discharge spark is relatively small, the background area is large, the contrast between the background area and the target area is low, and the grayscale histogram of the spark sample presents three peaks or multiple peaks. First, most of the uneven background is removed by background correction, the contrast between the background area and the target area is improved, and the grayscale histogram of the spark image is converted from multi-peak to single-peak characteristics. On this basis, an automatic threshold segmentation method based on the inter-class standard deviation is proposed to obtain the maximum inter-class standard deviation, and through the linear relationship between the grayscale mean of the spark image and the maximum inter-class standard deviation, the optimal segmentation threshold is close to the right edge of the single-mode histogram to achieve a better segmentation effect. The accuracy of identifying the reaction state of plasma electrolytic oxidation is improved, which is more conducive to accurately adjusting the reaction process.
Claims
1. A preprocessing method for liquid plasma discharge spark image recognition, characterized in that: The specific steps include: Step 1: Use an industrial camera to take a picture of the workpiece surface to obtain a spark image to be processed; Step 2, graying the spark image obtained in step 1 to obtain a grayscale histogram; Step 3, using a background correction method based on a rolling ball algorithm to perform background correction on the grayscaled 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 sparks and background in the spark image processed in step 3 are segmented to obtain the target spark image.
2. The preprocessing method for liquid plasma discharge spark image recognition according to claim 1, characterized in that: The specific process of step 2 is: The color of the pixel points in the spark image obtained in step 1 is converted into grayscale using the weighted average method. The formula is as follows: I(x,y)=0.3I R (x,y)+0.59I G (x,y)+0.11I B (x,y) (1) Where x represents the vertical position of the pixel in the image, y represents the horizontal position of the pixel in the image; I(x, y) represents the grayscale value of the point (x, y), and I R (x,y),I G (x,y),I B (x, y) represents the values of the red, green, and blue components of the pixel at position (x, y), respectively.
3. The preprocessing method for liquid plasma discharge spark image recognition according to claim 2, characterized in that: The specific process of step 3 is as follows: Step 3.1, using the background correction technology based on the rolling ball algorithm to estimate the background of the spark image; Step 3.2, obtain the corrected image F based on the background estimation result obtained in step 3.1, and remove the uneven background pixels in the spark image.
4. The preprocessing method for liquid plasma discharge spark image recognition according to claim 3, characterized in that: The specific process of step 3.1 is as follows: Step 3.1.1, define a spherical mask with a radius of R. This mask is used to determine the area of each position (i, j) in the image. The formula is as follows: Where x, y are the horizontal and vertical distances from any other position in the image except position (i, j) to position (i, j); 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 of 2R pixels. The horizontally expanded image I PX The size will become (M+4R)×N, and the formula for horizontal expansion is as follows: Then the image I obtained after horizontal expansion PX Expand vertically, increase the height of 2R pixels, and the image I after vertical expansion P The size will become (M+4R)×(N+4R), and the formula for vertical expansion is as follows: Step 3.1.3, create a local background matrix Q, the matrix size is equal to the original image I defined in step 3.1.2; 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); Step 3.1.5, extract all pixel values in the mask centered at (i, j) to form a set S, which is expressed as: S={S1,S2,…,S n } (5) Among them, S m represents the mth pixel value in the set, and n is the total number of pixel values in the set; Step 3.1.6, sort all pixel values in the set S in step 3.1.5 in descending order to obtain a new set in, Step 3.1.7, calculate the set in step 3.1.6 The median value is calculated as follows: Step 3.1.8, within the window W(i, j) defined in step 3.1.4, apply the sphere mask defined in step 3.1.1, only consider the pixels with mask value 1, set the median of these pixels as the value of position (i, j) in the image, put them into the local background matrix Q, and obtain the uneven background C with a size of M×N, so as to realize the extraction of the uneven background of the spark image. The formula is as follows: C(i,j)=median{I P (i,j)|mask(i,j)=1} (8)。 5. The preprocessing method for liquid plasma discharge spark image recognition according to claim 4, characterized in that: The specific process of step 3.2 is as follows: Subtract the uneven 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, which can eliminate the uneven background pixels of the spark image. The formula is as follows: F(i,j)=I(i,j)-C(i,j) (9).
6. The preprocessing method for liquid plasma discharge spark image recognition according to claim 4, characterized in that: The specific process of step 4 is as follows: Step 4.1, the optimal segmentation threshold k is obtained by the automatic threshold segmentation method based on the grayscale mean and grayscale standard deviation; Step 4.2: Normalize the optimal threshold k obtained in step 4.1 to obtain the normalized optimal threshold k n : Step 4.3, according to the average gray value All ave and the maximum inter-class standard deviation ICV t Find the optimal segmentation threshold T; Step 4.4, use the optimal segmentation threshold T to segment the image into a binary image.
7. The preprocessing method for liquid plasma discharge spark image recognition according to claim 6, characterized in that: The specific process of step 4.1 is as follows: Step 4.1.1, initialize the threshold variable t, and traverse each gray level of the image. The formula is as follows: t∈{0,1,2,…,255} (10) 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 of part A H A = 0, the total number of pixels in part A is N A = 0, the total gray value of part B is H B = 0, the total number of pixels in part B is N B =0; 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, i.e., 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, i.e., F(i, j) ≥ t, then N B = N B + 1, H B = H B + F(i, j); Step 4.1.4, calculate the pixel ratio P of part A and part B A and P B , and the average gray value A ave and B ave ; 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: Step 4.1.6, use the threshold segmentation algorithm based on the inter-class standard deviation to calculate the inter-class standard deviation ICV under the current threshold t: 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.
8. The preprocessing method for liquid plasma discharge spark image recognition according to claim 7, characterized in that: In step 4.3, the average gray value All ave , maximum inter-class standard deviation ICV t There is the following linear relationship with the optimal segmentation threshold T: T=All ave +k n *ICV t (13)。 9. The preprocessing method for liquid plasma discharge spark image recognition according to claim 7, characterized in that: The specific process of step 4.4 is: using the optimal segmentation threshold T to segment the image into a binary image: T=T[i,j,p(i,j),f(i,j)] (14) Among them, i, j represent the horizontal and vertical coordinates of the pixel, p(i, j) represents the local characteristics of the pixel, f(i, j) represents the gray value of the pixel, and the image after thresholding is a binary image, which is defined as:
Citation Information
Patent Citations
Self-adaption image binaryzation method based on residual image histogram cyclic shift
CN106204617A
Fast noise-containing image two-dimensional maximum between-class variance threshold value method
CN106709928A
System and method for removing background of three-dimensional image of biological tissue
CN107590798A
Intelligent electric meter chip image binarization processing method based on adaptive mixed threshold
CN111986222A
Self-adaptive threshold segmentation method for grayscale image
CN113129326A