Surface defect detection method based on channel enhancement and feature reconstruction
Through three-channel feature reconstruction technology, the R, G, and B channels of the image are randomly enhanced and smoothed to generate fusion images, which solves the problems of insufficient training data and background interference in the YOLO algorithm, and improves the accuracy and accuracy of surface defect detection.
Patent Information
- Application Number
- CN202510436839.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-09
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2045-04-09
AI Technical Summary
The existing YOLO series algorithms have problems such as difficult to collect training data samples and small number in surface defect detection, and the defect characteristics are not obvious and complex background texture interference leads to insufficient detection accuracy and accuracy.
Three-channel feature reconstruction technology is used to perform random channel feature enhancement and Gaussian smoothing processing on the R, G, and B channels of the image, and the fusion image is generated through weighted fusion, which enhances the contrast of defect features and suppresses background texture, and is input to the YOLO network for detection.
It significantly improves the generalization ability and robustness of the model, improves the defect detection rate and detection accuracy, reduces background noise interference, and improves the ability to identify small defects.
Smart Images

Figure CN120298374A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of surface defect detection, and particularly relates to a surface defect detection method based on channel enhancement and feature reconstruction. Background Art
[0002] Surface defect detection is an extremely important application field in the quality control of manufacturing. With the improvement of manufacturing automation, higher and higher requirements are put forward for surface defect detection on the production line. Traditional surface defect detection methods mainly rely on machine vision algorithms. Its basic principle is to obtain the surface image of the object to be detected through cameras, optical sensors, etc., and use image processing technology to identify defects. Image processing technology mainly includes methods such as edge detection, texture analysis, gray histogram analysis, morphological processing, template matching, and Hough transform. However, these methods have common limitations, such as insufficient detection ability for complex textures, sensitivity to light changes, and limited recognition accuracy for tiny defects. In recent years, the successful application of deep learning in computer vision has made the surface defect detection method based on convolutional neural network (CNN) gradually become the mainstream. CNN can automatically learn multi-level feature expressions of images, so as to still maintain a high detection accuracy in complex environments. Among them, the YOLO algorithm series is particularly suitable for surface defect detection scenarios of real-time monitoring and large-scale production lines due to its fast and efficient detection ability.
[0003] Although the YOLO series of object detection deep learning algorithms have more advantages than traditional image processing algorithms when applied to the defect detection of ceramic bottles, the YOLO series of algorithms, especially the YOLOv8 algorithm, are still limited by the quantity of training data and the quality of defect features, and there are still many problems:
[0004] 1) Difficult to collect and small quantity of training data samples: In actual production, surface defects (such as black and white dots, color bars, pits, bulges, oil stains, indentations, etc.) are usually sporadic and randomly distributed, making it very difficult to obtain enough defect samples. At the same time, the production line is large-scale, and real-time collection of high-resolution image data requires expensive equipment and complex arrangements, and manual annotation of defect data is also very time-consuming. In addition, some defect types may occur very rarely, resulting in the model being prone to overfitting to frequently occurring categories during training, and having poor detection effects on rare types of defects.
[0005] 2) Problem of very unclear surface defect features: The surface of the material usually has complex and irregular textures. The intensity and morphology of these textures may be extremely similar to those of the defect area, making it difficult to effectively distinguish the defects. Moreover, the defect area may only account for a small part of the image (diameter 0.1 mm), and its morphology also has a high degree of variability, such as black and white dots, lines, pits, and bulges. Changes in lighting conditions (such as light and shadow, reflection, etc.) may cover up or blur the defect features, further exacerbating the detection difficulty.
[0006] 3) Problem of background interference after enhancing defect features due to irregular surface patterns: When enhancing the defect features, the irregular patterns may be enhanced simultaneously, making it more difficult for the model to distinguish between defects and background patterns. Moreover, a large amount of high-frequency information (such as edges, lines) is contained in the irregular surface patterns, and these information may be misinterpreted as defect features after enhancement, thus increasing the false alarm rate of detection. In addition, a large number of invalid or noise features may be introduced during the enhancement process, further interfering with the model's judgment. Summary of the Invention
[0007] To solve the above problems, the present invention provides a surface defect detection method based on channel enhancement and feature reconstruction. The specific scheme includes the following steps:
[0008] S1. Obtain the original image;
[0009] S2. Process any channel image of the original image through a random channel feature enhancement method to obtain an enhanced channel map;
[0010] S3. Perform Gaussian smoothing on any channel image of the two unselected channel images of the original image in step S2 to obtain a background texture suppression channel map;
[0011] S4. Perform brightness balancing processing on the last unprocessed channel image to obtain a brightness balanced channel map;
[0012] S5. Perform weighted fusion on the enhanced channel map, the background texture suppression channel map, and the brightness balanced channel map to obtain a fused image;
[0013] S6. Input the fused image into a trained defect detection model to obtain a detection result. The defect detection model is constructed using the YOLO network.
[0014] Further, the specific process of step S2 includes:
[0015] S21. Randomly select one of the three channel images of the R channel image, the G channel image, and the B channel image of the original image as the feature image;
[0016] S22. Perform contrast-limited adaptive histogram equalization on the feature image to obtain an enhanced feature map;
[0017] S23. Adjust the brightness and contrast of the enhanced feature map to obtain an enhanced channel map.
[0018] Further, the contrast adjustment of the enhanced feature map in step S23 is expressed as
[0019]
[0020] where, I′ s represents the enhanced channel map, represents the enhanced feature map, α represents the contrast factor, β represents the contrast offset, and μ represents the average brightness of the enhanced feature map.
[0021] Further, the Gaussian smoothing of any channel image in step S3 is expressed as
[0022]
[0023] where, I smooth (x, y) represents the value of the pixel point (x, y) in the channel image after Gaussian smoothing, σ represents the standard deviation, k represents the radius of the Gaussian kernel; I(x + i, y + j) represents the pixel value at the pixel point (x, y) in the channel image, and i, j are independent variables.
[0024] Further, in step S5, the enhanced channel map, the background texture suppression channel map, and the brightness balance channel map are weighted and fused to obtain a fused image, which is expressed as
[0025] I final = ω j · E j + ω k · P k + ω l · P l
[0026] where, I final represents the fused image, E j represents the enhanced channel map, P k represents the background texture suppression channel map, P l represents the brightness balance channel map; ω j 、ω k 、ω l are weighting coefficients, ω j = 0.5, ω k = 0.35, ω l = 0.15.
[0027] The beneficial effects of the present invention:
[0028] The present invention proposes a three-channel feature reconstruction technique that processes and fuses the three channels of an image separately. Among them, for a certain channel image, a random channel feature enhancement method is applied for single-channel feature enhancement. By randomly selecting and enhancing the channels of the existing image, not only the dilemma of insufficient sample quantity is avoided, but also more new samples with diverse features are generated through virtual augmentation. Such enhanced samples can help the target detection model better learn different features, thereby improving its adaptability to defective samples and significantly enhancing the generalization ability and robustness of the model.
[0029] Through the random channel feature enhancement technique of the present invention, the contrast of defective features in any channel is enhanced, making the difference between the defective area and the background more significant and enhancing the target detection model's perception ability of tiny defective features. At the same time, the three-channel feature reconstruction technique effectively avoids the interference of background features on defective features by independently modeling the features of each channel (such as texture changes, brightness differences, and defective area enhancement), improves the consistency of the defective area in multiple channels, and significantly improves the defective detection rate and detection accuracy.
[0030] The detected surface background often has irregular textures and complex patterns, which are likely to interfere with the recognition of defects. Through the random channel feature enhancement technique, only the randomly selected single channel is subjected to feature enhancement, avoiding excessive amplification of background textures. In addition, the three-channel feature reconstruction technique reduces the interference of background noise on defect recognition by separating the background and defective features and applying an inhibitory weight to the background features in different channels, significantly improving the detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 is a flowchart of the method of the present invention;
[0032] Figure 2 is a comparison diagram of the results of the embodiments of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0033] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0034] The present invention proposes a surface defect detection method based on channel enhancement and feature reconstruction, in which a three-channel feature reconstruction technique is designed. By randomly enhancing and reconstructing the features of the three channels (R, G, B channels) of an image, it helps the model achieve effective virtual data augmentation, improve the prominence of defective features, and reduce background interference in the case of scarce data, asFigure 1 As shown in Figure 1 , it includes the following steps:
[0035] S1. Obtain the original image.
[0036] S2. Process any channel image of the original image through a random channel feature enhancement method to obtain an enhanced channel map.
[0037] Specifically, the present invention particularly proposes a random channel feature enhancement method in the three-channel feature reconstruction technology. The random channel feature enhancement method can enhance the defective features in a single-channel map of the image, that is, amplify the difference between the defective area and the background, enabling the model to more easily perceive tiny defective features. Using the random channel enhancement method to enhance the unobvious defective features can make the object detection (YOLO) model more easily learn the unobvious features and thus improve the detection rate of the model.
[0038] The specific process of step S2 includes:
[0039] S21. Randomly select one of the three channel images, namely the R-channel image, G-channel image, and B-channel image of the original image, as the feature image.
[0040] S22. Perform contrast-limited adaptive histogram equalization (CLAHE) on the feature image to obtain an enhanced feature map.
[0041] Specifically, step S22 includes:
[0042] S221. Divide the feature image into 16×16 small blocks, and calculate the gray value histogram of each small block, where
[0043]
[0044] H k (g) represents the number of pixel points with pixel value g in the kth small block, N k represents the total number of pixel points in the kth small block, I k (i) represents the pixel value of the ith pixel point in the kth small block; δ( ) represents the indicator function. When I k (i) = g, δ(g - I k (i)) = 1, otherwise it is 0.
[0045] S222. To avoid over-enhancing the feature image and introducing noise, a contrast-limiting calculation is added during the calculation. Usually, the local histogram of each small block is clipped, that is, the peak value of the histogram is limited to prevent over-enhancement of certain gray levels. If the cumulative frequency of a certain gray level g is greater than the set limit value T (usually set as a threshold), it is clipped by 1 so that the cumulative frequency of each gray level does not exceed this limit.
[0046] S223. Calculate the cumulative distribution function (CDF, Cumulative Distribution Function) of the small block according to the cropped grayscale value histogram, denoted as
[0047]
[0048] H′ k (j) = min(H k (j), T)
[0049] where CDF k (g) represents the cumulative distribution function of the k-th small block; H′ k (j) represents the number of pixel points with pixel value g in the k-th small block after cropping;
[0050] S224. Normalize the cumulative distribution function to the range of 0 to L - 1 to obtain the equalized output, denoted as
[0051]
[0052] where CDF k (0) is the minimum cumulative distribution value of the k-th small block, CDF k (L - 1) is the maximum cumulative distribution value of the k-th small block, CDF′ k (g) is the result of equalization, and L represents the gray level of the feature image.
[0053] S225. Merge these small blocks into a complete image according to the equalized output, and perform smooth transition according to the edges of the small blocks to avoid obvious splicing traces, obtaining an enhanced feature map.
[0054] S23. Adjust the brightness and contrast of the enhanced feature map to obtain an enhanced channel map.
[0055] Specifically, the contrast adjustment of the enhanced feature map in step S23 is expressed as
[0056]
[0057] where I′ represents the enhanced channel map, represents the enhanced feature map, α represents the contrast factor, β represents the contrast offset, and μ represents the average brightness of the enhanced feature map.
[0058] S3. Perform Gaussian smoothing on any one of the two channel images not selected in the original image in step S2 to obtain a background texture suppression channel map.
[0059] Specifically, in traditional object detection tasks, the features of each channel often have a certain degree of redundancy. Especially during the three-channel enhancement process, the mixing of background information and defect information may lead to a decrease in detection accuracy. The three-channel feature reconstruction technology of the present invention reconstructs the defect features in different channels into independent feature representations (for example, channel 1 captures texture changes, channel 2 focuses on brightness differences, and channel 3 enhances defect features). In this way, it reduces the problem that the background information masks the defect features through the random channel feature enhancement technology, resulting in a decrease in the detection rate of the object detection model. Through three-channel feature reconstruction, the consistency of unobvious defect features in the multi-channel dimension is strengthened, enabling effective modeling of unobvious defect areas and improving the detection rate of the object detection (YOLO) model. The enhancement goals of these channels are to maintain specific features while avoiding excessive background interference. Therefore, different mathematical calculation processes are performed on different channels.
[0060] Step S3 performs Gaussian smoothing on any channel image to suppress background texture information, expressed as
[0061]
[0062] where I smooth (x,y) represents the value of the pixel point (x,y) in the channel image after Gaussian smoothing, σ represents the standard deviation, and k represents the radius of the Gaussian kernel; I(x+i,y+j) represents the pixel value at the pixel point (x,y) in the channel image, and i, j are independent variables.
[0063] S4. Perform brightness balancing processing on the last unprocessed channel image P to avoid the influence of the brightness difference between the background and defects on feature extraction, and obtain the brightness-balanced channel map P l , which can be expressed as
[0064] P l =α'·P + β'
[0065] where α' represents the brightness factor and β' represents the brightness offset. Through this method, channel C l will enhance the brightness information, thereby enhancing the contrast between the defect area and the background and reducing background interference.
[0066] S5. Perform weighted fusion on the enhanced channel map, the background texture suppression channel map, and the brightness-balanced channel map to obtain a fused image.
[0067] Specifically, step S5 performs weighted fusion on the enhanced channel map, the background texture suppression channel map, and the brightness-balanced channel map to obtain a fused image, expressed as
[0068] I final =ω j ·E j +ωk ·P k +ω l ·P l
[0069] Among them, I final represents the fused image, E j represents the enhancement channel map, P k represents the background texture suppression channel map, P l represents the brightness balance channel map; ω j , ω k , ω l are weighting coefficients, ω j = 0.5, ω k = 0.35, ω l = 0.15. After the fused image I final is the result image after feature enhancement, background suppression, and brightness balance processing, as Figure 2 shown. This image has a more significant contrast in the defect area, while the influence of noise or texture in the background area is weakened. Therefore, the deep learning model (YOLO) can more easily learn and identify defects.
[0070] S6. Input the fused image into the trained defect detection model to obtain the detection result, and the defect detection model is constructed using the YOLO network.
[0071] During both the training process and the inference process, after image processing and before model inference, the preprocessed image is subjected to three-channel feature reconstruction to obtain the fused image.
[0072] In the present invention, unless otherwise clearly specified and limited, terms such as "installation", "setting", "connection", "fixation", "rotation", etc. should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or integrated; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium, and it can be the internal connection of two components or the interaction relationship between two components. Unless otherwise clearly limited, for those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0073] Although the embodiments of the present invention have been shown and described, for those of ordinary skill in the art, it can be understood that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A surface defect detection method based on channel enhancement and feature reconstruction, characterized in that Including the following steps: S1. Obtain the original image; S2. Process any channel image of the original image through a random channel feature enhancement method to obtain an enhanced channel map; S3. Perform Gaussian smoothing on any one of the two unselected channel images of the original image in step S2 to obtain a background texture suppression channel map; S4. Perform brightness balance processing on the last unprocessed channel image to obtain a brightness balance channel map; S5. Perform weighted fusion on the enhanced channel map, the background texture suppression channel map, and the brightness balance channel map to obtain a fused image; S6. Input the fused image into a trained defect detection model to obtain a detection result, and the defect detection model is constructed using the YOLO network.
2. The surface defect detection method based on channel enhancement and feature reconstruction according to claim 1, characterized in that, The specific process of step S2 includes: S21. Randomly select one of the three channel images, namely the R-channel image, the G-channel image, and the B-channel image of the original image, as the feature image; S22. Perform contrast-limited adaptive histogram equalization on the feature image to obtain an enhanced feature map; S23. Adjust the brightness and contrast of the enhanced feature map to obtain an enhanced channel map.
3. The surface defect detection method based on channel enhancement and feature reconstruction according to claim 2, characterized in that, Step S23 adjusts the contrast of the enhanced feature map and is expressed as Among them, I′ s represents the enhanced channel map, represents the enhanced feature map, α represents the contrast factor, β represents the contrast offset, and μ represents the average brightness of the enhanced feature map.
4. A surface defect detection method based on channel enhancement and feature reconstruction according to claim 1, characterized in that, Step S3 performs Gaussian smoothing on any one channel image and is expressed as where I smooth (x, y) represents the value of the pixel point (x, y) in the channel image after Gaussian smoothing, σ represents the standard deviation, and k represents the radius of the Gaussian kernel; I(x + i, y + j) represents the pixel value at the pixel point (x, y) in the channel image, and i, j are independent variables.
5. The surface defect detection method based on channel enhancement and feature reconstruction according to claim 1, characterized in that Step S4 performs balanced brightness processing on any channel to obtain a brightness balance channel map P l , including: P l = α′·P + β′ where α’ represents the brightness factor and β’ represents the brightness offset.
6. The surface defect detection method based on channel enhancement and feature reconstruction according to claim 1, wherein Step S5 performs weighted fusion on the enhanced channel map, the background texture suppression channel map, and the brightness balance channel map to obtain a fused image, denoted as I final = ω j · E j + ω k · P k + ω l · P l Among them, I final represents the fused image, E j represents the enhancement channel map, P k represents the background texture suppression channel map, P l represents the brightness balance channel map; ω j 、ω k 、ω l are weighting coefficients, ω j = 0.5, ω k = 0.35, ω l = 0.15.
Citation Information
Patent Citations
Background modeling method based on brightness and texture fusion threshold value
CN106570885A
Trackside image enhancement method
CN118608407A
Product appearance quality judgment method based on industrial vision
CN119313944A
Detection and enhancement of backlit images
US20040120599A1
Low-light-level image rapid enhancement method and apparatus based on retinex
WO2020107308A1