A method for non-contact detection of polyurethane foam boards
By adjusting the Gaussian filter variance and the weights of neighboring pixels through adaptive Gaussian filtering, the problem of misjudgment of texture edges in polyurethane foam board detection is solved, and higher accuracy anomaly detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHAANXI SHAANXI YAO FUTURE ENVIRONMENTAL PROTECTION TECHNOLOGY CO LTD
- Filing Date
- 2025-12-12
- Publication Date
- 2026-06-23
AI Technical Summary
Existing methods for detecting anomalies in polyurethane foam boards have low accuracy, mainly because traditional Gaussian filtering cannot effectively distinguish between decorative texture edges and defect edges, leading to normal texture edges being misjudged as scratch defects.
An adaptive Gaussian filtering method is adopted. By obtaining the gray-level co-occurrence matrix and autocorrelation within the Gaussian filtering window, the variance of the Gaussian filter and the weight values of neighboring pixels are dynamically adjusted to smooth the edges of normal textures and preserve the edges of scratch defects.
It improves the accuracy of anomaly detection in polyurethane foam boards, accurately extracts the edges of scratch defects, and reduces misjudgment of normal texture edges.
Smart Images

Figure CN121685478B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and specifically to a non-contact testing method for polyurethane foam boards. Background Technology
[0002] Polyurethane foam board is a new type of synthetic material with thermal insulation and waterproofing functions. It is mainly used in building exterior wall insulation, integrated roof waterproofing and insulation, cold storage insulation, pipe insulation materials, building panels, and refrigerated truck and cold storage insulation materials. During continuous, large-scale production, factors such as fluctuations in raw material ratios, improper control of foaming conditions, and abnormal curing processes can cause surface defects in the foam board, such as cracks, scratches, and abnormal density. These abnormalities can significantly affect the product's appearance and physical properties, such as thermal conductivity and compressive strength.
[0003] Existing methods for detecting anomalies in polyurethane foam boards primarily involve edge detection of acquired images to extract defective edges. However, before edge extraction, traditional Gaussian filtering is typically used for smoothing to reduce noise during subsequent edge extraction. Furthermore, polyurethane foam boards often contain normal decorative texture edges. During the smoothing process using traditional Gaussian filtering, these decorative texture edges and scratch defect edges are affected by their surrounding pixels in the same way. This leads to the normal decorative texture edges being mistaken for scratch defects and extracted during subsequent edge extraction, resulting in low accuracy in detecting anomalies in polyurethane foam boards. Summary of the Invention
[0004] This invention provides a non-contact detection method for polyurethane foam boards, which solves the problem of low accuracy in existing methods for anomaly detection of polyurethane foam boards. The specific technical solution adopted is as follows:
[0005] This invention provides a non-contact testing method for polyurethane foam boards, comprising the following steps:
[0006] The surface image of the polyurethane foam board to be tested is acquired and processed to obtain the target grayscale image.
[0007] Obtain the Gaussian filter window corresponding to each pixel in the target grayscale image; based on the Gaussian filter window corresponding to each pixel, obtain the grayscale co-occurrence matrix of the target grayscale image;
[0008] Based on the gray-level co-occurrence matrix, the Gaussian filter variance value is obtained;
[0009] Based on the autocorrelation of the gray-level co-occurrence matrix, the autocorrelation of each neighboring pixel within the Gaussian filter window corresponding to each pixel is obtained.
[0010] Based on the coordinate values and autocorrelation of each neighboring pixel, the weight values of each neighboring pixel within the Gaussian filter window corresponding to each pixel are obtained.
[0011] Based on the Gaussian filter variance value, the initial Gaussian value of each neighboring pixel in the Gaussian filter window corresponding to each pixel is obtained.
[0012] Based on the weight value and the initial Gaussian value, the target Gaussian value of each neighboring pixel in the Gaussian filter window corresponding to each pixel is obtained.
[0013] Based on the target Gaussian value and gray value of each neighboring pixel in the Gaussian filter window corresponding to each pixel, the target grayscale image after Gaussian filtering smoothing is obtained.
[0014] Edge detection is performed on the target grayscale image after Gaussian filtering and smoothing. The edges extracted by edge detection are recorded as the scratch defect edges on the polyurethane foam board to be tested.
[0015] Preferably, the method for acquiring and processing the surface image of the polyurethane foam board to be tested to obtain the target grayscale image includes:
[0016] Semantic segmentation is performed on the surface image corresponding to the polyurethane foam board to be tested. The segmented surface image containing the polyurethane foam board is then converted to grayscale, and the grayscale image is recorded as the target grayscale image.
[0017] Preferably, the method for obtaining the gray-level co-occurrence matrix of the target gray-level image based on the Gaussian filter window corresponding to each pixel includes:
[0018] Using the center pixel of each Gaussian filter window as the origin, the horizontal direction as the x-axis and the vertical direction as the y-axis, we obtain the coordinate system of the Gaussian filter window corresponding to each pixel and the coordinate values of each pixel in the Gaussian filter window corresponding to each pixel.
[0019] Based on the ordinate and abscissa values of each pixel within the Gaussian filter window corresponding to each pixel, the orientation angle of each pixel within the Gaussian filter window corresponding to each pixel is obtained.
[0020] Based on the orientation angle of each pixel within the Gaussian filter window corresponding to each pixel, the types of orientation angles are statistically obtained, and each type of orientation angle is recorded as a feature direction.
[0021] The gray-level co-occurrence matrix of the target gray-level image in each feature direction is calculated.
[0022] Preferably, the method for obtaining the orientation angle of each pixel within the Gaussian filter window based on the ordinate and abscissa values of each pixel within the Gaussian filter window includes:
[0023] Get the pixels within the Gaussian filter window that are not on the coordinate axis of the corresponding coordinate system, and denot them as feature pixels;
[0024] For any pixel in the target grayscale image, the orientation angle corresponding to each feature pixel within the Gaussian filter window is calculated using the following formula:
[0025]
[0026] in, This represents the x-coordinate of the a-th feature pixel within the Gaussian filter window corresponding to that pixel. This represents the ordinate value of the a-th feature pixel within the Gaussian filter window corresponding to that pixel. Let be the orientation angle of the a-th feature pixel within the Gaussian filter window corresponding to the pixel, and arctan2() is the two-parameter arctangent function;
[0027] The orientation angle of the pixel with an x-coordinate value of 0 and a y-coordinate value of non-0 in each Gaussian filter window is recorded as 90°.
[0028] The orientation angle of pixels with a vertical coordinate of 0 and a horizontal coordinate of non-0 within each Gaussian filter window is recorded as 0°.
[0029] Preferably, the method for obtaining the Gaussian filter variance value based on the gray-level co-occurrence matrix includes:
[0030] Summing the gray-level co-occurrence matrices corresponding to each feature direction of the target gray-level image, dividing the sum by the number of gray-level co-occurrence matrices corresponding to the target gray-level image, and recording the result as the target gray-level co-occurrence matrix corresponding to the target gray-level image;
[0031] Calculate the Gaussian filter variance value using the following formula:
[0032]
[0033] in, This represents the Gaussian filter variance value corresponding to the Gaussian filter. Let e be the energy value of the target gray-level co-occurrence matrix corresponding to the target gray-level image, and e is a natural constant.
[0034] Preferably, the method for obtaining the weight values of each neighboring pixel within the Gaussian filter window corresponding to each pixel based on the coordinate values and autocorrelation of each neighboring pixel includes:
[0035] Based on the gray-level co-occurrence matrix of the target gray-level image in each feature direction, the autocorrelation of the gray-level co-occurrence matrix of the target gray-level image in each feature direction is obtained;
[0036] Each pixel in the Gaussian filter window corresponding to each pixel, except for the center pixel, is recorded as the neighboring pixel in the Gaussian filter window corresponding to each pixel.
[0037] For any pixel, the neighboring pixels within the Gaussian filter window corresponding to any pixel:
[0038] Based on the orientation angle corresponding to the neighboring pixel, the feature orientation corresponding to the neighboring pixel is obtained, and the autocorrelation of the gray-level co-occurrence matrix corresponding to the feature orientation is recorded as the autocorrelation corresponding to the neighboring pixel.
[0039] Preferably, for any neighboring pixel within the Gaussian filter window corresponding to any pixel, the weight value of that neighboring pixel within the Gaussian filter window is calculated according to the following formula:
[0040]
[0041] in, For the neighboring pixels within the Gaussian filter window corresponding to this pixel. The weight value, This represents the x-coordinate of the neighboring pixels within the Gaussian filter window corresponding to the given pixel. This represents the ordinate value of the neighboring pixels within the Gaussian filter window corresponding to the given pixel. Indicates to Normalization This represents the autocorrelation of neighboring pixels within the Gaussian filter window corresponding to the given pixel. Indicates to Normalization.
[0042] Preferably, the method for obtaining the initial Gaussian value of each neighboring pixel within the Gaussian filter window corresponding to each pixel based on the Gaussian filter variance value includes:
[0043] Based on the Gaussian filter variance value corresponding to the Gaussian filter, the Gaussian function is obtained. According to the Gaussian function, the initial Gaussian value of each neighboring pixel in the Gaussian filter window corresponding to each pixel is obtained.
[0044] Preferably, the method for obtaining the target Gaussian value of each neighboring pixel within the Gaussian filter window corresponding to each pixel, based on the weight value and the initial Gaussian value, includes:
[0045] Sort the initial Gaussian values of each neighboring pixel within the Gaussian filter window corresponding to each pixel in ascending order of initial Gaussian values to obtain the sequence of initial Gaussian values corresponding to each pixel.
[0046] Sort the neighboring pixels in the Gaussian filter window corresponding to each pixel in ascending order of weight value to obtain the sequence of neighboring pixels corresponding to each pixel.
[0047] For any pixel in the target grayscale image: assign the m-th initial Gaussian value from the initial Gaussian value sequence corresponding to the pixel to the m-th neighboring pixel in the corresponding neighborhood pixel sequence, and record it as the target Gaussian value of the m-th neighboring pixel in the corresponding neighborhood pixel sequence, where m is an integer.
[0048] Preferably, the method for obtaining the target grayscale image after Gaussian filtering smoothing based on the target Gaussian value and grayscale value of each neighboring pixel within the Gaussian filtering window corresponding to each pixel includes:
[0049] Based on the target Gaussian value and grayscale value of each neighboring pixel in the Gaussian filter window corresponding to each pixel, the center pixel in the Gaussian filter window corresponding to each pixel is smoothed to obtain the smoothed pixel value of the center pixel in the Gaussian filter window corresponding to each pixel.
[0050] Based on the smoothed pixel value of the center pixel in the Gaussian filter window corresponding to each pixel, the target grayscale image after Gaussian filtering and the smoothed pixel value of each pixel in the target grayscale image after Gaussian filtering are obtained; the smoothed pixel value of the center pixel in the Gaussian filter window corresponding to each pixel is the sum of the target Gaussian value and the corresponding grayscale value of each neighboring pixel in the Gaussian filter window corresponding to the corresponding pixel.
[0051] Beneficial Effects: The main objective of this invention is to smooth out normal texture edges on polyurethane foam boards while preserving scratch defect edges based on edge detection and adaptive Gaussian filtering, thereby improving the accuracy of subsequent scratch defect edge extraction. This invention first obtains the Gaussian filter variance value based on the gray-level co-occurrence matrix corresponding to the target gray-level image. The gray-level co-occurrence matrix reflects the texture information of the image. This invention, by obtaining the Gaussian filter variance value based on the image's texture information, avoids setting the Gaussian filter variance value too large, which would result in both scratch defect edges and normal texture edges being over-smoothed, failing to achieve the goal of smoothing out normal texture edges on the polyurethane foam board while preserving scratch defect edges. Simultaneously, it also avoids setting the Gaussian filter variance value too small, which would lead to ineffective smoothing of normal texture edges. In other words, this invention uses the gray-level co-occurrence matrix to set the Gaussian filter variance value, which is the basis for subsequently smoothing out normal texture edges on the polyurethane foam board while preserving scratch defect edges.
[0052] Next, based on the coordinates and autocorrelation of the neighboring pixels within the Gaussian filter window corresponding to each pixel, this invention obtains the weight values of the neighboring pixels within the Gaussian filter window corresponding to each pixel. The autocorrelation reflects the relationship between the neighboring pixels within the Gaussian filter window and the normal texture direction. Referring to the autocorrelation of the neighboring pixels can avoid assigning excessive weights to neighboring pixels similar to the center pixel, resulting in a lower smoothness of the center pixel in subsequent windows. The coordinates of the neighboring pixels reflect the distance between the neighboring pixels and the center pixel in the corresponding window. The closer the distance, the more important the smoothing effect on the center pixel is, i.e., the closer the distance, the larger the corresponding weight value. Therefore, based on the weight values of the neighboring pixels within the Gaussian filter window corresponding to each pixel, this invention can further achieve the purpose of smoothing out the normal texture edges on the polyurethane foam board while preserving the edges of scratch defects.
[0053] Finally, this invention performs edge detection on the target grayscale image after Gaussian filtering and smoothing, which can accurately extract the edges of scratch defects on the polyurethane foam board to be tested. In other words, this invention improves the accuracy of anomaly detection on polyurethane foam boards. Attached Figure Description
[0054] To more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0055] Figure 1 This is a flowchart of a non-contact polyurethane foam board testing method according to the present invention. Detailed Implementation
[0056] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention are within the protection scope of the embodiments of the present invention.
[0057] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art.
[0058] This embodiment provides a non-contact testing method for polyurethane foam boards, which is described in detail below:
[0059] like Figure 1 As shown, the testing method for a non-contact polyurethane foam board includes the following steps:
[0060] Step S001: Obtain the surface image of the polyurethane foam board to be tested and process it to obtain the target grayscale image.
[0061] This embodiment primarily focuses on anomaly detection in polyurethane foam boards, specifically detecting scratches and defects. The polyurethane foam boards contain normal decorative texture edges. Existing technologies mainly rely on traditional Gaussian filtering and edge detection for anomaly detection. However, during the smoothing process of traditional Gaussian filtering, both the decorative texture edges and scratch defect edges are affected by their surrounding pixels. This leads to the decorative texture edges being mistakenly extracted as scratch defects during subsequent edge extraction, resulting in low accuracy in anomaly detection. Therefore, this embodiment proposes a non-contact polyurethane foam board detection method. This method primarily uses edge detection and adaptive Gaussian filtering to detect scratch defects on polyurethane foam boards. The adaptive Gaussian filtering smooths out the normal texture edges while preserving the scratch defect edges, allowing for more accurate extraction of scratch defect edges and improving the accuracy of anomaly detection.
[0062] This embodiment first uses a CCD camera to acquire the surface image of the completed polyurethane foam board to be tested. The camera is positioned above the polyurethane foam board, with its acquisition angle pointing downwards. Since the acquired surface image of the polyurethane foam board includes background areas other than polyurethane foam, to reduce the computational load of subsequent analysis, this embodiment performs semantic segmentation on the acquired surface image, retaining the polyurethane foam board area and setting the remaining background areas to black, thus obtaining a surface image containing only polyurethane foam. Then, the surface image containing only polyurethane foam is converted to grayscale, and the grayscale image is recorded as the target grayscale image corresponding to the polyurethane foam board to be tested. This embodiment utilizes a semantic segmentation network to segment the surface image of the polyurethane foam board to be tested. Since image segmentation using semantic segmentation networks is a well-known technique, it will not be described in detail here.
[0063] Step S002: Obtain the Gaussian filter window corresponding to each pixel in the target grayscale image; obtain the gray-level co-occurrence matrix of the target grayscale image based on the Gaussian filter window corresponding to each pixel; obtain the Gaussian filter variance value based on the gray-level co-occurrence matrix.
[0064] This embodiment primarily utilizes adaptive Gaussian filtering to smooth out the normal texture edges on the polyurethane foam board while preserving the edges of scratches and defects. Specifically, it achieves this by analyzing the texture information in the image and setting the Gaussian filter variance value and the weight values of each pixel within the Gaussian filter window.
[0065] Since different types of polyurethane foam boards may have different normal decorative textures, if the texture of the polyurethane foam board is not considered and the Gaussian filter variance value is set solely based on the traditional method of setting the Gaussian filter variance value, and then smoothed for all types of polyurethane foam boards based on the traditionally set Gaussian filter variance value, the edges of the normal decorative textures will be extracted as scratches and defects during subsequent edge extraction. This embodiment, however, sets an appropriate Gaussian filter variance value based on the analysis results of the polyurethane foam board texture, thereby smoothing out the edges of the normal textures on the polyurethane foam board while preserving the edges of scratches and defects. Therefore, the specific process for obtaining the Gaussian filter variance value is as follows:
[0066] This embodiment first obtains the Gaussian filter window corresponding to each pixel in the target grayscale image. The size of each Gaussian filter window is 5*5. Then, it constructs the coordinate system of the Gaussian filter window corresponding to each pixel, obtaining the coordinate values of each pixel within the Gaussian filter window. The process of constructing the coordinate system is as follows: using the center pixel within each Gaussian filter window as the origin, the horizontal direction as the x-axis, and the vertical direction as the y-axis, the coordinate system of the Gaussian filter window corresponding to each pixel is obtained. Then, the pixels within the Gaussian filter window that are not on the corresponding coordinate axis are obtained and denoted as feature pixels. Based on the x-coordinate and y-coordinate of each feature pixel within the Gaussian filter window, the orientation angle of each feature pixel within the Gaussian filter window relative to the center pixel within the corresponding Gaussian filter window is obtained and denoted as the orientation angle corresponding to each feature pixel. For any pixel in the target grayscale image, the orientation angle corresponding to each feature pixel within the Gaussian filter window is calculated according to the following formula:
[0067]
[0068] in, This represents the x-coordinate of the a-th feature pixel within the Gaussian filter window corresponding to that pixel. This represents the ordinate value of the a-th feature pixel within the Gaussian filter window corresponding to that pixel. Let be the orientation angle of the a-th feature pixel within the Gaussian filter window corresponding to this pixel, and arctan2() is the two-parameter arctangent function.
[0069] Since each Gaussian filter window is 5*5, the number of pixels in each Gaussian filter window that are on the corresponding coordinate axis is 9, and the number of pixels in each Gaussian filter window that are not on the corresponding coordinate axis is 16, that is, the number of feature pixels in each Gaussian filter window is 16. Since the origin of each Gaussian filter window is the center pixel, the horizontal axis is horizontal and the vertical axis is vertical. Therefore, the coordinates of the pixels in the i-th row and j-th column within each Gaussian filter window are all the same; thus, the orientation angles of the pixels with coordinates (-2,2) and (-1,1) and the pixels with coordinates (1,-1) and (2,-2) within each Gaussian filter window are recorded as the first feature direction; the orientation angles of the pixels with coordinates (2,2) and (1,1) and the pixels with coordinates (-1,-1) and (-2,-2) within each Gaussian filter window are recorded as the second feature direction; the orientation angles of the pixels with coordinates (1,2) and (-1,-2) within each Gaussian filter window are recorded as the third feature direction; each Gaussian filter... The orientation angles of pixels with coordinates (2,1) and (-2,-1) within the Gaussian filter window are recorded as the 4th feature direction; the orientation angles of pixels with coordinates (-1,2) and (1,-2) within each Gaussian filter window are recorded as the 5th feature direction; the orientation angles of pixels with coordinates (-2,1) and (2,-1) within each Gaussian filter window are recorded as the 6th feature direction; the orientation angles of pixels with an x-coordinate of 0 and a y-coordinate of non-0 within each Gaussian filter window are recorded as the 7th feature direction; and the orientation angles of pixels with a y-coordinate of 0 and a x-coordinate of non-0 within each Gaussian filter window are recorded as the 8th feature direction; thus, a total of eight types of feature directions are obtained. The gray-level co-occurrence matrix of the target grayscale image will be calculated using these eight types of feature directions. The purpose of obtaining feature directions based on the Gaussian filter window in this embodiment is to analyze the relationship between the orientation angles of each pixel within the Gaussian filter window and the normal texture direction on the polyurethane foam board under test, facilitating the subsequent setting of the weight values of each pixel within the Gaussian filter window.
[0070] Since the gray-level co-occurrence matrix (GLCM) can effectively statistically analyze texture information in an image and obtain some texture feature values, this embodiment will use the GLCM to reflect the texture information of the image. Specifically, this embodiment will obtain feature values reflecting the texture based on the GLCM, and subsequently obtain the Gaussian filter variance value based on these feature values. To facilitate the acquisition of the GLCM, the gray levels of the original image are generally compressed to a smaller range. In this embodiment, gray levels 0 to 255 are transformed into gray levels 0 to 7, i.e., every 32 gray levels are compressed into one level, resulting in the compressed target gray-level image and the gray values corresponding to each pixel in the compressed target gray-level image. Then, based on the gray values corresponding to each pixel in the compressed target gray-level image, the target gray level is statistically obtained. The image is plotted as follows: the gray-level co-occurrence matrix (GLCM) corresponding to each feature direction; the statistical step size is 1, meaning the statistical step size is 1 pixel; then, the GLCM corresponding to each feature direction of the target gray-level image is summed, and the summation result is divided by the number of GLCMs, and recorded as the target GLCM corresponding to the target gray-level image; then, the energy value (ASM value) of the target GLCM corresponding to the target gray-level image is calculated; the ASM value can reflect the texture information of the target gray-level image. If the ASM value is smaller, it indicates that the texture in the image is finer and the edges are sharper, and vice versa. The process of obtaining the energy value of the GLCM is a known technique, so it will not be described in detail here.
[0071] Since the magnitude of the Gaussian filter variance reflects the influence of other pixels within the Gaussian filter window on the smoothing result of the center pixel, the larger the Gaussian filter variance, the greater the influence of other pixels within the Gaussian filter window on the smoothing result of the center pixel, and vice versa; and since the main purpose of this embodiment is to smooth out the normal texture edges on the polyurethane foam board while preserving the edges of scratch defects, the Gaussian filter variance value should conform to the ASM value when setting it. That is, the finer the texture (smaller the ASM value) on the polyurethane foam board being tested, the larger the ASM value should be. A smaller Gaussian filter variance value is set to avoid the phenomenon that the edges of scratch defects and normal textures are overly smoothed due to an excessively large Gaussian filter variance value, which would prevent the smoothing of normal texture edges on the polyurethane foam board while preserving scratch defect edges. When the texture of the polyurethane foam board under test is coarser (larger ASM value), a larger Gaussian filter variance value should be set to avoid the phenomenon that the normal texture edges are ineffectively smoothed due to an excessively small Gaussian filter variance value. Therefore, in this embodiment, the Gaussian filter variance value corresponding to the Gaussian filter is obtained based on the energy value of the target gray-level co-occurrence matrix corresponding to the target gray-level image. The Gaussian filter variance value corresponding to the Gaussian filter is calculated according to the following formula:
[0072]
[0073] in, This represents the Gaussian filter variance value corresponding to the Gaussian filter. Let e be the energy value of the target gray-level co-occurrence matrix corresponding to the target gray-level image, where e is the natural constant. The larger the value, the larger the variance of the Gaussian filter, and vice versa. The smaller the value, the smaller the variance of the Gaussian filter. The smaller the value, The smaller, the opposite. The larger the value, the better. The larger; Yes Perform negative correlation normalization to keep its value between 0 and 1; This is to ensure that the relationship between the energy value and the variance value is positively correlated.
[0074] Step S003: Based on the autocorrelation of the gray-level co-occurrence matrix, obtain the autocorrelation of each neighboring pixel in the Gaussian filter window corresponding to each pixel; based on the coordinate values and autocorrelation of each neighboring pixel, obtain the weight value of each neighboring pixel in the Gaussian filter window corresponding to each pixel.
[0075] When Gaussian filtering smooths the center pixel of each window, the smoothing result is obtained by summing the product of the pixel values of each neighboring pixel and the corresponding Gaussian value of the neighboring pixel. However, the influence of neighboring pixels on the center pixel at different positions is different. For example, when the center pixel in the window is an edge pixel, and the center pixel in the window is a normal texture edge pixel, if a large weight is set for the neighboring pixels of the center pixel in the window during smoothing, and the neighboring pixels of the center pixel are also normal texture edge pixels, then the smoothing degree of the center pixel will be greatly affected by the neighboring pixels. Therefore, the smoothing degree will be relatively small, and it will be impossible to achieve the purpose of smoothing out the normal texture edge on the polyurethane foam board and retaining the edge of the scratch defect. Therefore, in this embodiment, the weight values of each neighboring pixel in the window will be set based on the distance between each neighboring pixel and the center pixel, and whether the orientation angle corresponding to each neighboring pixel in the window is a normal texture direction. The neighboring pixels are all pixels in the window except the center pixel. When the orientation angle of a neighboring pixel in the window is a normal texture direction angle, it indicates that the texture features of the neighboring pixel and the center pixel may be consistent, that is, both the neighboring pixel and the center pixel may be normal texture edge points. Therefore, the weight value of the neighboring pixel should be set to a small value to avoid the smoothness of the center pixel being greatly affected by the neighboring pixel, resulting in a small smoothness of the center pixel. This embodiment considers the distance between each neighboring pixel and the center pixel in the window because the closer the neighboring pixel is to the center pixel, the more important the smoothing effect of the neighboring pixel is to the center pixel, and a larger weight value should be set.
[0076] Since the orientation angle of each neighboring pixel within the window relative to the window center point is a normal texture direction angle, it can be reflected by the autocorrelation of the gray-level co-occurrence matrix of the target gray-level image in each feature direction; and the greater the autocorrelation of the gray-level co-occurrence matrix of the target gray-level image in each feature direction, the more texture there is in the corresponding feature direction. Furthermore, the scratch defect texture on the polyurethane foam board under test is usually less than the normal texture. Therefore, the feature direction with a higher autocorrelation is the normal texture direction corresponding to the polyurethane foam board under test. Therefore, in this embodiment, the autocorrelation of the gray-level co-occurrence matrix of the target gray-level image in each feature direction is obtained based on the gray-level co-occurrence matrix of the target gray-level image in each feature direction. The autocorrelation of the gray-level co-occurrence matrix of the target gray-level image in each feature direction is calculated according to the following formula:
[0077]
[0078] in, Let be the autocorrelation of the gray-level co-occurrence matrix of the target gray-level image in the b-th feature direction. Let k be the number of rows in the gray-level co-occurrence matrix of the target gray-level image in the b-th feature direction, and k is also the number of columns in the gray-level co-occurrence matrix of the target gray-level image in the b-th feature direction. Let f be the value of the element in the f-th row and g-th column of the gray-level co-occurrence matrix corresponding to the b-th feature direction of the target gray-level image. Let f be the mean value of each element in the f-th row of the gray-level co-occurrence matrix corresponding to the b-th feature direction of the target gray-level image. Let g be the mean value of each element in the g-th column of the gray-level co-occurrence matrix corresponding to the b-th feature direction of the target gray-level image. Let be the variance of the element values in the f-th row of the gray-level co-occurrence matrix corresponding to the b-th feature direction of the target gray-level image. Let be the variance of the values of each element in the g-th column of the gray-level co-occurrence matrix corresponding to the b-th feature direction of the target gray-level image.
[0079] The larger the value, the greater the autocorrelation of the gray-level co-occurrence matrix corresponding to the b-th feature direction of the target gray-level image, and the more texture there is in that feature direction of the image. That is, the greater the probability that this feature direction is the normal texture direction corresponding to the polyurethane foam board under test. Conversely, the smaller the value, the smaller the autocorrelation of the gray-level co-occurrence matrix corresponding to the b-th feature direction of the target gray-level image, and the less texture there is in that feature direction of the image. That is, the smaller the probability that this feature direction is the normal texture direction corresponding to the polyurethane foam board under test. Furthermore, the calculation process of the autocorrelation of the gray-level co-occurrence matrix is a well-known technique, so the specific detailed process will not be described in detail.
[0080] Then, obtain all pixels within the Gaussian filter window corresponding to each pixel, excluding the center pixel, and record them as neighboring pixels within the Gaussian filter window. For any neighboring pixel within the Gaussian filter window corresponding to any pixel: obtain the orientation angle corresponding to the neighboring pixel; based on the orientation angle, obtain the feature direction corresponding to the neighboring pixel, and record the autocorrelation of the gray-level co-occurrence matrix corresponding to the feature direction as the autocorrelation corresponding to the neighboring pixel; then, based on the coordinate values of the neighboring pixels within the Gaussian filter window corresponding to each pixel and the autocorrelation of the neighboring pixels within the Gaussian filter window corresponding to each pixel, obtain the weight value of the neighboring pixels within the Gaussian filter window corresponding to each pixel; for any neighboring pixel within the Gaussian filter window corresponding to any pixel, calculate the weight value of the neighboring pixel within the Gaussian filter window corresponding to the pixel according to the following formula:
[0081]
[0082] in, For the neighboring pixels within the Gaussian filter window corresponding to this pixel. The weight value, This represents the x-coordinate of the neighboring pixels within the Gaussian filter window corresponding to the given pixel. This represents the ordinate value of the neighboring pixels within the Gaussian filter window corresponding to the given pixel. Indicates to Normalization can be achieved using maximum and minimum value normalization methods. This represents the autocorrelation of neighboring pixels within the Gaussian filter window corresponding to the given pixel. Indicates to Normalization can be achieved by using the formula: (autocorrelation + 1) / 2.
[0083] The larger the value, the more pixels in the neighborhood of that pixel within the Gaussian filter window it represents. The larger the weight value, the more it affects the smoothing of the center pixel within the Gaussian filter window corresponding to that pixel, due to the influence of its neighboring pixels. The greater the impact; It can characterize the distance between a neighboring pixel and the center pixel within the corresponding Gaussian filter window, and The larger the value, the more likely it is to be a neighboring pixel. The farther away from the center pixel within the Gaussian filter window corresponding to that pixel, the better. The smaller the value; The larger the value, the greater the autocorrelation of the gray-level co-occurrence matrix in the feature direction corresponding to the neighboring pixel. This indicates a higher probability that the feature direction corresponding to the neighboring pixel is a normal texture direction on the polyurethane foam board under test. In other words, it indicates that the texture features of the neighboring pixel are more similar to those of the center pixel within the corresponding window. For example, both the neighboring pixel and the center pixel may be normal texture edge points. Therefore, when... The larger the value, the lower the weight value of the neighboring pixels should be. The larger, The smaller the value, the greater the representational value of the obtained weight value of the neighboring pixels. This embodiment combines the coordinate values of the neighboring pixels within the window with the autocorrelation of the neighboring pixels, which can avoid the situation where points with similar gray values to the center pixel of the window have a large weight, resulting in an unsatisfactory smoothing effect. That is, by combining the coordinate values of the neighboring pixels within the window with the autocorrelation of the neighboring pixels, the weight value can be set in the subsequent smoothing process to further achieve the purpose of smoothing out the normal texture edges on the polyurethane foam board while preserving the edges of scratch defects.
[0084] Step S004: Based on the Gaussian filter variance value, obtain the initial Gaussian value of each neighboring pixel in the Gaussian filter window corresponding to each pixel; based on the weight value and the initial Gaussian value, obtain the target Gaussian value of each neighboring pixel in the Gaussian filter window corresponding to each pixel.
[0085] In steps S002 and S003 of this embodiment, the Gaussian filter variance value corresponding to the Gaussian filter and the weight value of each neighboring pixel in the Gaussian filter window corresponding to each pixel are obtained respectively. Next, based on the Gaussian filter variance value corresponding to the Gaussian filter, this embodiment obtains the Gaussian function, and then obtains the initial Gaussian value of each neighboring pixel in the Gaussian filter window corresponding to each pixel according to the Gaussian function. The process of obtaining the Gaussian function based on the Gaussian filter variance value corresponding to the Gaussian filter and obtaining the initial Gaussian value based on the Gaussian function is a well-known technique, so it will not be described in detail in this embodiment.
[0086] Then, the initial Gaussian values of the neighboring pixels within the Gaussian filter window corresponding to each pixel are sorted in ascending order of their initial Gaussian values, resulting in a sequence of initial Gaussian values for each pixel. Next, the neighboring pixels within the Gaussian filter window corresponding to each pixel are sorted in ascending order of their weight values, resulting in a sequence of neighboring pixels for each pixel. The number of initial Gaussian values in the initial Gaussian value sequence corresponding to each pixel is equal to the number of neighboring pixels in the corresponding neighboring pixel sequence. For any pixel in the target grayscale image: the m-th initial Gaussian value in the initial Gaussian value sequence corresponding to that pixel is assigned to the pixel's corresponding initial Gaussian value. The m-th neighboring pixel in the neighboring pixel sequence is denoted as the target Gaussian value of the m-th neighboring pixel in the corresponding neighboring pixel sequence, where m is an integer. Thus, the target Gaussian value of each neighboring pixel in the Gaussian filtering window corresponding to each pixel is obtained, realizing the adjustment of the Gaussian value of each neighboring pixel in the Gaussian filtering window. After adjustment, the Gaussian value of the neighboring pixel with a larger weight value is also larger. That is, the Gaussian value of the neighboring pixel in the normal texture direction in the image window is small after adjustment, and the impact on the center pixel is small when smoothing. On the other hand, the Gaussian value of the neighboring pixel in the non-normal texture direction in the window is large, and the impact on the center pixel is large when smoothing.
[0087] Step S005: Based on the target Gaussian value and gray value of each neighboring pixel in the Gaussian filter window corresponding to each pixel, obtain the target grayscale image after Gaussian filtering smoothing; perform edge detection on the target grayscale image after Gaussian filtering smoothing, and record the edge extracted by edge detection as the scratch defect edge on the polyurethane foam board to be tested.
[0088] In this embodiment, step S004 obtains the target Gaussian value of each neighboring pixel within the Gaussian filter window corresponding to each pixel. Then, based on the target Gaussian value and grayscale value of each neighboring pixel within the Gaussian filter window, the center pixel within the Gaussian filter window is smoothed to obtain the smoothed pixel value of the center pixel within the Gaussian filter window. Based on the smoothed pixel value of the center pixel within the Gaussian filter window, the Gaussian-smoothed target grayscale image and the smoothed pixel values of each pixel in the Gaussian-smoothed target grayscale image are obtained. The smoothed pixel value of the center pixel within the Gaussian filter window is the sum of the products of the target Gaussian value and the corresponding grayscale value of each neighboring pixel within the Gaussian filter window. It should be understood that the target Gaussian value of each neighboring pixel within the Gaussian filter window needs to be normalized so that the sum of the target Gaussian values of each neighboring pixel within the Gaussian filter window is 1. This embodiment starts smoothing from the top left corner of the target grayscale image, sliding from left to right and top to bottom with a sliding step size of 1. Gaussian filtering is initiated at each pixel. This completes the smoothing of the target grayscale image. Then, edge detection is performed on the Gaussian-smoothed target grayscale image, and the edges extracted by edge detection are recorded as the scratch defect edges on the polyurethane foam board to be tested. Furthermore, the region corresponding to the scratch defect edges is preserved, while the remaining regions are turned black, thus obtaining the scratch defect region on the polyurethane foam board to be tested, achieving the detection of scratch defects on the polyurethane foam board to be tested.
[0089] It should be understood that if the center pixel is located at the edge and cannot form a complete Gaussian filter window, then when calculating the smoothed pixel value of the center pixel, the portion outside the image in the Gaussian filter window can be excluded from the calculation; only the portion inside the image in the Gaussian filter window is included. The target Gaussian values of each pixel within the Gaussian filter window need to be re-normalized so that the sum of the target Gaussian values of all pixels within the Gaussian filter window is 1. The main purpose of this embodiment is to smooth out the normal texture edges on the polyurethane foam board based on edge detection and adaptive Gaussian filtering, while preserving the edges of scratch defects, thereby improving the accuracy of subsequent scratch defect edge extraction. This embodiment first obtains the Gaussian filter variance value based on the gray-level co-occurrence matrix corresponding to the target gray-level image. The gray-level co-occurrence matrix can reflect the texture information of the image. This embodiment obtains the Gaussian filter variance value based on the texture information of the image. This avoids setting the Gaussian filter variance value too large, which would result in both scratch defect edges and normal texture edges being over-smoothed, failing to achieve the purpose of smoothing out the normal texture edges on the polyurethane foam board while retaining the scratch defect edges. At the same time, it can also avoid setting the Gaussian filter variance value too small, which would lead to ineffective smoothing of normal texture edges. That is, in this embodiment, setting the Gaussian filter variance value based on the gray-level co-occurrence matrix is the basis for subsequently smoothing out the normal texture edges on the polyurethane foam board while retaining the scratch defect edges. Next, this embodiment obtains the weight values of each neighboring pixel within the Gaussian filter window corresponding to each pixel based on the coordinate values and autocorrelation of each neighboring pixel. The autocorrelation reflects the relationship between each neighboring pixel and the normal texture direction within the Gaussian filter window. Referencing the autocorrelation of each neighboring pixel avoids assigning excessive weights to neighboring pixels similar to the center pixel, which could result in a lower smoothness of the center pixel in subsequent windows. The coordinate values of each neighboring pixel reflect the distance between the neighboring pixel and the center pixel within the corresponding window. Closer distances indicate greater importance for the smoothing effect on the center pixel, meaning closer distances correspond to larger weight values. Therefore, this embodiment, based on the weight values of each neighboring pixel within the Gaussian filter window corresponding to a pixel, can further smooth out the normal texture edges on the polyurethane foam board while preserving the scratch defect edges. Finally, this embodiment performs edge detection on the Gaussian-filtered target grayscale image, accurately extracting the scratch defect edges on the polyurethane foam board under test. Thus, this embodiment improves the accuracy of anomaly detection on polyurethane foam boards.
[0090] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for testing non-contact polyurethane foam boards, characterized in that, The method includes the following steps: The surface image of the polyurethane foam board to be tested is acquired and processed to obtain the target grayscale image. Obtain the Gaussian filter window corresponding to each pixel in the target grayscale image; Based on the Gaussian filter window corresponding to each pixel, the gray-level co-occurrence matrix of the target gray-level image is obtained; Based on the gray-level co-occurrence matrix, the Gaussian filter variance value is obtained; Based on the autocorrelation of the gray-level co-occurrence matrix, the autocorrelation of each neighboring pixel within the Gaussian filter window corresponding to each pixel is obtained. Based on the coordinate values and autocorrelation of each neighboring pixel, the weight values of each neighboring pixel within the Gaussian filter window corresponding to each pixel are obtained. Based on the Gaussian filter variance value, the initial Gaussian value of each neighboring pixel in the Gaussian filter window corresponding to each pixel is obtained. Based on the weight value and the initial Gaussian value, the target Gaussian value of each neighboring pixel in the Gaussian filter window corresponding to each pixel is obtained. Based on the target Gaussian value and gray value of each neighboring pixel in the Gaussian filter window corresponding to each pixel, the target grayscale image after Gaussian filtering smoothing is obtained. Edge detection is performed on the target grayscale image after Gaussian filtering and smoothing. The edges extracted by edge detection are recorded as the scratch defect edges on the polyurethane foam board to be tested.
2. The method for detecting non-contact polyurethane foam boards as described in claim 1, characterized in that, A method for acquiring and processing the surface image of the polyurethane foam board under test to obtain a target grayscale image includes... Semantic segmentation is performed on the surface image corresponding to the polyurethane foam board to be tested. The segmented surface image containing the polyurethane foam board is then converted to grayscale, and the grayscale image is recorded as the target grayscale image.
3. The method for testing non-contact polyurethane foam boards as described in claim 1, characterized in that, Methods for obtaining the gray-level co-occurrence matrix of a target gray-level image based on the Gaussian filter window corresponding to each pixel include: Using the center pixel of each Gaussian filter window as the origin, the horizontal direction as the x-axis and the vertical direction as the y-axis, we obtain the coordinate system of the Gaussian filter window corresponding to each pixel and the coordinate values of each pixel in the Gaussian filter window corresponding to each pixel. Based on the ordinate and abscissa values of each pixel within the Gaussian filter window corresponding to each pixel, the orientation angle of each pixel within the Gaussian filter window corresponding to each pixel is obtained. Based on the orientation angle of each pixel within the Gaussian filter window corresponding to each pixel, the types of orientation angles are statistically obtained, and each type of orientation angle is recorded as a feature direction. The gray-level co-occurrence matrix of the target gray-level image in each feature direction is calculated.
4. The method for testing non-contact polyurethane foam boards as described in claim 3, characterized in that, The method for obtaining the orientation angle of each pixel within the Gaussian filter window based on the ordinate and abscissa values of each pixel within the Gaussian filter window includes: Get the pixels within the Gaussian filter window that are not on the coordinate axis of the corresponding coordinate system, and denot them as feature pixels; For any pixel in the target grayscale image, the orientation angle corresponding to each feature pixel within the Gaussian filter window is calculated using the following formula: in, This represents the x-coordinate of the a-th feature pixel within the Gaussian filter window corresponding to that pixel. This represents the ordinate value of the a-th feature pixel within the Gaussian filter window corresponding to that pixel. Let be the orientation angle of the a-th feature pixel within the Gaussian filter window corresponding to the pixel, and arctan2() is the two-parameter arctangent function; The orientation angle of the pixel with an x-coordinate value of 0 and a y-coordinate value of non-0 in each Gaussian filter window is recorded as 90°. The orientation angle of pixels with a vertical coordinate of 0 and a horizontal coordinate of non-0 within each Gaussian filter window is recorded as 0°.
5. The method for detecting non-contact polyurethane foam boards as described in claim 3, characterized in that, The method for obtaining the Gaussian filter variance value based on the gray-level co-occurrence matrix includes: Summing the gray-level co-occurrence matrices corresponding to each feature direction of the target gray-level image, dividing the sum by the number of gray-level co-occurrence matrices corresponding to the target gray-level image, and recording the result as the target gray-level co-occurrence matrix corresponding to the target gray-level image; Calculate the Gaussian filter variance value using the following formula: in, This represents the Gaussian filter variance value corresponding to the Gaussian filter. Let e be the energy value of the target gray-level co-occurrence matrix corresponding to the target gray-level image, and e is a natural constant.
6. The method for detecting non-contact polyurethane foam boards as described in claim 3, characterized in that, A method for obtaining the weight values of each neighboring pixel within a Gaussian filter window based on the coordinate values and autocorrelation of each neighboring pixel includes: Based on the gray-level co-occurrence matrix of the target gray-level image in each feature direction, the autocorrelation of the gray-level co-occurrence matrix of the target gray-level image in each feature direction is obtained; Each pixel in the Gaussian filter window corresponding to each pixel, except for the center pixel, is recorded as the neighboring pixel in the Gaussian filter window corresponding to each pixel. For any pixel, the neighboring pixels within the Gaussian filter window corresponding to any pixel: Based on the orientation angle corresponding to the neighboring pixel, the feature orientation corresponding to the neighboring pixel is obtained, and the autocorrelation of the gray-level co-occurrence matrix corresponding to the feature orientation is recorded as the autocorrelation corresponding to the neighboring pixel.
7. The method for testing non-contact polyurethane foam boards as described in claim 1, characterized in that, For any neighboring pixel within the Gaussian filter window corresponding to any pixel, the weight value of that neighboring pixel within the Gaussian filter window is calculated according to the following formula: in, For the neighboring pixels within the Gaussian filter window corresponding to this pixel. The weight value, This represents the x-coordinate of the neighboring pixels within the Gaussian filter window corresponding to the given pixel. This represents the ordinate value of the neighboring pixels within the Gaussian filter window corresponding to the given pixel. Indicates to Normalization This represents the autocorrelation of neighboring pixels within the Gaussian filter window corresponding to the given pixel. Indicates to Normalization.
8. The method for detecting non-contact polyurethane foam boards as described in claim 1, characterized in that, A method for obtaining the initial Gaussian values of neighboring pixels within the Gaussian filter window corresponding to each pixel based on the Gaussian filter variance value includes: Based on the Gaussian filter variance value corresponding to the Gaussian filter, the Gaussian function is obtained. According to the Gaussian function, the initial Gaussian value of each neighboring pixel in the Gaussian filter window corresponding to each pixel is obtained.
9. The method for detecting non-contact polyurethane foam boards as described in claim 1, characterized in that, A method for obtaining the target Gaussian value of each neighboring pixel within the Gaussian filter window corresponding to each pixel, based on the weight value and the initial Gaussian value, includes: Sort the initial Gaussian values of each neighboring pixel within the Gaussian filter window corresponding to each pixel in ascending order of initial Gaussian values to obtain the sequence of initial Gaussian values corresponding to each pixel. Sort the neighboring pixels in the Gaussian filter window corresponding to each pixel in ascending order of weight value to obtain the sequence of neighboring pixels corresponding to each pixel. For any pixel in the target grayscale image: assign the m-th initial Gaussian value from the initial Gaussian value sequence corresponding to the pixel to the m-th neighboring pixel in the corresponding neighborhood pixel sequence, and record it as the target Gaussian value of the m-th neighboring pixel in the corresponding neighborhood pixel sequence, where m is an integer.
10. The method for detecting non-contact polyurethane foam boards as described in claim 1, characterized in that, A method for obtaining a Gaussian-filtered smoothed target grayscale image based on the target Gaussian value and grayscale value of each neighboring pixel within the Gaussian filter window corresponding to each pixel includes: Based on the target Gaussian value and grayscale value of each neighboring pixel in the Gaussian filter window corresponding to each pixel, the center pixel in the Gaussian filter window corresponding to each pixel is smoothed to obtain the smoothed pixel value of the center pixel in the Gaussian filter window corresponding to each pixel. Based on the smoothed pixel value of the center pixel in the Gaussian filter window corresponding to each pixel, the target grayscale image after Gaussian filtering and the smoothed pixel value of each pixel in the target grayscale image after Gaussian filtering are obtained; the smoothed pixel value of the center pixel in the Gaussian filter window corresponding to each pixel is the sum of the target Gaussian value and the corresponding grayscale value of each neighboring pixel in the Gaussian filter window corresponding to the corresponding pixel.