Online detection method and system for automobile part injection mold based on image analysis
By performing grayscale image processing, binarization processing and contour extraction on the injection mold images of automobile parts, combined with RGB threshold comparison, the problem of inaccurate detection under different lighting conditions is solved, and more efficient and accurate defect detection is achieved.
Patent Information
- Application Number
- CN202411808273.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-12-10
AI Technical Summary
The existing automotive component injection mold defect detection technology is inaccurate under different lighting conditions, and the RGB value changes of pixel points are not effectively considered.
By acquiring the detection mold image, greyscale image processing, binarization processing and contour extraction are performed, defect outlines are obtained, and the RGB value of the pixel points in it is compared with the RGB threshold value to determine whether it is a real defect.
It improves detection accuracy under different lighting conditions, reduces the workload of pixel point comparison, and improves detection efficiency.
Smart Images

Figure CN119741271A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of automobile component injection mold defect detection, and in particular to an automobile component injection mold online detection method and system based on image analysis. Background Art
[0002] With the rapid development of the automobile industry, the quality and safety requirements for automobile parts are increasing. Defects in the injection molds of automobile parts during the injection molding process, such as bubbles, cracks, and surface defects, directly affect the performance and appearance of the finished product. Therefore, it is necessary to detect defects in the injection molds of automobile parts. Mold defect detection not only improves the quality of automobile plastic parts, but also helps to improve production efficiency and reduce costs, meeting the market demand for high-precision and high-stability products.
[0003] Existing defect detection technologies for automobile parts injection molds include manual detection and image analysis detection. The evaluation criteria for manual detection are relatively subjective, resulting in fluctuations in accuracy with people's subjective consciousness. At the same time, manual monitoring has the problem of low efficiency. Image analysis detection compares the pixel points of the mold image to be detected with the pixel points of the normal mold image to determine whether the mold image to be detected contains defects. When the pixel points of the normal mold image are obtained, it is not considered that the RGB values of the pixels under different lighting conditions will change. For example, in a patent application with authorization announcement number CN112465809B, a mold defect detection method based on image recognition, a computer-readable storage medium and a device are disclosed. The acquisition of the standard sample of this scheme does not take into account that the RGB values of the pixels under different lighting conditions will change. That is, when the normal mold image is obtained in the existing defect detection technology for automobile parts injection molds, it is not considered that the RGB values of the pixels under different lighting conditions will change, resulting in inaccurate comparison defect detection of automobile parts injection molds. Summary of the invention
[0004] The present invention aims to solve one of the technical problems in the prior art to at least a certain extent, by obtaining a detection mold image, performing grayscale image processing, binarization processing and contour processing on the detection mold image to obtain a defect contour, and comparing the RGB of a pixel point within the defect contour of the detection mold image with an RGB threshold to determine whether it is a real defect, so as to solve the problem that when obtaining a defect-free mold image in the existing automobile component injection mold defect detection technology, the RGB value of the pixel point will change under different lighting conditions, resulting in inaccurate defect detection of the automobile component injection mold.
[0005] To achieve the above objectives, in a first aspect, the present application provides an online detection method for automobile parts injection molds based on image analysis, comprising the following steps:
[0006] Obtain an image of an injection mold of an automobile part to be inspected, and mark it as an inspection mold image;
[0007] The inspection mold image is converted into a grayscale image to obtain an inspection grayscale image, the inspection grayscale image is binarized to obtain an inspection binary image, and the inspection binary image is contour extracted to obtain a defect contour;
[0008] Obtain the RGB thresholds of all pixels based on a normal automobile parts injection mold image;
[0009] Based on the position of the defect contour in the detection binary image, the position of the defect contour on the original detection mold image is obtained, and the defect contour in the detection mold image is marked as the detection contour. It is determined whether the RGB values of all pixels in the detection contour exceed the RGB threshold. If the RGB threshold is exceeded, a defect warning and the detection contour position are sent to the processing end.
[0010] Furthermore, converting the detection mold image into a grayscale image to obtain a detection grayscale image includes the following sub-steps:
[0011] Get the RGB value of each pixel of the detected mold image and count the number of pixels N;
[0012] Get the R weight Arg, G weight Agg, and B weight Abg in the RGB value;
[0013] Use the grayscale conversion formula to convert the RGB value into a grayscale value. The grayscale conversion formula is:
[0014] H=Arg*R+Agg*G+Abg*B; wherein H is the gray value, and R, G and B are three values in the RGB value.
[0015] Further, obtaining the R weight Arg, G weight Agg, and B weight Abg in the RGB value includes the following sub-steps:
[0016] Set Ari to be an arithmetic progression with the first term being 0 and the common difference being z, ranging from 0 to 1; where z is a positive number between 0 and 1;
[0017] At the same time, each Ari corresponds to a set of Agi data, where Agi data is an arithmetic progression with the first term being 0, the common difference being z, and the range being 0 to 1-Ari;
[0018] Calculate the Abi corresponding to each set of Ari and Agi using the following formula: Abi = 1-Ari-Agi;
[0019] Use the grayscale conversion formula to convert the RGB value into a grayscale value. The grayscale conversion formula is:
[0020] Hi=Ari*R+Agi*G+Abi*B; Hi is the gray value under different weights, and R, G and B are three values in RGB value;
[0021] Count the number Ni of each grayscale value of a grayscale image respectively;
[0022] Calculate the proportion pi of each gray level of the grayscale image respectively, the calculation formula is: pi = Ni / N; where i is a positive integer between 0 and 255, Ni is the number of the i-th gray level in the grayscale image, and pi is the proportion of the i-th gray level in the image;
[0023] Calculate the contrast value Ti of a grayscale image using the following formula:
[0024]
[0025] Calculate Ti of all grayscale images, find the maximum value Tmax in Ti, and obtain Tmax corresponding to Ari, Agi and Abi, marked as Arg, Agg and Abg respectively.
[0026] Furthermore, binarizing the detection grayscale image to obtain a detection binary image includes the following sub-steps:
[0027] Divide the grayscale value from 0 to 255 into d equal intervals;
[0028] Count the frequency of grayscale values in each equally divided interval and mark it as interval frequency;
[0029] A histogram is drawn with grayscale value as the X-axis and interval frequency as the Y-axis, marked as a grayscale histogram.
[0030] Furthermore, binarizing the detection grayscale image to obtain a detection binary image also includes the following sub-steps:
[0031] Get the frequency X of all gray values;
[0032] If there is an interval whose frequency is less than X / d, it is marked as a low-frequency area, and the intervals other than the low-frequency area are marked as high-frequency areas. It is determined whether there are high-frequency areas on both sides of the low-frequency area. If so, the low-frequency area is marked as a threshold area.
[0033] The grayscale values of pixels in the area greater than the threshold are set to 255, and the grayscale values of pixels in the area less than or equal to the threshold are set to 0.
[0034] Furthermore, extracting the contour of the detection binary image to obtain the defect contour includes the following sub-steps:
[0035] If a pixel with a gray value of 255 is adjacent to a pixel with a gray value of 0, the pixel with a gray value of 255 is marked as a defect edge pixel;
[0036] Count all defect edge pixels and mark them as defect contours.
[0037] Furthermore, obtaining the RGB thresholds of all pixels based on a normal automobile component injection mold image includes the following sub-steps:
[0038] In the first time, a normal automobile component injection mold image is obtained at every time interval t, and marked as a standard mold image;
[0039] The total number of pixels of a standard mold image is counted as U;
[0040] Count the R, G and B values of each pixel of each standard mold image, and mark them as Rb, Gb and Bb respectively;
[0041] Rb, Gb and Bb are processed by the RGB value range acquisition method to obtain: Q1, Q2, Q3, Q4, Q5 and Q6, where Q1 is the first quantile, Q2 is the second quantile, Q3 is the third quantile, Q4 is the fourth quantile, Q5 is the fifth quantile and Q6 is the sixth quantile;
[0042] The method for obtaining the RGB value range includes: setting the quantile of Rb to the first quantile Q1 and the second quantile Q2, wherein the specific method for obtaining the first quantile Q1 and the second quantile Q2 of Rb is:
[0043] Sort the Rb values of the pixels at the same position of each standard mold image from small to large, and set each Rb value to correspond to an Rb value serial number, which is an integer starting from 1;
[0044] Determine whether r1*U is an integer. If it is an integer, set the Rb value of the serial number r1*U as the first quantile Q1. If it is not an integer, find the average of the Rb values corresponding to the serial numbers on both sides of r1*U and mark it as the first quantile Q1; where r1 is the first quantile ratio;
[0045] Determine whether r2*U is an integer. If it is an integer, set the Rb value of the serial number r2*U as the second quantile Q2. If it is not an integer, find the average of the Rb values corresponding to the serial numbers on both sides of r2*U and mark it as the second quantile Q2; where r2 is the second quantile ratio, r2 = (1 / r1-1)*r1;
[0046] Similarly, the third quantile Q3 and the fourth quantile Q4 of Gb are obtained by using the RGB value range acquisition method, and the fifth quantile Q5 and the sixth quantile Q6 of Bb are obtained;
[0047] Set q1=Q1-c*(Q2-Q1), q2=Q2+c*(Q2-Q1), q3=Q3-c*(Q4-Q3), q4=Q3+c*(Q4-Q3), q5=Q5-c*(Q6-Q5), q6=Q6+c*(Q6-Q5), and calculate each pixel point q1, q2, q3, q4, q5 and q6; where q1 is the lower threshold of R of a pixel point, q2 is the upper threshold of R of a pixel point, q3 is the lower threshold of G of a pixel point, q4 is the upper threshold of G of a pixel point, q5 is the lower threshold of B of a pixel point, q6 is the upper threshold of B of a pixel point, and c is a constant.
[0048] Furthermore, obtaining the position of the defect contour on the original inspection mold image based on the position of the defect contour on the inspection binary image includes the following sub-steps:
[0049] Establishing a first plane rectangular coordinate system;
[0050] Get a pixel point at the intersection of the long side and the wide side of the detection binary image, take the center of the pixel point as the origin coordinate, the X axis is parallel to the long side of the detection binary image, the Y axis is parallel to the wide side of the detection binary image, and the detection binary image is in the first quadrant;
[0051] Get the center coordinates of all pixels included in the defect contour and mark them as contour coordinates;
[0052] Establishing a second plane rectangular coordinate system;
[0053] Get a pixel point at the intersection of the long side and the wide side of the detection mold image, take the center of the pixel point as the origin coordinate, the X axis is parallel to the long side of the detection binary image, the Y axis is parallel to the wide side of the detection binary image, and the detection binary image is in the first quadrant;
[0054] Get all the pixel points of the detected mold image at the contour coordinate position and mark them as the detected contour;
[0055] Get the R, G, and B values of all pixels within the detected contour and mark them as Rj, Gj, and Bj respectively.
[0056] Further, determining whether the RGB values of all pixels within the detection contour exceed the RGB threshold, and if the RGB threshold is exceeded, sending a defect warning and a defect contour to the processing end includes the following steps:
[0057] Judge whether each pixel point Rj, Gj, and Bj simultaneously satisfies the RGB threshold range of its own pixel point: q1 < Rj < q2, q3 < Gj < q4, and q5 < Bj < q6. If it is satisfied, the detected contour is the normal injection mold structure contour of the automotive part, and the detected contour is marked as the normal contour. If it is not satisfied, the detected contour is a defect of the injection mold of the automotive part, and a defect warning and the position of the detected contour are sent to the processing end.
[0058] In a second aspect, the present application also provides an online detection system for an injection mold of an automotive part based on image analysis, including an image acquisition module, a defect acquisition module, a threshold acquisition module, and a defect comparison module;
[0059] The image acquisition module is used to acquire an image of the injection mold of the automotive part to be detected, marked as the detected mold image;
[0060] The defect acquisition module is used to convert the detected mold image into a grayscale image to obtain a detected grayscale image, perform binarization processing on the detected grayscale image to obtain a detected binarized image, and perform contour extraction on the detected binarized image to obtain a defect contour;
[0061] The threshold acquisition module is used to acquire the RGB thresholds of all pixel points based on the image of the normal injection mold of the automotive part;
[0062] The defect comparison module is used to obtain the position of the defect contour on the original detected mold image based on the position of the defect contour in the detected binarized image, mark the defect contour in the detected mold image as the detected contour, and judge whether the RGB values of all pixel points within the detected contour exceed the RGB threshold. If the RGB threshold is exceeded, a defect warning and the position of the detected contour are sent to the processing end.
[0063] Advantages of the present invention: The present invention obtains the defect contour by performing grayscale image processing, binarization processing, and contour processing on the detected mold image, and compares the RGB of the pixel points within the defect contour of the detected mold image with the RGB threshold to determine whether it is a real defect. The advantage is that the defect contour is obtained, enabling subsequent detection of only the pixel points within the defect contour, which can reduce the workload of pixel point comparison and improve efficiency. The RGB value thresholds of the images of the normal injection molds of automotive parts under different lighting conditions are obtained, which improves the accuracy of detecting the detected mold under different lighting conditions and makes the detection more accurate;
[0064] The present invention obtains the weight Arg, G weight Agg, and B weight Abg. The advantage is that it can calculate the weight of the grayscale image conversion of the current detected mold image based on the current detected mold image, making it easier to distinguish the contours existing on the mold and increasing the accuracy of subsequent contour extraction. Description of the Drawings
[0065] Figure 1 is a functional block diagram of the system of the present invention;
[0066] Figure 2 is a schematic diagram of a grayscale histogram of the present invention;
[0067] Figure 3 The figure is a flow chart of the steps of the method of the present invention. DETAILED DESCRIPTION
[0068] 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 only 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 ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0069] Example 1, please refer to Figure 1 As shown, in the first aspect, the present application provides an online inspection system for automobile parts injection molds based on image analysis, including an image acquisition module, a defect acquisition module, a threshold acquisition module, and a defect comparison module;
[0070] The image acquisition module is used to acquire the image of the automobile component injection mold to be inspected, which is marked as the inspection mold image; the automobile component injection mold image acquired here only contains the image inside the mold;
[0071] The defect acquisition module is used to convert the detection mold image into a grayscale image to obtain a detection grayscale image, perform binarization processing on the detection grayscale image to obtain a detection binary image, and perform contour extraction on the detection binary image to obtain a defect contour;
[0072] The defect acquisition module is configured with a grayscale conversion strategy, which includes: obtaining the RGB value of each pixel point of the detection mold image and counting the number of pixels N;
[0073] Get the R weight Arg, G weight Agg, and B weight Abg in the RGB value; in the grayscale image conversion method, there is a weighted conversion method, which makes the grayscale image conversion more suitable by obtaining the weight suitable for the current detection mold image conversion;
[0074] Use the grayscale conversion formula to convert the RGB value into a grayscale value. The grayscale conversion formula is:
[0075] H=Arg*R+Agg*G+Abg*B; wherein H is the gray value, and R, G and B are three values in the RGB value.
[0076] The defect acquisition module is configured with a weight acquisition strategy, which includes: setting Ari to be an arithmetic progression group with a leading term of 0, a tolerance of z, and a range of 0 to 1; where z is a positive number between 0 and 1; and obtaining a set of Ari data by setting the arithmetic progression group;
[0077] At the same time, each Ari corresponds to a set of Agi data, where Agi data is an arithmetic progression group with the first term being 0, the common difference being z, and the range being 0 to 1-Ari; by setting the arithmetic progression group, a set of data Agi corresponding to each Ari is obtained;
[0078] Calculate the Abi corresponding to each group of Ari and Agi using the following formula: Abi = 1-Ari-Agi; the formula is obtained based on the weight sum being 1;
[0079] In practical applications, Ari is set to be an arithmetic progression with the first term of 0, the tolerance of z, and the range of 0 to 1; z is a positive number between 0 and 1. The smaller z is, the more accurate the subsequent calculation is, but the difficulty of calculation increases. z can be set according to the specific actual situation. When z is 0.2, Ari is 0, 0.2, 0.4, 0.6, 0.8 and 1. At the same time, each Ari corresponds to a set of Agi data, where Agi data is an arithmetic progression with the first term of 0, the tolerance of z, and the range of 0 to 1-Ari. That is, when Ari is 0, Agi is 0, 0.2, 0.4, 0.8 and 1. 6, 0.8 and 1, when Ari is 0.2, Agi is 0, 0.2, 0.4, 0.6 and 0.8, when Ari is 0.4, Agi is 0, 0.2, 0.4 and 0.6, when Ari is 0.6, Agi is 0, 0.2 and 0.4, when Ari is 0.8, Agi is 0 and 0.2, when Ari is 1, Agi is 0, and then use the formula Abi = 1-Ari-Agi to calculate all Abi. For example, when Ari is 0.2 and Agi is 0.6, Abi is 0.2;
[0080] Use the grayscale conversion formula to convert the RGB value into a grayscale value. The grayscale conversion formula is:
[0081] Hi=Ari*R+Agi*G+Abi*B; Hi is the gray value under different weights, and R, G and B are three values in RGB value;
[0082] Count the number Ni of each grayscale value of a grayscale image respectively;
[0083] Calculate the proportion pi of each gray level of the grayscale image respectively, the calculation formula is: pi = Ni / N; where i is a positive integer between 0 and 255, Ni is the number of the i-th gray level in the grayscale image, and pi is the proportion of the i-th gray level in the image;
[0084] Calculate the contrast value Ti of a grayscale image using the following formula:
[0085] Where Ti is the contrast value of a grayscale image;
[0086] Calculate Ti of all grayscale images, find the maximum value Tmax in Ti, obtain Tmax corresponding to Ari, Agi and Abi, marked as Arg, Agg and Abg respectively; According to the calculation formula of Ti, when all pi are equal, Ti is the maximum, so when the maximum value Tmax in Ti is obtained, the values of all pi are closest, making the grayscale image clearer, and the grayscale value of the contour and the detection mold image can be more easily distinguished;
[0087] In practical applications, according to Ari, Agi and Abi of all groups, the grayscale conversion formula: Hi = Ari*R+Agi*G+Abi*B is used to obtain Hi. For example, when Ari is 0.2, Agi is 0.6 and Abi is 0.2, and the RGB value of the pixel is (121, 72, 59), Hi is calculated to retain the integer, Hi is 79, all Hi are calculated, and the proportion pi of each grayscale level of the grayscale image is calculated. Then the contrast value Ti is calculated using the Ti calculation formula, and then the pi and Ti of each grayscale image are repeatedly calculated to obtain the maximum value Tmax of Ti. If Tmax corresponds to Ari, Agi and Abi of the grayscale conversion formula of 0.4, 0.4 and 0.2 respectively, then Arg, Agg and Abg are set to 0.4, 0.4 and 0.2.
[0088] The defect acquisition module is configured with a histogram establishment strategy, which includes: dividing the grayscale values of 0-255 into d equal intervals;
[0089] Count the frequency of grayscale values in each equally divided interval and mark it as interval frequency;
[0090] Draw a histogram with grayscale value as X-axis and interval frequency as Y-axis, marked as grayscale histogram;
[0091] For practical applications, please refer to Figure 2 As shown, the grayscale values 0-255 are divided into 8 equal intervals, such as 0-31, 31-63, ..., 223-255. The frequency of the grayscale values in each equal interval is counted and marked as interval frequency. The interval frequencies are 820,000, 2.91 million, 5.23 million, 940,000, 8.96 million, 8.35 million, 1.62 million and 1.39 million, respectively, and a histogram is drawn.
[0092] The image acquisition module is configured with a binarization strategy, which includes: obtaining the frequency X of all gray values;
[0093] If there is an interval whose frequency is less than X / d, it is marked as a low-frequency area, and the interval other than the low-frequency area is marked as a high-frequency area. It is determined whether there are high-frequency areas on both sides of the low-frequency area. If so, the low-frequency area is marked as the threshold area. The prerequisite here is a grayscale image with a bimodal distribution. If it is not present, d can be increased until a bimodal distribution appears, and then the grayscale image threshold is obtained.
[0094] The grayscale values of pixels in the area greater than the threshold are set to 255, and the grayscale values of pixels in the area less than or equal to the threshold are set to 0.
[0095] In practical applications, the frequency of all grayscale values is 30.22 million, X / d=3022 / 8=3.77 million, and the result is retained as an integer. By observing the histogram, the threshold area is obtained to be between 95 and 127, that is, the grayscale value of the pixel point with a grayscale value greater than 127 is set to 255, and the grayscale value of the pixel point with a grayscale value less than or equal to 127 is set to 0.
[0096] The defect acquisition module is configured with an acquisition contour strategy, which includes: if a pixel point with a gray value of 255 is adjacent to a pixel point with a gray value of 0, the pixel point with a gray value of 255 is marked as a defect edge pixel point;
[0097] Count all defect edge pixels and mark them as defect contours.
[0098] The threshold acquisition module is used to obtain the RGB thresholds of all pixels based on a normal automobile component injection mold image;
[0099] The threshold acquisition module is configured with a threshold acquisition strategy, which includes: obtaining a normal automobile component injection mold image at intervals of t within the first time, and marking it as a standard mold image; because the RGB values of normal automobile component injection mold images are different under the influence of natural light and light at different times, the automobile component injection mold images under different lighting conditions at different times are counted to make the subsequent RGB values more accurate. The t setting here can be set according to the speed of the specific lighting condition change. If the lighting changes quickly, t can be appropriately reduced, otherwise it will be increased, such as t = 30min;
[0100] The total number of pixels of a standard mold image is counted as U;
[0101] Count the R, G and B values of each pixel of each standard mold image, and mark them as Rb, Gb and Bb respectively;
[0102] Rb, Gb and Bb are processed by the RGB value range acquisition method to obtain: Q1, Q2, Q3, Q4, Q5 and Q6, where Q1 is the first quantile, Q2 is the second quantile, Q3 is the third quantile, Q4 is the fourth quantile, Q5 is the fifth quantile and Q6 is the sixth quantile;
[0103] The method for obtaining the RGB value range includes: quantiles, setting the quantiles of Rb to the first quantile Q1 and the second quantile Q2, wherein the specific method for obtaining the first quantile Q1 and the second quantile Q2 of Rb is:
[0104] Sort the Rb values of the pixels at the same position of each standard mold image from small to large, and set each Rb value to correspond to an Rb value serial number, which is an integer starting from 1;
[0105] Determine whether r1*U is an integer. If it is an integer, set the Rb value of the serial number r1*U as the first quantile Q1. If it is not an integer, find the average value of the Rb values corresponding to the serial numbers on both sides of r1*U and mark it as the first quantile Q1; where r1 is the first quantile ratio; the first quantile ratio is set between 0-0.5, and r1 is 0.25 for the best value;
[0106] Determine whether r2*U is an integer. If it is an integer, set the Rb value of the serial number r2*U as the second quantile Q2. If it is not an integer, find the average value of the Rb values corresponding to the serial numbers on both sides of r2*U and mark it as the second quantile Q2; where r2 is the second quantile ratio, r2 = (1 / r1-1)*r1; when r1 is 0.25, r2 = (1 / r1-1)*r1 = 0.75;
[0107] Similarly, the third quantile Q3 and the fourth quantile Q4 of Gb are obtained by using the RGB value range acquisition method, and the fifth quantile Q5 and the sixth quantile Q6 of Bb are obtained;
[0108] Set q1 = Q1-c*(Q2-Q1), q2 = Q2+c*(Q2-Q1), q3 = Q3-c*(Q4-Q3), q4 = Q3+c*(Q4-Q3), q5 = Q5-c*(Q6-Q5), q6 = Q6+c*(Q6-Q5), and find q1, q2, q3, q4, q5 and q6 for each pixel; q1 is the lower threshold of R of a pixel, q2 is the upper threshold of R of a pixel, q3 is the lower threshold of G of a pixel, and q4 is the lower threshold of G of a pixel. The upper threshold of G is q5, the lower threshold of B is q6, and the upper threshold of B is c. The setting of c can be adjusted according to the distribution of Rb. If the distribution is not concentrated, c can be appropriately increased. When r1 is 0.25, c is 1.5, which is the best. The overall method is to take Rb as an example, determine the value of Rb in the middle segment according to Q1 and Q2, and then subtract the data distribution between Q1 and Q2 from Q1 to obtain q1, and then add the value of the middle distribution value range multiplied by c to obtain q2.
[0109] In practical applications, U is 30222312. For example, r1 is 0.25 and r2 is 0.75. Since r2*U=7555578 is an integer, the Rb=102 value with the serial number 7555578 is set as the first quantile Q1. Since r2*U=22666734 is an integer, the Rb=132 value with the serial number 22666734 is set as the second quantile Q2. When c=1.5, q1=Q1-c*(Q2-Q1)=57, q2=Q2+c*(Q2-Q1)=189. Similarly, q3, q4, q5, q6 are obtained.
[0110] The defect comparison module is used to obtain the position of the defect contour on the original detection mold image based on the position of the defect contour in the detection binary image, mark the defect contour in the detection mold image as the detection contour, and determine whether the RGB values of all pixels in the detection contour exceed the RGB threshold. If the RGB threshold is exceeded, a defect warning and the detection contour position are sent to the processing end;
[0111] The defect comparison module is configured with a detection contour acquisition strategy, and the detection contour acquisition strategy includes: establishing a first plane rectangular coordinate system;
[0112] Get a pixel point at the intersection of the long side and the wide side of the detection binary image, take the center of the pixel point as the origin coordinate, the X axis is parallel to the long side of the detection binary image, the Y axis is parallel to the wide side of the detection binary image, and the detection binary image is in the first quadrant;
[0113] Get the center coordinates of all pixels included in the defect contour and mark them as contour coordinates;
[0114] Establishing a second plane rectangular coordinate system;
[0115] Obtain a pixel point at the intersection of the long side and the wide side of the detected mold image, and use the center of this pixel point as the origin coordinate. The X-axis is parallel to the long side of the detected binary image, and the Y-axis is parallel to the wide side of the detected binary image. The detected binary image is in the first quadrant;
[0116] Obtain all pixel points of the detected mold image at the contour coordinate positions and mark them as the detected contour;
[0117] Respectively obtain the R, G, and B values of all pixel points within the detected contour, and mark them as Rj, Gj, and Bj respectively;
[0118] The defect comparison module is configured with a strategy for comparing the RGB values of pixel points. The strategy for comparing the RGB values of pixel points includes: respectively determining whether each pixel point's Rj, Gj, and Bj simultaneously satisfy the RGB threshold range of its own pixel point: q1 < Rj < q2, q3 < Gj < q4, and q5 < Bj < q6. If satisfied, then this detected contour is the normal structure contour of the automotive part injection mold, and mark the detected contour as the normal contour. If not satisfied, then this detected contour is a defect of the automotive part injection mold, and send a defect warning and the position of the detected contour to the processing end; due to the complex internal structure of the mold, there are concavities, convexities, and holes, so the contours within the concavities, convexities, and holes are not necessarily defect contours;
[0119] In practical applications, if the Rj of this pixel point is 90, q1 is 57, and q2 is 189; then q1 < Rj < q2 is satisfied. If at the same time q3 < Gj < q4 and q5 < Bj < q6, that is, this detected contour is the normal structure contour of the automotive part injection mold;
[0120] Example 2, please refer to Figure 3 As shown, in the second aspect, the present application provides an online detection method for automotive part injection molds based on image analysis, including the following steps: Step S1, obtain an image of the automotive part injection mold to be detected and mark it as the detected mold image.
[0121] Step S2, convert the detected mold image into a grayscale image to obtain the detected grayscale image, perform binaryzation processing on the detected grayscale image to obtain the detected binary image, and perform contour extraction on the detected binary image to obtain the defect contour; Step S2 includes the following sub-steps:
[0122] Step S201, obtain the RGB value of each pixel point of the detected mold image and count the number of pixel points N;
[0123] Step S202, obtain the R weight Arg, G weight Agg, and B weight Abg in the RGB values;
[0124] Use the grayscale conversion formula to convert the RGB value into a grayscale value. The grayscale conversion formula is:
[0125] H=Arg*R+Agg*G+Abg*B; wherein H is a gray value, and R, G and B are three values in RGB values; step S202 includes the following sub-steps:
[0126] Step S2021, set Ari to be an arithmetic progression with a leading term of 0, a common difference of z, and a range of 0 to 1; wherein z is a positive number between 0 and 1;
[0127] Step S2022, each Ari corresponds to a set of Agi data, wherein the Agi data is an arithmetic progression set with a leading term of 0, a common difference of z, and a range of 0 to 1-Ari;
[0128] Step S2023, finding the Abi corresponding to each set of Ari and Agi, the calculation formula is: Abi = 1-Ari-Agi;
[0129] Step S2024, converting the RGB value into a grayscale value using a grayscale conversion formula, the grayscale conversion formula is: Hi = Ari*R + Agi*G + Abi*B; wherein Hi is a grayscale value under different weights, and R, G and B are three values in the RGB value;
[0130] Step S2025, counting the number Ni of each grayscale value of a grayscale image;
[0131] Step S2026, respectively calculate the proportion pi of each gray level of the gray image, the calculation formula is: pi = Ni / N; where i is a positive integer between 0 and 255, Ni is the number of the i-th gray level in the gray image, and pi is the proportion of the i-th gray level in the image;
[0132] Step S2027, calculate the contrast value Ti of a grayscale image, the calculation formula is:
[0133] Where Ti is the contrast value of a grayscale image;
[0134] Step S2028, calculate Ti of all grayscale images, find the maximum value Tmax in Ti, obtain Tmax corresponding to Ari, Agi and Abi, and mark them as Arg, Agg and Abg respectively.
[0135] Step S203, converting the RGB value into a grayscale value using a grayscale conversion formula, the grayscale conversion formula is:
[0136] H=Arg*R+Agg*G+Abg*B; where H is the gray value, and R, G and B are three values in RGB value;
[0137] Step S204, divide the grayscale values from 0 to 255 into d equal intervals;
[0138] Step S205, counting the frequency of the grayscale value of each equally divided interval respectively, and marking it as interval frequency;
[0139] Step S206, draw a histogram with the gray value as the X-axis and the interval frequency as the Y-axis, marked as a gray histogram;
[0140] Step S207, obtaining the frequency X of all gray values; if there is an interval whose frequency is less than X / d, it is marked as a low-frequency area, and the intervals other than the low-frequency area are marked as high-frequency areas, and it is determined whether both sides of the low-frequency area contain high-frequency areas. If so, the low-frequency area is marked as a threshold area;
[0141] Step S208, setting the grayscale value of the pixel points in the region greater than the threshold to 255, and setting the grayscale value of the pixel points in the region less than or equal to the threshold to 0;
[0142] Step S209: if a pixel with a grayscale value of 255 is adjacent to a pixel with a grayscale value of 0, mark the pixel with a grayscale value of 255 as a defect edge pixel; count all defect edge pixels and mark them as defect contours.
[0143] Step S3, obtaining RGB thresholds of all pixels based on a normal automobile component injection mold image; Step S3 includes the following sub-steps:
[0144] Step S301, obtaining a normal automobile component injection mold image at intervals of t within a first time period, and marking it as a standard mold image;
[0145] Step S302, counting the total number of pixels of a standard mold image as U; respectively counting the R, G and B values of each pixel of each standard mold image, and marking them as Rb, Gb and Bb respectively;
[0146] Step S303, processing Rb, Gb and Bb by the RGB value range acquisition method to obtain: Q1, Q2, Q3, Q4, Q5 and Q6 respectively, where Q1 is the first quantile, Q2 is the second quantile, Q3 is the third quantile, Q4 is the fourth quantile, Q5 is the fifth quantile and Q6 is the sixth quantile;
[0147] Step S304, the RGB value range acquisition method includes: quantile, setting the quantile of Rb to the first quantile Q1 and the second quantile Q2, wherein the specific method for obtaining the first quantile Q1 and the second quantile Q2 of Rb is:
[0148] Step S305, sorting the Rb values of the pixels at the same position of each standard mold image from small to large, setting each Rb value to correspond to an Rb value sequence number, and the Rb value sequence number is an integer starting from 1;
[0149] Step S306: Determine whether r1*U is an integer. If it is an integer, set the Rb value with the serial number r1*U as the first quartile Q1. If it is not an integer, calculate the average value of the Rb values corresponding to the serial numbers on both sides of r1*U, and mark it as the first quartile Q1; where r1 is the first quartile ratio.
[0150] Step S307: Determine whether r2*U is an integer. If it is an integer, set the Rb value with the serial number r2*U as the second quartile Q2. If it is not an integer, calculate the average value of the Rb values corresponding to the serial numbers on both sides of r2*U, and mark it as the second quartile Q2; where r2 is the second quartile ratio, and r2 = (1 / r1 - 1)*r1.
[0151] Step S308: Similarly, use the RGB value range acquisition method to obtain the third quartile Q3 and the fourth quartile Q4 of Gb, and obtain the fifth quartile Q5 and the sixth quartile Q6 of Bb.
[0152] Step S309: Set q1 = Q1 - c*(Q2 - Q1), q2 = Q2 + c*(Q2 - Q1), q3 = Q3 - c*(Q4 - Q3), q4 = Q3 + c*(Q4 - Q3), q5 = Q5 - c*(Q6 - Q5), q6 = Q6 + c*(Q6 - Q5), and calculate each pixel point q1, q2, q3, q4, q5, and q6; where q1 is the lower threshold of R for a pixel point, q2 is the upper threshold of R for a pixel point, q3 is the lower threshold of G for a pixel point, q4 is the upper threshold of G for a pixel point, q5 is the lower threshold of B for a pixel point, q6 is the upper threshold of B for a pixel point, and c is a constant.
[0153] Step S4: Based on the position of the defect contour in the detection binarized image, obtain the position of the defect contour on the original detection mold image. Mark the defect contour in the detection mold image as the detection contour, and determine whether the RGB values of all pixel points within the detection contour exceed the RGB threshold. If they exceed the RGB threshold, send a defect warning and the position of the detection contour to the processing end; Step S4 includes the following sub-steps:
[0154] Step S401: Respectively determine whether each pixel point Rj, Gj, and Bj simultaneously satisfies the RGB threshold range of its own pixel point: q1 < Rj < q2, q3 < Gj < q4, and q5 < Bj < q6. If it is satisfied, the detection contour is the normal injection mold structure contour of the automotive part, and mark the detection contour as the normal contour. If it is not satisfied, the detection contour is a defect of the injection mold of the automotive part, and send a defect warning and the position of the detection contour to the processing end.
[0155] It should be understood by those skilled in the art that the embodiments of the present invention can be provided as methods, systems or computer program products. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program codes. Among them, the storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read Only Memory, referred to as EPROM), programmable read-only memory (Programmable Red-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, disk or optical disk. These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0156] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
Claims
1. An online detection method for automobile parts injection molds based on image analysis, characterized in that: The steps include: Obtain an image of an injection mold of an automobile part to be inspected, and mark it as an inspection mold image; The inspection mold image is converted into a grayscale image to obtain an inspection grayscale image, the inspection grayscale image is binarized to obtain an inspection binary image, and the inspection binary image is contour extracted to obtain a defect contour; Obtain the RGB thresholds of all pixels based on a normal automobile parts injection mold image; Based on the position of the defect contour in the detection binary image, the position of the defect contour on the original detection mold image is obtained, and the defect contour in the detection mold image is marked as the detection contour. It is determined whether the RGB values of all pixels in the detection contour exceed the RGB threshold. If the RGB threshold is exceeded, a defect warning and the detection contour position are sent to the processing end.
2. The on-line detection method for automobile parts injection mold based on image analysis according to claim 1 is characterized in that: Converting the detection mold image into a grayscale image to obtain a detection grayscale image includes the following sub-steps: Get the RGB value of each pixel of the detected mold image and count the number of pixels N; Get the R weight Arg, G weight Agg, and B weight Abg in the RGB value; Use the grayscale conversion formula to convert the RGB value into a grayscale value. The grayscale conversion formula is: H=Arg*R+Agg*G+Abg*B; wherein H is the gray value, and R, G and B are three values in the RGB value.
3. The on-line detection method for automobile parts injection mold based on image analysis according to claim 2 is characterized in that: Obtaining the R weight Arg, G weight Agg, and B weight Abg in the RGB value includes the following sub-steps: Set Ari to be an arithmetic progression with the first term being 0 and the common difference being z, ranging from 0 to 1; where z is a positive number between 0 and 1; At the same time, each Ari corresponds to a set of Agi data, where Agi data is an arithmetic progression with the first term being 0, the common difference being z, and the range being 0 to 1-Ari; Calculate the Abi corresponding to each set of Ari and Agi using the following formula: Abi = 1-Ari-Agi; Use the grayscale conversion formula to convert the RGB value into a grayscale value. The grayscale conversion formula is: Hi=Ari*R+Agi*G+Abi*B; Hi is the gray value under different weights, and R, G and B are three values in RGB value; Count the number Ni of each grayscale value of a grayscale image respectively; Calculate the proportion pi of each gray level of the grayscale image respectively, the calculation formula is: pi = Ni / N; where i is a positive integer between 0 and 255, Ni is the number of the i-th gray level in the grayscale image, and pi is the proportion of the i-th gray level in the image; Calculate the contrast value Ti of a grayscale image using the following formula: Calculate Ti of all grayscale images, find the maximum value Tmax in Ti, and obtain Tmax corresponding to Ari, Agi and Abi, marked as Arg, Agg and Abg respectively.
4. The on-line detection method for automobile parts injection mold based on image analysis according to claim 3 is characterized in that: Binarizing the detection grayscale image to obtain a detection binary image includes the following sub-steps: Divide the grayscale value from 0 to 255 into d equal intervals; Count the frequency of grayscale values in each equally divided interval and mark it as interval frequency; A histogram is drawn with grayscale value as the X-axis and interval frequency as the Y-axis, marked as a grayscale histogram.
5. The on-line detection method for automobile parts injection mold based on image analysis according to claim 4 is characterized in that: Binarizing the detection grayscale image to obtain a detection binary image also includes the following sub-steps: Get the frequency X of all gray values; If there is an interval whose frequency is less than X / d, it is marked as a low-frequency area, and the intervals other than the low-frequency area are marked as high-frequency areas. It is determined whether there are high-frequency areas on both sides of the low-frequency area. If so, the low-frequency area is marked as a threshold area. The grayscale values of pixels in the area greater than the threshold are set to 255, and the grayscale values of pixels in the area less than or equal to the threshold are set to 0.
6. The on-line detection method for automobile parts injection mold based on image analysis according to claim 5 is characterized in that: The following sub-steps are included in extracting the contour of the detection binary image to obtain the defect contour: If a pixel with a gray value of 255 is adjacent to a pixel with a gray value of 0, the pixel with a gray value of 255 is marked as a defect edge pixel; Count all defect edge pixels and mark them as defect contours.
7. The on-line detection method for automobile parts injection mold based on image analysis according to claim 6 is characterized in that: Obtaining the RGB thresholds of all pixels based on a normal automotive parts injection mold image includes the following sub-steps: In the first time, a normal automobile component injection mold image is obtained at every time interval t, and marked as a standard mold image; The total number of pixels of a standard mold image is counted as U; Count the R, G and B values of each pixel of each standard mold image, and mark them as Rb, Gb and Bb respectively; Rb, Gb and Bb are processed by the RGB value range acquisition method to obtain: Q1, Q2, Q3, Q4, Q5 and Q6, where Q1 is the first quantile, Q2 is the second quantile, Q3 is the third quantile, Q4 is the fourth quantile, Q5 is the fifth quantile and Q6 is the sixth quantile; The method for obtaining the RGB value range includes: setting the quantile of Rb to the first quantile Q1 and the second quantile Q2, wherein the specific method for obtaining the first quantile Q1 and the second quantile Q2 of Rb is: Sort the Rb values of the pixels at the same position of each standard mold image from small to large, and set each Rb value to correspond to an Rb value serial number, which is an integer starting from 1; Determine whether r1*U is an integer. If it is an integer, set the Rb value of the serial number r1*U as the first quantile Q1. If it is not an integer, find the average of the Rb values corresponding to the serial numbers on both sides of r1*U and mark it as the first quantile Q1; where r1 is the first quantile ratio; Determine whether r2*U is an integer. If it is an integer, set the Rb value of the serial number r2*U as the second quantile Q2. If it is not an integer, find the average of the Rb values corresponding to the serial numbers on both sides of r2*U and mark it as the second quantile Q2; where r2 is the second quantile ratio, r2 = (1 / r1-1)*r1; Similarly, the third quantile Q3 and the fourth quantile Q4 of Gb are obtained by using the RGB value range acquisition method, and the fifth quantile Q5 and the sixth quantile Q6 of Bb are obtained; Set \(q1 = Q1 - c*(Q2 - Q1)\), \(q2 = Q2 + c*(Q2 - Q1)\), \(q3 = Q3 - c*(Q4 - Q3)\), \(q4 = Q3 + c*(Q4 - Q3)\), \(q5 = Q5 - c*(Q6 - Q5)\), \(q6 = Q6 + c*(Q6 - Q5)\), and find each pixel point \(q1\), \(q2\), \(q3\), \(q4\), \(q5\) and \(q6\); where \(q1\) is the lower threshold of \(R\) for a pixel point, \(q2\) is the upper threshold of \(R\) for a pixel point, \(q3\) is the lower threshold of \(G\) for a pixel point, \(q4\) is the upper threshold of \(G\) for a pixel point, \(q5\) is the lower threshold of \(B\) for a pixel point, \(q6\) is the upper threshold of \(B\) for a pixel point, and \(c\) is a constant.
8. The on-line detection method for automobile parts injection mold based on image analysis according to claim 7 is characterized in that: Obtaining the position of the defect contour on the original detection mold diagram based on the position of the defect contour in the detection binary image includes the following sub-steps: Establish a first rectangular coordinate system. Obtain a pixel point at the intersection of the long side and the wide side of the detection binary image, take the center of this pixel point as the origin coordinate, the \(X\)-axis is parallel to the long side of the detection binary image, the \(Y\)-axis is parallel to the wide side of the detection binary image, and the detection binary image is in the first quadrant. Obtain the central coordinates of all pixel points included in the defect contour, and mark them as contour coordinates. Establish a second rectangular coordinate system. Obtain a pixel point at the intersection of the long side and the wide side of the detection mold diagram, take the center of this pixel point as the origin coordinate, the \(X\)-axis is parallel to the long side of the detection binary image, the \(Y\)-axis is parallel to the wide side of the detection binary image, and the detection binary image is in the first quadrant. Obtain all pixel points of the detection mold diagram at the contour coordinate position, and mark them as the detection contour. Respectively obtain the \(R\), \(G\) and \(B\) values of all pixel points within the detection contour, and mark them as \(Rj\), \(Gj\) and \(Bj\) respectively.
9. The on-line detection method for automobile parts injection mold based on image analysis according to claim 8, characterized in that: Judge whether the RGB values of all pixel points within the detection contour exceed the RGB threshold. If they exceed the RGB threshold, the steps for sending a defect warning and the defect contour to the processing end are as follows: Respectively judge whether each pixel point \(Rj\), \(Gj\) and \(Bj\) simultaneously satisfies the RGB threshold range of its own pixel point: \(q1 < Rj < q2\), \(q3 < Gj < q4\) and \(q5 < Bj < q6\). If it is satisfied, the detection contour is the normal structure contour of the automotive part injection mold, mark the detection contour as the normal contour. If it is not satisfied, the detection contour is a defect of the automotive part injection mold, and send a defect warning and the position of the detection contour to the processing end.
10. An online detection system for automobile parts injection molds based on image analysis, used to implement the online detection method for automobile parts injection molds based on image analysis according to any one of claims 1 to 9, characterized in that: It includes an image acquisition module, a defect acquisition module, a threshold acquisition module, and a defect comparison module; The image acquisition module is used to acquire the image of the automotive part injection mold to be detected, and mark it as the detection mold diagram; The defect acquisition module is used to convert the detection mold diagram into a grayscale image to obtain a detection grayscale image, perform binaryzation processing on the detection grayscale image to obtain a detection binary image, and perform contour extraction on the detection binary image to obtain a defect contour; The threshold acquisition module is used to obtain the RGB threshold of all pixel points based on the image of the normal automotive part injection mold. The defect comparison module is used to obtain the position of the defect contour on the original detection mold image based on the position of the defect contour in the detection binary image, mark the defect contour in the detection mold image as the detection contour, and determine whether the RGB values of all pixels in the detection contour exceed the RGB threshold. If the RGB threshold is exceeded, a defect warning and the detection contour position are sent to the processing end.
Citation Information
Patent Citations
A method, computer-readable storage medium, and device for mold defect detection based on image recognition.
CN112465809B
Device and method for detecting micro defects on bright and clean surface of metal part based on machine vision
CN102590218A
PCB color change defect detection method, device, equipment and medium
CN115861327A
Method and system for detecting surface defects of titanium alloy forge piece
CN118379286A
Method and apparatus for inspecting stripe like defect
JP1999048457A