A powder spraying defect detection method and system based on image processing
By using a method based on image processing, the impact degree of particle defects on the spraying surface is calculated and clustered, which solves the problem in the existing technology of being unable to accurately detect the location of particle defects on the spraying surface, and achieves accurate location of particle defects on the spraying surface. detection, improving the accuracy of detection results.
Patent Information
- Application Number
- CN202410896865.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-07-05
AI Technical Summary
Existing spray defect detection methods cannot accurately detect the location of particle defects on the spray surface, especially in dark-colored spray materials, and traditional clustering algorithms cannot effectively segment the defect locations.
An image processing-based method is used to obtain the sprayed surface image for preprocessing, calculate the impact degree of particle defects at each pixel, and use the gradient direction consistency and difference degree for clustering to accurately locate the location of particle defects.
It achieves accurate detection of particle defect locations on the spray surface, improves the accuracy of detection results, and ensures that the quality of spray products meets standards.
Smart Images

Figure CN118429354B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and more specifically, to a powder spraying defect detection method and system based on image processing. Background Art
[0002] Since metal materials are easy to rust in a humid environment, in order to protect the metal surface of mechanical equipment, powder materials are usually sprayed on its surface. Under the action of static electricity, the powder will be evenly adsorbed on the surface of the workpiece to form a powdery coating; thereby enhancing the mechanical strength, adhesion, corrosion resistance and aging resistance of the mechanical equipment. However, if the spraying quality is poor, it will affect the appearance of the product, and cause the metal surface of the mechanical equipment to corrode when in contact with the air, seriously affecting the service life of the mechanical equipment. Therefore, it is very important to monitor the spraying quality of the spraying surface in real time during the spraying process. When the spraying quality is detected to be poor, the spraying can be stopped, and the relevant personnel can make timely adjustments according to the actual situation to ensure that the product quality meets the standards and achieve quality monitoring and optimization. Usually, the defects of the spraying surface are mostly particle defects, cracks and depressions, but the existing spraying defect detection method can only detect whether there are defects on the spraying surface, but cannot detect the specific defect type. For example, the paint defect detection method based on machine vision disclosed in the Chinese patent with authorization announcement number CN115115613B can be used to detect defects in powder spraying, but it can only detect whether there are defects in the paint on the sprayed surface, but cannot detect the specific defect type and defect location.
[0003] In the prior art, clustering algorithms are usually used to detect surface defects of objects. For example, the document entitled "Application of Cluster Analysis in Defect Classification" by Jing Renke, Li Jianzeng and Zhou Hailin from the Ordnance Engineering College discloses a method of identifying the types of defects using clustering analysis, but this method cannot detect the location of the defect. In addition, during the powder spraying process, color difference or particles may occur due to uneven temperature distribution in the curing furnace, and the powder coating itself may accumulate and agglomerate or impurities may form in the furnace, resulting in poor atomization during spraying, resulting in protruding particle defects. For dark spraying materials, the location of the particle defect itself is not obvious, and the particle defect also has color difference, so the traditional clustering algorithm cannot accurately segment the defect location. Summary of the invention
[0004] In order to solve the technical problem that the defect position cannot be accurately detected when the existing defect detection method is used to detect defects on the sprayed surface, the present invention provides solutions in the following aspects.
[0005] In the first aspect, the present invention provides a powder spray defect detection method based on image processing, comprising: acquiring a spray surface image, and preprocessing it to obtain a spray surface grayscale image; dividing the spray surface grayscale image into blocks, and calculating the possibility of spray defects in each block according to the mean and variance of the grayscale values of the pixels in each block; the possibility is positively correlated with the mean and the variance; for each pixel point, the difference between the possibility of spray defects in the block where the pixel point is located and the possibility of spray defects in the neighborhood block of the block is recorded as a first difference degree, and the particle defect influence degree of the pixel point is calculated according to the gradient direction consistency of the two adjacent pixels in the block where the pixel point is located, and the first difference degree; the particle defect influence degree is positively correlated with the first difference degree and the gradient direction consistency; one of the two adjacent pixels is a pixel point adjacent to another pixel point in the gradient direction; the particle defect influence degree of each pixel point is clustered as a clustering value to obtain the particle defect position.
[0006] The traditional clustering method is to cluster based on the pixel value of the pixel point. When the powder spray defect detection method based on image processing of this embodiment is used to detect the particle defects on the spray surface, the influence degree of the particle defects of each pixel point is first calculated. When clustering the pixels, the pixel values are no longer clustered, but the influence degree of the particle defects of each pixel point is used as the clustering value for clustering, so as to obtain the accurate particle defect position; it solves the problem that the position of the particle defects of dark spray materials is not obvious in itself, and the particle defects also have color difference, and the traditional clustering algorithm cannot accurately segment the defect position, and at the same time makes the observation and processing of relevant personnel more efficient; in addition, when calculating the influence degree of the particle defects of each pixel point, the influence of the particle defects on the grayscale value in the block and the influence of the particle defects on the coating thickness and coating color are taken into account, so that the calculated influence degree of the particle defects is more accurate, thereby improving the accuracy of the particle defect detection results.
[0007] In one embodiment, the probability calculation expression of the spraying defect is:
[0008] ;
[0009] in, For Block i There is a possibility of spraying defects, Represents block i The grayscale mean of the inner pixels, Represents block i Grayscale variance of inner pixels.
[0010] In one embodiment, calculating the influence degree of the particle defect of the pixel point includes:
[0011] The unit vectors of all pixels in the block of the pixel point in their gradient direction are summed, the direction of the obtained vector is used as the direction of the block vector, and the angle between the gradient direction of the pixel point in the block of the pixel point and the direction of the block vector is calculated; the degree of influence of the particle defect in the block where the pixel point is located is calculated based on the first difference degree, the gradient direction consistency and the angle, and it is used as the initial value of the particle defect influence degree of the pixel point; the initial value of the particle defect influence degree is positively correlated with the first difference degree and the gradient direction consistency, and is negatively correlated with the angle.
[0012] Since the gradient distribution of pixels in a normal block is relatively chaotic, the gradient direction of pixels in the block is relatively chaotic, and the angle between the gradient direction of the pixel in the block of the pixel and the direction of the block vector is relatively large. However, the gradient distribution of pixels in a block with particle defects is relatively consistent, and the angle between the gradient direction of the pixel in the block of the pixel and the direction of the block vector is relatively small. Therefore, a more accurate initial value of the particle defect influence degree can be calculated based on the angle between the gradient direction of the pixel in the block of the pixel and the direction of the block vector, and the initial value of the particle defect influence degree is negatively correlated with the angle. The method for calculating the particle defect influence degree of a pixel in this embodiment further combines the angle between the gradient direction of the pixel and the direction of the block vector of the block where the pixel is located when calculating the particle defect influence degree of the pixel, thereby making the calculation result of the initial value of the particle defect influence degree more accurate.
[0013] In one embodiment, the calculation expression of the gradient direction consistency is:
[0014] ;
[0015] In the formula, Represents block i No. j The gradient direction consistency corresponding to the pixel points Represents block i No. j The pixel vector of pixels, Represents block i No. j The pixel vector of the pixels adjacent to the pixel in the gradient direction.
[0016] As the gradient direction of the pixel point is more consistent with the gradient direction of the adjacent pixel points, the directions of the pixel vectors of the two pixel points will be more consistent, and the sum of the pixel vectors of the two pixel points will be larger. Therefore, the degree of influence of the particle defect of the pixel point can be calculated based on the consistency of the gradient directions of two adjacent pixel points in the block where the pixel point is located.
[0017] In one embodiment, the calculation expression of the initial value of the particle defect influence degree is:
[0018] ;
[0019] In the formula, Represents block i No. j The pixel vector of pixels, Represents block i No. j The pixel vector of the pixel points adjacent to the pixel point in the gradient direction, Represents block i The degree of influence of particle defects, n Represents block i The total number of pixels in represents the maximum and minimum normalized function, Represents block i Inner pixel j The angle between the vector direction of the block and the vector direction of the block, Represents block i Possibility of spraying defects, Represents block i The neighborhood The probability of spraying defects in blocks, z represents the number of neighborhood blocks, Indicates the sequence number of the neighborhood block.
[0020] The calculation expression for the initial value of the degree of influence of particle defects in this embodiment comprehensively considers the consistency of the gradient directions of all pixels in the block when calculating the consistency of the gradient directions of two adjacent pixels; and comprehensively considers the angles corresponding to all pixels in the block when calculating the angle between the gradient direction of the pixel point in the block of the pixel point and the direction of the block vector, thereby avoiding calculation deviations caused by generalizing from a single case, and further improving the accuracy of the calculation results of the initial value of the degree of influence of particle defects.
[0021] In one embodiment, the calculation of the degree of influence of the particle defect of the pixel point also includes: recording the difference between the average degree of influence of the particle defect of all pixels in the image and the degree of influence of the particle defect of the pixels in the neighborhood of the pixel point as the second degree of difference, recording the difference between the initial value of the degree of influence of the particle defect of the pixel point and the initial value of the degree of influence of the particle defect of the pixel point in the neighborhood of the pixel point as the third degree of difference, and correcting the initial value of the degree of influence of the particle defect according to the second degree of difference and the third degree of difference to obtain a corrected value of the degree of influence of the particle defect, and the corrected value of the degree of influence of the particle defect is positively correlated with the second degree of difference and the third degree of difference.
[0022] Since the closer a pixel is to the center of a particle, the faster the grayscale of the pixel changes to its neighborhood, the difference between the initial value of the particle defect influence degree of the pixel and the initial value of the particle defect influence degree of the pixel's neighborhood pixel can characterize the amplitude of change between the pixel and the neighborhood pixel. The larger the difference, the greater the degree of influence of the particle defect on the pixel. In addition, the difference between the mean value of the particle defect influence degree of all pixels in the image and the particle defect influence degree of the pixels in the neighborhood of the pixel can reflect the degree of difference between the pixel and the image as a whole. The greater the degree of difference, the greater the influence of the particle defect on the pixel. Therefore, the initial value of the particle defect influence degree can be corrected according to the second degree of difference and the third degree of difference, so as to obtain a more accurate degree of influence of the particle defect.
[0023] In one embodiment, the calculation expression of the particle defect influence degree correction value is:
[0024] ;
[0025] In the formula, Represents pixel p The particle defect influence correction value, Represents pixel p The initial value of the particle defect influence degree, Represents pixel p In the 8 neighborhoods of q The impact of particle defects on each pixel point, It represents the mean value of the particle defect influence of all pixels in the image, norm represents the maximum and minimum normalization function, q Represents pixel p The pixel number in the 8-neighborhood of Represents pixel p The number of pixels in the 8-neighborhood of Represents pixel p The initial value of the particle defect influence degree and its 8 neighborsq The absolute value of the difference between the initial values of the particle defect influence degree of each pixel.
[0026] When there are no particle defects on the spray surface, the grayscale features of each pixel are approximately consistent. When particles exist, they will affect the surrounding spray surface, so that the grayscale of the spray surface gradually increases from the center of the particle to the surrounding. Therefore, the more similar the pixels in the grayscale image of the spray surface are as a whole and the more uniform the local changes are, the lower the possibility that there are particle defects at the pixel position. On the contrary, the smaller the consistency of the pixel with the whole and the greater the local variability, the greater the possibility that there are particle defects under the spray surface. The calculation expression of the particle defect influence degree correction value of this embodiment takes into account the degree of approximation and local changes between the pixel image as a whole when calculating the third difference degree and the third difference degree, and takes into account all adjacent pixels of the pixel when calculating the second difference degree and the third difference degree, so that the correction result of the particle defect influence degree is more accurate.
[0027] In one embodiment, it also includes: setting the grayscale value of the pixel points of the cluster with the lower mean particle defect impact degree in the two clusters of the clustering results to 0, setting the grayscale value of the pixel points of the cluster with the higher mean particle defect impact degree in the two clusters to 255, and performing binary segmentation to obtain a binary image.
[0028] By performing binary segmentation on the grayscale image of the sprayed surface according to the clustering results, the pixels with particle defects can be intuitively displayed.
[0029] In one embodiment, the clustering algorithm used for the clustering is a K-means clustering algorithm.
[0030] In a second aspect, the present invention provides a powder spray defect detection system based on image processing, comprising a memory and a processor, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the powder spray defect detection method based on image processing of the present invention is implemented.
[0031] The beneficial effects of the present invention are as follows: the powder spraying defect detection method based on image processing of the present invention can accurately detect particle defects on the spraying surface and can accurately locate the position of the particle defects, so that the staff can promptly repair the defective spraying surface, thereby ensuring that the quality of the sprayed products meets the standards. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The following detailed description is read with reference to the accompanying drawings, in which several embodiments of the present invention are shown by way of example and not limitation, and in which like or corresponding reference numerals designate like or corresponding parts, wherein:
[0033] Figure 1 is a flow chart schematically showing a powder spraying defect detection method based on image processing according to an embodiment of the present invention;
[0034] Figure 2 is a schematic diagram schematically showing a grayscale image of a sprayed surface according to an embodiment of the present invention;
[0035] Figure 3 is a flow chart schematically showing a method for calculating the influence degree of particle defects of a pixel point according to an embodiment of the present invention;
[0036] Figure 4 It is a schematic diagram schematically showing the structure of a powder spraying defect detection system based on image processing according to an embodiment of the present invention. DETAILED DESCRIPTION
[0037] 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.
[0038] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0039] Powder spraying defect detection method based on image processing:
[0040] like Figure 1 As shown, the powder spraying defect detection method based on image processing of the present invention comprises:
[0041] S101, acquiring a spray-painted surface image, and preprocessing it to obtain a spray-painted surface grayscale image.
[0042] An industrial camera can be used to collect images of the sprayed surface. The grayscale image of the sprayed surface is as follows: Figure 2 The preprocessing includes grayscale processing, and in other embodiments, may also include denoising processing.
[0043] S102, dividing the image into blocks and calculating the possibility of the existence of spraying defects in each block, specifically: dividing the grayscale image of the sprayed surface into blocks, and calculating the possibility of the existence of spraying defects in each block according to the mean and variance of the grayscale values of the pixels in each block; the possibility is positively correlated with the mean and the variance.
[0044] In this embodiment, according to 3 3, the block size can be adjusted according to the actual situation. In other embodiments, the size of the blocks may not be set in advance, but the entire spray surface grayscale image is evenly divided into blocks.
[0045] According to the grayscale feature analysis of the pixel points at the particle position and the area around the particle, the closer a block is to the center of the particle, the higher the grayscale value of the pixel points in the block, and the faster the grayscale change of the pixel points in the block to its neighborhood. Therefore, the larger the mean and variance of the grayscale values of the pixel points in the block, the greater the possibility of spraying defects in the block, and the possibility of spraying defects in each block can be calculated more accurately based on the mean and variance.
[0046] S103. Calculate the influence of particle defects on pixel points, specifically: for each pixel point, record the difference between the possibility of a spraying defect in the block where the pixel point is located and the possibility of a spraying defect in the neighborhood block of the block as the first difference degree, and calculate the influence of particle defects on the pixel point based on the gradient direction consistency of two adjacent pixels in the block where the pixel point is located and the first difference degree; the influence of particle defects is positively correlated with both the first difference degree and the gradient direction consistency; one of the two adjacent pixels is a pixel point adjacent to another pixel point in the gradient direction.
[0047] If there are particles on the spraying surface, the thickness of the powder sprayed coating at the particle position and the surrounding position of the particle is different due to the influence of the particles, or due to the influence of impurities in the particles, color diffusion may appear around the position where the particle is located. By comparing and analyzing the spraying surface affected by particle defects with the normal spraying surface, it is found that the particles and the spraying surface around the particles may have a color gradient around the position where the particles are located because the coating thickness thickens from the middle to the surroundings and the influence of impurities in the particles, so the gradient direction of the pixel point and the pixel points adjacent to the pixel point in the gradient direction are more uniform, while for the normal spraying surface, the gradient direction of the pixel point is more chaotic; therefore, the degree of influence of the particle defect of the pixel point can be calculated based on the consistency of the gradient direction of the two adjacent pixel points in the block where the pixel point is located, and the greater the consistency of the gradient direction, the greater the degree of influence of the particle defect.
[0048] Because the particles are small, the impact range of particle defects is usually small, and the impact of different particles is relatively random. Therefore, if there is a particle defect in a block, the impact of the particle defect on the pixel in the block will be greater, and the difference between the impact of the particle defect in the block and the impact of the particle defect in the adjacent block will be larger. Therefore, the impact of the particle defect on the pixel can be calculated more accurately based on the difference between the possibility of a spraying defect in the block where the pixel is located and the possibility of a spraying defect in the neighboring blocks of the block, and the impact of the particle defect on the pixel is positively correlated with the difference.
[0049] S104, clustering each pixel point, specifically: clustering the influence degree of the particle defect of each pixel point after correction as a cluster value, so as to obtain the particle defect position.
[0050] In this embodiment, the initial cluster centers are set to 2, so that all pixels are divided into two categories, one of which is pixels with particle defects and the other is normal pixels. In this embodiment, the K-means clustering algorithm can be used, and other suitable clustering algorithms can also be used in other embodiments.
[0051] The traditional clustering method is to cluster based on the pixel value of the pixel point. When the powder spray defect detection method based on image processing of this embodiment is used to detect the particle defects on the spray surface, the influence degree of the particle defects of each pixel point is first calculated. When clustering the pixels, the pixel values are no longer clustered, but the influence degree of the particle defects of each pixel point is used as the clustering value for clustering, so as to obtain the accurate particle defect position; the problem that the position of the particle defect of dark spraying materials is not obvious in itself and the particle defect has color difference, and the traditional clustering algorithm cannot accurately segment the defect position is solved, and the observation and processing by relevant personnel is more efficient; in addition, when calculating the influence degree of the particle defect of each pixel point, the influence of the particle defect on the gray value in the block and the influence of the particle defect on the coating thickness and coating color are taken into account, so that the calculated influence degree of the particle defect is more accurate, thereby improving the accuracy of the particle defect detection results.
[0052] It can be seen from the above embodiments that the possibility is positively correlated with the mean and variance. In one embodiment, for block i, the possibility of spraying defects is calculated as follows:
[0053]
[0054] in, For Block iThe possibility of spraying defects reflects the characteristics of the possible influence of particle defects in the block. The larger the value, the greater the probability of the influence of particle defects in the block. Represents block i The grayscale mean of the internal pixels, the larger the value, the greater the possibility of particle defects in the block. Represents block i The grayscale variance of the inner pixel is large because the grayscale changes from the center of the particle to the surrounding area. The larger the value is, the greater the possibility of particle defects in the block; norm represents the maximum and minimum value normalization function.
[0055] like Figure 3 As shown, in one embodiment, calculating the influence degree of the particle defect of the pixel point includes:
[0056] S201. Calculate the angle between the gradient direction of the pixel point and the direction of the block vector, specifically: sum the unit vectors of all pixels in the block of the pixel point in their gradient direction, use the direction of the obtained vector as the direction of the block vector, and calculate the angle between the gradient direction of the pixel points in the block of the pixel point and the direction of the block vector.
[0057] The unit vector of a pixel point in its gradient direction refers to a vector obtained after the pixel point vector of the pixel point is normalized. The direction and magnitude of the pixel point vector are the gradient direction and gradient magnitude of the pixel point, respectively.
[0058] S202. Calculate the initial value of the particle defect influence degree of the pixel point, specifically: calculate the particle defect influence degree of the block where the pixel point is located based on the first difference degree, the gradient direction consistency and the angle, and use it as the initial value of the particle defect influence degree of the pixel point; the initial value of the particle defect influence degree is positively correlated with the first difference degree and the gradient direction consistency, and negatively correlated with the angle.
[0059] Since the gradient distribution of pixels in a normal block is relatively chaotic, the gradient direction of pixels in the block is relatively chaotic, and the angle between the gradient direction of the pixel in the block of the pixel and the direction of the block vector is relatively large. However, the gradient distribution of pixels in a block with particle defects is relatively consistent, and the angle between the gradient direction of the pixel in the block of the pixel and the direction of the block vector is relatively small. Therefore, a more accurate initial value of the particle defect influence degree can be calculated based on the angle between the gradient direction of the pixel in the block of the pixel and the direction of the block vector, and the initial value of the particle defect influence degree is negatively correlated with the angle. The method for calculating the particle defect influence degree of a pixel in this embodiment further combines the angle between the gradient direction of the pixel and the direction of the block vector of the block where the pixel is located when calculating the particle defect influence degree of the pixel, thereby making the calculation result of the initial value of the particle defect influence degree more accurate.
[0060] In one embodiment, for the j-th pixel point of block i, the calculation expression of the corresponding gradient direction consistency is:
[0061]
[0062] In the formula, Represents block i No. j The gradient direction consistency corresponding to the pixel points Represents block i No. j The pixel vector of pixels, Represents block i No. j The pixel vector of the pixels adjacent to the pixel in the gradient direction.
[0063] The direction and magnitude of the pixel vector of the j-th pixel in block i are the gradient direction and gradient amplitude of the pixel, respectively.
[0064] Since the more consistent the gradient directions of two adjacent pixels in a block are, the more consistent the directions of the pixel vectors of the two pixels will be, and the larger the sum of the pixel vectors of the two pixels will be. Therefore, the corresponding gradient direction consistency can be calculated more accurately and quickly based on the sum of the pixel vectors of the pixel points adjacent to the pixel point in its gradient direction and the pixel vector of the pixel point.
[0065] In the above embodiments, it is mentioned that the initial value of the particle defect influence degree is positively correlated with the first difference degree and the gradient direction consistency, and is negatively correlated with the angle. In one embodiment, the calculation expression of the initial value of the particle defect influence degree is:
[0066]
[0067] In the formula, Represents block i No. j The pixel vector of pixels, Represents block i No. j The pixel vector of the pixel points adjacent to the pixel point in the gradient direction, Represents block i The larger the value, the greater the possibility that the pixel in the block is a particle defect pixel. n Represents block i The total number of pixels in represents the maximum and minimum normalized function, Represents block i Inner pixel j The angle between the vector direction of the pixel and the vector direction of the block. The larger the value, the greater the difference between the direction of the pixel and the direction in the block, and the lower the possibility of the block being affected by particle defects. Represents block i Possibility of spraying defects, Represents block i The neighborhood The probability of spraying defects in blocks, z represents the number of neighborhood blocks, Indicates the sequence number of the neighborhood block.
[0068] pass Represents block i Possibility of spraying defects and block i The greater the value, the greater the probability that particle defects may exist in the block.
[0069] The calculation expression for the initial value of the degree of influence of particle defects in this embodiment comprehensively considers the consistency of the gradient directions of all pixels in the block when calculating the consistency of the gradient directions of two adjacent pixels; and comprehensively considers the angles corresponding to all pixels in the block when calculating the angle between the gradient direction of the pixel point in the block of the pixel point and the direction of the block vector, thereby avoiding calculation deviations caused by generalizing from a single case, and further improving the accuracy of the calculation results of the initial value of the degree of influence of particle defects.
[0070] In one embodiment, calculating the influence degree of the particle defect of the pixel point further includes:
[0071] The difference between the average value of the particle defect influence degree of all pixels in the image and the particle defect influence degree of the pixels in the neighborhood of the pixel is recorded as the second difference degree, and the difference between the initial value of the particle defect influence degree of the pixel and the initial value of the particle defect influence degree of the pixels in the neighborhood of the pixel is recorded as the third difference degree. The initial value of the particle defect influence degree is corrected according to the second difference degree and the third difference degree to obtain a corrected value of the particle defect influence degree, and the corrected value of the particle defect influence degree is positively correlated with the second difference degree and the third difference degree.
[0072] Since the closer a pixel is to the center of a particle, the faster the grayscale of the pixel changes to its neighborhood, the difference between the initial value of the particle defect influence degree of the pixel and the initial value of the particle defect influence degree of the pixel's neighborhood pixel can characterize the amplitude of change between the pixel and the neighborhood pixel. The larger the difference, the larger the amplitude of change between the pixel and the neighborhood pixel, and the greater the degree of influence of the particle defect on the pixel. In addition, the difference between the mean value of the particle defect influence degree of all pixels in the image and the particle defect influence degree of the pixels in the neighborhood of the pixel can reflect the degree of difference between the pixel and the image as a whole. The greater the degree of difference, the greater the influence of the particle defect on the pixel. Therefore, the initial value of the particle defect influence degree can be corrected according to the second degree of difference and the third degree of difference, so as to obtain a more accurate degree of influence of the particle defect.
[0073] In one embodiment, the calculation expression of the particle defect influence degree correction value is:
[0074]
[0075] In the formula, Represents pixel p The larger the value, the greater the impact of particle defects on the pixel. Represents pixel p The initial value of the particle defect influence degree, Represents pixel p In the 8 neighborhoods of q The impact of particle defects on each pixel point, It represents the mean value of the particle defect influence of all pixels in the image, norm represents the maximum and minimum normalization function, Represents pixel p The pixel number in the 8-neighborhood of Represents pixel p The number of pixels in the 8-neighborhood of Represents pixel pThe initial value of the particle defect influence degree and its 8 neighbors q The absolute value of the difference between the initial values of the particle defect influence degree of each pixel. Used to reflect pixel points p The larger the value is, the greater the impact of particle defects will be.
[0076] Because the particles are small and the normal spraying surface occupies most of the image, the impact range of particle defects is not particularly large. Therefore, the difference in the spraying surface affected by particle defects can be highlighted by comparing with the pixel points of the whole image. It reflects the difference in the degree of influence of particle defects between the pixel point and the image as a whole. The larger the value is, the greater the influence of particle defects on the pixel point is. Represents the normalization function.
[0077] Because the closer to the center of the particle, the greater the grayscale change from the center of the particle to the surrounding area, It reflects the difference in grayscale change between the pixel and its neighborhood (i.e., local change). The larger the value, the greater the impact of particle defects.
[0078] When there are no particle defects on the spray surface, the grayscale features of each pixel are approximately consistent. When particles exist, they will affect the surrounding spray surface, so that the grayscale of the spray surface gradually increases from the center of the particle to the periphery. Therefore, the more similar the pixels in the grayscale image of the spray surface are as a whole and the more uniform the local changes are, the lower the possibility that there are particle defects at the position of the pixel point. On the contrary, the smaller the consistency of the pixel point with the whole and the greater the local variability, the greater the possibility that there are particle defects on the spray surface. The calculation expression of the particle defect influence degree correction value of this embodiment takes into account the degree of approximation and local changes between the pixel point images as a whole when calculating the second difference degree and the third difference degree, and comprehensively considers all adjacent pixels of the pixel point when calculating the second difference degree and the third difference degree, so that the correction result of the particle defect influence degree is more accurate.
[0079] In order to intuitively display the particle defect position, in one embodiment, the method further includes:
[0080] The grayscale value of the pixel points of the cluster with the lower mean particle defect impact degree in the two clusters of the clustering results is set to 0, and the grayscale value of the pixel points of the cluster with the higher mean particle defect impact degree in the two clusters is set to 255, and binary segmentation is performed to obtain a binary image.
[0081] The pixel position with a grayscale value of 0 is a normal position without particle defects, and the pixel position with a grayscale value of 255 is a particle defect position. This accurately displays the particle defect position and facilitates relevant personnel to observe and handle it.
[0082] Example of powder coating defect detection system based on image processing:
[0083] The present invention also provides a powder spraying defect detection system based on image processing. Figure 4 As shown, the powder spraying defect detection system based on image processing includes a processor and a memory, and the memory stores computer program instructions. When the computer program instructions are executed by the processor, the powder spraying defect detection method based on image processing according to the first aspect of the present invention is implemented.
[0084] The powder spraying defect detection system based on image processing also includes other components familiar to those skilled in the art, such as a communication bus and a communication interface, whose settings and functions are known in the art and 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 powder spraying defect detection method based on image processing, It is characterized in that include: Acquire a spray-painted surface image, and pre-process it to obtain a spray-painted surface grayscale image; The grayscale image of the sprayed surface is divided into blocks, and the possibility of the existence of spraying defects in each block is calculated according to the mean and variance of the grayscale values of the pixels in each block; the possibility is positively correlated with the mean and the variance; For each pixel point, the difference between the possibility of the existence of a spraying defect in the block where the pixel point is located and the possibility of the existence of a spraying defect in the neighborhood block of the block is recorded as the first difference degree, and the particle defect influence degree of the pixel point is calculated based on the gradient direction consistency of the two adjacent pixels in the block where the pixel point is located and the first difference degree, including: summing the unit vectors of all pixels in the block of the pixel point in the gradient direction, taking the direction of the obtained vector as the direction of the block vector, and calculating the angle between the gradient direction of the pixel point in the block of the pixel point and the direction of the block vector; calculating the particle defect influence degree of the block where the pixel point is located based on the first difference degree, the gradient direction consistency and the angle, and taking it as the initial value of the particle defect influence degree of the pixel point, the calculation expression is: ; In the formula, Represents block i No. j The pixel vector of pixels, Represents block i No. j The pixel vector of the pixel points adjacent to the pixel point in the gradient direction, Represents block i The degree of influence of particle defects, n Represents block i The total number of pixels in represents the maximum and minimum normalized function, Represents block i Inner pixel j The angle between the vector direction of the block and the vector direction of the block, Represents block i Possibility of spraying defects, Represents block i The neighborhood The probability of spraying defects in blocks, z represents the number of neighborhood blocks, Indicates the sequence number of the neighborhood block; the initial value of the particle defect influence degree is positively correlated with the first difference degree and the gradient direction consistency, and is negatively correlated with the angle; The calculation expression of the gradient direction consistency is: ; In the formula, Represents block i No. j The gradient direction consistency corresponding to the pixel points; one of the two adjacent pixel points is an adjacent pixel point in the gradient direction of another pixel point; The influence degree of particle defects at each pixel point is clustered as a cluster value to obtain the particle defect position.
2. The powder spraying defect detection method based on image processing according to claim 1, It is characterized in that The calculation expression of the possibility of spraying defects is: ; in, For Block i There is a possibility of spraying defects, Represents block i The grayscale mean of the inner pixels, Represents block i Grayscale variance of inner pixels.
3. The powder spraying defect detection method based on image processing according to claim 1, It is characterized in that The calculation of the degree of influence of the particle defect of the pixel point also includes: recording the difference between the average degree of influence of the particle defect of all pixels in the image and the degree of influence of the particle defect of the pixels in the neighborhood of the pixel point as a second degree of difference, recording the difference between the initial value of the degree of influence of the particle defect of the pixel point and the initial value of the degree of influence of the particle defect of the pixel point in the neighborhood of the pixel point as a third degree of difference, and correcting the initial value of the degree of influence of the particle defect according to the second degree of difference and the third degree of difference to obtain a corrected value of the degree of influence of the particle defect, wherein the corrected value of the degree of influence of the particle defect is positively correlated with the second degree of difference and the third degree of difference.
4. The powder spraying defect detection method based on image processing as claimed in claim 3, It is characterized in that The calculation expression of the particle defect influence correction value is: ; In the formula, Represents pixel p The particle defect influence correction value, Represents pixel p The initial value of the particle defect influence degree, Represents pixel p In the 8 neighborhoods of q The impact of particle defects on each pixel point, It represents the mean value of the particle defect influence of all pixels in the image, norm represents the maximum and minimum normalization function, q Represents pixel p The pixel number in the 8-neighborhood of Represents pixel p The number of pixels in the 8-neighborhood of Represents pixel p The initial value of the particle defect influence degree and its 8 neighbors q The absolute value of the difference between the initial values of the particle defect influence degree of each pixel.
5. The powder spraying defect detection method based on image processing according to claim 1, It is characterized in that The method also includes: setting the grayscale value of the pixel points of the cluster with the lower mean particle defect impact degree in the two clusters of the clustering result to 0, setting the grayscale value of the pixel points of the cluster with the higher mean particle defect impact degree in the two clusters to 255, performing binary segmentation, and thus obtaining a binary image.
6. The powder spraying defect detection method based on image processing according to any one of claims 1 to 5, It is characterized in that The clustering algorithm used in the clustering is the K-means clustering algorithm.
7. A powder spraying defect detection system based on image processing, comprising a memory and a processor, wherein the memory stores computer program instructions, It is characterized in that When the computer program instructions are executed by the processor, the powder spraying defect detection method based on image processing described in any one of claims 1 to 6 is implemented.
