Image-based support vector machine detection method and system for part surface roughness
The support vector machine detection method divides and image acquisition of the part surface, extracts features that can effectively characterize roughness, solves the problems of random sampling and inaccurate feature extraction in the prior art, and realizes high-precision non-contact detection of the surface roughness of the part.
Patent Information
- Application Number
- CN202111262722.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-28
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2041-10-28
AI Technical Summary
The existing image-based part surface roughness detection method has random sampling, and the entire part surface cannot be fully collected, and the extracted features cannot effectively characterize the roughness, affecting the detection accuracy.
The support vector machine detection method is used to automatically divide the part surface into multiple areas of appropriate size, and the part surface images are comprehensively collected from multiple areas and extracted features that can effectively characterize the surface roughness of the part.
It realizes comprehensive non-contact detection of part surface roughness, improves detection accuracy, and avoids the problems of random sampling and inaccurate feature extraction.
Smart Images

Figure CN113989233B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of detection technology, and in particular relates to a method and system for detecting surface roughness of a part based on image technology using a support vector machine. Background Art
[0002] Part surface roughness is one of the important indicators for evaluating part surface quality in modern mechanical manufacturing. Image technology has the advantages of large amount of information, non-contact, and low cost, and has obvious non-contact detection effect on part surface roughness. The existing image-based roughness detection methods are randomly sampled and cannot fully capture the entire part surface, and the extracted part surface features cannot effectively characterize the roughness. These problems will greatly affect the detection accuracy of the roughness, and thus have a significant impact on the assembly performance, wear resistance, and fatigue resistance of precision parts. Therefore, it is necessary to design a part surface roughness detection model based on image technology to achieve comprehensive non-contact detection of roughness. Summary of the invention
[0003] In view of the above situation, the purpose of the present invention is to provide an image-based part surface roughness support vector machine detection method and system, which can automatically divide the part surface into multiple areas of appropriate size, continuously and comprehensively collect part surface images in multiple areas and extract features that can effectively characterize the part surface roughness, thereby completing the roughness detection, avoiding the problem of random sampling and the inability of the extracted features to effectively characterize the part surface roughness.
[0004] A method for detecting surface roughness of a part based on an image using a support vector machine comprises the following steps:
[0005] S1 divides the surface of the part into appropriate areas using the part surface division method, and collects images of each area on the surface of the part through the part surface image acquisition system;
[0006] S2 performs image preprocessing on the part image; converts the part surface image into a grayscale image using the pixel component ratio addition method, and performs filtering using a Gaussian window;
[0007] S3 extracts four texture features of the image, namely energy, entropy, moment of inertia, and correlation, based on the gray-level co-occurrence matrix, and calculates their mean and variance to generate an 8-dimensional feature vector as the input of the support vector machine;
[0008] The S4 support vector machine detection model outputs the roughness value, and the part surface roughness value detection results are displayed through the host computer interface.
[0009] In the detection method, in step S1, the method for dividing the part surface is as follows: the part is evenly divided into multiple areas. When the area of the divided area is smaller than the visible area of the digital microscope, the division is considered to be effective and can be used for roughness detection; when the area of the divided area exceeds the visible area of the digital microscope, the area exceeding the visible area of the digital microscope is divided twice, and is still evenly divided into multiple areas for detection to ensure that the secondary divided area is smaller than the visible area of the digital microscope. If the division is still invalid, a third division is performed, and so on, until the areas of all divided areas are smaller than the visible area of the digital microscope.
[0010] In the detection method, in step S1, collecting images of various regions on the surface of the part includes the following steps:
[0011] S11, placing the parts at the sampling point of the horizontal tray, the host computer sends an image start acquisition signal, the single chip microcomputer receives the signal, outputs a PWM wave, and the stepper motor drives the horizontal tray and the parts on it to rotate to the divided area;
[0012] S12, the single chip computer suspends PWM wave output and sends an image acquisition signal to the upper computer;
[0013] S13, the host computer receives the image acquisition signal, controls the digital microscope to acquire the part image and saves it to the host computer, and then sends the image acquisition completion signal to the single-chip microcomputer through the serial port;
[0014] S14, the single chip microcomputer receives the image acquisition completion signal, continues to output PWM waves to drive the stepper motor, and repeats steps S11, S12, and S13 until all the areas divided by the parts are acquired.
[0015] In the detection method, in step S2, a Gaussian filter operation is performed on the grayscale image of the part surface using a Gaussian window with a dimension of 3×3 and a standard deviation of 0.8.
[0016] The detection method, the specific method of S3 is: extracting the surface texture features of the part, and establishing a relationship model between the surface texture features of the part and the surface roughness of the part;
[0017] By analyzing the probability of the simultaneous appearance of a pixel with grayscale i at point (x, y) and a pixel with grayscale j at point (x+a, y+b) in the part surface image, a probability matrix P(i, j) is constructed, and its formula is:
[0018] Probability Matrix
[0019] Where, i = 1, 2, ..., M; j = 1, 2, ..., N; f(x, y) and f(x+a, y+b) represent the grayscale values of the pixels (x, y) and (x+a, y+b) in the part surface image;
[0020] Based on the gray-level co-occurrence matrix, the following features are extracted: energy, entropy, moment of inertia, and correlation. The calculation process is as follows:
[0021] energy
[0022] entropy
[0023] Moment of inertia
[0024] Relevance
[0025] Where: M and N are the number of pixels in the horizontal and vertical directions of the part surface image, respectively; μ is the mean value of the pixels in the part surface image; x' and y' represent the gradients in the horizontal and vertical directions of the part surface image, respectively; l represents the gray level of the pixel in the part surface image; L represents the maximum gray level, L = 255; P(l) is the percentage of pixels with gray level l in the part surface image.
[0026] Generate eigenvectors and calculate W respectively A , W B , W C , W D The mean value W A1 , W B1 , W C1 , W D1 and variance W A2 , W B2 , W C2 , W D2 As features to describe the surface texture of parts, these eight features are used to generate an 8-dimensional feature vector as the input of the support vector machine.
[0027] The detection method, the specific method of S4 is:
[0028] S41. The output value of the roughness detection model based on the support vector machine can be expressed as a nonlinear regression model as shown below:
[0029] Nonlinear regression model Ra 模型 =w T x+b (8)
[0030] Where Ra 模型 is the surface roughness of the part output by the support vector machine detection model, w is the linear combination of the part surface image feature vector input extracted based on the gray level co-occurrence matrix; b is the function bias.
[0031] S42, the kernel function of the support vector machine detection model uses the Gaussian kernel function. According to the input part surface feature vector, the penalty parameter C = 0.1 and the width parameter σ = 0.8 are set. Through the training and verification of the model, the root mean square error of the support vector machine roughness detection based on the Gaussian kernel function is 0.0316, the average relative error is 0.0296, the detection accuracy is high, and the running time is suitable.
[0032] S44. The extracted part surface texture feature vector is used as the input of a support vector machine detection model, and the output of the model is the part surface roughness value.
[0033] The detection method, the process of the pixel component comparison method is as follows:
[0034] (1) Based on the acquired image, the pixel point X is calibrated at equal distances along the direction perpendicular to the image texture, and the red (R), green (G), and blue (B) components of the pixel value at the point are obtained;
[0035] (2) Compare the pixel components B and R, B and G, and add them together, and use the normalized value as the new pixel value of the point. The formula is as follows:
[0036] Pixel component ratio addition
[0037] Among them, R(i,j), B(i,j), and G(i,j) are the R, G, and B component values of the pixel point with coordinates (i,j) in the part surface image.
[0038] A support vector machine detection system for part surface roughness according to any of the detection methods, characterized in that it comprises:
[0039] Part surface image acquisition device: using the part surface division method to divide the part surface into appropriate areas, and collect images of each area on the part surface;
[0040] Image preprocessing module: Use the pixel component ratio addition method to convert the part surface image into a grayscale image, and use the Gaussian window for filtering;
[0041] Texture feature extraction module: extracts four texture features of the image, namely energy, entropy, moment of inertia, and correlation, based on the gray-level co-occurrence matrix, and calculates their mean and variance to generate an 8-dimensional feature vector as the input of the support vector machine;
[0042] Support vector machine detection module: The support vector machine detection module outputs the roughness value and displays the part surface roughness value detection result through the host computer interface.
[0043] The detection system, the texture feature extraction module: extracts the surface texture features of the part, and establishes a relationship model between the surface texture features of the part and the surface roughness of the part;
[0044] By analyzing the probability of the simultaneous appearance of a pixel with grayscale i at point (x, y) and a pixel with grayscale j at point (x+a, y+b) in the part surface image, a probability matrix P(i, j) is constructed, and its formula is:
[0045] Probability Matrix
[0046] Where, i = 1, 2, ..., M; j = 1, 2, ..., N; f(x, y) and f(x+a, y+b) represent the grayscale values of the pixels (x, y) and (x+a, y+b) in the part surface image;
[0047] Based on the gray-level co-occurrence matrix, the following features are extracted: energy, entropy, moment of inertia, and correlation. The calculation process is as follows:
[0048] energy
[0049] entropy
[0050] Moment of inertia
[0051] Relevance
[0052] Where: M and N are the number of pixels in the horizontal and vertical directions of the part surface image, respectively; μ is the mean value of the pixels in the part surface image; x' and y' represent the gradients in the horizontal and vertical directions of the part surface image, respectively; l represents the gray level of the pixel in the part surface image; L represents the maximum gray level, L = 255; P(l) is the percentage of pixels with gray level l in the part surface image.
[0053] Generate eigenvectors and calculate W respectively A , W B , W C , W D The mean value W A1 , W B1 , W C1 , W D1 and variance W A2 , W B2 , W C2 , W D2 As features to describe the surface texture of parts, these eight features are used to generate an 8-dimensional feature vector as the input of the support vector machine.
[0054] In the detection system, the image preprocessing module includes a pixel component comparison unit, and the method of the pixel component comparison unit is as follows:
[0055] (1) Based on the acquired image, the pixel point X is calibrated at equal distances along the direction perpendicular to the image texture, and the red (R), green (G), and blue (B) components of the pixel value at the point are obtained;
[0056] (2) Compare the pixel components B and R, B and G, and add them together, and use the normalized value as the new pixel value of the point. The formula is as follows:
[0057] Pixel component ratio addition
[0058] Among them, R(i,j), B(i,j), and G(i,j) are the R, G, and B component values of the pixel point with coordinates (i,j) in the part surface image.
[0059] The beneficial effects of the present invention are as follows: the surface roughness of parts can be measured comprehensively and non-contactly, which solves the problems of random sampling in the process of extracting image features and the inability of the extracted features to effectively distinguish parts with different roughness grades, and greatly improves the detection accuracy of non-contact detection of the surface roughness of parts. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 A flow chart of the entire process of part surface roughness detection provided by an embodiment of the present invention;
[0061] Figure 2 A schematic diagram of dividing the sampling area of a part surface provided by an embodiment of the present invention;
[0062] Figure 3 A pixel component calibration map provided by an embodiment of the present invention;
[0063] Figure 4 Comparison diagram of the original image provided by the embodiment of the present invention and the images obtained by using different grayscale methods; (a1) Ra = 0.4μm original image, (a2) Ra = 0.4μm weighted average method, (a3) Ra = 0.4μm pixel component ratio addition method; (b1) Ra = 0.8μm original image, (b2) Ra = 0.8μm weighted average method, (b3) Ra = 0.8μm pixel component ratio addition method; (c1) Ra = 1.6μm original image, (c2) Ra = 1.6μm weighted average method, (c3) Ra = 1.6μm pixel component ratio addition method;
[0064] Figure 5 A comparison of grayscale image quality obtained by four grayscale methods provided in an embodiment of the present invention; (a) comparison of standard deviations of different grayscale methods; (b) comparison of average gradients of different grayscale methods; (c) comparison of information entropy of different grayscale methods;
[0065] Figure 6 A comparison chart of filtering effects of three filtering methods provided in an embodiment of the present invention;
[0066] Figure 7 A comparison chart of the actual values and the detected values of the roughness of 16 acquisition areas on the surface of a set of test sample parts provided by an embodiment of the present invention;
[0067] Figure 8 The percentage of images with relative errors lower than the threshold in each area of the roughness detection part surface divided by different modeling methods provided in the embodiments of the present invention;
[0068] Fig. 9 A flow chart of part surface image acquisition provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0069] The present invention is described in detail below in conjunction with specific embodiments.
[0070] like Figure 1 The figure shows the complete steps of part surface roughness detection. The image acquisition module is used to collect images of various areas on the part surface. The image processing module is used to grayscale, filter and extract features on the image. The obtained feature vector is then input into the roughness detection module to obtain the surface roughness value of the part.
[0071] like Figure 2 As shown, the present invention provides a method for dividing a part surface into regions. Taking a circular part as an example, the method is divided into 16 regions, and the size of each region is controlled within the observable field of view of a digital microscope.
[0072] In addition, for the surface of parts of any shape, the average division method can be used. The parts can be evenly divided into multiple areas. When the area of the divided area is smaller than the visible area of the digital microscope, the division is considered effective and can be used for roughness detection; when the area of the divided area exceeds the visible area of the digital microscope, the area exceeding the visible area of the digital microscope is divided twice and still evenly divided into multiple areas for detection to ensure that the secondary divided area is smaller than the visible area of the digital microscope. If the division is still invalid, the third division is performed, and so on, until the area of all divided areas is smaller than the visible area of the digital microscope.
[0073] The image processing module is divided into three parts, as follows:
[0074] 1. The surface image of the part is grayed out. The specific process is as follows:
[0075] (1) Based on the collected part surface image, the pixel point X is calibrated at equal distances along the direction perpendicular to the image texture, and the red (R), green (G), and blue (B) components of the pixel value at the point are obtained. The pixel component calibration diagram is shown in the figure below: Figure 3 shown.
[0076] (2) Compare the three pixel components R, G, and B in pairs, and define them as grayscale 1 to grayscale 6: Among them, R(i,j), B(i,j), G(i,j) are the R, G, and B component values of the pixel point with coordinates (i,j) in the part surface image respectively;
[0077] (3) Since the grayscale value obtained by dividing each pixel component may exceed the range of 0 to 1 specified by the pixel, normalization processing is required. The calculation formula is as follows:
[0078] Normalization
[0079] In the formula, Gray′(i,j) min and Gray(i,j) min It is the maximum and minimum grayscale values of the pixels on the surface of the part.
[0080] The image quality comparison after being processed by grayscale 1 to grayscale 6 is shown in Table 1.
[0081] Table 1 Comparison of part surface image quality of grayscale 1 to grayscale 6
[0082]
[0083] It can be seen from Table 1 that the image quality obtained by grayscale 5 and grayscale 6 is better. In order to comprehensively consider the three components of RGB, grayscale 5 and grayscale 6 are combined and defined as the pixel component ratio addition method. The calculation formula is as follows:
[0084] Pixel component ratio addition
[0085] like Figure 4 As shown in the figure, the original part surface image, the weighted average method and the part surface image after graying by the pixel component ratio addition method. In order to analyze the image quality after graying by the pixel component ratio addition method, the three evaluation indicators of the gray image standard deviation, average gradient and information entropy are calculated respectively, and compared with the most commonly used weighted average method in graying 5, graying 6 and image graying methods. The comparison results are shown in the figure. Figure 5 As shown. Figure 5 It can be seen that the standard deviation, average gradient, and information entropy of the pixel component extracted by the addition method are larger than those of grayscale 5, grayscale 6, and weighted average method, and the corresponding image texture changes are more obvious, which is more conducive to the extraction of texture features that characterize the surface roughness of parts. Therefore, this method is used to grayscale the collected image.
[0086] 2. Filtering of grayscale image of part surface:
[0087] The Gaussian filter operation is performed on the grayscale image of the part surface using a Gaussian window with a dimension of 3×3 and a standard deviation of 0.8, and the mean square error and peak signal-to-noise ratio are used to compare the filtering effects of mean filtering, median filtering and Gaussian filtering. The specific results are as follows Figure 6 As shown. Figure 6 It can be seen that the mean square error of the part surface image obtained by Gaussian filtering is much smaller than that of the other two methods, and the peak signal-to-noise ratio is greater than that of the other two methods, and the corresponding image quality is higher. Therefore, Gaussian filtering is selected to filter the collected image.
[0088] 3. Based on the gray-level co-occurrence matrix, four texture features, namely energy, entropy, moment of inertia and correlation, are extracted, and their means and variances are calculated to generate an 8-dimensional feature vector.
[0089] Extract the surface texture features of the parts and establish the relationship model between the surface texture features of the parts and the surface roughness of the parts. The gray-level co-occurrence matrix analyzes the gray-level changes of the pixels on the surface of the parts, represents the adjacent intervals and the amplitude of the changes of the surface images of the parts, and then describes the surface texture of the parts.
[0090] By analyzing the probability of the simultaneous appearance of a pixel with grayscale i at point (x, y) and a pixel with grayscale j at point (x+a, y+b) in the part surface image, a probability matrix P(i, j) is constructed, and its formula is:
[0091] Probability Matrix
[0092] Wherein, i=1,2,...,M; j=1,2,...,N; f(x,y) and f(x+a,y+b) represent the grayscale values of the pixel points (x,y) and (x+a,y+b) in the part surface image.
[0093] Based on the gray-level co-occurrence matrix, the following features are extracted: energy, entropy, moment of inertia, and correlation. The calculation process is as follows:
[0094] energy
[0095] entropy
[0096] Moment of inertia
[0097] Relevance
[0098] Where: M and N are the number of pixels in the horizontal and vertical directions of the part surface image, respectively; μ is the mean value of the pixels in the part surface image; x' and y' represent the gradients in the horizontal and vertical directions of the part surface image, respectively; l represents the gray level of the pixel in the part surface image; L represents the maximum gray level, L = 255; P(l) is the percentage of pixels with gray level l in the part surface image.
[0099] S24, generate feature vectors, and calculate W respectively A , W B , W C , W D The mean value W A1 , W B1 , W C1 , W D1 and variance W A2 , W B2 , W C2 , W D2 As features to describe the surface texture of parts, these eight features are used to generate an 8-dimensional feature vector as the input of the support vector machine.
[0100] As shown in Table 2, the results of texture feature extraction for the surface of parts with Ra=0.4μm, 0.8μm, and 1.6μm are shown based on different grayscale methods.
[0101] Table 2 Comparison of surface texture characteristics of parts with different roughness levels
[0102]
[0103] It can be seen from Table 2 that when Ra = 0.8 μm ~ 1.6 μm, the texture feature W extracted after preprocessing based on the weighted average method A1 , W B1 , W C1 , W D1 Compared with the pixel component addition method, the change range is smaller, and it is not easy to distinguish similar roughness; and the partial correlation mean W extracted after preprocessing based on the weighted average method D1 It increases with the increase of roughness and has a correlation with the mean value W D1 Therefore, the image preprocessed by adding pixel components is more conducive to extracting texture features with obvious roughness distinction, so as to better identify the surface roughness of parts.
[0104] The detection process of the roughness detection module is as follows:
[0105] The 8-dimensional feature vector extracted based on the gray level co-occurrence matrix is used as the input of the support vector machine detection model. The output of the model is the roughness value of each area on the part surface. Finally, the average of the roughness values of each area is calculated as the roughness value of the part surface.
[0106] Support vector machine (SVM) is based on the principle of structural risk minimization and can effectively solve problems such as data nonlinearity and small number of samples. It has the advantages of fast training and strong generalization ability. It establishes the relationship between the surface texture features of parts and the surface roughness of parts, and detects the surface roughness of parts based on support vector machine.
[0107] The output value of the roughness detection model based on support vector machine can be expressed as a nonlinear regression model as shown below:
[0108] Nonlinear regression model Ra 模型 =w T x+b (8)
[0109] Where Ra 模型 is the surface roughness of the part output by the support vector machine detection model, w is the linear combination of the part surface image feature vector input extracted based on the gray level co-occurrence matrix; b is the function bias.
[0110] The kernel function of the support vector machine detection model uses the Gaussian kernel function. According to the input part surface feature vector, the penalty parameter C = 0.1 and the width parameter σ = 0.8 are set. Through the training and verification of the model, the root mean square error of the roughness detection of the support vector machine based on the Gaussian kernel function is 0.0316, the average relative error is 0.0296, the detection accuracy is high, and the running time is suitable.
[0111] The extracted part surface texture feature vector is used as the input of the support vector machine detection model, and the output of the model is the part surface roughness value.
[0112] As shown in Table 3, this is the detection accuracy of the support vector machine model for parts with different roughness levels.
[0113] Table 3 Roughness test results of parts with different roughness levels
[0114]
[0115] like Figure 7 As shown, it is a comparison chart between the actual value and the detected value of the roughness of 16 acquisition areas on the surface of one group of test sample parts.
[0116] In order to analyze the influence of grayscale improvement on the roughness detection accuracy, the texture features extracted after processing the image by weighted average method and pixel component ratio addition method are selected as input, and multiple batches of simulations are carried out based on support vector machine. The comparison of detection accuracy is shown in Table 4.
[0117] Table 4 Comparison of roughness detection accuracy under different grayscale methods
[0118]
[0119] In order to analyze the rationality of the detection model selection, the detection accuracy of various models is compared, and 5% detection relative error is used as the threshold. The percentage of images with detection relative error below the threshold in each area of the part surface is calculated. The comparison results are shown in the figure. Figure 8 As shown. Figure 8 It can be seen that the relative errors of the roughness detection of each area on the surface of the part based on the support vector machine are all less than 5%, and the percentages of the number of images with relative errors below the threshold in each area detected by the other three methods are 68.75%, 37.5%, and 43.75% respectively. Compared with the other three methods, the support vector machine model has higher detection accuracy for the surface roughness of parts.
[0120] The invention provides an image acquisition device for each area on a part surface, comprising: an STM32 single-chip microcomputer, a two-phase four-wire stepping motor, an SGO-1000BX digital microscope, a host computer and a part surface image acquisition and part surface roughness detection system built thereon; wherein the single-chip microcomputer is respectively connected to the stepping motor and the host computer, and the stepping motor drives a horizontal tray to rotate; the host computer is connected to the digital microscope, and the digital microscope is distributed above the horizontal tray.
[0121] like Fig. 9 As shown in the figure, the image acquisition method of each area on the surface of the part has the following specific steps:
[0122] (1) Place the parts on a horizontal tray, and the host computer sends an image acquisition start signal to the microcontroller through the serial port;
[0123] (2) The single-chip microcomputer receives the image and starts to collect signals, outputs a PWM wave with a certain period to drive the stepper motor to rotate, and the stepper motor drives the horizontal tray and the parts on it to rotate to the divided area;
[0124] (3) The MCU suspends PWM wave output and sends image acquisition signals to the host computer through the serial port;
[0125] (4) The host computer receives the image acquisition signal, controls the digital microscope to acquire and save the part surface image, and sends the image acquisition completion signal to the single-chip microcomputer through serial communication;
[0126] (5) The single-chip microcomputer receives the signal and continues to output PWM waves to drive the stepper motor to rotate. The stepper motor drives the horizontal tray and the parts on it to rotate to the next divided area, and repeats steps (3) and (4) until the images of all the divided areas on the surface of the part are collected.
[0127] (6) The host computer sends an image stop acquisition signal to the microcontroller through the serial port.
[0128] (7) The single-chip microcomputer receives the image stop acquisition signal, stops outputting the PWM wave, the stepper motor stops rotating, and stops acquiring the image of the part surface.
[0129] It should be understood that those skilled in the art can make improvements or changes based on the above description, and all these improvements and changes should fall within the scope of protection of the appended claims of the present invention.
Claims
1. A method for detecting surface roughness of a part based on an image using a support vector machine, characterized in that: The following steps are involved: S1 divides the surface of the part into appropriate areas using the part surface division method, and collects images of each area on the surface of the part through the part surface image acquisition system; S2 performs image preprocessing on the part image; The part surface image is converted into a grayscale image using the ratio addition method of pixel components, and filtered using a Gaussian window; The process of the pixel component comparison method is as follows: (1) Based on the acquired image, the pixel point X is calibrated at equal distances along the direction perpendicular to the image texture, and the red (R), green (G), and blue (B) components of the pixel value at the point are obtained; (2) Compare the pixel components B and R, B and G, and add them together, and use the normalized value as the new pixel value of the point. The formula is as follows: Pixel component ratio addition Among them, R(i,j), B(i,j), G(i,j) are the R, G, and B component values of the pixel point with coordinates (i,j) in the part surface image respectively; S3 extracts four texture features of the image, namely energy, entropy, moment of inertia, and correlation, based on the gray-level co-occurrence matrix, and calculates their mean and variance to generate an 8-dimensional feature vector as the input of the support vector machine; The S4 support vector machine detection model outputs the roughness value, and the part surface roughness value detection results are displayed through the host computer interface.
2. The detection method according to claim 1, characterized in that: In step S1, the method for dividing the part surface is as follows: the part is evenly divided into multiple regions. When the area of the divided region is smaller than the visible area of the digital microscope, the division is considered to be effective and can be used for roughness detection; when the area of the divided region exceeds the visible area of the digital microscope, the region exceeding the visible area of the digital microscope is divided twice, and is still evenly divided into multiple regions for detection to ensure that the secondary divided area is smaller than the visible area of the digital microscope. If the division is still invalid, a third division is performed, and so on, until the areas of all divided regions are smaller than the visible area of the digital microscope.
3. The detection method according to claim 1, characterized in that: In step S1, collecting images of various regions on the surface of a part includes the following steps: S11, placing the parts at the sampling point of the horizontal tray, the host computer sends an image start acquisition signal, the single chip microcomputer receives the signal, outputs a PWM wave, and the stepper motor drives the horizontal tray and the parts on it to rotate to the divided area; S12, the single chip computer suspends PWM wave output and sends an image acquisition signal to the upper computer; S13, the host computer receives the image acquisition signal, controls the digital microscope to acquire the part image and saves it to the host computer, and then sends the image acquisition completion signal to the single-chip microcomputer through the serial port; S14, the single chip microcomputer receives the image acquisition completion signal, continues to output PWM waves to drive the stepper motor, and repeats steps S11, S12, and S13 until all the areas divided by the parts are acquired.
4. The detection method according to claim 1, characterized in that: In step S2, a Gaussian filtering operation is performed on the grayscale image of the part surface using a Gaussian window with a dimension of 3×3 and a standard deviation of 0.
8.
5. The detection method according to claim 1, characterized in that: The specific method of S3 is: extracting the surface texture features of the part and establishing a relationship model between the surface texture features of the part and the surface roughness of the part; By analyzing the probability of the simultaneous appearance of a pixel with grayscale i at point (x, y) and a pixel with grayscale j at point (x+a, y+b) in the part surface image, a probability matrix P(i, j) is constructed, and its formula is: Probability Matrix Where, i = 1, 2, ..., M; j = 1, 2, ..., N; f(x, y) and f(x+a, y+b) represent the grayscale values of the pixels (x, y) and (x+a, y+b) in the part surface image; Based on the gray-level co-occurrence matrix, the following features are extracted: energy, entropy, moment of inertia, and correlation. The calculation process is as follows: energy entropy Moment of inertia Relevance Where: M and N are the number of pixels in the horizontal and vertical directions of the part surface image, respectively; μ is the mean value of the pixels in the part surface image; x' and y' represent the gradients in the horizontal and vertical directions of the part surface image, respectively; l represents the gray level of the pixel in the part surface image; L represents the maximum gray level, L = 255; P(l) is the percentage of pixels with gray level l in the part surface image; Generate eigenvectors and calculate W respectively A , W B , W C , W D The mean value W A1 , W B1 , W C1 , W D1 and variance W A2 , W B2 , W C2 , W D2 As features to describe the surface texture of parts, these eight features are used to generate an 8-dimensional feature vector as the input of the support vector machine.
6. The detection method according to claim 1, characterized in that: The specific method of S4 is: S41. The output value of the roughness detection model based on the support vector machine can be expressed as a nonlinear regression model as shown below: Where Ra 模型 is the surface roughness of the part output by the support vector machine detection model, w is the linear combination of the part surface image feature vector input extracted based on the gray level co-occurrence matrix; b is the function bias; S42, the kernel function of the support vector machine detection model uses the Gaussian kernel function, and according to the input part surface feature vector, the penalty parameter C=0.1 and the width parameter σ=0.8 are set; S44. The extracted part surface texture feature vector is used as the input of the support vector machine detection model, and the output of the model is the part surface roughness value.
7. A support vector machine detection system for part surface roughness according to any one of claims 1 to 6, characterized in that: include: Part surface image acquisition device: using the part surface division method to divide the part surface into appropriate areas, and collect images of each area on the part surface; Image preprocessing module: Use the pixel component ratio addition method to convert the part surface image into a grayscale image, and use the Gaussian window for filtering; Texture feature extraction module: extracts four texture features of the image, namely energy, entropy, moment of inertia, and correlation, based on the gray-level co-occurrence matrix, and calculates their mean and variance to generate an 8-dimensional feature vector as the input of the support vector machine; Support vector machine detection module: The support vector machine detection module outputs the roughness value and displays the part surface roughness value detection result through the host computer interface.
8. The detection system according to claim 7, characterized in that: The texture feature extraction module is used to extract the surface texture features of the part and establish a relationship model between the surface texture features of the part and the surface roughness of the part; By analyzing the probability of the simultaneous appearance of a pixel with grayscale i at point (x, y) and a pixel with grayscale j at point (x+a, y+b) in the part surface image, a probability matrix P(i, j) is constructed, and its formula is: Probability Matrix Where, i = 1, 2, ..., M; j = 1, 2, ..., N; f(x, y) and f(x+a, y+b) represent the grayscale values of the pixels (x, y) and (x+a, y+b) in the part surface image; Based on the gray-level co-occurrence matrix, the following features are extracted: energy, entropy, moment of inertia, and correlation. The calculation process is as follows: energy entropy Moment of inertia Relevance Where: M and N are the number of pixels in the horizontal and vertical directions of the part surface image, respectively; μ is the mean value of the pixels in the part surface image; x' and y' represent the gradients in the horizontal and vertical directions of the part surface image, respectively; l represents the gray level of the pixel in the part surface image; L represents the maximum gray level, L = 255; P(l) is the percentage of pixels with gray level l in the part surface image; Generate eigenvectors and calculate W respectively A , W B , W C , W D The mean value W A1 , W B1 , W C1 , W D1 and variance W A2 , W B2 , W C2 , W D2 As features to describe the surface texture of parts, these eight features are used to generate an 8-dimensional feature vector as the input of the support vector machine.
9. The detection system according to claim 7, characterized in that: The image preprocessing module includes a pixel component comparison unit, and the method of the pixel component comparison unit is as follows: (1) Based on the acquired image, the pixel point X is calibrated at equal distances along the direction perpendicular to the image texture, and the red (R), green (G), and blue (B) components of the pixel value at the point are obtained; (2) Compare the pixel components B and R, B and G, and add them together, and use the normalized value as the new pixel value of the point. The formula is as follows: Pixel component ratio addition Among them, R(i,j), B(i,j), and G(i,j) are the R, G, and B component values of the pixel point with coordinates (i,j) in the part surface image.
Citation Information
Patent Citations
Microscopic imaging detection method of copper surface roughness Ra of a flexible IC substrate
CN109191433A
Powder mixing uniformity detection method based on image technology
CN109612888A