Large diameter pressure steel pipe coating color difference detection method based on machine vision
By using machine vision technology to calculate the prominence and reflection similarity of abnormal pixels in the coating color difference detection of large-diameter pressure steel pipes, we constructed and optimized abnormal pixels, enhanced the detection model, and solved the problem of low accuracy in traditional detection methods. , improving detection accuracy and production efficiency.
Patent Information
- Application Number
- CN202410752712.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-06-12
AI Technical Summary
The traditional AdaBoost algorithm is used in large-diameter pressure steel pipe coating color difference detection. There are few abnormal training samples and they are easy to mix with normal samples, which affects the accuracy of the detection model and results in low accuracy of detection results.
Through a method based on machine vision, the prominence and reflection similarity of the target abnormal pixels of the initial abnormal training sample are used to calculate the sampling probability, construct optimized abnormal pixels, and finally conduct preset training to enhance the color difference detection model and improve detection accuracy. .
It improves the accuracy of coating color difference detection of large-diameter pressure steel pipes, enhances the performance and stability of the detection model, and reduces production costs.
Smart Images

Figure CN118334021B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image data processing, and in particular to a method for detecting color difference in coating of large-diameter pressure steel pipes based on machine vision. Background Art
[0002] Large diameter pressure steel pipe refers to a pressure pipe with a larger diameter, usually a pipe with a diameter greater than 200 mm. This type of pipe is mainly used in high-pressure fluid transportation, chemical industry, petroleum, natural gas and other fields, and has high strength, pressure resistance and stability. Due to the high manufacturing and transportation costs of large diameter pressure steel pipes, their scope of use is subject to certain restrictions. In practical applications, according to different engineering needs, pressure steel pipes of different diameters and sizes can be selected to meet the requirements. For example, pressure water pipelines that pass through valleys, rivers, depressions, roads or other channels in long-distance water transmission projects are one of the important facilities in channel crossing buildings, large-scale water diversion projects and irrigation canal systems. They require high-level design, construction and technical management. Therefore, intelligent coating of steel pipes is one of the important links to ensure the quality of the project.
[0003] When large-diameter pressure steel pipes are put into production, the surface of the large-diameter pressure steel pipes is usually painted. The painting of the surface of large-diameter steel pipes can not only improve the appearance, but also protect the surface of the steel pipes from corrosion and oxidation. Therefore, the detection of the color difference of the coating on the surface of the steel pipe is of great significance to ensure product quality, improve production efficiency and reduce production costs. Therefore, it is particularly important to inspect the quality of the coating on the surface of large-diameter pressure steel pipes. Usually, machine vision technology is combined with an integrated learning algorithm to inspect the color difference of the coating on the surface of the steel pipe for detection. One of the commonly used algorithms is the AdaBoost algorithm. The traditional AdaBoost algorithm detects the color difference of the coating on the surface of the steel pipe. Due to the characteristics of fewer abnormal training samples and the fact that abnormal training samples are easily mixed with normal training samples, the model accuracy of the detection model is affected, resulting in the detection results of the trained detection model having low accuracy. Summary of the invention
[0004] In view of the above, it is necessary to provide a large-diameter pressure steel pipe coating color difference detection based on machine vision, which improves the detection accuracy of large-diameter pressure steel pipe coating color difference compared with traditional large-diameter pressure steel pipe coating color difference detection.
[0005] The first aspect of the present application provides a large-diameter pressure steel pipe coating color difference detection method based on machine vision, the method comprising: based on the grayscale value of the target abnormal pixel point and its corresponding neighborhood pixel point of the initial abnormal training sample, and the gradient value of the target abnormal pixel point in a preset number of directions, confirming the prominence degree corresponding to the target abnormal pixel point, wherein the initial abnormal training sample is obtained by a number of steel pipe images shot from multiple angles; according to the classification accuracy and training weight of the target abnormal pixel point in the initial training, and the cosine similarity of the feature vector corresponding to the target abnormal pixel point, calculating the reflection similarity corresponding to the target abnormal pixel point, the initial training refers to training the initial abnormal training sample for a preset number of times through a preset training algorithm; confirming the sampling probability corresponding to the target abnormal pixel point through the prominence degree and reflection similarity corresponding to the target abnormal pixel point; sampling based on the sampling probability corresponding to all abnormal pixels in the initial abnormal training sample, constructing an optimized abnormal pixel point, so as to confirm the final abnormal training sample; training the final abnormal training sample with a preset training algorithm, confirming an enhanced color difference detection model, so as to perform coating color difference detection on a number of steel pipe images shot from multiple angles.
[0006] In one embodiment, the grayscale value of the target abnormal pixel point and its corresponding neighborhood pixel point based on the initial abnormal training sample, as well as the gradient value of the target abnormal pixel point in a preset number of directions, confirms the prominence degree corresponding to the target abnormal pixel point, wherein the initial abnormal training sample is obtained through a number of steel pipe images taken from multiple angles, specifically comprising: configuring labels for the pixel points in a number of steel pipe images taken from multiple angles to obtain the initial abnormal training sample, wherein the initial abnormal training sample includes abnormal pixels and normal pixels; according to the average grayscale value of the neighborhood corresponding to the target abnormal pixel point and the average grayscale value of the image, calculating the grayscale value difference value corresponding to the target abnormal pixel point, The neighborhood average grayscale value refers to the average grayscale value of the neighborhood pixels within the preset neighborhood where the target abnormal pixel is located, and the image average grayscale value refers to the average grayscale value of the steel pipe image where the target abnormal pixel is located; based on the gradient value of a preset number of pixels of the target abnormal pixel in a preset number of directions, the average grayscale change speed corresponding to the target abnormal pixel is calculated; through the maximum gradient value of the target abnormal pixel within a preset number of pixels in a preset number of directions, the average maximum gradient value corresponding to the target abnormal pixel is calculated; the grayscale value difference value, the average grayscale change speed and the average maximum gradient value corresponding to the target abnormal pixel are used as calculation parameters to calculate the prominence degree corresponding to the target abnormal pixel.
[0007] In one embodiment, the preset neighborhood is 5×5 pixels, the preset number of directions is eight directions with a horizontal line as the reference and 45° apart from each other, the preset number of pixels when calculating the average grayscale change speed corresponding to the target abnormal pixel is 20, and the preset number of pixels when calculating the average maximum gradient value corresponding to the target abnormal pixel is 20. Correspondingly, the grayscale value difference value, the average grayscale change speed and the average maximum gradient value corresponding to the target abnormal pixel are used as calculation parameters to calculate the prominence degree corresponding to the target abnormal pixel, specifically including:
[0008] in, is the target abnormal pixel The corresponding prominence level, is the target abnormal pixel In the preset neighborhood The gray value of the neighboring pixels, is the target abnormal pixel In the corresponding steel pipe image The gray value of the image pixel, is the target abnormal pixel The total number of image pixels in the corresponding steel pipe image, is the target abnormal pixel In the In the direction The gradient value corresponding to the pixel point is is the target abnormal pixel In the In the direction The center distance between the pixel point and the center of the image, is the normalization function, is the maximum value function.
[0009] In one embodiment, the reflection similarity corresponding to the target abnormal pixel is calculated according to the classification accuracy and training weight of the target abnormal pixel in the initial training, and the cosine similarity of the feature vector corresponding to the target abnormal pixel. The initial training refers to training the initial abnormal training sample for a preset number of times through a preset training algorithm, specifically including: training the initial abnormal training sample ten times through a preset training algorithm, and counting the classification accuracy of each abnormal pixel in the initial abnormal training sample during the ten training processes and the training weight corresponding to each training; according to the feature vector corresponding to the target abnormal pixel and the feature vector corresponding to all normal pixels in the corresponding cluster, The cosine similarity of the feature vector corresponding to the target abnormal pixel point is calculated, wherein the cluster corresponding to the target abnormal pixel point refers to mapping all the pixel points of the steel pipe image corresponding to the target abnormal pixel point to the feature space, and clustering the feature vectors corresponding to all the pixels in the feature space to obtain a preset number of clusters; the normal pixels in the cluster corresponding to the target abnormal pixel point are counted and the quotient of all the pixels in the cluster is calculated to confirm the proportion of normal pixels corresponding to the target abnormal pixel point; the classification accuracy of the target abnormal pixel point in the initial training and the training weight, cosine similarity and the proportion of normal pixels are used as calculation parameters to calculate the reflection similarity corresponding to the target abnormal pixel point.
[0010] In one embodiment, the classification accuracy of the target abnormal pixel in the initial training and the training weight, the cosine similarity and the normal pixel ratio are used as calculation parameters to calculate the reflection similarity corresponding to the target abnormal pixel, specifically including:
[0011] in, is the target abnormal pixel The corresponding reflective similarity, is the classification accuracy of the target abnormal pixel in the initial training, is the target abnormal pixel The corresponding training weights are is the target abnormal pixel The first-order difference of the training weights corresponding to the jth training in the initial training, is the target abnormal pixel In the initial training The direction of the first-order difference of the training weights corresponding to the training, is the target abnormal pixel The corresponding eigenvector, is the target abnormal pixel Corresponding normal pixel points in the cluster The characteristic vector of is the target abnormal pixel The number of normal pixels in the corresponding cluster, is the target abnormal pixel The number of all pixels in the corresponding cluster, is a step function, is the cosine function.
[0012] In one of the embodiments, the sampling probability corresponding to the target abnormal pixel point is confirmed by the prominence degree and reflection similarity corresponding to the target abnormal pixel point, specifically including: calculating the average prominence degree difference value corresponding to the target abnormal pixel point according to the difference between the prominence degree corresponding to the target abnormal pixel point and the prominence degree corresponding to other abnormal pixels in the initial abnormal training sample; calculating the average reflection similarity corresponding to the target abnormal pixel point based on the reflection similarity corresponding to the target abnormal pixel point and the reflection similarity of other abnormal pixels in the initial abnormal training sample; using the average prominence degree difference value and the average reflection similarity corresponding to the target abnormal pixel point as calculation parameters to calculate the weight coefficient corresponding to the target abnormal pixel point; using the ratio of the weight coefficient corresponding to the target abnormal pixel point to the sum of the weight coefficients of all abnormal pixels in the initial abnormal training sample as the sampling probability corresponding to the target abnormal pixel point.
[0013] In one embodiment, the average prominence difference value and the average reflection similarity corresponding to the target abnormal pixel point are used as calculation parameters to calculate the weight coefficient corresponding to the target abnormal pixel point, specifically including:
[0014] in, is the target abnormal pixel The corresponding weight coefficient is, is the target abnormal pixel The number of other abnormal pixels in the corresponding initial abnormal training sample, is the target abnormal pixel The corresponding prominence level, is the target abnormal pixel Corresponding other abnormal pixels The corresponding prominence level, is the target abnormal pixel The corresponding average prominence difference value is is the target abnormal pixel The corresponding reflective similarity, is the target abnormal pixel The corresponding average reflectance similarity, is an exponential function with a natural constant as its base.
[0015] In one embodiment, the ratio of the weight coefficient corresponding to the target abnormal pixel to the sum of the weight coefficients of all abnormal pixels in the initial abnormal training sample is used as the sampling probability corresponding to the target abnormal pixel, specifically including:
[0016] in, is the target abnormal pixel The corresponding sampling probability is the target abnormal pixel The corresponding weight coefficient is, is the target abnormal pixel The sum of the weight coefficients of all abnormal pixels in the corresponding initial abnormal training sample. In one embodiment, the sampling is performed based on the sampling probability corresponding to all abnormal pixels in the initial abnormal training sample to construct the optimized abnormal pixel points to confirm the final abnormal training sample, specifically including: sampling based on the sampling probability corresponding to all abnormal pixels in the initial abnormal training sample to extract a preset number of abnormal pixels; taking the gray value mean of the preset number of abnormal pixels as the gray value of the optimized abnormal pixel point to complete the construction of an optimized abnormal pixel point; returning to the initial step until the sample balance is reached to confirm the final abnormal training sample.
[0017] In one of the embodiments, the final abnormal training sample is trained with a preset training algorithm to confirm an enhanced color difference detection model so as to perform paint color difference detection on a number of steel pipe images taken at multiple angles, specifically comprising: training a preset training algorithm with the final abnormal training sample and a normal training sample to construct an enhanced color difference detection model; performing paint color difference detection on a number of steel pipe images taken at multiple angles and inputting the enhanced color difference detection model into the enhanced color difference detection model to obtain paint color difference detection results.
[0018] The embodiment of the present application provides a large-diameter pressure steel pipe coating color difference detection method based on machine vision, the method comprising: firstly, based on the grayscale value of the target abnormal pixel point of the initial abnormal training sample and the corresponding neighboring pixel point, and the gradient value of the target abnormal pixel point in a preset number of directions, confirming the prominence degree corresponding to the target abnormal pixel point, wherein the initial abnormal training sample is obtained by a number of steel pipe images shot from multiple angles, and then calculating the reflection similarity corresponding to the target abnormal pixel point according to the classification accuracy and training weight of the target abnormal pixel point in the initial training, and the cosine similarity of the feature vector corresponding to the target abnormal pixel point, the initial training refers to training the initial abnormal training sample for a preset number of times through a preset training algorithm, and then confirming the sampling probability corresponding to the target abnormal pixel point through the prominence degree and reflection similarity corresponding to the target abnormal pixel point, and sampling based on the sampling probability corresponding to all abnormal pixels in the initial abnormal training sample, constructing an optimized abnormal pixel point, so as to confirm the final abnormal training sample, and finally training the final abnormal training sample with a preset training algorithm, confirming the enhanced color difference detection model, so as to perform coating color difference detection on a number of steel pipe images shot from multiple angles. Through the prominence degree and reflection similarity of abnormal pixels in the initial abnormal training samples, optimized abnormal pixels are constructed to confirm the final abnormal training samples for training the preset training algorithm, and the enhanced color difference detection model is obtained. Then, a number of steel pipe images taken from multiple angles are used for coating color difference detection. Compared with traditional coating color difference detection, the detection accuracy is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a flow chart of a method for detecting color difference in coating of large-diameter pressure steel pipes based on machine vision according to an embodiment of the present application.
[0020] Figure 2 It is a schematic diagram of the first sub-process of the method for detecting color difference in coating of large-diameter pressure steel pipe based on machine vision in an embodiment of the present application.
[0021] Figure 3 It is a schematic diagram of the second sub-process of the method for detecting color difference in coating of large-diameter pressure steel pipe based on machine vision in an embodiment of the present application.
[0022] Figure 4 It is a schematic diagram of the third sub-process of the method for detecting color difference in coating of large-diameter pressure steel pipe based on machine vision in an embodiment of the present application.
[0023] Figure 5 It is a schematic diagram of the fourth sub-process of the method for detecting color difference in coating of large-diameter pressure steel pipe based on machine vision in an embodiment of the present application.
[0024] Figure 6It is a schematic diagram of the fifth sub-process of the method for detecting color difference in coating of large-diameter pressure steel pipe based on machine vision in an embodiment of the present application. DETAILED DESCRIPTION
[0025] In the description of the embodiments of the present application, words such as "exemplary", "or", "for example" and the like are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary", "or", "for example" and the like is intended to present related concepts in a concrete manner.
[0026] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those generally understood by technicians in the technical field in this application. The terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. It should be understood that, unless otherwise specified in this application, " / " means or. For example, A / B can represent A or B. "And / or" in this application is only a description of the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. "At least one" means one or more. "Multiple" means two or more than two. For example, at least one of a, b or c can represent: a, b, c, a and b, a and c, b and c, a, b and c seven situations.
[0027] It should also be noted that the terms "first" and "second" in the specification, claims and drawings of this application are used to distinguish similar objects, rather than to describe a specific order or sequence. The method disclosed in the embodiments of this application or the method shown in the flowchart includes one or more steps for implementing the method. Without departing from the scope of the claims, the execution order of multiple steps can be interchanged with each other, and some steps can also be deleted.
[0028] The present application embodiment first proposes a large-diameter pressure steel pipe coating color difference detection method based on machine vision, which is applied to the field of coating color difference image detection. Figure 1 , the method comprises the following steps:
[0029] S101. Based on the grayscale values of the target abnormal pixel point and its corresponding neighborhood pixel points of the initial abnormal training sample, and the gradient value of the target abnormal pixel point in a preset number of directions, confirm the prominence degree corresponding to the target abnormal pixel point, wherein the initial abnormal training sample is obtained by a number of steel pipe images taken from multiple angles.
[0030] It should be noted that before the color difference of the coating of the large-diameter pressure steel pipe is detected by machine vision recognition, it is necessary to train the color difference detection model according to the preset detection algorithm, and the detection algorithm can be the AdaBoost algorithm. The AdaBoost (Adaptive Boosting) algorithm is an integrated learning method for training a powerful classifier. It is iteratively trained through a series of weak learners (usually decision trees), and each weak learner is adjusted according to the prediction error of the previous strong learner, thereby gradually improving the performance of the entire learner. The workflow of the AdaBoost algorithm is divided into the following steps: 1) Initialization: Select some training samples and use these samples to train weak learners (usually decision trees). 2) Iterative training: For each iteration, perform the following steps: a. Traverse all training samples, and for each sample, use the current optimal weak learner (usually a decision tree) for training. b. Evaluate the performance of the current weak learner, usually by calculating the accuracy, recall rate, F1 value and other indicators through cross-validation. c. According to the performance of the current weak learner, adjust the parameters of the weak learner, that is, the weight, so that in the next iteration, it can better predict the label of the sample. 3) Stop condition: When a certain stop condition is met (for example, the number of iterations reaches the set value or the performance no longer improves), stop training. 4) Combine weak learners: All trained weak learners are combined into a final strong learner for predicting new unlabeled samples. An important feature of the AdaBoost algorithm is that it uses weighted voting to combine the prediction results of each weak learner to ultimately obtain the final prediction result. Specifically, it will perform weighted voting based on the prediction probability of each weak learner, and weak learners with higher prediction probabilities will receive higher weights. In this way, it can ensure that the final prediction result is closer to the true label, thereby improving the generalization ability of the model. In this embodiment, the training samples include normal training samples and abnormal training samples, the normal training samples include a preset number of normal pixels, and the abnormal training samples include a preset number of abnormal pixels.
[0031] Specifically, the initial abnormal training sample includes a number of abnormal pixels, which are a number of steel pipe images taken from multiple angles, and then manually screened according to the display characteristics of the number of steel pipe images, and some pixels with large gray values or obvious defects are configured as abnormal pixels, and the remaining pixels displayed normally are configured as normal pixels. The pixels configured as abnormal pixels constitute the initial abnormal training sample. The neighborhood pixels corresponding to the target abnormal pixel refer to the pixels in the preset neighborhood corresponding to the target abnormal pixel, and the gradient value of the target abnormal pixel in the preset number of directions refers to the gradient value of the pixel in the preset number of directions starting from the target abnormal pixel. The prominence corresponding to the target abnormal pixel refers to the difference in display between the target pixel and the steel pipe image in which it is located.
[0032] It should be noted that there are usually fewer abnormal pixels in steel pipe images, that is, there are generally fewer abnormalities in the color difference of pressure steel pipe coating, which results in the abnormal training samples containing less information than the normal training samples.
[0033] S102. Calculate the reflection similarity corresponding to the target abnormal pixel point according to the classification accuracy and training weight of the target abnormal pixel point in the initial training and the cosine similarity of the feature vector corresponding to the target abnormal pixel point. The initial training refers to training the initial abnormal training sample a preset number of times through a preset training algorithm.
[0034] Among them, before obtaining parameters such as the classification accuracy and training weight corresponding to the target abnormal pixel point, the cosine similarity of the feature vector, and the reflection similarity, it is necessary to perform initial training based on the initial abnormal training sample. The initial training refers to training the initial abnormal training sample for a preset number of times through a preset training algorithm. For example, the initial abnormal training sample is trained ten times through the AdaBoost algorithm, and then all the pixels in the steel pipe image where the target abnormal pixel point is located are mapped in the feature space to confirm the distribution of each pixel point in the feature space, and each pixel point corresponds to a feature vector in the feature space, and then all the feature vectors in the feature space are K-means clustered to obtain a preset number of clusters. The number of clusters can be an empirical value of 10, that is, pixels with similar features are divided into the same cluster.
[0035] Specifically, the classification accuracy of the target abnormal pixel in the initial training refers to the classification accuracy of the target abnormal pixel after a preset number of trainings in the initial training. The training weight corresponding to the target abnormal pixel refers to the weight configured by the target abnormal pixel after a preset number of trainings in the initial training. The cosine similarity of the feature vector corresponding to the target abnormal pixel refers to the size of the angle between the feature vector corresponding to the target abnormal pixel and other feature vectors in the cluster in which it is located in the feature space. The reflection similarity corresponding to the target abnormal pixel refers to the similarity between the target abnormal pixel and the reflection pixel. The reflection pixel refers to the pixel that displays abnormality due to light reflection when shooting a large-diameter pressure steel pipe.
[0036] It should be noted that when taking surface images of large-diameter pressure steel pipes, it is difficult to avoid the influence of light on the image due to the smooth surface of the steel pipe after painting. The reflective pixels affected by light will tend to be abnormal pixels with color difference in image features. Therefore, when training these abnormal pixels, it is difficult for the classifier to distinguish them from reflective pixels, causing the algorithm to pay too much attention to these similar pixels, resulting in the trained model overfitting to this part of the data, reduced generalization ability, and reduced prediction accuracy for new samples. Not only that, the presence of too much similar feature data in the two types of samples will increase the noise and complexity of the data, making the model more susceptible to these features, resulting in increased instability of the model. The similarity between the target abnormal pixel and the reflective pixel, that is, the reflective similarity corresponding to the target abnormal pixel, is used as a consideration parameter for the subsequent construction and optimization of the abnormal pixel, which can further improve the accuracy of subsequent detection.
[0037] S103: confirming the sampling probability corresponding to the target abnormal pixel point through the prominence degree and reflection similarity corresponding to the target abnormal pixel point.
[0038] Among them, after obtaining the prominence degree and the reflective similarity corresponding to the target abnormal pixel point, the probability that the target abnormal pixel point is a true abnormal pixel point (non-reflective pixel point and normal pixel point) is calculated according to the size relationship between the prominence degree and the reflective similarity corresponding to the target abnormal pixel point, and the sampling probability corresponding to the target abnormal pixel point is configured according to the probability. The sampling probability corresponding to the target abnormal pixel point refers to the probability of being sampled for constructing the optimized abnormal pixel point. That is, the higher the probability that the target abnormal pixel point is a true abnormal pixel point (non-reflective pixel point and normal pixel point), the higher the sampling probability corresponding to the target abnormal pixel point, the higher the probability that it is likely to be selected for subsequent construction of the optimized abnormal pixel point, and the higher the detection accuracy of the color difference detection model subsequently trained according to the optimized abnormal pixel point.
[0039] S104: Sampling is performed based on the sampling probabilities corresponding to all abnormal pixels in the initial abnormal training sample to construct optimized abnormal pixels to confirm the final abnormal training sample.
[0040] Among them, after obtaining the sampling probabilities corresponding to all abnormal pixels in the initial abnormal training sample, all abnormal pixels in the initial abnormal training sample are randomly sampled, and the probability of each abnormal pixel being selected is the sampling probability corresponding to each abnormal pixel. A preset number of abnormal pixels are extracted at a time, and the grayscale values of the preset number of abnormal pixels extracted are added and averaged, and the average obtained is the grayscale value of the newly constructed optimized abnormal pixel. It should be noted that after the optimized abnormal pixel is constructed, the constructed optimized abnormal pixel is added to the initial abnormal training sample to iterate the old initial abnormal training sample, and then a new round of calculation is performed until the initial abnormal training sample and the normal training sample reach a balance, then the construction of the optimized abnormal pixel is stopped, and the final initial abnormal training sample is confirmed as the final abnormal training sample.
[0041] Furthermore, in order to ensure the training effect of the subsequent detection model, the pixels in all feature intervals should be evenly extracted during sampling so that the newly constructed pixel features can also be evenly distributed. And when sampling, the probability of extracting pixels that are too similar to reflective pixels should be minimized to avoid new pixels being too close to reflective pixels and reducing the performance of the model.
[0042] S105, training the final abnormal training sample with a preset training algorithm, confirming an enhanced color difference detection model, and performing coating color difference detection on a number of steel pipe images taken at multiple angles.
[0043] After obtaining the final abnormal training sample, the detection model is constructed by the AdaBoost algorithm based on the normal training sample and the final abnormal training sample to obtain an enhanced color difference detection model. After obtaining the enhanced color difference detection model, a number of steel pipe images taken from multiple angles are input into the enhanced color difference detection model to perform coating color difference detection and obtain corresponding detection results.
[0044] The embodiment of the present application provides a large-diameter pressure steel pipe coating color difference detection method based on machine vision, the method comprising: firstly, based on the grayscale value of the target abnormal pixel point of the initial abnormal training sample and the corresponding neighboring pixel point, and the gradient value of the target abnormal pixel point in a preset number of directions, confirming the prominence degree corresponding to the target abnormal pixel point, wherein the initial abnormal training sample is obtained by a number of steel pipe images shot from multiple angles, and then calculating the reflection similarity corresponding to the target abnormal pixel point according to the classification accuracy and training weight of the target abnormal pixel point in the initial training, and the cosine similarity of the feature vector corresponding to the target abnormal pixel point, the initial training refers to training the initial abnormal training sample for a preset number of times through a preset training algorithm, and then confirming the sampling probability corresponding to the target abnormal pixel point through the prominence degree and reflection similarity corresponding to the target abnormal pixel point, and sampling based on the sampling probability corresponding to all abnormal pixels in the initial abnormal training sample, constructing an optimized abnormal pixel point, so as to confirm the final abnormal training sample, and finally training the final abnormal training sample with a preset training algorithm, confirming the enhanced color difference detection model, so as to perform coating color difference detection on a number of steel pipe images shot from multiple angles. Through the prominence degree and reflection similarity of abnormal pixels in the initial abnormal training samples, optimized abnormal pixels are constructed to confirm the final abnormal training samples for training the preset training algorithm, and the enhanced color difference detection model is obtained. Then, a number of steel pipe images taken from multiple angles are used for coating color difference detection. Compared with traditional coating color difference detection, the detection accuracy is improved.
[0045] In one embodiment of the present application, see Figure 2 , the step S101, the grayscale value of the target abnormal pixel point and its corresponding neighborhood pixel point based on the initial abnormal training sample, and the gradient value of the target abnormal pixel point in a preset number of directions, confirming the prominence degree corresponding to the target abnormal pixel point, wherein the initial abnormal training sample is obtained by a number of steel pipe images taken from multiple angles, specifically including:
[0046] S201. Assign labels to pixel points in a number of steel pipe images taken at multiple angles to obtain initial abnormal training samples, wherein the initial abnormal training samples include a number of abnormal pixel points.
[0047] After obtaining a number of steel pipe images taken at multiple angles, the pixels in the number of steel pipe images taken at multiple angles are screened, and some pixels with obvious color difference or obvious defects are labeled as abnormal pixels, and the remaining normal pixels are labeled as normal pixels. The pixels labeled with abnormal pixels are the initial abnormal training samples, and the pixels labeled with normal pixels are the normal training samples.
[0048] S202. Calculate the grayscale value difference value corresponding to the target abnormal pixel point according to the neighborhood average grayscale value corresponding to the target abnormal pixel point and the image average grayscale value. The neighborhood average grayscale value refers to the average grayscale value of the neighborhood pixels in the preset neighborhood where the target abnormal pixel point is located, and the image average grayscale value refers to the average grayscale value of the steel pipe image where the target abnormal pixel point is located.
[0049] Among them, according to the grayscale values of all neighboring pixels in the preset neighborhood corresponding to the target abnormal pixel, the neighborhood average grayscale value corresponding to the target abnormal pixel is calculated. The preset neighborhood corresponding to the target abnormal pixel is a 5×5 neighborhood range centered on the target abnormal pixel. Then, according to the grayscale values of all pixels in the steel pipe image where the target abnormal pixel is located, the average grayscale value of all pixels in the steel pipe image is calculated, that is, the image average grayscale value corresponding to the target abnormal pixel. The neighborhood average grayscale value refers to the average grayscale value of the neighborhood pixels in the preset neighborhood where the target abnormal pixel is located, and the image average grayscale value refers to the average grayscale value of the steel pipe image where the target abnormal pixel is located. After obtaining the neighborhood average grayscale value and the image average grayscale value corresponding to the target abnormal pixel, the difference between the two is calculated to obtain the grayscale value difference between the local area where the target abnormal pixel is located and the overall area of the steel pipe image, that is, the grayscale value difference value corresponding to the target abnormal pixel.
[0050] S203. Calculate the average grayscale change speed corresponding to the target abnormal pixel based on the gradient values of a preset number of pixel points of the target abnormal pixel in a preset number of directions.
[0051] Among them, the preset number of directions of the target abnormal pixel point refers to defining a preset number of different directions with the target abnormal pixel point as the starting point. Preferably, the preset number of directions of the target abnormal pixel point are eight directions with a 45° interval from each other based on the horizontal line, specifically, with the target abnormal pixel point as the starting point and the horizontal line passing through the target abnormal pixel point as the 0 degree direction, eight vectors with a 45 degree interval from each other are determined to obtain 8 directions centered on the reference pixel. The gradient value of the preset number of pixel points of the target abnormal pixel point in the preset number of directions refers to taking a preset number of pixel points in the preset number of directions of the target abnormal pixel point and calculating the gradient value corresponding to the pixel point. The average grayscale change speed corresponding to the target abnormal pixel point refers to the average change rate of the gradient value of the target abnormal pixel point in the preset number of directions.
[0052] S204, calculating an average maximum gradient value corresponding to the target abnormal pixel point through the maximum gradient values within a preset number of pixel points of the target abnormal pixel point in a preset number of directions.
[0053] Among them, the maximum gradient value of the target abnormal pixel within a preset number of pixels in a preset number of directions means that the target abnormal pixel takes a preset number of pixels in each preset number of directions, obtains the gradient values of the preset number of pixels, and takes the maximum gradient value as the maximum gradient value of the target abnormal pixel in this direction, that is, the target abnormal pixel has a maximum gradient value in each preset number of directions. The maximum gradient values of the target abnormal pixel in each preset number of directions are averaged to obtain the average maximum gradient value corresponding to the target abnormal pixel.
[0054] S205, using the grayscale value difference value, average grayscale change speed and average maximum gradient value corresponding to the target abnormal pixel point as calculation parameters, and calculating the prominence degree corresponding to the target abnormal pixel point.
[0055] Among them, after obtaining the gray value difference value, average gray value change speed and average maximum gradient value corresponding to the target abnormal pixel point, the three are used as calculation parameters to further calculate the prominence degree corresponding to the target abnormal pixel point. The prominence degree corresponding to the target abnormal pixel point refers to the difference degree of the target abnormal pixel point relative to the steel pipe image in which it is located. The greater the prominence degree corresponding to the target abnormal pixel point, the more likely the target abnormal pixel point is to be the final abnormal pixel point.
[0056] Specifically, the preset neighborhood is 5×5 pixels, the preset number of directions is eight directions with a horizontal line as the reference and 45° apart from each other, the preset number of pixels when calculating the average grayscale change speed corresponding to the target abnormal pixel is 20, and the preset number of pixels when calculating the average maximum gradient value corresponding to the target abnormal pixel is 20. Correspondingly, the grayscale value difference value, the average grayscale change speed and the average maximum gradient value corresponding to the target abnormal pixel are used as calculation parameters to calculate the prominence degree corresponding to the target abnormal pixel, specifically including:
[0057] in, is the target abnormal pixel The corresponding prominence level, is the target abnormal pixel In the preset neighborhood The gray value of the neighboring pixels, is the target abnormal pixel In the corresponding steel pipe image The gray value of the image pixel, is the target abnormal pixel The total number of image pixels in the corresponding steel pipe image, is the target abnormal pixel In the In the direction The gradient value corresponding to the pixel point is is the target abnormal pixel In the In the direction The center distance between the pixel point and the center of the image, is the target abnormal pixel In the The maximum gradient value among 20 pixels in each direction, is the normalization function, is the maximum value function.
[0058] Furthermore, is the average gray value of the neighborhood corresponding to the target abnormal pixel, is the average gray value of the image corresponding to the target abnormal pixel, is the grayscale value difference value corresponding to the target abnormal pixel point. When the grayscale value difference value corresponding to the target abnormal pixel point is large, that is, the average grayscale value of the neighborhood pixels in the preset neighborhood where the target abnormal pixel point is located is large different from the average grayscale value of the steel pipe image where the target abnormal pixel point is located, it proves that the greater the grayscale value difference between the local area where the target abnormal pixel point is located and the overall area of the steel pipe image, the more likely the target abnormal pixel point is to be the final abnormal pixel point. is the average grayscale change speed corresponding to the target abnormal pixel. When the average grayscale change speed corresponding to the target abnormal pixel is large, it proves that the grayscale value change difference between the target abnormal pixel and its local position is large, which is more likely to be caused by the color difference of the pressure steel pipe coating. Therefore, the greater the average grayscale change speed corresponding to the target abnormal pixel, the more likely the target abnormal pixel is to be the final abnormal pixel. It is the average maximum gradient value corresponding to the target abnormal pixel, which can characterize the amplitude of the gray value change of the target abnormal pixel in the preset number of directions to a certain extent. If the average maximum gradient value corresponding to the target abnormal pixel is larger, it proves that the amplitude of the gray value change of the target abnormal pixel in the preset number of directions is larger, and the target abnormal pixel is more likely to be the final abnormal pixel.
[0059] In one embodiment of the present application, refer to the attached Figure 3 Step S102: Calculate the reflection similarity corresponding to the target abnormal pixel point according to the classification accuracy and training weight of the target abnormal pixel point in the initial training and the cosine similarity of the feature vector corresponding to the target abnormal pixel point. The initial training refers to training the initial abnormal training sample for a preset number of times through a preset training algorithm, which specifically includes:
[0060] S301, training the initial abnormal training sample ten times using a preset training algorithm, and counting the classification accuracy of each abnormal pixel point in the initial abnormal training sample during the ten training processes and the training weight corresponding to each training.
[0061] Among them, the classification accuracy of each abnormal pixel point in the ten training processes refers to the classification accuracy of each abnormal pixel point in the ten training processes in the initial training, and the training weight corresponding to each abnormal pixel point in each training of the ten training processes refers to the weight configured for the abnormal pixel point in each training.
[0062] S302. Calculate the cosine similarity of the feature vector corresponding to the target abnormal pixel point based on the feature vector corresponding to the target abnormal pixel point and the feature vectors corresponding to all normal pixels in its corresponding cluster, wherein the cluster corresponding to the target abnormal pixel point refers to mapping all pixels of the steel pipe image corresponding to the target abnormal pixel point to the feature space, and clustering the feature vectors corresponding to all pixels in the feature space to obtain a preset number of clusters.
[0063] Among them, all the pixels in the steel pipe image where the target abnormal pixel is located are mapped in the feature space to confirm the distribution of each pixel in the feature space, and each pixel corresponds to a feature vector in the feature space, and then all the feature vectors in the feature space are clustered by K-means to obtain a preset number of clusters. The number of clusters can be an empirical value of 10, that is, pixels with similar features are divided into the same cluster. The cosine similarity of the feature vector corresponding to the target abnormal pixel refers to the size of the angle between the feature vector corresponding to the target abnormal pixel in the feature space and other feature vectors in the clustering cluster. That is to say, when the angle between the feature vector corresponding to the target abnormal pixel and other feature vectors in the feature space is larger, the cosine similarity of the feature vector corresponding to the target abnormal pixel is larger, which proves that the feature vector corresponding to the target abnormal pixel is more different from other feature vectors, and the corresponding target abnormal pixel is more likely to be a pixel in the color difference area.
[0064] S303, calculating the quotient of normal pixels in the cluster corresponding to the target abnormal pixel and all pixels in the cluster to determine the proportion of normal pixels corresponding to the target abnormal pixel.
[0065] Among them, the ratio of normal pixels in the cluster corresponding to the target abnormal pixel to all pixels in the cluster is the proportion of normal pixels corresponding to the target abnormal pixel, which can characterize the number of normal pixels in the cluster corresponding to the target abnormal pixel. The larger the number, the less likely it is that the target abnormal pixel is a pixel in the color difference area.
[0066] S304, using the classification accuracy of the target abnormal pixel in the initial training and the training weight, the cosine similarity and the normal pixel ratio as calculation parameters, and calculating the reflection similarity corresponding to the target abnormal pixel.
[0067] Among them, the reflection similarity corresponding to the target abnormal pixel point refers to the similarity between the target abnormal pixel point and the reflection pixel point, and the reflection pixel point refers to the pixel point that displays abnormality due to light reflection when shooting a large-diameter pressure steel pipe. The purpose of calculating the reflection similarity corresponding to the target abnormal pixel point is to distinguish the reflective pixels affected by the illumination from the reflective pixels. Because the reflective pixels affected by the illumination will tend to be partial to the abnormal pixels with color difference in image features, the reflection similarity is used as a calculation parameter for subsequent calculation, which can improve the accuracy of subsequent color difference detection.
[0068] Specifically, the classification accuracy of the target abnormal pixel in the initial training and the training weight, cosine similarity and the proportion of normal pixels are used as calculation parameters to calculate the reflection similarity corresponding to the target abnormal pixel, which specifically includes:
[0069] in, is the target abnormal pixel Corresponding reflection similarity is the classification accuracy of the target abnormal pixel in the initial training is the target abnormal pixel The corresponding training weights is the target abnormal pixel The first-order difference of the training weights corresponding to the jth training in the initial training, is the target abnormal pixel In the initial training The direction of the first-order difference of the training weights corresponding to the training, is the target abnormal pixel The corresponding eigenvector, is the target abnormal pixel Corresponding normal pixel points in the cluster The characteristic vector of is the target abnormal pixel The number of normal pixels in the corresponding cluster, is the target abnormal pixel The number of all pixels in the corresponding cluster, is a step function, is the cosine function.
[0070] Furthermore, It is the reciprocal of the classification accuracy of the target abnormal pixel in the initial training. When the classification accuracy of the target abnormal pixel in the initial training is greater, the reciprocal is smaller, which proves that the target abnormal pixel is less likely to be a reflective pixel. It is the sum of the first-order differences of the training weights corresponding to each training in the ten trainings, where the first-order difference refers to the difference between two adjacent continuous training weights. It is the sum of the function values of the step function corresponding to the direction of the first-order difference of the training weight corresponding to each training in the ten trainings. The function of the step function is to return an integer variable to indicate the positive and negative signs of the parameters, that is, to characterize the direction of the parameters. When the directions are consistent, the function returns 1, and when the directions are inconsistent, the value returns -1. When the directions of the first-order differences of the training weights in the ten trainings are inconsistent, the more times the weight of the reference pixel increases and decreases, indicating that the positive and negative signs of the pixel often change during differentiation, making it difficult to distinguish. Therefore, the higher the similarity between the pixel and the reflective pixel, the higher the similarity. The corresponding value is smaller, which proves that the pixel often changes in correctness and error during distinction, making it difficult to distinguish, indicating that it is more likely to be a reflective pixel. The cosine similarity of the feature vector corresponding to the target abnormal pixel is the average value of the cosine value of the angle between the feature vector corresponding to the target abnormal pixel and other feature vectors in the same cluster. The larger the average value, the smaller the angle between the feature vector corresponding to the target abnormal pixel and other feature vectors, and the more likely it is a reflective pixel. In summary, the above three calculation parameters are proportional to the probability of becoming a reflective pixel, that is, proportional to the reflective similarity corresponding to the target abnormal pixel. The larger the values of the three calculation parameters, the greater the reflective similarity corresponding to the target abnormal pixel, and the less likely it is a pixel in the color difference area.
[0071] In one embodiment of the present application, refer to the attached Figure 4 Step S103, confirming the sampling probability corresponding to the target abnormal pixel point through the prominence degree and reflection similarity corresponding to the target abnormal pixel point, specifically includes:
[0072] S401. Calculate an average prominence difference value corresponding to the target abnormal pixel point according to the difference between the prominence degree corresponding to the target abnormal pixel point and the prominence degrees corresponding to other abnormal pixel points in the initial abnormal training sample.
[0073] Among them, after obtaining the prominence degree corresponding to the target abnormal pixel point, the prominence degrees corresponding to other abnormal pixel points in the initial abnormal training sample are obtained synchronously, and the prominence degree corresponding to the target abnormal pixel point and the prominence degrees corresponding to other abnormal pixels are calculated one by one to obtain the difference in the prominence degree corresponding to the target abnormal pixel point, and then the difference in the prominence degree corresponding to the target abnormal pixel point is averaged to obtain the average prominence degree difference value corresponding to the target abnormal pixel point.
[0074] S402: Calculate the average reflection similarity corresponding to the target abnormal pixel based on the reflection similarity corresponding to the target abnormal pixel and the reflection similarities of other abnormal pixels in the initial abnormal training sample.
[0075] After obtaining the reflection similarity corresponding to the target abnormal pixel, the reflection similarities of other abnormal pixels in the initial abnormal training sample are counted, and the average reflection similarity in the initial abnormal training sample corresponding to the target abnormal pixel is calculated.
[0076] S403: Taking the average prominence degree difference value and the average reflection similarity corresponding to the target abnormal pixel point as calculation parameters, calculate the weight coefficient corresponding to the target abnormal pixel point.
[0077] After obtaining the average prominence difference value and the average reflection similarity corresponding to the target abnormal pixel point, a preset calculation formula is input to calculate the weight coefficient corresponding to the target abnormal pixel point.
[0078] Specifically, the average prominence difference value and the average reflection similarity corresponding to the target abnormal pixel point are used as calculation parameters to calculate the weight coefficient corresponding to the target abnormal pixel point, which specifically includes:
[0079] in, is the target abnormal pixel The corresponding weight coefficient is, is the target abnormal pixel The number of other abnormal pixels in the corresponding initial abnormal training sample, is the target abnormal pixel The corresponding prominence level, is the target abnormal pixel Corresponding other abnormal pixels The corresponding prominence level, is the target abnormal pixel The corresponding prominence degree and target abnormal pixel point Corresponding other abnormal pixels The absolute value of the difference in the corresponding prominence degree, is the target abnormal pixel The corresponding average prominence difference value is is the target abnormal pixel The corresponding reflective similarity, is the average reflection similarity in the initial abnormal training samples corresponding to the target abnormal pixel, is the target abnormal pixel The corresponding average reflectance similarity ratio, is an exponential function with a natural constant as its base.
[0080] Furthermore, the average prominence difference value corresponding to the target abnormal pixel point is proportional to the weight coefficient corresponding to the target abnormal pixel point. Ratio of similarity to the corresponding average reflectance It is inversely proportional to the weight coefficient corresponding to the target abnormal pixel. and The larger the value, the more likely it is that the image pixel is in the color difference area, and the larger the weight coefficient corresponding to the target abnormal pixel should be configured.
[0081] S404: taking the ratio of the weight coefficient corresponding to the target abnormal pixel point to the sum of the weight coefficients of all abnormal pixels in the initial abnormal training sample as the sampling probability corresponding to the target abnormal pixel point.
[0082] Among them, the sampling probability corresponding to the target abnormal pixel point refers to the probability that the target abnormal pixel point is selected to construct the optimized abnormal pixel point. It should be noted that the larger the abnormal pixel point is, the more likely it is to be a pixel point in the color difference area image, and the corresponding sampling probability should be configured to be a larger probability.
[0083] Specifically, the ratio of the weight coefficient corresponding to the target abnormal pixel point to the sum of the weight coefficients of all abnormal pixels in the initial abnormal training sample is used as the sampling probability corresponding to the target abnormal pixel point, which specifically includes:
[0084] in, is the target abnormal pixel The corresponding sampling probability is the target abnormal pixel The corresponding weight coefficient is, is the target abnormal pixel The sum of the weight coefficients of all abnormal pixels in the corresponding initial abnormal training sample.
[0085] Furthermore, when the target abnormal pixel is more likely to be a pixel in the color difference area, the corresponding sampling probability is greater, and the probability of being selected to construct the optimized abnormal pixel is greater, the quality of the subsequently constructed optimized abnormal pixel is higher, and the detection quality of the corresponding trained detection model is higher.
[0086] In one embodiment of the present application, refer to the attached Figure 5 Step S104, sampling based on the sampling probabilities corresponding to all abnormal pixels in the initial abnormal training sample to construct optimized abnormal pixels to confirm the final abnormal training sample, specifically includes:
[0087] S501, sampling based on the sampling probabilities corresponding to all abnormal pixels in the initial abnormal training sample, extracting a preset number of abnormal pixels;
[0088] S502, taking the grayscale value average of a preset number of abnormal pixel points as the grayscale value of the optimized abnormal pixel point, so as to complete the construction of an optimized abnormal pixel point;
[0089] S503: Return to the initial step until the sample balance is reached and the final abnormal training sample is confirmed.
[0090] Among them, after obtaining the sampling probabilities corresponding to all abnormal pixels in the initial abnormal training sample, a preset number of samples are sampled in the initial abnormal training sample according to the sampling probability, and the empirical value can be 10. Then, the grayscale value average of the preset number of abnormal pixels sampled is used as the grayscale value of the optimized abnormal pixel to complete the construction of an optimized abnormal pixel. The optimized abnormal pixel that has been constructed is put back into the initial abnormal training sample as a new initial abnormal training sample to perform the next round of calculation and construction until it is balanced with the normal training sample and the final abnormal training sample is confirmed.
[0091] In some other embodiments, refer to the attached Figure 6 Step S105, training the final abnormal training sample with a preset training algorithm, confirming the enhanced color difference detection model, and performing coating color difference detection on a number of steel pipe images taken at multiple angles, specifically includes:
[0092] S601, training a preset training algorithm by using the final abnormal training samples and the normal training samples to construct an enhanced color difference detection model;
[0093] S602, performing coating color difference detection on a plurality of steel pipe images taken at multiple angles and inputting them into an enhanced color difference detection model to obtain coating color difference detection results.
[0094] Among them, after obtaining the final abnormal training samples and normal training samples, the preset training algorithm, preferably the AdaBoost algorithm, is used to train and construct the enhanced color difference detection model. After the enhanced color difference detection model is constructed, the plurality of steel pipe images taken from multiple angles are input into the enhanced color difference detection model for coating color difference detection to obtain coating color difference detection results. In other words, after the enhanced color difference detection model is constructed, the user can use a camera to shoot the surface of the large-diameter pressure steel pipe, and use the trained enhanced color difference detection model to perform pixel classification on the collected image to determine whether there are color difference pixels in the image. If the enhanced color difference detection model detects that there are color difference pixels in a certain image, the operator is reminded to reprocess the unqualified area on the surface of the steel pipe to complete the coating color difference detection of the large-diameter pressure steel pipe.
[0095] The embodiment of the present application provides a large-diameter pressure steel pipe coating color difference detection method based on machine vision, the method comprising: firstly, based on the grayscale value of the target abnormal pixel point of the initial abnormal training sample and the corresponding neighboring pixel point, and the gradient value of the target abnormal pixel point in a preset number of directions, confirming the prominence degree corresponding to the target abnormal pixel point, wherein the initial abnormal training sample is obtained by a number of steel pipe images shot from multiple angles, and then calculating the reflection similarity corresponding to the target abnormal pixel point according to the classification accuracy and training weight of the target abnormal pixel point in the initial training, and the cosine similarity of the feature vector corresponding to the target abnormal pixel point, the initial training refers to training the initial abnormal training sample for a preset number of times through a preset training algorithm, and then confirming the sampling probability corresponding to the target abnormal pixel point through the prominence degree and reflection similarity corresponding to the target abnormal pixel point, and sampling based on the sampling probability corresponding to all abnormal pixels in the initial abnormal training sample, constructing an optimized abnormal pixel point, so as to confirm the final abnormal training sample, and finally training the final abnormal training sample with a preset training algorithm, confirming the enhanced color difference detection model, so as to perform coating color difference detection on a number of steel pipe images shot from multiple angles. Through the prominence degree and reflection similarity of abnormal pixels in the initial abnormal training samples, optimized abnormal pixels are constructed to confirm the final abnormal training samples for training the preset training algorithm, and the enhanced color difference detection model is obtained. Then, a number of steel pipe images taken from multiple angles are used for coating color difference detection. Compared with traditional coating color difference detection, the detection accuracy is improved.
[0096] The flowchart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to the embodiment of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. In the description corresponding to the flowchart and the block diagram in the accompanying drawings, the operations or steps corresponding to different boxes can also occur in a different order from the order disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified functions or actions, or may be implemented by a combination of dedicated hardware and computer instructions.
[0097] It is obvious to those skilled in the art that the present application is not limited to the details of the above exemplary embodiments, and that the present application can be implemented in other specific forms without departing from the spirit or basic features of the present application. Therefore, no matter from which point of view, the above embodiments of the present application should be regarded as exemplary and non-restrictive, and the scope of the present application is defined by the attached claims rather than the above description, and therefore it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present application.
Claims
1. A method for detecting color difference of large-diameter pressure steel pipe coating based on machine vision. It is characterized in that The method comprises: Based on the grayscale values of the target abnormal pixel point and its corresponding neighboring pixel points of the initial abnormal training sample, and the gradient value of the target abnormal pixel point in a preset number of directions, the highlight degree corresponding to the target abnormal pixel point is confirmed, wherein the initial abnormal training sample is obtained by a number of steel pipe images taken from multiple angles; Calculate the reflection similarity corresponding to the target abnormal pixel point according to the classification accuracy and training weight of the target abnormal pixel point in the initial training and the cosine similarity of the feature vector corresponding to the target abnormal pixel point, wherein the initial training refers to training the initial abnormal training sample a preset number of times through a preset training algorithm; Confirm the sampling probability corresponding to the target abnormal pixel point through the prominence degree and reflection similarity corresponding to the target abnormal pixel point; Sampling is performed based on the sampling probabilities corresponding to all abnormal pixels in the initial abnormal training sample to construct optimized abnormal pixels to confirm the final abnormal training sample; The final abnormal training sample is trained with a preset training algorithm to confirm an enhanced color difference detection model to perform coating color difference detection on a number of steel pipe images taken at multiple angles, wherein the preset training algorithm is an AdaBoost algorithm; The grayscale value of the target abnormal pixel point and its corresponding neighboring pixel point based on the initial abnormal training sample, and the gradient value of the target abnormal pixel point in a preset number of directions, confirm the prominence degree corresponding to the target abnormal pixel point, wherein the initial abnormal training sample is obtained by a number of steel pipe images taken from multiple angles, specifically including: Assign labels to the pixel points in a number of steel pipe images taken at multiple angles to obtain initial abnormal training samples, wherein the initial abnormal training samples include a number of abnormal pixel points; According to the neighborhood average grayscale value corresponding to the target abnormal pixel point and the image average grayscale value, the grayscale value difference value corresponding to the target abnormal pixel point is calculated, wherein the neighborhood average grayscale value refers to the average grayscale value of the neighborhood pixels in the preset neighborhood where the target abnormal pixel point is located, and the image average grayscale value refers to the average grayscale value of the steel pipe image where the target abnormal pixel point is located; Based on the gradient values of a preset number of pixel points of the target abnormal pixel point in a preset number of directions, the average grayscale change speed corresponding to the target abnormal pixel point is calculated; Calculate the average maximum gradient value corresponding to the target abnormal pixel point through the maximum gradient value within a preset number of pixel points in a preset number of directions of the target abnormal pixel point; The grayscale value difference, average grayscale change speed and average maximum gradient value corresponding to the target abnormal pixel point are used as calculation parameters to calculate the prominence degree corresponding to the target abnormal pixel point; The preset neighborhood is 5×5 pixels, the preset number of directions is eight directions with a 45° interval between each other based on the horizontal line, the preset number of pixels when calculating the average grayscale change speed corresponding to the target abnormal pixel is 20, and the preset number of pixels when calculating the average maximum gradient value corresponding to the target abnormal pixel is 20. Correspondingly, the grayscale value difference value, the average grayscale change speed and the average maximum gradient value corresponding to the target abnormal pixel are used as calculation parameters to calculate the prominence degree corresponding to the target abnormal pixel, specifically including: in, is the target abnormal pixel The corresponding prominence level, is the target abnormal pixel In the preset neighborhood The gray value of the neighboring pixels, is the target abnormal pixel In the corresponding steel pipe image The gray value of the image pixel, is the target abnormal pixel The total number of image pixels in the corresponding steel pipe image, is the target abnormal pixel In the In the direction The gradient value corresponding to the pixel point is is the target abnormal pixel In the In the direction The center distance between the pixel point and the center of the image, is the normalization function, is the maximum value function; The calculation of the reflection similarity corresponding to the target abnormal pixel point is based on the classification accuracy and training weight of the target abnormal pixel point in the initial training, and the cosine similarity of the feature vector corresponding to the target abnormal pixel point. The initial training refers to training the initial abnormal training sample for a preset number of times through a preset training algorithm, specifically including: The initial abnormal training sample is trained ten times by a preset training algorithm, and the classification accuracy of each abnormal pixel point in the initial abnormal training sample during the ten training processes and the training weight corresponding to each training are counted; According to the feature vector corresponding to the target abnormal pixel point and the feature vector corresponding to all normal pixels in its corresponding cluster, the cosine similarity of the feature vector corresponding to the target abnormal pixel point is calculated, wherein the cluster corresponding to the target abnormal pixel point refers to mapping all pixels of the steel pipe image corresponding to the target abnormal pixel point to the feature space, and clustering the feature vectors corresponding to all pixels in the feature space to obtain a preset number of clusters; Calculate the quotient of normal pixels in the cluster corresponding to the target abnormal pixel and all pixels in the cluster to confirm the proportion of normal pixels corresponding to the target abnormal pixel; The classification accuracy of the target abnormal pixel in the initial training, the training weight, the cosine similarity, and the proportion of normal pixels are used as calculation parameters to calculate the reflection similarity corresponding to the target abnormal pixel; The method uses the classification accuracy of the target abnormal pixel points in the initial training, the training weight, the cosine similarity, and the normal pixel ratio as calculation parameters to calculate the reflection similarity corresponding to the target abnormal pixel points, specifically including: in, is the target abnormal pixel The corresponding reflective similarity, is the classification accuracy of the target abnormal pixel in the initial training, is the target abnormal pixel The corresponding training weights are is the target abnormal pixel The first-order difference of the training weights corresponding to the jth training in the initial training, is the target abnormal pixel In the initial training The direction of the first-order difference of the training weights corresponding to the training, is the target abnormal pixel The corresponding eigenvector, is the target abnormal pixel Corresponding normal pixel points in the cluster The characteristic vector of is the target abnormal pixel The number of normal pixels c in the corresponding cluster, is the target abnormal pixel The number of all pixels in the corresponding cluster, is a step function, is the cosine function.
2. According to the method for detecting color difference of large-diameter pressure steel pipe coating based on machine vision in claim 1, It is characterized in that The step of confirming the sampling probability corresponding to the target abnormal pixel point by the prominence degree and the reflection similarity corresponding to the target abnormal pixel point specifically includes: According to the difference between the prominence degree corresponding to the target abnormal pixel point and the prominence degree corresponding to other abnormal pixel points in the initial abnormal training sample, the average prominence degree difference value corresponding to the target abnormal pixel point is calculated; Based on the reflection similarity corresponding to the target abnormal pixel and the reflection similarity of other abnormal pixels in the initial abnormal training sample, the average reflection similarity corresponding to the target abnormal pixel is calculated; The average prominence difference value and the average reflection similarity corresponding to the target abnormal pixel point are used as calculation parameters to calculate the weight coefficient corresponding to the target abnormal pixel point; The ratio of the weight coefficient corresponding to the target abnormal pixel point to the sum of the weight coefficients of all abnormal pixels in the initial abnormal training sample is used as the sampling probability corresponding to the target abnormal pixel point.
3. According to the method for detecting color difference of large-diameter pressure steel pipe coating based on machine vision in claim 2, It is characterized in that The method of using the average prominence degree difference value and the average reflection similarity corresponding to the target abnormal pixel point as calculation parameters to calculate the weight coefficient corresponding to the target abnormal pixel point specifically includes: in, is the target abnormal pixel The corresponding weight coefficient is, is the target abnormal pixel The number of other abnormal pixels in the corresponding initial abnormal training sample, is the target abnormal pixel The corresponding prominence level, is the target abnormal pixel Corresponding other abnormal pixels The corresponding prominence level, is the target abnormal pixel The corresponding average prominence difference value is is the target abnormal pixel The corresponding reflective similarity, is the target abnormal pixel The corresponding average reflectance similarity, is an exponential function with a natural constant as its base.
4. According to the method for detecting color difference of large-diameter pressure steel pipe coating based on machine vision in claim 3, It is characterized in that The ratio of the weight coefficient corresponding to the target abnormal pixel point to the sum of the weight coefficients of all abnormal pixels in the initial abnormal training sample is used as the sampling probability corresponding to the target abnormal pixel point, specifically including: in, is the target abnormal pixel The corresponding sampling probability is, is the target abnormal pixel The corresponding weight coefficient is, is the target abnormal pixel The sum of the weight coefficients of all abnormal pixels in the corresponding initial abnormal training sample.
5. According to the method for detecting color difference of coating of large-diameter pressure steel pipe based on machine vision in claim 3, It is characterized in that The sampling is performed based on the sampling probabilities corresponding to all abnormal pixels in the initial abnormal training sample to construct optimized abnormal pixels to confirm the final abnormal training sample, specifically including: Sampling is performed based on the sampling probabilities corresponding to all abnormal pixels in the initial abnormal training sample to extract a preset number of abnormal pixels; The grayscale value average of a preset number of abnormal pixels is used as the grayscale value of the optimized abnormal pixel to complete the construction of an optimized abnormal pixel; Return to the initial step until sample balance is achieved and the final abnormal training sample is confirmed.
6. The method for detecting color difference of coating of large-diameter pressure steel pipe based on machine vision according to any one of claims 1 to 5, It is characterized in that The final abnormal training sample is trained with a preset training algorithm to confirm the enhanced color difference detection model to perform coating color difference detection on a number of steel pipe images taken at multiple angles, specifically including: The preset training algorithm is trained by the final abnormal training samples and normal training samples to build an enhanced color difference detection model; The plurality of steel pipe images taken at multiple angles are subjected to coating color difference detection and input into an enhanced color difference detection model to obtain coating color difference detection results.
