A method for automatically detecting the production quality of injection molds
By performing threshold iterative segmentation and adaptive threshold adjustment on the injection mold surface image, the problem of low flow mark detection accuracy caused by inaccurate image segmentation is solved, and the accuracy of injection molding mold production quality detection is significantly improved.
Patent Information
- Application Number
- CN202410946678.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-16
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-07-16
AI Technical Summary
In the existing technology, due to inaccurate image segmentation in the production of injection molds, the accuracy of flow mark defect detection is low, which further reduces the accuracy of quality inspection of injection mold production.
Through threshold iterative segmentation of the surface image of the injection molded product, the degree and possibility of changes in the gray value of the suspected defect area are analyzed, and the segmentation threshold is adaptively adjusted to ensure complete segmentation of the flow mark area.
The accuracy of flow mark defect detection is improved, thereby improving the accuracy of injection molding mold production quality detection.
Smart Images

Figure CN118505737B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of image segmentation, and in particular to an automatic detection method for production quality of an injection mold. Background Art
[0002] During the production and processing of injection molds, there is usually a flow mark defect on the surface of the injection molded product obtained by the injection mold. The formation of flow marks is caused by many reasons such as the flow channel design of the mold itself, the flow properties of the injection material, and the injection speed and temperature. Since flow mark defects will reduce the aesthetics of the final product and reduce the strength and durability of the injection molded product, it is usually necessary to detect flow mark defects on the surface of the injection molded product during the quality inspection of injection mold production.
[0003] When detecting flow mark defects on the surface of injection molded products, an iterative threshold segmentation algorithm is used to segment the surface image of the injection molded products, and the flow mark area is determined based on the segmentation results. However, when performing iterative threshold segmentation, due to the difference in grayscale values of the flow mark area itself, there are some areas in the flow mark area with very small grayscale value differences and grayscale values close to the background. This makes it impossible to fully obtain the entire flow mark area during the iterative threshold segmentation process, resulting in a decrease in the accuracy of flow mark defect detection, and further resulting in a low accuracy of injection mold production quality inspection. Summary of the invention
[0004] The object of the present invention is to provide an automatic detection method for injection mold production quality, which is used to solve the problem of low accuracy of injection mold production quality detection due to inaccurate image segmentation.
[0005] In order to solve the above technical problems, the present invention provides an automatic detection method for injection mold production quality, comprising the following steps:
[0006] Obtaining a grayscale image of the surface image of the injection molded product;
[0007] Performing threshold iteration segmentation on the grayscale image to obtain a foreground image in the grayscale image, and determining whether there is a quality problem on the surface of the injection molded product based on the foreground image. The process of performing threshold iteration segmentation on the grayscale image includes:
[0008] Determine whether the iterative segmentation termination condition is met, if the iterative segmentation termination condition is met, use the current foreground image as the final foreground image in the grayscale image, if the iterative segmentation termination condition is not met, determine each suspected defect area in the current foreground image according to the position of each pixel in the current foreground image;
[0009] Determine each extension position of the suspected defect area, and determine the primary change degree of the grayscale value of each extension position of the suspected defect area according to the grayscale value difference between the extension position and each pixel point on both sides thereof;
[0010] Determining the grayscale value change degree of each extended position of the suspected defect area according to the difference between the primary change degrees of the grayscale values of adjacent extended positions of the suspected defect area;
[0011] Determine the possibility that the suspected defect area belongs to the flow mark area according to the gray value change degree of each extended position of each suspected defect area, the difference in the gray value change degree of the extended position of the same height between each suspected defect area and its adjacent suspected defect area, and the distance between each suspected defect area and its adjacent suspected defect area at the same height.
[0012] Based on the possibility of belonging to the flow mark area, the grayscale values of the pixels in each suspected defect area in the current foreground image, and the grayscale values of the pixels in the current background image, an updated segmentation threshold is determined, and the grayscale image is segmented using the updated segmentation threshold to obtain an updated foreground image and background image.
[0013] Furthermore, the primary change degree of the gray value of each extended position of the suspected defect area is determined, and the corresponding calculation formula is:
[0014] ;in, Indicates the primary change degree of the gray value of the j-th extension position of the i-th suspected defect area; represents the jth extended position in the i-th suspected defect area and the pixel sequence composed of each pixel point on the first side thereof. The gray value of each pixel; represents the jth extended position in the i-th suspected defect area and the pixel sequence composed of each pixel point on the first side thereof. -The gray value of 1 pixel; represents the jth extended position in the i-th suspected defect area and the pixel sequence composed of each pixel point on the second side thereof. The gray value of each pixel; represents the jth extended position in the i-th suspected defect area and the pixel sequence composed of each pixel point on the second side thereof. A represents the total number of pixels in the pixel sequence composed of the j-th extended position and the pixels on its first side in the i-th suspected defect area; B represents the total number of pixels in the pixel sequence composed of the j-th extended position and the pixels on its second side in the i-th suspected defect area; || represents the absolute value sign.
[0015] Further, determining the gray value change degree of each extended position of the suspected defect area includes:
[0016] Determine the average absolute value of the difference in the primary change degree of the grayscale value between each extended position of the suspected defect area and its front and rear adjacent extended positions, and determine the absolute value of the difference in the primary change degree of the grayscale value between the front and rear adjacent extended positions of each extended position of the suspected defect area;
[0017] The grayscale value change degree of each extended position of the suspected defect area is determined according to the primary change degree of the grayscale value of each extended position of the suspected defect area and the corresponding average difference absolute value and difference absolute value.
[0018] Furthermore, the grayscale value variation degree of each extended position of the suspected defect area is determined, and the corresponding calculation formula is:
[0019] ;in, Indicates the degree of change in the gray value of the j-th extension position of the i-th suspected defect area; Indicates the average absolute value of the difference in the primary change degree of the gray value between the j-th extension position of the i-th suspected defect area and its adjacent extension positions before and after; represents the absolute value of the difference in the primary change degree of the gray value between the adjacent extension positions before and after the jth extension position of the i-th suspected defect area; Indicates the primary change degree of the gray value of the j-th extension position of the i-th suspected defect area; represents the first adjustment parameter; Represents the second adjustment parameter.
[0020] Furthermore, the possibility of the suspected defect area belonging to the flow mark area is determined, and the corresponding calculation formula is:
[0021] ;in, Indicates the possibility that the i-th suspected defect area belongs to the flow mark area; represents the distance between the jth extension position of the same height between the ith suspected defect region and its kth adjacent suspected defect region; Indicates the degree of change in the grayscale value of the jth extended position of the same height of the kth adjacent suspected defect area corresponding to the i-th suspected defect area; Indicates the degree of change in the grayscale value of the jth extended position of the i-th suspected defect region corresponding to the k-th adjacent suspected defect region; represents the total number of extended positions of equal height between the ith suspected defect region and its kth adjacent suspected defect region; K represents the number of the adjacent suspected defect regions of the ith suspected defect region; represents the normalization function; | | represents the absolute value sign; represents the third adjustment parameter.
[0022] Further, determining the updated segmentation threshold includes:
[0023] Determine the average grayscale value of each suspected defect area according to the grayscale value of the pixel points in each suspected defect area in the current foreground image;
[0024] Determine whether the possibility of each suspected defect area belonging to the flow mark area is less than the flow mark area possibility threshold, and determine the suspected defect area corresponding to the area less than the flow mark area possibility threshold as the target suspected defect area;
[0025] Determine the weight value of each suspected defect area, and according to the possibility that the target suspected defect area belongs to the flow mark area, modify the weight value of the target suspected defect area to obtain the final weight value of the target suspected defect area;
[0026] According to the average grayscale value of each suspected defect area and the final weight value, a weighted sum is performed to obtain the grayscale mean value corresponding to the current foreground image;
[0027] According to the grayscale values of the pixels in the current background image, the grayscale mean corresponding to the current background image is determined, and the average of the grayscale mean corresponding to the current foreground image and the grayscale mean corresponding to the current background image is determined as the updated segmentation threshold.
[0028] Furthermore, the final weight value of the target suspected defect area is obtained, and the corresponding calculation formula is:
[0029] ;in, represents the final weight value of the i-th target suspected defect area; represents the weight value of the i-th target suspected defect area before correction; It indicates the possibility that the i-th target suspected defect area belongs to the flow mark area.
[0030] Further, determining each extension position of the suspected defect area includes:
[0031] Determine the extension direction of the suspected defect area, and then determine a curve passing through the center point of the suspected defect area and located in the extension direction, and determine the positions of each pixel point in the suspected defect area located on the curve as each extension position of the suspected defect area.
[0032] Furthermore, the iterative segmentation termination condition is: the absolute value of the difference between the current segmentation threshold and the previous segmentation threshold is less than the set segmentation difference threshold, or the current segmentation times reaches the set segmentation times threshold.
[0033] Further, each suspected defect area in the current foreground image is determined, including:
[0034] According to the position of each pixel point in the current foreground image, density clustering is performed on each pixel point in the current foreground image to obtain each cluster, and the area formed by each cluster is determined as each suspected defect area in the current foreground image.
[0035] The present invention has the following beneficial effects: in the process of threshold iterative segmentation of the grayscale image of the surface image of the injection molded product, for each suspected defect area in the foreground image obtained after each iterative segmentation, based on the texture characteristics of the flow mark defect, the grayscale value difference between each extension position and each pixel point on both sides of the suspected defect area is analyzed to obtain the primary change degree of the grayscale value of each extension position, and the difference between the primary change degrees of the grayscale values of adjacent extension positions is analyzed to obtain the grayscale value change degree of each extension position. Then, by comprehensively considering the grayscale value change degree of each extension position of each suspected defect area, the distance between each suspected defect area and the extension position of the adjacent suspected defect area, and the difference in the grayscale value change degree between the extension positions, the possibility of each suspected defect area belonging to the flow mark area is accurately quantified, thereby obtaining the possibility of each suspected defect area belonging to the flow mark area. Based on the possibility of each suspected defect area belonging to the flow mark area, the current segmentation threshold is adaptively adjusted, so that the flow mark area with a smaller grayscale change can be completely segmented out, effectively improving the accuracy of flow mark defect detection, and thus improving the accuracy of injection mold production quality detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0037] Figure 1 It is a flow chart of the automatic detection method of injection mold production quality according to an embodiment of the present invention;
[0038] Figure 2 The present invention is a flowchart of performing iterative threshold segmentation on a grayscale image according to an embodiment of the present invention. DETAILED DESCRIPTION
[0039] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the specific implementation methods, structures, features and effects of the technical solutions proposed by the present invention are described in detail below in conjunction with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0040] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. In addition, all parameters or indicators in the formulas involved in this article are normalized values that eliminate the influence of dimensions.
[0041] In order to solve the problem of low accuracy in quality detection of existing injection mold production, this embodiment provides an automatic detection method for injection mold production quality. The corresponding flow chart of the method is as follows: Figure 1 As shown, the following steps are included:
[0042] Step S1: obtaining a grayscale image of the surface image of the injection molded product;
[0043] When the production quality of the injection mold is automatically inspected, the surface image of the injection molded product is collected by a high-speed camera, and the collected surface image is grayed to obtain a corresponding gray image.
[0044] Step S2: performing threshold iteration segmentation on the grayscale image to obtain a foreground image in the grayscale image, and determining whether there are quality problems on the surface of the injection molded product based on the foreground image.
[0045] When using the iterative threshold segmentation algorithm to segment the surface image of the injection molded product, it is difficult to obtain a complete segmentation effect because the grayscale value of the middle area closer to the flow mark is less different from the grayscale value of the injection molded product. Considering that the grayscale feature of the flow mark area is that the grayscale value increases from the center to both sides, the possibility that the suspected defect area belongs to the real flow mark area can be determined by performing feature analysis on the suspected defect area in the foreground image during each segmentation process, so as to realize the judgment of the flow mark area segmentation situation, and according to this possibility, the segmentation threshold in each segmentation process is adaptively updated to obtain a more accurate segmentation threshold, and finally achieve complete segmentation of the flow mark area.
[0046] Based on the above analysis, the grayscale image is subjected to threshold iteration segmentation to obtain the foreground image in the grayscale image. Since the specific steps of threshold iteration segmentation of the grayscale image will be introduced in detail in the subsequent content, they will not be repeated here. According to the position of each pixel point in the obtained foreground image, each pixel point is density clustered to obtain each cluster cluster, and the area formed by each cluster cluster is each flow mark area in the foreground image. In this embodiment, the algorithm used for density clustering here is DBSCAN (Density-Based Spatial Clustering of Applications with Noise) algorithm.
[0047] According to the situation of each flow mark area in the foreground image, it can be determined whether there is a quality problem on the surface of the injection molded product. For example, when the area ratio of these flow mark areas in the foreground image exceeds the set ratio threshold, it is judged that there is a quality problem on the surface of the injection molded product. When the area ratio of these flow mark areas in the foreground image does not exceed the set ratio threshold, but the number of these flow mark areas exceeds the set number threshold, it is also judged that there is a quality problem on the surface of the injection molded product, otherwise it is judged that there is no quality problem on the surface of the injection molded product.
[0048] like Figure 2 As shown, it shows the specific steps of performing threshold iteration segmentation on the grayscale image in this embodiment to obtain the foreground image in the grayscale image, including:
[0049] Determine whether the iterative segmentation termination condition is met, if the iterative segmentation termination condition is met, use the current foreground image as the final foreground image in the grayscale image, if the iterative segmentation termination condition is not met, determine each suspected defect area in the current foreground image according to the position of each pixel in the current foreground image;
[0050] Determine each extension position of the suspected defect area, and determine the primary change degree of the grayscale value of each extension position of the suspected defect area according to the grayscale value difference between the extension position and each pixel point on both sides thereof;
[0051] Determining the grayscale value change degree of each extended position of the suspected defect area according to the difference between the primary change degrees of the grayscale values of adjacent extended positions of the suspected defect area;
[0052] Determine the possibility that the suspected defect area belongs to the flow mark area according to the gray value change degree of each extended position of each suspected defect area, the difference in the gray value change degree of the extended position of the same height between each suspected defect area and its adjacent suspected defect area, and the distance between each suspected defect area and its adjacent suspected defect area at the same height.
[0053] Based on the possibility of belonging to the flow mark area, the grayscale values of the pixels in each suspected defect area in the current foreground image, and the grayscale values of the pixels in the current background image, an updated segmentation threshold is determined, and the grayscale image is segmented using the updated segmentation threshold to obtain an updated foreground image and background image.
[0054] For the above steps, in order to facilitate understanding, first, it is necessary to determine the initial segmentation threshold when performing threshold iteration segmentation on the grayscale image. The initial segmentation threshold can be reasonably set as needed. In this embodiment, the middle value of all gray levels in the grayscale image is selected as the initial segmentation threshold. The pixels in the grayscale image are segmented using the initial segmentation threshold, so as to obtain the initial foreground image and background image. By analyzing the initial foreground image, the segmentation threshold after the first update can be obtained. Since the specific steps for obtaining the segmentation threshold after the first update are exactly the same as the steps for obtaining the segmentation threshold after each update in the subsequent content, they are not repeated here. The pixels in the grayscale image are segmented using the segmentation threshold after the first update, so as to obtain the foreground image and background image after the first update. Here, the segmentation threshold after the first update is referred to as the current segmentation threshold, and the grayscale image is segmented using the segmentation threshold after the first update, and the foreground image and background image obtained after the first update are referred to as the current foreground image and background image.
[0055] It is determined whether the iterative segmentation termination condition is met. The iterative segmentation termination condition can be reasonably set as needed. In this embodiment, the iterative segmentation termination condition is: the absolute value of the difference between the current segmentation threshold and the previous segmentation threshold is less than the set segmentation difference threshold, or the current segmentation times are greater than the set segmentation times threshold. Both the set segmentation difference threshold and the set segmentation times threshold can be reasonably set as needed, and are not limited here.
[0056] If the iterative segmentation termination condition is met, the current foreground image is used as the final foreground image in the grayscale image, and then the surface of the injection molded product is judged whether there are quality problems. If the iterative segmentation termination condition is not met, the suspected defect areas in the current foreground image are determined according to the positions of the pixels in the current foreground image. The steps include: density clustering the pixels in the current foreground image according to the positions of the pixels in the current foreground image to obtain clusters, and the areas formed by the clusters are determined as the suspected defect areas in the current foreground image. In this embodiment, the algorithm used for density clustering is still the DBSCAN algorithm.
[0057] According to the characteristics of the flow mark area, the grayscale value of the center point of the area is the smallest and the grayscale gradient is large. Therefore, the pixel with the smallest grayscale value and the largest grayscale gradient in the suspected defect area is more likely to be the center point. In this embodiment, the pixel corresponding to the minimum grayscale value in each suspected defect area is determined. If there is only one pixel, the pixel is directly used as the center point of the corresponding suspected defect area. If there are multiple pixels, the pixel corresponding to the largest grayscale gradient is used as the center point of the corresponding suspected defect area. Of course, if there are multiple pixels corresponding to the largest grayscale gradient, the pixel closest to the geometric center of the suspected defect area is used as the center point of the corresponding suspected defect area.
[0058] Next, the various extension positions in each suspected defect area are determined, and the steps include: determining the extension direction of the suspected defect area, and then determining a curve that passes through the center point of the suspected defect area and is in the extension direction, and determining the positions of the various pixel points on the curve in the suspected defect area as the various extension positions of the suspected defect area. According to the distribution of the pixel points in each suspected defect area, the extension direction of each suspected defect area can be determined. The extension direction refers to the direction of the central axis of the suspected defect area. When the suspected defect area is an irregular shape, the central axis may not be a straight line, and the direction corresponding to the central axis direction at different positions may be different. Determine a curve that passes through the center point of each suspected defect area and is in its corresponding extension direction, and use the various pixel points on the curve and in the corresponding suspected defect area as the various extension positions of the corresponding suspected defect area.
[0059] According to the characteristics of the flow mark area, for any extended position of each suspected defect area, when the extended position is taken as the starting point, the more obvious the increasing relationship of the grayscale value along the two sides of the extended position is, the greater the possibility that the suspected defect area belongs to the flow mark area. The two sides refer to the directions perpendicular to the extension direction of the flow mark area at the extended position, and the pixel points belonging to the corresponding flow mark area on any side of the two sides of the extended position are taken as the pixel points on the first side of the extended position, and the pixel points belonging to the corresponding flow mark area on the other side are taken as the pixel points on the second side of the extended position. In order to measure the possibility that each suspected defect area belongs to the flow mark area, the primary change degree of the grayscale value of each extended position of each suspected defect area can be determined according to the grayscale value difference between each extended position of each suspected defect area and each pixel point on both sides thereof.
[0060] Preferably, in this embodiment, the primary change degree of the gray value of each extended position of each suspected defect area is determined, and the corresponding calculation formula is:
[0061] ;in, Indicates the primary change degree of the gray value of the j-th extension position of the i-th suspected defect area; represents the jth extended position in the i-th suspected defect area and the pixel sequence composed of each pixel point on the first side thereof. The gray value of each pixel; represents the jth extended position in the i-th suspected defect area and the pixel sequence composed of each pixel point on the first side thereof. -The gray value of 1 pixel; represents the jth extended position in the i-th suspected defect area and the pixel sequence composed of each pixel point on the second side thereof. The gray value of each pixel; represents the jth extended position in the i-th suspected defect area and the pixel sequence composed of each pixel point on the second side thereof. A represents the total number of pixels in the pixel sequence composed of the j-th extended position and the pixels on its first side in the i-th suspected defect area; B represents the total number of pixels in the pixel sequence composed of the j-th extended position and the pixels on its second side in the i-th suspected defect area; || represents the absolute value sign.
[0062] In the above formula, each extended position of each suspected defect area and each pixel point on each side thereof are combined into a pixel sequence according to the pixel arrangement order, and the cumulative grayscale value difference between each two adjacent pixels in the pixel sequence is measured. The larger the cumulative grayscale value difference is, the more obvious the increasing relationship of the grayscale value along the two sides of the extended position with the extended position as the starting point is, the greater the grayscale value change degree of the pixel points on both sides of the extended position is, and the greater the value of the corresponding primary change degree of the grayscale value is.
[0063] Next, the difference between the primary change degrees of grayscale values of adjacent extended positions of each suspected defect area is analyzed to determine the change degrees of grayscale values of each extended position of the suspected defect area. The steps include: determining the average absolute value of the difference in the primary change degrees of grayscale values between each extended position of the suspected defect area and its front and rear adjacent extended positions, and determining the absolute value of the difference in the primary change degrees of grayscale values between the front and rear adjacent extended positions of each extended position of the suspected defect area; determining the change degrees of grayscale values of each extended position of the suspected defect area based on the primary change degrees of grayscale values of each extended position of the suspected defect area and the corresponding average absolute value of the difference and the absolute value of the difference.
[0064] Preferably, in this embodiment, the gray value variation degree of each extension position of each suspected defect area is determined, and the corresponding calculation formula is:
[0065] ;in, Indicates the degree of change in the gray value of the j-th extension position of the i-th suspected defect area; Indicates the average absolute value of the difference in the primary change degree of the gray value between the j-th extension position of the i-th suspected defect area and its adjacent extension positions before and after; represents the absolute value of the difference in the primary change degree of the gray value between the adjacent extension positions before and after the jth extension position of the i-th suspected defect area; Indicates the primary change degree of the gray value of the j-th extension position of the i-th suspected defect area; represents the first adjustment parameter, which is used to prevent the denominator from being 0. In this embodiment, ; Represents the second adjustment parameter, which is used to prevent the denominator from being 0. In this embodiment, .
[0066] In the above formula, when the primary change degree of the gray value of the jth extension position of the i-th suspected defect area is The larger the value of is, the more the j-th extension position and the pixels on both sides of it conform to the change characteristics of the flow mark area, and the corresponding final grayscale value change degree should also be larger, and the j-th extension position is more likely to be part of the flow mark area.
[0067] In the above formula, the primary change degree of the gray value between the jth extension position of the i-th suspected defect area and its previous adjacent extension position is determined. The absolute value of the difference , and the primary change degree of gray value between the jth extension position and its next adjacent extension position The absolute value of the difference , and calculate the average of the absolute values of the two differences to get the average absolute value of the difference Of course, when the jth extension position is located at the endpoint, it may only have the previous adjacent extension position or the next adjacent extension position. At this time, the interpolation algorithm is used to interpolate the next adjacent extension position or the previous adjacent extension position of the jth extension position, thereby obtaining the average absolute value of the difference. When the absolute value of the mean difference The smaller the value is, the greater the credibility of the primary change in the grayscale value of the j-th extended position is, the greater the possibility that the j-th extended position belongs to the position with smaller grayscale value difference in the flow mark area, and the j-th extended position is less likely to be completely segmented in the iterative threshold segmentation. At this time, the value of the grayscale value change degree of the j-th extended position should be larger.
[0068] In the above formula, the primary change degree of the previous adjacent extension position of the jth extension position of the i-th suspected defect area is determined and the primary change degree of the gray value of the next adjacent extended position The absolute value of the difference is obtained Similarly, when the jth extension position is at the endpoint, it may only have the previous adjacent extension position or the next adjacent extension position. At this time, the absolute value of the difference is obtained based on the next adjacent extension position or the previous adjacent extension position of the jth extension position interpolated above. When the absolute value of the difference The smaller it is, the greater the possibility that the primary change degree of the grayscale value of the j-th extension position is reduced relative to its adjacent extension position, which further indicates that the possibility that the j-th extension position belongs to the flow mark area is greater, and at this time, the greater the value of the grayscale value change degree of the j-th extension position should be.
[0069] When analyzing the possibility that a suspected defect area belongs to a flow mark area, since the grayscale change degree at the extended position at the same height between multiple suspected defect areas is relatively similar, that is, they all show the characteristic of increasing from the middle to both sides, this characteristic can be used to analyze and calculate the possibility that the suspected defect area belongs to the flow mark area. When performing the analysis and calculation, first, for each suspected defect area, the adjacent suspected defect area of the suspected defect area is determined. In this embodiment, the Euclidean distance between the center point of each suspected defect area and the center point of other suspected defect areas is calculated, and other suspected defect areas corresponding to the Euclidean distance less than the set Euclidean distance threshold are used as the adjacent suspected defect areas of each suspected defect area. The setting of the Euclidean distance threshold can be reasonably set according to actual needs, and is not limited here.
[0070] After determining the adjacent suspected defect areas of each suspected defect area, determine the extension positions of equal height between each suspected defect area and each of its adjacent suspected defect areas. For suspected defect area a and one of its adjacent suspected defect areas b, draw a straight line perpendicular to the extension direction of the extension position c through the extension position c of the suspected defect area a, and determine the extension position d of the suspected defect area b and located on the straight line. The extension positions c and d are a pair of extension positions of equal height between the suspected defect area a and one of its adjacent suspected defect areas b. In this way, multiple pairs of extension positions of equal height between each suspected defect area and each of its adjacent suspected defect areas can be determined.
[0071] On this basis, the possibility of each suspected defect area belonging to the flow mark area is determined according to the degree of change of the grayscale value of each extended position of each suspected defect area, the difference in the degree of change of the grayscale value of the extended positions at the same height between each suspected defect area and its adjacent suspected defect areas, and the distance between the extended positions at the same height between each suspected defect area and its adjacent suspected defect areas.
[0072] Preferably, in this embodiment, the possibility of each suspected defect area belonging to the flow mark area is determined, and the corresponding calculation formula is:
[0073] ;in, Indicates the possibility that the i-th suspected defect area belongs to the flow mark area; represents the distance between the jth extension position of the same height between the ith suspected defect region and its kth adjacent suspected defect region; Indicates the degree of change in the grayscale value of the jth extended position of the same height of the kth adjacent suspected defect area corresponding to the i-th suspected defect area; Indicates the degree of change in the grayscale value of the jth extended position of the i-th suspected defect region corresponding to the k-th adjacent suspected defect region; represents the total number of extended positions of equal height between the ith suspected defect region and its kth adjacent suspected defect region; K represents the number of the adjacent suspected defect regions of the ith suspected defect region; represents the normalization function; | | represents the absolute value sign; represents the third adjustment parameter, which is used to prevent the denominator from being 0. In this embodiment, .
[0074] In the above formula, by comparing the grayscale value change degree of the extended position of the same height between each suspected defect area and its adjacent suspected defect area, the absolute value of the difference between the two represents the change amount of the grayscale value change degree. When the change amount is smaller, the grayscale change degree difference between adjacent suspected defect areas is smaller, which means that the corresponding extended position is more likely to belong to the position with a smaller grayscale value difference in the flow mark area, that is, the area that cannot be completely segmented in the iterative threshold segmentation. Then the corresponding suspected defect area is more likely to belong to the flow mark area, that is, the suspected defect area is more likely to be a real flow mark area. By calculating the distance between the extended position of the same height between each suspected defect area and its adjacent suspected defect area, the smaller the distance value, the greater the credibility of the change amount of the grayscale value change degree corresponding to the extended position of the same height. Then, the grayscale value change degree of the extended position of each suspected defect area corresponding to the suspected defect area is weighted by using the grayscale value change degree of the extended position of the same height between each suspected defect area and its adjacent suspected defect area, so as to take into account the grayscale value change degree of the extended position corresponding to each suspected defect area, and finally obtain the weighted change amount. By accumulating and summing all weighted changes and normalizing the accumulated summation results, the probability of each suspected defect area belonging to the flow mark area is finally accurately obtained. When the value of the probability of belonging to the flow mark area is larger, it means that the corresponding suspected defect area is more likely to belong to the flow mark area.
[0075] Considering that the segmentation threshold of iterative threshold segmentation is obtained by the average of the average grayscale value of the foreground area and the average grayscale value of the background area, when the suspected defect area is more likely to belong to the flow mark area, that is, the greater the value of the possibility of the suspected defect area belonging to the flow mark area, then what needs to be done is to change the segmentation threshold to make this part of the area easier to be segmented out. Therefore, the average grayscale value of the suspected defect area is set to a lower weight when calculating the two types of average grayscale values, so that the segmentation threshold is more biased towards the background area. However, when the possibility of belonging to the flow mark area exceeds a certain threshold, the original segmentation threshold needs to be maintained. This is because this type of suspected defect area has clearly shown the characteristics of the flow mark area and is already a defect area that is easy to segment out.
[0076] To achieve the above purpose, based on the possibility of each suspected defect area belonging to the flow mark area, the grayscale mean corresponding to the current foreground image is adaptively updated to determine the updated segmentation threshold of the entire grayscale image, and the steps include: determining the average grayscale value of each suspected defect area according to the grayscale value of the pixel points in each suspected defect area in the current foreground image; judging whether the possibility of each suspected defect area belonging to the flow mark area is less than the flow mark area possibility threshold, and determining the suspected defect area corresponding to the flow mark area possibility threshold as the target suspected defect area; determining the weight value of each suspected defect area, and correcting the weight value of the target suspected defect area according to the possibility of the target suspected defect area belonging to the flow mark area to obtain the final weight value of the target suspected defect area; performing weighted summation according to the average grayscale value of each suspected defect area and the final weight value to obtain the grayscale mean corresponding to the current foreground image; determining the grayscale mean corresponding to the current background image according to the grayscale value of the pixel points in the current background image, and determining the average value of the grayscale mean corresponding to the current foreground image and the grayscale mean corresponding to the current background image as the updated segmentation threshold.
[0077] In the above process of determining the updated segmentation threshold of the entire grayscale image, the flow mark area possibility threshold can be reasonably set according to the actual situation. In this embodiment, the flow mark area possibility threshold is set to 0.6. When determining the weight value of each suspected defect area, the reciprocal of the number of each current suspected defect area is used as the weight value of each suspected defect area, that is, the initial weight value.
[0078] Preferably, in this embodiment, the weight value of the target suspected defect area is corrected to obtain the final weight value of the target suspected defect area, and the corresponding calculation formula is:
[0079] ;in, represents the final weight value of the i-th target suspected defect area; represents the weight value of the i-th target suspected defect area before correction; It indicates the possibility that the i-th target suspected defect area belongs to the flow mark area.
[0080] In the above formula, the greater the possibility that the target suspected defect area belongs to the flow mark area, the smaller the final corrected weight value of the target suspected defect area. Since the grayscale mean corresponding to the current foreground image is obtained by weighted summing the average grayscale value and weight value of each suspected defect area, the updated segmentation threshold determined later will be more biased towards the grayscale value of the background area in the background image, which is more conducive to segmenting the complete flow mark area, thereby making the segmentation result more accurate.
[0081] After determining the updated segmentation threshold in the above manner, the grayscale image is re-segmented using the updated segmentation threshold to obtain an updated foreground image and background image. The updated segmentation threshold is then used as the current segmentation threshold, and the updated foreground image and background image are used as the current foreground image and background image, respectively. The above iterative segmentation process is continuously performed until the iterative segmentation termination condition is met, thereby obtaining the final foreground image in the grayscale image. Based on the final foreground image, it is determined whether there are quality problems on the surface of the injection molded product. Since the specific process has been described in detail in the above content, it will not be repeated here.
[0082] The present invention obtains a grayscale image of the surface image of the injection molded product, analyzes the characteristics of each suspected defect area in the foreground image obtained by each segmentation, determines the possibility that each suspected defect area belongs to a flow mark area, and then adaptively adjusts the segmentation threshold in the iterative threshold segmentation algorithm, so that the flow mark area with smaller grayscale changes can be completely segmented out, effectively improving the accuracy of flow mark defect detection, and further improving the accuracy of injection mold production quality inspection.
[0083] It should be noted that the above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for automatically detecting the production quality of injection molds, characterized in that: The following steps are involved: Obtaining a grayscale image of the surface image of the injection molded product; Performing threshold iteration segmentation on the grayscale image to obtain a foreground image in the grayscale image, and determining whether there is a quality problem on the surface of the injection molded product based on the foreground image. The process of performing threshold iteration segmentation on the grayscale image includes: Determine whether the iterative segmentation termination condition is met, if the iterative segmentation termination condition is met, use the current foreground image as the final foreground image in the grayscale image, if the iterative segmentation termination condition is not met, determine each suspected defect area in the current foreground image according to the position of each pixel in the current foreground image; Determine each extension position of the suspected defect area, and determine the primary change degree of the grayscale value of each extension position of the suspected defect area according to the grayscale value difference between the extension position and each pixel point on both sides thereof; Determining the grayscale value change degree of each extended position of the suspected defect area according to the difference between the primary change degrees of the grayscale values of adjacent extended positions of the suspected defect area; Determine the possibility that the suspected defect area belongs to the flow mark area according to the gray value change degree of each extended position of each suspected defect area, the difference in the gray value change degree of the extended position of the same height between each suspected defect area and its adjacent suspected defect area, and the distance between each suspected defect area and its adjacent suspected defect area at the same height. Determine an updated segmentation threshold according to the possibility of belonging to the flow mark area, the grayscale values of the pixels in each suspected defect area in the current foreground image, and the grayscale values of the pixels in the current background image, and segment the grayscale image using the updated segmentation threshold to obtain an updated foreground image and background image; Determining each extension position of the suspected defect area includes: Determine an extension direction of the suspected defect area, and then determine a curve passing through a center point of the suspected defect area and located in the extension direction, and determine positions of each pixel point in the suspected defect area located on the curve as each extension position of the suspected defect area; Determine the primary change degree of the gray value of each extended position of the suspected defect area, and the corresponding calculation formula is: ;in, Indicates the primary change degree of the gray value of the j-th extension position of the i-th suspected defect area; represents the jth extended position in the i-th suspected defect area and the pixel sequence composed of each pixel point on the first side thereof. The gray value of each pixel; represents the jth extended position in the i-th suspected defect area and the pixel sequence composed of each pixel point on the first side thereof. -The gray value of 1 pixel; represents the jth extended position in the i-th suspected defect area and the pixel sequence composed of each pixel point on the second side thereof. The gray value of each pixel; represents the jth extended position in the i-th suspected defect area and the pixel sequence composed of each pixel point on the second side thereof. A represents the total number of pixels in the pixel sequence formed by the jth extended position and the pixels on the first side of the i-th suspected defect area; B represents the total number of pixels in the pixel sequence formed by the jth extended position and the pixels on the second side of the i-th suspected defect area; | | represents the absolute value sign; Determine the updated segmentation threshold, including: Determine the average grayscale value of each suspected defect area according to the grayscale value of the pixel points in each suspected defect area in the current foreground image; Determine whether the possibility of each suspected defect area belonging to the flow mark area is less than the flow mark area possibility threshold, and determine the suspected defect area corresponding to the area less than the flow mark area possibility threshold as the target suspected defect area; Determine the weight value of each suspected defect area, and according to the possibility that the target suspected defect area belongs to the flow mark area, modify the weight value of the target suspected defect area to obtain the final weight value of the target suspected defect area; According to the average grayscale value of each suspected defect area and the final weight value, a weighted sum is performed to obtain the grayscale mean value corresponding to the current foreground image; According to the grayscale values of the pixels in the current background image, the grayscale mean corresponding to the current background image is determined, and the average of the grayscale mean corresponding to the current foreground image and the grayscale mean corresponding to the current background image is determined as the updated segmentation threshold.
2. The method for automatically detecting the production quality of injection molds according to claim 1, characterized in that: Determining the grayscale value change degree of each extended position of the suspected defect area includes: Determine the average absolute value of the difference in the primary change degree of the grayscale value between each extended position of the suspected defect area and its front and rear adjacent extended positions, and determine the absolute value of the difference in the primary change degree of the grayscale value between the front and rear adjacent extended positions of each extended position of the suspected defect area; The grayscale value change degree of each extended position of the suspected defect area is determined according to the primary change degree of the grayscale value of each extended position of the suspected defect area and the corresponding average difference absolute value and difference absolute value.
3. The method for automatically detecting the production quality of injection molds according to claim 2, characterized in that: Determine the gray value change degree of each extended position of the suspected defect area, and the corresponding calculation formula is: ;in, Indicates the degree of change in the gray value of the j-th extension position of the i-th suspected defect area; represents the average absolute value of the difference between the primary change degree of the gray value between the j-th extension position of the i-th suspected defect area and its front and rear adjacent extension positions; represents the absolute value of the difference in the primary change degree of the gray value between the adjacent extension positions before and after the jth extension position of the i-th suspected defect area; Indicates the primary change degree of the gray value of the j-th extension position of the i-th suspected defect area; represents the first adjustment parameter; Represents the second adjustment parameter.
4. The method for automatically detecting the production quality of injection molds according to claim 1, characterized in that: Determine the possibility that the suspected defect area belongs to the flow mark area, and the corresponding calculation formula is: ;in, Indicates the possibility that the i-th suspected defect area belongs to the flow mark area; represents the distance between the jth extension position of the same height between the ith suspected defect region and its kth adjacent suspected defect region; Indicates the degree of change in the grayscale value of the jth extended position of the same height of the kth adjacent suspected defect area corresponding to the i-th suspected defect area; Indicates the degree of change in the grayscale value of the jth extended position of the i-th suspected defect region corresponding to the k-th adjacent suspected defect region; represents the total number of extended positions of equal height between the ith suspected defect region and its kth adjacent suspected defect region; K represents the number of the adjacent suspected defect regions of the ith suspected defect region; represents the normalization function; | | represents the absolute value sign; represents the third adjustment parameter.
5. The method for automatically detecting the production quality of injection molds according to claim 1, characterized in that: The final weight value of the target suspected defect area is obtained, and the corresponding calculation formula is: ;in, represents the final weight value of the i-th target suspected defect area; represents the weight value of the i-th target suspected defect area before correction; It indicates the possibility that the i-th target suspected defect area belongs to the flow mark area.
6. The method for automatically detecting the production quality of injection molds according to claim 1, characterized in that: The iterative segmentation termination condition is: the absolute value of the difference between the current segmentation threshold and the previous segmentation threshold is less than the set segmentation difference threshold, or the current segmentation times reaches the set segmentation times threshold.
7. The method for automatically detecting the production quality of injection molds according to claim 1, characterized in that: Determine each suspected defect area in the current foreground image, including: According to the position of each pixel point in the current foreground image, density clustering is performed on each pixel point in the current foreground image to obtain each cluster, and the area formed by each cluster is determined as each suspected defect area in the current foreground image.
Citation Information
Patent Citations
Injection molding part wave flow mark identification method based on image processing
CN113936000A
Non-ferrous metal rolling quality detection method and system based on machine vision
CN114638833A
