Metal piece forging defect detection method and system

By acquiring the crack weight and local structural consistency of each pixel on the surface of a metal forging, adaptively adjusting the length of the structural element and the segmentation threshold, and combining bottom cap transformation and skeleton extraction, the false alarm and false negative problems of traditional morphological methods in metal forging detection are solved, and higher detection accuracy is achieved.

CN121353284BActive Publication Date: 2026-04-07HANZHONG QUNFENG MACHINERY MFG
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-18
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Traditional morphological methods have high false alarm and false negative rates in the inspection of metal forging surfaces, and cannot adapt to drastic changes in local texture, resulting in insufficient detection accuracy.

Method used

By acquiring the crack weight, local structural consistency, and adaptive structuring element length for each pixel, the segmentation threshold is dynamically adjusted. Combined with bottom-hat transformation and skeleton extraction algorithms, crack defects are accurately identified.

Benefits of technology

It improves the accuracy of crack detection in complex backgrounds, reduces false alarm and false negative rates, and ensures the precision of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121353284B_ABST
    Figure CN121353284B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of image processing, and particularly relates to a metal piece forging defect detection method and system. The method comprises the following steps: collecting a metal forging surface image, and obtaining a crack weight of each pixel point in the metal forging surface image; based on the crack weight and a gradient vector of a pixel point in a local window of each pixel point, obtaining a local structure consistency of each pixel point; according to the local structure consistency, obtaining a length of a structure element of each pixel point and constructing the structure element of each pixel point, performing morphological processing on the metal forging surface image to obtain a metal forging surface enhanced image, obtaining a segmentation threshold of each pixel point in the metal forging surface enhanced image to perform threshold segmentation, obtaining a binary image, extracting a skeleton segment based on the binary image, and obtaining a probability that each skeleton segment is a crack; and based on the probability, obtaining a crack. The present application improves the accuracy of crack detection in a complex background.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a method and system for detecting defects in metal forging. Background Technology

[0002] Cracks are one of the most common and serious defects in the metal forging process. They not only affect the mechanical properties and service life of metals, but may also lead to product failure. Therefore, timely detection of crack defects is crucial to ensuring the quality of metal parts.

[0003] Morphological analysis methods, especially algorithms combining cap transformation and skeleton extraction, are often used to detect crack-like defects due to their sensitivity to linear structural features. These methods typically enhance the features of suspected defects through cap transformation, then perform binarization, and finally extract the skeleton from the connected components in the binary image. Crack defects are then identified by analyzing the features of the skeleton. However, existing morphological analysis-based detection methods have significant limitations when applied to the surface of metal forgings. The surface of metal forgings is not uniform and smooth; its inherent rough base, forging flow lines, and noise together constitute an extremely complex background. These normal background textures may exhibit linear or edge features on the image that are very similar to real crack defects.

[0004] Traditional morphological methods use globally uniform structural elements to enhance images, and then use fixed binarization thresholds to segment crack defects. This method cannot adapt to the drastic changes in local textures on the surface of metal forgings. The globally uniform structural elements and fixed binarization thresholds may misclassify a large number of background textures (such as rough background edges and forging flow lines) as defects, resulting in a high false alarm rate. It may also miss real defects, leading to false negatives. Summary of the Invention

[0005] To address the technical problem that traditional morphological methods, which use globally uniform structural elements to enhance images and use fixed binarization thresholds to segment crack defects, may misclassify a large number of background textures (such as rough background edges and forging streamlines) as defects, resulting in a high false alarm rate, or may miss real defects, this invention provides a method and system for detecting forging defects in metal parts.

[0006] In a first aspect, the present invention provides a method for detecting forging defects in metal parts, employing the following technical solution:

[0007] A method for detecting forging defects in metal parts, comprising the following steps:

[0008] Acquire an image of the surface of a metal forging; obtain the edge sharpness and dark feature level of each pixel in the surface image of the metal forging; obtain the crack weight of each pixel based on the edge sharpness and dark feature level; perform weighted summation of the gradient vectors of pixels in the local window of each pixel based on the crack weight to obtain the local cooperative gradient vector of each pixel; normalize the local cooperative gradient vector to obtain the local structural consistency of each pixel.

[0009] Based on the local structural consistency, the length of the structural element of each pixel is obtained; based on the length of the structural element of each pixel, the structural element of each pixel is obtained; the structural element of each pixel is input into the bottom-hat transform algorithm to perform morphological processing on the surface image of the metal forging to obtain the surface enhancement image of the metal forging; the segmentation threshold of each pixel in the surface enhancement image of the metal forging is obtained; based on the segmentation threshold, the surface enhancement image of the metal forging is segmented to obtain a binary image;

[0010] Skeleton segments are extracted from connected components in a binary image; the probability of each skeleton segment being a crack is obtained, and the crack is identified.

[0011] The innovation of this invention lies in obtaining the crack weight of each pixel, thereby achieving local structural consistency for each pixel. This enables accurate differentiation between real cracks and background textures, making subsequent feature enhancement and target extraction more accurate. Furthermore, based on the local structural consistency, the length of the structural element of each pixel is adaptively obtained. The algorithm can use longer structural elements to enhance and connect cracks, and use shorter structural elements to avoid enhancing irrelevant textures, achieving precise control over feature enhancement. Further, by dynamically adjusting the segmentation threshold based on local structural consistency to obtain a binary image, the threshold can be automatically lowered to ensure crack detection. Finally, crack defects are identified based on the binary image, improving the accuracy of crack detection in complex backgrounds.

[0012] Preferably, the step of acquiring the edge sharpness and dark feature level of each pixel in the surface image of the metal forging includes:

[0013] , This represents the edge sharpness of the i-th pixel. This represents the gradient magnitude of the i-th pixel. Represents the sharpness enhancement factor;

[0014] , Represents the degree of darkness of the i-th pixel; The maximum grayscale value of all pixels in the image representing the surface of the metal forging; This represents the grayscale value of the i-th pixel. This represents the darkness enhancement factor.

[0015] Preferably, obtaining the crack weight of each pixel includes:

[0016] ;

[0017] In the formula, Represents the crack weight at the i-th pixel; This represents the edge sharpness of the i-th pixel. This represents the degree of darkness of the i-th pixel.

[0018] Based on edge sharpness and dark feature intensity, crack weights are obtained, which can effectively identify cracks in the initial stage and suppress background interference.

[0019] Preferably, obtaining the local cooperative gradient vector for each pixel includes:

[0020] The Sobel operator is used to obtain the gradient vector of each pixel in the surface image of the metal forging; the preset local window size is [value missing]. ; Construct a system centered on the i-th pixel of the metal forging surface image. The window is used as a local window for the i-th pixel in the surface image of the metal forging;

[0021] , Represents the local cooperative gradient vector of the i-th pixel; This represents the number of pixels in the local window containing the i-th pixel. The crack weight represents the j-th pixel in the local window of the i-th pixel. This represents the gradient vector of the j-th pixel within the local window of the i-th pixel.

[0022] Preferably, obtaining the local structural consistency of each pixel includes:

[0023] , Represents the local structural consistency of the i-th pixel; Represents the local cooperative gradient vector of the i-th pixel; The crack weight represents the j-th pixel in the local window of the i-th pixel. The magnitude of the gradient vector of the j-th pixel in the local window of the i-th pixel represents the gradient vector of the j-th pixel.

[0024] Preferably, obtaining the length of the structuring element for each pixel includes:

[0025] Acquire historical metal forging surface images where cracks were detected, and obtain the bounding rectangle of each crack in each historical metal forging surface image; take the maximum length of the bounding rectangles of all cracks in all historical metal forging surface images as the maximum length of the structuring element; take the minimum length of the bounding rectangles of all cracks in all historical metal forging surface images as the minimum length of the structuring element.

[0026] , The length of the structuring element representing the i-th pixel; This represents the minimum length of a linear structuring element. Represents the maximum length of a struct element; This represents the local structural consistency of the i-th pixel.

[0027] By dynamically adjusting the length of structuring elements in morphological transformations based on local structural consistency, the algorithm can use longer structuring elements to enhance and connect cracks, and use shorter structuring elements to avoid enhancing irrelevant textures, thus achieving precise control over feature enhancement.

[0028] Preferably, obtaining the structural element of each pixel based on the length of the structural element of each pixel includes:

[0029] The minimum length of the bounding rectangle of all cracks in all historical metal forging surface images is taken as the minimum length of the structuring element.

[0030] The pixel corresponding to the maximum gradient value in the local window of the i-th pixel in the surface image of the metal forging is denoted as the target pixel. The gradient direction between the i-th pixel and the target pixel is taken as the principal gradient direction of the pixel. The principal gradient direction of each pixel is taken as the direction of the structuring element of each pixel. The structuring element of each pixel is constructed according to the width and length of the structuring element of each pixel.

[0031] This makes the shape of the structural element similar to that of the crack, and the orientation of the structural element is consistent with that of the crack, which makes the subsequent crack reinforcement effect better.

[0032] Preferably, obtaining the segmentation threshold for each pixel in the surface enhancement image of the metal forging includes:

[0033] The average gray value of all pixels in the surface enhancement image of the metal forging is used as the initial segmentation threshold for the surface enhancement image of the metal forging.

[0034] , The segmentation threshold represents the i-th pixel in the surface enhancement image of the metal forging; The initial segmentation threshold represents the surface enhancement image of the metal forging; This represents the local structural consistency of the i-th pixel in the surface enhancement image of a metal forging.

[0035] Preferably, the step of obtaining the probability that each skeleton segment is a crack and identifying the crack includes:

[0036] A skeleton extraction algorithm is used to extract the skeleton of connected components in a binary image to obtain each skeleton segment.

[0037] , This represents the probability that the k-th skeleton segment is a crack; This represents the number of pixels on the k-th skeleton segment; The mean value represents the local structural consistency of all pixels on the k-th skeleton segment; norm() represents the normalization function.

[0038] A preset probability threshold T is set. If the probability that any skeleton segment is a crack is greater than or equal to the probability threshold, then the skeleton segment is considered to be a crack.

[0039] It improves the accuracy of crack detection in complex background textures.

[0040] Secondly, the present invention provides a metal forging defect detection system, which adopts the following technical solution:

[0041] A metal forging defect detection system 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 aforementioned metal forging defect detection method is implemented.

[0042] By adopting the above technical solution, a computer program for detecting defects in metal forging is generated and stored in a memory so that it can be loaded and executed by a processor. A terminal device can then be made based on the memory and processor for convenient use.

[0043] This invention has the following technical effects: Firstly, by acquiring the crack weight of each pixel and then obtaining the local structural consistency of each pixel based on that crack weight, this indicator can accurately distinguish between true cracks and inherent forging streamline textures and background textures such as noise, making subsequent feature enhancement and extraction targets clearer. Secondly, based on the local structural consistency of each pixel, the length of the structural element of each pixel is adaptively obtained, allowing the algorithm to use longer structural elements to enhance and connect cracks in crack regions, while using shorter structural elements in background regions to avoid enhancing irrelevant textures, thus achieving precise control over feature enhancement. Thirdly, by dynamically adjusting the segmentation threshold based on local structural consistency to obtain a binary image, the threshold can be automatically lowered to ensure crack detection. Finally, crack defects are identified based on the binary image, improving the accuracy of crack detection in complex backgrounds. Attached Figure Description

[0044] Figure 1 This is a flowchart of a method for detecting forging defects in metal parts according to an embodiment of the present invention. Detailed Implementation

[0045] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments.

[0046] This invention discloses a method for detecting forging defects in metal parts, referring to... Figure 1 This includes steps S1-S4:

[0047] S1: Acquire images of the surface of the metal forging.

[0048] In this embodiment of the invention, a camera is used to capture an RGB image of the metal forging surface. To facilitate subsequent analysis, the RGB image of the metal forging surface is converted to grayscale to obtain a surface image of the metal forging.

[0049] S2: Obtain the edge sharpness and dark feature degree of each pixel in the surface image of the metal forging; based on the edge sharpness and dark feature degree, obtain the crack weight of each pixel; based on the crack weight, weight the gradient vector of the pixel in the local window of each pixel to obtain the local collaborative gradient vector of each pixel; based on the local gradient vector, obtain the local structural consistency of each pixel in the surface image of the metal forging.

[0050] It should be noted that the actual crack edges on the surface of a metal forging are sharp, with large gradient amplitudes at the pixels on the crack edges. In contrast, the transition of the forging streamline edges on the surface of a metal forging is relatively smooth, meaning that the gradient amplitudes at the pixels on the forging streamline edges are smaller. Furthermore, the gradient amplitudes of pixels in the smooth background area on the surface of a metal forging are also small. Therefore, based on the gradient value of each pixel in the image, the edge sharpness of each pixel in the image of the metal forging surface is obtained. The larger the value, the more likely the pixel is to be a crack edge. Also, since the grayscale value of the cracks on the surface of a metal forging is much lower than that of the surrounding background area and the pixels on the forging streamline edges of the metal forging surface, the dark feature intensity of each pixel in the image of the metal forging surface is obtained based on the grayscale value of each pixel. The larger the value, the more likely the pixel is to be a crack edge.

[0051] Therefore, the crack weight of each pixel in the surface image of the metal forging is obtained by combining the edge sharpness and dark feature degree of each pixel.

[0052] In this embodiment of the invention, the edge sharpness of each pixel in the surface image of the metal forging is obtained:

[0053] ;

[0054] In the formula, This represents the edge sharpness of the i-th pixel. This represents the gradient magnitude of the i-th pixel. Representing the sharpness enhancement coefficient, in this embodiment of the invention, the preset number of sharpness enhancements... In order to amplify the edge sharpness of pixels with high gradient amplitude, the greater the edge sharpness, the more likely the pixel is to belong to the crack edge.

[0055] Obtain the dark feature level of each pixel in the surface image of the metal forging:

[0056] ;

[0057] In the formula, Represents the degree of darkness of the i-th pixel; The maximum grayscale value of all pixels in the image representing the surface of the metal forging; This represents the grayscale value of the i-th pixel. Representing the darkness enhancement coefficient, in this embodiment of the invention, a preset darkness enhancement coefficient is used. At this point, the dark feature intensity of pixels with lower grayscale values ​​is magnified. The greater the dark feature intensity, the more likely the pixel is to belong to the crack edge.

[0058] Obtain the crack weight of each pixel in the surface image of the metal forging:

[0059] ;

[0060] In the formula, Represents the crack weight at the i-th pixel; This represents the edge sharpness of the i-th pixel. Represents the degree of darkness of the i-th pixel; The larger the value, the more likely the i-th pixel is to be at the edge of the crack.

[0061] It should be noted that the most essential feature of cracks in terms of geometric morphology is linearity, while noise and rough background textures in the surface image of metal forgings do not have linear features in terms of aggregate morphology. Therefore, the gradient vectors of pixels on the crack edge are relatively consistent, while the gradient vectors of pixels surrounding the rough texture or image noise on the forging surface have different directions. Therefore, a local window is constructed for each pixel, and the gradient vectors of each pixel in the local window are weighted and summed based on the crack weight to obtain the local collaborative gradient vector of each pixel.

[0062] It should be further explained that the magnitude of the local cooperative gradient vector intuitively reflects the consistency in direction of the gradient vectors of all possible crack-representing pixels within a local window of a pixel in the image. If the gradient vectors of pixels with higher crack weights within the local window of any pixel in the metal forging surface image are more consistent, the magnitude of the local cooperative gradient vector is larger, and the pixel is more likely to belong to a crack. Conversely, if the gradient vectors of pixels with higher crack weights within the local window are disordered in direction, they will cancel each other out, and the magnitude of the local cooperative gradient vector is smaller. Then, this invention normalizes the magnitude of the local cooperative gradient vector of each pixel in the metal forging surface image to obtain the local structural consistency of each pixel in the metal forging surface image. The larger the value, the more likely the pixel is to belong to a crack.

[0063] In this embodiment of the invention, the Sobel operator is used to obtain the gradient vector of each pixel in the surface image of the metal forging;

[0064] The default local window size is ; Construct a system centered on the i-th pixel of the metal forging surface image. The window is used as a local window for the i-th pixel in the surface image of the metal forging;

[0065] Obtain the local cooperative gradient vector of each pixel in the surface image of the metal forging:

[0066] ;

[0067] In the formula, Represents the local cooperative gradient vector of the i-th pixel; This represents the number of pixels in the local window containing the i-th pixel. The crack weight represents the j-th pixel in the local window of the i-th pixel. The gradient vector of the j-th pixel in the local window representing the i-th pixel; The larger it is, The greater the value of , the greater its contribution to the local cooperative gradient vector of the i-th pixel;

[0068] In this embodiment of the invention, the local structural consistency of each pixel in the surface image of the metal forging is obtained:

[0069] ;

[0070] In the formula, Represents the local structural consistency of the i-th pixel; Represents the local cooperative gradient vector of the i-th pixel; The crack weight represents the j-th pixel in the local window of the i-th pixel. The magnitude of the gradient vector of the j-th pixel within the local window of the i-th pixel; This represents the number of pixels in the local window containing the i-th pixel. The larger the value, the more likely the i-th pixel is to be at the edge of the crack.

[0071] S3: Based on the local structural consistency of each pixel in the surface image of the metal forging, obtain the length of the structural element of each pixel; construct the structural element of each pixel based on the length of the structural element and input it into the bottom-hat transformation algorithm to perform morphological processing on the surface image of the metal forging to obtain the surface enhancement image of the metal forging; obtain the segmentation threshold of each pixel in the surface enhancement image of the metal forging and perform threshold segmentation on the surface enhancement image of the metal forging to obtain a binary image.

[0072] It should be noted that the bottom cap transformation is a morphological image processing operation that can remove the background or enhance local details from an image. For metal forging surface images, the bottom cap transformation is usually used to remove large-scale background information from the surface image, thereby highlighting the crack features in the metal forging surface image. However, traditional morphological bottom cap transformations usually use structuring elements of fixed size and shape, which cannot adapt to the diversity of defects. Therefore, this invention needs to adaptively construct a structuring element for each pixel in the metal forging surface image. In order to enhance the real crack and suppress the background, the structuring element should be consistent with the shape of the crack. Therefore, it is necessary to construct a structuring element for each pixel in the metal forging surface image. The direction of the structuring element should be consistent with the direction of the crack in the local window of the pixel.

[0073] Since the local structural consistency of each pixel in the surface image of a metal forging is positively correlated with the length of the structural element of each pixel, the greater the local structural consistency of any pixel, the greater the probability that the pixel is a crack defect. The length of the structural element of that pixel needs to be set longer, which helps to connect and enhance the complete crack. Conversely, the smaller the local structural consistency of a pixel, the lower the probability that the pixel is a crack defect. In this case, the length of the structural element of that pixel needs to be set shorter, which helps to smooth out noise points and does not enhance the texture of the background area. Therefore, based on the local consistency, the length of the structural element of each pixel in the surface image of the metal forging is adaptively obtained.

[0074] In this embodiment of the invention, historical metal forging surface images with detected cracks are obtained, and the bounding rectangle of each crack in each historical metal forging surface image is obtained; the average width of the bounding rectangles of all cracks in all historical metal forging surface images is used as the width of the structural element of each pixel in the metal forging surface image.

[0075] The maximum length of the bounding rectangle of all cracks in all historical metal forging surface images is taken as the maximum length of the structuring element; the minimum length of the bounding rectangle of all cracks in all historical metal forging surface images is taken as the minimum length of the structuring element.

[0076] The pixel corresponding to the maximum gradient value in the local window of the i-th pixel in the surface image of the metal forging is denoted as the target pixel; the gradient direction between the i-th pixel and the target pixel is taken as the principal gradient direction of the pixel; it should be noted that the principal gradient direction represents the orientation of the crack in the local window.

[0077] In this embodiment of the invention, the length of the structural element of each pixel in the surface image of the metal forging is obtained:

[0078] ;

[0079] In the formula, The length of the structuring element representing the i-th pixel; This represents the minimum length of a linear structuring element. Represents the maximum length of a struct element; Represents the local structural consistency of the i-th pixel;

[0080] This reflects the minimum crack length in historical metal forging surface images, therefore... The basic length of the structural element for each pixel;

[0081] The range of differences in the length of structural elements represents the variation, while the local structural consistency of the i-th pixel reflects whether there are obvious cracks in that region. Therefore, the greater the local structural consistency, the better. A larger value indicates a longer structuring element length for the i-th pixel, which helps to connect and strengthen the complete crack; conversely, a smaller local structural consistency for the i-th pixel... The smaller the value, the shorter the length of the structuring element of the i-th pixel, which helps to smooth out noise and unnecessary background textures and avoid misidentification as cracks.

[0082] In this embodiment of the invention, the principal gradient direction of each pixel is used as the direction of the structural element of each pixel, and the structural element of each pixel is constructed according to the width and length of the structural element of each pixel. The structural element of each pixel is input into the bottom cap transformation algorithm to enhance the surface image of the metal forging, thereby obtaining the enhanced surface image of the metal forging.

[0083] It should be noted that when segmenting cracks in enhanced images of metal forging surfaces, care must be taken to avoid misclassifying non-crack features such as noise, forging flow lines, or rough background textures as cracks. Furthermore, metal forging surfaces typically have complex textures and structures, and the size, shape, direction, and contrast with the surrounding material of cracks may vary depending on their location. A simple global threshold may not be able to accommodate such variations. Therefore, a more refined segmentation can be achieved by obtaining a segmentation threshold for each pixel.

[0084] In this embodiment of the invention, the average gray value of all pixels in the surface enhancement image of the metal forging is used as the initial segmentation threshold of the surface enhancement image of the metal forging.

[0085] Obtain the segmentation threshold for each pixel in the surface enhancement image of the metal forging:

[0086] ;

[0087] In the formula, The segmentation threshold represents the i-th pixel in the surface enhancement image of the metal forging; The initial segmentation threshold represents the surface enhancement image of the metal forging; The local structural consistency of the i-th pixel in the surface enhancement image of the metal forging should be noted. It should be noted that the local structural consistency of the i-th pixel in the surface enhancement image of the metal forging refers to the local structural consistency of that pixel in the surface image of the metal forging.

[0088] The greater the local structural consistency of the i-th pixel in the surface enhancement image of a metal forging, the more likely the i-th pixel is to be considered a crack. In this case, the segmentation threshold for the i-th pixel is set lower, making it easier to detect. Conversely, the greater the local structural consistency of the i-th pixel in the surface enhancement image of a metal forging, the less likely the i-th pixel is to be considered a crack. In this case, the segmentation threshold for the i-th pixel is set higher to avoid misjudging non-crack features such as noise, forging flow lines, and rough background textures as cracks.

[0089] In the surface enhancement image of the metal forging, pixels with a segmentation threshold greater than the gray value are taken as target pixels, and the gray value of the target pixels is set to 0. Conversely, pixels other than the target pixels in the surface enhancement image of the metal forging are set to 255, thus obtaining a binary image.

[0090] S4: Extract skeleton segments from the binary image and obtain the probability that each skeleton segment is a crack; obtain the crack based on the probability that each skeleton segment is a crack.

[0091] It should be noted that when extracting skeleton segments based on binary images, it is necessary to analyze whether the skeleton segments are cracks in order to avoid misidentifying background textures as cracks and causing misjudgments.

[0092] Local structural consistency reflects the probability that a pixel belongs to a crack feature. If the mean of local structural consistency of all pixels on a skeleton segment is larger, it may be more consistent with the characteristics of a crack, because cracks usually show a certain regularity in images. In some cases, cracks may appear as long and continuous skeleton segments, while other background textures may just be some isolated small areas. By considering the length of the skeleton segment, cracks and background textures can be effectively distinguished. That is to say, cracks often have a certain length and continuity, while noise, forging streamlines or background rough textures may be more local and shorter.

[0093] In this embodiment of the invention, a skeleton extraction algorithm is used to extract the skeleton of the connected components in the binary image to obtain each skeleton segment;

[0094] Obtain the probability that each skeleton segment is a crack:

[0095] ;

[0096] In the formula, This represents the probability that the k-th skeleton segment is a crack; This represents the number of pixels on the k-th skeleton segment; The mean of the local structural consistency of all pixels on the k-th skeleton segment is represented by norm(), which is a normalization function. The longer the number of pixels on the k-th skeleton segment and the larger the mean of the local structural consistency, the greater the probability that the k-th skeleton segment is a crack.

[0097] In this embodiment of the invention, the preset probability threshold T = 0.75. In other embodiments, the implementer may preset the value of T according to the specific implementation situation. If the probability that any skeleton segment is a crack is greater than or equal to the probability threshold, the skeleton segment is a crack.

[0098] 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, all equivalent changes made in accordance with the structure, shape and principle of the present invention should be covered within the scope of protection of the present invention.

Claims

1. A method for detecting forging defects in metal parts, characterized in that, include: Acquire images of the surface of metal forgings; To obtain the edge sharpness and dark feature level of each pixel in the surface image of a metal forging; Based on edge sharpness and dark feature intensity, the crack weight of each pixel is obtained; the gradient vectors of pixels in the local window of each pixel are weighted and summed based on the crack weight to obtain the local cooperative gradient vector of each pixel; the local cooperative gradient vector is normalized to obtain the local structural consistency of each pixel. Based on the local structural consistency, obtain the length of the structural element of each pixel; based on the length of the structural element of each pixel, obtain the structural element of each pixel. The structuring element of each pixel is input into the bottom-hat transform algorithm to perform morphological processing on the surface image of the metal forging, resulting in an enhanced surface image of the metal forging; the segmentation threshold of each pixel in the enhanced surface image of the metal forging is obtained; based on the segmentation threshold, the enhanced surface image of the metal forging is segmented to obtain a binary image; Extract skeleton segments from connected components in a binary image; Obtain the probability that each skeleton segment is a crack, and identify the crack; Obtain the edge sharpness and dark feature level of each pixel in the surface image of the metal forging, including: , This represents the edge sharpness of the i-th pixel. This represents the gradient magnitude of the i-th pixel. Represents the sharpness enhancement factor; , Represents the degree of darkness of the i-th pixel; The maximum grayscale value of all pixels in the image representing the surface of the metal forging; This represents the grayscale value of the i-th pixel. Represents the darkness enhancement factor; Obtain the crack weight for each pixel, including: ; Represents the crack weight at the i-th pixel; This represents the edge sharpness of the i-th pixel. This represents the degree of darkness of the i-th pixel.

2. The method for detecting forging defects in metal parts according to claim 1, characterized in that, Obtain the local cooperative gradient vector for each pixel, including: The Sobel operator is used to obtain the gradient vector of each pixel in the surface image of the metal forging; the preset local window size is [value missing]. ; Construct a system centered on the i-th pixel of the metal forging surface image. The window is used as a local window for the i-th pixel in the surface image of the metal forging; , Represents the local cooperative gradient vector of the i-th pixel; This represents the number of pixels in the local window containing the i-th pixel. The crack weight represents the j-th pixel in the local window of the i-th pixel. This represents the gradient vector of the j-th pixel within the local window of the i-th pixel.

3. The method for detecting forging defects in metal parts according to claim 1, characterized in that, To obtain the local structural consistency of each pixel, including: , Represents the local structural consistency of the i-th pixel; Represents the local cooperative gradient vector of the i-th pixel; The crack weight represents the j-th pixel in the local window of the i-th pixel. The magnitude of the gradient vector of the j-th pixel in the local window of the i-th pixel represents the gradient vector of the j-th pixel.

4. The method for detecting forging defects in metal parts according to claim 1, characterized in that, Get the length of the structuring element for each pixel, including: Acquire historical metal forging surface images where cracks were detected, and obtain the bounding rectangle of each crack in each historical metal forging surface image; take the maximum length of the bounding rectangles of all cracks in all historical metal forging surface images as the maximum length of the structuring element; take the minimum length of the bounding rectangles of all cracks in all historical metal forging surface images as the minimum length of the structuring element. , The length of the structuring element representing the i-th pixel; This represents the minimum length of a linear structuring element. Represents the maximum length of a struct element; This represents the local structural consistency of the i-th pixel.

5. A method for detecting forging defects in metal parts according to claim 1 or 4, characterized in that, Based on the length of the structuring element of each pixel, obtain the structuring element of each pixel, including: The minimum length of the bounding rectangle of all cracks in all historical metal forging surface images is taken as the minimum length of the structuring element. The pixel corresponding to the maximum gradient value in the local window of the i-th pixel in the surface image of the metal forging is denoted as the target pixel. The gradient direction between the i-th pixel and the target pixel is taken as the principal gradient direction of the pixel. The principal gradient direction of each pixel is taken as the direction of the structuring element of each pixel. The structuring element of each pixel is constructed according to the width and length of the structuring element of each pixel.

6. The method for detecting forging defects in metal parts according to claim 1, characterized in that, Obtain the segmentation threshold for each pixel in the surface enhancement image of the metal forging, including: The average gray value of all pixels in the surface enhancement image of the metal forging is used as the initial segmentation threshold for the surface enhancement image of the metal forging. , The segmentation threshold represents the i-th pixel in the surface enhancement image of the metal forging; The initial segmentation threshold represents the surface enhancement image of the metal forging; This represents the local structural consistency of the i-th pixel in the surface enhancement image of a metal forging.

7. The method for detecting forging defects in metal parts according to claim 1, characterized in that, Obtain the probability that each skeleton segment is a crack, and identify the cracks, including: A skeleton extraction algorithm is used to extract the skeleton of connected components in a binary image to obtain each skeleton segment. , This represents the probability that the k-th skeleton segment is a crack; This represents the number of pixels on the k-th skeleton segment; The mean value represents the local structural consistency of all pixels on the k-th skeleton segment; norm() represents the normalization function. A preset probability threshold T is set. If the probability that any skeleton segment is a crack is greater than or equal to the probability threshold, then the skeleton segment is considered to be a crack.

8. A forging defect detection system for metal parts, characterized in that, include: The processor and memory, the memory storing computer program instructions, implement a method for detecting forging defects in metal parts according to any one of claims 1-7 when the computer program instructions are executed by the processor.

Citation Information

Patent Citations

  • Welding defect detection method

    CN117351019A

  • Industrial machine defect visual detection method, system and equipment based on big data

    CN118521580A