Flange forging surface defect detection method and system based on image processing

CN122023235BActive Publication Date: 2026-08-21SHANXI ZHONGXIANG RING FORGING CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511868340.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-11
Publication Date
2026-08-21
Estimated Expiration
2045-12-11

AI Technical Summary

Technical Problem

[0005]为解决上述传统图像处理算法难以在法兰锻件强锻造纹理背景与复杂几何结构的干扰下准确提取甄别微观缺陷、易出现漏检或虚警的技术问题,本发明在如下的多个方面提供方案

Benefits of technology

[0014]本发明采用基于自然指数函数的几何抑制权重计算关系式,建立像素点偏离背景图像程度与权重值之间的映射关系。本发明利用预处理图像与背景图像在对应像素点亮度差值的平方表征偏离程度,在亮度差异较大的法兰边缘等几何突变区域,权重值随差值增大呈指数级衰减,从而降低该区域的信号响应,而在亮度差异较小的平坦区域则保留较高的权重值。同时,本发明引入预处理图像与背景图像之间差值的标准差对关系式中的分母进行调节,实现抑制灵敏度随法兰表面整体粗糙度的自适应调整。这种加权机制在保留潜在缺陷信号的同时,减少因宏观几何结构产生的高亮伪影对检测结果的干扰,提高算法对不同表面质量工况的适应性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122023235B_ABST
    Figure CN122023235B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of image data processing, and more particularly to a flange forging surface defect detection method and system based on image processing, which comprises the following steps: obtaining a flange forging original image and performing differential Gaussian band-pass filtering to obtain a pretreated image; performing multi-scale structure tensor analysis on the pretreated image, and determining texture abnormal values according to the gradient amplitude, the gradient direction and the angle between the local texture direction; extracting a background image through morphological reconstruction, and calculating geometric inhibition weights based on the brightness difference; fusing the texture abnormal values and the geometric inhibition weights to obtain defect response values, and identifying surface defects through threshold segmentation. Through the combination of multi-scale texture analysis and geometric inhibition mechanism, the present application can accurately extract weak defects in a strong texture background, effectively suppress the artifacts generated by the flange geometric structure, and improve the accuracy and robustness of defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image data processing technology, and in particular to a method and system for detecting surface defects in flange forgings based on image processing. Background Technology

[0002] As a critical basic connecting component, flange forgings are commonly used in petrochemical, aerospace, and other scenarios with high safety requirements, often operating under harsh conditions such as high temperature, high pressure, and strong corrosion. Surface defects such as micro-cracks and pits generated during the manufacturing process, if not detected in time, can easily lead to stress concentration and crack propagation, thereby shortening service life or even causing equipment failure. Therefore, defect detection of flange forging surfaces has significant industrial value.

[0003] Currently, machine vision has become the mainstream inspection method. Existing technologies mostly use traditional image processing algorithms: one type uses operators such as Canny and Sobel to calculate gradient magnitudes to identify abrupt edges; the other type uses linear filtering to smooth the image, attempting to separate the background from defects, and then combines this with a fixed threshold for judgment.

[0004] However, existing technologies have limitations in the actual inspection of flange forgings: On the one hand, the surface of flange forgings not only contains disordered noise but also densely covered with streamlined textures formed by the forging process, which appear as high-intensity edge features in images. Existing detection algorithms based on gradient amplitude struggle to extract weak defect signals against strong texture backgrounds. When the defect path is similar to the texture streamlines or the defect signal is submerged in the high-frequency information of the texture, the detection algorithm cannot effectively distinguish them, leading to a high false alarm rate or missed detection of minute cracks. On the other hand, flange forgings have complex geometric topologies, and their macroscopic structures such as inner and outer circular edges, chamfers, and mounting holes generate strong gradient responses in images. Traditional frequency domain or spatial domain filtering methods struggle to achieve accurate decoupling between macroscopic geometric backgrounds and microscopic defect features: if the filtering intensity is too high, it easily smooths out real micro-defects; if the filtering intensity is insufficient, artifacts generated by geometric edges will be misjudged as defects. Summary of the Invention

[0005] To address the technical problem that traditional image processing algorithms struggle to accurately extract and identify micro-defects and are prone to false alarms or missed detections when faced with interference from the strong forging texture background and complex geometric structure of flange forgings, this invention provides solutions in the following aspects.

[0006] In a first aspect, the present invention provides a method for detecting surface defects in flange forgings based on image processing, the method comprising the steps of: The process involves acquiring the original image of the flange forging, performing a bandpass filter based on differential Gaussian to obtain a preprocessed image, performing multi-scale structural tensor analysis on the preprocessed image to obtain the gradient direction and magnitude of each pixel, and calculating the local texture direction of each pixel at different scales. Based on the gradient magnitude and the absolute value of the sine of the angle between the gradient direction and the local texture direction, the texture anomaly value of each pixel is determined. Morphological reconstruction is performed on the preprocessed image to extract the background image, and the geometric suppression weight of each pixel is calculated based on the brightness difference between the preprocessed image and the background image; the geometric suppression weight is negatively correlated with the brightness difference. The texture anomaly value and the geometric suppression weight of each pixel are fused to obtain the defect response value of each pixel. Threshold segmentation is performed on the defect response map constructed from the defect response values ​​to identify surface defects in the flange forging.

[0007] This invention acquires the original image of the flange forging and performs bandpass filtering based on differential Gaussian to reduce the impact of uneven illumination and high-frequency noise on image quality. It utilizes multi-scale structural tensor analysis to obtain gradient direction and local texture direction, determines texture anomalies based on the absolute value of the sine of the angle between them, and identifies directional anomaly signals by leveraging the characteristic of cracks intersecting the forging streamlines, reducing interference from background textures. Furthermore, this invention extracts the background image through morphological reconstruction and calculates geometric suppression weights, reducing the weights of areas such as the flange edge based on brightness differences. The texture anomalies are then fused with the geometric suppression weights to obtain the defect response value, preserving the defect signal while reducing false alarms caused by macroscopic geometric structures, thus improving the accuracy of defect detection.

[0008] Preferably, the calculation of the local texture direction of each pixel at different scales includes: constructing a multi-scale window; for each preset scale, constructing a structure tensor for each pixel in the preprocessed image; calculating the feature vector corresponding to the maximum eigenvalue of the structure tensor of each pixel at the current scale; and determining the direction of the feature vector as the local texture direction of the corresponding pixel at the current scale.

[0009] This invention obtains the dominant direction of the surface texture of flange forgings at different scales by constructing a multi-scale window and calculating the eigenvector corresponding to the maximum eigenvalue of the structural tensor. This direction evaluation method based on statistical characteristics utilizes neighborhood information to smooth local gradient fluctuations, reduces the interference of noise on texture direction judgment, and provides a reference benchmark for subsequent calculation of texture outliers.

[0010] Preferably, constructing a structure tensor for each pixel in the preprocessed image includes: calculating the gradient components of the preprocessed image in the horizontal direction and the gradient components in the vertical direction; calculating the tensor product based on the gradient components in the horizontal direction and the gradient components in the vertical direction; performing convolution smoothing on the tensor product using a Gaussian smoothing kernel, and constructing the structure tensor of the pixel from the smoothed components.

[0011] Preferably, obtaining the texture anomaly value of the pixel includes: calculating the local orientation deviation value at each scale; selecting the maximum value among the local orientation deviation values ​​at different scales and recording it as the texture anomaly value of the corresponding pixel; the local orientation deviation value satisfies the following relationship: ; in, It is a pixel. In scale Local directional deviation value below; It is a pixel. The gradient direction angle; It is a pixel. The local texture direction of the neighborhood; It is a pixel. The gradient magnitude; It is the maximum gradient value in the preprocessed image; It is the absolute value symbol.

[0012] This invention determines texture anomaly values ​​based on the absolute value of the sine of the angle between the gradient magnitude and the gradient direction and the local texture direction, and identifies directional anomaly signals by utilizing the physical characteristic that cracks typically intersect forging flow lines. This invention combines gradient magnitude with weighted bias, reducing the weight of low-contrast noise in defect identification and improving the ability to identify minute defects.

[0013] Preferably, the geometric suppression weights satisfy the following relationship: ; in, It is a pixel. Geometric suppression weights; It is the preprocessing of the image at the pixel level The brightness value; The background image at the pixel level The brightness value; It is the standard deviation of the difference between the preprocessed image and the background image; It is the preset sensitivity adjustment coefficient; It is a natural exponential function.

[0014] This invention employs a geometric suppression weight calculation formula based on the natural exponential function to establish a mapping relationship between the degree of pixel deviation from the background image and the weight value. The invention uses the square of the brightness difference between corresponding pixels in the preprocessed image and the background image to represent the degree of deviation. In geometrically abrupt regions such as flange edges with large brightness differences, the weight value decreases exponentially with increasing difference, thereby reducing the signal response in these areas. Conversely, in flat regions with smaller brightness differences, a higher weight value is retained. Simultaneously, this invention introduces the standard deviation of the difference between the preprocessed image and the background image to adjust the denominator in the formula, achieving adaptive adjustment of suppression sensitivity based on the overall roughness of the flange surface. This weighting mechanism, while preserving potential defect signals, reduces the interference of high-brightness artifacts caused by macroscopic geometric structures on the detection results, improving the algorithm's adaptability to different surface quality conditions.

[0015] Preferably, the step of performing morphological reconstruction on the preprocessed image to extract the background image includes: performing morphological erosion on the preprocessed image using a structuring element of a preset size to obtain a marker image; and performing geodesic dilation on the marker image using the preprocessed image as a mask until convergence to obtain the background image.

[0016] This invention utilizes morphological erosion of a preprocessed image using structuring elements to obtain a labeled image, and then performs geodesic dilatation using the preprocessed image as a mask until convergence to obtain a background image. This processing method fills in microscopic defects while preserving the macroscopic geometric contour of the flange, obtaining a background image that reflects the macroscopic structure, and providing a comparative basis for subsequent evaluation of geometric suppression weights.

[0017] Preferably, the step of fusing the texture anomaly value of each pixel with the geometric suppression weight to obtain the defect response value of each pixel includes: multiplying the texture anomaly value of each pixel with the corresponding geometric suppression weight to obtain the defect response value of each pixel.

[0018] Preferably, the step of thresholding the defect response map formed by the defect response values ​​to identify surface defects of the flange forging includes: thresholding the defect response map formed by the defect response values ​​to obtain a binary image; performing morphological operations on the binary image to extract connected regions to obtain candidate defect regions; calculating the geometric feature parameters of the candidate defect regions; and classifying the candidate defect regions according to preset geometric feature rules to identify surface defects of the flange forging.

[0019] Preferably, the step of performing bandpass filtering on the original image based on difference Gaussian to obtain a preprocessed image includes: convolving the original image with a Gaussian filter having a first standard deviation to obtain a first filtered image, and convolving the original image with a Gaussian filter having a second standard deviation to obtain a second filtered image; wherein the first standard deviation is greater than the second standard deviation; performing pixel-level difference operation to subtract the pixel values ​​of the first filtered image from the pixel values ​​of the second filtered image to obtain a difference image; and linearly stretching and mapping the pixel values ​​of the difference image to a preset range to obtain the preprocessed image.

[0020] In a second aspect, the present invention provides an image processing-based flange forging surface defect detection system, which includes a memory and a processor. The memory stores computer program instructions, and when the computer program instructions are executed by the processor, the image processing-based flange forging surface defect detection method of the first aspect of the present invention is implemented.

[0021] By adopting the above technical solution, the image processing-based flange forging surface defect detection method of the first aspect of the present invention is generated into a computer program 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 the processor for convenient use.

[0022] The beneficial effects of this invention are as follows: This invention uses differential Gaussian bandpass filtering to separate low-frequency interference caused by uneven illumination from high-frequency random noise generated by the sensor in the frequency domain, enhancing the feature information of the flange forging surface and improving the input quality of image processing. This invention utilizes multi-scale structural tensor analysis to evaluate local texture direction and combines gradient information to determine texture outliers. By leveraging the characteristic that defects disrupt texture consistency, it identifies potential defect areas against the complex forging flow lines of the flange forging, reducing interference from background textures. This invention extracts the background image through morphological reconstruction and calculates geometric suppression weights, fusing texture features with geometric position features to suppress artifact signals generated by macroscopic geometric structures such as flange edges and chamfers, reducing false alarm rates while maintaining defect detection rates. Attached Figure Description

[0023] Figure 1 A flowchart of an image processing-based method for detecting surface defects in flange forgings provided in an embodiment of the present invention; Figure 2 The original image of the flange forging surface acquired for an embodiment of the present invention; Figure 3 A flowchart of an image processing-based method for detecting surface defects in flange forgings provided in an embodiment of the present invention; Figure 4This is a structural block diagram of an image processing-based flange forging surface defect detection system provided in an embodiment of the present invention.

[0024] In the figure, 1. Longitudinal cracks in the flat area at the top of the flange; 2. Transverse cracks in the flat area at the bottom of the flange; 3. Dense pitting in the right side of the middle of the flange; 4. Fine cracks near the edge of the mounting hole. Detailed Implementation

[0025] The first aspect of this invention provides a method for detecting surface defects in flange forgings based on image processing, such as... Figure 1 As shown, the method includes steps S100-S400: Step S100: Obtain the original image of the flange forging, and perform bandpass filtering based on differential Gaussian on the original image to obtain a preprocessed image.

[0026] It should be noted that flange forging surface images often contain both low-frequency illumination unevenness interference and high-frequency random noise interference, both of which can easily mask subtle defects. Therefore, this invention introduces a differential Gaussian algorithm with bandpass filtering characteristics. The differential Gaussian algorithm is a feature enhancement algorithm that can simultaneously suppress high-frequency detail interference and low-frequency background interference. Since real defect signals such as cracks and scratches are mainly concentrated in the mid-frequency band in the frequency domain, the differential Gaussian algorithm can construct an accurate frequency domain window, suppressing high-frequency noise while stripping away low-frequency illumination background, thereby improving the signal-to-noise ratio of the image while preserving defect edge features.

[0027] Specifically, raw images of the flange forging surface are acquired using an industrial camera and then converted into single-channel grayscale images. This is done using images with a first standard deviation. A Gaussian filter is used to convolve the grayscale values ​​to obtain a first filtered image; a second standard deviation is then used... A Gaussian filter is used to convolve the grayscale image to obtain a second filtered image. The first standard deviation... Greater than the second standard deviation .

[0028] The application has the first standard deviation Gaussian filter and with second standard deviation A Gaussian filter is used to convolve the grayscale image to obtain a preprocessed image.

[0029] Regarding the setting of filter parameters, the selection is differentiated based on the physical characteristics of the flange surface: for the second standard deviation It is preferable to set a smaller value to slightly smooth the image, filtering out random high-frequency noise introduced by the sensor while preserving edge information of fine cracks as much as possible; for the first standard deviation A larger value is preferably set to simulate the low-frequency background field generated by the illumination distribution and the macroscopic geometry of the flange. This invention preferably... , .

[0030] The window size of a Gaussian filter is determined according to strict statistical principles, namely, the effective window should cover the area extending from the center to both sides. The distance.

[0031] Specifically, the formula for calculating window size is as follows: ,in It is the standard deviation of the corresponding Gaussian filter. and For example, when using the second standard deviation, At this point, the window size is 11 pixels, which ensures that the Gaussian kernel can capture most of the weight energy and avoids the introduction of boundary errors due to window truncation.

[0032] Finally, pixel-level difference operations are performed, subtracting the pixel values ​​of the first filtered image from the pixel values ​​of the second filtered image to obtain the difference image; the pixel values ​​of the difference image are then linearly stretched and mapped to... The range is determined to obtain the preprocessed image.

[0033] like Figure 1 The image shown is the original image of the flange forging surface captured by an industrial camera, which shows the streamline texture and geometry of the flange surface. The image contains four defects to be detected: a longitudinal crack 1 located in the flat area at the top of the flange, a transverse crack 2 located in the flat area at the bottom of the flange, a dense group of pits 3 located in the right side of the middle of the flange, and a fine crack 4 located near the edge of the mounting hole at the bottom right.

[0034] At this point, the preprocessed image has been obtained.

[0035] Step S200: Perform multi-scale structural tensor analysis on the preprocessed image to obtain the gradient direction and gradient magnitude of each pixel, and calculate the local texture direction of each pixel at different scales; determine the texture anomaly value of each pixel based on the gradient magnitude and the absolute value of the sine of the angle between the gradient direction and the local texture direction.

[0036] It should be noted that the normal forging texture on the surface of flange forgings exhibits a highly consistent directional field within local areas, meaning that the gradient vectors of each pixel in the neighborhood tend to be parallel. However, defective areas such as cracks and scratches disrupt this local consistency; the gradient directions of defective pixels are typically orthogonal to or randomly distributed with the dominant direction of the background texture. Based on this, this invention, starting from the directional statistical characteristics of pixels, introduces a multi-scale structural tensor to evaluate the degree of deviation of each pixel from its dominant neighborhood direction, thereby distinguishing between isotropic background textures and anisotropic defect features.

[0037] Specifically, firstly, the gradient magnitude and gradient direction angle of each pixel are obtained. It should be noted that gradient information is a fundamental physical quantity describing the edge features of an image. In order to more accurately capture the edge details of weak defects on the flange surface, it is preferable to use the Scharr operator to process the preprocessed image.

[0038] Specifically, the Scharr operator is used to perform convolution operations on the preprocessed image to obtain the horizontal and vertical gradient components of each pixel, and the gradient magnitude and gradient direction angle of each pixel are calculated accordingly.

[0039] Then, the local texture direction at each scale of the pixel is obtained. It should be noted that the gradient direction of a single pixel is easily affected by noise and exhibits random fluctuations, making it unstable for representing texture flow. Therefore, a structure tensor is introduced to statistically integrate the gradient information within the local neighborhood. Furthermore, considering the significant diversity of defect sizes on the surface of flange forgings—including extremely fine hairline cracks as well as wider scratches or pits—a single-scale analysis window cannot adequately cover the sensitivity to all types of defects. Therefore, this invention employs a multi-scale analysis strategy, using differentiated window settings to cover different feature frequency bands.

[0040] Specifically, define the set of analytical scales. For any scale, a structure tensor field reflecting the local texture geometry is constructed: for each pixel in the preprocessed image, a Gaussian weighted window is constructed centered on that pixel, and the products of gradient components in the neighborhood are weighted and averaged to finally construct a structure tensor matrix for each pixel. Subsequently, eigenvalue decomposition is performed on this structure tensor matrix to obtain the eigenvector corresponding to the largest eigenvalue, and this eigenvector is converted into an angle value, thus obtaining the local texture orientation of the neighborhood of each pixel at the corresponding scale. It should be noted that at small scales... Aimed at capturing the high-frequency directional characteristics of minute cracks; large-scale Designed to capture large-scale texture anomaly flow; mesoscale Used to balance local details with macro texture trends.

[0041] Then, the local orientation deviation value of each pixel at each scale is obtained. It should be noted that in order to accurately identify defects, it is necessary to construct an index that can assess the degree of anomaly. Considering that the edge direction of real defects such as cracks and scratches is usually transverse to the forging flow line, that is, it forms a significant angle with the dominant direction of the background texture, the index should have orientation sensitivity to ensure that a high response is generated when the pixel gradient direction is inconsistent with the background flow direction. Considering that the low-contrast clutter noise in the background is also disordered in direction, but its edge intensity is much lower than that of real defects, the index should have intensity dependence, that is, the orientation deviation is weighted by the gradient magnitude to effectively suppress noise false alarms.

[0042] Based on the above logic, the local directional deviation value satisfies the following relationship: ; in, It is a pixel. In scale Local directional deviation value below; It is a pixel. The gradient direction angle; It is a pixel. The local texture direction of the neighborhood; It is a pixel. The gradient magnitude; It is the maximum gradient value in the entire preprocessed image; It is the absolute value symbol.

[0043] In this relation, For the direction difference term, when the pixel point When it belongs to normal texture, its gradient direction angle tends to be consistent with the dominant direction of the neighborhood, and the difference between the two angles tends to be close to 1 / 2. or This makes the sine term approach the mean. This suppresses background texture response; when pixels When a defect, such as a transverse microcrack, is present, its gradient direction angle is perpendicular to the dominant direction of the neighborhood, and the difference between the two angles approaches 1 / 2. This makes the sine term approach the mean. This enhances the defect signal. As an intensity weighting term, this term uses the normalized gradient magnitude to weight the directional differences, ensuring that only directional anomalies with a certain edge intensity are identified as potential defects, thereby filtering out low-contrast clutter noise.

[0044] Finally, the texture anomaly value for each pixel is determined. For each pixel in the preprocessed image, the maximum value of the local orientation deviation at different analysis scales is selected as the texture anomaly value for that pixel. .

[0045] At this point, the texture anomaly value for each pixel has been obtained.

[0046] Step S300: Perform morphological reconstruction on the preprocessed image to extract the background image, and calculate the geometric suppression weight of each pixel based on the brightness difference between the preprocessed image and the background image.

[0047] It should be noted that although texture outliers can characterize the degree of disorder in the orientation field, the inherent macroscopic geometry of flange forgings, such as flange edges, chamfers, and mounting holes, also exhibit strong gradient responses in the image. If not distinguished, these non-defect high-frequency details can easily be misidentified as defects. Traditional linear filtering blurs the boundaries of large defects when smoothing macroscopic structures. Morphological reconstruction is a nonlinear image transformation technique that utilizes constrained iterative dilation operations under mask limitations. It has the characteristic of completely filling in minute dark features within the image while strictly preserving the position of strong macroscopic edge contours. Based on this, this invention employs a morphological reconstruction-based background extraction technique, utilizing its edge-preserving properties to construct a background image containing only macroscopic geometric information. This achieves accurate decoupling of microscopic defects from the macroscopic geometric background, providing a reliable benchmark for subsequent residual analysis to locate geometric edge pixels.

[0048] First, the background image is extracted based on iterative morphological reconstruction. It's important to note that morphological reconstruction requires a labeled image. This labeled image must contain background features but cannot contain any small bright defects; otherwise, these defects will be recovered during the reconstruction process. Therefore, erosion is used to remove small bright details from the image. Second, standard dilation tends to over-brighten the image, destroying the macroscopic contours. Geodesic dilation, using the original preprocessed image as a brightness upper limit, only allows the labeled image to grow under mask constraints. This fills in small defects without exceeding the brightness range of the original image, thus accurately preserving the macroscopic geometric structure. Based on this, geodesic dilation is used. This process uses the original preprocessed image as a mask, forcing the brightness in the labeled image to grow upwards but never exceeding the original brightness, thereby achieving an accurate approximation of the macroscopic background.

[0049] Specifically, using dimensions of The structuring element performs morphological erosion on the preprocessed image, removing all bright features smaller than the structuring element. The result is defined as the labeled image. Using the preprocessed image as a mask, geodesic dilation reconstruction is performed on the labeled image. In each iteration, the labeled image is first dilated using standard methods. Then, the dilation result is compared with the brightness value at the corresponding pixel location in the preprocessed image, and the minimum value is taken. This iterative process is repeated until the image data converges, i.e., the difference rate between two consecutive iterations is less than a preset threshold. At this point, the image after the iteration terminates is a background image without microscopic defects.

[0050] It should be noted that the size of the structural element The value setting must comply with actual physical constraints: The principle for determining the value is: greater than the maximum expected defect size and less than the minimum macroscopic geometric feature width, to ensure that the macroscopic outline of the flange is completely preserved while eliminating defect features. This embodiment is preferably set for typical forgings. The preset threshold is used to balance reconstruction accuracy and computational efficiency, and is usually set to a rate of change of overall image brightness of less than 0.1%. This indicates that the background image has reached a stable state, and the implementers can also set it according to their needs.

[0051] Then, the standard deviation of the difference between the preprocessed image and the background image is calculated and denoted as the global residual dispersion. This index dynamically characterizes the overall roughness level of the current flange surface and the background noise benchmark, providing a statistical reference for subsequent adaptive suppression.

[0052] Finally, the geometric suppression weight for each pixel is determined. To suppress geometric artifacts while protecting the true defect signal, this invention constructs a nonlinear mapping mechanism based on statistical characteristics. Considering that in the flat region of the flange, the background image can accurately fit the preprocessed image, and the difference between the two should be within the statistically permissible range defined by the global discreteness, a high weight should be assigned to preserve the signal. Considering that in regions of geometric abrupt change, the background image cannot follow drastic gradient changes, and the difference between the two will significantly exceed the above statistically permissible range, a very low weight should be assigned to mask artifacts. This mapping mechanism employs a Gaussian decay model with smooth transition characteristics. The bandwidth of this model needs to be dynamically adjusted with the global residual discreteness to ensure the robustness of the algorithm to different roughness conditions.

[0053] Based on the above logic, the geometric suppression weight of each pixel satisfies the following relationship: ; in, It is a pixel. Geometric inhibition weights; It is the preprocessing of the image at the pixel level Brightness value; The background image at the pixel level Brightness value; It is the standard deviation of the difference between the preprocessed image and the background image; It is the preset sensitivity adjustment coefficient; It is a natural exponential function.

[0054] In this relation, Characterizing pixels The square of the absolute degree of deviation from the background image. The larger this value, the more likely the pixel belongs to abrupt structures outside the background, such as geometric edges or severe defects. Used for adaptive normalization, determined by both the global residual dispersion and the sensitivity adjustment coefficient, it defines the tolerance bandwidth that dynamically changes with the overall image quality, controlling the decay rate of the Gaussian function. When the residual energy of a pixel falls within the tolerance bandwidth defined by the denominator, Approaching This indicates that the region falls within the permissible normal surface fluctuation range; when the residual energy significantly exceeds this bandwidth, the calculation results decay exponentially. This enables strong suppression of geometric edge signals that are significantly deviated from the background image.

[0055] It should be noted that the sensitivity adjustment coefficient The value needs to be set according to the actual surface roughness of the flange forging and the inspection process requirements: for flange forgings with relatively rough surfaces and deep forging flow lines, If it is too large, it can be appropriately increased. If set as This relaxes the tolerance bandwidth of suppression, avoiding excessive suppression due to inherent micro-undulations on the surface, thereby preventing the missed detection of true defects inside the texture; for flange forgings with finely machined or relatively smooth surfaces and high sensitivity to small geometric artifacts, the tolerance bandwidth can be appropriately reduced. If set as To tighten the tolerance bandwidth, a steeper attenuation curve is achieved, thereby enhancing the ability to eliminate artifacts at fine geometric edges. In this embodiment, to balance the tolerance for rough textures with the suppression of geometric artifacts, Preferred setting is .

[0056] At this point, the geometric suppression weights for each pixel have been obtained.

[0057] Step S400: Fuse the texture anomaly value of each pixel with the geometric suppression weight to obtain the defect response value of each pixel; perform threshold segmentation on the defect response map formed by the defect response values ​​to identify surface defects of the flange forging.

[0058] It should be noted that this invention is the decision-making step in the entire inspection process. It transforms the abstract features extracted in the previous steps into defect signals with clear physical meaning through the fusion operation of multiple feature spaces, and further transforms the continuous signal intensity into discrete defect categories, thereby achieving the final judgment on the surface quality of the flange forging.

[0059] First, the defect response value of each pixel is calculated. It should be noted that, based on the physical characteristics of flange forging defect detection, the determination of a true defect requires comprehensive consideration of both texture features and spatial location features. Considering that a true defect will inevitably disrupt the directional consistency of the local forging streamlines, a true defect pixel should exhibit obvious texture direction anomalies; considering that the geometric edges such as the inner and outer circular contours of the flange will generate high gradient responses that are not defects, a true defect pixel should be located in a flat or transitional region without geometric abrupt changes.

[0060] Therefore, this invention uses a pixel-by-pixel product method to fuse the attributes of the two feature spaces, and uses geometric suppression weights as confidence coefficients to perform weighted correction on texture outliers, thereby eliminating geometric artifacts and enhancing the signal strength of real defects.

[0061] Based on the above logic, the defect response value of a pixel satisfies the following relationship: ; in, It is a pixel. The defect response value; It is a pixel. Geometric inhibition weights; It is a pixel. Texture anomalies.

[0062] In this relationship, if the pixel point Located on the flange contour, although its texture outliers are high due to abrupt changes in gradient direction, the geometric suppression weight at this location is close to 0 due to the high residual effect. The product of these two factors is reduced, effectively filtering out geometric artifacts. If the pixel... Located at the actual defect, it exhibits strong texture direction anomalies, resulting in high texture anomaly values. Furthermore, because it is located in a non-geometric abrupt change region, the geometric suppression weight approaches 1. The product of the two will remain high, thus highlighting the defect characteristics.

[0063] The process iterates through each pixel in the preprocessed image, obtaining the defect response value corresponding to each pixel. Then, it performs spatial mapping and visualization of all pixel defect response values ​​according to their original row and column coordinates to obtain the defect response map. For example... Figure 3 The image shown is a defect response diagram processed by the present invention. This diagram visually represents the intensity of the defect response signal using pixel brightness values. Figure 2 and Figure 3 Comparative analysis shows that, Figure 2 The physical locations of the longitudinal crack 1 in the flat upper area of ​​the flange, the transverse crack 2 in the flat lower area of ​​the flange, the dense pit group 3 in the right side of the middle area of ​​the flange, and the fine crack 4 near the edge of the lower right mounting hole, as indicated in the markings, are: Figure 3The signals accurately correspond to the high-brightness feature regions, indicating that the present invention has successfully enhanced the signal strength of the aforementioned real defects, making them clearly stand out from the background. Meanwhile, Figure 2 The flange mounting hole edges, inner and outer chamfers, and background streamline texture areas, which originally had strong gradient characteristics, are now... Figure 3 The corresponding positions in the image are all represented by a dark background with extremely low brightness, indicating that these non-defect geometric and texture interference signals are effectively and adaptively suppressed. This comparative effect demonstrates that the present invention can reliably preserve and extract weak defect features while suppressing complex macroscopic geometric interference.

[0064] Secondly, obtain the defect candidate regions after topology optimization.

[0065] It should be noted that while the defect response value already possesses a high signal-to-noise ratio, it is essentially still a continuous grayscale value and cannot be directly used for industrial grading. Furthermore, due to fluctuations in illumination or surface oil contamination, a single linear defect, such as a crack, may appear as discontinuous fragments on the defect response map. Therefore, it is necessary to discretize the response value into a binary region using an adaptive threshold and introduce morphological operations to perform topological repair on the binary region, in order to connect broken defect fragments and filter out isolated noise points.

[0066] Specifically, for the defect response values ​​of each pixel in the entire image, the optimal segmentation threshold is calculated using the Otsu's method. Pixels with response values ​​greater than the segmentation threshold are marked as foreground, generating binarized data. Subsequently, morphological opening operations are performed on the binarized data to filter out isolated noise points, and morphological closing operations are performed to bridge cracks caused by signal fluctuations. Next, connected component labeling is performed to identify all independent connected regions, and each connected region is defined as a defect candidate.

[0067] Finally, the geometric feature parameters of each defect candidate are calculated, and the candidate defect objects are screened and classified based on geometric feature rules. It should be noted that different types of defects have significant differences in physical morphology: cracks typically exhibit slender linear structures, while craters or indentations usually appear as dense circular or near-circular structures. To distinguish these morphologies, quantitative geometric descriptors need to be constructed.

[0068] Specifically, for each defect candidate object, its geometric features are calculated, including: counting all foreground pixels within the connected region corresponding to the defect candidate object and obtaining its area. First, the physical dimensions of the defect are characterized; second, the minimum bounding rectangle of the connected region is constructed to obtain its width. and height And calculate the aspect ratio. A larger aspect ratio indicates a more slender and elongated shape and structure of the connected region; finally, the perimeter of the connected region is calculated. Calculate its circularity based on its perimeter. The closer the circularity is to 1, the more closely the shape of the connected region approximates a circle.

[0069] Candidate defect objects are screened and classified based on geometric feature rules, including: executing hierarchical judgment logic based on geometric feature parameters. First-level judgment: For area The connected regions are treated as background noise and removed. Second-level judgment: Regarding aspect ratio and area The connected region, given its distinctly elongated shape, is identified as a crack. Third-level judgment: Regarding roundness and area The connected region, given its high density and near-circular characteristics, is identified as a pit.

[0070] Other cases: For the remaining areas that do not meet the above conditions, they are uniformly classified as other defects.

[0071] The second aspect of this embodiment provides a flange forging surface defect detection system based on image processing, such as... Figure 4 As shown, the image processing-based flange forging surface defect detection system includes a memory and a processor. The memory stores computer program instructions, which, when executed by the processor, implement the image processing-based flange forging surface defect detection method of the first aspect of the present invention.

[0072] The image processing-based flange forging surface defect detection system also includes other components well known to those skilled in the art, such as communication buses and communication interfaces. Their setup and functions are known in the art and will not be described in detail here.

[0073] In this invention, the aforementioned memory can be any tangible medium containing or storing a program that can be used or combined with an instruction execution system, apparatus, or device. For example, a computer-readable storage medium can be any suitable magnetic or magneto-optical storage medium, such as resistive random access memory (DRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (DRAM), high-bandwidth memory, hybrid memory cube, etc., or any other medium that can be used to store desired information and can be accessed by an application, module, or both. Any such computer storage medium can be part of a device or accessible to or connected to a device.

[0074] 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 surface defects in flange forgings based on image processing, characterized in that, include: The original image of the flange forging is obtained, and the original image is subjected to bandpass filtering based on difference Gaussian to obtain a preprocessed image. Multi-scale structural tensor analysis is performed on the preprocessed image to obtain the gradient direction and gradient magnitude of each pixel, and the local texture direction of each pixel at different scales is calculated; based on the gradient magnitude and the absolute value of the sine of the angle between the gradient direction and the local texture direction, the texture anomaly value of each pixel is determined. The acquisition of the texture anomaly values ​​of the pixels includes: For each scale, calculate the local orientation deviation value at that scale; The maximum value among the local directional deviation values ​​at different scales is selected and recorded as the texture anomaly value of the corresponding pixel. The local directional deviation value satisfies the following relationship: ; in, It is a pixel. In scale Local directional deviation value below; It is a pixel. The gradient direction angle; It is a pixel. The local texture direction of the neighborhood; It is a pixel. The gradient magnitude; It is the maximum gradient value in the preprocessed image; It is the absolute value symbol; Morphological reconstruction is performed on the preprocessed image to extract the background image. Based on the brightness difference between the preprocessed image and the background image, the geometric suppression weight of each pixel is calculated. The geometric suppression weight is negatively correlated with the brightness difference. The texture anomaly value of each pixel is fused with the geometric suppression weight to obtain the defect response value of each pixel; the defect response map formed by the defect response values ​​is subjected to threshold segmentation to identify surface defects of the flange forging.

2. The method for detecting surface defects in flange forgings based on image processing according to claim 1, characterized in that, The calculation of the local texture direction of each pixel at different scales includes: Construct a multi-scale window, and for each preset scale, construct a structure tensor for each pixel in the preprocessed image; Calculate the eigenvector corresponding to the largest eigenvalue of the structure tensor at the current scale for each pixel; The direction of the feature vector is determined as the local texture direction of the corresponding pixel at the current scale.

3. The method for detecting surface defects in flange forgings based on image processing according to claim 2, characterized in that, The step of constructing a structure tensor for each pixel in the preprocessed image includes: Calculate the gradient components in the horizontal direction and the gradient components in the vertical direction of the preprocessed image; Calculate the tensor product based on the gradient components in the horizontal and vertical directions. The tensor product is convolved and smoothed using a Gaussian smoothing kernel, and the smoothed components constitute the structure tensor of the pixel.

4. The method for detecting surface defects in flange forgings based on image processing according to claim 1, characterized in that, The geometric suppression weights satisfy the following relationship: ; in, It is a pixel. Geometric suppression weights; It is the preprocessing of the image at the pixel level The brightness value; The background image at the pixel level The brightness value; It is the standard deviation of the difference between the preprocessed image and the background image; It is the preset sensitivity adjustment coefficient; It is a natural exponential function.

5. The method for detecting surface defects in flange forgings based on image processing according to claim 1, characterized in that, The step of performing morphological reconstruction on the preprocessed image to extract the background image includes: The preprocessed image is subjected to morphological erosion using a structuring element of a preset size to obtain a labeled image; Using the preprocessed image as a mask, geodesic dilation is performed on the marked image until convergence, to obtain the background image.

6. The method for detecting surface defects in flange forgings based on image processing according to claim 1, characterized in that, The process of fusing the texture outlier values ​​of each pixel with the geometric suppression weights to obtain the defect response value of each pixel includes: The defect response value of each pixel is obtained by multiplying the texture anomaly value of each pixel by the geometric suppression weight of the corresponding pixel.

7. The method for detecting surface defects in flange forgings based on image processing according to claim 1, characterized in that, The step of thresholding the defect response map formed by the defect response values ​​to identify surface defects in the flange forging includes: A binary image is obtained by thresholding the defect response map composed of defect response values; Morphological operations are performed on the binary image to extract connected regions, thereby obtaining candidate defect regions; Calculate the geometric feature parameters of the candidate defect region, and classify the candidate defect region according to the preset geometric feature rules in order to identify surface defects of the flange forging.

8. The method for detecting surface defects in flange forgings based on image processing according to claim 1, characterized in that, The step of performing a bandpass filter based on difference Gaussian on the original image to obtain a preprocessed image includes: The original image is convolved with a Gaussian filter with a first standard deviation to obtain a first filtered image, and the original image is convolved with a Gaussian filter with a second standard deviation to obtain a second filtered image; wherein the first standard deviation is greater than the second standard deviation. Perform pixel-level difference operation to subtract the pixel values ​​of the first filtered image from the pixel values ​​of the second filtered image to obtain the difference image; The pixel values ​​of the differential image are linearly stretched and mapped to a preset range to obtain a preprocessed image.

9. A flange forging surface defect detection system based on image processing, characterized in that, The image processing-based flange forging surface defect detection system includes a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement the image processing-based flange forging surface defect detection method according to any one of claims 1-8.

Citation Information

Patent Citations

  • Defect detection method, device, computer device and storage medium

    CN109300127A

  • Lithium battery pole piece coating defect detection method and related equipment

    CN117611540A

  • Multi-element prospecting data cleaning and feature extraction system based on machine learning

    CN120972280A