Machine vision-based method and system for detecting defects in production of automobile part molds
By performing grayscale difference range analysis and region division binarization on the scanned images, and combining historical data to analyze crack depth, the problems of misidentification and inaccurate positioning of component flaw detection results in the existing technology are solved, achieving higher detection accuracy and effectiveness.
Patent Information
- Application Number
- CN202411762680.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2044-12-03
AI Technical Summary
Existing component flaw detection technologies use preset thresholds during binarization processing, which makes it difficult to adapt to the characteristics of different components. This leads to problems such as misidentification of cracks and inaccurate location of damage in the test results.
By performing grayscale neighbor difference range analysis on the scanned image, dividing the region and performing binarization processing, and combining historical data to analyze the crack depth, a machine vision-based flaw detection method is adopted, including scanning, grayscale neighbor difference analysis, region division and binarization processing.
It improves the accuracy and effectiveness of component flaw detection, can accurately identify cracks and analyze their depth, avoids misidentification and incorrect binarization processing, and enhances the reliability of the detection results.
Smart Images

Figure CN119579569B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to the technical field of part flaw detection, in particular to a flaw detection method and system for automobile part mold production based on machine vision. BACKGROUND
[0002] Part flaw detection technology refers to a non-destructive testing method for detecting potential defects, damages or abnormalities in metal products. The main purpose is to check the parts to ensure their quality and reliability without destructive testing or disassembly.
[0003] The existing part flaw detection technology usually obtains a detection image after detecting the part, and then binarizes the detection image for computer flaw detection analysis. However, the preset threshold is usually used for binarization division. Different parts have different characteristics, and different detection results will be obtained during detection. Therefore, it is difficult to adapt to the flaw detection analysis of different parts under different conditions by using the preset threshold for binarization processing of the detection image. The binarized image obtained by processing is prone to be unable to identify the cracks in the part. For example, in the Chinese patent with the application publication number CN111445434A, an image processing method of a metal workpiece grade sorting system is disclosed. This scheme does not analyze different thresholds for different inspected components, which leads to the problem that the binarized image is prone to be unable to identify the damage. In addition, the existing part flaw detection technology can only detect whether the part is damaged, but cannot detect the specific position of the damage, so as to check the subsequent processing steps of the part. The existing part flaw detection technology also has the problems that the preset threshold is usually used for binarization division when the detection result is binarized, and the position of the damage in the part cannot be detected, which leads to the problem that the part flaw detection result is prone to error. SUMMARY
[0004] The present application aims to at least solve one of the technical problems in the prior art. The scanning image of the part is obtained by scanning the part, the image pixel points in the scanning image are analyzed to obtain a gray level neighborhood difference range, the scanning image is regionally divided based on the gray level neighborhood difference range, the divided regions are binarized after the division, the binarized image is analyzed, it is judged whether the part has cracks, and the crack depth of the cracks is analyzed based on historical data, so as to solve the problem that the preset threshold is usually used for binarization division when the detection result is binarized in the existing part flaw detection technology, and the position of the damage in the part cannot be detected, which leads to the problem that the part flaw detection result is prone to error.
[0005] To achieve the above-mentioned purpose, in a first aspect, the present application provides a flaw detection method for automobile part mold production based on machine vision, comprising the following steps:
[0006] scanning the part to obtain a scanned image;
[0007] analyzing the scanned image to determine a gray level neighborhood difference range of the scanned image;
[0008] dividing the scanned image into regions based on the gray level neighborhood difference range to obtain divided regions;
[0009] performing binary processing on the divided regions to obtain a binary image;
[0010] analyzing the binary image to determine whether the part has a crack and analyze the depth of the crack.
[0011] Further, the scanning of the part is performed by using X-ray to scan and detect the part, and a scanned image is obtained after scanning, wherein the scanned image is a gray scale image.
[0012] Further, the analyzing of the scanned image includes the following sub-steps:
[0013] obtaining an image resolution of the scanned image, wherein the image resolution is in a format of CxL, and C and L are both non-zero natural numbers;
[0014] numbering image pixels in the scanned image, and naming the image pixels as pixel numbers, which are represented by P(n, m), wherein n and m are column and row serial numbers of the pixel numbers, and n and m are both non-zero natural numbers and 1≤n≤C and 1≤m≤L;
[0015] obtaining a gray level value of the image pixels, and naming the gray level value as a pixel gray level, and finding a maximum value in the pixel gray level, and marking the maximum value as a maximum gray level;
[0016] marking an image pixel corresponding to the maximum gray level as an analyzed point, and marking a pixel number corresponding to the maximum gray level as an analyzed number;
[0017] further analyzing the analyzed point and the analyzed number to determine a gray level neighborhood difference range of the scanned image.
[0018] Further, the further analyzing of the analyzed point and the analyzed number includes the following sub-steps:
[0019] n and m of the analyzed number are represented by i and j respectively, and the analyzed number is P(i, j), i.e., the analyzed number is in the ith column and the jth row;
[0020] Acquire pixel gray scales of P(i-1, j-1), P(i, j-1), P(i+1, j-1), P(i-1, j), P(i+1, j), P(i-1, j+1), P(i, j+1) and P(i+1, j+1), and name them as pixel first gray scale, pixel second gray scale, pixel third gray scale, pixel fourth gray scale, pixel fifth gray scale, pixel sixth gray scale, pixel seventh gray scale and pixel eighth gray scale, collectively called adjacent cell gray scales;
[0021] Mark the gray scale value of the point to be analyzed as an analyzed gray scale, calculate the value of the analyzed gray scale minus the adjacent cell gray scale, and name the calculation result as a neighborhood gray scale difference;
[0022] Set P(i-1, j-1), P(i, j-1), P(i+1, j-1), P(i-1, j), P(i+1, j), P(i-1, j+1), P(i, j+1) and P(i+1, j+1) as the point to be analyzed in turn, and calculate the neighborhood gray scale difference again;
[0023] Integrate all the neighborhood gray scale differences, find the maximum value in the neighborhood gray scale differences, mark it as the maximum difference value, and represent it by the symbol D;
[0024] The gray scale neighborhood difference range is [-D, D].
[0025] Further, based on the gray scale neighborhood difference range, the scanned image is regionally divided to obtain a division region, including the following sub-steps:
[0026] Mark the image pixel points that have not been divided as pixel points to be divided, and mark the image pixel points that have been divided as divided pixel points;
[0027] Find the minimum value of n+m in P(n, m) of the pixel point to be divided, mark the corresponding pixel point to be divided as a starting point to be divided, and mark the corresponding pixel gray scale as an analyzed gray scale;
[0028] Acquire the pixel gray scale of the image pixel point adjacent to P(n, m), and name it as an adjacent gray scale;
[0029] Calculate |analyzed gray scale-adjacent gray scale|, mark the calculation result as an adjacent difference value, and compare the adjacent difference value with the gray scale neighborhood difference range, if the adjacent difference value is within the gray scale neighborhood difference range, output a homologous signal, and if the adjacent difference value is not within the gray scale neighborhood difference range, output a non-homologous signal;
[0030] If a homologous signal is output, mark the corresponding image pixel point as a homologous pixel point, analyze all the adjacent gray scales of P(n, m), and find all the homologous pixel points;
[0031] Further analyze the homologous pixel points to obtain a division region.
[0032] Further, the further analysis of the homologous pixel point comprises the following sub-steps:
[0033] Taking the homologous pixel point as a new pixel point to be divided, the new homologous pixel point is analyzed again until no homologous signal is output; in the process of analyzing the homologous pixel point, the image pixel point which has output the homologous signal no longer participates in the analysis of adjacent gray scale;
[0034] After stopping the analysis, all image pixel points as the pixel points to be divided in the current region division are marked as divided pixel points and integrated into the same division region;
[0035] The remaining pixel points to be divided are continuously analyzed until there is no pixel point to be divided, and a plurality of division regions are obtained.
[0036] Further, the division region is subjected to a binaryzation process to obtain a binaryzation image, comprising the following sub-steps:
[0037] The division region is named as the Hth region according to the order of division, and H is a non-zero natural number;
[0038] In the binaryzation image, the black region is named as a black area, and the white region is named as a white area;
[0039] The first region is set as the black area;
[0040] The remaining division regions are divided according to the order of H from small to large, and it is found whether the division region adjacent to the Hth region is a black area or a white area, if it is a black area, it is set as a white area, if it is a white area, it is set as a black area, if it is adjacent to both a black area and a white area, a black and white analysis signal is output, if none is divided, the Hth region is skipped, the H+1th region is analyzed first, after the analysis is completed, the Hth region is analyzed again, and the division region which has been analyzed is not analyzed repeatedly;
[0041] If the black and white analysis signal is output, the number of image pixel points contained in the adjacent white area and black area is found, respectively marked as the number of black areas and the number of white areas, if the number of black areas is greater than the number of white areas, the Hth region is set as a black area, if the number of black areas is less than the number of white areas, the Hth region is set as a white area, if the number of black areas is equal to the number of white areas, the Hth region is skipped first, and the next division region is analyzed, and then analyzed again after the analysis is completed;
[0042] After the analysis of the division region is completed, a binaryzation image is obtained.
[0043] Further, the binaryzation image is analyzed to determine whether a crack exists in the part and analyze the depth of the crack, comprising the following sub-steps:
[0044] The binary image is identified by a crack identification algorithm to determine whether the part has a crack. If yes, a crack signal is output. If no, a non-crack signal is output.
[0045] If the crack signal is output, the crack is analyzed by a crack depth analysis function to obtain the crack depth.
[0046] The crack depth analysis function is obtained from a crack depth analysis scheme.
[0047] Further, the crack depth analysis scheme includes the following sub-steps:
[0048] The division area where the crack is located is marked as a crack area, and the division area adjacent to the crack area is marked as a normal area.
[0049] The image pixel points in the crack area of the scanning image are marked as crack pixel points, and the gray value of the crack pixel points is marked as crack gray value. The image pixel points in the normal area of the scanning image are marked as normal pixel points, and the gray value of the normal pixel points is marked as normal gray value.
[0050] The average value of the normal gray value is calculated and marked as the normal average gray value. The average value of the crack gray value is calculated and marked as the crack average gray value.
[0051] The crack depth history database is read to obtain the historical data of the crack depth, the crack average gray value and the normal average gray value, which are marked as the historical depth, the historical crack gray value and the historical normal gray value, respectively.
[0052] The historical normal gray value is subtracted from the historical crack gray value, and the calculation result is marked as the crack difference gray value.
[0053] A rectangular coordinate system is established with the crack difference gray value as the X-axis and the historical depth as the Y-axis, named as the difference-depth coordinate system, and the crack difference gray value and the corresponding historical depth are recorded in the difference-depth coordinate system.
[0054] The difference-depth coordinate system is subjected to logarithmic regression to obtain the crack depth analysis function.
[0055] In a second aspect, the application provides a crack detection system for automobile part mold production based on machine vision, which comprises a scanning module, a gray difference analysis module, a region division module, a binary processing module and a crack analysis module. The scanning module, the gray difference analysis module, the region division module and the crack analysis module are respectively connected with the binary processing module.
[0056] The scanning module is used to scan the part to obtain a scanning image.
[0057] The gray scale neighborhood difference analysis module is used for analyzing the scanned image to determine a gray scale neighborhood difference range of the scanned image.
[0058] The region division module is used for dividing the scanned image into regions based on the gray scale neighborhood difference range to obtain divided regions.
[0059] The binarization processing module is used for performing binarization processing on the divided regions to obtain a binarization image.
[0060] The crack analysis module is used for analyzing the binarization image to determine whether the part has cracks and analyze the depth of the cracks.
[0061] The present application has the following advantages: the present application analyzes the image pixels in the scanned image, analyzes the maximum gray scale and each adjacent image pixel, obtains the gray scale neighborhood difference range of the scanned image, and has the advantage that the maximum gray scale can ensure that the surrounding image pixels are all normal regions of the part, and the gray scale difference between them and the adjacent image pixels can obtain the amplitude of the gray scale change of the same region in the scanned image, thereby improving the accuracy and effectiveness of the part detection.
[0062] The present application analyzes the scanned image based on the gray scale neighborhood difference range, combines the same parts into the same divided region, and obtains a plurality of divided regions through multiple divisions, and has the advantage that binarization processing of the scanned image based on the threshold of the gray scale value can cause black spots in the image or damage regions to be classified as normal regions, which further causes errors in the part detection result, and therefore, the same image pixels are integrated into a region based on the gray scale neighborhood difference range, and the divided regions are binarized, which can avoid black spots in the image or damage regions being classified as normal regions, thereby improving the accuracy of the part detection.
[0063] The present application performs binarization processing on the divided regions, and distinguishes the adjacent divided regions by assigning different colors to them, and has the advantage that if the threshold of the gray scale value is set to divide, the adjacent divided regions can be set to white or black, which cannot be distinguished in the binarization image, and therefore, a black region is set first, and then the adjacent divided regions are divided, which can avoid the above situation, thereby improving the accuracy of the part detection and the accuracy of the binarization division.
[0064] The application calculates the crack difference gray value by analyzing historical data, combining the crack average gray value and the normal average gray value, and then obtains the relationship between the crack difference gray value and the crack depth, i.e. the crack depth analysis function, based on the analysis of historical data, and the advantage is that the gray value of the scanning image of the part usually has a certain rule, and the crack is inside the part, and the gray value difference between different depths and the normal area also has a certain rule, and generally the deeper the crack depth, the larger the gray value difference, so the relationship between the crack difference gray value and the crack depth can be analyzed through historical data, and then the crack depth is calculated, and whether the processing technology has a problem can be judged based on the crack depth, thereby improving the effectiveness of the part detection and the rationality of the part processing. BRIEF DESCRIPTION OF DRAWINGS
[0065] Figure 1 A step flow chart of the method of the application;
[0066] Figure 2 A scanning image of the application;
[0067] Figure 3 A schematic view of a divided region obtained by the first division of the application;
[0068] Figure 4 A binary image of the application;
[0069] Figure 5 An existing binary processing image of the application;
[0070] Figure 6 A schematic view of a normal area and a crack area of the application;
[0071] Figure 7 A difference-depth coordinate system of the application;
[0072] Figure 8 A principle block diagram of the system of the application. DETAILED DESCRIPTION
[0073] The technical solutions in the embodiments of the application will be clearly and completely described below with reference to the drawings in the embodiments of the application. Obviously, the described embodiments are only part of the embodiments of the application, rather than all the embodiments of the application. Based on the embodiments in the application, all other embodiments obtained by a person of ordinary skill in the art without creative labor fall within the protection scope of the application.
[0074] Embodiment 1, please refer to Figure 1 As shown in the first aspect, the application provides a flaw detection method for automobile part mold production based on machine vision, which comprises the following steps:
[0075] Please refer to Figure 2As shown, in step S1, the part is scanned to obtain a scanning image; the part is scanned by X-ray scanning detection, and the scanning image is obtained after scanning, which is a gray image;
[0076] In a specific implementation, the X-ray scanning detection of the part is performed by using an existing X-ray scanning technology, and the scanning image is obtained as shown in Figure 2
[0077] In actual application, the pixel value in the image will have a certain change rule when the image is displayed in the computer, and theoretically, the colors of the same parts of the image are the same, but when the image is displayed, it will be displayed as an image composed of similar color values, rather than a single color, which makes the image look more natural, and the change range of different image color values is also different, so it needs to be analyzed; step S2 includes the following sub-steps:
[0078] Step S201, obtaining the image resolution of the scanning image, the format of the image resolution is CxL, and C and L are both non-zero natural numbers;
[0079] Step S202, numbering the image pixels in the scanning image, named as pixel point number, represented by symbol P(n,m), n and m are the column sequence number and row sequence number of the pixel point number respectively, n and m are both non-zero natural numbers and 1≤n≤C, 1≤m≤L;
[0080] Step S203, obtaining the gray value of the image pixel, named as pixel gray, finding the maximum value in the pixel gray, marked as the maximum gray;
[0081] Step S204, marking the image pixel corresponding to the maximum gray as an analysis point, and marking the corresponding pixel point number as an analysis number;
[0082] In a specific implementation, the image resolution is obtained as 1176x710, C=1176, L=710, that is, the pixel point number is P(1,1) to P(1176,710); the maximum gray is obtained as 243, and the corresponding analysis point is P(424,496);
[0083] Step S205, further analyzing the analysis point and the analysis number to determine the gray difference range of the scanning image;
[0084] Step S205 includes the following sub-steps:
[0085] Step S2051, n and m of the analysis number are represented by i and j respectively, the analysis number is P(i,j), that is, the analysis number is in the ith column and the jth row;
[0086] Step S2052, the pixel gray scale of P(i-1, j-1), P(i, j-1), P(i+1, j-1), P(i-1, j), P(i+1, j), P(i-1, j+1), P(i, j+1) and P(i+1, j+1) are acquired, which are named as pixel first gray scale, pixel second gray scale, pixel third gray scale, pixel fourth gray scale, pixel fifth gray scale, pixel sixth gray scale, pixel seventh gray scale and pixel eighth gray scale, collectively called as adjacent cell gray scale;
[0087] In the embodiment, the to-be-analyzed mark is P(i, j), i.e. i=424, j=496; the pixel gray scale of P(423, 495), P(424, 495), P(425, 495), P(423, 496), P(424, 496), P(425, 496), P(423, 498), P(424, 498) and P(425, 498) are acquired, which are 237, 240, 236, 238, 226, 237, 237 and 234, i.e. pixel first gray scale to pixel eighth gray scale;
[0088] Step S2053, the gray scale value of the to-be-analyzed point is marked as to-be-analyzed gray scale, the value of to-be-analyzed gray scale-adjacent cell gray scale is calculated, and the calculation result is named as adjacent gray scale difference;
[0089] Step S2054, P(i-1, j-1), P(i, j-1), P(i+1, j-1), P(i-1, j), P(i+1, j), P(i-1, j+1), P(i, j+1) and P(i+1, j+1) are set as the to-be-analyzed point in turn, and the adjacent gray scale difference is calculated again;
[0090] Step S2055, all the adjacent gray scale differences are integrated, the maximum value in the adjacent gray scale difference is found and marked as maximum difference value, which is represented by symbol D;
[0091] Step S2056, the gray scale adjacent difference range is [-D, D];
[0092] In the implementation, the gray scale to be analyzed is 243, and the gray scales of the adjacent grids are subtracted in sequence to obtain the neighborhood gray scale differences including 6, 3, 7, 5, 17, 6, 6 and 9. After the calculation is completed, P(423, 495) is set as the point to be analyzed, at this time i = 423 and j = 495, the gray scales of the adjacent grids are obtained in sequence as 237, 235, 235, 236, 240, 234, 238 and 243, the gray scale to be analyzed is 237 at this time, and the neighborhood gray scale differences obtained by calculation include 0, 2, 2, 1, 3, 3, 1 and 6. P(424, 495) is set as the point to be analyzed, and the above steps are repeated until P(425, 498) is set as the point to be analyzed and the analysis is completed, the analysis is stopped, the neighborhood gray scale differences obtained by each analysis are integrated, the repeated neighborhood gray scale differences are recorded only once, and the neighborhood gray scale differences include 0, 1, 2, 3, 5, 6, 7, 9, 11, 13, 14, 16 and 17. It is found that the maximum difference value is 17, that is, the gray scale neighborhood difference range is [-17, 17].
[0093] In step S3, the scanning image is regionally divided based on the gray scale neighborhood difference range to obtain a divided region; step S3 includes the following sub-steps:
[0094] In step S301, the image pixel points not yet divided are marked as pixel points to be divided, and the image pixel points already divided are marked as pixel points already divided.
[0095] In step S302, the minimum value of n+m in P(n,m) of the pixel point to be divided is found, the corresponding pixel point to be divided is marked as a starting point to be divided, and the corresponding pixel gray scale is marked as a gray scale to be divided.
[0096] In step S303, the pixel gray scale of the image pixel point adjacent to P(n,m) is obtained and named as an adjacent gray scale.
[0097] In step S304, |gray scale to be divided-adjacent gray scale| is calculated, the calculation result is marked as an adjacent difference value, and the adjacent difference value is compared with the gray scale neighborhood difference range. If the adjacent difference value is within the gray scale neighborhood difference range, a homologous signal is output. If the adjacent difference value is not within the gray scale neighborhood difference range, a non-homologous signal is output.
[0098] In step S305, if the homologous signal is output, the corresponding image pixel point is marked as a homologous pixel point, and all the adjacent gray scales of P(n,m) are analyzed to find all the homologous pixel points.
[0099] In the embodiment, if the value of n+m of P(1, 1) is the minimum, P(1, 1) is set as the starting point to be divided, and the gray scale to be divided is 0. The image pixel points adjacent to P(1, 1) include P(1, 2), P(2, 1) and P(2, 2), and the adjacent gray scales are 0, 0 and 3 in turn. The adjacent difference values are 0, 0 and 3 in turn. Through comparison, it is found that the adjacent difference values are all within the gray scale adjacent difference range, so the homogenous signals are output, and P(1, 2), P(2, 1) and P(2, 2) are all marked as homogenous pixel points.
[0100] In step S306, the homogenous pixel points are further analyzed to obtain the division region.
[0101] Step S306 includes the following sub-steps:
[0102] In step S3061, the homogenous pixel points are taken as new pixel points to be divided, and the new homogenous pixel points are analyzed again until no homogenous signal is output. In the process of analyzing the homogenous pixel points, the image pixel points which have output the homogenous signal do not participate in the analysis of the adjacent gray scales.
[0103] In the embodiment, the homogenous pixel points are set as new pixel points to be divided according to the order of the time when the homogenous signals are output. P(1, 2) is taken as a pixel point to be divided. The image pixel points adjacent to P(1, 2) include P(1, 1), P(1, 3), P(2, 1), P(2, 2) and P(2, 3). P(1, 1) has been analyzed as a pixel point to be divided, P(2, 1) and P(2, 2) are homogenous pixel points, so P(1, 1), P(2, 1) and P(2, 2) are excluded. At this time, P(1, 3) and P(2, 3) are left. The adjacent gray scales are 1 and 2 respectively, and the adjacent difference values are 1 and 2 respectively. Through comparison, it is found that the adjacent difference values are all within the gray scale adjacent difference range, so the homogenous signals are output, and P(1, 3) and P(2, 3) are marked as homogenous pixel points. At this time, the homogenous pixel points include P(2, 1), P(2, 2), P(1, 3) and P(2, 3). The next homogenous pixel point is taken as a pixel point to be divided to continue the analysis until there is no homogenous pixel point.
[0104] Referring to FIG. 6, Figure 3 As shown in FIG. 6, in step S3062, after the analysis is stopped, all the image pixel points which are taken as pixel points to be divided in this region division are marked as divided pixel points and integrated into the same division region.
[0105] In step S3063, the remaining pixel points to be divided are continuously analyzed until there is no pixel point to be divided, and a plurality of division regions are obtained.
[0106] In the embodiment, the division region obtained by the first division is as shown in FIG. 7.Figure 3 As shown in the figure, the divided regions are separated by black curves. In order to observe the existence of the black curves, the image is lightened in this embodiment. In actual analysis, the parameters of the image are not changed. The remaining pixel points to be divided are analyzed until there is no pixel point to be divided, and a plurality of divided regions are obtained.
[0107] In step S4, the divided regions are binarized to obtain a binarized image. Step S4 includes the following sub-steps:
[0108] In step S401, the divided regions are named as the Hth region according to the order of division, and H is a non-zero natural number.
[0109] In step S402, in the binarized image, the black region is named as a black area, and the white region is named as a white area.
[0110] In step S403, the first region is set as the black area.
[0111] In step S404, the remaining divided regions are divided according to the order of H from small to large. It is determined whether the divided region adjacent to the Hth region is a black area or a white area. If it is a black area, it is set as a white area. If it is a white area, it is set as a black area. If it is adjacent to both a black area and a white area, a black-and-white analysis signal is output. If none of the above conditions is met, the Hth region is skipped. The (H+1)th region is analyzed first. After the analysis is completed, the Hth region is analyzed again. The divided region that has been analyzed is not analyzed repeatedly.
[0112] In step S405, if the black-and-white analysis signal is output, the number of image pixel points contained in the adjacent white area and black area is determined, which is marked as the number of black areas and the number of white areas, respectively. If the number of black areas is greater than the number of white areas, the Hth region is set as a black area. If the number of black areas is less than the number of white areas, the Hth region is set as a white area. If the number of black areas is equal to the number of white areas, the Hth region is skipped. After the analysis of the next divided region is completed, the Hth region is analyzed again.
[0113] Please refer to Figure 4 to Figure 5 As shown in the figure, after the analysis of the divided regions is completed, a binarized image is obtained.
[0114] In the specific implementation, the first region is set as a black area. The second region is analyzed. The second region is adjacent to the first region, the third region, the fourth region, and the fifth region. Since the first region is a black area and the remaining regions are not divided, the second region is set as a white area. The next divided region is analyzed until the analysis of all the divided regions is completed. The binarized image is as shown in the figure Figure 4 In order to intuitively feel the difference between the processing of this embodiment and the existing binarization processing, this embodiment provides an existing binarization processing image, as shown in the figureFigure 5 as shown.
[0115] Step S5, analyzing the binary image to determine whether the part has a crack and analyze the depth of the crack; Step S5 includes the following sub-steps:
[0116] Step S501, identifying the binary image by a crack identification algorithm to determine whether the part has a crack, if so, output a crack signal; if not, output a crack-free signal;
[0117] Step S502, if the crack signal is output, the crack is analyzed by a crack depth analysis function to obtain the crack depth;
[0118] In specific implementation, the crack identification algorithm uses an existing crack identification algorithm model, and the crack identification algorithm model identifies that the part has a crack, and then outputs a crack signal, and the crack is analyzed by the crack depth analysis function;
[0119] Step S503, the crack depth analysis function is obtained from a crack depth analysis scheme;
[0120] Step S503 includes the following sub-steps:
[0121] Please refer to Figure 6 as shown, step S5031, the partition area where the crack is located is marked as a crack area, and the partition area adjacent to the crack area is marked as a normal area;
[0122] Step S5032, mark the image pixel points in the crack area of the scanning image as crack pixel points, and mark the gray value of the crack pixel points as crack gray value; mark the image pixel points in the normal area of the scanning image as normal pixel points, and mark the gray value of the normal pixel points as normal gray value;
[0123] Step S5033, calculate the average value of the normal gray value, marked as normal average gray; calculate the average value of the crack gray value, marked as crack average gray;
[0124] In specific implementation, the normal area and the crack area are as shown in Figure 6 , the normal area is displayed in black in Figure 5 , and the white wrapped in the black is the crack area; the normal gray value and the crack gray value of the normal area and the crack area are statistically calculated to obtain the normal average gray value of 206 and the crack average gray value of 116;
[0125] Step S5034, read the crack depth historical database to obtain the historical data of crack depth, crack average gray value and normal average gray value, respectively marked as historical depth, historical crack gray value and historical normal gray value;
[0126] Step S5035, calculate the history normal gray minus the history crack gray, and mark the calculation result as a crack difference gray;
[0127] Please refer to Figure 7 As shown in
[0128] Step S5037, logarithmic regression is performed on the difference-depth coordinate system to obtain a crack depth analysis function;
[0129] In a specific implementation, the crack depth history database is historical data obtained by disassembling and analyzing original parts with cracks; the history normal gray is obtained as 202, the history crack gray is obtained as 113, the crack difference gray is obtained as 89 through calculation, and the difference-depth coordinate system is constructed as shown in Figure 7 The crack depth analysis function obtained by logarithmic regression on the difference-depth coordinate system is Y = 2.442*ln(X)-9.1429, where Y is the history depth and X is the crack difference gray. The crack difference gray is substituted into Y = 2.442*ln(X)-9.1429 to obtain the crack depth as 1.8 cm. In actual application, if multiple parts have cracks and the crack depths are similar, it is possible that a problem occurs in a certain processing step in the processing technology. Therefore, the depth of the crack detected in the metal detection can help the user to troubleshoot the cause of the crack.
[0130] Embodiment 2, please refer to Figure 8 As shown in
[0131] The scanning module is configured to scan the part to obtain a scanning image. The part is scanned by X-ray scanning detection, and the scanning image is obtained after scanning. The scanning image is a gray image.
[0132] The gray neighbor difference analysis module is configured to analyze the scanning image to determine the gray neighbor difference range of the scanning image. The gray neighbor difference analysis module includes a point position analysis unit and a gray neighbor difference analysis unit.
[0133] The point position analysis unit is configured with a point position analysis strategy. The point position analysis strategy includes:
[0134] An image resolution of the scanned image is acquired, the image resolution is in a format of C×L, C and L are both non-zero natural numbers;
[0135] Image pixels in the scanned image are numbered, named as pixel numbers, represented by a symbol P(n,m), n and m are column and row numbers of the pixel numbers respectively, n and m are both non-zero natural numbers and 1≤n≤C, 1≤m≤L;
[0136] A gray value of the image pixel is acquired, named as a pixel gray, a maximum value in the pixel gray is found, marked as a maximum gray;
[0137] The image pixel corresponding to the maximum gray is marked as an analysis point, and the corresponding pixel number is marked as an analysis number;
[0138] The analysis point and the analysis number are further analyzed to determine a gray neighborhood difference range of the scanned image;
[0139] The gray neighborhood difference analysis unit is configured with a gray neighborhood difference analysis strategy, the gray neighborhood difference analysis strategy includes:
[0140] n and m of the analysis number are represented by i and j respectively, the analysis number is P(i,j), that is, the analysis number is in the ith column and the jth row;
[0141] Pixel grays of P(i-1,j-1), P(i,j-1), P(i+1,j-1), P(i-1,j), P(i+1,j), P(i-1,j+1), P(i,j+1) and P(i+1,j+1) are acquired, named as a first pixel gray, a second pixel gray, a third pixel gray, a fourth pixel gray, a fifth pixel gray, a sixth pixel gray, a seventh pixel gray and an eighth pixel gray respectively, collectively referred to as neighborhood grays;
[0142] A gray value of the analysis point is marked as an analysis gray, a value of the analysis gray minus the neighborhood grays is calculated, and the calculation result is named as a neighborhood gray difference;
[0143] P(i-1,j-1), P(i,j-1), P(i+1,j-1), P(i-1,j), P(i+1,j), P(i-1,j+1), P(i,j+1) and P(i+1,j+1) are set as the analysis point in turn, and the neighborhood gray difference is calculated again;
[0144] All the neighborhood gray differences are integrated, a maximum value in the neighborhood gray differences is found, marked as a maximum difference value, represented by a symbol D;
[0145] The gray neighborhood difference range is [-D, D];
[0146] The region division module is configured to divide the scanning image into regions based on the gray level neighborhood difference range, and obtain the division regions; the region division module comprises a homogenous pixel searching unit and a homogenous pixel analyzing unit; the region division module comprises the homogenous pixel searching unit configured with a homogenous pixel searching strategy, and the homogenous pixel searching strategy comprises:
[0147] marking the un-divided image pixel points as to-be-divided pixel points and the divided image pixel points as divided pixel points;
[0148] finding the minimum value of n+m in the P(n,m) of the to-be-divided pixel point, marking the corresponding to-be-divided pixel point as a to-be-divided starting point, and marking the pixel gray level corresponding to the to-be-divided pixel point as a to-be-divided gray level;
[0149] obtaining the pixel gray level of the image pixel point adjacent to the P(n,m) and naming the pixel gray level as an adjacent gray level;
[0150] calculating |to-be-divided gray level-adjacent gray level|, marking the calculation result as an adjacent difference value, comparing the adjacent difference value with the gray level neighborhood difference range, outputting a homogenous signal if the adjacent difference value is within the gray level neighborhood difference range, and outputting a non-homogenous signal if the adjacent difference value is not within the gray level neighborhood difference range;
[0151] if the homogenous signal is outputted, marking the corresponding image pixel point as a homogenous pixel point, and analyzing all the adjacent gray levels of the P(n,m) to find all the homogenous pixel points;
[0152] further analyzing the homogenous pixel points to obtain the division regions;
[0153] the homogenous pixel analyzing unit is configured with a homogenous pixel analyzing strategy, and the homogenous pixel analyzing strategy comprises:
[0154] taking the homogenous pixel point as a new to-be-divided pixel point, reanalyzing the new homogenous pixel point until no homogenous signal is outputted; in the process of analyzing the homogenous pixel points, the image pixel points that have outputted the homogenous signal no longer participate in the analysis of the adjacent gray levels;
[0155] after stopping the analysis, marking all the image pixel points that are to-be-divided pixel points in the current region division as divided pixel points and integrating the image pixel points into a same division region;
[0156] continuing to analyze the remaining to-be-divided pixel points until there is no to-be-divided pixel point, and obtaining a plurality of division regions;
[0157] the binarization processing module is configured to perform binarization processing on the division regions to obtain a binarization image;
[0158] the binarization processing module is configured with a binarization processing strategy, and the binarization processing strategy comprises:
[0159] The divided areas are named as the Hth area according to the order of division, H being a non-zero natural number;
[0160] In the binary image, the black area is named as a black region, and the white area is named as a white region;
[0161] The first area is set as the black region;
[0162] The remaining divided areas are divided according to the order of H from small to large, and it is found whether the divided area adjacent to the Hth area is a black region or a white region. If it is a black region, it is set as a white region. If it is a white region, it is set as a black region. If it is adjacent to both a black region and a white region, a black-and-white analysis signal is output. If none of the above conditions is met, the Hth area is skipped, and the (H+1)th area is analyzed first. After the analysis is completed, the Hth area is analyzed again. The divided areas that have been analyzed are not analyzed repeatedly;
[0163] If the black-and-white analysis signal is output, the number of image pixels contained in the adjacent white region and black region is found, and is marked as the number of black regions and the number of white regions, respectively. If the number of black regions is greater than the number of white regions, the Hth area is set as a black region. If the number of black regions is less than the number of white regions, the Hth area is set as a white region. If the number of black regions is equal to the number of white regions, the Hth area is skipped, and the analysis is performed again after the analysis of the next divided area is completed;
[0164] The binary image is obtained after the analysis of the divided areas is completed;
[0165] The crack analysis module is used to analyze the binary image, determine whether the part has a crack, and analyze the depth of the crack. The crack analysis module includes a crack judgment unit and a crack analysis unit;
[0166] The crack judgment unit is configured with a crack judgment strategy, and the crack judgment strategy includes:
[0167] The binary image is recognized by a crack recognition algorithm to determine whether the part has a crack. If it does, a crack signal is output. If it does not, a no-crack signal is output.
[0168] If the crack signal is output, the crack is analyzed by a crack depth analysis function to obtain the crack depth.
[0169] The crack depth analysis function is obtained from a crack depth analysis scheme.
[0170] The crack analysis unit is configured with a crack analysis strategy, and the crack analysis strategy includes:
[0171] The area where the crack is located is marked as a crack region, and the area adjacent to the crack region is marked as a normal region.
[0172] Mark the image pixel points of the crack region in the scanned image as crack pixel points, and mark the gray value of the crack pixel points as crack gray value; mark the image pixel points of the normal region in the scanned image as normal pixel points, and mark the gray value of the normal pixel points as normal gray value;
[0173] Calculate the average value of the normal gray value, and mark it as normal average gray value; calculate the average value of the crack gray value, and mark it as crack average gray value;
[0174] Read the crack depth history database to obtain the historical data of crack depth, crack average gray value and normal average gray value, respectively marked as historical depth, historical crack gray value and historical normal gray value;
[0175] Calculate the historical normal gray value minus the historical crack gray value, and mark the calculation result as crack difference gray value;
[0176] Establish a rectangular coordinate system with the crack difference gray value as the X axis and the historical depth as the Y axis, named as difference-depth coordinate system, and record the crack difference gray value and the corresponding historical depth in the difference-depth coordinate system;
[0177] Logarithmic regression is performed on the difference-depth coordinate system to obtain a crack depth analysis function.
[0178] In the third aspect, the application provides an electronic device, comprising a processor and a memory, the memory storing a computer readable instruction, when the computer readable instruction is executed by the processor, the steps in the above method are executed. Through the above technical solution, the processor and the memory are interconnected and communicate with each other through a communication bus and / or other forms of connection mechanism, the memory stores a computer program executable by the processor, when the electronic device is running, the processor executes the computer program to execute the method in any optional implementation manner of the above embodiment, to realize the following functions: scanning the parts to obtain a scanned image; analyzing the scanned image to determine the gray difference range of the scanned image; dividing the scanned image into regions based on the gray difference range to obtain divided regions; performing binaryzation processing on the divided regions to obtain a binary image; analyzing the binary image to determine whether the parts have cracks and analyze the depth of the cracks.
[0179] In the fourth aspect, the application provides a storage medium, which stores a computer program. The computer program is executed by a processor to perform the steps in the above method. Through the above technical solution, when the computer program is executed by the processor, the method in any one of the optional implementation manners of the above embodiments is executed to achieve the following functions: scanning the part to obtain a scanning image; analyzing the scanning image to determine a gray level neighborhood difference range of the scanning image; performing region division on the scanning image based on the gray level neighborhood difference range to obtain a divided region; performing binaryzation processing on the divided region to obtain a binaryzation image; and analyzing the binaryzation image to determine whether the part has a crack and analyze the depth of the crack.
[0180] In the above embodiments of the application, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.
[0181] Those skilled in the art should understand that the embodiments of the application can be provided as a method, a system or a computer program product. Therefore, the application can be in the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Moreover, the application can be in the form of a computer program product implemented on one or more computer-usable storage media including computer-usable program code. The storage media can be realized by any type of volatile or non-volatile storage devices or their combinations, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk. These computer program instructions can also be stored in a computer readable storage medium which can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer readable storage medium produce a product including an instruction device, which realizes the functions specified in the flowcharts Figure One one or more flows and / or blocks Figure One one or more flows and / or blocks
[0182] In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other manners. The embodiments described above are merely exemplary, for example, the division of the units is only a logical function division, and there can be another division manner in actual implementation; for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between different units, or the among different units, can be indirect couplings or communication connections through some interfaces, communication interfaces, or a combination of the two, which can be electric, mechanical, or in other forms.
Claims
1. A flaw detection method for automotive parts mold production based on machine vision, characterized in that, Includes the following steps: The components are scanned to obtain scanned images; Analyze the scanned image to determine the grayscale difference range of the scanned image; The scanned image is divided into regions based on the gray-level difference range to obtain the divided regions. The divided regions are binarized to obtain a binarized image; Analyze the binarized image to determine whether there are cracks in the parts and analyze the depth of the cracks; Analyzing scanned images includes the following sub-steps: Obtain the image resolution of the scanned image, wherein the image resolution is in the format C×L, where C and L are both non-zero natural numbers; The image pixels in the scanned image are numbered and named as pixel numbers, which are represented by the symbol P(n,m), where n and m are the column number and row number of the pixel number, respectively. n and m are both non-zero natural numbers and 1≤n≤C, 1≤m≤L; Get the grayscale value of each pixel in the image and name it as pixel grayscale. Find the maximum value among the pixel grayscale values and mark it as the maximum grayscale. Mark the image pixel corresponding to the maximum gray level as the point to be analyzed, and mark the corresponding pixel number as the analysis number; Further analysis is performed on the points and numbers to be analyzed to determine the grayscale neighbor difference range of the scanned image; Further analysis of the points and numbers to be analyzed includes the following sub-steps: The n and m of the number to be analyzed are represented by i and j respectively. The number to be analyzed is P(i,j), which means that the number to be analyzed is located in the i-th column and j-th row. Obtain the pixel grayscale values of P(i-1,j-1), P(i,j-1), P(i+1,j-1), P(i-1,j), P(i+1,j), P(i-1,j+1), P(i,j+1), and P(i+1,j+1), and name them sequentially as pixel first grayscale, pixel second grayscale, pixel third grayscale, pixel fourth grayscale, pixel fifth grayscale, pixel sixth grayscale, pixel seventh grayscale, and pixel eighth grayscale, collectively referred to as adjacent cell grayscale; Mark the gray value of the point to be analyzed as the gray value to be analyzed, calculate the value of gray value to be analyzed minus the gray value of neighboring cells, and name the calculation result as the neighborhood gray value difference. Set P(i-1,j-1), P(i,j-1), P(i+1,j-1), P(i-1,j), P(i+1,j), P(i-1,j+1), P(i,j+1), and P(i+1,j+1) as the points to be analyzed in sequence, and calculate the neighborhood gray level difference again. Integrate all neighborhood grayscale differences, find the maximum value among the neighborhood grayscale differences, mark it as the maximum difference value, and represent it by the symbol D; The grayscale adjacent difference range is [-D, D].
2. The flaw detection method for automotive parts mold production based on machine vision according to claim 1, characterized in that, The scanning of the components is performed using X-rays to scan and inspect the components, and the resulting scanned image is a grayscale image.
3. The flaw detection method for automotive parts mold production based on machine vision according to claim 2, characterized in that, The scanned image is divided into regions based on the gray-level adjacent difference range. The process of obtaining the divided regions includes the following sub-steps: Undivided image pixels are marked as pixels to be divided, and divided image pixels are marked as divided pixels; Find the minimum value of n+m in P(n,m) of the pixels to be divided, mark the corresponding pixel to be divided as the starting point of the division, and mark the corresponding pixel gray level as the gray level to be divided. Get the pixel grayscale of the image pixels adjacent to P(n,m), and name them as adjacent grayscale; Calculate | Gray level to be divided - adjacent gray levels|, mark the calculation result as adjacent difference, compare the adjacent difference with the gray level adjacent difference range, and if the adjacent difference is within the gray level adjacent difference range, output the same source signal; If the adjacent difference values are not within the grayscale adjacent difference range, then output signals from different sources; If the output signals are from the same source, then the corresponding image pixels are marked as pixels from the same source. Analyze all adjacent gray levels of P(n,m) to find all pixels from the same source. Further analysis of pixels from the same origin yields the segmented regions.
4. The flaw detection method for automotive parts mold production based on machine vision according to claim 3, characterized in that, Further analysis of pixels from the same origin includes the following sub-steps: Using pixels from the same source as new pixels to be divided, the new pixels from the same source are analyzed again until no more pixels from the same source are output. During the analysis of pixels from the same source, the image pixels that have already output pixels from the same source no longer participate in the analysis of adjacent gray levels. After the analysis is stopped, all image pixels that were to be divided in this region division are marked as divided pixels and integrated into the same region. Continue analyzing the remaining pixels to be divided until there are no more pixels to be divided, resulting in multiple division regions.
5. The flaw detection method for automotive parts mold production based on machine vision according to claim 4, characterized in that, Binarizing the segmented regions to obtain a binary image involves the following sub-steps: The regions are named as region H in the order they were divided, where H is a non-zero natural number. In a binarized image, black areas are named black areas and white areas are named white areas; Set region 1 to a black area; The remaining regions are divided in ascending order of H. The system checks whether the region adjacent to the H-th region is a black or white region. If it is a black region, it is set as a white region; if it is a white region, it is set as a black region. If a region is adjacent to both a black and a white region, a black-white analysis signal is output. If neither region is divided, the H-th region is skipped, and the H+1-th region is analyzed first. After the H-th region is analyzed, the H-th region is analyzed again. Regions that have already been analyzed are not analyzed again. If the black and white analysis signal is output, the number of image pixels contained in the adjacent white and black areas is found and marked as the number of black areas and the number of white areas, respectively. If the number of black areas is greater than the number of white areas, the Hth region is set as a black area; if the number of black areas is less than the number of white areas, the Hth region is set as a white area; if the number of black areas is equal to the number of white areas, the Hth region is skipped and the analysis is performed again after the next region is divided. After the region segmentation analysis is completed, a binarized image is obtained.
6. The flaw detection method for automotive parts mold production based on machine vision according to claim 5, characterized in that, Analyzing the binarized image to determine whether a component has cracks and to analyze the depth of the cracks includes the following sub-steps: A crack detection algorithm is used to identify the binary image and determine whether there are cracks in the parts. If cracks are found, a crack presence signal is output; otherwise, a crack absence signal is output. If a crack signal is present in the output, the crack is analyzed using the crack depth analysis function to obtain the crack depth. The crack depth analysis function is obtained from the crack depth analysis scheme.
7. The flaw detection method for automotive parts mold production based on machine vision according to claim 6, characterized in that, The crack depth analysis scheme includes the following sub-steps: The region where the crack is located is marked as the crack region, and the region adjacent to the crack region is marked as the normal region. Image pixels in the cracked area of the scanned image are marked as crack pixels, and the gray values of the crack pixels are marked as crack gray values; image pixels in the normal area of the scanned image are marked as normal pixels, and the gray values of the normal pixels are marked as normal gray values. Calculate the average value of normal grayscale values and mark it as the normal average grayscale. Calculate the average gray value of the crack and mark it as the average gray value of the crack. Read the historical crack depth database to obtain historical data of crack depth, crack average gray level and normal average gray level, and mark them as historical depth, historical crack gray level and historical normal gray level respectively. Calculate the historical normal grayscale and subtract the historical crack grayscale, and mark the result as the crack difference grayscale; A rectangular coordinate system is established with the crack difference grayscale as the X-axis and the historical depth as the Y-axis, named the difference-depth coordinate system. The crack difference grayscale and the corresponding historical depth are entered into the difference-depth coordinate system. Logarithmic regression was performed on the difference-depth coordinate system to obtain the crack depth analysis function.
8. A machine vision-based flaw detection system for automotive parts mold production, applicable to the machine vision-based flaw detection method for automotive parts mold production as described in any one of claims 1-7, characterized in that, It includes a scanning module, a grayscale neighbor difference analysis module, a region division module, a binarization processing module, and a crack analysis module. The scanning module, grayscale neighbor difference analysis module, region division module, and crack analysis module are respectively connected to the binarization processing module for data transmission. The scanning module is used to scan the parts and obtain scanned images; The grayscale neighbor difference analysis module is used to analyze the scanned image and determine the grayscale neighbor difference range of the scanned image; The region division module is used to divide the scanned image into regions based on the gray-level adjacent difference range to obtain the divided regions; The binarization processing module is used to perform binarization processing on the divided regions to obtain a binarized image; The crack analysis module is used to analyze the binary image to determine whether there are cracks in the component and to analyze the depth of the crack.
Citation Information
Patent Citations
Image processing method of metal workpiece grade sorting system
CN111445434A
Part multi-scale defect feature extraction method, computing device and storage medium
CN116385414A
Road construction quality detection method and system based on artificial intelligence
CN117173184A