Vision-based method for detecting defects in the painting of furniture surfaces
By constructing a multi-level analysis system and combining K-means clustering and multi-dimensional feature gradient calculation, the problems of adaptability and refined evaluation of furniture paint defect detection were solved, achieving accurate identification and grade assessment of paint defects and improving the adaptability and consistency of detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-23
- Publication Date
- 2026-04-07
AI Technical Summary
Existing methods for detecting defects in furniture paint are sensitive to changes in light, have difficulty adapting to different surface characteristics, and lack the ability to identify small defects and irregularly shaped defects, thus failing to meet the needs of refined quality management.
A multi-level analysis system from pixel level to region level is constructed. By combining K-means clustering, multi-dimensional feature gradient calculation, growth trend analysis and probability model evaluation, grayscale image processing is used to achieve accurate detection and grade assessment of paint defects on furniture surfaces.
It improves the ability to identify various painting defects, especially the detection accuracy of small defects and irregularly shaped defects. It is adaptive and robust, and can assess the severity of defects to meet the needs of refined quality management.
Smart Images

Figure CN120543521B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of computer vision, and particularly relates to a visual-based furniture surface paint defect detection method, which is suitable for the automatic detection and evaluation of the quality of painted surfaces on furniture production lines. BACKGROUND
[0002] In the furniture manufacturing industry, surface paint quality has a significant impact on product appearance and service life. Traditional paint defect detection mainly relies on manual visual inspection, which is not only inefficient, but also affected by factors such as the experience, fatigue, and subjective judgment of the inspectors, resulting in poor stability and consistency of the detection results.
[0003] With the development of computer vision technology, automatic defect detection methods based on image processing have gradually been applied in industrial production. However, existing defect detection methods still have many problems when dealing with furniture surface paint defects: on the one hand, traditional threshold-based segmentation methods are sensitive to changes in lighting and are difficult to adapt to different surface characteristics; on the other hand, texture analysis-based methods have limited detection capabilities for small defects and poor recognition results for irregularly shaped defects. In addition, existing methods generally lack the ability to evaluate defect severity, making it difficult to meet the needs of fine quality management.
[0004] Therefore, there is an urgent need for an intelligent detection method that can accurately identify various paint defects and perform reasonable grading to improve the quality control level of furniture production. SUMMARY
[0005] The purpose of the present application is to provide a visual-based furniture surface paint defect detection method that builds a multi-level analysis system from the pixel level to the region level, combines K-means clustering, multi-dimensional feature gradient calculation, growth trend analysis, and probability model evaluation, and realizes accurate detection and grading of furniture surface paint defects.
[0006] The present application proposes a visual-based furniture surface paint defect detection method, which includes:
[0007] Obtaining a surface image of the detection object, the surface image being a grayscale image;
[0008] Using a K-means clustering algorithm to divide the pixel points in the grayscale image into three categories, calculating the number of pixel points belonging to the three categories in the grayscale image and the average grayscale value of the third category of pixel points, and assigning the grayscale value of the pixel points belonging to the first category to the pixel points belonging to the second category in the grayscale image to obtain a grayscale image;
[0009] determining a minimum gradient value of each pixel point in the gray image and each pixel point in the same class respectively, assigning a gray value of a pixel point greater than a gray value of the pixel point to each pixel point, wherein the gray value is in a gray value array, and marking each element in the gray value array as an initial point, wherein a gray value of the element is equal to a gray value of the pixel point in the first class;
[0010] determining a growth trend of each initial point according to the initial point and a curve direction where the initial point is located, recording two growth trends as an integral trend when a coincidence ratio of the two growth trends is within a set range, otherwise recording the two growth trends as different growth trends, determining a contour value of each integral according to a number of pixel points in each integral, and setting a point with a maximum pixel value in all pixel points in the growth trend of the integral as a center point, wherein the contour value is greater than a set number of pixel points;
[0011] constructing a center window with a center point and points in eight neighborhoods of the center point, determining an anomaly index of the center point according to a gray value of the center point and each pixel point in the center window, marking the center point as an anomaly point when a pixel point in a four neighborhood of the center point is a pixel point in the third class, taking an anomaly index of a pixel point with a minimum gray value in all pixel points in the center window as an anomaly index of each pixel point in the center window, determining a probability index of each pixel point in the center window according to the anomaly index of each pixel point in the center window, and determining a defect probability density of the center window according to the anomaly index and the probability index of each pixel point in the center window;
[0012] determining a defect probability distribution of the gray value array according to the defect probability density of the pixel point in the gray value array;
[0013] determining a confidence of the defect probability density of the gray value array according to a smoothness of the gray value array, a gray mean value of the pixel point in the gray value array, and the defect probability distribution;
[0014] determining a threshold value according to the defect probability distribution and the confidence of the defect probability density of the gray value array, determining a probability value of the object to be detected belonging to a normal class according to the gray value array and the threshold value, and determining whether the object to be detected has a defect according to the probability value of the object to be detected belonging to the normal class;
[0015] determining a defect level of the object to be detected according to the probability value of the object to be detected belonging to the normal class.
[0016] As preferred, the method further comprises:
[0017] calculating a gray value difference between the pixel points;
[0018] Calculate the deviation of a pixel from the mean of its neighborhood;
[0019] Calculate the absolute value of the grayscale value difference between the pixel and other pixels in its eight-neighborhood;
[0020] Calculate the sine and cosine of the angle between the vector formed by the pixel and the other pixels in the eight-neighborhood and the vector formed by the two pixels;
[0021] Based on the above calculation results, the minimum gradient value between each pixel and each pixel in the same class is determined.
[0022] Preferably, each pixel is assigned the gray value of the pixel whose minimum gradient value is greater than that of the pixel in the same class, including:
[0023] For each pixel in the grayscale image, iterate through all pixels of the same class;
[0024] Compare the grayscale value of each pixel with the grayscale value of the target pixel corresponding to its minimum gradient value;
[0025] When the gray value of the target pixel is greater than the gray value of the current pixel, the gray value of the target pixel is assigned to the current pixel.
[0026] Update the grayscale value at the corresponding position in the grayscale value array.
[0027] Preferably, determining the growth trend of each initial point based on each initial point and the curve direction in which the initial point is located includes:
[0028] An analysis window is created with each initial point as the center point;
[0029] Determine the curve direction for each pixel within the window;
[0030] Analyze the curve directions of the pixels in the eight neighborhood of the initial point, excluding the initial point itself.
[0031] By combining the characteristics of the initial point itself and the characteristics of the neighborhood direction, a growth trend description of the initial point is constructed.
[0032] Based on directional consistency and continuity, the main direction of the growth trend is determined.
[0033] Preferably, determining the contour value of each overall trend based on the number of pixels in each overall trend includes:
[0034] Count the number of pixels included in each overall trend;
[0035] Use this quantity as the profile value of the overall trend;
[0036] Set a contour value threshold to filter out small noise areas;
[0037] Compare the contour values with the threshold to determine the effective overall trend.
[0038] Preferably, determining the probability index of each pixel within the central window based on the anomaly index of each pixel within the central window includes:
[0039] Set the constant coefficient for the probability exponent calculation;
[0040] Consider the ratio of the number of third-class pixels to the number of first-class pixels in a grayscale image;
[0041] Combined with the average probability index of the growth trend at the initial point;
[0042] Based on the anomaly index of each pixel within the central window;
[0043] By comprehensively considering the above factors, the probability index of each pixel within the central window is calculated.
[0044] Preferably, determining the defect probability density of the central window based on the anomaly index and probability index of each pixel within the central window includes:
[0045] Calculate the variance of grayscale values of all pixels in the four neighboring regions of each pixel within the central window;
[0046] Calculate the average grayscale value of all pixels in the four neighboring regions of each pixel within the central window;
[0047] Get the grayscale value of each pixel within the center window;
[0048] Combine the probability index of each pixel within the central window;
[0049] Based on the above parameters and hyperparameters, the defect probability density of the central window is calculated using an exponential function.
[0050] Preferably, determining the defect probability distribution of the grayscale value array based on the defect probability density of pixels in the grayscale value array includes:
[0051] Use the gray values of the pixels in the gray value array as the x-coordinate;
[0052] The mean value of the defect probability density of all pixels in the grayscale array is used as the ordinate;
[0053] A probability distribution curve is established based on the above coordinate data;
[0054] This curve illustrates the relationship between different grayscale values and the probability of defects.
[0055] Preferably, the step of determining the confidence level of the defect probability density of the grayscale value array based on the smoothness of the grayscale value array includes:
[0056] Analyze the smoothness characteristics of the grayscale array;
[0057] Calculate the mean gray value of the gray value array;
[0058] Count the number of pixels in the grayscale value array;
[0059] The confidence level of the defect probability density is obtained by combining the above parameters using an exponential function.
[0060] This confidence level reflects the reliability of the test results.
[0061] Preferably, determining the probability value of the object to be detected belonging to the normal class based on the grayscale value array and the threshold includes:
[0062] Count the number of pixels in the grayscale array whose grayscale value is greater than a threshold;
[0063] Calculate the ratio of the number of pixels greater than the threshold to the total number of pixels;
[0064] This ratio represents the probability that the object being tested belongs to the normal class.
[0065] When the probability value is greater than or equal to the set threshold, it is determined that the object to be detected has no defects;
[0066] When the probability value is less than the set threshold, the object to be tested is determined to have a defect, and the defect level is determined according to the specific value of the probability value.
[0067] The present invention has the following beneficial effects:
[0068] 1. By using multidimensional feature gradient calculation and growth trend analysis, the ability to identify various paint defects has been improved, especially the detection accuracy of small defects and irregularly shaped defects has been significantly improved;
[0069] 2. A hierarchical analysis architecture of point-line-surface is adopted, which gradually expands from pixel-level features to region-level features, thereby enhancing the robustness and adaptability of the detection system;
[0070] 3. By introducing a probabilistic model evaluation mechanism, it is possible not only to determine whether a defect exists, but also to assess the severity of the defect, thus meeting the needs of refined quality management;
[0071] 4. It has the ability to adaptively adjust parameters, adapting to different furniture surfaces and different lighting conditions, reducing the need for manual intervention;
[0072] 5. It has a fast detection speed and low resource consumption, making it suitable for real-time application on the production line, which significantly improves detection efficiency and consistency. Attached Figure Description
[0073] Figure 1 This is a flowchart of the vision-based furniture surface paint defect detection method of the present invention;
[0074] Figure 2 This is a schematic diagram illustrating how K-means clustering divides pixels into three categories in this invention;
[0075] Figure 3 This is a schematic diagram illustrating the growth trend analysis and overall trend judgment in this invention;
[0076] Figure 4 This is a schematic diagram of the center window analysis and defect probability density calculation in this invention;
[0077] Figure 5 This is an example diagram of the defect probability distribution curve in this invention;
[0078] Figure 6 This is an example diagram for the defect level assessment of the present invention. Detailed Implementation
[0079] Please refer to the attached document. Figures 1-6 The specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
[0080] Reference Figure 1 The present invention provides a vision-based method for detecting defects in furniture surface paint, comprising the following steps:
[0081] First, a surface image of the object to be detected is acquired and converted into a grayscale image. In a preferred embodiment of the invention, an industrial camera is used to acquire images of the furniture surface with a resolution of 1920×1080 pixels, and a ring-shaped LED light source is used to ensure uniform illumination. The acquired color image is converted into a grayscale image using a weighted average method, calculated as follows:
[0082] ,
[0083] in, Grayscale value , , These are the pixel values for the red, green, and blue channels of the original image, respectively. This conversion method takes into account the human eye's sensitivity to different colors, and can better preserve the image's detailed information.
[0084] The K-means clustering algorithm is used to classify pixels in a grayscale image into three categories: background area, normal surface area, and potential defect area. K-means clustering is an unsupervised learning algorithm that iteratively optimizes the data points into K clusters. In this invention, K is set to 3, and the algorithm steps are as follows:
[0085] (1) Initialize three cluster centers, which can be selected from three points with gray values of 0, 128 and 255;
[0086] (2) Calculate the distance from each pixel to each cluster center and assign the pixel to the nearest category;
[0087] (3) Recalculate the center point (average gray value) for each category;
[0088] (4) Repeat steps (2) and (3) until the cluster centers are stable or the maximum number of iterations is reached (usually set to 20).
[0089] After clustering, the number of pixels and the average gray value of each category are counted. Preferably, the three categories are sorted in ascending order of average gray value and labeled as Category 1, Category 2, and Category 3, respectively. Typically, Category 1 corresponds to the background area, Category 2 corresponds to the normal surface area, and Category 3 corresponds to the potential defect area.
[0090] To enhance image contrast, the grayscale values of pixels belonging to the second category in the grayscale image are replaced with the average grayscale value of the first category, resulting in an enhanced grayscale image. This processing effectively highlights the difference between potential defect areas and the background, laying the foundation for subsequent analysis.
[0091] Multidimensional feature gradient calculation is one of the core innovations of this invention. It breaks through the limitation of traditional methods that only consider gray-level differences and constructs a more comprehensive pixel relationship description model.
[0092] First, determine the minimum gradient value between each pixel in the grayscale image and each pixel of the same class. In an embodiment of the present invention, the gradient value between pixel i and pixel j of the same class is calculated using the following formula:
[0093] ,
[0094] in, For pixels With pixels The gradient values between; Each pixel and grayscale value; For pixels The average gray value of all pixels in the neighborhood; For pixels Other pixels in the eight-neighborhood and pixels The absolute value of the difference in grayscale values; , Each pixel Other pixels in the eight-neighborhood and pixels The vectors and pixels formed With pixels The sine and cosine values of the angle between the vectors formed.
[0095] This formula comprehensively considers four key dimensions: grayscale difference, neighborhood bias, directional similarity, and angle compensation, enabling a more complete description of the relationships between pixels. In particular, the introduction of the concept of vector angle makes gradient calculation directionally sensitive, which helps to capture the morphological features of defects.
[0096] Next, the calculated minimum gradient value is compared with the grayscale value of the pixel. When the grayscale value of the target pixel corresponding to the minimum gradient value is greater than the grayscale value of the current pixel, the grayscale value of the target pixel is assigned to the current pixel, resulting in a grayscale value array. This assignment operation can be represented as:
[0097] ,
[0098] in, For the updated grayscale array of pixels grayscale value; The target pixel corresponding to the minimum gradient value grayscale value; pixels in the original grayscale image The grayscale value.
[0099] After the above processing, the pixels in the grayscale array will be more conducive to subsequent feature analysis. In particular, the points in the grayscale array whose grayscale value is equal to the average grayscale value of the first type of pixels are marked as initial points, and these initial points will serve as the starting point for growth trend analysis.
[0100] In practical applications, an eight-neighborhood typically refers to the eight adjacent pixels within a 3×3 window centered on the current pixel. To avoid edge processing issues, appropriate padding can be applied to the image edges, such as using mirror padding or zero padding.
[0101] Growth trend analysis is a key step in this invention, which elevates defects from point features to line features and then to surface features. It analyzes the continuity and morphological characteristics of defects based on the directional characteristics of the initial point.
[0102] First, the growth trend of each initial point is determined based on each initial point and the curve direction in which the initial point lies. In a preferred embodiment of the present invention, the growth trend of initial point i can be expressed as:
[0103] ,
[0104] in, As the initial point The growth trend; Starting from the initial point Establish the curve direction of the pixels within the window based on the center point; As the initial point The eight neighboring regions; Within the eight neighborhoods excluding the initial point The curve direction of all other pixels; pixels in a grayscale image The direction of the curve it is located in.
[0105] The direction of a curve can usually be determined by the local gradient direction, for example, by using the Sobel operator to calculate the gradient direction. In practical implementations, the direction can be quantized into 8 or 16 discrete directions for easier subsequent analysis.
[0106] Next, the relationship between any two growth trends is analyzed. When the overlap ratio of two growth trends is within a set range, they are recorded as a single overall trend; otherwise, they are recorded as opposing growth trends. The overlap ratio can be calculated based on the proportion and directional consistency of shared pixels. In embodiments of the present invention, the threshold range for the overlap ratio is set to 30%–70%, which effectively avoids erroneous fusion while ensuring that associated defective parts are not overlooked.
[0107] For each overall trend, the number of pixels it contains is calculated as a contour value. When the contour value is greater than a set threshold (e.g., 0.5% of the total number of pixels in the image), the overall trend is considered to represent a valid defect area, and the point with the highest gray value in the overall trend is set as the center point. This mechanism can effectively filter out small areas caused by noise, improving the reliability of detection.
[0108] It is worth noting that the selection strategy for the center point can be adjusted according to actual needs. Besides selecting the point with the highest grayscale value, one can also select the point closest to the geometric center of the region, or the point with the most prominent specific features. In a preferred embodiment of the invention, the point with the highest grayscale value is selected as the center point because high grayscale values typically correspond to the core area of the defect.
[0109] Center window analysis is a crucial step in performing detailed local analysis of defect areas. It constructs an analysis window based on a center point, calculates anomaly and probability indices, and ultimately determines the defect probability density.
[0110] First, a central window is constructed by defining a center point and its eight neighboring points. In practical applications, the window size can be expanded to 5×5 or larger to capture more local information. Based on the difference in grayscale values between the center point and each pixel within the window, the anomaly index of the center point is calculated.
[0111] ,
[0112] in, Center point Abnormal index; Center point The central window; The center point and pixels within the window grayscale value; This represents the number of pixels within the window.
[0113] When a third type of pixel exists within the four neighboring areas of the center point, the center point is marked as an anomaly, and its anomaly index is appropriately increased. Preferably, the anomaly index of the anomaly point is increased by 50%, which can enhance the sensitivity to obvious defective areas.
[0114] To maintain consistency in the analysis within a window, the anomaly index of the pixel with the lowest grayscale value among all pixels within the window is used as the unified anomaly index for every pixel within the central window. This process avoids local fluctuations in the anomaly index and improves the stability of the analysis.
[0115] Next, the probability index for each pixel is calculated based on the anomaly index:
[0116] ,
[0117] in, For pixels The probability index; This is a constant coefficient, usually set to a value between 0.5 and 1.0; This represents the number of third-class pixels in the grayscale image. This represents the number of pixels of the first class in the grayscale image. For pixels Abnormal index; For pixels The sum of all associated abnormal indices; is the base of the natural logarithm.
[0118] The probability index calculation considers multiple factors: category distribution ratio, anomaly index, and cumulative effect, enabling a comprehensive assessment of the likelihood that a pixel belongs to a defect. In particular, the introduction of an exponential function makes the calculation results more consistent with the characteristics of probability distribution.
[0119] Finally, based on the anomaly index and probability index of the pixels within the window, the defect probability density of the central window is calculated:
[0120] ,
[0121] in, Center window The defect probability density; For pixels grayscale value; For pixels The average gray value of all pixels in the four neighboring regions; For pixels The variance of gray values of all pixels in the four neighboring regions; For pixels The probability index; This is a hyperparameter, typically set to a value between 0.1 and 0.5; is the base of the natural logarithm.
[0122] This formula takes into account both grayscale distribution characteristics and probability exponents, providing a more accurate description of the defect area. In practical applications, a defect probability density value greater than 0.7 typically indicates the presence of a high probability defect.
[0123] Based on the results of the central window analysis, the defect probability distribution of the grayscale value array is further determined, providing a basis for the final defect judgment.
[0124] First, the defect probability distribution of the grayscale value array is determined based on the defect probability density of the pixels in the grayscale value array. Specifically, the grayscale value is used as the x-axis, and the mean defect probability density of the corresponding grayscale pixel is used as the y-axis to construct a probability distribution curve.
[0125] ,
[0126] in, The grayscale value is The mean defect probability density of pixels; For the grayscale value array, the grayscale value is A set of pixels; For pixels The probability density of defects in the central window; The grayscale value is The number of pixels.
[0127] Next, the confidence level of the defect probability density of the grayscale array is evaluated. The confidence level calculation considers three key factors: the smoothness of the grayscale array, the grayscale mean, and the number of pixels. The calculation formula is as follows:
[0128] ,
[0129] in, The confidence level of the defect probability density; The smoothness of the grayscale array is usually calculated based on gradient statistical properties; This represents the average grayscale value of the grayscale array. The target grayscale value is usually set to the typical grayscale value of a normal surface. This represents the total number of pixels in the grayscale value array. This is a hyperparameter, typically set to a value between 0.01 and 0.1; is the base of the natural logarithm.
[0130] Smoothness S can be evaluated using the statistical properties of the gradient magnitude, such as the reciprocal of the standard deviation of the gradient magnitude. In practical applications, higher smoothness indicates a more uniform image and a lower probability of defects.
[0131] Based on the defect probability distribution and confidence level, determine the optimal detection threshold:
[0132] ,
[0133] This threshold determination method takes into account probability distribution and confidence level, and can adaptively adjust detection sensitivity to improve detection accuracy and stability.
[0134] Finally, based on the threshold, it is determined whether the detected object has defects, and the defect level is evaluated.
[0135] First, calculate the proportion of pixels with gray values higher than a threshold, which is used as the probability value that the detected object belongs to the normal class:
[0136] ,
[0137] in, This represents the probability that the detected object belongs to the normal class. For pixels grayscale value; For a given threshold; This represents the total number of pixels in the grayscale array. When the value is greater than or equal to a set threshold (e.g., 0.9), the object being tested is determined to have no defects; when... If the value is below a set threshold, the object being tested is deemed to have a defect. Furthermore, according to... The specific numerical value can further assess the severity of the defect. In a preferred embodiment of the present invention, the defect level is classified as follows:
[0138] when At that time, it was determined to be without defects;
[0139] when At that time, it was determined to be a minor defect;
[0140] when At that time, it was determined to be a moderate defect;
[0141] when At that time, it was determined to be a serious defect.
[0142] This grading method can be adjusted according to actual application needs, such as adding more detailed grading or adjusting the threshold range.
[0143] This invention also provides a detailed implementation method for multidimensional feature gradient calculation. Multidimensional feature gradient calculation includes four key steps:
[0144] (1) Calculate the grayscale difference between pixels:
[0145] For any two pixels i and j, calculate the difference in their grayscale values. This difference reflects the clear visual distinction between the two pixels and is the most basic feature description.
[0146] (2) Calculate the deviation between a pixel and the mean of its neighborhood:
[0147] For pixel i, calculate its deviation from the neighborhood mean. ,in is the average grayscale value of all pixels in the neighborhood of pixel i. This deviation reflects the degree of abnormality of a pixel relative to its local environment and helps to identify regions of local abrupt change.
[0148] (3) Calculate the absolute value of the difference in gray values within the eight neighborhoods:
[0149] For pixel i, calculate the absolute value of the difference between the grayscale value of the pixel and the grayscale value of the other pixels in its eight neighborhood. This metric reflects the intensity of gradient changes around a pixel and is an important description of edge and texture features.
[0150] (4) Calculate the sine and cosine values of the angle between the vectors:
[0151] Consider the vector formed by pixel i and its eight neighboring pixels, and the vector formed by pixel i and pixel j, calculate the sine of the angle between the two vectors. Sum of cosine values This description introduces directional information, making gradient calculations direction-sensitive and helping to capture the morphological features of defects.
[0152] By combining the calculation results from the above four aspects, the minimum gradient value between each pixel and every pixel in the same class is determined. Compared with the traditional single gray-level difference calculation, this multi-dimensional feature gradient calculation method can more comprehensively describe the relationship between pixels and improve the sensitivity to various defect features.
[0153] In practical applications, the weights of each dimension of features can be adjusted according to the characteristics of different types of defects. For example, for edge-blurred defects, the weight of directional features can be increased; for point-like defects, the weight of local deviations can be increased. This flexible weight adjustment mechanism makes the present invention more adaptable.
[0154] This invention also provides a detailed implementation method for constructing a grayscale value array. The specific steps for constructing the grayscale value array will be described below.
[0155] The core of constructing the grayscale array is to assign the grayscale value of the target pixel corresponding to the minimum gradient value to the current pixel. The specific implementation steps are as follows:
[0156] (1) For each pixel in the grayscale image, traverse all pixels of the same class to determine the minimum gradient value and its corresponding target pixel. Preferably, in order to improve computational efficiency, the traversal range can be limited, for example, only considering pixels of the same class within a certain radius around the current pixel.
[0157] (2) Compare the gray value of the current pixel with the gray value of the target pixel corresponding to the minimum gradient value. This comparison can reveal the hierarchical relationship between pixels and help identify gray-scale gradient regions.
[0158] (3) When the gray value of the target pixel is greater than the gray value of the current pixel, the gray value of the target pixel is assigned to the current pixel. This assignment operation can enhance the hierarchical structure in the image, making the defective area more prominent.
[0159] (4) Update the gray values at the corresponding positions in the gray value array. After processing all pixels, the gray value array will reflect the structural characteristics of the image, providing a basis for subsequent analysis.
[0160] This grayscale array construction method enhances the structural information in images, particularly the contrast between defect areas and the background, thus improving the effectiveness of subsequent feature analysis. In practical applications, the assignment conditions can be adjusted according to the surface characteristics of different types of furniture. For example, for high-gloss surfaces, both greater than and less than conditions can be used simultaneously to capture more reflective properties.
[0161] Based on Example 1, the present invention also provides a detailed implementation method for growth trend analysis.
[0162] Growth trend analysis is a crucial transition from point features to line features, and its specific implementation steps are as follows:
[0163] (1) Establish an analysis window with each initial point as the center point. The window size is usually 3×3 or 5×5. The choice of window size needs to balance local detail capture and computational efficiency. For small defects, a smaller window can be used; for large defects, a larger window can be used.
[0164] (2) Determine the curve direction of each pixel within the window. The curve direction can be determined by the local gradient direction, for example, by using the Sobel operator to calculate the gradient direction:
[0165] ,
[0166] ,
[0167] ,
[0168] in, and These are the gradients in the horizontal and vertical directions, respectively. It is an image; * indicates a convolution operation; It is the gradient direction angle.
[0169] (3) Analyze the curve directions of the other pixels in the eight neighborhood of the initial point, excluding the initial point. This analysis can reveal the directional distribution characteristics around the initial point and help determine the main direction of the growth trend.
[0170] (4) Combining the characteristics of the initial point itself and the directional characteristics of its neighborhood, a growth trend description of the initial point is constructed. The growth trend description should include information on both spatial distribution and directional characteristics. In a preferred embodiment of the present invention, the growth trend is represented as a combination of a direction vector and a probability.
[0171] (5) Based on the consistency and continuity of direction, determine the main direction of the growth trend. The main direction can be determined by directional statistics or principal component analysis, selecting the direction with the highest frequency or the largest variance as the main direction.
[0172] The advantage of growth trend analysis lies in its ability to capture the morphological characteristics of defects, especially for defects with obvious directionality such as stripes and scratches, where the detection effect is particularly significant. Furthermore, growth trend analysis provides a foundation for overall trend judgment, achieving feature enhancement from local to global perspectives.
[0173] The present invention also provides a detailed implementation method for contour value calculation.
[0174] Silhouette value calculation is a key indicator for assessing the importance of overall trends, and its specific implementation steps are as follows:
[0175] (1) Count the number of pixels contained in each overall trend. The overall trend is formed by analyzing the overlap between growth trends, and it represents a coherent defect area. The number of pixels reflects the size of the defect area and is a basic indicator for assessing the importance of defects.
[0176] (2) The number of pixels is used as the contour value of the overall trend. The contour value is directly related to the area of the defect region and can be used to filter valid defect regions. In a preferred embodiment of the present invention, the contour value is calculated as follows:
[0177] ,
[0178] in, For the first The overall trend profile value; For belonging to the first A set of pixels representing an overall trend; This indicates the number of elements in the set.
[0179] (3) Set a contour value threshold to filter out small noise areas. The threshold setting is usually based on the image size and the minimum defect size to be detected. In embodiments of the present invention, the threshold can be set to 0.5% to 1% of the total number of pixels in the image. For example, for a 1920×1080 image, the threshold can be set to 10,000 to 20,000 pixels.
[0180] (4) Compare the contour value with the threshold to determine the valid overall trend. When the contour value is greater than the threshold, the overall trend is considered to represent a valid defect area; when the contour value is less than the threshold, it may be a false defect caused by noise or fine texture, and should be excluded.
[0181] The contour value calculation method is simple, intuitive, and highly efficient, while effectively filtering out true defect areas, making it a crucial element in achieving high-accuracy detection in this invention. In practical applications, the contour value threshold can be adjusted based on the characteristics of different defect types. For example, the threshold can be appropriately lowered for scenarios requiring the detection of small defects, while it can be increased for scenarios focusing only on large-area defects.
[0182] This invention also provides a detailed implementation method for calculating the probability exponent. Calculating the probability exponent is a crucial step in assessing the likelihood that a pixel belongs to a defect, and its specific implementation steps are as follows:
[0183] (1) Set the constant coefficient C for calculating the probability index. The constant coefficient is used to adjust the overall range of the probability index, and is usually set to a value between 0.5 and 1.0. In a preferred embodiment of the present invention, C is set to 0.8, a value that performs well in various furniture surface tests.
[0184] (2) Consider the ratio of the number of third-class pixels to the number of first-class pixels in the grayscale image. This ratio reflects the proportion of the potential defect area relative to the background area, and is a basic indicator of the likelihood of a defect. The larger the ratio, the more significant the potential defect area, and the higher the probability index should be.
[0185] (3) Combine the average probability index of the growth trend at the initial point This parameter incorporates information about the growth trend, linking the probability index calculation to the results of previous analyses and enhancing the coherence of the analysis. In practice, the average probability index of all initial points in the growth trend can be used as this parameter.
[0186] (4) Anomaly index based on each pixel within the central window The probability index of each pixel is calculated. The anomaly index reflects the degree of anomaly of a pixel relative to its surrounding environment and is a direct basis for assessing the likelihood of defects.
[0187] Taking all the above factors into account, the formula for calculating the probability index is:
[0188] ,
[0189] in, This is a hyperparameter used to adjust the degree of influence of the cumulative effect, and is usually set to a value between 0.01 and 0.1. The larger this hyperparameter is, the more significant the cumulative effect is, and the more sensitive the probability index is to the distribution of the outlier index.
[0190] The probability exponent calculation method comprehensively considers multiple factors, enabling a more accurate assessment of the likelihood that a pixel is a defect. In particular, the introduction of an exponential function makes the calculation results more consistent with the characteristics of a probability distribution. In practical applications, the probability exponent typically ranges from 0 to 1, with a higher value indicating a higher probability of it being a defect.
[0191] This invention also provides a detailed implementation method for calculating defect probability density. Defect probability density calculation is a comprehensive evaluation of defect characteristics within a central window, and its specific implementation steps are as follows:
[0192] (1) Calculate the variance of gray values of all pixels in the four neighborhoods of each pixel in the central window. Variance reflects the degree of dispersion of gray-level distribution around a pixel. The larger the variance, the more drastic the gray-level changes, which may indicate the presence of edges or defects.
[0193] (2) Calculate the average gray value of all pixels in the four neighboring regions of each pixel within the central window. The mean reflects the gray level around a pixel and serves as a benchmark for assessing the degree of anomaly of a pixel relative to its local environment.
[0194] (3) Obtain the grayscale value of each pixel in the center window. Grayscale value is the most basic image feature, directly reflecting the brightness level of a pixel.
[0195] (4) Combine the probability index of each pixel in the central window The probability index is the result of the preceding analysis, reflecting the likelihood that a pixel belongs to a defect, and is an important basis for calculating the defect probability density.
[0196] Based on the above parameters and hyperparameters The defect probability density of the center window is calculated using an exponential function:
[0197] ,
[0198] in, It is a small constant, such as 0.001, used to avoid the denominator being zero; It is a hyperparameter used to adjust the rate of exponential decay, and is usually set to a value between 0.1 and 0.5.
[0199] In this formula, It is the normalized grayscale deviation, which reflects the degree of abnormality of a pixel relative to its local environment; The probability assessment results of the preceding analysis were introduced; It is a decay factor used to adjust the level of the overall defect probability density.
[0200] The defect probability density calculation method comprehensively considers grayscale distribution characteristics and probability exponents, providing a more accurate description of the defect region. In practical applications, defect probability density values are typically distributed between 0 and 10, with higher values indicating a higher probability of a defect. To facilitate subsequent processing, the defect probability density can be normalized to distribute it between 0 and 1.
[0201] This invention also provides a detailed implementation method for determining the defect probability distribution. The defect probability distribution is a global description of the relationship between grayscale values and defect probabilities, and its specific implementation steps are as follows:
[0202] (1) Using the gray values of the pixels in the gray value array as the horizontal coordinates, a gray value space of 0~255 is constructed. This space covers all possible gray values, providing a complete reference framework for subsequent analysis.
[0203] (2) Use the mean of the defect probability density of all pixels in the grayscale array as the ordinate. For each grayscale value... Calculate the average defect probability density of all pixels with this grayscale value:
[0204] ,
[0205] in, The grayscale value is The mean defect probability density of pixels; For the grayscale value array, the grayscale value is A set of pixels; For pixels The probability density of defects in the central window; The grayscale value is The number of pixels.
[0206] (3) Establish a probability distribution curve based on the above coordinate data. This curve describes the relationship between different gray values and the probability of defects, and is an important basis for determining the optimal detection threshold.
[0207] In practical applications, defect probability distribution curves typically exhibit multi-peak characteristics, with different peaks corresponding to different types of regions. By analyzing the shape of the curve and the position of the peaks, potential defective regions and normal regions can be identified. For example, a high probability density in a high grayscale value region may indicate a reflective defect, while a high probability density in a low grayscale value region may indicate a dark spot defect.
[0208] To enhance the smoothness and interpretability of the curve, the original distribution curve can be smoothed, for example, using moving averages or Gaussian filtering. Furthermore, key points of change can be identified by analyzing the derivative properties of the curve; these points typically correspond to boundaries between different regions.
[0209] The defect probability distribution determination method provides a global correlation between grayscale values and defect probabilities, which is the basis for the adaptive threshold determination in this invention. Compared with the fixed threshold method, this probability distribution-based threshold determination method can better adapt to different types of furniture surfaces and different lighting conditions, improving the accuracy and robustness of detection.
[0210] This invention also provides a detailed implementation method for confidence level calculation. Confidence level calculation is a crucial step in evaluating the reliability of test results, and its specific implementation steps are as follows:
[0211] (1) Analyze the smoothness characteristic S of the grayscale array. Smoothness reflects the uniformity of the image and can be evaluated by the statistical characteristics of the gradient magnitude. In a preferred embodiment of the present invention, the smoothness calculation formula is:
[0212] ,
[0213] in, Let be the standard deviation of the gradient magnitude. This formula means that the greater the gradient change, the lower the smoothness; the smaller the gradient change, the higher the smoothness.
[0214] (2) Calculate the mean gray value of the gray value array. The grayscale mean reflects the overall brightness level of an image and is a fundamental indicator for evaluating image quality.
[0215] ,
[0216] in, This represents the total number of pixels in the grayscale value array. For pixels The grayscale value.
[0217] (3) Count the number of pixels N in the grayscale array. The number of pixels reflects the amount of information in the image. The larger the number, the more reliable the statistical characteristics.
[0218] (4) Using an exponential function to combine the above parameters, the confidence level of the defect probability density is obtained:
[0219] ,
[0220] in, The target grayscale value is usually set to the typical grayscale value of a normal surface. This is a hyperparameter used to adjust the degree of influence of grayscale deviation, and is usually set to a value between 0.01 and 0.1.
[0221] In this formula, S incorporates smoothness information; the higher the smoothness, the higher the confidence level. It is a decay factor based on the gray-level mean deviation. The closer the gray-level mean is to the target value, the smaller the decay and the higher the confidence. Dividing by N is for normalization processing, so that the image size does not significantly affect the confidence calculation.
[0222] The confidence score calculation method comprehensively considers multiple factors, enabling a more accurate assessment of the reliability of detection results. In practical applications, the confidence score is typically distributed between 0 and 1, with a higher value indicating a more reliable detection result. When the confidence score falls below a certain threshold (e.g., 0.6), adjustments to the detection parameters or re-acquiring the image may be considered.
[0223] This invention also provides a detailed implementation method for defect identification and rating. The specific steps for defect identification and rating are explained.
[0224] Defect identification and grading is the final step in the inspection process, and its specific implementation steps are as follows:
[0225] (1) Count the number of pixels in the grayscale array whose grayscale value is greater than the threshold. :
[0226] ,
[0227] in, The optimal detection threshold determined by the preceding steps; For pixels The grayscale value.
[0228] (2) Calculate the ratio of the number of pixels greater than the threshold to the total number of pixels to obtain the normal class probability value:
[0229] ,
[0230] Where N is the total number of pixels in the grayscale array.
[0231] (3) Determine whether a defect exists based on the probability value of the normal class:
[0232] when When the time comes, it is determined that the object to be tested does not have defects;
[0233] when At that time, it is determined that the object to be tested has a defect.
[0234] in, The defect judgment threshold is typically set to a value between 0.8 and 0.95. In a preferred embodiment of the present invention, Setting it to 0.9, this value performs well in various furniture surface tests.
[0235] (4) Determine the defect level based on the specific value of the normal probability value:
[0236] when At that time, it was determined to be without defects;
[0237] when At that time, it was determined to be a minor defect;
[0238] when At that time, it was determined to be a moderate defect;
[0239] when At that time, it was determined to be a serious defect.
[0240] This grading method is intuitive and clear, and can meet the quality control needs of most furniture production. In practical applications, the grading standards can be adjusted according to the specific quality requirements of the product. For example, for high-end furniture, the thresholds for each level can be increased to enhance the rigor of testing; for ordinary furniture, the thresholds can be appropriately lowered to reduce excessive rejection.
[0241] The defect identification and rating method is simple and effective, requires minimal computation, and can quickly provide test results, meeting the real-time inspection needs of the production line. Furthermore, the rating results can be directly used for quality control and product grading, improving production management efficiency.
[0242] Through testing on various furniture surface paint samples, the detection method of the present invention demonstrated excellent performance:
[0243] 1. Detection accuracy: For common paint defects (such as bubbles, runs, wrinkles, scratches, etc.), the detection accuracy can reach over 95%, with a false detection rate of less than 5% and a missed detection rate of less than 3%.
[0244] 2. Adaptability: It can adapt to different furniture surfaces (such as wood, metal, composite materials, etc.) and different lighting conditions, and the parameters are easy to adjust;
[0245] 3. Processing speed: For images with a resolution of 1920×1080, the processing time on a typical industrial computer (Intel Core i5 processor, 8GB memory) is usually within 200ms, which meets the requirements of online inspection;
[0246] 4. Defect Level Assessment: The results of the defect level assessment are consistent with the evaluations of professional quality inspectors in over 90% of cases, providing a reliable basis for refined product quality management.
[0247] Compared with the prior art, the advantages of the present invention are:
[0248] 1. Compared with the traditional threshold segmentation method, this method introduces multi-dimensional feature analysis and hierarchical processing architecture, which greatly improves detection accuracy and adaptability;
[0249] 2. Compared with deep learning methods, this method does not require a large amount of labeled data, has low computational resource requirements, and the detection results are highly interpretable, making it easy to apply in industrial settings;
[0250] 3. Compared with traditional texture analysis methods, this method integrates directional information and probabilistic models, which enhances the detection capability of small defects and irregularly shaped defects.
[0251] In summary, the vision-based furniture surface paint defect detection method provided by this invention achieves high accuracy and adaptability in defect detection and grade assessment through innovative multi-dimensional feature gradient calculation, growth trend analysis, and probability model evaluation, providing an effective tool for quality control in the furniture manufacturing industry.
[0252] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A vision-based method for detecting defects in furniture surface paint, characterized in that, The method includes: Acquire a surface image of the object being detected, wherein the surface image is a grayscale image; The K-means clustering algorithm is used to divide the pixels in the grayscale image into three categories. The number of pixels belonging to each of the three categories and the average grayscale value of the third category of pixels are calculated respectively. The grayscale value of the pixels belonging to the first category is assigned to the pixels belonging to the second category of the grayscale image to obtain the grayscale image. The steps of the K-means clustering algorithm are as follows: (1) Initialize three cluster centers, selecting three points with gray values of 0, 128 and 255; (2) Calculate the distance from each pixel to each cluster center and assign the pixel to the nearest category; (3) Recalculate the center point of each category; (4) Repeat steps (2) and (3) until the cluster centers are stable or the maximum number of iterations is reached; After clustering is completed, the number of pixels and the average gray value of each category are counted. The three categories are sorted in ascending order of average gray value and labeled as the first category, the second category, and the third category, respectively. Determine the minimum gradient value between each pixel in the grayscale image and each pixel in the same class. Assign the grayscale value of each pixel to each pixel whose minimum gradient value between each pixel and each pixel in the same class is greater than the grayscale value of the pixel in the image. This will result in a grayscale value array. Mark each element in the grayscale value array whose grayscale value is equal to the grayscale value of the pixel in the first class as the initial point. The growth trend of each initial point is determined based on each initial point and the curve direction in which the initial point is located. When the overlap ratio of any two growth trends is within the set range, the two growth trends are recorded as an overall trend. Otherwise, the two growth trends are recorded as opposite growth trends. The contour value of each overall trend is determined based on the number of pixels in each overall trend. The point with the largest pixel value among all pixels in the overall growth trend whose contour value is greater than the set number of pixels is set as the center point. A central window is formed by a center point and the points in its eight neighboring regions. The anomaly index of the center point is determined based on the gray value of the center point and each pixel in the central window. When the pixels in the four neighboring regions of the center point are third-class pixels, the center point is marked as an anomaly. The anomaly index of the pixel with the smallest gray value among all pixels in the central window is taken as the anomaly index of each pixel in the central window. The probability index of each pixel in the central window is determined based on the anomaly index of each pixel in the central window. The defect probability density of the central window is determined based on the anomaly index and the probability index of each pixel in the central window. The defect probability distribution of the grayscale value array is determined based on the defect probability density of the pixels in the grayscale value array. The confidence level of the defect probability density of the grayscale value array is determined based on the smoothness of the grayscale value array, the mean grayscale value of the pixels in the grayscale value array, and the defect probability distribution. The threshold is determined based on the confidence level of the defect probability distribution and defect probability density of the grayscale value array. The probability value of the object to be detected belonging to the normal class is determined based on the grayscale value array and the threshold. The presence or absence of defects in the object to be detected is determined based on the probability value of the object to be detected belonging to the normal class. The level of defects on the surface of the object to be inspected is determined based on the probability value that the object belongs to the normal category.
2. The vision-based method for detecting defects in furniture surface paint according to claim 1, characterized in that, The step of determining the minimum gradient value between each pixel in the grayscale image and each pixel of the same class includes: Calculate the difference in grayscale values between pixels; Calculate the deviation of a pixel from the mean of its neighborhood; Calculate the absolute value of the grayscale value difference between the pixel and other pixels in its eight-neighborhood; Calculate the sine and cosine of the angle between the vector formed by the pixel and the other pixels in the eight-neighborhood and the vector formed by the two pixels; Based on the above calculation results, the minimum gradient value between each pixel and each pixel in the same class is determined.
3. The vision-based method for detecting defects in furniture surface paint according to claim 1, characterized in that, The grayscale value of each pixel is assigned to the pixel whose minimum gradient value is greater than that of the pixel in the same class, including: For each pixel in the grayscale image, iterate through all pixels of the same class; Compare the grayscale value of each pixel with the grayscale value of the target pixel corresponding to its minimum gradient value; When the gray value of the target pixel is greater than the gray value of the current pixel, the gray value of the target pixel is assigned to the current pixel. Update the grayscale value at the corresponding position in the grayscale value array.
4. The vision-based method for detecting defects in furniture surface paint according to claim 1, characterized in that, The process of determining the growth trend of each initial point based on each initial point and the curve direction in which the initial point is located includes: An analysis window is created with each initial point as the center point; Determine the curve direction for each pixel within the window; Analyze the curve directions of the pixels in the eight neighborhood of the initial point, excluding the initial point itself. By combining the characteristics of the initial point itself and the characteristics of the neighborhood direction, a growth trend description of the initial point is constructed. Based on directional consistency and continuity, the main direction of the growth trend is determined.
5. The vision-based method for detecting defects in furniture surface paint according to claim 1, characterized in that, The process of determining the contour value of each overall trend based on the number of pixels in each overall trend includes: Count the number of pixels included in each overall trend; Use this quantity as the profile value of the overall trend; Set a contour value threshold to filter out small noise areas; Compare the contour values with the threshold to determine the effective overall trend.
6. The vision-based method for detecting defects in furniture surface paint according to claim 1, characterized in that, The step of determining the probability index of each pixel in the central window based on the anomaly index of each pixel in the central window includes: Set the constant coefficient for the probability exponent calculation; Consider the ratio of the number of third-class pixels to the number of first-class pixels in a grayscale image; Combined with the average probability index of the growth trend at the initial point; Based on the anomaly index of each pixel within the central window; By comprehensively considering the above factors, the probability index of each pixel within the central window is calculated.
7. The vision-based method for detecting defects in furniture surface paint according to claim 1, characterized in that, The step of determining the defect probability density of the central window based on the anomaly index and probability index of each pixel within the central window includes: Calculate the variance of grayscale values of all pixels in the four neighboring regions of each pixel within the central window; Calculate the average grayscale value of all pixels in the four neighboring regions of each pixel within the central window; Get the grayscale value of each pixel within the center window; Combine the probability index of each pixel within the central window; Based on the above parameters and hyperparameters, the defect probability density of the central window is calculated using an exponential function.
8. The vision-based method for detecting defects in furniture surface paint according to claim 1, characterized in that, The step of determining the defect probability distribution of the grayscale value array based on the defect probability density of pixels in the grayscale value array includes: Use the gray values of the pixels in the gray value array as the x-coordinate; The mean value of the defect probability density of all pixels in the grayscale array is used as the ordinate; A probability distribution curve is established based on the above coordinate data; This curve illustrates the relationship between different grayscale values and the probability of defects.
9. The vision-based method for detecting defects in furniture surface paint according to claim 1, characterized in that, The step of determining the confidence level of the defect probability density of the grayscale value array based on the smoothness of the grayscale value array includes: Analyze the smoothness characteristics of the grayscale array; Calculate the mean gray value of the gray value array; Count the number of pixels in the grayscale value array; The confidence level of the defect probability density is obtained by combining the above parameters using an exponential function. This confidence level reflects the reliability of the test results.
10. The vision-based method for detecting defects in furniture surface paint according to claim 1, characterized in that, The step of determining the probability value of the object to be detected belonging to the normal class based on the grayscale value array and the threshold includes: Count the number of pixels in the grayscale array whose grayscale value is greater than a threshold; Calculate the ratio of the number of pixels greater than the threshold to the total number of pixels; This ratio represents the probability that the object being tested belongs to the normal class. When the probability value is greater than or equal to the set threshold, it is determined that the object to be detected has no defects; When the probability value is less than the set threshold, the object to be tested is determined to have a defect, and the defect level is determined according to the specific value of the probability value.
Citation Information
Patent Citations
Furniture surface paint spraying defect detection method based on vision
CN115222743A
LED lamp bead defect detection method and system
CN119963547A