Coating defect detection method and system based on machine vision
By introducing local light uniformity factors in the lighting correction process, combining fluctuation factors and adaptive metric distance to improve the superpixel segmentation algorithm, and combining convolutional neural network model for defect classification, the problem of low accuracy in coating defect detection under complex lighting conditions is solved, and a more efficient defect detection effect is achieved.
Patent Information
- Application Number
- CN202510006970.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-03
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2045-01-03
AI Technical Summary
The existing machine vision technology has low accuracy when detecting paint surface defects under complex lighting conditions, and traditional superpixel segmentation methods are difficult to deal with highlights and color changes, resulting in inaccurate segmentation boundaries.
A brightness correction mechanism based on local illumination uniformity factor is adopted to construct the fluctuation factor in combination with color fluctuations and texture features, and an adaptive metric distance is introduced to improve the superpixel segmentation algorithm to adapt to complex scenarios. At the same time, the convolutional neural network model is used for defect classification and quality evaluation.
It significantly improves the accuracy of coating defect detection under complex lighting conditions, avoids misjudgment of highlight areas, and enhances the ability to identify small defects, and overall improves the automation, accuracy and robustness of detection.
Smart Images

Figure CN119417817B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to a coating defect detection method and system based on machine vision. Background Art
[0002] Paint is a material widely used in modern industrial production and daily life. It is mainly used for the decoration and protection of the surface of objects. Its application fields include automobile manufacturing, architectural decoration, electronic equipment, furniture, etc. Quality control directly affects the appearance and function of products. Defects on the surface of paint, such as cracks, bubbles, uneven coating, etc., not only affect the appearance, but also may reduce product performance. Therefore, in the process of paint production and application, the detection of surface defects is particularly important.
[0003] Paint surface defect detection has traditionally been based on manual visual inspection. Although existing machine vision technology can partially achieve automation, these methods perform well under uniform lighting and simple texture conditions, such as fixed threshold segmentation, gradient detection, and morphological analysis. However, they are easily disturbed by highlights and shadows under complex lighting conditions, resulting in a significant drop in detection accuracy. At the same time, segmentation algorithms based on a single feature are difficult to effectively handle defects with complex surface textures, such as tiny features such as cracks or bubbles.
[0004] In addition, existing deep learning technologies often have difficulty in obtaining sufficient training results due to the lack of high-quality image segmentation. The superpixel segmentation method SLIC can be used to perform high-quality image segmentation and then extract features to further obtain better training results. However, the traditional superpixel segmentation method SLIC has the problem that the fixed metric formula cannot adapt to complex scenes, and the processing of highlight areas and color changes is insufficient, resulting in inaccurate segmentation boundaries. Summary of the invention
[0005] In view of the problem that the above-mentioned segmentation boundary is not accurate enough, in the first aspect, the present invention proposes a paint defect detection method based on machine vision, including: obtaining a paint history image containing defects; using superpixel segmentation on the paint history image to obtain multiple superpixel areas, obtaining the feature vector of each superpixel area and adding labels for training the CNN model; obtaining a real-time paint image and inputting it into the trained CNN model and judging whether the corresponding paint has defects based on the output result of the CNN model; the superpixel segmentation also includes clustering through adaptive metric distance, wherein: determining a neighborhood window with any pixel point in the paint history image as the center, calculating the standard deviation of the brightness of each pixel point in the neighborhood window and the center pixel point; confirming Determine an illumination correction factor for any pixel, the illumination correction factor is positively correlated with the brightness mean value and the standard deviation of the neighborhood window, and is negatively correlated with the brightness of any pixel; take the product of the brightness of any pixel and the illumination correction factor as the corrected brightness of any pixel; take the sum of the differences between the corrected brightness of each pixel in the neighborhood window and the corrected brightness mean value of all pixels in the neighborhood window as the corrected brightness uniformity; take the product of the corrected brightness uniformity and the texture contrast of the neighborhood window as the fluctuation factor; the product of the difference between the fluctuation factor of any pixel and the cluster center in the corresponding superpixel area and the initial metric distance in superpixel segmentation constitutes the adaptive metric distance.
[0006] The present invention introduces a brightness correction mechanism based on local uniformity factors in the illumination correction link, integrates color fluctuations and texture features in the construction of fluctuation factors, introduces fluctuation factors into the distance measurement formula, and achieves accurate segmentation of complex surface areas, avoiding misjudgment of highlight areas, while significantly improving the ability to identify tiny defects. Finally, the classification detection and quality assessment of coating defects are achieved through the convolutional neural network model combined with multidimensional feature vectors, which improves the automation, accuracy and robustness of defect detection as a whole. Compared with traditional methods such as fixed threshold segmentation and simple texture analysis, the present invention has significant advantages in the detection of complex defects on the coating surface.
[0007] Furthermore, the calculation method of the adaptive metric distance is specifically as follows:
[0008] ;
[0009] Where D imp (i, l) represents the adaptive metric distance between pixel i and the cluster center l in the corresponding superpixel region; D bas (i,l) represents the initial metric distance between pixel i and the cluster center l in the corresponding superpixel region; exp( ) represents the natural exponential function; W(i) represents the fluctuation factor of pixel i; W(l) represents the fluctuation factor of cluster center l in the corresponding superpixel region.
[0010] By introducing the fluctuation factor and combining it with the initial distance metric, an adaptive metric distance is constructed, which realizes the function of dynamically adjusting the distance weight according to regional heterogeneity in superpixel segmentation, effectively solving the problem of inaccurate segmentation of regions with similar colors in traditional superpixel segmentation and improving the segmentation accuracy of complex areas.
[0011] Furthermore, the calculation method of the fluctuation factor is specifically as follows:
[0012] ;
[0013] Where W(i) represents the fluctuation factor of pixel i; Norm( ) represents the normalization function; Ω(i) represents the neighborhood window determined by pixel i; Cont(i) represents the texture contrast of the neighborhood window; N represents the total number of pixels in the neighborhood window; I corr (j) represents the corrected brightness value of pixel j in the neighborhood window; I corr_avg (i) represents the mean brightness of all pixels in the neighborhood window after correcting the brightness.
[0014] The present invention constructs a fluctuation factor by fusing color fluctuation and texture features, which effectively reflects the color and texture characteristics of the region, overcomes the limitation of the prior art of relying only on a single feature to measure regional features, and enhances the sensitivity to complex regions in the segmentation and classification links.
[0015] Furthermore, the texture contrast of the neighborhood window is obtained by the contrast of the gray level co-occurrence matrix.
[0016] Furthermore, the method for calculating the texture contrast of the neighborhood window is specifically as follows: obtaining the LBP values of all pixels in the neighborhood window; and taking the standard deviation of all LBP values as the texture contrast of the neighborhood window.
[0017] Furthermore, the calculation method of the illumination correction factor is specifically as follows:
[0018] ;
[0019] ;
[0020] ;
[0021] Where C(i) represents the illumination correction factor of pixel i; I avg(i) represents the brightness mean of the neighborhood window determined by pixel i; I(i) represents the brightness value of pixel i; є represents the adjustment factor; exp( ) represents the natural exponential function; U(i) represents the local illumination uniformity factor of pixel i; λ represents the illumination correction adjustment parameter; Ω(i) represents the neighborhood window determined by pixel i; I(j) represents the brightness value of pixel j in the neighborhood window; N represents the total number of pixels in the neighborhood window; ln represents the natural logarithm function; U max represents the maximum value of the local illumination uniformity factor in the paint history image; U(q) represents the local illumination uniformity factor of the qth pixel in the paint history image; ω represents the parameter adjustment factor; M represents the total number of pixels in the paint history image.
[0022] By dynamically adjusting the illumination correction factor based on the local illumination uniformity factor, the present invention effectively eliminates the influence of highlight and dark light areas in the image, making the brightness distribution of the processed image more uniform. Compared with the traditional global brightness correction method, the present invention has better adaptability and correction accuracy.
[0023] Furthermore, the feature vector of each superpixel area is obtained and a label is added for training the CNN model, including: calculating the color mean and color standard deviation of the RGB space of each superpixel area based on the meanStdDev function in OpenCV; calculating the texture features of each superpixel area based on the gray-level co-occurrence matrix, including contrast, entropy and uniformity; using the countNonZero method in OpenCV to obtain the area of each superpixel area; using the findContours method and the arcLength method to obtain the perimeter of each superpixel area; calculating the brightness mean and brightness standard deviation in each superpixel area based on the corrected brightness; after obtaining the feature vector of each superpixel area, adding a label as "defect" or "non-defect" to each superpixel area; the feature vector and label of each superpixel area constitute a data set for training the CNN model.
[0024] Furthermore, obtaining a real-time image of the paint and inputting it into a trained CNN model and determining whether the corresponding paint has defects based on the output result of the CNN model also includes: obtaining a real-time image after the paint production is completed; segmenting the real-time image using a superpixel segmentation algorithm with an adaptive metric distance; obtaining feature vectors of all segmented superpixel areas and inputting them into the trained CNN model to obtain all classification results; and in response to the presence of a "defect" label in the classification result, notifying staff to perform corresponding troubleshooting on the paint production equipment.
[0025] By training the convolutional neural network model to classify the extracted superpixel features, accurate classification and detection of complex defects are achieved by combining the fluctuation factor and texture features. Compared with traditional classification methods based on rules or simple feature matching, the present invention has a higher level of automation and robustness to unknown defects.
[0026] Furthermore, obtaining a paint history image containing defects also includes: using a high-definition industrial camera to shoot the paint history image containing defects; using a bilateral filtering algorithm to perform noise reduction on the paint history image; using a gamma correction algorithm to perform color correction on the paint history image after noise reduction; and using adaptive histogram equalization on the paint history image after color correction to enhance the local contrast of the image.
[0027] In a second aspect, the present invention provides a machine vision-based paint defect detection system, comprising a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the machine vision-based paint defect detection method of the present invention is implemented.
[0028] The technical effects of the present invention are:
[0029] The present invention proposes an illumination correction method based on the local illumination uniformity factor, realizes the dynamic correction of the highlight and low brightness areas, and significantly improves the image quality in the scene with uneven illumination; secondly, the color fluctuation and texture features are integrated to construct the fluctuation factor, and an improved superpixel segmentation algorithm is introduced to realize the accurate segmentation of complex surface areas through the dynamic distance measurement formula, which solves the problem of mis-segmentation of complex features such as highlights and dark patterns by traditional methods; finally, the convolutional neural network model is combined for defect classification, and the multi-dimensional feature vector is used to improve the detection accuracy and adaptability to unknown defects. The present invention effectively solves the problems of low detection accuracy, poor robustness, and insufficient automation in the prior art, and provides a more efficient and reliable solution for coating defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0031] Figure 1 is a flowchart schematically showing a coating defect detection method based on machine vision in an embodiment of the present invention;
[0032] Figure 2 Schematic diagram of coating surface defects in an embodiment of the present invention;
[0033] Figure 3 It is a block diagram schematically showing the structure of a paint defect detection system based on machine vision according to an embodiment of the present invention. DETAILED DESCRIPTION
[0034] 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 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 those skilled in the art without creative work are within the scope of protection of the present invention.
[0035] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0036] Embodiment of coating defect detection method based on machine vision:
[0037] like Figure 1 As shown, the coating defect detection method based on machine vision of the present invention includes:
[0038] S1. Collect paint surface images and perform preprocessing operations.
[0039] Paint is an important material used in the fields of construction, automobiles, home appliances, etc. If the produced paint has defects such as bubbles, impurities or uneven mixing, Figure 2 As shown, not only will the appearance quality of the product to which the coating is applied be reduced, but it may also affect its protective performance, which in turn leads to a decrease in performance or premature failure of the product in actual use. Therefore, accurate and rapid detection of defects on the coating surface is of great significance to ensure product quality.
[0040] In order to accurately detect defects on the paint surface, it is first necessary to obtain high-quality image data. The quality of the image directly affects the accuracy and reliability of subsequent defect detection. Therefore, in this embodiment, a high-resolution industrial camera with a resolution of at least 1920×1080 pixels can be used to ensure that subtle defects on the paint surface are captured; at the same time, the camera can be installed on a fixed bracket and maintain an empirical distance of about 50 cm from the paint surface to avoid image scaling changes; then a ring LED light source can be used to ensure that the paint surface is evenly illuminated in all directions to reduce interference from reflections and shadows; to further reduce the impact of mirror reflections, a polarizing filter can also be equipped on the industrial camera lens.
[0041] After capturing an image of a coating surface containing defects, a bilateral filtering algorithm can be used for noise reduction processing to effectively remove noise while maintaining edge information; further, a gamma correction algorithm can be used to improve image quality to ensure that the image color is close to the actual coating color; finally, adaptive histogram equalization can be used to enhance the local contrast of the image and highlight the subtle texture and potential defects on the coating surface. The above-mentioned image preprocessing algorithms belong to well-known technologies, and the specific implementation methods will not be repeated here.
[0042] S2. Obtain the local illumination uniformity factor of the paint surface pixel.
[0043] Defect detection on the paint surface depends on accurate segmentation of the image. In this embodiment, the superpixel segmentation algorithm SLIC can be used, which achieves preliminary segmentation of the image by grouping image pixels into several superpixel regions with similar color and spatial characteristics. However, the traditional superpixel segmentation algorithm SLIC has certain limitations when processing paint surfaces. Exemplary explanation: The paint surface is usually relatively uniform, but due to the presence of light reflection and tiny defects, the traditional superpixel segmentation algorithm SLIC may not be able to effectively distinguish between highlight areas and real defects, resulting in inaccurate segmentation. Therefore, it needs to be improved to meet the specific needs of paint defect detection.
[0044] The implementation method of the superpixel segmentation algorithm SLIC mainly includes the steps of initialization, distance measurement, clustering update, and iterative optimization. In the coating defect detection scenario, there are highlight areas and tiny defects on the coating surface. These features will have an adverse effect on the segmentation effect of the traditional superpixel algorithm. An exemplary explanation is: due to the smooth reflection of the coating surface, the color of the highlight area is obviously different, and the original superpixel segmentation algorithm may misjudge it as a defect or mistakenly segment it into multiple superpixels; at the same time, the tiny defects on the coating surface, such as bubbles and small cracks, change little in the color space, and the original superpixel segmentation algorithm may not be able to effectively capture these subtle differences, resulting in defects being ignored or inaccurate segmentation. Therefore, in this embodiment, on the basis of the superpixel segmentation algorithm SLIC, an improvement step for the coating surface features is introduced to improve the accuracy of segmentation and the sensitivity to defects.
[0045] In order to eliminate the influence of uneven illumination, in this embodiment, the illumination uniformity of the local area can be quantified first, and corresponding illumination correction can be performed to improve the reliability of subsequent color fluctuation detection. Here, the local illumination uniformity factor of each pixel is defined, and the local illumination uniformity factor of pixel i is recorded as U(i). The specific calculation method is:
[0046] ;
[0047] Where U(i) represents the local illumination uniformity factor of pixel i, which represents the standard deviation of the brightness change in the area where pixel i is located; Ω(i) represents the neighborhood window with a radius of r and centered on pixel i. In this embodiment, r can take an empirical value of 3; I(j) represents the brightness value of pixel j in the neighborhood window Ω(i); I avg (i) represents the average brightness value of the neighborhood window Ω(i) of pixel i; N represents the total number of pixels in the neighborhood window Ω(i). It should be noted that the above brightness value is calculated by averaging the RGB three-channel values, and the specific calculation process will not be repeated here.
[0048] When the local illumination uniformity factor U(i) of a pixel is large, it means that the brightness in the area varies greatly, that is, the illumination is uneven, which may be caused by reflection or tiny defects on the paint surface.
[0049] S3. Obtain an illumination correction factor based on the local illumination uniformity factor of step S2; and obtain a fluctuation factor based on the illumination correction factor and texture features.
[0050] In step S2, the local illumination uniformity factor is obtained, and the local illumination unevenness is quantified. In this embodiment, in order to eliminate the influence of illumination on color analysis, it is necessary to perform illumination correction on the image. At the same time, in order to improve the accuracy of correction, the illumination correction factor is calculated by combining the coating reflection characteristics and the neighborhood brightness information. The specific calculation method is as follows:
[0051] ;
[0052] ;
[0053] ;
[0054] Where C(i) represents the illumination correction factor for pixel i; I avg (i) represents the average brightness value in the neighborhood window Ω(i) of pixel i; I(i) represents the brightness value of pixel i; є represents the parameter adjustment factor to avoid the denominator being 0. In this embodiment, the empirical value can be 0.001; exp( ) represents the natural exponential function; U(i) represents the local illumination uniformity factor of pixel i; λ represents the illumination correction adjustment parameter; ln represents the natural logarithm function; U max represents the maximum value of the local illumination uniformity factor in the image; U(q) represents the local illumination uniformity factor of the qth pixel in the paint image; ω represents the parameter adjustment factor to avoid the situation where the denominator is 0. In this embodiment, the empirical value can be 0.001; M represents the total number of pixels in the image; I corr (i) represents the brightness of pixel i after correction.
[0055] It is used to adjust the brightness of pixel i to make it closer to the average brightness of the neighborhood and reduce the impact of highlights or shadows on the image. exp(-λU(i)) is used to dynamically adjust the correction intensity according to the global illumination uniformity. When is larger, that is, when the illumination is uneven, the illumination correction adjustment parameter λ should be smaller to weaken the influence of the correction factor and avoid over-correction.
[0056] When U(i) is larger, exp(-λU(i)) should be smaller to reduce the brightness adjustment of the highlight area and avoid misjudgment. When U(i) is smaller, exp(-λU(i)) should be larger to enhance the brightness adjustment of the uniform area and ensure the overall illumination of the image is consistent.
[0057] By dynamically adjusting the illumination correction factor based on the local illumination uniformity factor, the present invention effectively eliminates the influence of highlight and dark light areas in the image, making the brightness distribution of the processed image more uniform. Compared with the traditional global brightness correction method, the present invention has better adaptability and correction accuracy.
[0058] After completing the illumination correction, tiny defects on the coating surface, such as bubbles and fine cracks, are usually accompanied by slight color fluctuations and local texture changes. In order to detect these defects more effectively, it is necessary to enhance the detection capability of local color fluctuations, thereby improving the superpixel segmentation algorithm to make it more sensitive to real defects while avoiding misjudgment of highlight areas. At the same time, in order to further enhance the detection capability of local texture changes of tiny defects, in this embodiment, a quantitative index of texture features is introduced into the neighborhood window Ω(i) of pixel i and the fluctuation factor is calculated.
[0059] First, the paint surface image is grayed using the maximum method, and then for the neighborhood window Ω(i) of pixel i, its local texture contrast Cont(i) is obtained. High contrast usually corresponds to an area with rich texture details and may contain tiny defects. In one embodiment, the local texture contrast Cont(i) can be obtained by the contrast of the grayscale co-occurrence matrix; in another embodiment: the LBP values of all pixels in the neighborhood window Ω(i) are calculated, and the standard deviation of all the obtained LBP values is used as the local texture contrast Cont(i) of the neighborhood window Ω(i).
[0060] The grayscale algorithm, grayscale co-occurrence matrix and LBP algorithm are all well-known technologies, and the specific implementation methods are not described here. Then, the fluctuation factor is obtained, and the calculation method is specifically as follows:
[0061] ;
[0062] Where W(i) represents the fluctuation factor of pixel i; Norm( ) represents the normalization function, which is used to normalize the local texture contrast Cont(i) of all pixels obtained in the image; N represents the total number of pixels in the neighborhood window Ω(i); I corr (j) represents the corrected brightness value of pixel j in the neighborhood window Ω(i); I corr_avg (i) represents the corrected brightness mean of all pixels in the neighborhood window Ω(i).
[0063] When Norm(Cont(i)) is larger, it means that there is a larger texture contrast in the neighborhood window Ω(i), that is, the texture details are richer, and the possibility of tiny defects in the area is greater, and the fluctuation factor W(i) is larger; when The larger the value, the greater the color fluctuation in the neighborhood window Ω(i). The greater the possibility of small defects in the area, the greater the fluctuation factor W(i). It should be noted that: It can also be recorded as corrected brightness uniformity.
[0064] The present invention constructs a fluctuation factor by fusing color fluctuation and texture features, which effectively reflects the color and texture characteristics of the region, overcomes the limitation of the prior art of relying only on a single feature to measure regional features, and enhances the sensitivity to complex regions in the segmentation and classification links.
[0065] In the traditional superpixel segmentation algorithm SLIC, its metric distance only considers the color distance and the spatial distance, and cannot effectively distinguish between the highlight area and the real defect. Therefore, in this embodiment, a fluctuation factor is introduced to dynamically adjust the metric distance, improve the sensitivity of the algorithm segmentation to defects and avoid misjudgment of the highlight area. The adaptive metric distance is:
[0066] ;
[0067] Where D imp (i, l) represents the adaptive metric distance between pixel i and the corresponding cluster center l; D bas (i,l) represents the initial metric distance between pixel i and the corresponding cluster center l; exp( ) represents the natural exponential function; W(i) represents the fluctuation factor of pixel i; W(l) represents the fluctuation factor of the corresponding cluster center l.
[0068] When |W(i)-W(l)| is larger, it means that the fluctuation factor between the pixel point and the cluster center is different. The metric distance should be increased to make it easier for the superpixel to segment the tiny defect area. Then D imp The larger (i,l) is.
[0069] By introducing the fluctuation factor and combining it with the initial distance metric, an adaptive metric distance is constructed, which realizes the function of dynamically adjusting the distance weight according to regional heterogeneity in superpixel segmentation, effectively solving the problem of inaccurate segmentation of regions with similar colors in traditional superpixel segmentation and improving the segmentation accuracy of complex areas.
[0070] S4. Perform region segmentation and feature extraction based on the improved superpixel segmentation algorithm, and input the extracted features into the CNN model for training; obtain real-time paint images, and input them into the trained CNN model for defect assessment and subsequent processing.
[0071] After a large number of defective paint surface images are obtained and preprocessed based on the image acquisition method of step S1, each image is segmented using a superpixel segmentation algorithm with an adaptive metric distance to obtain multiple superpixel regions, each of which has color uniformity and spatial consistency, while reducing misjudgment of highlight areas. The number of defective paint surface images obtained can be set to an empirical value of 1000, and the implementer can also set the empirical value to 1500, 2000 or 2500, etc. according to actual conditions to ensure the training effect of the subsequent CNN model.
[0072] After obtaining the superpixel region, multiple features are extracted for each superpixel region, including: first, the color mean f1 and color standard deviation f2 of the RGB space of each superpixel region are calculated based on the meanStdDev function in OpenCV; then, the texture features are calculated based on the gray-level co-occurrence matrix, including contrast f3, entropy f4, and uniformity f5; further, the countNonZero method in OpenCV is used to obtain the area f6, and the findContours method and arcLength method are used to obtain the perimeter f7; finally, the brightness mean f8 and brightness standard deviation f9 in the region are calculated based on the brightness after illumination correction. For any superpixel region k, the above features are integrated into the feature vector F k , as follows:
[0073] ;
[0074] After obtaining the feature vector of each superpixel region, according to the actual detection requirements, in this embodiment, each superpixel region can be manually labeled as "defect" or "non-defect", and the defect categories include but are not limited to bubbles, cracks, uneven mixing, etc. For example, non-defects are labeled with a digital label "0", bubbles are labeled with a digital label "1", cracks are labeled with a digital label "2", and uneven mixing is labeled with a digital label "3". After the labeling is completed, a data set containing the feature vectors and labels of the superpixel region is generated, specifically:
[0075] ;
[0076] Where D represents the data set; F k represents the feature vector of any superpixel region k; y k represents the label of any superpixel region k; K represents the total number of superpixel regions, which in this embodiment is an empirical value of 1000. After obtaining the data set D, the labeled data is randomly divided into a training set, a validation set, and a test set, where the training set can be set to an empirical value of 70%D, the validation set can be set to an empirical value of 20%D, and the test set can be set to an empirical value of 10%D.
[0077] The above training set is input into the CNN model for training. During the training process, the activation function can select the ReLU function; the learning rate optimizer can select the Adam optimizer, and the loss function can select the cross entropy loss function. The specific training process of the CNN model belongs to the well-known technology and will not be repeated here. At this point, a trained CNN model is obtained.
[0078] By training the convolutional neural network model to classify the extracted superpixel features, accurate classification and detection of complex defects are achieved by combining the fluctuation factor and texture features. Compared with traditional classification methods based on rules or simple feature matching, the present invention has a higher level of automation and robustness to unknown defects.
[0079] In the quality inspection phase after the production of paint, firstly, a high-definition image of the paint surface is obtained based on the image acquisition method of step S1 for preprocessing, and the preprocessed image is segmented based on the superpixel segmentation algorithm after the improved adaptive metric distance; then, the feature vectors of all segmented superpixel areas are obtained; then, each feature vector is input into the trained CNN model to obtain all classification results; finally, the defects of the paint corresponding to the current image are evaluated according to the classification results.
[0080] An exemplary explanation: there is a high-definition image of a paint surface, which has 5 superpixel regions after superpixel segmentation. The feature vectors of these 5 superpixel regions are extracted and recorded as: F1, F2, F3, F4 and F5 respectively. These 5 feature vectors are respectively input into the trained CNN model to obtain 5 output results, which are: 0, 0, 0, 0 and 1 respectively; since there are non-zero cases in the above output results, that is, there are defects, and the defect corresponding to the digital label is a bubble, based on the defect type, the staff is notified to perform corresponding troubleshooting on the paint production equipment to improve production quality and minimize production losses.
[0081] The present invention introduces a brightness correction mechanism based on local uniformity factors in the illumination correction link, integrates color fluctuations and texture features in the construction of fluctuation factors, introduces fluctuation factors into the distance measurement formula, and achieves accurate segmentation of complex surface areas, avoiding misjudgment of highlight areas, while significantly improving the ability to identify tiny defects. Finally, the classification detection and quality assessment of coating defects are achieved through the convolutional neural network model combined with multidimensional feature vectors, which improves the automation, accuracy and robustness of defect detection as a whole. Compared with traditional methods such as fixed threshold segmentation and simple texture analysis, the present invention has significant advantages in the detection of complex defects on the coating surface.
[0082] Example of coating defect detection system based on machine vision:
[0083] On the other hand, the present invention also provides a coating defect detection system based on machine vision. Figure 3 As shown, the paint defect detection system based on machine vision includes a processor and a memory, wherein the memory stores computer program instructions. When the computer program instructions are executed by the processor, a paint defect detection method based on machine vision according to the first aspect of the present invention is implemented.
[0084] The machine vision-based paint defect detection system also includes other components familiar to those skilled in the art, such as a communication interface, and their settings and functions are known in the art, so they will not be described in detail here.
[0085] In the present invention, the aforementioned memory may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, apparatus or device. For example, a computer-readable storage medium may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc., or any other medium that can be used to store the required information and can be accessed by an application, a module, or both. Any such computer storage medium may be part of a device or accessible or connectable to a device. Any application or module described in the present invention may be implemented using computer-readable / executable instructions that may be stored or otherwise maintained by such a computer-readable medium.
[0086] In the description of this specification, "plurality" or "several" means at least two, such as two, three or more, etc., unless otherwise clearly and specifically defined.
[0087] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.
Claims
1. A coating defect detection method based on machine vision, characterized in that: The method comprises: Acquire a paint history image containing defects; segment the paint history image using superpixels to obtain multiple superpixel regions, obtain feature vectors of each superpixel region and add labels for training a CNN model; obtain a real-time paint image and input it into the trained CNN model and determine whether the corresponding paint has defects based on the output result of the CNN model; The superpixel segmentation also includes clustering by adaptive metric distance, wherein: A neighborhood window is determined with any pixel point in the paint history image as the center, and the standard deviation of the brightness of each pixel point in the neighborhood window and the center pixel point is calculated; and the illumination correction factor of any pixel point is determined, specifically: ; ; ; Where C(i) represents the illumination correction factor of pixel i; I avg (i) represents the brightness mean of the neighborhood window determined by pixel i; I(i) represents the brightness value of pixel i; є represents the adjustment factor; exp( ) represents the natural exponential function; U(i) is the standard deviation of the brightness change in the area where pixel i is located, which represents the local illumination uniformity factor of pixel i; λ represents the illumination correction adjustment parameter; Ω(i) represents the neighborhood window determined by pixel i; I(j) represents the brightness value of pixel j in the neighborhood window; N represents the total number of pixels in the neighborhood window; ln represents the natural logarithm function; U max represents the maximum value of the local illumination uniformity factor in the paint history image; U(q) represents the local illumination uniformity factor of the qth pixel in the paint history image; ω represents the parameter adjustment factor; M represents the total number of pixels in the paint history image; the product of the brightness of any pixel and the illumination correction factor is used as the corrected brightness of any pixel; The sum of the differences between the corrected brightness of each pixel in the neighborhood window and the corrected brightness mean of all pixels in the neighborhood window is taken as the corrected brightness uniformity; The calculation method of the adaptive metric distance is specifically as follows: ; Where D imp (i, l) represents the adaptive metric distance between pixel i and the cluster center l in the corresponding superpixel region; D bas (i,l) represents the initial metric distance between pixel i and the cluster center l in the corresponding superpixel region; exp( ) represents the natural exponential function; W(i) represents the fluctuation factor of pixel i; W(l) represents the fluctuation factor of cluster center l in the corresponding superpixel region; The calculation method of the fluctuation factor is specifically as follows: ; Where W(i) represents the fluctuation factor of pixel i; Norm( ) represents the normalization function; Ω(i) represents the neighborhood window determined by pixel i; Cont(i) represents the texture contrast of the neighborhood window; N represents the total number of pixels in the neighborhood window; I corr (j) represents the corrected brightness value of pixel j in the neighborhood window; I corr_avg (i) represents the mean brightness of all pixels in the neighborhood window after correcting the brightness.
2. The coating defect detection method based on machine vision according to claim 1, characterized in that: The texture contrast of the neighborhood window is obtained through the contrast of the gray level co-occurrence matrix.
3. The coating defect detection method based on machine vision according to claim 1, characterized in that: The method for calculating the texture contrast of the neighborhood window is specifically as follows: Obtaining LBP values of all pixels in the neighborhood window; The standard deviation of all LBP values is taken as the texture contrast of the neighborhood window.
4. The coating defect detection method based on machine vision according to claim 1, characterized in that: Get the feature vector of each superpixel area and add labels for training the CNN model, including: Based on the meanStdDev function in OpenCV, the color mean and color standard deviation of each superpixel area in RGB space are calculated; The texture features of each superpixel region are calculated based on the gray-level co-occurrence matrix, including contrast, entropy, and uniformity. Use the countNonZero method in OpenCV to obtain the area of each superpixel region; Use the findContours method and arcLength method to obtain the perimeter of each superpixel area; Calculate the brightness mean and brightness standard deviation in each superpixel area based on the corrected brightness; After obtaining the feature vector of each super-pixel region, a label is added to each super-pixel region as "defect" or "non-defect"; The feature vector and label of each superpixel region constitute a data set for training the CNN model.
5. The coating defect detection method based on machine vision according to claim 4 is characterized in that: Obtain the real-time image of the paint and input it into the trained CNN model and determine whether the corresponding paint has defects based on the output of the CNN model, including: Get real-time images after coating production is completed; Segmenting the real-time image using a superpixel segmentation algorithm with an adaptive metric distance; Get the feature vectors of all segmented superpixel regions and input them into the trained CNN model to obtain all classification results; In response to the presence of a "defect" label in the classification result, the staff is notified to perform corresponding troubleshooting on the paint production equipment.
6. The coating defect detection method based on machine vision according to claim 1, characterized in that: Get images of coating history containing defects, including: Use high-definition industrial cameras to capture historical images of coatings containing defects; Using a bilateral filtering algorithm to perform noise reduction on the paint history image; Use the gamma correction algorithm to perform color correction on the denoised paint history image; Adaptive histogram equalization is used to enhance the local contrast of the color-corrected paint history image.
7. The coating defect detection system based on machine vision is characterized by: The invention comprises a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the coating defect detection method based on machine vision according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Abdomen CT (Computed Tomography) image multi-organ segmentation method based on superpixel
CN108364294A
Near-shore ship target detection method based on context semantic perception
CN112101250A