An image recognition-based automobile steel plate spring surface defect detection method
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANDONG PROVINCE WENDENGSHISHUANGLIBANHUANG GRP CO LTD
- Filing Date
- 2026-05-22
- Publication Date
- 2026-06-19
Smart Images

Figure CN122244046A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and more specifically to a method for detecting surface defects in automotive leaf springs based on image recognition. Background Technology
[0002] Automotive leaf springs are core load-bearing components in vehicle suspension systems, directly undertaking multiple functions such as load transfer between the frame and axle, shock absorption, and directional stability. Under long-term alternating stress, leaf springs are prone to typical defects such as fatigue cracks, plastic deformation, surface indentations, rust pits, and wear. These defects not only affect the ride comfort and handling stability of the vehicle but may also lead to catastrophic safety accidents such as fracture failure. Statistics show that leaf spring-related failures account for more than 18% of low-speed vehicle chassis system failures, making it one of the key factors threatening driving safety. Therefore, accurate and efficient detection of surface defects in leaf springs is of significant engineering value for ensuring vehicle operation safety and extending the service life of components.
[0003] With the rapid development of machine vision technology, image processing-based defect detection methods have been widely used in the field of industrial parts inspection due to their advantages such as non-contact operation, high efficiency, and quantifiability. Existing research shows that using digital imaging technology to inspect spring parts can achieve precise measurement of inner and outer diameters and identification of surface defects, overcoming the shortcomings of traditional inspection methods, such as low automation and large errors by human inspectors. However, existing image detection methods are mainly aimed at regular parts such as small helical springs. For long, narrow parts such as automotive leaf springs, which have curved surfaces, complex surface reflective properties, and diverse defect types, directly applying conventional image processing algorithms faces many challenges. For example, the surface of leaf springs is usually covered with paint or anti-rust coatings, resulting in low contrast between defects and the background, making it difficult for traditional threshold segmentation methods to accurately extract defect areas; leaf springs have complex curved surface structures, which easily generate uneven lighting and reflective interference during imaging, affecting the stability of defect identification; micro-defects such as fatigue cracks are small in scale and have varied shapes, making it easy for conventional edge detection algorithms to miss detection or generate a large number of false edges. Summary of the Invention
[0004] To address the aforementioned technical problems, the present invention aims to provide a method for detecting surface defects in automotive leaf springs based on image recognition. The specific technical solution adopted is as follows: One embodiment of the present invention provides a method for detecting surface defects in automotive leaf springs based on image recognition, the method comprising: The surface image of the leaf spring is acquired and preprocessed to obtain the target image; the target image is divided into blocks to obtain sub-blocks; the gradient direction angle of each pixel in each sub-block is mapped to obtain the edge direction angle of each pixel; a weighted direction histogram is constructed using the edge direction angles of each pixel in a sub-block, and the main direction of the sub-block is obtained; Multi-scale ridge wave transformation is performed on the main direction of a sub-block to obtain the ridge wave coefficients at each scale corresponding to the sub-block; the threshold at the same scale is obtained by using the ridge wave coefficients of each sub-block; and the enhanced ridge wave coefficients at each scale corresponding to a sub-block are obtained by enhancing the ridge wave coefficients at each scale corresponding to the sub-block based on the threshold at each scale. The sub-block is reconstructed using the enhanced ridge coefficients at various scales corresponding to the sub-block; the enhanced image of the target image is obtained using each reconstructed sub-block; and the surface defects of the automotive leaf spring are detected using the enhanced image.
[0005] Preferably, the target image is divided into blocks to obtain sub-blocks, including: The target image is divided into M×N overlapping sub-blocks, each sub-block being w×w in size. The distance between the center points of two adjacent sub-blocks in the horizontal direction is s, and the distance between the center points of two adjacent sub-blocks in the vertical direction is s.
[0006] Preferably, a weighted orientation histogram is constructed using the edge orientation angles of each pixel in a sub-block, and the main orientation of the sub-block is obtained, including: Each interval is used as the x-coordinate of the weighted orientation histogram; the gradient magnitudes of each pixel belonging to the edge orientation angle of an interval in a sub-block are summed to obtain the y-coordinate of that interval. The index of the interval corresponding to the peak value in the weighted direction histogram of the sub-block is recorded as the peak interval index; the result of adding the peak interval index to the first preset value is divided by the number of intervals in the weighted direction histogram, and then multiplied by π to obtain the initial main direction of the sub-block; the main direction of the sub-block is obtained by smoothing the initial main direction of the sub-block within the preset neighborhood of the sub-block.
[0007] Preferably, the threshold at that scale is obtained using the ridge wave coefficients at the same scale for each sub-block, including: Obtain the mean and standard deviation of the ridge wave coefficients at the same scale for each sub-block, and add the product of the first parameter and the standard deviation to the mean to obtain the threshold at that scale.
[0008] Preferably, the enhanced ridge wave coefficients at each scale corresponding to a sub-block are obtained by enhancing the ridge wave coefficients at each scale based on a threshold at each scale, including: If the absolute value of a ridge coefficient at a certain scale of the sub-block is greater than the threshold at that scale, the ridge coefficient at that scale of the sub-block is multiplied by the second parameter to obtain the enhanced ridge coefficient corresponding to the ridge coefficient at that scale of the sub-block; if the absolute value of a ridge coefficient at a certain scale of the sub-block is less than or equal to the threshold at that scale, the ridge coefficient at that scale of the sub-block is set to 0 to obtain the enhanced ridge coefficient corresponding to the ridge coefficient at that scale of the sub-block.
[0009] Preferably, obtaining an enhanced image of the target image using each reconstructed sub-block includes: Each reconstructed sub-block is placed in its original position in the target image. For the pixels in the overlapping area, a weighted average method is used to obtain the gray value of each pixel in the overlapping area, thus obtaining the enhanced image of the target image.
[0010] Preferably, the surface defects of automotive leaf springs are detected using enhanced imaging, including: The enhanced image is uniformly divided into non-overlapping pixel blocks. For each pixel block, the Otsu algorithm is used to calculate the global optimal threshold. The gray values of pixels within a pixel block whose gray values are greater than the global optimal threshold are set to 255, otherwise set to 0, resulting in a local binary image for that pixel block. The local binary images of all pixel blocks are then concatenated to obtain the global binary image. Median filtering is applied to the global binary image to obtain the filtered global binary image. Connected components in the global binary image are obtained, and the area of each connected component and the aspect ratio of its minimum bounding rectangle are calculated. If the area of a connected component is greater than or equal to an area threshold and its aspect ratio is greater than or equal to an aspect ratio threshold, then the connected component is considered a crack.
[0011] The embodiments of the present invention have at least the following beneficial effects: This application addresses the problems in existing steel leaf spring surface crack detection, such as extremely low contrast between cracks and background due to paint coating, uneven illumination caused by curved surface reflection, and high false negative rate of traditional edge detection operators for small linear structures. The invention acquires a surface image of the steel leaf spring and preprocesses it to obtain a target image. Then, the target image is divided into sub-blocks, and the principal direction of each sub-block is obtained. For the principal direction of each sub-block, a multi-scale ridge wave transform is performed using the principal direction of one sub-block to obtain the ridge wave coefficients at each scale corresponding to that sub-block. The ridge wave coefficients at the same scale of each sub-block are then used to obtain the scale... The method involves using a threshold at each scale and then enhancing the ridge wave coefficients at each scale corresponding to a sub-block based on the threshold at each scale to obtain the enhanced ridge wave coefficients at each scale corresponding to that sub-block. The enhanced ridge wave coefficients at each scale corresponding to that sub-block are then used to reconstruct the sub-block and obtain the reconstructed sub-block. The enhanced image of the target image is obtained using each reconstructed sub-block. The enhanced image is then used to detect surface defects in automotive leaf springs. This method accurately characterizes the linear geometric features of cracks and performs multi-scale ridge wave transformation based on local adaptive direction estimation. This enhances the crack signal while suppressing background interference, requires no large number of defect samples, and is insensitive to changes in illumination. Attached Figure Description
[0012] To more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 This is a flowchart illustrating a method for detecting surface defects in automotive leaf springs based on image recognition, as provided in an embodiment of this application. Detailed Implementation
[0014] To further illustrate the technical means and effects adopted by the present invention to achieve its intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of an image recognition-based method for detecting surface defects in automotive leaf springs according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.
[0015] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0016] The following description, in conjunction with the accompanying drawings, details a specific scheme for an image recognition-based method for detecting surface defects in automotive leaf springs provided by this invention.
[0017] In this embodiment, the main application scenario of the present invention is as follows: In the existing detection of surface cracks in steel leaf springs, the contrast between cracks and background is extremely low due to the paint coating, uneven illumination caused by surface reflection, and the high rate of missed detection of small linear structures by traditional edge detection operators. The present invention enhances the image and then performs defect detection on the surface of the steel leaf spring based on the enhanced image.
[0018] Please see Figure 1 The diagram illustrates a method flowchart for detecting surface defects in automotive leaf springs based on image recognition, according to an embodiment of the present invention. The method includes the following steps: Step S1: Acquire the surface image of the leaf spring and preprocess it to obtain the target image; divide the target image into blocks to obtain sub-blocks; map the gradient direction angle of each pixel in each sub-block to obtain the edge direction angle of each pixel; construct a weighted direction histogram using the edge direction angle of each pixel in a sub-block, and obtain the main direction of the sub-block.
[0019] First, surface images of the leaf spring need to be acquired. This is done using a near-infrared (center wavelength 850nm) LED light source for illumination, coupled with an industrial camera equipped with a rotatable polarizer (placed in front of the camera lens and adjusted to the optimal extinction angle). Near-infrared light can penetrate paint coatings, enhancing the reflection signal from cracks in the metal substrate; the polarizer suppresses specular reflections caused by curved surfaces, eliminating overly bright areas. The acquired surface image is an 8-bit grayscale image, denoted as [image description needed]. ,in , , , These are the image width and height, respectively (e.g., W=1024, H=768).
[0020] Furthermore, the surface image is preprocessed. Specifically, median filtering is used to remove salt-and-pepper noise from the surface image while preserving edge information. The filter window size is set to 3×3. For each pixel (x,y), the median gray value of its neighboring pixels is taken as the output to obtain the preprocessed smooth image I, which is recorded as the target image of the surface image.
[0021] Cracks on the surface of a leaf spring typically extend in a certain direction, but due to the curved surface and stress distribution, the local direction may vary. Therefore, it is necessary to estimate the principal direction of each local region to provide a directional reference for subsequent ridge transformation.
[0022] Therefore, local analysis requires dividing the target image. Specifically, the target image is divided into M×N overlapping sub-blocks, each sub-block being w×w in size. The distance between the center points of two adjacent sub-blocks in the horizontal direction is s, and the distance between the center points of two adjacent sub-blocks in the vertical direction is also s; where w and s are in pixels, in this application w is 64 pixels and s is 16 pixels. Overlapping block division avoids abrupt changes in direction at block boundaries and enhances the continuity of detection. The number of sub-blocks is: , For each sub-block ( , Its upper left corner coordinates are .
[0023] Furthermore, it is necessary to obtain the gradient magnitude and gradient direction angle of each pixel in each sub-block, thereby determining the gradient magnitude and direction angle of each sub-block. For each pixel (u,v) within the range, the horizontal gradient is calculated using the Sobel operator. and vertical gradient The gradient magnitude is: , The gradient direction angle (angle, expressed in radians) is: , This allows us to obtain the gradient direction angle and gradient magnitude for each pixel. Additionally, we need to map the gradient direction angle of each pixel, changing the range [-π / 2, π / 2] to [0, π) (because the edge direction is unsigned). This gives us the edge direction angle θ(u, v) for each pixel. Since the gradient direction at the crack edge is perpendicular to the crack direction, the ridge transform needs to be integrated along the crack direction. However, the crack direction is perpendicular to the edge direction, so a conversion is necessary. In this example, we directly use the gradient direction to represent the edge direction because the edge and crack direction are perpendicular; therefore, the edge direction angle is the sum of the gradient direction angle and π / 2.
[0024] Furthermore, a weighted orientation histogram is constructed using the edge orientation angles of each pixel in a sub-block, and the main orientation of the sub-block is obtained.
[0025] Specifically, the range of edge direction angles is divided into K intervals (K=36, each interval width is 5°), and each interval is used as the x-coordinate of the weighted direction histogram; the gradient magnitudes of each pixel point of the edge direction angle belonging to an interval in a sub-block are added together to obtain the y-coordinate of that interval.
[0026] For a weighted directional histogram of a sub-block, the ordinate calculation model for the k-th interval is as follows: , in, The ordinate represents the weighted statistical value of the k-th interval in the weighted directional histogram corresponding to the sub-block, i.e., the ordinate, indicating the sub-block. The sum of gradient magnitudes of pixels at all edge corners in the k-th interval; the value of k ranges from 0, 1, ..., K-1, where K is the total number of intervals (K=36 in this application). traverse sub-blocks Each pixel within the coordinates is (u,v); G(u,v) represents the gradient magnitude at pixel (u,v), calculated by the Sobel operator, reflecting the intensity of the grayscale change at that point; the larger the gradient magnitude, the more likely the point is to be part of an edge or texture; θ(u,v) represents the edge orientation angle at pixel (u,v), which, after mapping, ranges from... Because the edge direction is unsigned; the gradient direction is perpendicular to the direction of the local image structure (e.g., perpendicular to the crack direction); δ( The parentheses () represent the Dirac delta function (indicator function), which takes the value 1 if the condition within the parentheses is true, and 0 otherwise. Here, the condition is... That is, to determine whether the edge direction angle obtained after mapping the gradient direction of the pixel belongs to the k-th interval. This indicates a floor operation, used to discretize consecutive edge direction angles into integer interval indices; This represents a linear transformation that maps the edge direction angle θ(u,v) from radians to an interval index. Since θ∈[0,π), multiplying by K / π yields... The real number is rounded down to obtain the integer index 0, 1, ..., K-1. Each index corresponds to an interval with a width of π / K radians (i.e., ..., K-1). (because K=36).
[0027] For each pixel in a sub-block, the gradient magnitude of each pixel is accumulated as the weight of the interval (the ordinate of the interval) based on the interval to which its edge orientation angle belongs. In this way, pixels with larger gradient magnitudes contribute more to the orientation statistics, reflecting the dominant orientation of significant edges.
[0028] Next, the main direction corresponding to a sub-block is obtained using the weighted direction histogram corresponding to that sub-block. Specifically, the index of the interval corresponding to the peak value in the weighted direction histogram of the sub-block is recorded as the peak interval index; the result of adding the peak interval index to a first preset value is divided by the number of intervals in the weighted direction histogram, and then multiplied by π to obtain the initial main direction of the sub-block; the main direction of the sub-block is obtained by smoothing using the initial main directions of the sub-blocks in the preset neighborhood of the sub-block.
[0029] The specific calculation model for the initial main direction of a sub-block is as follows: , in, The initial main direction of a sub-block is defined by an angle. This represents the index of the interval corresponding to the peak value in the weighted orientation histogram of the sub-block, which is also the index of the interval with the largest ordinate. This is denoted as the peak interval index. The interval with the largest gradient magnitude is the interval where the pixel gradient directions are most concentrated within the sub-block, reflecting the dominant direction of the local image structure. K is the total number of intervals in the weighted orientation histogram, which is 36, meaning that the gradient direction range [0, ... The area is evenly divided into 36 intervals, each interval having a width of [missing information]. / radian( The choice of K=36 is to strike a balance between the accuracy and computational complexity of direction estimation, capturing subtle direction changes without causing sparsity in the histogram due to too many intervals. π represents pi and is used to convert the normalized scale to radians. The gradient direction ranges from [0,π), i.e. Therefore, the angle value obtained by multiplying by π is within the range of [0, π) radians; the second preset value is 0.5. This represents the index offset from the center of the interval. Since the histogram intervals are discrete, each interval covers an angle range (e.g., the angle range of the k-th interval is...). ), use directly This corresponds to the left boundary of the interval, but the actual dominant direction may fall anywhere within the interval. To reduce quantization error and estimate the dominant direction more accurately, the center position of the interval is taken, i.e. , represents the index of the midpoint of the interval, and dividing by K indicates normalizing the interval center index to . The interval is used to obtain the relative position of the center within the entire directional range. Multiplying by π represents mapping the normalized value back to the actual angle value (radians), resulting in the final initial principal direction. .
[0030] Since noise or local texture may cause individual sub-block orientation anomalies, the orientation field needs to be smoothed. Therefore, for a sub-block, the main orientation of the sub-block is obtained by smoothing the initial main orientation of each sub-block in the preset neighborhood of the sub-block (the preset neighborhood in this application is a 3×3 neighborhood). (Note that the edge orientation angle is a periodic function and the angle wrapping needs to be handled.)
[0031] The specific calculation model for the main direction of a sub-block is as follows: , in, For sub-blocks The `angle_mean` function converts the initial principal direction of each sub-block within its 3×3 neighborhood into a unit vector. Take the average and then half of the arctangent to eliminate... The fuzziness allows us to determine the main direction of the sub-block. This is the initial main direction for each sub-block within the 3×3 neighborhood of this sub-block.
[0032] The above calculation converts the peak interval indices of the discrete weighted orientation histogram into continuous angle values, serving as the dominant orientation estimate of the image structure within that sub-block. By taking the interval center, a more accurate orientation estimate is obtained than simply using the interval boundaries, thus providing a more accurate orientation reference for subsequent ridge transform. Cracks on the surface of a leaf spring often have a clear local orientation, but due to the influence of surface curvature, crack bending, or coating texture, the crack orientation may change in different regions of the image. Therefore, it is necessary to estimate the orientation independently for each local sub-block. In the formula... The source of this is the weighted orientation histogram constructed above. This histogram sums gradient magnitudes, allowing pixels with larger gradient magnitudes (such as crack edges) to dominate the orientation statistics, while suppressing the influence of noise and weak textures. Therefore, even if the crack occupies only a small number of pixels in the sub-block, as long as the gradient magnitude at the crack edge is strong enough, the peak value of the histogram can correctly reflect the crack direction. Cracks on the surface of leaf springs typically propagate along the stress direction, and the direction is relatively consistent. However, due to the surface curvature, the local direction changes slowly. The main orientation estimation of the sub-block can adapt to this change, ensuring that the subsequent ridge wave transform is integrated along the actual crack direction, maximizing the enhancement of the crack signal.
[0033] Step S2: Perform multi-scale ridge wave transformation on the main direction of a sub-block to obtain the ridge wave coefficients at each scale corresponding to the sub-block; obtain the threshold at the same scale using the ridge wave coefficients of each sub-block; and enhance the ridge wave coefficients at each scale corresponding to a sub-block based on the threshold at each scale to obtain the enhanced ridge wave coefficients at each scale corresponding to the sub-block.
[0034] After the above processing, the principal direction of each sub-block can be obtained. Then, based on the principal direction of each sub-block, a multi-scale ridge wave transform can be performed. The ridge wave transform can be regarded as a combination of Radon transform and one-dimensional wavelet transform, which can effectively represent linear singularities (such as cracks) in the image. In specific implementation, Radon transform is performed on each sub-block along its principal direction to obtain the projected signal, and then wavelet decomposition is performed on the signal to obtain ridge wave coefficients at different scales.
[0035] For sub-blocks (size is) Establish a coordinate system with its geometric center as the origin. ,in , Radon transform along the principal direction Calculating the line integral, we can obtain Where t is the perpendicular distance from the origin to the line (with a sign), and its value range is... , Then integrate the obtained line integral. Discretization yields the final discrete signal. ;right One-dimensional wavelet decomposition is performed using the Daubechies-4 wavelet (which has good compact support and regularity). Number of decomposition levels. Corresponding scale , (i.e., scales 2, 4, and 8 pixels). Wavelet transform decomposes the signal into approximation coefficients (low frequency) and detail coefficients (high frequency). This invention only enhances the detail coefficients because cracks belong to high-frequency details. Therefore, the detail coefficients are denoted as ridge coefficients, and the ridge coefficients at each scale corresponding to the sub-block can be obtained. Thus, for a sub-block, a sequence of ridge coefficients at three scales can be obtained. That is, the ridge coefficients at one scale form a ridge coefficient sequence. Scales 2, 4, and 8 each correspond to a ridge coefficient sequence, and the length of each sequence is approximately [a fraction of] the length of the original signal. .
[0036] Cracks in leaf springs appear as linear structures in images, typically with a width between 1 and 3 pixels. In multi-scale ridge transform, scale 2 corresponds to the finest crack edge, scale 4 to the main crack body, and scale 8 to wider cracks or clustered areas. Multi-scale analysis can capture cracks of varying widths, improving detection robustness.
[0037] The amplitude of the ridge wave coefficient corresponding to the crack is usually greater than that of the background noise. Therefore, the crack can be enhanced by thresholding and amplifying significant coefficients. However, the threshold needs to be adaptive to each scale because the dynamic range of the coefficients is different at different scales.
[0038] Therefore, the threshold at that scale is obtained using the ridge wave coefficients of each sub-block at the same scale. Specifically, the mean and standard deviation of the ridge wave coefficients of each sub-block at the same scale are obtained, and the threshold at that scale is obtained by adding the product of the first parameter and the standard deviation to the mean.
[0039] The specific calculation model for the threshold at one scale is as follows: , in, This represents the threshold at scale a (scales 2, 4, and 8). and Let represent the mean and standard deviation of the ridge coefficient at each sub-block scale 'a', respectively. λ is the first parameter, which is adjustable (usually taken as 2-3). The noise figure typically follows a Gaussian distribution, while the crack coefficient is an outlier; a value of λ=2.5 can suppress approximately 98% of the noise. The threshold for each scale can then be obtained.
[0040] Then, based on the threshold at each scale, the ridge wave coefficients at each scale corresponding to a sub-block are enhanced to obtain the enhanced ridge wave coefficients at each scale corresponding to the sub-block. Specifically, if the absolute value of a ridge wave coefficient at a scale of the sub-block is greater than the threshold at that scale, the ridge wave coefficient at that scale of the sub-block is multiplied by the second parameter to obtain the enhanced ridge wave coefficient corresponding to the ridge wave coefficient at that scale of the sub-block; if the absolute value of a ridge wave coefficient at a scale of the sub-block is less than or equal to the threshold at that scale, the ridge wave coefficient at that scale of the sub-block is set to 0 to obtain the enhanced ridge wave coefficient corresponding to the ridge wave coefficient at that scale of the sub-block.
[0041] The specific calculation model for enhancing the ridge wave coefficient is as follows: , in, denoted as the enhanced fundamental wave coefficient corresponding to a fundamental wave coefficient at a sub-block scale a, and c represents the ridge wave coefficient at that sub-block and that scale. The threshold at scale a is determined by the statistical properties of all coefficients at that scale; γ is the second parameter; γ>1 is the second parameter, which is an enhancement factor (e.g., γ=2.5), used to amplify coefficients exceeding the threshold; for each sub-block, after multi-scale ridge transform, a ridge coefficient sequence of three scales is obtained, each sequence corresponding to a different displacement t (i.e., the projection position in Radon transform), where the ridge coefficients at each scale corresponding to each sub-block can be enhanced; The second parameter γ>1 is an enhancement factor (e.g., γ=2.5). This amplifies ridge coefficients greater than the threshold and sets ridge coefficients less than the threshold to zero, thus highlighting the crack signal and suppressing noise and background texture. The second parameter λ controls the strictness of the threshold: a larger λ retains fewer coefficients, but the retained coefficients are more reliable; a smaller λ retains more coefficients, but may introduce more noise. Typically, based on experimental adjustments, setting λ=2.5 effectively suppresses noise while maintaining a high crack detection rate.
[0042] The ridge wave coefficient can be positive or negative, and the crack may correspond to a positive or negative peak (depending on whether the crack is darker or brighter than the background), so the absolute value is used for comparison.
[0043] Multi-scale ridge transform concentrates the energy of linear structures (such as cracks) in a target image onto a few ridge coefficients, which typically have large amplitudes; while the energy of random disturbances such as background noise and coating textures is dispersed, resulting in smaller amplitude ridge coefficients. Therefore, by setting a threshold... This allows us to separate significant ridge coefficients (which may correspond to cracks) from insignificant ridge coefficients (which may correspond to noise). Specifically: when At that time, it was assumed that the ridge wave coefficient was likely caused by a crack, so it was amplified by γ times to enhance the representation of the crack in the reconstructed image. At that time, it was assumed that the ridge wave coefficient was mainly contributed by noise or background texture, so it was set to zero, thereby suppressing these interferences after the inverse transform.
[0044] The surface of a leaf spring may have coating textures or minor scratches. These pseudo-defects typically have a smaller ridge coefficient, while genuine cracks (especially those penetrating the coating) have a larger coefficient. An adaptive threshold can be used to distinguish genuine cracks from the background.
[0045] Therefore, the enhanced ridge wave coefficients corresponding to the ridge wave coefficients at each scale of each sub-block can be obtained, and then the enhanced ridge wave coefficients at each scale of each sub-block can be used for sub-block reconstruction.
[0046] Step S3: Use the enhanced ridge coefficients at each scale corresponding to the sub-block to reconstruct the sub-block and obtain the reconstructed sub-block; use each reconstructed sub-block to obtain the enhanced image of the target image; use the enhanced image to detect surface defects of the automotive leaf spring.
[0047] The enhanced ridge coefficients at each scale corresponding to each sub-block have been obtained. An inverse transform is then required to obtain the reconstructed sub-blocks, which are also the enhanced sub-blocks. Finally, all sub-blocks are stitched together to form a complete image. For a sub-block, the enhanced ridge coefficients corresponding to each ridge coefficient at a given scale are used to form an enhanced ridge coefficient sequence for that scale. One-dimensional wavelet reconstruction is then performed on the enhanced ridge coefficient sequence at each scale to obtain the enhanced Radon domain signal. The filtered back projection method is used to reconstruct the sub-block image from the enhanced Radon domain signal, thus obtaining the reconstructed sub-block; for a given angle θ, firstly... A Fourier transform is performed, multiplied by the frequency domain response of a ramp filter, and then an inverse transform is performed to obtain the filtered projection. This projection is then back-projected onto the image space along the θ direction. Since there is only one angle, the inverse Radon transform is equivalent to expanding the one-dimensional signal into a two-dimensional image along that angle, which is consistent with the linear structure along that direction in the original sub-block.
[0048] Since only one direction (the main direction) is enhanced, the inverse Radon transform can be approximated as creating an all-zero image for each... ,Will The value is assigned to all elements in the image that satisfy the condition. The pixels, i.e., assigned along a straight line, are used to reconstruct the sub-block image at the three scales of a sub-block, denoted as follows: , , We will then combine them using a weighted approach: ,in Indicates a sub-block Reconstructed sub-blocks, weights The weighting can be set based on the main scale of the crack. For example, if the main cracks are small cracks, then scale 2 should be given a higher weight. .
[0049] Furthermore, the enhanced image of the target image is obtained using each reconstructed sub-block. Specifically, each reconstructed sub-block is placed in its original position in the target image. For pixels in the overlapping region, a weighted average method is used to obtain the grayscale value of each pixel in the overlapping region, thus obtaining the enhanced image of the target image. When using the weighted average method to obtain the grayscale value of each pixel in the overlapping region, the weights used are determined by the distance from the pixel to the center of the sub-block; the closer the distance, the greater the weight, such as using Gaussian weights.
[0050] The inverse ridge transform maps the enhanced ridge coefficients back to the image space, significantly enhancing cracks extending along local directions in the original image while suppressing structures in other directions (such as coating textures and noise). Fusion of multi-scale results ensures that cracks of different widths can be enhanced.
[0051] In the enhanced image, cracks appear as highlighted areas, but a few isolated noise points may still exist. Thresholding segmentation and morphological screening are needed to extract the true cracks, and the enhanced image can then be used to detect surface defects in automotive leaf springs.
[0052] Specifically, the enhanced image is uniformly divided into non-overlapping pixel blocks; for each pixel block, the Otsu algorithm is used to calculate the global optimal threshold; the gray values of pixels within a pixel block whose gray values are greater than the global optimal threshold are set to 255, otherwise set to 0, to obtain the local binary image corresponding to that pixel block; the local binary images corresponding to all pixel blocks are stitched together to obtain the global binary image; median filtering is applied to the global binary image to obtain the filtered global binary image; connected components in the global binary image are obtained, and the area of each connected component and the aspect ratio of the minimum bounding rectangle of each connected component are calculated; if the area of a connected component is greater than or equal to the area threshold and the aspect ratio of the connected component is greater than or equal to the aspect ratio threshold, then the connected component is a crack.
[0053] In this application, the pixel block size is 32×32 to avoid the segmentation threshold from failing due to excessively large pixel blocks; a 3×3 median filter is used when filtering the global binary image to remove isolated noise points; connected components (8-neighborhoods) in the global binary image are marked; and an area threshold is set. (pixels), aspect ratio threshold The threshold can be adjusted according to the actual image resolution. Detected crack areas are marked with red rectangles or lines on the original image, and the detection results are output.
[0054] Cracks are typically long and thin in images, while false defects such as dust and pits are often small or nearly circular. Shape screening can further improve detection accuracy.
[0055] It should be noted that the order of the above embodiments of the present invention is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, the above description focuses on specific embodiments of this specification. Additionally, the processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired results. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0056] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.
[0057] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the scope of the present invention and its principles should be included within the protection scope of the present invention.
Claims
1. A method for detecting surface defects in automotive leaf springs based on image recognition, characterized in that, The method includes: The surface image of the leaf spring is acquired and preprocessed to obtain the target image; the target image is divided into blocks to obtain sub-blocks; the gradient direction angle of each pixel in each sub-block is mapped to obtain the edge direction angle of each pixel; a weighted direction histogram is constructed using the edge direction angles of each pixel in a sub-block, and the main direction of the sub-block is obtained; Multi-scale ridge wave transformation is performed on the main direction of a sub-block to obtain the ridge wave coefficients at each scale corresponding to the sub-block; the threshold at the same scale is obtained by using the ridge wave coefficients of each sub-block; and the enhanced ridge wave coefficients at each scale corresponding to a sub-block are obtained by enhancing the ridge wave coefficients at each scale corresponding to the sub-block based on the threshold at each scale. The sub-block is reconstructed using the enhanced ridge coefficients at various scales corresponding to the sub-block; the enhanced image of the target image is obtained using each reconstructed sub-block; and the surface defects of the automotive leaf spring are detected using the enhanced image.
2. The method for detecting surface defects in automotive leaf springs based on image recognition according to claim 1, characterized in that, The process of dividing the target image into sub-blocks includes: The target image is divided into M×N overlapping sub-blocks, each sub-block being w×w in size. The distance between the center points of two adjacent sub-blocks in the horizontal direction is s, and the distance between the center points of two adjacent sub-blocks in the vertical direction is s.
3. The method for detecting surface defects in automotive leaf springs based on image recognition according to claim 1, characterized in that, The step of constructing a weighted orientation histogram using the edge orientation angles of each pixel in a sub-block and obtaining the main orientation of that sub-block includes: Each interval is used as the x-coordinate of the weighted orientation histogram; the gradient magnitudes of each pixel belonging to the edge orientation angle of an interval in a sub-block are summed to obtain the y-coordinate of that interval. The index of the interval corresponding to the peak value in the weighted direction histogram of the sub-block is recorded as the peak interval index; the result of adding the peak interval index to the first preset value is divided by the number of intervals in the weighted direction histogram, and then multiplied by π to obtain the initial main direction of the sub-block; the main direction of the sub-block is obtained by smoothing the initial main direction of the sub-block within the preset neighborhood of the sub-block.
4. The method for detecting surface defects in automotive leaf springs based on image recognition according to claim 1, characterized in that, The step of obtaining the threshold at a given scale using the ridge wave coefficients of each sub-block at the same scale includes: Obtain the mean and standard deviation of the ridge wave coefficients at the same scale for each sub-block, and add the product of the first parameter and the standard deviation to the mean to obtain the threshold at that scale.
5. The method for detecting surface defects in automotive leaf springs based on image recognition according to claim 1, characterized in that, The step of enhancing the ridge wave coefficients at each scale corresponding to a sub-block based on a threshold at each scale to obtain the enhanced ridge wave coefficients at each scale corresponding to that sub-block includes: If the absolute value of a ridge coefficient at a certain scale of the sub-block is greater than the threshold at that scale, the ridge coefficient at that scale of the sub-block is multiplied by the second parameter to obtain the enhanced ridge coefficient corresponding to the ridge coefficient at that scale of the sub-block; if the absolute value of a ridge coefficient at a certain scale of the sub-block is less than or equal to the threshold at that scale, the ridge coefficient at that scale of the sub-block is set to 0 to obtain the enhanced ridge coefficient corresponding to the ridge coefficient at that scale of the sub-block.
6. The method for detecting surface defects in automotive leaf springs based on image recognition according to claim 1, characterized in that, The enhanced image obtained by utilizing each reconstructed sub-block of the target image includes: Each reconstructed sub-block is placed in its original position in the target image. For the pixels in the overlapping area, a weighted average method is used to obtain the gray value of each pixel in the overlapping area, thus obtaining the enhanced image of the target image.
7. The method for detecting surface defects in automotive leaf springs based on image recognition according to claim 1, characterized in that, The method of detecting surface defects in automotive leaf springs using enhanced images includes: The enhanced image is uniformly divided into non-overlapping pixel blocks. For each pixel block, the Otsu algorithm is used to calculate the global optimal threshold. The gray values of pixels within a pixel block whose gray values are greater than the global optimal threshold are set to 255, otherwise set to 0, resulting in a local binary image for that pixel block. The local binary images of all pixel blocks are then concatenated to obtain the global binary image. Median filtering is applied to the global binary image to obtain the filtered global binary image. Connected components in the global binary image are obtained, and the area of each connected component and the aspect ratio of its minimum bounding rectangle are calculated. If the area of a connected component is greater than or equal to an area threshold and its aspect ratio is greater than or equal to an aspect ratio threshold, then the connected component is considered a crack.