A method and system for detecting surface defects of a crankshaft based on image processing
By combining multi-angle image processing and multiple algorithms, the problem of low crankshaft surface crack detection accuracy caused by lubricating oil film interference was solved, achieving higher detection accuracy and lower false detection rate.
Patent Information
- Application Number
- CN202511093511.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-06
- Publication Date
- 2025-10-14
- Estimated Expiration
- 2045-08-06
AI Technical Summary
In existing crankshaft surface inspection methods, lubricating oil film interference leads to low crack detection accuracy and high false detection rate.
The crankshaft surface images are taken from multiple angles. Combining grayscale co-occurrence matrix, grayscale uniformity, LBP algorithm, Canny edge detection and K-means clustering algorithm, the texture continuity, texture clarity and linear profile factor within the window are calculated to distinguish lubricating oil and crack defects.
Through multi-angle image processing, the interference of lubricating oil on detection is reduced, the false detection rate of crack defects is reduced, and the accuracy of detection is improved.
Smart Images

Figure CN120598944B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of defect detection, and in particular to a crankshaft surface defect detection method and system based on image processing. Background Art
[0002] The crankshaft, the engine's drive shaft and a vital component, is typically produced through forging or casting. After forging or casting, the crankshaft undergoes heat treatment, shot blasting, and flaw detection. During the molding and heat treatment process, the crankshaft is prone to various production defects, such as shear cracks, forging folds, quenching cracks, and grinding cracks. These defects can easily lead to component breakage during engine operation, resulting in safety accidents and property damage. Therefore, inspecting the crankshaft for defects during the final production step is crucial.
[0003] A Chinese patent document with publication number CN114897909B discloses a crankshaft surface crack monitoring method and system based on unsupervised learning. The monitoring method includes: establishing an initial model for surface crack monitoring; training the model using real sample data sets and unlabeled sample data to obtain a final classification model for surface crack monitoring; inputting the collected crankshaft surface image into the final classification model to classify the crankshaft surface crack status.
[0004] During the crankshaft production process, a transparent lubricating oil film is easily adhered to the crankshaft surface. Then, when using a classification model to detect cracks on the crankshaft surface, the lubricating oil film causes significant interference to the classification model. For example, the oil film is misjudged as a crack, or the crack cannot be detected when the oil film completely covers the crack. Therefore, the existing classification model has low accuracy in detecting cracks. Summary of the Invention
[0005] In order to solve the problem of low accuracy of crack detection caused by the presence of lubricating oil film on the crankshaft surface, the present invention provides a crankshaft surface defect detection method and system based on image processing.
[0006] In a first aspect, the present invention provides a crankshaft surface defect detection method based on image processing, which adopts the following technical solution:
[0007] The method comprises the following steps: obtaining grayscale images of a crankshaft under different illumination angles, dividing each grayscale image into a plurality of windows, classifying the windows to obtain a first window and a second window, and calculating a first probability that the first window is a crack defect; recording the first window whose first probability is greater than a preset threshold as a third window; calculating a second probability that the second window and the third window are crack defects, and obtaining the defect categories to which the second window and the third window belong based on the second probability;
[0008] The calculation method of the second possibility is: constructing the gray level co-occurrence matrix of the corresponding window area, calculating the correlation and contrast of the gray level co-occurrence matrix, and the expression of the second possibility is:
[0009]
[0010] Where, 、 They represent the texture continuity and texture clarity in the γth window of the grayscale image with an illumination angle of θ; 、 They represent the correlation and contrast of the gray-level co-occurrence matrix corresponding to the γth window in the gray-scale image with an illumination angle of θ, represents the possibility of crack defects in the γth window; 、 They represent the variance and mean of the texture continuity in the γth window in multiple grayscale images, norm is the normalization function, and exp represents the exponential function with e as the base.
[0011] By acquiring crankshaft surface images taken from multiple angles, missed crack detection caused by a single illumination angle is avoided. The grayscale co-occurrence matrix is used to calculate the texture continuity and texture clarity in the second and third windows on the crankshaft surface grayscale images under different illumination angles to obtain the possibility of crack defects in the second and third windows, making it easier to determine whether crack defects exist in the second and third windows. By capturing the microscopic discontinuity characteristics of the crack edge, the interference of lubricating oil on crack defect detection is reduced, thereby reducing the false detection rate of crack defects.
[0012] Preferably, the method further comprises:
[0013] Calculate the grayscale uniformity of each window and classify the grayscale uniformity into normal windows and abnormal windows. The expression of grayscale uniformity is:
[0014]
[0015] Where, represents the grayscale uniformity of the αth window in the grayscale image with an illumination angle of θ, It represents the information entropy of the gray value k in the αth window of the gray image with an illumination angle of θ, and exp represents the exponential function with e as the base.
[0016] Grayscale uniformity can be used to determine the richness of the grayscale within the window, providing a theoretical basis for determining whether there are crack defects on the crankshaft surface.
[0017] Preferably, the method for classifying windows to obtain the first window and the second window is: in multiple grayscale images, if the windows at the same position are all abnormal windows, the window at the corresponding position is used as the first window; if the windows at the same position contain normal windows, the window at the corresponding position is used as the second window.
[0018] By classifying the windows, it is convenient to classify the defect types within the windows.
[0019] Preferably, the method further comprises: calculating the texture consistency of the first window by:
[0020] The LBP algorithm is used to calculate the LBP value of the first window pixel in the grayscale image, and a histogram of the LBP value is constructed to obtain the frequency of each LBP value. The expression of texture consistency is:
[0021]
[0022] Where, is the texture consistency of the βth first window in the grayscale image; is the set of illumination angles; The frequency of the LBP value i of the pixel in the βth first window of the grayscale image with an illumination angle of θ; It represents the frequency of the LBP value i of the pixel point in the βth first window of the grayscale image with an illumination angle of δ, r represents the preset hyperparameter, and exp represents the exponential function with base e.
[0023] The above formula can accurately calculate the texture consistency of the window, thereby improving the accuracy of the calculation results.
[0024] Preferably, the method further comprises: calculating the linear profile factor of the first window, the calculation method being:
[0025] The Canny edge detection algorithm is used to detect the first window to obtain the contour line, and the minimum circumscribed rectangle of the contour line is constructed. The expression of the linear contour factor is:
[0026]
[0027] Where, is the linear profile factor of the βth first window in the grayscale image with an illumination angle of θ, and They represent the length and width of the minimum circumscribed rectangle of the inner contour line of the βth first window in the grayscale image with an illumination angle of θ; and are the perimeter and area of the minimum circumscribed rectangle respectively, and norm represents the normalization function.
[0028] The linear profile factor can be used to determine the possibility of cracks in the window, whether there are compound crack patterns, and to distinguish the edge of the lubricating oil film from crack defects.
[0029] Preferably, the method further comprises: calculating the degree of difference of the linear profile factor of the first window, expressed as:
[0030]
[0031] Where, represents the degree of difference of the linear profile factor of the βth first window, is the linear profile factor of the βth first window in the grayscale image with an illumination angle of θ, is the linear profile factor of the βth first window in the grayscale image with an illumination angle of δ, tanh is the hyperbolic tangent function, Represents a collection of lighting angles.
[0032] The above formula can be used to understand the degree of difference between the internal linear factors of the first windows in different grayscale images, which is convenient for further determining whether there is a crack defect in the corresponding first window, thereby improving the accuracy of the determination result.
[0033] Preferably, the expression of the first possibility is:
[0034]
[0035] Where, represents the first possibility that the βth first window is a crack defect, represents the degree of difference of the linear profile factor of the βth first window, is the texture consistency of the βth first window in the grayscale image.
[0036] Preferably, the method for obtaining the defect categories to which the second window and the third window belong according to the second possibility is: clustering the second possibility using a K-means clustering algorithm to obtain three clusters, each cluster corresponding to one defect category.
[0037] Preferably, the defect categories are: crack completely covered by lubricating oil, crack partially covered by lubricating oil and lubricating oil area.
[0038] In a second aspect, the present invention provides a crankshaft surface defect detection system based on image processing, which adopts the following technical solutions:
[0039] A crankshaft surface defect detection system based on image processing includes: a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the crankshaft surface defect detection method based on image processing is implemented.
[0040] The above-mentioned crankshaft surface defect detection method based on image processing is generated into a computer program and stored in a memory so as to be loaded and executed by a processor. Thus, a system is made based on the memory and the processor for easy use.
[0041] The present invention has the following technical effects:
[0042] By acquiring crankshaft surface images taken from multiple angles, missed crack detection caused by a single illumination angle is avoided. The grayscale co-occurrence matrix is used to calculate the texture continuity and texture clarity in the second and third windows on the crankshaft surface grayscale images under different illumination angles to obtain the possibility of crack defects in the second and third windows, making it easier to determine whether crack defects exist in the second and third windows. By capturing the microscopic discontinuity characteristics of the crack edge, the interference of lubricating oil on crack defect detection is reduced, thereby reducing the false detection rate of crack defects. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 This is a flow chart of a crankshaft surface defect detection method based on image processing according to the present invention. DETAILED DESCRIPTION
[0044] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work shall fall within the scope of protection of the present invention.
[0045] The embodiment of the present invention discloses a crankshaft surface defect detection method based on image processing, referring to Figure 1 , including the following steps:
[0046] S1: Obtain grayscale images of the crankshaft under different illumination angles and divide each grayscale image into multiple windows.
[0047] An industrial camera and a light source are set above the crankshaft to obtain an image of the crankshaft surface. After adjusting the illumination angle of the light source, the image of the crankshaft surface is obtained again. In this way, multiple images of the crankshaft surface are obtained, and the images are converted into corresponding grayscale images. The grayscale images are denoised, and each grayscale image is divided into multiple windows of the same size.
[0048] For example, when the light of the light source is at 90 degrees to the crankshaft surface, an industrial camera is used to obtain an image of the crankshaft surface; when the light of the light source is adjusted to 85 degrees to the crankshaft surface, an industrial camera is used to obtain an image of the crankshaft surface; when the light of the light source is adjusted to 80 degrees to the crankshaft surface, an industrial camera is used to obtain an image of the crankshaft surface, the image is converted into a grayscale image, and the grayscale image is divided into multiple 10×10 windows.
[0049] S2: Classify the windows to obtain a first window and a second window.
[0050] S21: Calculate the grayscale uniformity of each window.
[0051] The expression of grayscale uniformity is:
[0052]
[0053] Where, represents the grayscale uniformity of the αth window in the grayscale image with an illumination angle of θ, It represents the information entropy of the gray value k in the αth window of the gray image with an illumination angle of θ, and exp represents the exponential function with e as the base.
[0054] Represents the grayscale information entropy within the αth window. A larger value indicates a richer grayscale within the αth window and a smaller grayscale uniformity within the window. A smaller value indicates a more uniform grayscale within the αth window and a larger grayscale uniformity within the window. It is understood that each grayscale image has multiple windows, each corresponding to a grayscale uniformity. The Otsu threshold method is used to classify the multiple grayscale uniformities obtained, with windows with grayscale uniformity greater than or equal to the threshold being considered normal windows, and windows with grayscale uniformity less than the threshold being considered abnormal windows. It is understood that normal windows have no crack defects, while abnormal windows are more likely to have crack defects.
[0055] S22: Classify the abnormal windows to obtain the first window and the second window
[0056] If all windows at the same location in multiple grayscale images are abnormal, the corresponding window is considered the first window. If the windows at the same location also contain a normal window, the corresponding window is considered the second window. If the first window is abnormal at all illumination angles, it is highly likely that the first window contains a crack defect. If the second window is abnormal only at certain illumination angles, it is highly likely that the second window contains lubricant, and the second window may contain lubricant or a crack completely covered by lubricant.
[0057] For example, the number of grayscale images is 5. If the second windows in all 5 grayscale images are abnormal windows, the second window is used as the first window. If the third windows in 4 of the 5 grayscale images are abnormal windows, and the third window in 1 of the 5 grayscale images is a normal window, the third window is used as the second window.
[0058] S3: Calculate the first possibility that the first window is a crack defect.
[0059] S31: Calculate the texture consistency of the first window.
[0060] The calculation method is: use the LBP algorithm to calculate the LBP value of the first window pixel in the grayscale image, construct a histogram of the LBP value, and obtain the frequency of each LBP value. The expression of texture consistency is:
[0061]
[0062] Where, is the texture consistency of the βth first window in the grayscale image; is the set of illumination angles; The frequency of the LBP value i of the pixel in the βth first window of the grayscale image with an illumination angle of θ; represents the frequency of the LBP value i of the pixel point in the βth first window of the grayscale image with an illumination angle of δ. r represents a preset hyperparameter with a value of 0.01 to prevent the denominator from being zero. exp represents an exponential function with base e.
[0063] It represents the chi-square distance of the LBP histogram in the βth first window of the grayscale image with an illumination angle of θ and an illumination angle of δ. The larger the value, the greater the difference in the LBP histogram of the βth first window of the two grayscale images, and the smaller the texture consistency in the βth first window of the two grayscale images. Conversely, the smaller the value, the smaller the difference in the LBP histogram in the βth first window of the two grayscale images, and the greater the texture consistency in the βth first window of the two grayscale images.
[0064] S32: Calculate the linear profile factor of the first window.
[0065] The calculation method is: use the Canny edge detection algorithm to detect the first window to obtain the contour line, and construct the minimum circumscribed rectangle of the contour line. The expression of the linear contour factor is:
[0066]
[0067] Where, is the linear profile factor of the βth first window in the grayscale image with an illumination angle of θ, and The length and width of the minimum circumscribed rectangle of the inner contour line of the β-th first window in the grayscale image with an illumination angle of θ respectively; and are the perimeter and area of the minimum circumscribed rectangle respectively, and norm represents the normalization function.
[0068] is the absolute value of the difference between the length and width of the minimum circumscribed rectangle of the contour line in the βth first window of the grayscale image with an illumination angle of θ. The larger the value, the greater the possibility that the contour line is linear, and the smaller the value, the less likely the contour line is linear. The linear profile factor represents the slenderness of the minimum circumscribed rectangle of the contour line within the βth first window in the grayscale image at an illumination angle of θ. A larger value indicates a greater slenderness of the minimum circumscribed rectangle of the contour line within the βth first window and a greater likelihood that the contour line is linear. Conversely, a smaller value indicates a lower likelihood of a linear contour line. Cracks on the crankshaft surface typically have a nearly linear structure, and the linear profile factor can be used to preliminarily determine whether a crack defect exists on the crankshaft surface.
[0069] S33: Calculate the degree of difference of the linear profile factor of the first window.
[0070] The expression is:
[0071] Where, represents the degree of difference of the linear profile factor of the βth first window, is the linear profile factor of the βth first window in the grayscale image with an illumination angle of θ, is the linear profile factor of the βth first window in the grayscale image with an illumination angle of δ, tanh is the hyperbolic tangent function, Represents a collection of lighting angles. It indicates the possibility that the contour line in the βth first window is linear under all illumination angles. The larger the value, the greater the difference in the possibility that the contour line in the βth first window is linear under different illumination angles, and the greater the possibility of crack defects in the βth first window. Conversely, the possibility of crack defects in the βth first window is smaller.
[0072] S34: Calculate the first probability.
[0073] The expression is:
[0074] Where, represents the first possibility that the βth first window is a crack defect, represents the degree of difference of the linear profile factor of the βth first window, is the texture consistency of the βth first window in the grayscale image. The larger the value of , the greater the possibility of crack defects in the βth first window.
[0075] S4: Record the first window whose first probability is greater than the preset threshold as the third window.
[0076] A histogram of the first possibility of the first window is constructed, and the maximum entropy method is used to maximize the sum of the inter-class entropy to obtain the optimal segmentation threshold. If the first possibility is greater than or equal to the optimal segmentation threshold, it indicates that there is a crack defect in the corresponding first window; if the first possibility is less than the optimal segmentation threshold, the corresponding first window is used as the third window.
[0077] S5: Calculate the second probability that the second window and the third window are crack defects, and obtain the defect categories to which the second window and the third window belong according to the second probability.
[0078] The second possible calculation method is: constructing a gray level co-occurrence matrix of the corresponding window area, and calculating the correlation and contrast of the gray level co-occurrence matrix. This is a prior art, and the specific calculation method will not be repeated here.
[0079] The second possibility is expressed as:
[0080]
[0081] Where, 、 They represent the texture continuity and texture clarity in the γth window of the grayscale image with an illumination angle of θ; 、 They represent the correlation and contrast of the gray-level co-occurrence matrix corresponding to the γth window in the gray-scale image with an illumination angle of θ, represents the possibility of crack defects in the γth window; 、 where γ represents the variance and mean of the texture continuity within the γth window in multiple grayscale images, norm represents the normalization function, and exp represents the exponential function with base e. It should be noted that the γth window is the second window or the third window.
[0082] is the mean value of texture continuity in the γth window (the second window or the third window) under different illumination angles. The larger the value, the fewer areas with drastic grayscale changes in the grayscale image as the illumination angle changes, and the lower the possibility of crack defects in the window. The smaller the value, the more areas with drastic grayscale changes in the grayscale image as the illumination angle changes, and the higher the possibility of crack defects in the window. The value is the fluctuation degree of texture continuity in the γth window (second window or third window) under different illumination angles. The larger the value, the greater the fluctuation degree of texture continuity in the γth window (second window or third window) with the illumination angle, the greater the influence of the texture continuity on the illumination angle, and the greater the possibility of crack defects in the window. The smaller the value, the greater the fluctuation degree of texture continuity in the γth window (second window or third window) with the illumination angle. The smaller the fluctuation of texture continuity in a window (the second window or the third window), the less the texture continuity is affected by the illumination angle, and the smaller the possibility of crack defects in the window; The smaller the time, the better. The greater the upward correction, the greater the possibility of crack defects in the window. The larger the size, the higher the texture in the window. Too many corrections are made, at this time right The smaller the degree of correction.
[0083] The K-means clustering algorithm is used to cluster the second possibility to obtain three clusters, each cluster corresponding to a defect category.
[0084] In three clusters:
[0085] The defect of the window corresponding to the data point in the cluster with the largest center point is: there is a crack defect in the window that is not completely covered by lubricating oil;
[0086] The defect of the window corresponding to the data point in the cluster with the smallest center point is: the lubricant exists in the window;
[0087] The defect of the window corresponding to the data points in the cluster whose center point is between the two is: there is a crack defect in the window that is completely covered by lubricating oil.
[0088] An embodiment of the present invention also discloses a crankshaft surface defect detection system based on image processing, including a processor and a memory, wherein the memory stores computer program instructions. When the computer program instructions are executed by the processor, a crankshaft surface defect detection method based on image processing according to the present invention is implemented.
[0089] The above system also includes other components well known to those skilled in the art, such as a communication bus and a communication interface. The configuration and functions of these components are known in the art and will not be described in detail here.
[0090] The above are all preferred embodiments of the present invention, and are not intended to limit the scope of protection of the present invention. Therefore, any equivalent changes made based on the structure, shape, and principle of the present invention should be included in the scope of protection of the present invention.
Claims
1. A crankshaft surface defect detection method based on image processing, characterized in that: The method comprises the following steps: obtaining grayscale images of a crankshaft under different illumination angles, dividing each grayscale image into multiple windows, classifying the windows to obtain a first window and a second window, and calculating a first probability that the first window is a crack defect; recording the first window whose first probability is greater than a preset threshold as a third window; calculating a second probability that the second window and the third window are crack defects, and obtaining the defect categories to which the second window and the third window belong based on the second probability; the first probability satisfies: represents the first possibility that the βth first window is a crack defect, represents the degree of difference of the linear profile factor of the βth first window, is the texture consistency of the βth first window in the grayscale image; The calculation method of the second possibility is: constructing the gray level co-occurrence matrix of the corresponding window area, calculating the correlation and contrast of the gray level co-occurrence matrix, and the second possibility satisfies: 、 They represent the texture continuity and texture clarity in the γth window of the grayscale image with an illumination angle of θ; 、 They represent the correlation and contrast of the gray-level co-occurrence matrix corresponding to the γth window in the gray-scale image with an illumination angle of θ, represents the possibility of crack defects in the γth window; 、 They represent the variance and mean of the texture continuity in the γth window of multiple grayscale images, norm is the normalization function, and exp represents the exponential function with e as the base; Represents the mean value of texture clarity within the γth window under different illumination angles.
2. The method for detecting crankshaft surface defects based on image processing according to claim 1, characterized in that: The method also includes: Calculate the grayscale uniformity of each window and classify the grayscale uniformity into normal windows and abnormal windows. The expression of grayscale uniformity is: Where, represents the grayscale uniformity of the αth window in the grayscale image with an illumination angle of θ, It represents the information entropy of the gray value k in the αth window of the gray image with an illumination angle of θ, and exp represents the exponential function with base e.
3. The method for detecting crankshaft surface defects based on image processing according to claim 2, characterized in that: The method for classifying windows to obtain the first window and the second window is as follows: in multiple grayscale images, if the windows at the same position are all abnormal windows, the window at the corresponding position is used as the first window; if the windows at the same position contain normal windows, the window at the corresponding position is used as the second window.
4. The method for detecting crankshaft surface defects based on image processing according to claim 1, characterized in that: The method further includes calculating the texture consistency of the first window by: The LBP algorithm is used to calculate the LBP value of the first window pixel in the grayscale image, and a histogram of the LBP value is constructed to obtain the frequency of each LBP value. The expression of texture consistency is: , ; Where, is the texture consistency of the βth first window in the grayscale image; is the set of illumination angles; The frequency of the LBP value i of the pixel in the βth first window of the grayscale image with an illumination angle of θ; It represents the frequency of the LBP value i of the pixel point in the βth first window of the grayscale image with an illumination angle of δ, r represents the preset hyperparameter, and exp represents the exponential function with base e.
5. The method for detecting crankshaft surface defects based on image processing according to claim 4, characterized in that: The method further includes: calculating the linear profile factor of the first window, the calculation method being: The Canny edge detection algorithm is used to detect the first window to obtain the contour line, and the minimum circumscribed rectangle of the contour line is constructed. The expression of the linear contour factor is: Where, is the linear profile factor of the βth first window in the grayscale image with an illumination angle of θ, and They represent the length and width of the minimum circumscribed rectangle of the inner contour line of the βth first window in the grayscale image with an illumination angle of θ; and are the perimeter and area of the minimum circumscribed rectangle respectively, and norm represents the normalization function.
6. The method for detecting crankshaft surface defects based on image processing according to claim 5, characterized in that: The method further includes: calculating the degree of difference of the linear profile factor of the first window, which is expressed as: , ; Where, represents the degree of difference of the linear profile factor of the βth first window, is the linear profile factor of the βth first window in the grayscale image with an illumination angle of θ, is the linear profile factor of the βth first window in the grayscale image with an illumination angle of δ, tanh is the hyperbolic tangent function, Represents a collection of lighting angles.
7. The method for detecting crankshaft surface defects based on image processing according to claim 1, characterized in that: The method for obtaining the defect categories to which the second window and the third window belong according to the second possibility is: clustering the second possibility using a K-means clustering algorithm to obtain three clusters, each cluster corresponding to one defect category.
8. The method for detecting crankshaft surface defects based on image processing according to claim 7, characterized in that: The defect categories are: crack completely covered by lubricant, crack partially covered by lubricant, and lubricant area.
9. A crankshaft surface defect detection system based on image processing, characterized in that: include: A processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, a crankshaft surface defect detection method based on image processing according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
A Crankshaft Surface Crack Monitoring Method and System Based on Unsupervised Learning
CN114897909B
Die forging rigging die crack defect detection method based on image processing
CN117893532A
Guide wheel crack defect intelligent detection method and system based on image features
CN117974637A