Disclosure of Invention
The invention aims to provide a plasma electrolytic oxidation reaction state identification method based on image processing, which solves the problem that the number of discharge sparks cannot be accurately obtained in the prior art.
The technical scheme adopted by the invention is that the method for identifying the plasma electrolytic oxidation reaction state based on image processing comprises the following steps:
step 1, acquiring a spark image to be processed, and obtaining the area S of the surface of a workpiece;
step2, graying the spark image to be processed;
step 3, dividing sparks and backgrounds of the grey-scale spark image to be processed to obtain a target spark image;
Step 4, performing morphological processing on the target spark image to obtain mutually separated spark targets;
Step 5, extracting edge characteristics of each spark target in the target spark image;
And 6, communicating the edge features by adopting a communicating domain method to obtain the total number of sparks, dividing the total number of sparks by the area S of the surface of the workpiece to obtain the number of sparks in unit area, and identifying the plasma electrolytic oxidation reaction state at the current moment according to the number of sparks in unit area.
The invention is also characterized in that:
The specific process of the step2 is that the color of the pixel point in the spark image to be processed is converted into gray scale by a weighted average method.
The specific process of the step 3 is that firstly, a gray value M of a spark image to be processed after graying is taken, a gray value T is arbitrarily selected to divide a gray histogram of the image into a front part A and a rear part B, the average value of the two parts A and B is MA and MB, the proportion of the pixel number of the part A to the total pixel number is marked as PA, the proportion of the pixel number of the part B to the total pixel number is marked as PB, the maximum inter-class variance is calculated and is used as a gray threshold T, and then the gray threshold T is used for dividing the image into a binary image, so that a target spark image is obtained.
The specific process of the step 4 is that the target spark image is firstly corroded and then expanded to obtain spark targets separated from each other.
The step 5 specifically comprises the following steps:
step 5.1, convolving the target spark image by using a Gaussian filter to obtain a filtered pixel point e;
Step 5.2, convolving a 3x3 window in the target spark image with a Sobel operator by using a pair of convolution arrays S x,Sy to obtain gradient values of the pixel point e in x and y directions as G X and G y respectively, and then calculating gradient strength G and gradient direction theta of the pixel point e;
step 5.3, performing non-maximum suppression on the gradient amplitude according to the gradient direction to obtain edge points;
and 5.4, processing the edge points by using the high and low thresholds to obtain the edge characteristics of each spark target.
The specific process of the step 5.3 is that the gradient direction is divided into E, NE, N, NW, W, SW, S, SE, wherein 0 represents 0-45 degrees, 1 represents 45-90 degrees, 2 represents-90-45 degrees, 3 represents-45-0 degrees, the gradient direction of a pixel point P is theta, gradient linear interpolation G P1 and G p2 of the pixel points P1 and P2 are obtained, the gradient intensity G of the current pixel is compared with a pixel G P1、Gp2 along the positive and negative gradient directions, the pixel point smaller than the pixel G P1、Gp2 is restrained, and the pixel point larger than the pixel G P1、Gp2 is taken as an edge point;
And 6, connecting eight connected areas, traversing the image statistics to obtain 1 spark point, expanding the eight neighborhood of the spark point to search the area, counting +1 when the searched area is not expanding, continuously searching the next new point, and repeating the operation until the whole image is searched to obtain the total number of sparks.
The method for identifying the plasma electrolytic oxidation reaction state based on the image processing has the advantages that the number of sparks in unit area generated on the surface of a sample at a certain moment is accurately detected through an image processing technology to identify the reaction state of the plasma electrolytic oxidation at the moment, the reaction process is further accurately controlled according to the evolution of the sparks, the accuracy of identifying the reaction state of the plasma electrolytic oxidation is improved, and the accurate adjustment of the reaction process is facilitated.
Detailed Description
The invention will be described in detail below with reference to the drawings and the detailed description.
The method for identifying the plasma electrolytic oxidation reaction state based on image processing, as shown in fig. 1, comprises the following steps:
step 1, photographing and imaging the surface of a workpiece by adopting high-resolution photographing equipment, as shown in fig. 2, to obtain a spark image to be processed and the area S of the surface of the workpiece;
step2, graying the spark image to be processed;
specifically, the color of a pixel point in a spark image to be processed is converted into gray scale by a weighted average method, and the conversion formula is as follows:
I(x,y)=0.3*I_R(x,y)+0.59*I_G(x,y)+0.11*I_B(x,y) (1);
In the above equation, 0.3,0.59,0.11 is the weighting coefficient adjusted by the human brightness sensing system. Converting an RGB color image into a gray scale image is accomplished by eliminating image hue and saturation information while preserving brightness.
Step 3, dividing the sparks and the background of the grey-scale spark image to be processed to obtain a target spark image, as shown in fig. 3;
Specifically, firstly, taking a gray value mean value M of a gray image to be processed, arbitrarily selecting a gray value T to divide a gray histogram of the image into a front part A and a rear part B, wherein the average value of the two parts A and B is MA and MB respectively, the proportion of the pixel number of the part A to the total pixel number is marked as PA, the proportion of the pixel number of the part B to the total pixel number is marked as PB, the maximum inter-class variance is calculated and is used as a gray threshold value T, and the maximum inter-class variance is defined as:
ICV=PAα*(MA-M)2+PBα*(MB-M)2 (2);
In the above equation, α is 0.8, and the threshold t=icv is 200.
The image is then segmented into binarized images with a gray threshold T:
T=T[x,y,p(x,y),f(x,y)] (3);
In the above formula, x, y represents the abscissa of the pixel, p (x, y) represents the local characteristic of the pixel, f (x, y) represents the gray value of the pixel, and the thresholded image is a binary image defined as:
The pixel indicated by 0 is the target spark and the target spark image is obtained.
Step 4, performing morphological processing on the target spark images to obtain mutually separated target spark images;
Specifically, in the plasma electrolytic oxidation process, the spark causes the problem of adhesion of the spark in the image due to arc mapping, and the accuracy of counting is affected. And performing corrosion operation on the target spark image, and then expanding to obtain spark targets separated from each other. The processing method plays roles of smoothing the target outline, breaking the narrow connecting part and removing the tiny bulges, so that each target spark is in a mutually separated state, the counting error is effectively reduced, and the subsequent processing is convenient, as shown in fig. 4.
Step 5, extracting edge characteristics of each spark target in the target spark image;
Step 5.1 in order to reduce as much as possible the effect of noise present in the spark image on the spark edge detection result, the noise must be filtered out to prevent false detection caused by the noise. To smooth the image, a gaussian filter is used to convolve the image to reduce the apparent noise effects on the edge detector. Specifically, a Gaussian filter is used for convolving the target spark image to obtain a filtered pixel point e;
In this embodiment, a gaussian filter kernel of (2k+1) x (2k+1) is used, and the equation is:
in the above formula, i and j are the row and column of the gaussian convolution kernel matrix, σ is the variance, k determines the dimension of the kernel matrix, and the gaussian convolution kernel with the dimension of 3x3 (k=1) is taken as:
let a 3x3 window in the target spark image be a, and the pixel point to be filtered be e, after gaussian filtering, the brightness value of the pixel point e is:
Where, is a convolution symbol, sum represents the sum of all elements in the matrix, h is the coefficient of the gaussian convolution kernel matrix, and a-i is the coefficient of window a.
Step 5.2, convolving a 3x3 window in the target spark image with a Sobel operator by using a pair of convolution arrays S x,Sy, where the convolution array S x,Sy is:
In the above formula, S x represents a Sobel operator in the x direction for detecting an edge in the y direction, and S y represents a Sobel operator in the y direction for detecting an edge in the x direction;
The gradient values of the pixel point e in the x and y directions obtained after convolution are G X and G y respectively:
In the above formula, the symbols are convolution symbols, and sum represents the sum of all elements in the matrix;
then calculating the gradient strength G and gradient direction theta of the pixel point e;
step 5.3, performing non-maximum suppression on the gradient amplitude according to the gradient direction to obtain edge points;
Specifically, the gradient direction is divided into E, NE, N, NW, W, SW, S, SE, wherein 0 represents 0-45 degrees, 1 represents 45-90 degrees, 2 represents-90-45 degrees, 3 represents-45-0 degrees, the gradient direction of the pixel point P is theta, gradient linear interpolation G P1 and G p2 of the pixel points P1 and P2 are obtained,
tanθ=Gy/Gx (14);
GP1=(1-tan(θ))*E+tan(θ)*NE (15);
GP2=(1-tan(θ))*W+tan(θ)*SW (16);
Comparing the gradient intensity G of the current pixel with the pixel G P1、Gp2 along the positive and negative gradient directions, suppressing the pixel point smaller than the pixel G P1、Gp2, and taking the pixel point larger than the pixel G P1、Gp2 as an edge point;
And 5.4, processing the edge points by using the high and low thresholds to obtain the edge characteristics of each spark target. Specifically, the edge pixels are filtered with weak gradient intensity, and the edge pixels with high gradient intensity are reserved to solve the spurious response, wherein the high-low threshold ratio of 2:1 is taken to obtain the edge characteristic of each spark target, as shown in fig. 5.
And 6, communicating the edge features by adopting a communicating domain method to obtain the total number of sparks, dividing the total number of sparks by the area S of the surface of the workpiece to obtain the number of sparks in unit area, and identifying the plasma electrolytic oxidation reaction state at the current moment according to the number of sparks in unit area, so that the evolution state of the plasma electrolytic oxidation is accurately known, and a basis is provided for further accurate control of the reaction process.
Specifically, the values after the binarization process are only 0 and 1, and the spark edge clearly appears. The pixel denoted by 0 represents the spark edge to be counted, and the adjacent pixel denoted by 0 assumes a connected state. Connecting the eight connected areas of the pixel represented by 0, namely, the upper, lower, left, right, upper left, upper right, lower left and lower right, traversing the image statistics to obtain 1 spark point, expanding the eight neighborhood of the spark point to search the area, when the searched area is not expanding, indicating that the area is searched completely, counting +1, continuously searching for the next new point, repeating the operation until the whole image is searched, and obtaining the total number of sparks as shown in fig. 6.
According to the method for identifying the plasma electrolytic oxidation reaction state based on image processing, the number of sparks in unit area generated on the surface of the sample at a certain moment is accurately detected through an image processing technology, so that the reaction state of the plasma electrolytic oxidation at the moment is identified, the reaction process is further accurately controlled according to the evolution of the sparks, the accuracy of identifying the reaction state of the plasma electrolytic oxidation is improved, and the accurate adjustment of the reaction process is facilitated.