Stamping part surface quality detection method and system for assembly line detection
By calculating the image noise level and clustering differentiation areas, dynamically setting the local range size, and combining multiple factors to calculate the segmentation threshold, the misjudgment and misjudgment problems of traditional algorithms in stamping surface detection are solved, and detection accuracy and adaptability are improved , realizes accurate evaluation and early warning of the surface quality of the stamped parts.
Patent Information
- Application Number
- CN202411854076.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-01-14
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional local threshold segmentation algorithms are prone to misjudgment or misjudgment in the detection of scratches on stamping parts, resulting in a decrease in the accuracy and reliability of the detection results.
By calculating the noise level of the image, clustering and distinguishing regions, dynamically setting the local range size, and calculating the segmentation threshold in combination with multiple factors to improve the accuracy of scratch detection.
It significantly improves the accuracy of scratch detection, reduces misjudgment and misjudgment, enhances the adaptability and versatility of the algorithm, optimizes the utilization of computing resources, and realizes accurate evaluation and early warning of the surface quality of the stamped parts.
Smart Images

Figure CN119313664A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and more particularly to a stamping part surface quality detection method and system for assembly line detection. Background Art
[0002] In modern manufacturing, stamping is an extremely important processing technology. It mainly relies on presses and molds to apply external forces to various raw materials, such as plates, strips, pipes and profiles, so that these raw materials undergo plastic deformation or separation, and finally obtain stamping parts that meet specific shape and size requirements. In the actual production process, scratches on the surface of stamping parts are a common situation. The causes of these scratches are often closely related to the damage of the raw materials themselves or the abnormal conditions of the stamping equipment during operation. Once there are scratches on the surface of the stamping parts, a series of serious consequences will occur. For example, the structural strength of the scratches will be significantly reduced, making the stamping parts more susceptible to damage when subjected to external forces; at the same time, the corrosion resistance will be greatly reduced, which will significantly shorten the service life of the stamping parts.
[0003] Therefore, in order to ensure the quality and performance of stamping parts, quality inspection of stamping parts has become an indispensable key link in the production process. The method commonly used at present is to first collect the image of the workpiece to be inspected, and then use the local threshold segmentation algorithm to identify the scratches in the image to determine whether there are scratch defects. For example, the Chinese patent application document with the existing publication number CN117169222A discloses a machine vision-based alloy shell surface scratch detection system, including a startup module, an image acquisition module, a wireless transmission module, an image processing module, a main control module, a scratch analysis module, a spatial sharpening filter module, an image segmentation module, etc. The image segmentation module uses the local threshold method to segment the image.
[0004] The traditional local threshold segmentation algorithm used in the above scheme sets a unified local range size for all pixels for threshold calculation. However, when detecting the quality of stamped parts, due to the significant differences in images of different stamped parts, their textures, lighting, scratch distribution and characteristics are different. The fixed local range size is easy to ignore the image differences in different areas. In determining the segmentation threshold, due to the complexity of the stamped part image, it is difficult to determine a threshold standard that can be accurate and universally applicable to all pixels to clearly distinguish scratches from normal areas. These problems lead to misjudgment or omission when identifying scratches on stamped parts, affecting the accuracy and reliability of stamped part quality detection. Summary of the invention
[0005] In order to solve the problem that when performing scratch detection on the surface of stamping parts, the traditional local threshold segmentation algorithm is prone to misjudgment or missed judgment, which reduces the accuracy and reliability of the quality inspection results of stamping parts, the present invention proposes a stamping part surface quality inspection method for assembly line inspection, comprising: Obtain the grayscale histogram of the surface image of the stamping part and calculate the noise level of the surface image : , where is the variance of all frequencies of the grayscale histogram, , are the maximum frequency and the second largest frequency of the grayscale histogram, respectively. is the natural exponential function, is the total frequency of the grayscale histogram; Extracting a characteristic value of each pixel point, clustering all the pixels points into pixels points belonging to the conveyor belt area and pixels points belonging to the stamping part area based on the characteristic value, and setting respective local range sizes for the pixels points in each area according to the noise degree and the gradient characteristics of the pixels points in each area; Get the quantized value of the gradient direction of all pixels in the local range and calculate the segmentation threshold of each pixel , where For the The segmentation threshold of pixels, For the The local range size of pixels, For the The number of pixels within the local range of pixels, For the The local range of the pixel The gray value of a pixel, For the The quantized value of the gradient direction in the local range of the pixel is The number of pixels that are identical to each other. is the hyperbolic tangent function; Image segmentation is performed based on the segmentation threshold of all pixels, and quality inspection of the stamping surface is performed according to the image segmentation results.
[0006] The above technical solution quantifies the noise level of the image by calculating the relevant frequency and variance in the grayscale histogram of the stamping image. The grayscale histogram reflects the frequency of occurrence of different grayscale values in the image. The maximum frequency and the second largest frequency can reflect the concentration of the grayscale value distribution in the image. The variance reflects the discreteness of the grayscale value. It can judge the noise situation from the overall characteristics of the image, which is helpful for adjusting the processing strategy according to the noise level in the future, and provides a basis for more accurate detection of scratches. Then, the pixel points are classified through the clustering algorithm to accurately distinguish different areas, which can avoid the interference of the noise in the conveyor belt area on the detection of stamping scratches. Different local range sizes are set for different areas to better adapt to the image characteristics of different areas. Next, the gradient direction of the pixels in the local range is quantified, and then the segmentation threshold is calculated according to the number of pixels with the same quantization value, the gray value of the pixels and the size of the local range. The gradient direction quantization helps to analyze the edge features of the image. The number of pixels with the same quantization value can reflect the correlation between the pixel and the scratch edge. By comprehensively considering multiple factors to calculate the segmentation threshold, the scratch can be distinguished from the normal area more accurately. When the number of pixels with the same gradient direction as a certain pixel in the local range is large, the pixel is more likely to be in the scratch. The formula calculation will make the threshold corresponding to the pixel more conducive to segmenting it, thereby improving the accuracy of scratch detection and reducing misjudgment and missed judgment. Next, the image is segmented using the segmentation threshold of each pixel calculated previously, and the image is divided into different areas. The surface quality of the stamping part is judged based on the image characteristics after segmentation, which can accurately separate the scratch area from the normal area in the image. By judging the ratio of the number of pixels in the abnormal area to the total number of pixels in the segmentation result, it can effectively detect whether there are defects such as scratches on the surface of the stamping part, and realize accurate evaluation of the surface quality of the stamping part.
[0007] Preferably, another calculation method of the segmentation threshold of each pixel is:
[0008] In the formula, For the The segmentation threshold of pixels, For the The local range size of pixels, For the The number of pixels within the local range of pixels, For the The local range of the pixel The gray value of a pixel, For the The quantized value of the gradient direction in the local range of the pixel is The number of pixels that are identical to each other. is the hyperbolic tangent function, For the A pixel point and its local range The Euclidean distance between pixels.
[0009] The above technical solution introduces the Euclidean distance between a pixel and other pixels in its local range. It not only pays attention to the attributes of the pixel itself (such as grayscale value) and the statistical characteristics in the local range (such as the number of pixels with the same quantized value in the gradient direction), but also considers the relative position relationship between the pixel and other pixels in space. This enables the calculation of the segmentation threshold to better adapt to the complex spatial structure of different areas in the image.
[0010] Preferably, the method of setting the local range size for the pixels in each area is: Set the local range size of the pixels belonging to the stamping area to: , if the overall value of the formula is an even number, it will increase by 1 to become an odd number; Set the local range size of the pixels belonging to the conveyor belt area to: , if the overall value of the formula is an even number, it will increase by 1 to become an odd number; in, is the noise level of the surface image, is the preset basic size, and are the average gradient values of all pixels belonging to the stamping area and the average gradient values of all pixels belonging to the conveyor belt area, respectively. is the gradient value of the pixel, is the round-up symbol, is a natural exponential function.
[0011] The above technical solution comprehensively considers the noise level of the image, the average gradient value of different regions, and the gradient value of a single pixel when determining the size of the local range. The noise level reflects the overall noise condition of the image, affecting the size of the local range that should be set to avoid noise interference. The average gradient value of the region reflects the texture complexity of different regions and other characteristics. For the stamping area, its texture complexity affects the difficulty of scratch detection. For the conveyor belt area, its texture changes may be related to wear and other conditions. The gradient value of a single pixel is further refined to the local characteristics of each pixel, which helps to adjust the local range more accurately.
[0012] Preferably, the method for performing image segmentation based on the segmentation threshold of all pixels is: First, a single-channel image with the same size as the surface image of the stamping is constructed. In the initial state, the pixel values of all pixels in the single-channel image are set to 0. The single-channel image will be used as the final segmentation result image. Then, for each pixel in the surface image of the stamping, a judgment is made one by one: if the grayscale value of a pixel exceeds the segmentation threshold of the pixel, the pixel value of the pixel corresponding to the position of the pixel is assigned to 1 in the final segmentation result image.
[0013] The above technical solution constructs a single-channel image with the same size as the original stamping part image and an initial pixel value of 0 as the segmentation result image, which provides a standardized carrier for the subsequent accurate recording and presentation of the segmentation results. For each pixel point in the grayscale image of the stamping part, binary segmentation is performed according to its own segmentation threshold, which can effectively extract the area suspected of scratches in the image, providing key information for accurately detecting scratches on the surface of the stamping part.
[0014] Preferably, the method for extracting the feature value of each pixel is: Count the average grayscale value of all pixels in the row where each pixel is located , the average gray value of all pixels in the column where the pixel is located ,Will and The minimum value of is taken as the feature value of the pixel.
[0015] The above technical solution considers the grayscale distribution of pixels in the horizontal and vertical directions by counting the average grayscale values of the rows and columns where the pixels are located. This comprehensive consideration can obtain the general trend of the grayscale values around the pixels, avoiding the one-sidedness caused by using only a single direction information, and thus more comprehensively describing the local grayscale environment of the pixels.
[0016] Preferably, the clustering adopts K-means clustering algorithm, and K is set to 2, where K is the number of clusters generated after clustering.
[0017] Preferably, the method for obtaining the quantized value of the gradient direction of all pixels is: Divide the angle corresponding to the gradient direction of each pixel by The obtained value is rounded to get the quantized value of the gradient direction of the pixel. The preset angle value.
[0018] The above technical solution quantifies the gradient direction of pixel points so that the gradient direction information of different pixel points can be processed and compared with a unified standard in the process of calculating the segmentation threshold, which helps to find areas with similar gradient direction characteristics in the image and improves the efficiency of the detection method.
[0019] Preferably, the local range of each pixel is determined based on the local range size of the pixel, the local range is a rectangle, and the local range size is the side length of the local range.
[0020] Preferably, the method of dividing all pixel points into pixel points belonging to the conveyor belt area and pixel points belonging to the stamping part area is: All pixels are divided into two categories by clustering, and the average grayscale value of these two categories of pixels is calculated. The area composed of the pixel points with the lowest average grayscale value is taken as the conveyor belt area, and this type of pixel points belongs to the conveyor belt area. The area composed of the pixel points with the highest average grayscale value is taken as the stamping part area, and this type of pixel points belongs to the stamping part area.
[0021] The method for quality inspection of stamping surface based on image segmentation results is: When the ratio of the number of pixels with a pixel value of 1 in the final segmentation result image to the total number of pixels in the surface image of the stamping part exceeds a preset ratio, it is determined that scratches exist in the surface image of the stamping part; Furthermore, when continuous detection When there are scratches on the surface images of all stamping parts, an early warning notification is issued. The preset quantity.
[0022] The present invention also provides a stamping part surface quality inspection system for assembly line inspection, the quality inspection system comprising a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement any step of the quality inspection method.
[0023] The present invention has the following effects: The present invention effectively solves many defects of the traditional local threshold segmentation algorithm in the detection of scratches on the surface of stamping parts through a series of innovative measures. By calculating the degree of image noise and adjusting the processing strategy accordingly, clustering and distinguishing regions and dynamically setting the local range size, and comprehensively calculating the segmentation threshold based on multiple factors, these measures have greatly improved the accuracy of scratch detection and effectively reduced misjudgments and missed judgments. At the same time, its ability to dynamically adjust according to image features enhances the adaptability and versatility of the algorithm and optimizes the use of computing resources. In addition, constructing a unified segmentation result image for quality assessment and setting an early warning mechanism for continuous scratch detection can not only accurately judge the surface quality of stamping parts, but also promptly discover production problems and issue early warnings, avoid producing more defective products, and ensure the quality and efficiency of stamping production. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein: Figure 1 It is a schematic flow chart of the method of the present invention. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0026] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0027] Reference Figure 1 The present invention provides a method for detecting the surface quality of stamping parts for assembly line detection, comprising the steps of: -step : : Get the grayscale histogram of the surface image of the stamping part and calculate the noise level of the surface image.
[0028] On the production line of stamping parts, the stamping parts are transported by conveyor belts after forming. During this process, the surface quality of the stamping parts needs to be inspected. In this step, an image acquisition device is arranged above the conveyor belt of the stamping parts. The image acquisition device can acquire images facing the surface of the stamping parts. When the stamping parts run to this position with the conveyor belt, the image acquisition device starts to acquire the surface image of the stamping parts. The acquisition frequency is one picture per second. This step is the starting point of the entire stamping parts surface quality inspection process. The quality of the acquired surface image will directly affect the subsequent inspection results.
[0029] Taking into account that the image acquisition equipment is affected by its own performance and working environment, a certain amount of noise will inevitably be introduced in the process of image acquisition, and the noise will interfere with the performance of scratches on stamping parts in the image. The difficulty of scratch feature extraction varies under different noise levels. In order to improve the accuracy of scratch detection, it is necessary to quantitatively evaluate the image noise level, thereby providing a basis for adjusting the processing strategy according to the noise situation in the future.
[0030] First, the collected surface images of stamping parts are converted into grayscale images. Grayscale images can simplify image information, highlight brightness differences, and facilitate subsequent analysis of image features.
[0031] Next, obtain the grayscale histogram of the surface image (grayscale image). The grayscale histogram uses the horizontal axis to represent the grayscale value and the vertical axis to represent the frequency, that is, the number of pixels corresponding to each grayscale value. It intuitively shows the distribution of grayscale values in the image.
[0032] Finally, the noise level of the surface image is calculated based on the frequency in the grayscale histogram:
[0033] In the formula, is the noise level of the surface image, is the variance of all frequencies of the grayscale histogram. The variance is used to measure the degree of discreteness of the data. is the maximum frequency of the grayscale histogram, that is, the frequency (number of pixels) corresponding to the grayscale value that appears most times in the image. is the second largest frequency of the grayscale histogram, is the natural exponential function, is the total frequency of the grayscale histogram, that is, the total number of pixels in the surface image.
[0034] In this formula, It is the proportion of the pixel points corresponding to the most frequent grayscale value in the image in the entire image. When this ratio is large, it means that there is one or several main grayscale values in the image that dominate. In the stamping part image, these main grayscale values usually correspond to the characteristics of the stamping part itself (such as the color and brightness of a specific material) or the color and brightness of the conveyor belt. For example, if the stamping part is a metal material with a relatively single color and a large proportion, it may show a dominant grayscale value in the image, and the conveyor belt may also have its fixed grayscale characteristics. In this case, the grayscale distribution of the image is relatively concentrated near the grayscale values of these main features, and the noise usually appears as a random change in the grayscale value, and it is relatively rare to have the same grayscale value as the main feature, so the noise in the image is relatively small, and the noise level of the stamping part image is also smaller. On the contrary, when the value of this ratio is small, it means that there is no obvious dominant grayscale value in the image, and the grayscale value distribution is relatively dispersed. In the image composed of stamping parts and conveyor belts, under normal circumstances, features such as color and brightness are relatively stable, and there are no complex color changes (such as color patterns, etc.). Therefore, this scattered gray value distribution is most likely caused by the noise introduced during the image acquisition process. Therefore, the noise level of the stamping part image is relatively high at this time.
[0035] In this formula, It also indicates the proportion of pixels with more frequent gray values in the entire image. Its principle is the same as Similarly, when this ratio is large, it also reflects to a certain extent that there are relatively more pixels in the image with similar grayscale values (second only to the most frequent grayscale value), which also tends to indicate that the grayscale distribution of the image is not dominated by noise, but has certain characteristics, so the noise level is relatively small; on the contrary, when the ratio is small, it further supports the view that the scattered grayscale distribution of the image may be caused by noise, and the noise level is large. However, the weight of the influence on the judgment of the noise level may be relatively small, but it is also one of the important bases for comprehensive judgment of the noise level.
[0036] In this formula, Represents the size relationship of the variance of all frequencies relative to the maximum frequency. When this value is large, it indicates that the differences between the frequencies in the grayscale histogram are significant, that is, the gap between the frequencies is large. For stamping parts images, this means that the grayscale value distribution of pixels in the image has a strong regularity. Usually, this regularity is reflected in the fact that the grayscale values tend to be concentrated near the grayscale values corresponding to the color of the stamping parts themselves and the grayscale values corresponding to the color of the conveyor belt. Because in the image, stamping parts and conveyor belts are the main components, and their color and brightness characteristics are relatively stable, so when the grayscale values are concentrated on the grayscale values corresponding to these features, the noise in the image (manifested as random grayscale value changes) is relatively small, and the noise level of the stamping parts image is also smaller. When the value is smaller, it means that the variance of all frequencies is relatively small. Small variance means that the frequencies in the grayscale histogram are relatively close and the gap between frequencies is small, which reflects that the grayscale value distribution of pixels in the image is relatively uniform, without obvious centralization trend, and presents a dispersed distribution. In an image composed only of stamping parts and conveyor belts, its color and grayscale value should have certain characteristics and concentration under normal circumstances. This dispersed grayscale value distribution is most likely caused by the presence of more noise points that do not belong to the inherent color and brightness of stamping parts and conveyor belts. Therefore, there may be more noise in the image at this time, and the noise level of the stamping part image is also greater.
[0037] In summary, this plan has the following significance: Multi-angle image feature analysis: By calculating the maximum frequency, the second largest frequency and the variance of all frequencies in the grayscale histogram, the distribution of grayscale values in the image is fully considered. The maximum frequency and the second largest frequency reflect the concentration of the main grayscale values in the image, while the variance reflects the discreteness of the grayscale value distribution, describing the characteristics of the image from different angles.
[0038] Analyze noise based on image composition: Considering that stamping parts images are mainly composed of stamping parts and conveyor belts, their color and brightness characteristics are relatively stable, and the difference between these characteristics and noise is used to judge the degree of noise. By combining the various terms in the formula, the gray value distribution characteristics of the image are compared with the random characteristics of the noise, thereby achieving a quantitative evaluation of the degree of noise.
[0039] Multi-factor fusion decision-making: , and These three factors are combined through multiplication and exponential functions, making the impact of each factor on the noise level interrelated and nonlinear. This fusion method can more carefully reflect the complex characteristics of the image and avoid the one-sidedness of a single factor judgment.
[0040] Accurately evaluate the noise level: The noise level can be accurately calculated based on the actual grayscale value distribution of the image. Whether the grayscale values in the image are concentrated near the characteristic grayscale values of the stamping parts and the conveyor belt (low noise) or the grayscale values are dispersed (high noise), the formula can be used to obtain a reasonable quantitative result of the noise level, providing a reliable basis for adjusting the processing strategy according to the noise situation in the future.
[0041] : Clustering is performed based on the feature value of each pixel, and all pixels are divided into pixels belonging to the conveyor belt area and pixels belonging to the stamping part area.
[0042] In the scratch detection on the surface of stamped parts, the conveyor belt area of the surface image itself does not contain valid information related to the scratches on the stamped parts surface. However, the conventional image segmentation method is often unable to accurately distinguish the conveyor belt area and the stamped parts area due to its lack of specificity during processing. It is easy to segment the noise points in the conveyor belt area as valid information. These noise points may be caused by the wear and stains of the conveyor belt itself or interference in the image acquisition process. They appear in the image as abnormal grayscale values or features similar to scratches, which will interfere with the accurate identification of the real scratches on the stamped parts surface and reduce the accuracy of scratch detection.
[0043] Therefore, in response to the above problems, this step adopts the following methods: First extract the feature value of each pixel: For any pixel in the surface image of the stamping part, the average grayscale value of all pixels in the row where the pixel is located is counted , and the average grayscale value of all pixels in the column where the pixel is located ,Will and The minimum value of is taken as the feature value of the pixel.
[0044] By counting the average grayscale value of the row and column where the pixel is located, the grayscale distribution around the pixel can be obtained from both the horizontal and vertical directions. The grayscale value information in a single direction may not fully reflect the local environmental characteristics of the pixel, and considering the information of both rows and columns can provide a more comprehensive understanding of the grayscale trend around the pixel. For example, in a stamping image, a scratch may have a specific grayscale change feature in a certain direction, and the combined information of rows and columns can help capture this feature.
[0045] by and The minimum value of is used as the eigenvalue to provide an effective basis for subsequent clustering to distinguish the conveyor belt area and the stamping part area. Usually, there may be differences in grayscale values between the conveyor belt area and the stamping part area. The eigenvalue obtained through this comprehensive calculation can better reflect this difference. For example, the conveyor belt may appear as a relatively dark area (low grayscale value) in the image, and the average grayscale values of its rows and columns may have certain characteristics. By taking the minimum value as the eigenvalue, the expression of this regional feature can be enhanced, making it easier for the clustering algorithm to accurately classify the pixels into the corresponding area.
[0046] Then, based on the feature values of all pixels, Clustering, and setting is 2. After clustering, all pixels are divided into two categories. The average grayscale value of these two categories of pixels is calculated. The area composed of the pixel points with the lowest average grayscale value is taken as the conveyor belt area. This type of pixel points belongs to the conveyor belt area. The area composed of the pixel points with the highest average grayscale value is taken as the stamping part area. This type of pixel points belongs to the stamping part area.
[0047] In the image of the stamped parts, the stamped parts themselves usually have different materials, colors or surface characteristics from the conveyor belts, and these differences will be reflected in the grayscale values of the image. Generally speaking, the material and surface treatment of the stamped parts may cause them to present relatively high grayscale values in the image. For example, if the stamped parts are made of metal and the surface is treated in a certain way, they may reflect more light, thus appearing as brighter areas in the image, corresponding to higher grayscale values. The material and color of the conveyor belt are often relatively dark, such as the common black rubber conveyor belt, which has a relatively low grayscale value in the image. Through the K-means clustering algorithm, all pixels are divided into two categories according to the feature values of the pixels (determined by the minimum value of the average grayscale value of the row where the pixel is located and the average grayscale value of the column where the pixel is located). Ideally, due to the inherent differences in grayscale values between stamped parts and conveyor belts, the clustering algorithm will cluster pixels with similar grayscale characteristics together. When calculating the average grayscale value of the two types of pixels, the one with a higher average grayscale value is more likely to correspond to the stamping area, because the grayscale values of the pixels in the stamping area are generally higher; while the one with a lower average grayscale value is more likely to be the conveyor belt area, because the grayscale values of the pixels in the conveyor belt area are relatively low. This classification method can effectively distinguish the conveyor belt area and the stamping area in the image, providing an accurate basis for subsequent processing of different areas (such as setting different local range sizes, performing scratch detection, etc.).
[0048] : Set different local range sizes for pixels belonging to the conveyor belt area and pixels belonging to the stamping part area.
[0049] When using the local threshold segmentation algorithm to detect scratches on stamping parts, the degree of noise has a key influence on the selection of the local range size. When the noise level is large, it means that there are many noise pixels in the image. At this time, in order to prevent the noise pixels from being mis-segmented, a larger local range should be used for segmentation. Because a larger local range can integrate more pixel information, thereby reducing the interference of noise on the segmentation results. On the contrary, when the noise level is small and the image noise is less, in order to more accurately segment the scratches on the stamping parts, a smaller local range should be used. A smaller local range can more finely capture the difference between the scratches and the surrounding normal areas, thereby improving the accuracy of scratch detection.
[0050] Next, according to the noise level of the surface image of the stamping part and the gradient characteristics of the pixel points in each area (stamping part area and conveyor belt area), the local range size is set for the pixel points in each area, including: For any pixel point belonging to the stamping area, the local range size of the pixel point is set to:
[0051] In this formula, It is the preset basic size, and the experience value is 5. is the noise level of the surface image of the stamping part, is the gradient value of the pixel, is the natural exponential function, is the average gradient value of all pixels belonging to the stamping area, The symbol for rounding up is: if the overall value of the formula is an even number, it is incremented by 1 to become an odd number, and the odd number is used as the local range size of the pixel.
[0052] For the pixels in the stamping area, The value of reflects the complexity of the texture change in the stamping area. If the value is large, it means that the texture is complex. In this case, in order to avoid smoothing out the scratches and causing missed detection, a smaller local range should be used for local threshold segmentation. This is because a smaller local range can focus on a finer area around the pixel point and retain the detailed features of the scratch. On the contrary, if Smaller means simple texture. In this case, to prevent noise points from being misjudged as scratches, a larger local range should be used. A larger local range can use the surrounding pixel information to filter out noise interference. At the same time, for a single pixel, The larger the value of , the more likely the pixel is in the scratch area of the stamping part. In order to accurately segment the scratches, a smaller local range should be used. The smaller the value, the larger the local range should be used to smooth out local image fluctuations and avoid mistaking noise for scratches.
[0053] For any pixel that belongs to the conveyor belt area, the local range size of the pixel is set to:
[0054] In this formula, is the average gradient value of all pixels belonging to the conveyor belt area. The meanings of the remaining characters are the same as above. If the overall value of the formula is an even number, it is incremented by 1 to become an odd number, and the odd number is used as the local range size of the pixel.
[0055] For the pixels in the conveyor belt area, The larger the value, the more likely the pixel is to be in the worn area of the conveyor belt. To prevent the wear on the conveyor belt from interfering with the identification of scratches on the surface of the stamping, a larger local range should be used for local threshold segmentation to prevent the scratches on the conveyor belt from being mistakenly included in the quality inspection scope of the stamping. The smaller the size, the less need to expand the local area. It reflects the complexity of the texture change in the conveyor belt area. The larger the value, the more complex the texture. To avoid mistakenly segmenting the scratches on the conveyor belt and interfering with the scratch detection of stamping parts, a larger local range should be used. The smaller it is, the simpler the texture of the conveyor belt area is, and there is no need to expand the local area too much. right To make corrections, and its index The values of are all in the range of 0 to 1, It partially conforms to the characteristics of the gamma transform, that is, when the base and the exponent are both in the range of 0 to 1, the smaller the exponent, the larger the overall value. For example, 0.5 to the power of 0.2 is 0.87, which is 0.37 larger than 0.5, and 0.5 to the power of 0.3 is 0.81. The larger the exponent, the smaller the degree of expansion. Part, when The bigger the The smaller, the The greater the expansion, the larger the local range of the pixel. The more hours, The bigger it is, The smaller the expansion degree, the smaller the local range of the pixel point will be.
[0056] According to the above method, the local range size of each pixel can be calculated. The local range of each pixel is a rectangular area with the local range size of the pixel as the side length. This calculation method in this step can reasonably determine the local range size of each pixel according to the characteristics of different areas of the image and the noise situation, thereby providing a more accurate and reliable basis for subsequent image segmentation.
[0057] : Get the quantized value of the gradient direction of all pixels in the local range and calculate the segmentation threshold of each pixel.
[0058] For any pixel, the angle corresponding to the gradient direction of each pixel in its local range is divided by the value of A and rounded to get the quantized value of the gradient direction of the pixel. Here, the empirical value of A is 45 degrees. The gradient direction can be detected by the Sobel operator. According to this quantization method, the quantized value of the gradient direction of all pixels in its local range is obtained. This quantization method converts continuous gradient direction angle values into discrete quantized values. For example, the original gradient direction angle may have continuous values between 0 and 360 degrees. After this quantization, there may be only 8 discrete values. This greatly simplifies the representation of data and reduces the complexity of data.
[0059] Next, two calculation methods are provided to determine the segmentation threshold of the pixel points, as follows: The first way to calculate the segmentation threshold for each pixel is:
[0060] In the formula, For the The segmentation threshold of pixels, For the The local range size of pixels, Indicates The number of pixels within the local range of pixels, For the The local range of the pixel The gray value of a pixel, For the The quantized value of the gradient direction in the local range of the pixel is The number of pixels that are identical to each other. is the hyperbolic tangent function.
[0061] In this formula, Reflects the The local range of pixels The relative value of the number of pixels with the same quantized value of the gradient direction of the pixels. Since the local range sizes of different pixels may be different, if we directly use Calculate, then the pixel with large local range corresponds to will be larger simply because the total number of pixels in its local range is large, which will lead to deviations when comparing the features of different pixels. Divide by , you can Converted to relative values, so that no matter how large the local range is, can reflect the local and the first The density of pixels with the same gradient direction in the local area. For example, in a smaller local area and a larger local area, if the same proportion of pixels have the same gradient direction, then their They should be similar, so that the segmentation threshold can be calculated more accurately based on the gradient direction characteristics of the pixel points.
[0062] Generally speaking, when there is an edge in a local area of an image, the pixels corresponding to the edge will have similar directions, while the gradients of pixels outside the edge are random. Therefore, the larger the relative value, the closer the local area is to the first pixel. The more pixels have similar gradient directions, the more The more pixels there are, the more likely they are to be at the scratch of the stamping. In order to accurately segment the scratches during threshold segmentation, the local range The pixel point should occupy a larger proportion in the threshold calculation. On the contrary, the smaller the relative value is, the smaller the pixel point is in the local range. The fewer pixels have similar gradient directions, the smaller the gradient direction of the pixels is. The more likely a pixel is to be outside the area of the stamping scratch, the smaller its weight in the threshold calculation should be.
[0063] Therefore, using To regulate the influence of the gray value of each pixel in the local range on the segmentation threshold. When larger, The smaller it is, and the more likely it is to be less than 1, then the formula is The more significant the expansion effect is, the The local range of the pixel The gray value of the pixel is The threshold influence of each pixel increases. When smaller, The larger it is, the more likely it is to be greater than 1. In this case, the formula The more obvious the reduction effect is, the more The local range of the pixel The gray value of the pixel is The effect of the threshold value of pixels is reduced.
[0064] In this formula, The parameters 0.5 and 1 in are to reasonably adjust The value range of It can play a role of expansion and reduction, so as to accurately calculate the segmentation threshold of each pixel according to the gradient direction characteristics of the pixel and the local range, providing a reasonable basis for subsequent image segmentation.
[0065] Another way to calculate the segmentation threshold for each pixel is:
[0066] In the formula, For the The segmentation threshold of pixels, For the The local range size of pixels, Indicates The number of pixels within the local range of pixels, For the The local range of the pixel The gray value of a pixel, For the The quantized value of the gradient direction in the local range of the pixel is The number of pixels that are identical to each other. is the hyperbolic tangent function, For the A pixel point and its local range The Euclidean distance between pixels.
[0067] In this formula, When it is smaller, it means that the Pixels and The pixels are closer in space. From the perspective of image features, pixels with similar distances tend to have higher similarity and are more likely to have the same properties, such as gray value change trends and texture features. When the segmentation threshold of pixels is 1, the closer The information provided by each pixel has a higher reference value, and its influence on the calculation results of the segmentation threshold should also increase accordingly.
[0068] In this formula, Indicates A pixel point and its local range The relative value of the Euclidean distance between pixels. The smaller the value, the closer the local range is. The pixel point in the image The closer the pixels are, the more likely they are to have the same properties. The pixel point is compared with the The segmentation threshold of pixels has a higher reference value, so the local range of The pixel pair in the image The calculation of the pixel threshold should have a greater proportion; the larger the value, the more The pixel point in the image The farther apart the pixels are, the more likely they are to have different properties. The pixel point is compared with the The lower the reference value of the segmentation threshold of pixels, the lower the The pixel pair in the image The calculation of the pixel threshold should have a smaller proportion, and the formula Multiplying by 2 is to control The pixel segmentation threshold can be adjusted to any value greater than 1.
[0069] : Image segmentation is performed based on the segmentation threshold of all pixels, and the quality of the stamping surface is inspected according to the image segmentation results.
[0070] The method for image segmentation based on the segmentation threshold of all pixels is: First, a single-channel image with the same size as the surface image of the stamping is constructed. In the initial state, the pixel values of all pixels in the single-channel image are set to 0. The single-channel image will be used as the final segmentation result image. Then, for each pixel in the surface image of the stamping, a judgment is made one by one: if the grayscale value of a pixel exceeds the segmentation threshold of the pixel, the pixel value of the pixel corresponding to the position of the pixel is assigned to 1 in the final segmentation result image.
[0071] This segmentation method performs image segmentation based on the segmentation threshold calculated for each pixel, taking into account the characteristics of different pixels in the image. For images such as stamping parts that may have complex textures and local changes, it can more accurately capture the characteristics of different areas. For example, in areas with scratches or wear on the surface of stamping parts, the grayscale values of the pixels may be different from those in the surrounding normal areas. By judging the threshold for each pixel, these defective areas can be better segmented. The final result is a single-channel image with only pixel values of 0 and 1. This binary result image is very intuitive and convenient for subsequent quality inspection and analysis. In quality inspection, staff can easily judge whether there are defects on the surface of stamping parts, as well as the location and range of defects by observing the distribution of pixel values 1 in the segmentation result image.
[0072] Finally, the method for quality inspection of stamping surface based on image segmentation results is: When the ratio of the number of pixels with a pixel value of 1 in the final segmentation result image to the total number of pixels in the surface image of the stamping part exceeds a preset number ratio, it is determined that scratches exist in the surface image of the stamping part. Here, the preset number ratio is 0.01, which is an empirical value.
[0073] When continuous detection When there are scratches on the surface images of all stamping parts, an early warning notification is issued. is the preset quantity, It is the default value, and the experience value is 10.
[0074] By setting a warning notification when scratches are detected on the surface of 10 stamping parts in succession, it is possible to avoid misjudgment of scratches on a single stamping part. This continuous detection mechanism can more accurately reflect the overall quality of stamping parts on the production line and help to promptly discover systemic problems in the production process, such as wear of stamping dies or deviations in stamping process parameters.
[0075] The present invention also provides a stamping part surface quality inspection system for assembly line inspection, the quality inspection system comprising a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the quality inspection method.
[0076] In the description of this specification, "multiple" or "several" means at least two, such as two, three or more, etc., unless otherwise clearly and specifically defined.
[0077] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.
Claims
1. A stamping parts surface quality detection method for assembly line detection, characterized in that: include: Obtain the grayscale histogram of the surface image of the stamping part and calculate the noise level of the surface image : , where is the variance of all frequencies of the grayscale histogram, , are the maximum frequency and the second largest frequency of the grayscale histogram, respectively. is the natural exponential function, is the total frequency of the grayscale histogram; Extracting a characteristic value of each pixel point, clustering all the pixels points into pixels points belonging to the conveyor belt area and pixels points belonging to the stamping part area based on the characteristic value, and setting respective local range sizes for the pixels points in each area according to the noise degree and the gradient characteristics of the pixels points in each area; Get the quantized value of the gradient direction of all pixels in the local range and calculate the segmentation threshold of each pixel , where For the The segmentation threshold of pixels, For the The local range size of pixels, For the The number of pixels within the local range of pixels, For the The local range of the pixel The gray value of a pixel, For the The quantized value of the gradient direction in the local range of the pixel is The number of pixels that are identical to each other. is the hyperbolic tangent function; Image segmentation is performed based on the segmentation threshold of all pixels, and quality inspection of the stamping surface is performed according to the image segmentation results.
2. The stamping parts surface quality detection method for assembly line detection according to claim 1 is characterized in that: Another way to calculate the segmentation threshold for each pixel is: ; In the formula, For the The segmentation threshold of pixels, For the The local range size of pixels, For the The number of pixels within the local range of pixels, For the The local range of the pixel The gray value of a pixel, For the The quantized value of the gradient direction in the local range of the pixel is The number of pixels that are identical to each other. is the hyperbolic tangent function, For the A pixel point and its local range The Euclidean distance between pixels.
3. The stamping parts surface quality detection method for assembly line detection according to claim 1 is characterized in that: The method to set the local range size for the pixels in each area is: Set the local range size of the pixels belonging to the stamping area to: , if the overall value of the formula is an even number, it will increase by 1 to become an odd number; Set the local range size of the pixels belonging to the conveyor belt area to: , if the overall value of the formula is an even number, it will increase by 1 to become an odd number; in, is the noise level of the surface image, is the preset basic size, and are the average gradient values of all pixels belonging to the stamping area and the average gradient values of all pixels belonging to the conveyor belt area, respectively. is the gradient value of the pixel, is the round-up symbol, is a natural exponential function.
4. The stamping parts surface quality detection method for assembly line detection according to claim 1 is characterized in that: The method for image segmentation based on the segmentation threshold of all pixels is: First, a single-channel image with the same size as the surface image of the stamping is constructed. In the initial state, the pixel values of all pixels in the single-channel image are set to 0. The single-channel image will be used as the final segmentation result image. Then, for each pixel in the surface image of the stamping, a judgment is made one by one: if the grayscale value of a pixel exceeds the segmentation threshold of the pixel, the pixel value of the pixel corresponding to the position of the pixel is assigned to 1 in the final segmentation result image.
5. The stamping parts surface quality detection method for assembly line detection according to claim 1, characterized in that: The method for extracting the feature value of each pixel is: Count the average grayscale value of all pixels in the row where each pixel is located , the average gray value of all pixels in the column where the pixel is located ,Will and The minimum value of is taken as the feature value of the pixel.
6. The stamping parts surface quality inspection method for assembly line inspection according to claim 1 is characterized in that: The clustering adopts Clustering algorithm, and set is 2, is the number of clusters generated after clustering.
7. The stamping parts surface quality inspection method for assembly line inspection according to claim 1 is characterized in that: The method for obtaining the quantized value of the gradient direction of all pixels is: Divide the angle corresponding to the gradient direction of each pixel by The obtained value is rounded to get the quantized value of the gradient direction of the pixel. The preset angle value.
8. The stamping parts surface quality inspection method for assembly line inspection according to claim 3 is characterized in that: The method of dividing all pixels into pixels belonging to the conveyor belt area and pixels belonging to the stamping part area is: All pixels are divided into two categories by clustering, and the average grayscale value of these two categories of pixels is calculated. The area composed of the pixel points with the lowest average grayscale value is taken as the conveyor belt area, and this type of pixel points belongs to the conveyor belt area. The area composed of the pixel points with the highest average grayscale value is taken as the stamping part area, and this type of pixel points belongs to the stamping part area.
9. The stamping parts surface quality inspection method for assembly line inspection according to claim 4, characterized in that: The method for quality inspection of stamping surface based on image segmentation results is: When the ratio of the number of pixels with a pixel value of 1 in the final segmentation result image to the total number of pixels in the surface image of the stamping part exceeds a preset ratio, it is determined that scratches exist in the surface image of the stamping part; Furthermore, when continuous detection When there are scratches on the surface images of all stamping parts, an early warning notification is issued. The preset quantity.
10. A stamping parts surface quality inspection system for assembly line inspection, characterized in that: The quality inspection system comprises a memory and a processor, wherein a computer program is stored in the memory, and the processor executes the computer program to implement the steps of the quality inspection method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Alloy shell surface scratch detection system based on machine vision
CN117169222A
Local threshold segmentation method and defect detection method
CN111062910A
Scratch detection method and device for electronic component and computer equipment
CN113781406A
Fiberboard quality classification method based on machine vision
CN114445387A
Production quality detection method suitable for chip circuit board
CN114926463A
Cited By
Stamping forming quality detection method for stamping part
CN120747056A