Feature enhancement classification recognition algorithm for spring end face defect detection

CN119068239APending Publication Date: 2024-12-03TIANJIN UNIVERSITY OF TECHNOLOGY
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411059590.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-05
Publication Date
2024-12-03

Smart Images

  • Figure CN119068239A_ABST
    Figure CN119068239A_ABST
Patent Text Reader

Abstract

The invention relates to a feature enhancement classification recognition algorithm for spring end face defect detection, and belongs to the field of image processing and machine learning methods. Step 2, Gaussian filtering; 3, processing a threshold value and corroding the image; 4, extracting all contours of the image; 5, drawing all contours and straight lines from each point to the center of the image; 6, labeling the positive and negative samples; 7, extracting HOG (Histograms of Oriented Gradients) features of the positive and negative samples; and step 8, training a support vector machine (SVM) model to obtain a classification identification model which can be used for spring end face defect detection and is used for spring end face defect detection. According to the method, feature enhancement is carried out on the spring end face defect image, the defect identification accuracy is improved, automatic judgment of the end face defects is achieved by means of the spring end face structure features, the springs can be freely placed in the view field range, and the method can carry out processing in a self-adaptive mode.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of image processing and machine learning methods, and specifically is a feature enhancement classification and recognition algorithm for spring end face defect detection. Background Art

[0002] Springs play an irreplaceable role in various industrial fields, such as shock absorption and automatic reset. During the production process, due to some technical factors, a variety of defects may appear on the end faces of the springs. Therefore, it is necessary to identify and detect defective springs to prevent system operation problems during assembly and operation. Defect detection based on traditional image processing has the advantages of high efficiency, good real-time performance, and high degree of automation. However, there are problems such as low algorithm flexibility and the need for a sufficient number of templates with good quality, which makes it difficult to cope with a wide variety of defect recognition. Machine learning has powerful recognition capabilities. Compared with traditional image processing algorithms, it can automatically learn effective feature representations from data. Even in the case of complex backgrounds or noise, it can effectively identify and classify images, which can greatly improve the accuracy of defect recognition.

[0003] The training of machine learning models mostly requires a sufficient number of samples. However, it is difficult to collect a large number of defect samples in the industrial production process, which makes the training of machine learning models more difficult. Therefore, how to use small samples to still train accurate defect recognition models is an urgent problem to be solved. Summary of the invention

[0004] The purpose of the present invention is to propose a feature enhancement method through feature analysis of good and defective spring images, provide a reliable classification detection and recognition algorithm, perform defect detection on the spring end surface, and realize a high-accuracy defect recognition model based on small sample training.

[0005] In order to solve the above technical problems, the technical solution created by the present invention is implemented as follows:

[0006] A feature enhancement classification and recognition algorithm for spring end surface defect detection, the specific steps are:

[0007] Step 1: Extract sub-images: extract sub-images of the original image of the spring end surface, identify and detect the area to be observed, and obtain identified sub-images;

[0008] Step 2: Gaussian filtering: Gaussian blur all the obtained recognized sub-images to denoise the image and avoid pixel offset and disturbance introduced by noise;

[0009] Step 3: Threshold processing and image erosion: First, the Gaussian blurred image is converted into a binary image, and then image erosion is performed to further eliminate pixels in the image that do not clearly represent defect features;

[0010] Step 4: extracting the entire contour of the image: extracting the entire contour of the image obtained in step 3;

[0011] Step 5 draws all the contours, and draws line images from all points on the entire contour of the image to the center, forming a complete contour line image to achieve feature enhancement of the spring end surface defects;

[0012] Step 6: Label the positive and negative samples: For all the contour line images output in step 5, use the binary method to classify and label the good positive samples and defective negative samples;

[0013] Step 7 extracts the HOG features of the histogram of oriented gradients of the positive and negative samples: calculates the HOG data of all the contour line images output in step 5 and converts them into a one-dimensional vector;

[0014] Step 8: training the support vector machine model: the one-dimensional vector outputted in step 7 and the corresponding annotation label prepared in step 6 are used for training the support vector machine model to obtain a classification and recognition model that can be used for spring end face defect detection.

[0015] Moreover, the specific steps of step 4 are: extracting all contours of the image and recording the coordinates of all contour pixel points.

[0016] Moreover, the specific steps of step 5 are:

[0017] Draw all contours and straight lines from all points on the contours to the center of the image, and analyze all contour line images; by drawing all points and the lines to the center, a feature image is formed that is easier to distinguish between good products and defects, thereby achieving feature enhancement of spring end surface defects.

[0018] Moreover, the specific steps of step 6 are: identifying the features of good positive samples and defective negative samples, and marking the corresponding labels, marking good products as 1 and defects as -1, and dividing good products and defects.

[0019] Moreover, the specific steps of step 7 are: calculating the HOG data of all contour line images output by step 5 and converting them into one-dimensional vectors. HOG is an image feature descriptor that constructs features by calculating and counting the gradient direction histogram of the local area of ​​the image, and can describe the shape and texture information of the target.

[0020] Moreover, the specific steps of step 8 are: training the support vector machine model: using the one-dimensional HOG feature data vector outputted in step 7 and the corresponding annotation label prepared in step 6 for SVM model training, and finally obtaining a classification and recognition model that can be used for spring end face defect detection.

[0021] An electronic device comprises a processor and a memory, wherein the memory is used to store instructions, and the processor is used to execute the instructions stored in the memory so that the electronic device executes any one of the methods described above.

[0022] A computer-readable storage medium stores instructions, and when the instructions are executed, any one of the above methods is executed.

[0023] The advantages and positive effects of the present invention are:

[0024] The method of the present invention is suitable for spring end face defect recognition and detection. The spring end face image is processed by a feature enhancement-assisted machine learning model to accurately identify defects. Specifically, it has the following advantages:

[0025] (1) The method of the present invention enhances the features of the spring end surface defect image and improves the accuracy of defect recognition.

[0026] (2) The method of the present invention does not require manual setting of reference frames, lines, etc. for image processing, and completely relies on the structural features of the spring end face to achieve automatic identification of end face defects.

[0027] (3) The method of the present invention has no strict requirements on the position and angle of the spring end face in the image. The spring can be placed arbitrarily within the field of view, and the method will perform processing adaptively. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 is a flow chart of a method in an embodiment of the present invention.

[0029] Figure 2 The images of the end faces of good and defective springs. (a) is a good spring, and (b) is a defective spring.

[0030] Figure 3 This is the first step of the method in the example of the present invention, and the processing result diagram of the original image sub-image is extracted, where (a) is a good spring and (b) is a defective spring.

[0031] Figure 4 This is the second step of the method in the example of the present invention, and the result of Gaussian blurring the image is shown in Figure 1. (a) is a good spring, and (b) is a defective spring.

[0032] Figure 5This is the fourth step of the method in the example of the present invention, and the processing result diagram of threshold processing and image corrosion is shown in Figure 1. (a) is a good spring, and (b) is a defective spring.

[0033] Figure 6 This is the fifth step of the method in the example of the present invention, and is a processing result diagram of extracting all the contours of the image. (a) is a good spring, and (b) is a defective spring.

[0034] Figure 7 This is the sixth step of the method in the example of the present invention, and the processing result diagram of the lines from each point on the entire contour of the image to the center is drawn. (a) is a good spring, and (b) is a defective spring.

[0035] Figure 8 It is a comparative data diagram of the method in the example of the present invention and other types of image features used in defect recognition experiments. DETAILED DESCRIPTION

[0036] In order to make the purpose, technical solution and advantages of the present application clearer and easier to understand, the present invention is further described below in conjunction with the accompanying drawings and specific implementation methods. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0037] A feature enhancement classification and recognition algorithm for spring end surface defect detection, see Appendix Figure 1 As shown, the specific steps are:

[0038] Step 1: Extract sub-images: Since there are too many irrelevant feature points in the original image, it is necessary to identify and detect the area to be observed, so the patented method first processes the original image. First, extract the sub-image of the original image and extract the area to be identified and detected. Extracting a more accurate detection and recognition area, reducing irrelevant feature points, and shrinking the recognition area will help enhance the model's learning of image feature distinction. The original images of good and defective springs are shown in the attached figure. Figure 2 As shown in the figure, the schematic diagram of extracting sub-graphs in step 1 is shown in the attached Figure 3 shown.

[0039] Step 2: Gaussian filtering: Gaussian blur all the obtained sub-images. Gaussian blur can denoise the image and avoid pixel offset and disturbance introduced by noise. At the same time, Gaussian blur can smooth the image, thereby enhancing the robustness of the subsequent algorithm. Figure 4 shown.

[0040] Step 3: Threshold processing and image erosion: First, convert the Gaussian blurred image into a binary image, and then perform image erosion to further eliminate pixels in the image that do not clearly represent defect features.

[0041] Step 4: Extract all the contours of the image: Extract all the contours of the image and record the coordinates of all the contour pixels. See the attached figure for the processing results. Figure 5 shown.

[0042] Step 5 draws all contours and straight lines from each point to the center of the image: Draw lines from each point on all contours to the center. The distances from the points on each image of good products to the points in the center of the image are not much different, and the distribution is relatively uniform. The distances from the points on each image of defects to the points in the center of the image are quite different, and the distribution is messy. Therefore, by drawing each point and the lines to the center, a feature image that is easier to distinguish between good products and defects is formed, thereby realizing the feature enhancement of the spring end surface defects of the present invention. The image with enhanced features of the present invention is hereinafter referred to as the full contour line image. See the attached figure for the processing results. Figure 6 shown.

[0043] Step 6: Label the positive and negative samples: For all the contour line images output in step 5, use the binary method to classify the good positive samples and defective negative samples, and identify the features of the positive and negative samples. Label the positive and negative samples, with good samples marked as 1 and defects marked as 0, and divide the good products into defects. See the attached figure for the processing results. Figure 7 shown.

[0044] Step 7: Extract the HOG features of the positive and negative samples: Calculate the HOG data of all contour line images output in step 5 and convert them into one-dimensional vectors. HOG is an image feature descriptor that constructs features by calculating and counting the gradient direction histogram of the local area of ​​the image, and can describe the shape and texture information of the target. It has good invariance to the geometric and optical deformation of the image. The basic steps are as follows:

[0045] (1) Use Gamma correction method to enhance the contrast of the image:

[0046] I2(x,y)=I1(x,y) gamma (1)

[0047] Where gamma represents the correction value. (x, y) represents the two-dimensional coordinates of the image pixel, I1(x, y) represents the pixel grayscale value before correction, and I2(x, y) represents the pixel grayscale value after correction.

[0048] (2) Calculate image gradient

[0049] For the input image, calculate the horizontal and vertical gradients of the image at the pixel point (x, y):

[0050] G x(x,y)=I2(x+1,y)-I2(x-1,y) (2)

[0051] G y (x,y)=I2(x,y+1)-I2(x,y-1) (3)

[0052] In the formula, G x (x,y) and G y (x, y) are the horizontal gradient and the vertical gradient respectively; the gradient magnitude and gradient direction of the image at the pixel point (x, y) are expressed as G(x, y) and α(x, y) respectively:

[0053]

[0054] α(x,y)=tan -1 [G y (x,y) / G x (x,y)] (5)

[0055] (3) Constructing cell unit gradient histogram

[0056] The image is divided into several non-overlapping sub-images, denoted as cells, and the size of the cell is set to 8 × 8. The gradient direction value range (0°~180°) is divided into 9 intervals, and the gradient amplitude in each gradient direction interval in each cell is counted to construct the gradient histogram of each cell, thereby obtaining the 9-dimensional feature vector corresponding to each cell.

[0057] (4) Construct block feature vector and normalize it

[0058] The 2×2 adjacent cell feature vectors are combined into a 36-dimensional block feature vector and normalized.

[0059] (5) Generate HOG feature vector

[0060] Traverse all blocks in the image, collect the normalized feature vectors of each block, and concatenate them to form the final HOG feature vector.

[0061] Step 8: Training the Support Vector Machine (SVM) model: The one-dimensional HOG feature data vector output in the seventh step and the corresponding annotation label in the sixth step are used for SVM model training, and finally a classification and recognition model that can be used for spring end face defect detection is obtained.

[0062] In the SVM model, the hyperplane is used as the decision boundary of classification to distinguish samples of different categories. For the binary classification problem of the present invention, the two sides of the hyperplane are divided into positive and negative classes respectively. The learning strategy of SVM is to maximize the interval, that is, to find a hyperplane so that the distance from the sample point (support vector) closest to the hyperplane to the hyperplane is maximized. Construct a training sample set D = {(x1, y1), (x2, y2), (x3, y3), ..., (x n ,y n )},y i ∈{-1,+1}, where x i represents the i-th HOG feature vector, y i Represents x i The class label of (x i ,y i ) are sample points. The SVM hyperplane equation is as follows:

[0063]

[0064] Where w is the normal vector of the hyperplane and b is the displacement term of the hyperplane.

[0065] For the classification and recognition models of positive and negative classes, there are:

[0066]

[0067] In the sample space, the distance from a point to the hyperplane is Find w and b that satisfy the above constraints to maximize γ. From the mathematical relationship, we can see that maximizing ||w|| -1 , which is equivalent to minimizing ||w|| 2 , the SVM hyperplane can be obtained through the following function.

[0068]

[0069] The images of all contour lines with enhanced features of the present invention were used for comparison experiments with four other types of images containing features. During the experiment, the recognition models all used the HOG and SVM machine learning models with the same configuration.

[0070] Figure 8 (a) is an experimental data diagram using 170 good and defective spring end faces for training, all of which are used as test samples. The recognition accuracy of the method of the present invention is 100%, which is not achieved by the other four categories.

[0071] Figure 8 (b) is an experimental data diagram using 117 good and defective spring end faces for training and the remaining 53 images as test samples. The recognition accuracy of the method of the present invention is 93%, which is higher than that of the other four types of feature images.

[0072] The effectiveness of the method of the present invention is proved through comparative experiments.

[0073] The present application also provides an electronic device, which may include: at least one processor and at least one memory.

[0074] The processor may include one or more processing cores. The processor uses various interfaces and lines to connect various parts of the entire server, and executes various functions of the server and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory, and calling data stored in the memory.

[0075] Optionally, the processor can be implemented in at least one hardware form of digital signal processing (DSP), field programmable gate array (FPGA), and programmable logic array (PLA). The processor can integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display; and the modem is used to process wireless communications. It is understandable that the above-mentioned modem may not be integrated into the processor, but may be implemented separately through a chip.

[0076] Among them, the memory may include a random access memory (RAM) or a read-only memory (Read-Only Memory). Optionally, the memory includes a non-transitory computer-readable storage medium. The memory can be used to store instructions, programs, codes, code sets or instruction sets. The memory may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory may also be optionally at least one storage device located away from the aforementioned processor. The memory as a computer storage medium may include an operating system, a network communication module, a user interface module, and an application program for a method for diagnosing a fault of a worm gearbox.

[0077] The present application also provides a computer-readable storage medium, which stores instructions. When executed by one or more processors, the electronic device executes one or more of the methods described in the above embodiments.

[0078] In addition, each functional unit in the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0079] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: various media that can store program codes, such as USB flash drives, mobile hard drives, magnetic disks or optical disks.

[0080] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present invention. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application patent shall be subject to the attached claims.

Claims

1. A feature-enhanced classification and recognition algorithm for spring end surface defect detection. Features: The specific steps are: Step 1: Extract sub-images: extract sub-images of the original image of the spring end surface, identify and detect the area to be observed, and obtain identified sub-images; Step 2: Gaussian filtering: Gaussian blur all the obtained recognized sub-images to denoise the image and avoid pixel offset and disturbance introduced by noise; Step 3: Threshold processing and image erosion: First, the Gaussian blurred image is converted into a binary image, and then image erosion is performed to further eliminate pixels in the image that do not clearly represent defect features; Step 4: extracting the entire contour of the image: extracting the entire contour of the image obtained in step 3; Step 5 draws all the contours, and draws line images from all points on the entire contour of the image to the center, forming a complete contour line image to achieve feature enhancement of the spring end surface defects; Step 6: Label the positive and negative samples: For all the contour line images output in step 5, use the binary method to classify and label the good positive samples and defective negative samples; Step 7: Extract the HOG features of the histogram of directional gradients of positive and negative samples: Calculate the HOG data of all contour line images output in step 5 and convert them into one-dimensional vectors; Step 8: training the support vector machine model: the one-dimensional vector outputted in step 7 and the corresponding annotation label prepared in step 6 are used for training the support vector machine model to obtain a classification and recognition model that can be used for spring end face defect detection.

2. A feature enhancement classification and recognition algorithm for spring end surface defect detection according to claim 1, Features: The specific steps of step 4 are: extracting all contours of the image and recording the coordinates of all contour pixel points.

3. A feature enhancement classification and recognition algorithm for spring end surface defect detection according to claim 1, Features: The specific steps of step 5 are: Draw all contours and straight lines from all points on the contours to the center of the image, and analyze all contour line images; by drawing all points and the lines to the center, a feature image is formed that is easier to distinguish between good products and defects, thereby achieving feature enhancement of spring end surface defects.

4. The feature enhancement classification and recognition algorithm for spring end surface defect detection according to claim 1, Features: The specific steps of step 6 are: identifying the features of good product positive samples and defective negative samples, and marking them accordingly, with good products marked as 1 and defects marked as -1, to divide good products into defects.

5. The feature enhancement classification and recognition algorithm for spring end surface defect detection according to claim 1, Features: The specific steps of step 7 are: calculating the HOG data of all contour line images output by step 5 and converting them into one-dimensional vectors. HOG is an image feature descriptor that constructs features by calculating and counting the gradient direction histogram of the local area of ​​the image, and can describe the shape and texture information of the target.

6. A feature enhancement classification and recognition algorithm for spring end surface defect detection according to claim 1, Features: The specific steps of step 8 are: Training the support vector machine model: The one-dimensional HOG feature data vector output in step 7 and the corresponding annotation label in step 6 are used for SVM model training, and finally a classification and recognition model that can be used for spring end face defect detection is obtained.

7. An electronic device, comprising a processor and a memory, wherein the memory is used to store instructions, and the processor is used to execute the instructions stored in the memory, so that the electronic device executes the method described in any one of claims 1 to 6.

8. A computer-readable storage medium storing instructions, wherein when the instructions are executed, the method according to any one of claims 1 to 6 is executed.

Citation Information

Cited By

  • Spring surface defect detection method based on machine vision

    CN122312634A

  • A spring surface defect detection method based on machine vision

    CN122312634B