Metal surface defect detection and classification method, system, equipment and medium

Metal surface defect images are processed through technologies such as grayscale normalization, adaptive histogram equalization, Gabor filter and maximum entropy algorithm, and combined with the support vector machine model, the poor detection effect and high cost in the existing technology are solved. Problem, efficient and accurate detection and classification of metal surface defects.

CN119130952AActive Publication Date: 2024-12-13XIJING UNIV

Patent Information

Application Number
CN202411173839.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-26
Publication Date
2024-12-13
Estimated Expiration
2044-08-26

AI Technical Summary

Technical Problem

The existing metal surface defect detection technology has problems such as unstable training of the generative network and unsupervised learning to be sensitive to data quality, resulting in poor detection results and overfitting. The hardware facilities of the system based on machine vision are expensive, complicated to calculate, and high cost. .

Method used

Grayscale normalization, adaptive histogram equalization, Gabor filter, maximum entropy algorithm, morphological processing and improved local binary mode are used to process metal surface defect images, and classified training is carried out in combination with the support vector machine model, and calculation is carried out. Defect location and size.

Benefits of technology

It significantly improves image contrast and noise suppression capabilities, enhances defect boundary recognition and feature extraction, improves detection accuracy and classification accuracy, optimizes image analysis performance, and reduces calculation complexity and cost.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119130952A_ABST
    Figure CN119130952A_ABST
Patent Text Reader

Abstract

The invention discloses a metal surface defect detection and classification method, system, equipment and medium, and the method comprises the steps: processing images of different defect types through gray normalization, adaptive histogram equalization, a Gabor filter, a maximum entropy algorithm, morphological processing and an improved local binary pattern; carrying out defect position and size calculation on the processed image, and carrying out GUI (Graphical User Interface) measurement page design; the system, the equipment and the medium are used for realizing the metal surface defect detection and classification method. According to the method, the image processing effect is remarkable, the image contrast is improved, the defect boundary identification is enhanced, the accurate segmentation of the image and the detailed optimization of the structure are realized, the image features are accurately extracted, and efficient classification training is supported; the method has the advantages of improving image quality, enhancing defect detection precision and optimizing feature extraction and analysis, and can be widely applied to the field of high-precision image analysis such as metal defect detection, industrial quality control and computer vision.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of industrial detection technology, and in particular relates to a metal surface defect detection and classification method, system, equipment and medium. Background Art

[0002] Metal plates are widely used in industrial production and daily life, but their manufacturing process is complex, involving a variety of equipment and processes, which can easily lead to various defects on the surface. These defects not only weaken the wear resistance and corrosion resistance of the metal plate, but also affect its electromagnetic properties and appearance, which in turn has an adverse effect on the electromagnetic performance and coating effect. Therefore, for metal plate manufacturers, surface defect detection is a vital link. It can not only quickly identify and eliminate defective products, ensure product quality, and maintain corporate reputation, but also timely discover and correct problems in the production process by analyzing the test results, and promote the optimization and improvement of the production process.

[0003] In the metal products industry, product quality inspection and control occupy a core position. Among them, metal surface defect detection, as a key link to ensure product quality and enhance product competitiveness, has become an important focus of technological innovation in the metal industry. This detection technology is not only crucial to the metal industry, but also widely benefits other industrial fields. Therefore, it has received much attention from the country and has been listed as a key technical research project, gaining wide support and attention. Since the 1970s, machine vision inspection technology has embarked on a road of comprehensive exploration and research and development, and was successfully applied to production practice in the 1980s. In the 1990s, defect detection based on image processing technology ushered in a period of rapid development, with innovative achievements emerging in an endless stream, theoretical research and production practice going hand in hand, making product quality inspection in the production field enter a relatively mature application stage. At present, many domestic scientific research institutions regard the research and development of metal surface defect detection technology as a key scientific and technological task, and have made significant technological breakthroughs, effectively meeting the domestic metal industry's demand for high-quality inspection technology, and significantly improving the overall quality of my country's metal products.

[0004] The patent application document CN202011496247.9 discloses a metal surface defect detection method, system, device and storage medium, which generates defect-free images through a generative adversarial network and then uses unsupervised learning methods in deep learning to greatly reduce dependence on data, improve detection accuracy, and eliminate the need to identify the type of defects in advance. However, since the training of the generative adversarial network is unstable and difficult to converge, and unsupervised learning is extremely sensitive to data quality, the resulting model has poor results and overfitting problems.

[0005] The patent application document CN202110614111.1 discloses a metal surface defect detection system based on machine vision. By improving optical detection methods and optimizing image processing algorithms, the detection accuracy is high, the detection speed is fast, the detection stability is high, the repeatability is good, and the output detection results are stable; however, the hardware facilities required for the three major systems are relatively expensive, the image resolution cannot be guaranteed, and the algorithm is relatively complex, resulting in problems such as complicated model calculations and high costs. Summary of the invention

[0006] In order to solve the defects of the above-mentioned prior art, the purpose of the present invention is to provide a metal surface defect detection and classification method, system, equipment and medium, which processes images of different defect types by adopting grayscale normalization, adaptive histogram equalization, Gabor filter, maximum entropy algorithm, morphological processing and improved local binary pattern, calculates the defect position and size of the processed image, and designs a GUI measurement page; the image processing effect of the present invention is significant, the image contrast is improved, the recognition of the defect boundary is strengthened, the accurate segmentation of the image and the detailed optimization of the structure are realized, the image features are accurately extracted, and efficient classification training is supported; it has the advantages of improving image quality, enhancing defect detection accuracy, and optimizing feature extraction and analysis.

[0007] In order to achieve the above object, the technical solution adopted by the present invention is:

[0008] A method for detecting and classifying metal surface defects comprises the following steps:

[0009] Step 1: Collect metal surface images with different defect types, and organize the metal surface images with different defect types into image sample data sets;

[0010] Step 2: Use grayscale normalization and adaptive histogram equalization to perform contrast enhancement processing on the image sample data set sorted in step 1 to obtain an image set with contrast enhancement and noise reduction;

[0011] Step 3: Use a Gabor filter to perform a filtering algorithm on the image set that has undergone contrast enhancement and noise reduction in step 2 to obtain an image set with reduced noise and enhanced defect boundaries;

[0012] Step 4: Use the maximum entropy algorithm to perform threshold segmentation on the image set in step 3 after reducing noise and enhancing defect boundaries to obtain the image set with the optimal threshold.

[0013] Step 5: Use the morphological processing function (bwmorph function) provided by MATLAB, select the parameter as "thin", repeat the operation multiple times on the image set with the best threshold obtained in step 4, and obtain the image set after thinning processing;

[0014] Step 6: Use the improved local binary pattern to extract features from the image set after the refinement in step 5, convert the extracted features into feature vectors, and organize them into a matrix;

[0015] Step 7: Establish a support vector machine model and perform classification supervision training on the feature vector converted in step 6 to obtain a trained image set;

[0016] Step 8: extract the image set trained in step 7 and mark it as rolled-in scale defects, spot defects and scratch defects, and calculate the positions and sizes of rolled-in scale defects, spot defects and scratch defects respectively;

[0017] Step 9: Design the GUI for the image set whose defect positions and sizes are calculated in step 8.

[0018] The specific method of step 2 is:

[0019] Step 2.1: Use the grayscale normalization formula to process the image sample data set sorted in step 1, so that the grayscale value of the image sample data set is distributed between 0 and 255; the grayscale normalization formula is defined as:

[0020]

[0021] In the formula, I in ——The gray value of the original image;

[0022] I min ——The minimum gray value of the original image;

[0023] I max ——The maximum gray value of the original image;

[0024] I out ——The gray value of the image after gray normalization;

[0025] Step 2.2: Perform adaptive histogram equalization on the image sample data set after grayscale normalization in step 2.1. The specific method is as follows:

[0026] Step 2.2.1: Set a threshold for the original histogram distribution and cut off the part above the threshold (clamp);

[0027] Step 2.2.2: Perform equalization on the cut-off part, and then superimpose the cut-off part after equalization on the original histogram distribution that is less than the threshold;

[0028] Step 2.2.3: Equalize the superimposed histogram distribution to further enhance the contrast and effectively reduce noise.

[0029] The specific method of step 3 is:

[0030] Step 3.1: Use a Gabor filter to perform a filtering algorithm on the image set with contrast enhancement and noise reduction obtained in step 2.2; the Gabor filter is defined by a Gaussian kernel function modulated by a sinusoidal plane wave:

[0031]

[0032] in: is the rotated coordinate, θ is the directional parameter of the Gabor filter, which determines the filter direction selection characteristics of the Gabor filter; σ is the standard deviation of the Gaussian kernel function, which controls the width of the Gaussian function; λ is the bandwidth, which affects the bandwidth and frequency characteristics of the filter; γ is the spatial direction scale factor;

[0033] The filtered image is:

[0034]

[0035] in, is the pixel coordinate; g is the response of the Gabor filter, that is, the output value of the filter at each pixel position; I is the pixel value of the original image, that is, the image data that needs to be filtered;

[0036] Step 3.2: Use different filter parallel line directions (θ) to perform Gabor filtering on rolled-in oxide scale defects and spot defects; θ = 0°, 45°, 90°, 135°;

[0037] Step 3.3: Subtract the sum of the θ = 90°, 135° filter from the sum of the θ = 0°, 45° filter to offset the ripple caused by the directional selectivity of the Gabor filter, while filtering out noise and enhancing the defect boundary.

[0038] The specific method of step 4 is:

[0039] Step 4.1: Increase the threshold T from 0 to 255 by 1 each time, and divide the image set processed in step 3.3 into background (0) and foreground (1) according to the threshold T;

[0040] Step 4.2: Calculate each threshold T (0≤T<255) to obtain the optimal threshold. The specific calculation method is:

[0041] Step 4.2.1: Calculate the probability distribution p of each gray value in the background (0) and foreground (1) i ;

[0042] Step 4.2.2: Calculate the background (0) and foreground (1)

[0043] in: is the cumulative distribution in the background;

[0044] Step 4.2.3: Calculate the entropy of background (0) and foreground (1):

[0045]

[0046] Step 4.2.4: Calculate the inter-class entropy of the binary image:

[0047] H(T)=H1(T)+H2(T) (6)

[0048] Step 4.2.5: Select the threshold T (0≤T<255) that maximizes the inter-class entropy, and find the optimal threshold by continuously iterating T (0≤T<255).

[0049] The specific method of step 6 is:

[0050] Step 6.1: Select multiple circular domains with different radii, each with a different number of edge points; extract multiple groups of gray value sequences from the image set after the thinning process in step 5 using the selected circular domain parameters;

[0051] Step 6.2: Perform one-dimensional discrete fast Fourier transform on the multiple groups of different gray value sequences obtained in step 6.1 to obtain multiple spectrum graphs;

[0052] Step 6.3: According to the order of the radius of the circular domain, the feature sequences corresponding to the multiple spectrum graphs obtained in step 6.2 are stitched together in sequence to form a complete circular domain feature vector; this process is repeated for other regions of each image until the feature information of the entire image is obtained;

[0053] Step 6.4: Use the image features obtained in step 6.3 to obtain an accurate description of the defect area and find the maximum circumscribed rectangular area of ​​the detected defect location; extract features from the grayscale image inside the rectangle again and convert these features into a feature vector;

[0054] Step 6.5: Based on each feature vector in step 6.4, the feature vectors of all images are combined to form a feature matrix.

[0055] The specific method of step 7 is:

[0056] Step 7.1: Represent each row in the feature matrix formed in step 6.5 as a feature vector of a sample, and organize these feature vectors into a training sample set; the training sample set is defined as:

[0057] D={(x1,y1),(x2,y2),...,(xn,yn)}D={(x1,y1),(x2,y2),...,(xn,yn)}, yi∈{+1,-1}, (7)

[0058] Where: i represents the i-th sample, n represents the sample size, x i is the feature vector of the i-th image, y i is the label of the i-th image;

[0059] Step 7.2: Based on the training sample set organized in step 7.1, find an optimal partitioning hyperplane in the feature space, that is, solve the optimal w and b, specifically:

[0060] Step 7.2.1: The hyperplane is defined by the linear equation (6):

[0061] wz+b=0 (8)

[0062] Step 7.2.2: Define the optimization problem:

[0063] Set the goal to: minimize

[0064] The parameters w and b that maximize the distance from the eigenvector to the hyperplane satisfy the constraints at the same time:

[0065]

[0066] Step 7.2.3: Introduce Lagrange multipliers and construct Lagrange functions:

[0067]

[0068] Step 7.2.4: Use the quadratic programming (QP) algorithm to solve the Lagrangian dual problem and obtain the optimal Lagrangian multiplier α i :

[0069]

[0070] Step 7.2.5: Find the optimal w and b:

[0071]

[0072] Step 7.3: Use the solved optimal parameters w and b to establish a linearly separable support vector machine model; then use the support vector machine model to classify the feature vector in step 6.5 to obtain a trained image set.

[0073] The specific method of step 8 is:

[0074] Step 8.1: Get defect classification image:

[0075] Extract the image set that has been trained in step 7.3 and mark it as rolled-in scale defect, spot defect and scratch defect;

[0076] Step 8.2: Calculation of the location and size of rolled scale defects:

[0077] Step 8.2.1: Boundary extraction and mask application: For each image where a rolled-in scale defect is detected, first extract the boundary area of ​​the defect; then, perform a mask operation on the boundary area on the original image;

[0078] Step 8.2.2: Calculate the grayscale centroid: Use the centroid calculation formula:

[0079]

[0080] Where c(i,j) represents the gray value of the pixel point (i,j), and the gray centroid of the rolled-in oxide scale defect area is calculated and used as the center position of the defect;

[0081] Step 8.2.2: Record the location and size of the defect: Based on the centroid position and boundary information, record the specific location and size of the rolled-in oxide scale defect;

[0082] Step 8.3: Calculation of the location and size of spot defects:

[0083] Step 8.3.1: Spot area calculation: For images with detected spot defects, calculate the total pixel area A of the spot area spot , and the total pixel area A of the image total ;

[0084] Step 8.3.2: Calculate the spot ratio: Calculate the ratio of the spot area to the entire metal surface area:

[0085]

[0086] This ratio is used to assess the severity of spot defects;

[0087] Step 8.3.3: Record the spot position and size: According to the boundary information of the spot area, record the specific position and area ratio of the spot;

[0088] Step 8.4: Calculation of the location and size of the scratch defect:

[0089] Step 8.4.1: Line detection and segmentation: For the image with scratch defects detected, use the Hough transform algorithm to perform line detection;

[0090] Step 8.4.2: Line filtering and classification: Calculate the length of each detected line and remove those lines whose length is less than the set threshold; calculate the angle between all detected lines and the y-axis, and classify the lines into vertical lines and horizontal lines based on the angle;

[0091] Step 8.4.2: Sorting and accumulating straight lines: For vertical lines, sort them by the midpoint X coordinates from small to large; for horizontal lines, sort them by the midpoint Y coordinates from small to large; by traversing the straight lines, judge the coordinate difference between two adjacent straight lines, and accumulate the straight lines that meet the conditions as the same scratch;

[0092] Step 8.4.4: Calculate the scratch length and record the position: For each scratch, calculate the maximum and minimum values ​​of its endpoint coordinates to find the length of the scratch; process the remaining unprocessed straight lines in the same way and record the specific position and length of the scratch;

[0093] Step 8.5: Generate the calculated image set:

[0094] Step 8.5.1: Synthesize calculation results: synthesize the position and size information of the rolled scale defect, spot defect and scratch defect obtained in step 8.2, step 8.3 and step 8.4 into the corresponding image to generate an image set with defect position and size marks;

[0095] Step 8.5.2: Save and Export: Save the image set containing defect location and size information for further analysis or use.

[0096] A metal surface defect detection and classification system, comprising:

[0097] Image acquisition module: collects metal surface images with different defect types and organizes the metal surface images with different defect types into image sample data sets;

[0098] Image processing module: automatically processes the image sample data set and performs corresponding feature extraction through grayscale normalization, adaptive histogram equalization, Gabor filter, maximum entropy algorithm, morphological processing and improved local binary pattern, and constructs feature vectors for subsequent analysis;

[0099] Classification supervision module: establish a support vector machine model and perform classification supervision training on feature vectors;

[0100] Defect calculation module: extracts and marks the trained image set as rolled-in oxide scale defects, spot defects and scratch defects, and calculates the positions and sizes of rolled-in oxide scale defects, spot defects and scratch defects respectively.

[0101] A metal surface defect detection and classification device, comprising:

[0102] Memory: used to store a computer program to implement the metal surface defect detection and classification method as described above;

[0103] Processor: used to implement the metal surface defect detection and classification method as described above when executing the computer program.

[0104] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of a metal surface defect detection and classification method are implemented.

[0105] Compared with the prior art, the beneficial effects of the present invention are:

[0106] 1. The present invention uses grayscale normalization and adaptive histogram equalization in step 2 to perform contrast enhancement processing on the image sample data set sorted in step 1, so that the image contrast and noise suppression capabilities are significantly improved, and the visual clarity and detail performance of the image are further improved; it has the advantages of improving image quality, enhancing the accuracy of subsequent processing, and optimizing the image feature extraction effect.

[0107] 2. The present invention uses a Gabor filter in step 3 to perform filtering algorithm processing on the image set that has undergone contrast enhancement and noise reduction in step 2, thereby producing a significant filtering and noise suppression effect, and can effectively enhance the defect boundaries and texture features in the image; it has the advantages of improving image recognition accuracy, optimizing defect detection effects, and enhancing texture feature description.

[0108] 3. The present invention can efficiently separate image regions, improve image processing accuracy, and optimize image analysis performance by applying the maximum entropy algorithm to perform threshold segmentation on the image set in step 4; it has the advantages of enhancing image information extraction, increasing processing speed, improving image clarity, and reducing the error segmentation rate.

[0109] 4. The present invention produces a significant image refinement effect by performing morphological processing on the image set of the optimal threshold in step 5, and can effectively extract fine structures and edges; it has the advantages of improving image detail expression, enhancing image resolution, and optimizing image quality.

[0110] 5. The present invention uses a modified local binary pattern in step 6 to extract features from the image set after refinement, thereby generating accurate feature descriptions and comprehensive image feature information, which can effectively identify and describe details and defects in the image; it has the advantages of improving the accuracy of feature extraction, enhancing the ability to identify defective areas, and optimizing the integration and analysis of feature information.

[0111] 6. The present invention uses the support vector machine algorithm in step 7 to perform classification supervision training on the sorted matrix, thereby producing accurate classification results and excellent model performance, and can effectively distinguish and identify different types and features in metal defect images; this method has the advantages of improving classification accuracy, enhancing the generalization ability of the model, and optimizing the accuracy and efficiency of defect detection.

[0112] In summary, the present invention processes images of different defect types by adopting grayscale normalization, adaptive histogram equalization, Gabor filter, maximum entropy algorithm, morphological processing and improved local binary pattern, calculates the defect position and size of the processed image, and designs a GUI measurement page. The image processing effect is significant, the image contrast is improved, the recognition of defect boundaries is strengthened, the accurate segmentation of the image and the detailed optimization of the structure are achieved, the image features are accurately extracted, and efficient classification training is supported. The present invention has the advantages of improving image quality, enhancing defect detection accuracy, and optimizing feature extraction and analysis, and can be widely used in the fields of high-precision image analysis such as metal defect detection, industrial quality control, and computer vision. BRIEF DESCRIPTION OF THE DRAWINGS

[0113] Figure 1 It is a flowchart of the implementation steps of the present invention;

[0114] Figure 2 The image after contrast enhancement of the present invention;

[0115] Figure 3 This is a comparison diagram of the original spot image of the present invention and the image after being processed by Gabor filtering;

[0116] Figure 4 This is a comparison diagram of the original image of the rolled oxide scale of the present invention and the image after being processed by Gabor filtering;

[0117] Figure 5 This is a comparison chart of the effects of the present invention after being processed by the maximum entropy algorithm, OSYU method and Niblack method;

[0118] Figure 6 The image is processed by morphological thinning of the present invention;

[0119] Figure 7 An image of the inspection result of rolled-in scale defects of the present invention;

[0120] Figure 8 An image of a spot defect detection result of the present invention;

[0121] Fig. 9 An image of the scratch defect detection result of the present invention;

[0122] Fig.10 This is the initial test page of the GUI of the present invention;

[0123] Fig.11 Rolling in the oxide scale defect test page for the GUI of the present invention;

[0124] Fig.12 It is the GUI spot defect test page of the present invention;

[0125] Fig.13 This is the GUI scratch defect test page of the present invention. DETAILED DESCRIPTION

[0126] The technical solution of the present invention is described in detail below with reference to the accompanying drawings and embodiments.

[0127] See also Figure 1 , a metal surface defect detection and classification method, comprising the following steps:

[0128] Step 1: Collect metal surface images with different defect types, and organize the metal surface images with different defect types into image sample data sets; the defect types include rolled-in oxide scale defects, spot defects, and scratch defects;

[0129] Step 2: Use grayscale normalization and adaptive histogram equalization to perform contrast enhancement processing on the image sample data set sorted in step 1 to obtain an image set with contrast enhancement and noise reduction;

[0130] The specific method of step 2 is:

[0131] Step 2.1: Use the grayscale normalization formula to process the image sample data set sorted in step 1, so that the grayscale value of the image sample data set is distributed between 0 and 255, to avoid the interference of insufficient image contrast (unbalanced distribution of image pixel brightness) on subsequent processing. The grayscale normalization formula is defined as:

[0132]

[0133] In the formula, I in ——The gray value of the original image;

[0134] I min ——The minimum gray value of the original image;

[0135] I max ——The maximum gray value of the original image;

[0136] I out ——The gray value of the image after gray normalization;

[0137] Step 2.2: Perform adaptive histogram equalization on the image sample data set after grayscale normalization in step 2.1 to further enhance the contrast and effectively reduce noise. The specific method is as follows:

[0138] Step 2.2.1: Set a threshold for the original histogram distribution and cut off the part above the threshold (clamp);

[0139] Step 2.2.2: Equalize the cut-off part, and then superimpose the cut-off part after equalization onto the original histogram distribution that is less than the threshold, that is, add a "DC bias" to the histogram;

[0140] Step 2.2.3: Equalize the superimposed histogram distribution to further enhance the contrast and effectively reduce noise.

[0141] Step 3: Use a Gabor filter to perform a filtering algorithm on the image set that has undergone contrast enhancement and noise reduction in step 2 to obtain an image set with reduced noise and enhanced defect boundaries;

[0142] The specific method of step 3 is:

[0143] Step 3.1: Use a Gabor filter to perform a filtering algorithm on the image set with contrast enhancement and noise reduction obtained in step 2.2; the Gabor filter is defined by a Gaussian kernel function modulated by a sinusoidal plane wave:

[0144]

[0145] in: is the rotated coordinate, θ is the directional parameter of the Gabor filter, which determines the filter direction selection characteristics of the Gabor filter, that is, the sharpening and smoothing effect in different directions; σ is the standard deviation of the Gaussian kernel function, which controls the width of the Gaussian function; λ is the bandwidth, which affects the bandwidth and frequency characteristics of the filter; γ is the spatial direction scale factor;

[0146] Gabor filter can be divided into real part and imaginary part, where the real part can be used for smoothing filtering of images, which helps to remove noise and smooth the image. The imaginary part can be used for edge detection, which can highlight the texture and edge information of the image. The filter convolution kernel can be obtained by the formula defined by the above Gabor function. Specifically, by selecting appropriate parameters, Gabor filter convolution kernels with different directions and frequency characteristics can be generated. These convolution kernels are used to filter images to achieve smoothing and edge sharpening at the same time.

[0147] The filtered image is:

[0148]

[0149] in, is the pixel coordinate; g is the response of the Gabor filter, that is, the output value of the filter at each pixel position; I is the pixel value of the original image, that is, the image data that needs to be filtered;

[0150] Step 3.2: Use different filter parallel line directions (θ) to perform Gabor filtering on rolled-in oxide scale defects and spot defects; θ = 0°, 45°, 90°, 135°;

[0151] Step 3.3: Subtract the sum of the θ = 90°, 135° filter from the sum of the θ = 0°, 45° filter to offset the ripple caused by the directional selectivity of the Gabor filter, while filtering out noise and enhancing the defect boundary.

[0152] Step 4: Use the maximum entropy algorithm to perform threshold segmentation on the image set in step 3 after reducing noise and enhancing defect boundaries to obtain the image set with the optimal threshold.

[0153] The specific method of step 4 is:

[0154] Step 4.1: Increase the threshold T from 0 to 255 by 1 each time, and divide the image set processed in step 3.3 into background (0) and foreground (1) according to the threshold T;

[0155] Step 4.2: Calculate each threshold T (0≤T<255) to obtain the optimal threshold. The specific calculation method is:

[0156] Step 4.2.1: Calculate the probability distribution p of each gray value in the background (0) and foreground (1) i ;

[0157] Step 4.2.2: Calculate the background (0) and foreground (1)

[0158] in: is the cumulative distribution in the background;

[0159] Step 4.2.3: Calculate the entropy of background (0) and foreground (1):

[0160]

[0161] Step 4.2.4: Calculate the inter-class entropy of the binary image:

[0162] H(T)=H1(T)+H2(T) (6)

[0163] Step 4.2.5: Select the threshold T (0≤T<255) that maximizes the inter-class entropy, and find the optimal threshold by continuously iterating T (0≤T<255).

[0164] Step 5: Use the morphological processing function (bwmorph function) provided by MATLAB, select the parameter as "thin", repeat the operation multiple times on the image set with the best threshold obtained in step 4, and obtain the image set after thinning processing;

[0165] Step 6: Use the improved local binary pattern to extract features from the image set after the refinement in step 5, convert the extracted features into feature vectors, and organize them into a matrix;

[0166] The specific method of step 6 is:

[0167] Step 6.1: Select multiple circular domains with different radii, each with a different number of edge points; usually select three types of circular domains with small, medium and large radii to capture image features of different scales; the selection of circular domain parameters will affect the subsequent feature extraction, so selecting an appropriate radius and number of edge points is the key; using the selected circular domain parameters, extract multiple groups of gray value sequences from the image set after the refinement processing in step 5; these sequences are calculated from the pixel values ​​in the circular domain, and the gray value sequence reflects the grayscale change of the local area of ​​the image, which is used to describe the local texture features of the image. This embodiment extracts three groups of gray value sequences corresponding to the selected circular domain parameters.

[0168] Step 6.2: Perform one-dimensional discrete fast Fourier transform on the multiple groups of different gray value sequences obtained in step 6.1 to obtain multiple spectrograms, which retain the main frequency characteristics of the sequence and have certain rotation invariance and gray invariance;

[0169] Step 6.3: According to the order of the radius of the circular domain, the feature sequences corresponding to the multiple frequency spectra obtained in step 6.2 are stitched together in sequence to form a complete circular domain feature vector; this process is repeated for other areas of each image until the feature information of the entire image is obtained; in this embodiment, three frequency spectra are obtained by transforming three sets of gray value sequences.

[0170] Step 6.4: Use the image features obtained in step 6.3 to obtain an accurate description of the defect area and find the maximum circumscribed rectangular area of ​​the detected defect location; extract features from the grayscale image inside the rectangle again and convert these features into a feature vector;

[0171] Step 6.5: Based on each feature vector in step 6.4, the feature vectors of all images are combined to form a feature matrix.

[0172] Step 7: Establish a support vector machine model and perform classification supervision training on the feature vector converted in step 6 to obtain a trained image set;

[0173] The specific method of step 7 is:

[0174] Step 7.1: Represent each row in the feature matrix formed in step 6.5 as a feature vector of a sample, and organize these feature vectors into a training sample set; the training sample set is defined as:

[0175] D={(x1,y1),(x2,y2),...,(xn,yn)}D={(x1,y1),(x2,y2),...,(xn,yn)}, yi∈{+1,-1}, (7)

[0176] Where: i represents the i-th sample, n represents the sample size, x i is the feature vector of the i-th image, y i is the label of the i-th image;

[0177] Step 7.2: Based on the training sample set organized in step 7.1, find an optimal partitioning hyperplane in the feature space, separate the positive and negative samples, make the sample data points as far away from the hyperplane as possible, and find the parameters w and b that maximize the distance from the feature vector to the hyperplane; solve the optimal w and b, specifically:

[0178] Step 7.2.1: The hyperplane is defined by the linear equation (6):

[0179] wx+b=0 (8)

[0180] Step 7.2.2: Define the optimization problem:

[0181] Set the goal to: minimize

[0182] The parameters w and b that maximize the distance from the eigenvector to the hyperplane satisfy the constraints at the same time:

[0183]

[0184] Step 7.2.3: Introduce Lagrange multipliers and construct Lagrange functions:

[0185]

[0186] Step 7.2.4: Use the quadratic programming (QP) algorithm to solve the Lagrangian dual problem and obtain the optimal Lagrangian multiplier α i :

[0187]

[0188] Step 7.2.5: Find the optimal w and b:

[0189]

[0190] Step 7.3: Use the solved optimal parameters w and b to establish a linearly separable support vector machine model; then use the support vector machine model to classify the feature vector in step 6.5 to obtain a trained image set.

[0191] Through the above training process, a support vector machine model that can effectively classify metal defect images is obtained; this model is applied to metal defect detection tasks to achieve automatic classification and training of image sets.

[0192] Step 8: extract the image set trained in step 7 and mark it as rolled-in scale defects, spot defects and scratch defects, and calculate the positions and sizes of rolled-in scale defects, spot defects and scratch defects respectively;

[0193] The specific method of step 8 is:

[0194] Step 8.1: Get defect classification image:

[0195] Extract the image set that has been trained in step 7.3 and mark it as rolled-in scale defect, spot defect and scratch defect;

[0196] Step 8.2: Calculation of the location and size of rolled scale defects:

[0197] Step 8.2.1: Boundary extraction and mask application: For each image where a rolled-in scale defect is detected, first extract the boundary area of ​​the defect; then, perform a mask operation on the boundary area on the original image;

[0198] Step 8.2.2: Calculate the grayscale centroid: Use the centroid calculation formula:

[0199]

[0200] Where c(i,j) represents the gray value of the pixel point (i,j), and the gray centroid of the rolled-in oxide scale defect area is calculated and used as the center position of the defect;

[0201] Step 8.2.2: Record the location and size of the defect: Based on the centroid position and boundary information, record the specific location and size of the rolled-in oxide scale defect;

[0202] Step 8.3: Calculation of the location and size of spot defects:

[0203] Step 8.3.1: Spot area calculation: For images with detected spot defects, calculate the total pixel area A of the spot area spot , and the total pixel area A of the image total ;

[0204] Step 8.3.2: Calculate the spot ratio: Calculate the ratio of the spot area to the entire metal surface area:

[0205]

[0206] This ratio is used to assess the severity of spot defects;

[0207] Step 8.3.3: Record the spot position and size: According to the boundary information of the spot area, record the specific position and area ratio of the spot;

[0208] Step 8.4: Calculation of the location and size of the scratch defect:

[0209] Step 8.4.1: Line detection and segmentation: For images with scratch defects detected, use the Hough transform algorithm to perform line detection; since scratches are not necessarily strictly straight lines, these detected lines may overlap and have angles;

[0210] Step 8.4.2: Line filtering and classification: Calculate the length of each detected line and remove those lines whose length is less than the set threshold; calculate the angle between all detected lines and the y-axis, and classify the lines into vertical lines and horizontal lines based on the angle;

[0211] Step 8.4.2: Sorting and accumulating straight lines: For vertical lines, sort them by the midpoint X coordinates from small to large; for horizontal lines, sort them by the midpoint Y coordinates from small to large; by traversing the straight lines, judge the coordinate difference between two adjacent straight lines, and accumulate the straight lines that meet the conditions as the same scratch;

[0212] Step 8.4.4: Calculate the scratch length and record the position: For each scratch, calculate the maximum and minimum values ​​of its endpoint coordinates to find the length of the scratch; process the remaining unprocessed straight lines in the same way and record the specific position and length of the scratch;

[0213] Step 8.5: Generate the calculated image set:

[0214] Step 8.5.1: Synthesize calculation results: synthesize the position and size information of the rolled scale defect, spot defect and scratch defect obtained in step 8.2, step 8.3 and step 8.4 into the corresponding image to generate an image set with defect position and size marks;

[0215] Step 8.5.2: Save and Export: Save the image set containing defect location and size information for further analysis or use.

[0216] Step 9: Design the GUI for the image set with calculated defect positions and sizes obtained in step 8;

[0217] The specific method of step 9 is:

[0218] Step 9.1: Interface layout design: Create a main interface, including two image display windows, two buttons, two user input windows, a data download button, two text boxes and a table; ensure that the interface layout is reasonable and user-friendly;

[0219] Step 9.2: Image display window:

[0220] Step 9.2.1: Implement the image display function: add two image display windows on the main interface;

[0221] Original image display window: used to display the original grayscale image;

[0222] Annotated image display window: used to display the processed image, including annotations of the detected defect location and size;

[0223] Step 9.2.2: Load image function: realize the function of importing images from files. When the user clicks the "Import Image" button, the local grayscale image file is selected and loaded into the original image display window;

[0224] Step 9.3: Image Processing Button: Add an "Image Processing" button on the main interface; when the user clicks this button, the system will perform defect detection on the original image and display the processing results in the annotated image display window, including the location and size of the defect;

[0225] Step 9.4: User Input Window: Create User Input Window: Add two user input windows and enter the following parameters: camera focal length (f) and object distance (d);

[0226] Calculate the actual scratch size: Use the geometrical optics Gaussian formula to calculate the distance l';

[0227]

[0228] Calculate the actual object length y through the vertical axis magnification formula;

[0229]

[0230] Step 9.5: Dataset download button:

[0231] Add a "Dataset Download" button. When the user clicks this button, the system will open a dialog box, allowing the user to enter or select the URL for downloading the dataset and download it;

[0232] Step 9.6: The text box displays the defect information:

[0233] Create two defect information text boxes to display the following information:

[0234] Defect type: Displays the type of defects detected (such as rolled scale, spots, scratches); defect size (number) and the number of defects detected and the size of each defect;

[0235] Step 9.7: Table showing scratch information:

[0236] Step 9.7.1: Create a table control: Add a table control to display the following information:

[0237] Pixel size of scratches: The pixel size of each detected scratch in the image;

[0238] Actual scratch size: The calculated actual size of each scratch (based on the focal length and object distance entered by the user);

[0239] Step 9.7.2: Table data update: After image processing, fill the pixel size and actual size of the scratch into the table and update the interface display;

[0240] Step 9.8: Testing and Optimization:

[0241] Step 9.8.1: Test functionality: Perform a comprehensive test to ensure that image import, processing, calculation, and display functions are functioning properly; check that all buttons, input boxes, and display areas work as expected;

[0242] Step 9.8.2: Optimize user experience: Make adjustments based on test feedback to optimize interface layout, function response time, and user interaction experience;

[0243] Step 9.9: Deployment and Release: After completing the development and testing of all functions, package the application and make it available for users to download or publish it on the target platform.

[0244] A metal surface defect detection and classification system, comprising:

[0245] Image acquisition module: collects metal surface images with different defect types and organizes the metal surface images with different defect types into image sample data sets;

[0246] Image processing module: automatically processes the image sample data set and performs corresponding feature extraction through grayscale normalization, adaptive histogram equalization, Gabor filter, maximum entropy algorithm, morphological processing and improved local binary pattern, and constructs feature vectors for subsequent analysis.

[0247] Classification supervision module: establish a support vector machine model and perform classification supervision training on feature vectors;

[0248] Defect calculation module: extracts and marks the trained image set as rolled-in oxide scale defects, spot defects and scratch defects, and calculates the positions and sizes of rolled-in oxide scale defects, spot defects and scratch defects respectively.

[0249] A metal surface defect detection and classification device, comprising:

[0250] Memory: used to store a computer program to implement the metal surface defect detection and classification method as described above;

[0251] Processor: used to implement the metal surface defect detection and classification method as described above when executing the computer program.

[0252] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of a metal surface defect detection and classification method are implemented.

[0253] The application effect of the present invention is described in detail below in conjunction with simulation experiments.

[0254] In the process of building the image acquisition platform, a series of precise and systematic steps were followed to ensure that the platform can efficiently and accurately capture image data of metal surface defects. First, we started with the installation and configuration of the light source. We specially selected a side light source and carefully adjusted its position, angle and brightness to achieve the best illumination effect of light on the metal surface, while generating clear shadows to enhance the visibility of defects. In order to reduce the interference of external environmental factors, the light source was cleverly placed in a sealed box. This design significantly improved the stability and reliability of the system. A total of 600 grayscale images containing metal surface defects (scratches, rolled-in oxide scale, spots) were collected in the experiment.

[0255] First, read the image and extract the grayscale value of each pixel, which is usually in the range of 0 to 255. Next, find the minimum and maximum grayscale values ​​in the image to determine the distribution range of the grayscale values. Then, use the grayscale normalization formula (1) to normalize each original grayscale value to the range of 0 to 1. Apply the normalized value to each pixel of the image to generate a normalized image. Finally, save or display the normalized image for subsequent analysis or processing.

[0256] Apply contrast-limited adaptive histogram equalization (CLAHE) to the acquired image; set the corresponding parameters: Clip Limit = 0.01, Number of Tiles = 8x8; Figure 2 As shown in the figure, the contrast of the equalized image is significantly enhanced, and the details are more prominent, which is convenient for subsequent threshold segmentation.

[0257] Gabor filtering is performed on the three defects using θ = 0°, 45°, 90°, and 135° respectively, and other parameters remain unchanged at λ = 10. γ=0.5,b=0.5,convolution kernel size 25*25. Figure 3 , Figure 4 From the effect diagram, it can be seen that no Gabor filtering is performed on scratches, and only Gabor filtering is performed on rolled-in oxide scales and spots.

[0258] By filtering the scratches with different convolution kernels of θ=0°, 45°, 90°, and 135°, we found that scratches can only be shown after filtering when θ=0°, which shows that Gabor filtering is indeed directionally selective. When the filtering direction is consistent with the scratch direction, a large ripple oscillation will be generated at the scratch boundary, causing the scratch to appear to be widened. Therefore, we do not perform Gabor filtering on scratches, but only on rolled-in oxide scale and spots.

[0259] When Gabor filtering is performed on rolled-in oxide scale and spots, large oscillations will appear in the background along the filter direction. To reduce this oscillation, four Gabor filters at different angles are used for filtering, and the results of the filters at each angle are weighted averaged. By adding and subtracting the difference between the response images of the filters, the ripple phenomenon caused by the direction selectivity of the Gabor filter can be effectively offset, while removing noise and enhancing the boundaries of defects. Although Gabor filtering may make the image look more blurred, it can retain and enhance the image's features such as edges, peaks, valleys, and ridge contours, thereby improving the contrast between defects and background and edge contour information.

[0260] The maximum between-class variance method (OSTU), maximum entropy algorithm and Niblack method were applied to the defect image for threshold segmentation. Figure 5 The comparison chart of the threshold segmentation effects of the three algorithms is shown below. The OSTU method can show defects more completely, but it also introduces some image noise. The segmentation effects of the maximum entropy method and the Niblack method are relatively close, but considering that the maximum entropy method is a global threshold segmentation method, its calculation amount is much smaller than that of the Niblack method. Therefore, considering the effect and calculation complexity, the present invention selects the maximum entropy algorithm.

[0261] For scratch defects, after threshold segmentation, there are often some gaps in the middle of the scratches, which is not conducive to subsequent straight line detection. Therefore, we first perform a closing operation on the image to eliminate these small gaps in the middle. We selected a square structural element of size 5x5 for the operation. After the closing operation, the slit in the middle of the scratch, which was originally divided into three segments, was filled, and the scratch became continuous. For scratches that are too thick, adverse effects may occur if they are not refined. To this end, use MATLAB's built-in morphological processing function (bwmorph function), select the parameter as "thin", and repeat the operation 5 times to obtain the refined scratches. As shown Figure 6 As shown in the rendering, the gaps in the scratch image are eliminated and the scratch lines are clearer.

[0262] The largest outer rectangle of the detected defect is obtained, and the features of the grayscale image inside the rectangle are extracted. The features are converted into vectors to form a 600x18 feature matrix (600 images, 18 features per image), and the support vector machine (SVM) is used for classification training. 540 images are used as the training set and 60 images are used as the test set. The results show that the classifier test accuracy is 93.3%.

[0263] For the rolled-in oxide scale defect, the position was located according to the feature extraction and classifier training method, and its centroid was marked with a blue star. Figure 7 As shown, a total of 16 rolled-in oxide scale defects were counted.

[0264] For spot defects, their sizes were calculated using the feature extraction and classifier training methods, and their boundaries were marked with red circles. Figure 8 As shown, the spot occupies 5.13% of the area.

[0265] For scratch defects, the above algorithm is used to obtain the starting point coordinates and length of each scratch, and the two end points are marked with a cross, and the actual position of the scratch is marked with a straight line. The results are as follows Fig. 9 As shown, four scratches are detected, and the starting point coordinates and lengths are as follows (assuming the focal length is 2cm, the object distance is 50cm, and the pixel to actual size conversion ratio is 0.048cm / pixel):

[0266] The first one: 80 pixels, actual 3.84cm;

[0267] The second one: 172 pixels, actual 8.26cm;

[0268] The third line: 169 pixels, actual 8.09 cm;

[0269] The fourth line: 173 pixels, actual 8.31cm;

[0270] Mark the two end points with a cross and the scratch line with a line.

[0271] In order to facilitate operation and display, a metal defect classification and measurement page was developed, which includes two image display windows to display the original line and the image with the detected defect position and size respectively, two buttons to import grayscale images from files and perform image processing respectively, and two user input windows to allow users to input the focal length and object distance of the camera to calculate the actual scratch size. Fig.10 This is the initial test page of the GUI of the present invention; Fig.11 , Fig.12 , Fig.13 These are the test pages for rolled scale defects, spot defects, and scratch defects.

[0272] It can be seen from the simulation test that compared with the prior art, the present invention has significant advantages in the acquisition and processing of metal surface defect images:

[0273] In terms of light source design and control: the combination of side light source and sealed box not only optimizes the lighting conditions, but also improves the stability and anti-interference ability of the system. It is a rare high-efficiency light source design scheme in the existing technology; through the precise configuration of the side light source and the sealed box design, the stability of image acquisition is improved, external interference is reduced, the image quality is significantly improved, and the defect recognition rate is increased by about 20%.

[0274] In terms of image preprocessing effects: from grayscale normalization, adaptive histogram equalization (CLAHE) to Gabor filter optimization, and then to threshold segmentation and morphological processing, each step is finely adjusted according to the characteristics of metal surface defects, forming a complete image processing chain, which significantly improves the accuracy and efficiency of defect detection.

[0275] Grayscale normalization: Normalize the grayscale value to the range of 0 to 1, which provides a more stable data basis for subsequent processing and enhances the generalization ability of the algorithm.

[0276] CLAHE application: Through CLAHE processing, the image contrast is enhanced by about 30%, the defect details are clearer, and better conditions are provided for subsequent threshold segmentation.

[0277] Gabor filter optimization:

[0278] Optimized filtering strategies are adopted for scratches, rolled-in oxide scale and spots, especially multi-angle Gabor filtering and weighted averaging, which reduces background oscillation, enhances defect boundaries, and improves defect recognition accuracy by about 15%.

[0279] Selection of threshold segmentation algorithm: Compared with the OSTU method and Niblack method, the maximum entropy method reduces the computational complexity by about 40% while maintaining high segmentation accuracy.

[0280] Defect detection and measurement accuracy: In scratch detection, the continuity and clarity of scratches are significantly improved through closed operations and refinement processing, and the scratch length measurement error is controlled within ±0.1cm, with an accuracy of up to 99%.

[0281] In terms of multi-intelligent classification and measurement systems: Combining the support vector machine model with the GUI interface design, automatic classification, location and size measurement of defects are realized, providing a convenient and efficient solution for industrial inspection.

[0282] In terms of user experience: through the development of the GUI interface, users can easily import images, adjust parameters, and view processing results, which greatly improves the operability of the system and user experience.

[0283] In summary, the present invention demonstrates significant advantages and innovations in light source design, image processing algorithm, defect detection accuracy and user-friendliness, bringing new breakthroughs in the field of metal surface defect detection.

Claims

1. A method for detecting and classifying metal surface defects, characterized in that: The following steps are involved: Step 1: Collect metal surface images with different defect types, and organize the metal surface images with different defect types into image sample data sets; Step 2: Use grayscale normalization and adaptive histogram equalization to perform contrast enhancement processing on the image sample data set sorted in step 1 to obtain an image set with contrast enhancement and noise reduction; Step 3: Use a Gabor filter to perform a filtering algorithm on the image set that has undergone contrast enhancement and noise reduction in step 2 to obtain an image set with reduced noise and enhanced defect boundaries; Step 4: Use the maximum entropy algorithm to perform threshold segmentation on the image set in step 3 after reducing noise and enhancing defect boundaries, and obtain the image set with the optimal threshold. Step 5: Use the morphological processing function (bwmorph function) provided by MATLAB, select the parameter "thin", and repeat the operation multiple times on the image set with the best threshold obtained in step 4 to obtain the image set after thinning processing; Step 6: Use the improved local binary pattern to extract features from the image set after the refinement in step 5, convert the extracted features into feature vectors, and organize them into a matrix; Step 7: Establish a support vector machine model and perform classification supervision training on the feature vector converted in step 6 to obtain a trained image set; Step 8: extract the image set trained in step 7 and mark it as rolled-in scale defects, spot defects and scratch defects, and calculate the positions and sizes of rolled-in scale defects, spot defects and scratch defects respectively; Step 9: Design the GUI for the image set whose defect positions and sizes are calculated in step 8.

2. A metal surface defect detection and classification method according to claim 1, characterized in that: The specific method of step 2 is: Step 2.1: Use the grayscale normalization formula to process the image sample data set sorted in step 1, so that the grayscale value of the image sample data set is distributed between 0 and 255; the grayscale normalization formula is defined as: In the formula, I in ——The gray value of the original image; I min ——The minimum gray value of the original image; I max ——The maximum gray value of the original image; I out ——The gray value of the image after gray normalization; Step 2.2: Perform adaptive histogram equalization on the image sample data set after grayscale normalization in step 2.

1. The specific method is as follows: Step 2.2.1: Set a threshold for the original histogram distribution and cut off the part above the threshold (clamp); Step 2.2.2: Perform equalization on the cut-off part, and then superimpose the cut-off part after equalization on the original histogram distribution that is less than the threshold; Step 2.2.3: Equalize the superimposed histogram distribution to further enhance the contrast and effectively reduce noise.

3. A metal surface defect detection and classification method according to claim 1, characterized in that: The specific method of step 3 is: Step 3.1: Use a Gabor filter to perform a filtering algorithm on the image set with contrast enhancement and noise reduction obtained in step 2.2; the Gabor filter is defined by a Gaussian kernel function modulated by a sinusoidal plane wave: in: is the rotated coordinate, θ is the directional parameter of the Gabor filter, which determines the filter direction selection characteristics of the Gabor filter; σ is the standard deviation of the Gaussian kernel function, which controls the width of the Gaussian function; λ is the bandwidth, which affects the bandwidth and frequency characteristics of the filter; γ is the spatial direction scale factor; The filtered image is: in, is the pixel coordinate; g is the response of the Gabor filter, that is, the output value of the filter at each pixel position; I is the pixel value of the original image, that is, the image data that needs to be filtered; Step 3.2: Use different filter parallel line directions (θ) to perform Gabor filtering on rolled-in oxide scale defects and spot defects; θ = 0°, 45°, 90°, 135°; Step 3.3: Subtract the sum of the θ = 90°, 135° filter from the sum of the θ = 0°, 45° filter to offset the ripple caused by the directional selectivity of the Gabor filter, while filtering out noise and enhancing the defect boundary.

4. A metal surface defect detection and classification method according to claim 1, characterized in that: The specific method of step 4 is: Step 4.1: Increase the threshold T from 0 to 255 by 1 each time, and divide the image set processed in step 3.3 into background (0) and foreground (1) according to the threshold T; Step 4.2: Calculate each threshold T (0≤T<255) to obtain the optimal threshold. The specific calculation method is: Step 4.2.1: Calculate the probability distribution p of each gray value in the background (0) and foreground (1) i ; Step 4.2.2: Calculate the background (0) and foreground (1) in: is the cumulative distribution in the background; Step 4.2.3: Calculate the entropy of background (0) and foreground (1): Step 4.2.4: Calculate the inter-class entropy of the binary image: H(T)=H1(T)+H2(T) (6) Step 4.2.5: Select the threshold T (0≤T<255) that maximizes the inter-class entropy, and find the optimal threshold by continuously iterating through T (0≤T<255).

5. A metal surface defect detection and classification method according to claim 1, characterized in that: The specific method of step 6 is: Step 6.1: Select multiple circular domains with different radii, each with a different number of edge points; extract multiple groups of gray value sequences from the image set after the thinning process in step 5 using the selected circular domain parameters; Step 6.2: Perform one-dimensional discrete fast Fourier transform on the multiple groups of different gray value sequences obtained in step 6.1 to obtain multiple spectrum graphs; Step 6.3: According to the order of the radius of the circular domain, the feature sequences corresponding to the multiple spectrum graphs obtained in step 6.2 are stitched together in sequence to form a complete circular domain feature vector; this process is repeated for other regions of each image until the feature information of the entire image is obtained; Step 6.4: Use the image features obtained in step 6.3 to obtain an accurate description of the defect area and find the maximum circumscribed rectangular area of ​​the detected defect location; extract features from the grayscale image inside the rectangle again and convert these features into a feature vector; Step 6.5: Based on each feature vector in step 6.4, the feature vectors of all images are combined to form a feature matrix.

6. A metal surface defect detection and classification method according to claim 1 or 5, characterized in that: The specific method of step 7 is: Step 7.1: Represent each row in the feature matrix formed in step 6.5 as a feature vector of a sample, and organize these feature vectors into a training sample set; the training sample set is defined as: D={(x1,y1),(x2,y2),...,(xn,yn)}D={(x1,y1),(x2,y2),...,(xn,yn)}, yi∈{+1,-1}, (7) Where: i represents the i-th sample, n represents the sample size, x i is the feature vector of the i-th image, y i is the label of the i-th image; Step 7.2: Based on the training sample set organized in step 7.1, find an optimal partitioning hyperplane in the feature space, that is, solve the optimal w and b, specifically: Step 7.2.1: The hyperplane is defined by the linear equation (6): wx+b=0 (8) Step 7.2.2: Define the optimization problem: Set the goal to: minimize (9) The parameters w and b that maximize the distance from the eigenvector to the hyperplane satisfy the constraints at the same time: Step 7.2.3: Introduce Lagrange multipliers and construct Lagrange functions: Step 7.2.4: Use the quadratic programming (QP) algorithm to solve the Lagrangian dual problem and obtain the optimal Lagrangian multiplier α i : Step 7.2.5: Find the optimal w and b: Step 7.3: Use the solved optimal parameters w and b to establish a linearly separable support vector machine model; then use the support vector machine model to classify the feature vector in step 6.5 to obtain a trained image set.

7. A metal surface defect detection and classification method according to claim 1, characterized in that: The specific method of step 8 is: Step 8.1: Get defect classification image: Extract the image set that has been trained in step 7.3 and mark it as rolled-in scale defect, spot defect and scratch defect; Step 8.2: Calculation of the location and size of rolled-in scale defects: Step 8.2.1: Boundary extraction and mask application: For each image where a rolled-in scale defect is detected, first extract the boundary area of ​​the defect; then, perform a mask operation on the boundary area on the original image; Step 8.2.2: Calculate the grayscale centroid: Use the centroid calculation formula: Where c(i,j) represents the gray value of the pixel point (i,j), and the gray centroid of the rolled-in oxide scale defect area is calculated and used as the center position of the defect; Step 8.2.2: Record the location and size of the defect: Based on the centroid position and boundary information, record the specific location and size of the rolled-in oxide scale defect; Step 8.3: Calculation of the location and size of spot defects: Step 8.3.1: Spot area calculation: For images with detected spot defects, calculate the total pixel area A of the spot area spot , and the total pixel area A of the image total ; Step 8.3.2: Calculate the spot ratio: Calculate the ratio of the spot area to the entire metal surface area: This ratio is used to assess the severity of spot defects; Step 8.3.3: Record the spot position and size: According to the boundary information of the spot area, record the specific position and area ratio of the spot; Step 8.4: Calculation of the location and size of the scratch defect: Step 8.4.1: Line detection and segmentation: For the image with scratch defects detected, use the Hough transform algorithm to perform line detection; Step 8.4.2: Line filtering and classification: Calculate the length of each detected line and remove those lines whose length is less than the set threshold; calculate the angle between all detected lines and the y-axis, and classify the lines into vertical lines and horizontal lines based on the angle; Step 8.4.2: Sorting and accumulating straight lines: For vertical lines, sort them by the midpoint X coordinates from small to large; for horizontal lines, sort them by the midpoint Y coordinates from small to large; by traversing the straight lines, judge the coordinate difference between two adjacent straight lines, and accumulate the straight lines that meet the conditions as the same scratch; Step 8.4.4: Calculate the scratch length and record the position: For each scratch, calculate the maximum and minimum values ​​of its endpoint coordinates to find the length of the scratch; process the remaining unprocessed straight lines in the same way and record the specific position and length of the scratch; Step 8.5: Generate the calculated image set: Step 8.5.1: Synthesize calculation results: synthesize the position and size information of the rolled scale defect, spot defect and scratch defect obtained in step 8.2, step 8.3 and step 8.4 into the corresponding image to generate an image set with defect position and size marks; Step 8.5.2: Save and Export: Save the image set containing defect location and size information for further analysis or use.

8. A metal surface defect detection and classification system, characterized in that: include: Image acquisition module: collects metal surface images with different defect types and organizes the metal surface images with different defect types into image sample data sets; Image processing module: automatically processes the image sample data set and performs corresponding feature extraction through grayscale normalization, adaptive histogram equalization, Gabor filter, maximum entropy algorithm, morphological processing and improved local binary pattern, and constructs feature vectors for subsequent analysis; Classification supervision module: establish a support vector machine model and perform classification supervision training on feature vectors; Defect calculation module: extracts and marks the trained image set as rolled-in oxide scale defects, spot defects and scratch defects, and calculates the positions and sizes of rolled-in oxide scale defects, spot defects and scratch defects respectively.

9. A metal surface defect detection and classification device, characterized in that: include: Memory: used to store a computer program to implement a metal surface defect detection and classification method as described in any one of claims 1 to 7; Processor: used to implement a metal surface defect detection and classification method as described in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the metal surface defect detection and classification method are implemented.

Citation Information

Patent Citations

  • Metal surface defect detection method, system and device and storage medium

    CN112634219A

  • Metal surface defect detection system based on machine vision

    CN113237895A

  • Flame identification method, system and device and medium

    CN113177467A

  • Casting surface defect detection method based on computer vision

    CN116758061A

  • Method for classifying surface defects of hot-rolled strip steel based on support vector machine

    CN118038178A

Cited By

  • Modularized machine vision identification tablet quality detection system and method

    CN119360146A

  • Laptop appearance defect detection method and device based on DL, medium and equipment

    CN120931640A

  • Casting riser image recognition method based on machine learning

    CN121033528A

  • SiC substrate surface defect detection system and method based on FPGA

    CN121685483A

  • An FPGA-based SiC substrate surface defect detection system and method

    CN121685483B