Metal button surface defect real-time detection method based on deep learning
Through the real-time detection method of metal button surface defects based on deep learning, combined with image preprocessing and innovative algorithms, the problem of insufficient detection accuracy and real-time performance in the existing technology is solved, and high-precision and real-time defect detection is achieved, suitable for complex backgrounds and resource optimization requirements.
Patent Information
- Application Number
- CN202411559485.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-02-14
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing automated surface defect detection technology has shortcomings in detection accuracy, boundary recognition, real-timeness and resource optimization, especially when dealing with complex defect shapes and lighting changes, it is prone to missed or missed detection.
Using the real-time detection method of metal button surface defects based on deep learning, through image preprocessing, deep learning network models and innovative algorithms (such as dynamically regulated progressive boundary construction, adaptive gradient mapping, Gaussian fitting details enhancement, multi-dimensional difference correction factors and Segmented defect area generation) for defect detection and optimization.
The detection accuracy of small-size defect areas is improved, the identification and refined processing of defect boundaries are optimized, real-time detection needs are met, and the dependence on computing resources is reduced.
Smart Images

Figure CN119444718A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of real-time detection methods for metal button surface defects, and more specifically, to a real-time detection method for metal button surface defects based on deep learning. Background Art
[0002] At present, surface defect detection of small parts such as metal buttons is of great significance in modern manufacturing. There are various types of surface defects on metal buttons, including scratches, dents, corrosion spots and impurities, and the existence of these defects will directly affect the appearance quality and performance of the product. Traditional manual detection methods have problems such as low efficiency, strong subjectivity and unstable accuracy, so automated detection methods have emerged. However, the existing automated surface defect detection technology still faces many technical bottlenecks, especially in terms of detection accuracy, boundary recognition, real-time performance and optimization of defect areas during the detection process.
[0003] Traditional automated inspection methods are mostly based on edge detection and image segmentation technology, usually through the Sobel operator, Canny edge detection and other classic image processing methods to identify the defect boundaries on the surface of metal buttons. These methods may achieve certain results when dealing with simple defects, but in the face of complex defect shapes or changes in lighting conditions, traditional algorithms often miss or misdetect. In addition, the classic segmentation algorithm lacks the ability to dynamically adjust the image boundaries, resulting in inaccurate boundary recognition and smooth boundaries, making it difficult to meet high-precision detection requirements. For example, the traditional method based on the Otsu adaptive threshold segmentation method is difficult to effectively distinguish subtle surface defects and is easily interfered by external noise, resulting in unsatisfactory overall detection results.
[0004] The introduction of deep learning technology has improved the accuracy of automated surface defect detection. In particular, the advantages of convolutional neural networks (CNN) in feature extraction have brought new possibilities for defect detection. However, most of the existing deep learning models are applied to macro-target recognition and classification tasks, and there are still shortcomings in the boundary recognition and fine processing of small-size defect areas. When detecting tiny defects such as metal buttons, traditional CNN models have difficulty in taking into account both detailed information and real-time detection. In addition, the existing deep learning models lack special optimization in defect boundary processing and local feature enhancement. The improvement of detection accuracy depends on large data sets and high computing power, and fails to effectively meet the needs of rapid detection and resource optimization. These problems have prompted people to need new detection methods to improve accuracy and real-time performance while reducing dependence on computing resources. Summary of the invention
[0005] The real-time detection method for metal button surface defects based on deep learning proposed in the present invention is optimized for the technical problems existing in the prior art.
[0006] The present invention provides a real-time detection method for metal button surface defects based on deep learning, comprising the following steps: acquiring an image of a metal button to be detected and preprocessing it, inputting the preprocessed image into a deep learning network model to extract defect areas, optimizing and verifying the extracted defect areas, and finally generating statistical results of defect detection.
[0007] Preferably, the image preprocessing includes background removal, contrast enhancement, denoising, image normalization and segmentation operations on the acquired metal button image to obtain a regional image of the metal button, and the regional image is stored in a regional matrix M, which is the input image data for subsequent defect detection.
[0008] Preferably, the deep learning network model includes a classification module, a region positioning module and a regression module. The classification module is used to screen the preprocessed image and determine whether there is a defective area. The region positioning module generates the coordinates and size information of the defect and inputs the preliminary region information of the defect into the regression module to further optimize the boundary of the defective area.
[0009] Preferably, the regression module comprises the following steps:
[0010] Based on the preliminary results of the classification module and the regional positioning module, the initial matrix of the defect boundary construction is obtained, and the defect boundary is constructed by a dynamically controlled progressive boundary constructor. The boundary constructor is
[0011]
[0012] Among them, B(x,y) is the defect boundary matrix of the preliminary construction, α is the boundary adjustment coefficient, which controls the dynamics of the boundary construction.
[0013] f(uv) is the edge gradient function of the image, which calculates the gradient of the image at the pixel point (u, v). β is the offset, which smoothes the boundary construction effect.
[0014] Preferably, the matrix after boundary construction is subjected to boundary mapping by adaptive gradient mapping transformation, and the mapping transformation function is:
[0015]
[0016] Among them, G(x,y) is the mapped boundary matrix, γ is the gradient adjustment parameter, which controls the response range of the gradient, and μ is the mapping offset, which adjusts the response of the boundary details.
[0017] Preferably, the details of the defect boundary are enhanced by a local detail enhancement function of Gaussian fitting, wherein the Gaussian fitting function is:
[0018]
[0019] Among them, H(x,y) is the defect boundary matrix after local enhancement, (x0,y0) is the core position of the defect boundary located by the Gaussian center, σ x and σ y They are the standard deviations in the horizontal and vertical directions, respectively, and control the range of Gaussian diffusion.
[0020] Preferably, the boundary is refined and corrected based on a multidimensional difference correction factor function, wherein the difference correction factor function is:
[0021]
[0022] Among them, C(x,y) is the corrected defect boundary matrix, λ is the difference adjustment coefficient, and M(x,y) is the original image matrix, which provides a reference for the actual boundary information. is the boundary gradient.
[0023] Preferably, a complete matrix of defect regions is generated by a segmented defect region generating function, wherein the generating function is:
[0024] R(xy)=θC(x,y)+(1-θ)M(x,y)
[0025] Among them, R(x, y) is the final defect area matrix generated, and θ is the weight parameter, which is used to balance the degree of fusion between the correction matrix C(x, y) and the original image matrix M(x, y) to ensure that the generated defect area is aligned with the actual image.
[0026] Preferably, the generated defect area matrix R(x,y) is verified, including the following steps: extracting the actual shape of the defect based on the region growing algorithm, and performing an intersection operation on the generated defect area matrix and the extracted real shape to verify the accuracy of the defect area, and comparing it with the gradient of the original image to determine the defect edge information.
[0027] Preferably, statistics are collected on the verified defective areas, including the number statistics of single-type defects and the category distribution statistics of multiple-type defects, and a defect proportion distribution report is generated. The obtained statistical results are used to support product quality analysis and production process improvement.
[0028] The invention has the following beneficial effects:
[0029] First, the area of the metal button is extracted and standardized through the image preprocessing step, which reduces noise interference from the source and ensures the consistency of detection. Then, the present invention innovatively introduces algorithms such as dynamically controlled progressive boundary construction, adaptive gradient mapping, Gaussian fitting detail enhancement, multi-dimensional difference correction factor and segmented defect area generation in sequence, so that boundary recognition and detail optimization are progressive. This innovative multi-level optimization design enables the data output of each step to be interconnected with the subsequent steps, ensuring the continuity and consistency of defect detection, and avoiding the boundary error and information loss problems caused by algorithm independence in traditional methods.
[0030] Among them, the introduction of the progressive boundary constructor effectively solves the boundary discontinuity problem caused by illumination differences or slight noise, so that the initially extracted defect boundary can cover the defect area more smoothly. Adaptive gradient mapping optimizes the clarity of the boundary through nonlinear mapping, so that the edges of subtle defects can be fully identified and distinguished. This process combines boundary adjustment with detail enhancement, achieves a smooth transition at the boundary, and ensures the clarity and consistency of the edge. The local detail enhancement algorithm of Gaussian fitting further improves the smoothness of the boundary, so that the detection area has better detail performance when extracted. The multi-dimensional difference correction factor dynamically corrects the boundary position for the edge blur and position drift problems that are difficult to eliminate with traditional algorithms, so that the identified defect area is more consistent with the actual shape. The final segmented defect area generation function effectively avoids the sawtooth effect in the image segmentation process through the overall smoothing and generation of the defect area, so that the generated defect area is more in line with the actual detection needs.
[0031] In summary, the technical problems solved by the present invention include:
[0032] Improve the detection accuracy of small-size defect areas and ensure effective identification of complex defects on the surface of metal buttons;
[0033] Optimize the recognition and refinement of defect boundaries, especially to achieve high-precision boundary fitting under the influence of complex background and noise;
[0034] Meet real-time detection requirements and reduce detection time and computing resource usage;
[0035] Through the collaborative work of multiple algorithm modules, the boundary discontinuity and data loss problems between independent algorithm modules are eliminated, and systematic optimization of defect detection is achieved.
[0036] The present invention realizes progressive optimization on multiple algorithm modules, making the data flow transmission in the detection process smoother, and solving the contradiction of strong independence of existing algorithm modules and serious information loss. Through these innovative means, the defect detection of the present invention shows significant technical advantages in accuracy, boundary refinement and real-time performance, and has obvious practical application value. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is the overall system block diagram of the present invention.
[0038] Figure 2 It is a logical block diagram of the deep learning network model of the present invention.
[0039] Figure 3 It is a logic block diagram of the defect area optimization algorithm of the present invention.
[0040] Figure 4 It is a logic block diagram of defect verification and statistics of the present invention. DETAILED DESCRIPTION
[0041] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the specific implementation methods, structures, features and effects thereof are described in detail below in conjunction with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0042] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0043] Please refer to Figure 1-4 The present invention provides a real-time detection method for metal button surface defects based on deep learning, aiming to achieve rapid and accurate identification of metal button surface defects through intelligent means. The core of the present invention is to use multi-step preprocessing, defect extraction of deep learning network model and defect optimization of innovative algorithm to achieve real-time and high-precision detection effect.
[0044] The real-time detection method for metal button surface defects based on deep learning of the present invention first obtains the surface image of the metal button to be detected. Through a series of preprocessing steps, including background removal, contrast enhancement, denoising and normalization of the image, the uniformity and consistency of the image quality are ensured, which is convenient for subsequent defect detection. The metal button area matrix generated by the preprocessing provides accurate area data for subsequent deep learning model input, avoids unnecessary image interference, and thus improves the overall detection accuracy. During the preprocessing process, a threshold parameter can be set to filter the noise signal. For example, when removing the background, an area with a pixel brightness value less than 10 is used as a threshold to reduce interference from irrelevant areas.
[0045] Furthermore, in the image preprocessing, the regional image of the metal button is segmented and stored in the regional matrix M. The size and aspect ratio of the metal button are screened by matrix traversal, so that the preprocessed regional image is more in line with the actual detection requirements. Preferably, in one embodiment of the present invention, the size threshold range can be set to 50 to 200 pixels, and the aspect ratio threshold range can be set to 0.8 to 1.2 to ensure the accuracy of the preprocessed image data, thereby eliminating interference from images that are too small or too large, and ensuring the accuracy of the detection results.
[0046] Furthermore, the deep learning network model 1 is used to process the preprocessed image. The model consists of a classification module, a region positioning module and a regression module, which work together to complete the defect extraction task. First, the classification module performs a preliminary screening of the input image to determine whether the image contains a defective area. Then, the region positioning module generates the coordinates and size information of the defective area based on the output of the classification module, and passes the preliminary defective area information as input to the regression module. Preferably, in one embodiment of the present invention, the classification module can be initialized based on the ResNet50 model to improve the defect screening accuracy, while the region positioning module locally marks the defective area based on the 7×7 convolution kernel, so that the preliminary positioning has higher accuracy.
[0047] Furthermore, the regression module further refines the defect boundary based on the initially located defect area to improve the accuracy of the final detection. Specifically, the defect area optimization algorithm of the present invention uses a dynamically controlled progressive boundary constructor The defect boundary is constructed, where: B(x, y) represents the constructed defect boundary matrix, α is the boundary adjustment coefficient, which is used to dynamically adjust the response degree of the boundary structure. The typical value can be taken as 0.8 to 1.2 to maintain the stability of the boundary structure under different image brightness, f(u, v) is the edge gradient function, which detects the gradient value of the image at the position (u, v), and β is the bias, which is used to smooth the boundary to make the boundary curve more coherent.
[0048] In practical applications, this constructor helps eliminate irregular edges and avoid the appearance of false boundaries by accumulating gradients layer by layer.
[0049] Furthermore, the defect boundary matrix B(x, y) is further transferred to the adaptive gradient mapping transformation module, and the mapping transformation function Improve the clarity of the boundary, where: G(x,y) is the mapped boundary matrix, γ is the gradient adjustment parameter, which is used to control the response range of the gradient, and the typical value is between 1 and 5 to balance the edge noise and detail information, and μ is the offset, which is used to refine the response of the boundary details, and is set to the mean of the boundary value in one embodiment of the present invention. Through this mapping transformation, the clarity of the boundary is optimized, thereby achieving further refinement of the defect area.
[0050] The details of the defect boundary are further enhanced by the local detail enhancement function of Gaussian fitting, and the formula is: Among them: H(x,y) is the defect boundary matrix after local enhancement, (x0,y0) is the core position of the defect boundary located by Gaussian center, which is set as the geometric center position of the defect area to make the detail enhancement effect more concentrated, σ x and σ y They are the lateral and longitudinal standard deviations of the Gaussian distribution, respectively, and can be set to 3 to 5 in a preferred embodiment to achieve smoothing of the defect boundary.
[0051] This Gaussian fitting operation is used to remove redundant boundary noise and make boundary details clearer, thereby improving the accuracy of the defect area.
[0052] Based on the defect boundary, the multi-dimensional difference correction factor function of the present invention refines the boundary and the formula is: Where: C(x, y) is the defect boundary matrix after the final correction, λ is the difference adjustment coefficient, which can be set to 0.5 to 0.8 in the preferred embodiment to enhance the boundary adjustment effect, is the boundary gradient, and M(x,y) is the original image matrix, which is used to provide a reference for the real boundary information. This correction factor function adaptively adjusts the noise and slight errors in the image, making the boundary more consistent with the actual defect area.
[0053] The segmented defect area generation function R(x,y)=θC(x,y)+(1-θ)M(x,y) is used to generate the final defect area matrix, where: R(x,y) is the generated defect area matrix, θ is the weight parameter, which is 0.6 to 0.9 in the preferred embodiment to control the fusion ratio of the correction matrix C(x,y) and the original image matrix M(x,y), C(x,y) is the corrected defect boundary, and M(x,y) is the original image matrix. Through this generation function, the defect area is consistent with the boundary of the actual image, ensuring the integrity of the defect area.
[0054] Furthermore, the generated defect region R(x,y) is verified by a region growing algorithm. The verification process includes extracting the defect shape from the original image again using the region growing algorithm, and performing an intersection operation with the generated defect region R(x,y) to confirm the accuracy of the defect region. In a preferred embodiment, the gradient information of the image can also be compared to ensure that the detected defect boundary is highly consistent with the real boundary to avoid false detection and missed detection.
[0055] For the verified defective areas, the present invention further performs defect statistics. The statistical content includes the number statistics and proportion calculation of single-class and multi-class defects, generates defect distribution reports, and supports subsequent production quality analysis and improvement. Preferably, in one embodiment of the present invention, classification labels can be set to mark and calculate the number of defects of each type, providing a reference basis for subsequent processes.
[0056] In order to verify the superiority of the real-time detection method for metal button surface defects based on deep learning in the present invention in terms of detection accuracy and real-time performance, we selected an embodiment and a comparative example and tested them based on a professional metal surface defect detection data set. The data set includes surface images of metal buttons in a variety of real scenes, covering a variety of common defect types (such as scratches, dents, oxidation spots, etc.). The main performance indicators used in this test are detection accuracy, defect boundary positioning accuracy, and detection real-time performance, which respectively reflect the accuracy of the detection method, boundary recognition accuracy, and support for real-time applications.
[0057] The testing standards and methods are as follows:
[0058] 1. Detection accuracy: Accuracy is defined as the ratio of the intersection area of the detected real defect area and the standard defect area to the area of the standard defect area. The standard is set as an accuracy of ≥ 95% for excellent.
[0059] 2. Boundary Precision: The positioning accuracy evaluates the overlap between the defect area boundary and the actual defect area boundary, and the standard is boundary error ≤ 3 pixels. This item evaluates the effect of the defect boundary optimization algorithm on the refinement of the defect edge.
[0060] 3. Detection Time: Detection time is expressed as the time required to process an image. The standard is detection time ≤ 0.5 seconds to meet the real-time detection needs in industrial production.
[0061] The specific comparison between the embodiment and the comparative example is as follows:
[0062] Example 1: This example is based on the innovative algorithm of the present invention, including a dynamically controlled progressive boundary constructor, an adaptive gradient mapping transformation, a local detail enhancement of Gaussian fitting, a multidimensional difference correction factor, and a segmented defect area generation function. The recognition and detail enhancement of the defect area boundary are optimized, and a deep learning network model (ResNet50 classification model, 7×7 convolution kernel area positioning module and regression module) is used to extract the overall defect area.
[0063] Comparative Example 1: A conventional detection method based on image segmentation and edge detection is used, combined with the Sobel operator and the Otsu adaptive threshold segmentation method. The optimization algorithm module of the present invention is not included, and a conventional convolutional neural network (CNN) model is used for defect detection and boundary recognition.
[0064] The test was conducted under the same data set conditions, and the results are shown in the following table:
[0065] project Example 1 Comparative Example 1 Detection accuracy (%) 97.6 84.2 Defect boundary positioning accuracy (pixels) 2 6 Detection real-time performance (seconds) 0.42 0.8
[0066] It can be seen from the above test results that the embodiment is significantly better than the comparative example in terms of detection accuracy, defect boundary positioning accuracy and detection real-time performance. The specific analysis is as follows:
[0067] 1. Detection accuracy: The detection accuracy of the embodiment reached 97.6%, while that of the comparison example was only 84.2%. This gap shows that the method of the present invention has significant advantages in accurately identifying surface defects of metal buttons. This is mainly due to the innovative algorithms introduced in the present invention, such as the dynamically controlled progressive boundary constructor and the adaptive gradient mapping transformation, which significantly improve the accuracy of boundary recognition and reduce the false detection rate.
[0068] 2. Defect boundary positioning accuracy: The defect boundary positioning accuracy of the present invention is 2 pixels, which is significantly better than the 6 pixels of the comparative example. The improvement of this indicator shows that the Gaussian fitting local detail enhancement and multi-dimensional difference correction factor in the present invention have better performance in boundary recognition, making the boundary of the defect area more consistent with the real shape. Higher boundary accuracy not only improves the effectiveness of defect detection, but also provides more accurate data support in subsequent quality analysis.
[0069] 3. Real-time detection: The detection time of the embodiment for a single image is 0.42 seconds, which is significantly better than the 0.8 seconds of the comparative example. This shows that the method of the present invention not only improves the accuracy and precision of detection, but also meets the requirements of real-time detection, and can meet the needs of rapid detection in industrial production. Since the algorithm design in the present invention is optimized, especially the innovative segmented defect area generation function, the boundary generation and data processing speed are faster, thereby achieving a higher real-time detection performance.
[0070] In summary, the present invention is superior to traditional methods in terms of detection accuracy, boundary positioning accuracy and detection real-time performance, effectively improving the effect of metal button surface defect detection, and is suitable for industrial scenarios that require efficient, precise and real-time detection.
[0071] It should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A real-time detection method for metal button surface defects based on deep learning, characterized in that: The following steps are involved: The image of the metal button to be inspected is obtained and preprocessed. The preprocessed image is input into the deep learning network model to extract the defect area, and the extracted defect area is optimized and verified to finally generate the statistical results of defect detection.
2. The real-time detection method for metal button surface defects according to claim 1, characterized in that: The image preprocessing includes background removal, contrast enhancement, denoising, image normalization and segmentation operations on the acquired metal button image to obtain a regional image of the metal button, and the regional image is stored in a regional matrix M, which is the input image data for subsequent defect detection.
3. The real-time detection method for metal button surface defects according to claim 1 or 2, characterized in that: The deep learning network model includes a classification module, a region positioning module and a regression module. The classification module is used to screen the preprocessed image and determine whether there is a defective area. The region positioning module generates the coordinates and size information of the defect and inputs the preliminary region information of the defect into the regression module to further optimize the boundary of the defective area.
4. The real-time detection method for metal button surface defects according to claim 3, characterized in that: The regression module includes the following steps: Based on the preliminary results of the classification module and the regional positioning module, the initial matrix of the defect boundary construction is obtained, and the defect boundary is constructed by a dynamically controlled progressive boundary constructor. The boundary constructor is Among them, B(x,y) is the defect boundary matrix of the preliminary construction, α is the boundary adjustment coefficient, which controls the dynamics of the boundary construction. f(uv) is the edge gradient function of the image, which calculates the gradient of the image at the pixel point (u, v). β is the offset, which smoothes the boundary construction effect.
5. The real-time detection method for metal button surface defects according to claim 4, characterized in that: The boundary mapping is performed on the matrix after boundary construction by adaptive gradient mapping transformation. The mapping transformation function is: Among them, G(x,y) is the mapped boundary matrix, γ is the gradient adjustment parameter, which controls the response range of the gradient, and μ is the mapping offset, which adjusts the response of the boundary details.
6. The real-time detection method for metal button surface defects according to claim 5, characterized in that: The details of the defect boundary are enhanced by the local detail enhancement function of Gaussian fitting, and the Gaussian fitting function is: Among them, H(x,y) is the defect boundary matrix after local enhancement, (x0,y0) is the core position of the defect boundary located by the Gaussian center, σ x and σ y They are the standard deviations in the horizontal and vertical directions, respectively, and control the range of Gaussian diffusion.
7. The real-time detection method for metal button surface defects according to claim 6, characterized in that: The boundary is refined and corrected based on a multi-dimensional difference correction factor function, where the difference correction factor function is: Among them, C(x,y) is the corrected defect boundary matrix, λ is the difference adjustment coefficient, and M(x,y) is the original image matrix, which provides a reference for the actual boundary information. is the boundary gradient.
8. The real-time detection method for metal button surface defects according to claim 7, characterized in that: The complete matrix of defect regions is generated by a piecewise defect region generation function, where the generation function is R(xy)=θC(x,y)+(1-θ)M(x,y) Among them, R(x,u) is the final defect area matrix generated, and θ is the weight parameter, which is used to balance the degree of fusion between the correction matrix C(x,y) and the original image matrix M(x,y) to ensure that the generated defect area is aligned with the actual image.
9. The method for real-time detection of metal button surface defects according to claim 8, characterized in that: The generated defect area matrix R(x,y) is verified, including the following steps: extracting the actual shape of the defect based on the region growing algorithm, and performing an intersection operation on the generated defect area matrix and the extracted real shape to verify the accuracy of the defect area, and comparing it with the gradient of the original image to determine the defect edge information.
10. The real-time detection method for metal button surface defects according to claim 9, characterized in that: Statistics are collected on verified defect areas, including the number of single-type defects and the category distribution statistics of multiple-type defects, and defect proportion distribution reports are generated. The statistical results are used to support product quality analysis and production process improvement.
Citation Information
Cited By
Railway track fastener defect detection method, system and device and medium
CN120259287A
Intelligent monitoring method and system for injection molding of automobile parts
CN120598962A
An intelligent monitoring method and system for injection molding of automobile parts
CN120598962B