Industrial surface defect detection method, system and equipment and storage medium
Through the combination of multi-scale decomposition and adaptive local contrast enhancement, the real-time and adaptive problems of defect detection in complex industrial environments are solved, and industrial surface defect detection with high accuracy and robustness are achieved.
Patent Information
- Application Number
- CN202510143103.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-10
- Publication Date
- 2025-06-06
AI Technical Summary
When facing complex industrial environments, it is difficult for the prior art to ensure detection accuracy while taking into account real-time and adaptability, especially when dealing with defect detection under different materials, complex textures and changing lighting conditions.
Industrial surface defect detection is carried out by combining multi-scale decomposition and adaptive local contrast enhancement. The specific steps include receiving the image to be detected for preprocessing, performing multi-scale decomposition, processing the image based on the adaptive local contrast enhancement algorithm, performing multi-scale fusion, and finally performing defect detection based on the adaptive threshold segmentation method.
It improves the accuracy and robustness of defect detection, can meet the needs of real-time inspection in industrial production, and adapts to defect detection tasks under various material surfaces and lighting conditions.
Smart Images

Figure CN120107175A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of defect detection technology, and in particular to an industrial surface defect detection method, system, equipment and storage medium. Background Art
[0002] With the advent of the Industrial 4.0 era, automation and intelligent production have become the main development trend of the manufacturing industry. In this context, the importance of product quality control, especially surface defect detection technology, has become increasingly prominent. Industrial surface defect detection technology is widely used in many fields such as metal processing, textile production, electronic component manufacturing, and automobile parts production. It is of great significance to ensure product quality, improve production efficiency and reduce costs. Traditional manual detection methods can no longer meet the needs of modern industrial production. Therefore, automated defect detection technology based on machine vision has become a research hotspot. This type of technology obtains the surface image of the object to be inspected through image acquisition equipment, and then uses computer vision and image processing algorithms to analyze the image to identify and locate surface defects.
[0003] In the field of defect detection, researchers have proposed a variety of methods to improve the accuracy and efficiency of detection. The following are some of the main research directions and related technologies: 1. Methods based on image segmentation: Image segmentation is an important step in defect detection. Some scholars have proposed an image segmentation method based on adaptive thresholds. This method dynamically adjusts the segmentation threshold by analyzing local image features, effectively separating the defect area from the background. In addition, some people have developed a multi-scale image segmentation algorithm that can simultaneously detect defects of different sizes. 2. Methods based on texture analysis: Many industrial product surfaces have complex texture features, which poses a challenge to defect detection. To solve this problem, a texture analysis method based on local binary patterns (LBP) has been proposed. Defects are identified by comparing the texture features of defect areas and normal areas, and the detection capability of defects of different scales is improved by introducing multi-scale LBP features. 3. Methods based on image enhancement: Image enhancement plays an important role in defect detection, especially when dealing with images with low contrast or high noise. To this end, some scholars have proposed an adaptive contrast enhancement algorithm, which can dynamically adjust the enhancement parameters according to the local characteristics of the image, effectively improving the visibility of defects. By enhancing image details at different scales, the detection capability of defects of various sizes is improved.
[0004] Although these methods have achieved good results in specific application scenarios, it is still a challenge to ensure detection accuracy while taking into account real-time and adaptability in complex industrial environments. In particular, when dealing with defect detection under different materials, complex textures and changing lighting conditions, existing technologies often find it difficult to meet these requirements at the same time. Summary of the invention
[0005] The main purpose of the present invention is to provide an industrial surface defect detection method, system, equipment and storage medium, aiming to solve at least one of the above-mentioned technical problems.
[0006] To achieve the above object, the present invention provides an industrial surface defect detection method, comprising:
[0007] Receiving an input surface image of an industrial product to be inspected and performing image preprocessing to obtain a preprocessed surface image;
[0008] Performing multi-scale decomposition on the preprocessed surface image to obtain images of different scales;
[0009] Processing the images of different scales based on an adaptive local contrast enhancement algorithm to obtain enhanced images of different scales;
[0010] Performing multi-scale fusion on the enhanced images of different scales to obtain a target enhanced image;
[0011] Defect detection is performed on the target enhanced image based on an adaptive threshold segmentation method to obtain a defect candidate area.
[0012] In some embodiments, the step of receiving an input surface image of an industrial product to be inspected and performing image preprocessing to obtain a preprocessed surface image includes:
[0013] Receiving an input surface image of an industrial product to be inspected;
[0014] Using a bilateral filtering algorithm to perform image denoising on the surface image of the industrial product to be inspected, to obtain a denoised surface image;
[0015] The denoised surface image is grayed using a weighted average method to obtain a preprocessed surface image.
[0016] In some embodiments, performing multi-scale decomposition on the pre-processed surface image to obtain images of different scales includes:
[0017] The preprocessed surface image is set as an original image;
[0018] Based on the original image, a Gaussian pyramid is used to perform multi-scale decomposition; wherein the multi-scale decomposition includes Gaussian blurring and downsampling;
[0019] The multi-scale decomposition operation is repeated until the preset number of pyramid layers is reached to obtain images of different scales.
[0020] In some embodiments, the processing of the images of different scales based on the adaptive local contrast enhancement algorithm to obtain enhanced images of different scales includes:
[0021] Divide the image at each scale into multiple overlapping local regions;
[0022] Calculating a grayscale histogram and a cumulative distribution function for each of the local areas;
[0023] Introducing an adaptive factor, and dynamically adjusting the contrast enhancement parameter based on the adaptive factor according to the shape characteristics of the cumulative distribution function to obtain an adjusted parameter;
[0024] Performing contrast enhancement on the local area according to the adjusted parameters to obtain an enhancement result of the local area;
[0025] Perform weighted fusion on the enhancement results of all local areas to obtain an enhanced image of the corresponding scale;
[0026] Perform enhancement operations on images of all scales to obtain enhanced images of all scales.
[0027] In some embodiments, performing multi-scale fusion on the enhanced images of different scales to obtain a target enhanced image includes:
[0028] Calculate the variance or entropy of each scale image to obtain the information content of each scale image;
[0029] Determine a corresponding weight according to the information amount of each scale image;
[0030] Setting a fusion formula based on the weights;
[0031] The enhanced images of different scales are multi-scale fused according to the fusion formula in a weighted average manner to obtain a target enhanced image.
[0032] In some embodiments, the defect detection is performed on the target enhanced image based on the adaptive threshold segmentation method to obtain the defect candidate area, including:
[0033] Calculating the global average grayscale value and standard deviation of the target enhanced image, and setting an initial threshold value according to the global average grayscale value and standard deviation;
[0034] dividing the target enhanced image into foreground and background according to the initial threshold;
[0035] Calculate the average grayscale value of the foreground and background respectively;
[0036] Update the threshold value according to the average grayscale value of the foreground and the background to obtain an updated threshold value;
[0037] Repeatedly update the threshold until the threshold converges or reaches the maximum number of iterations to obtain the target threshold;
[0038] The target enhanced image is binarized according to the target threshold to obtain a defect candidate region.
[0039] In some embodiments, the method further comprises:
[0040] Post-processing is performed on the defect candidate area detected by the target enhanced image to obtain the target defect candidate area; wherein the post-processing includes in-and-out area screening and / or contour extraction.
[0041] In addition, to achieve the above-mentioned purpose, the present invention also proposes an industrial surface defect detection system, comprising:
[0042] A preprocessing module, used for receiving an input surface image of an industrial product to be inspected and performing image preprocessing to obtain a preprocessed surface image;
[0043] A multi-scale decomposition module, used for performing multi-scale decomposition on the pre-processed surface image to obtain images of different scales;
[0044] An image enhancement module, used for processing the images of different scales based on an adaptive local contrast enhancement algorithm to obtain enhanced images of different scales;
[0045] An image fusion module, used for performing multi-scale fusion on the enhanced images of different scales to obtain a target enhanced image;
[0046] The defect detection module is used to perform defect detection on the target enhanced image based on an adaptive threshold segmentation method to obtain a defect candidate area.
[0047] In addition, to achieve the above-mentioned objectives, the present invention also proposes an electronic device, which includes: a memory, a processor, and an industrial surface defect detection program stored in the memory and executable on the processor, wherein the industrial surface defect detection program is configured to implement the industrial surface defect detection method as described above.
[0048] In addition, to achieve the above-mentioned purpose, the present invention also proposes a storage medium, which stores an industrial surface defect detection program, and the industrial surface defect detection program is used to enable a processor to implement the industrial surface defect detection method described above when executing it.
[0049] The present invention provides an industrial surface defect detection method, comprising: receiving an input surface image of an industrial product to be detected and performing image preprocessing to obtain a preprocessed surface image; performing multi-scale decomposition on the preprocessed surface image to obtain images of different scales; processing the images of different scales based on an adaptive local contrast enhancement algorithm to obtain enhanced images of different scales; performing multi-scale fusion on the enhanced images of different scales to obtain a target enhanced image; performing defect detection on the target enhanced image based on an adaptive threshold segmentation method to obtain a defect candidate area. In the present invention, industrial surface defect detection is performed by combining multi-scale analysis and adaptive local contrast enhancement, which effectively improves the accuracy and robustness of defect detection and can meet the needs of real-time detection in industrial production. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 A schematic diagram of the structure of an electronic device in a hardware operating environment involved in an embodiment of the present invention;
[0051] Figure 2 A schematic diagram of a process flow of an industrial surface defect detection method according to an embodiment of the present invention;
[0052] Figure 3 A schematic diagram of the technical process involved in the embodiment of the present invention;
[0053] Figure 4 This is a schematic diagram of an example of grayscale conversion involved in an embodiment of the present invention;
[0054] Figure 5 It is a structural block diagram of an embodiment of an industrial surface defect detection system of the present invention.
[0055] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0056] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0057] It should be noted that all directional indications in the embodiments of the present invention (such as up, down, left, right, front, back, etc.) are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0058] In addition, the descriptions of "first", "second", etc. in the present invention are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but it must be based on the ability of ordinary technicians in the field to implement. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by the present invention. It should be understood that the specific embodiments described here are only used to explain the present invention and are not used to limit the present invention.
[0059] Reference Figure 1 , Figure 1 The figure is a schematic diagram of the structure of an electronic device of a hardware operating environment involved in an embodiment of the present invention.
[0060] like Figure 1 As shown, the electronic device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (Wireless-Fidelity, Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM memory) or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0061] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0062] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and an industrial surface defect detection program.
[0063] exist Figure 1In the electronic device shown, the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the electronic device of the present invention can be set in the electronic device, and the electronic device calls the industrial surface defect detection program stored in the memory 1005 through the processor 1001, and executes the industrial surface defect detection method provided by an embodiment of the present invention.
[0064] In the field of industrial surface defect detection, although a variety of methods have been proposed and applied, the existing technology still has some significant deficiencies, which seriously restrict the wide application and effect improvement of defect detection technology in complex industrial environments. First, most existing defect detection methods tend to adopt a single-scale image analysis strategy, which shows obvious limitations in dealing with defects of different sizes and shapes. Defects on the surface of industrial products may present multiple scales and forms, from tiny cracks to larger dents or scratches. It is difficult for a single-scale analysis to take into account defects of different characteristics at the same time, resulting in incomplete and inaccurate detection results. Secondly, most existing image enhancement technologies use global or fixed parameter processing methods, which are difficult to adapt to the complex and changeable lighting conditions and material surface characteristics in industrial environments. In actual production environments, the lighting conditions on the surface of products may be uneven due to the layout of the production line and changes in ambient light, and the surface reflection characteristics of different materials are also different. Fixed-parameter image enhancement methods are difficult to make effective adaptive adjustments to these changes, which may cause defects in some areas to be over-enhanced and misdetected, or defects in some areas to be missed due to insufficient enhancement. Thirdly, although many advanced image processing and machine learning algorithms have achieved remarkable results in improving detection accuracy, they are often accompanied by a significant increase in computational complexity. This high computational complexity not only increases hardware costs, but more importantly, may not meet the strict real-time requirements of industrial production. On high-speed production lines, every millisecond of delay may result in missed inspections or misjudgments of a large number of products. Therefore, how to ensure detection accuracy while taking into account the real-time performance of the algorithm has become a difficult problem that needs to be solved urgently.
[0065] In addition, existing defect detection methods often perform poorly when faced with complex backgrounds and textures. The surfaces of many industrial products themselves have complex texture structures, which may be similar to potential defect features, posing a huge challenge to detection. Simple threshold segmentation or edge detection methods often produce a large number of false detections in this case, while overly complex feature extraction methods may lead to a significant decrease in detection efficiency. Finally, existing technologies often lack sufficient flexibility and adaptability when dealing with different types of defects. Various types of surface defects may be encountered in industrial production, such as scratches, dents, bubbles, cracks, etc. These defects may present completely different characteristics on different materials and products. A detection method that lacks adaptability may perform well on a certain type of defect, but it is difficult to maintain the same detection effect when facing other types of defects.
[0066] In view of this, the present invention proposes an industrial surface defect detection method, system, equipment and storage medium.
[0067] The embodiment of the present invention provides an industrial surface defect detection method, referring to Figure 2 , Figure 2 It is a schematic diagram of the process of an embodiment of the industrial surface defect detection method of the present invention.
[0068] like Figure 2 As shown, the industrial surface defect detection method comprises:
[0069] Step S100: receiving an input surface image of an industrial product to be inspected and performing image preprocessing to obtain a preprocessed surface image;
[0070] Step S200: performing multi-scale decomposition on the pre-processed surface image to obtain images of different scales;
[0071] Step S300: Processing the images of different scales based on an adaptive local contrast enhancement algorithm to obtain enhanced images of different scales;
[0072] Step S400: performing multi-scale fusion on the enhanced images of different scales to obtain a target enhanced image;
[0073] Step S500: performing defect detection on the target enhanced image based on an adaptive threshold segmentation method to obtain a defect candidate region.
[0074] It should be noted that the execution subject in this embodiment may be an electronic device, which may be a computer device with data processing functions, or other devices that can achieve the same or similar functions. This embodiment does not limit this. In this embodiment, a computer device is used as an example for explanation.
[0075] It is understandable that if Figure 3 As shown, the method described in this embodiment mainly includes the following steps: image preprocessing, multi-scale decomposition, adaptive local contrast enhancement, multi-scale fusion, defect detection and post-processing, which are described in detail below in combination with the specific steps.
[0076] In one embodiment, an input surface image of an industrial product to be inspected is received and image preprocessing is performed to obtain a preprocessed surface image, including: receiving an input surface image of an industrial product to be inspected; performing image denoising on the surface image of the industrial product to be inspected using a bilateral filtering algorithm to obtain a denoised surface image; and graying the denoised surface image using a weighted average method to obtain a preprocessed surface image.
[0077] Specifically, image preprocessing: when receiving the surface image of the industrial product to be inspected, in order to reduce the complexity of subsequent processing, the input surface image of the industrial product to be inspected is preprocessed. Here, the preprocessing steps include but are not limited to image denoising and grayscale conversion. For example, image denoising can use a bilateral filtering algorithm, which can smooth the image while retaining edge information; grayscale conversion converts a color image into a grayscale image to simplify the subsequent processing process.
[0078] Exemplarily, image denoising: In this embodiment, a bilateral filtering algorithm is used for image denoising. The bilateral filtering algorithm can retain edge information while smoothing the image, and its core formula is as follows:
[0079]
[0080] Among them, I f(x) is the pixel value after filtering, I(x) is the original image value of the current pixel, I(y) is the neighborhood pixel value, N(x) is the neighborhood of the pixel, and f r is the range kernel function, g s is the spatial kernel function, W p Here, I(x) represents the target pixel to be processed during the filtering operation, that is, I(x) represents the grayscale or color value of the target pixel to be denoised; f r (I(y)-I(x)) measures the similarity of pixel values. r and g s Usually the Gaussian function is used:
[0081]
[0082] Among them, σ r and σ s They control the influence range of the range kernel and the spatial kernel respectively; t represents the value obtained by subtracting the current pixel value from the neighborhood pixel value.
[0083] For example, Figure 4 As shown, grayscale: For color images, this embodiment uses weighted average method to grayscale:
[0084] I gray =0.299R+0.587G+0.114B
[0085] Among them, R, G, and B are the pixel values of the red, green, and blue channels respectively.
[0086] In one embodiment, the preprocessed surface image is subjected to multi-scale decomposition to obtain images of different scales, including: setting the preprocessed surface image as an original image; performing multi-scale decomposition based on the original image using a Gaussian pyramid; wherein the multi-scale decomposition includes Gaussian blurring and downsampling; and repeating the multi-scale decomposition operation until a preset number of pyramid layers is reached to obtain images of different scales.
[0087] Specifically, multi-scale decomposition: the preprocessed surface image undergoes multi-scale decomposition to capture image features at different scales.
[0088] Exemplarily, in this embodiment, a Gaussian pyramid is used for multi-scale decomposition, and the specific steps are as follows:
[0089] a) Set the preprocessed image as the original image I_0.
[0090] b) Gaussian blur I_k to get G_k. Here, the kernel function of Gaussian blur is:
[0091]
[0092] c) Downsample G_k by 2×2 to get I k+1 The downsampling operation can be expressed as:
[0093] I (k+1)(x,y) =G k(2x,2y)
[0094] d) Repeat steps b) and c) until the preset number of pyramid levels N is reached.
[0095] Through the above multi-scale decomposition steps, a series of images with different resolutions {I 0 ,I 1 ,...,I N-1}; Among them, I 0 is the original resolution, I N-1 is the lowest resolution.
[0096] It should be noted that I_0: represents the original image, I_k: represents the k-th layer image in the Gaussian pyramid, where k is the layer index, usually starting from 1. Each layer I_k is obtained by applying Gaussian blur to the previous layer image (I_{k-1}) and downsampling. As k increases, the resolution of image I_k will become lower and lower, and the detailed information contained will gradually decrease.
[0097] In this embodiment, a Gaussian pyramid is used to perform multi-scale decomposition of the image, thereby reducing the resolution of the image and retaining its features at different scales.
[0098] In one embodiment, the images of different scales are processed based on an adaptive local contrast enhancement algorithm to obtain enhanced images of different scales, including: dividing the image of each scale into multiple overlapping local areas; calculating the grayscale histogram and the cumulative distribution function for each of the local areas; introducing an adaptive factor, and dynamically adjusting the contrast enhancement parameters based on the adaptive factor according to the shape characteristics of the cumulative distribution function to obtain the adjusted parameters; performing contrast enhancement on the local area according to the adjusted parameters to obtain the enhanced results of the local area; performing weighted fusion on the enhanced results of all local areas to obtain enhanced images of corresponding scales; performing enhancement operations on images of all scales to obtain enhanced images of all scales.
[0099] Specifically, adaptive local contrast enhancement: for each scale image I_k, the adaptive local contrast enhancement algorithm is used in this embodiment to process the image. The specific steps are as follows:
[0100] (a) Divide the image I_k into multiple overlapping local regions, each of which is m×m in size.
[0101] (b) For each local area, calculate its grayscale histogram h(i) and cumulative distribution function (CDF) C(i):
[0102]
[0103] (c) According to the shape characteristics of the cumulative distribution function CDF, the contrast enhancement parameters α and β are dynamically adjusted. In this embodiment, an adaptive factor λ is introduced:
[0104]
[0105] Among them, C max Represents the maximum value of the cumulative distribution function in the local area; C min Represents the minimum value of the cumulative distribution function in the local area; C target The cumulative distribution reference value representing the target contrast can be set by yourself, usually 0.5.
[0106] The contrast enhancement parameters α and β can be adjusted according to the adaptive factor λ:
[0107] α=α 0 *(1+λ)
[0108] β=β 0 *λ
[0109] Among them, α 0 and β 0 The default basic parameter value.
[0110] (d) Use the adjusted parameters to perform contrast enhancement on the local area. The enhancement function can be in the following form:
[0111] E(x,y)=α*I(x,y)+β*(I(x,y)-μ)
[0112] Among them, I(x,y) is the original pixel value, and μ is the average grayscale value of the local area.
[0113] (e) Perform weighted fusion on the enhancement results of all local regions to obtain the enhanced image E at that scale k Here, weighted fusion can use Gaussian weight function:
[0114]
[0115] The final enhancement result is:
[0116]
[0117] In this embodiment, a multi-scale adaptive local contrast enhancement algorithm is innovatively proposed. The algorithm can dynamically adjust the contrast enhancement parameters according to the local features of the image at different scales. This adaptive mechanism significantly improves the sensitivity and accuracy of defect detection, especially when dealing with defects of different sizes and shapes.
[0118] In one embodiment, multi-scale fusion is performed on the enhanced images of different scales to obtain a target enhanced image, including: calculating the variance or entropy of each scale image to obtain the information content of each scale image; determining a corresponding weight according to the information content of each scale image; setting a fusion formula based on the weight; and performing multi-scale fusion on the enhanced images of different scales according to the fusion formula in a weighted average manner to obtain a target enhanced image.
[0119] Specifically, multi-scale fusion: After obtaining enhanced images of each scale {E 0 ,E 1 ,...,E N-1}, they need to be fused into a final enhanced image. In this embodiment, the fusion is performed by adopting a weighted average method. The fusion formula is as follows:
[0120] F=∑(w k *E k )
[0121] Among them, w k is the weight of the kth scale, ∑w k = 1. The weight is chosen based on the amount of information in each scale image, which can be determined by calculating the variance or entropy of the image:
[0122]
[0123] Among them, Var(E k ) represents the variance of the k-th scale image, ∑(Var(E i )) represents the sum of variances of all scale images, which is used to calculate the normalized weights.
[0124] In this embodiment, a multi-scale result fusion strategy is designed. This strategy automatically determines the optimal fusion weight by analyzing the information content of each scale enhancement result, such as variance or entropy. This method can not only effectively integrate information at different scales, but also adaptively highlight the most relevant defect features, greatly improving the robustness of detection.
[0125] In one embodiment, defect detection is performed on the target enhanced image based on an adaptive threshold segmentation method to obtain a defect candidate area, including: calculating the global average grayscale value and standard deviation of the target enhanced image, and setting an initial threshold according to the global average grayscale value and standard deviation; dividing the target enhanced image into a foreground and a background according to the initial threshold; calculating the average grayscale values of the foreground and the background respectively; updating the threshold according to the average grayscale values of the foreground and the background to obtain an updated threshold; repeatedly updating the threshold until the threshold converges or reaches a maximum number of iterations to obtain a target threshold; binarizing the target enhanced image according to the target threshold to obtain a defect candidate area.
[0126] Specifically, after scale fusion, defect detection is performed. The defect detection link performs defect detection on the fused enhanced image F. In this embodiment, an adaptive threshold segmentation method is used to identify potential defect areas. The specific steps are as follows:
[0127] a. Calculate the global average gray value μ of image F (the enhanced image F after fusion) g and standard deviation σ g .
[0128] b. Set the initial threshold T = μ g +k*σg , where k is an adjustable parameter.
[0129] c. Use threshold T to divide the image into foreground (potential defects) and background.
[0130] d. Calculate the average gray value μ of the foreground and background respectively f and μ b .
[0131] e. Update threshold
[0132] f. Repeat steps c-e until T converges or reaches the maximum number of iterations.
[0133] g. Use the final threshold T to binarize the image and obtain the defect candidate area.
[0134] In one embodiment, the method further comprises: performing post-processing on the defect candidate area detected by the target enhanced image to obtain the target defect candidate area; wherein the post-processing comprises in-and-out area screening and / or contour extraction.
[0135] Exemplarily, the detection of defect candidate areas can be completed by performing post-processing operations such as in-and-out area screening or contour extraction for filtering.
[0136] In this embodiment, an adaptive threshold segmentation mechanism is introduced in the defect detection process. This mechanism can automatically adjust the segmentation threshold according to the global statistical characteristics and local contrast distribution of the image. This method effectively solves the limitations of the traditional fixed threshold method in complex backgrounds and significantly improves the accuracy of defect detection.
[0137] It should be noted that this embodiment adopts a multi-scale adaptive local contrast enhancement algorithm, which can dynamically adjust the contrast enhancement parameters according to the local features of the image at different scales. This adaptive mechanism significantly improves the sensitivity and accuracy of defect detection, especially when dealing with defects of different sizes and shapes. This embodiment adopts a multi-scale result fusion strategy, which automatically determines the optimal fusion weight by analyzing the amount of information of the enhancement results at each scale, such as variance or entropy. It can not only effectively integrate information at different scales, but also adaptively highlight the most relevant defect features, greatly improving the robustness of detection. This embodiment introduces an adaptive threshold segmentation mechanism in the defect detection process, which can automatically adjust the segmentation threshold according to the global statistical characteristics and local contrast distribution of the image, effectively solving the limitations of the traditional fixed threshold method in complex backgrounds and significantly improving the accuracy of defect detection.
[0138] It can be understood that this embodiment innovatively integrates multi-scale analysis, adaptive enhancement and intelligent threshold segmentation into a unified framework. This integrated method not only improves the accuracy of detection, but also achieves efficient calculation through optimization algorithm, so that the method described in this embodiment can meet the needs of real-time detection in industrial production. The method proposed in this embodiment has wide adaptability and can handle defect detection tasks under various material surfaces and lighting conditions. Through adaptive parameter adjustment and multi-scale analysis, this method can effectively cope with the complex textures and changing lighting environments of different industrial product surfaces, significantly improving the versatility and practical value of the detection system.
[0139] This embodiment provides an industrial surface defect detection method, including: receiving an input surface image of an industrial product to be detected and performing image preprocessing to obtain a preprocessed surface image; performing multi-scale decomposition on the preprocessed surface image to obtain images of different scales; processing the images of different scales based on an adaptive local contrast enhancement algorithm to obtain enhanced images of different scales; performing multi-scale fusion on the enhanced images of different scales to obtain a target enhanced image; performing defect detection on the target enhanced image based on an adaptive threshold segmentation method to obtain a defect candidate area. In this embodiment, industrial surface defect detection is performed by combining multi-scale analysis and adaptive local contrast enhancement, which effectively improves the accuracy and robustness of defect detection and can meet the needs of real-time detection in industrial production.
[0140] In addition, an embodiment of the present invention further proposes a storage medium, on which an industrial surface defect detection program is stored. When the industrial surface defect detection program is executed by a processor, the steps of the industrial surface defect detection method described above are implemented.
[0141] Reference Figure 5 , Figure 5 It is a structural block diagram of an embodiment of an industrial surface defect detection system of the present invention.
[0142] like Figure 5 As shown, the industrial surface defect detection system comprises:
[0143] The preprocessing module 10 is used to receive the input surface image of the industrial product to be inspected and perform image preprocessing to obtain a preprocessed surface image;
[0144] A multi-scale decomposition module 20, used for performing multi-scale decomposition on the pre-processed surface image to obtain images of different scales;
[0145] An image enhancement module 30, configured to process the images of different scales based on an adaptive local contrast enhancement algorithm to obtain enhanced images of different scales;
[0146] An image fusion module 40 is used to perform multi-scale fusion on the enhanced images of different scales to obtain a target enhanced image;
[0147] The defect detection module 50 is used to perform defect detection on the target enhanced image based on an adaptive threshold segmentation method to obtain a defect candidate area.
[0148] This embodiment provides an industrial surface defect detection system. In this embodiment, a multi-scale adaptive local contrast enhancement algorithm is used, which can dynamically adjust the contrast enhancement parameters according to the local features of the image at different scales. This adaptive mechanism significantly improves the sensitivity and accuracy of defect detection, especially when dealing with defects of different sizes and shapes. This embodiment adopts a multi-scale result fusion strategy, which automatically determines the optimal fusion weight by analyzing the amount of information of each scale enhancement result, such as variance or entropy. It can not only effectively integrate information of different scales, but also adaptively highlight the most relevant defect features, greatly improving the robustness of detection. This embodiment introduces an adaptive threshold segmentation mechanism in the defect detection process, which can automatically adjust the segmentation threshold according to the global statistical characteristics and local contrast distribution of the image, effectively solving the limitations of the traditional fixed threshold method in complex backgrounds and significantly improving the accuracy of defect detection.
[0149] It can be understood that in this embodiment, multi-scale analysis, adaptive enhancement and intelligent threshold segmentation are innovatively integrated into a unified framework. This integrated method not only improves the accuracy of detection, but also achieves efficient calculation through optimization algorithm, so that the method described in this embodiment can meet the needs of real-time detection in industrial production. The method proposed in this embodiment has wide adaptability and can handle defect detection tasks under various material surfaces and lighting conditions. Through adaptive parameter adjustment and multi-scale analysis, this method can effectively cope with the complex textures and changing lighting environments of different industrial product surfaces, significantly improving the versatility and practical value of the detection system.
[0150] It should be noted that the technical details that are not described in detail in the embodiment of the industrial surface defect detection system can be found in the industrial surface defect detection method described above provided in any embodiment of the present invention, and will not be repeated here.
[0151] It should be understood that the above is only an example and does not constitute any limitation on the technical solution of the present invention. In specific applications, technicians in this field can make settings as needed, and the present invention does not limit this.
[0152] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present invention. In practical applications, technicians in this field can select part or all of them according to actual needs to achieve the purpose of the present embodiment, and no limitation is made here.
[0153] In addition, it should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0154] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0155] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory (ROM) / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0156] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. An industrial surface defect detection method, characterized in that: include: Receiving an input surface image of an industrial product to be inspected and performing image preprocessing to obtain a preprocessed surface image; Performing multi-scale decomposition on the preprocessed surface image to obtain images of different scales; Processing the images of different scales based on an adaptive local contrast enhancement algorithm to obtain enhanced images of different scales; Performing multi-scale fusion on the enhanced images of different scales to obtain a target enhanced image; Defect detection is performed on the target enhanced image based on an adaptive threshold segmentation method to obtain a defect candidate area.
2. The method according to claim 1, characterized in that The step of receiving an input surface image of an industrial product to be inspected and performing image preprocessing to obtain a preprocessed surface image includes: Receiving an input surface image of an industrial product to be inspected; Using a bilateral filtering algorithm to perform image denoising on the surface image of the industrial product to be inspected, to obtain a denoised surface image; The denoised surface image is grayed using a weighted average method to obtain a preprocessed surface image.
3. The method according to claim 1, characterized in that The step of performing multi-scale decomposition on the pre-processed surface image to obtain images of different scales includes: The preprocessed surface image is set as an original image; Based on the original image, a Gaussian pyramid is used to perform multi-scale decomposition; wherein the multi-scale decomposition includes Gaussian blurring and downsampling; The multi-scale decomposition operation is repeated until the preset number of pyramid layers is reached to obtain images of different scales.
4. The method according to claim 1, characterized in that The processing of the images of different scales based on the adaptive local contrast enhancement algorithm to obtain enhanced images of different scales includes: Divide the image at each scale into multiple overlapping local regions; Calculating a grayscale histogram and a cumulative distribution function for each of the local areas; Introducing an adaptive factor, and dynamically adjusting the contrast enhancement parameter based on the adaptive factor according to the shape characteristics of the cumulative distribution function to obtain an adjusted parameter; Performing contrast enhancement on the local area according to the adjusted parameters to obtain an enhancement result of the local area; Perform weighted fusion on the enhancement results of all local areas to obtain an enhanced image of the corresponding scale; Perform enhancement operations on images of all scales to obtain enhanced images of all scales.
5. The method according to claim 1, characterized in that The multi-scale fusion of the enhanced images of different scales to obtain a target enhanced image includes: Calculate the variance or entropy of each scale image to obtain the information content of each scale image; Determine a corresponding weight according to the information amount of each scale image; Setting a fusion formula based on the weights; The enhanced images of different scales are multi-scale fused according to the fusion formula in a weighted average manner to obtain a target enhanced image.
6. The method according to claim 1, characterized in that The defect detection is performed on the target enhanced image based on the adaptive threshold segmentation method to obtain a defect candidate area, including: Calculating the global average grayscale value and standard deviation of the target enhanced image, and setting an initial threshold value according to the global average grayscale value and standard deviation; dividing the target enhanced image into foreground and background according to the initial threshold; Calculate the average grayscale value of the foreground and background respectively; Update the threshold value according to the average grayscale value of the foreground and the background to obtain an updated threshold value; Repeatedly update the threshold until the threshold converges or reaches the maximum number of iterations to obtain the target threshold; The target enhanced image is binarized according to the target threshold to obtain a defect candidate area.
7. The method according to claim 6, characterized in that The method further comprises: Post-processing is performed on the defect candidate area detected by the target enhanced image to obtain the target defect candidate area; wherein the post-processing includes in-and-out area screening and / or contour extraction.
8. An industrial surface defect detection system, characterized in that: include: A preprocessing module, used for receiving an input surface image of an industrial product to be inspected and performing image preprocessing to obtain a preprocessed surface image; A multi-scale decomposition module, used for performing multi-scale decomposition on the pre-processed surface image to obtain images of different scales; An image enhancement module, used for processing the images of different scales based on an adaptive local contrast enhancement algorithm to obtain enhanced images of different scales; An image fusion module, used for performing multi-scale fusion on the enhanced images of different scales to obtain a target enhanced image; The defect detection module is used to perform defect detection on the target enhanced image based on an adaptive threshold segmentation method to obtain a defect candidate area.
9. An electronic device, characterized in that: The electronic device comprises: a memory, a processor, and an industrial surface defect detection program stored in the memory and executable on the processor, wherein the industrial surface defect detection program is configured to implement the industrial surface defect detection method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium stores an industrial surface defect detection program, and the industrial surface defect detection program is used to enable a processor to implement the industrial surface defect detection method according to any one of claims 1 to 7 when executing the program.
Citation Information
Cited By
Material defect detection method for keyboard and keycap production
CN121033031A
A keyboard and a keycap production material defect detection method
CN121033031B
Defect detection method and device, electronic equipment and storage medium
CN121169922A
Engine blade defect detection method based on machine vision
CN122199536A
A Machine Vision-Based Method for Engine Blade Defect Detection
CN122199536B