Pin shaft forging forming quality detection method and system
By improving the active contour model, using local gradient direction dispersion and defect edge structure enhancement index to calculate the adaptive external energy scaling factor, the problem that traditional Snakes algorithm is difficult to distinguish real defects from background texture on the surface of pin forgings, and achieve higher precision defect detection.
Patent Information
- Application Number
- CN202510813252.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-18
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2045-06-18
AI Technical Summary
The traditional Snakes algorithm is difficult to effectively distinguish the edge of real defects from the pseudo-edge generated by background texture/noise on the surface of the pin forging, especially the detection accuracy of small defects is insufficient, and the external energy term parameter adjustment depends on empiricality, making it difficult to adapt to diversity.
The adaptive external energy scaling regulator is calculated through the local gradient direction discretitude and defect edge structure enhancement index, and the active contour model is improved, the ability to identify weak and irregular defect edges is enhanced, and background texture and noise interference is suppressed.
It significantly improves the accuracy and robustness of surface defect detection of pin shaft forgings, and can accurately segment the edges of weak defects in complex backgrounds, reduce noise interference, and improve detection accuracy.
Smart Images

Figure CN120339278A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and particularly to a method and system for detecting the quality of forged pin forming. Background Art
[0002] The pin, as a key connecting and load-bearing component widely used in mechanical equipment, its main function is to realize the rotational connection between mechanisms, transmit torque, and bear shear force and bending stress. In order to meet the harsh service conditions, high-quality alloy steel is usually selected as the raw material for pins, and the initial blank shape is obtained through the forging process. Forging can eliminate the as-cast porosity of metals, weld internal pores, break coarse as-cast structures, and form a dense fibrous structure with a specific streamline distribution, thereby significantly improving the mechanical properties of materials, such as strength, toughness, fatigue strength, and wear resistance. Therefore, forging is one of the key links to ensure the final performance of pins.
[0003] Based on this, the automated surface defect detection technology based on machine vision has emerged as the times require and has become a research and application hotspot. Among many image processing algorithms, the active contour model (Snakes) shows certain potential in object segmentation and defect extraction because it can adaptively evolve the contour according to the image content to approximate the target boundary. However, the traditional Snakes algorithm still has the following inherent defects: its external energy term mainly depends on the global or local gradient amplitude of the image. For forged pins, their surfaces are often not uniformly smooth, but may have natural textures, edges of oxide scale patches formed due to metal flow, oxidation, etc. These non-defect feature regions may also generate strong gradient responses. At the same time, some small but critical defects (such as early cracks, fine scratches) may generate relatively weak gradient signals due to their low contrast or blurred edges.
[0004] In this case, the external energy term of the traditional Snakes model is difficult to effectively distinguish the real defect edges from the pseudo-edges generated by background textures / noise, resulting in the following during the evolution of the contour line: the energy weight parameters in the model usually need to be adjusted empirically according to the specific scenario and defect type, and it is difficult to stably handle the diversity of the surface conditions and defect morphologies of forgings. Summary of the Invention
[0005] In view of the above problems of being difficult to stably handle the diversity of forging surface conditions and defect morphologies, in the first aspect, the present invention proposes a pin forging forming quality detection method, including: obtaining a surface image of the pin forging to be detected; determining the total energy function of the active contour model, where the total energy function includes an internal energy term and an external energy term; determining a pixel neighborhood window, and obtaining a structure tensor based on the gradient magnitudes of each pixel within the pixel neighborhood window, and then calculating the local gradient direction dispersion of each pixel point; calculating the defect edge structure enhancement index of each pixel point based on the spatial distribution and local morphological features of the local gradient direction dispersion; setting the minimum and maximum values of the adaptive external energy scaling adjustment factor and calculating the difference between the minimum and maximum values; taking the defect edge structure enhancement index as the independent variable of a preset non-linear mapping function to obtain a mapping value, calculating the product of the mapping value and the difference and summing it with the minimum value to obtain the adaptive external energy scaling adjustment factor; using the adaptive external energy scaling adjustment factor as a multiplicative weight and directly acting on the basic external energy term in the active contour model total energy function to obtain an improved total energy function, thereby obtaining an improved active contour model; using the improved active contour model to perform contour segmentation and extraction on potential defects in the surface image; performing feature extraction and quantification on the segmented defect regions, and determining the processing forming quality of the pin forging based on a preset quality acceptance standard.
[0006] Compared with the traditional active contour model that only relies on image gradient information for defect segmentation, the present invention improves the active contour model by the local gradient direction dispersion and the defect edge structure enhancement index, and generates an adaptive external energy scaling adjustment factor, which can significantly enhance the model's recognition ability and segmentation accuracy for weak and irregular defect edges under the complex background of the forging surface, effectively suppress the interference of background texture and noise, and improve the accuracy of defect detection and the robustness to different forging surface conditions.
[0007] Further, the local gradient direction dispersion is denoted as , and the calculation method is specifically as follows: For the pixel point and its neighborhood window , statistically obtain the set of effective gradient vectors within the window whose gradient magnitude is greater than a preset threshold; if the number of vectors in is less than the set minimum effective gradient number, then the local gradient direction dispersion is set to 0; otherwise, for each effective gradient vector in normalize it to obtain the direction vector , there is , and construct the structure tensor ; calculate 's two eigenvalues and , then , where is a small positive number to avoid a zero denominator.
[0008] By quantifying the discreteness of the local gradient direction through the structure tensor eigenvalues, compared with simple gradient statistics, this index can more robustly reflect the true inconsistency of the local image structure direction caused by defects, providing a more reliable underlying feature basis for the accurate enhancement of subsequent defect edges.
[0009] Furthermore, the calculation method of the defect edge structure enhancement index is specifically as follows: ; where represents the defect edge structure enhancement index of pixel point ; represents the local gradient direction discreteness; represents point on the line segment in the set direction value average; and represent the maximum value function and the minimum value function respectively.
[0010] Furthermore, the calculation method of the adaptive external energy scaling adjustment factor is specifically as follows: ; where and represent the set minimum and maximum scaling factors respectively; represents the defect edge structure enhancement index of pixel point ; is a non - linear mapping function, and its parameters include the lower threshold for calibrating the mapping interval, upper threshold and the exponent controlling the curve shape.
[0011] By non - linearly mapping the defect edge structure enhancement index to a preset scaling factor range, the adjustment factor can smoothly and adaptively change according to the size of the defect edge structure enhancement index (i.e., the significance degree of the defect edge). Compared with a fixed external energy weight or simple linear adjustment, it can more finely control the influence intensity of the external energy on the active contour evolution, improving the adaptability of the model to defect edges of different intensities.
[0012] Furthermore, the non - linear mapping function includes at least one of the Sigmoid function or the following piece - wise function, specifically: ; where represents a reference symbol for referring to the defect edge structure enhancement index.
[0013] Provides a specific, parameterized implementation of the non - linear mapping function, enabling the generation of the adaptive adjustment factor to have a clear mathematical expression and adjustable response characteristics. This facilitates the optimal configuration of different sensitive intervals of defect edge saliency according to the actual application scenario, enhancing the flexibility and practicality of the algorithm.
[0014] Furthermore, the improved energy function is specifically defined as: ; where represents the definition expression of the improved energy function; , represents the parameterized contour curve; represents the internal energy, and there is where and are the set weights; represents the adaptively scaled external energy adjustment factor calculated at the position of the contour point ; is a basic external energy term, constructed based on the image gradient magnitude, and there is where is the Gaussian smoothing kernel, is the set gradient energy weight constant.
[0015] Multiplying the spatially adaptive scaling adjustment factor multiplicatively on the basic external energy term enables the active contour model, during iterative solution, to dynamically adjust its sensitivity to the image gradient according to the defect edge confidence at the position of each contour point. Compared with the traditional model, it greatly enhances the driving force for the contour to converge to the real and significant defect edge, and effectively avoids false attraction in complex backgrounds or noise regions.
[0016] Furthermore, before acquiring the surface image of the pin - shaft forging to be detected, it also includes: cleaning, cooling, and precisely positioning the pin - shaft forging to be detected; using at least one industrial camera in combination with a telecentric lens and a programmable combined light source system to perform image acquisition of the surface to be detected of the pin - shaft forging under multi - angle or multi - mode illumination, and performing necessary camera calibration and light field calibration.
[0017] Furthermore, it also includes pre - processing the surface image: performing grayscale processing on the surface image; using adaptive histogram equalization to process the grayscale image; performing median filtering to remove noise from the grayscale image.
[0018] Further, after performing contour segmentation and extraction on potential defects in the surface image using the improved active contour model, the following steps are also included: for each segmented defect region, automatically calculate its geometric feature parameters, where the geometric feature parameters at least include area, perimeter, equivalent diameter, length and width of the minimum circumscribed rectangle, major axis direction angle, elongation, and circularity; and calculate its gray-scale feature parameters, where the gray-scale feature parameters at least include the average gray scale within the region, gray-scale standard deviation, and average contrast with the adjacent background region.
[0019] In a second aspect, the present invention provides a quality detection system for pin shaft forging forming, including a processor and a memory. The memory stores computer program instructions, and when the computer program instructions are executed by the processor, a quality detection method for pin shaft forging forming according to the present invention is implemented.
[0020] The technical effects of the present invention are as follows: The local gradient direction dispersion initially identifies discontinuous regions of the image structure by analyzing the statistical characteristics of the gradient directions in the pixel neighborhood. On this basis, the defect edge structure enhancement index further examines the linear structure characteristics of the high-value signals in these regions, thereby specifically enhancing the saliency of the true defect edges and effectively suppressing interference from background textures and isolated noise points.
[0021] Based on the defect edge structure enhancement index, the present invention obtains a spatially adaptive external energy scaling adjustment factor. This factor can dynamically adjust the weight of the external energy term in the traditional active contour model according to the possibility that each pixel point belongs to the true defect edge structure. In the region where the defect edge structure enhancement index indicates a strong defect signal, the external energy scaling adjustment factor will significantly enhance the attracting effect of the external energy; otherwise, it will weaken the influence. This decision support enables the improved active contour model to intelligently focus on defect edges with high confidence, thereby achieving more accurate defect contour localization in complex backgrounds. Description of the Drawings
[0022] Figure 1 Schematically shows a flowchart of a quality detection method for pin shaft forging forming in an embodiment of the present invention; Figure 2 Schematically shows a structural block diagram of a quality detection system for pin shaft forging forming in an embodiment of the present invention. Detailed Embodiments
[0023] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts belong to the protection scope of the present invention.
[0024] The following will describe in detail the specific implementation manners of the present invention in conjunction with the accompanying drawings.
[0025] An embodiment of a method for detecting the quality of forged pin shafts: As Figure 1 shown, a method for detecting the quality of forged pin shafts of the present invention includes: S1. Preparation and image acquisition of the pin shaft forging.
[0026] First, perform surface cleaning on the pin shaft forging to be detected. For example, use ultrasonic cleaning in combination with an environmentally friendly industrial cleaning agent to remove the oil stains and emulsified liquid residues on its surface, and use compressed air to dry it. Subsequently, ensure that the forging has naturally cooled to a stable ambient temperature (exemplarily, controlled at ), to eliminate the influence of thermal deformation on the detection accuracy. Further, clamp the cleaned and cooled forging on a rotatable workbench through a high-precision pneumatic three-jaw chuck. Finally, in this embodiment, a camera array composed of 4 global shutter industrial CMOS cameras with high resolution (for example, each camera has 2448×2048 effective pixels) is used. Each camera is equipped with a high-quality telecentric lens and a programmable combined light source system composed of multiple groups of independently controllable high-brightness white LED units (for example, including a coaxial light source, a low-angle ring light source, and a dome diffused light source, and the lighting mode can be switched or combined according to the detection requirements).
[0027] Before detection, it is also necessary to precisely calibrate the image acquisition device. Exemplarily, for a two-dimensional camera array, the internal parameters (such as focal length, principal point, distortion coefficient) and external parameters (the position and attitude of the camera relative to the coordinate system of the rotatable workbench) of each camera are respectively calibrated, and the light field uniformity calibration and light intensity response calibration in multiple light source modes are performed on the programmable combined light source system.
[0028] After completing the above steps, the image data of the pin forging is collected next. During the rotation of the forging (or after stepping and rotating to multiple preset specific angular postures), one or more cameras in the two-dimensional camera array are synchronously triggered by the central controller to take pictures. After obtaining the images taken by the cameras, the color images are first converted into single-channel grayscale images; subsequently, to reduce the influence of uneven illumination, adaptive histogram equalization can be applied to process the grayscale images; then, to smooth the random noise and protect the edge details, a median filter can be applied for denoising. The above preprocessing algorithms are well-known technologies and will not be elaborated here.
[0029] S2. Determine the total energy function of the active contour model.
[0030] The pin forging is formed under high temperature and high pressure, and its surface will inevitably form complex characteristics different from the ideal machined surface. For example, there may be fine flow patterns formed by uneven metal flow, surface oxide patches or color differences caused by oxidation and decarburization, etc.
[0031] The active contour model (Snakes) algorithm, as a classic image segmentation tool, its core driving force comes from the gradient information of the image, and the total energy function is usually expressed as: ; where , representing the internal energy, is used to constrain the geometric shape of the contour. The first term (controlled by the weight ) penalizes the stretching of the contour, making it tend to shorten; the second term (controlled by the weight ) penalizes the bending of the contour, making it tend to be smooth; represents the coordinate position of the contour point changing with the parameter .
[0032] represents the image energy or external energy, which comes from the characteristic information of the image itself and is used to guide the contour to move towards the target features of interest in the image (such as high-gradient edges, specific grayscale regions, etc.). Generally, is often set to be negatively correlated with the square of the image gradient magnitude, that is, , where represents the edge weight; represents the image coordinate position of the gradient.
[0033] represents the external constraint energy, allowing the implementer or high-level semantic information to impose additional guiding forces or constraint conditions on the contour. The solution process of the algorithm is to find a contour such that is minimized. The weight parameters (such as and the external energy weight) that control the internal and external energy balance in the Snakes algorithm are crucial for the segmentation result. However, the optimization of these parameters often relies on experience, and it is difficult to find a set of universal parameter sets that can adapt to different types of defects, different surface conditions, and different lighting conditions.
[0034] S3. Determine the neighborhood window, obtain the structure tensor based on the gradient magnitude within the neighborhood window, and further calculate the local gradient direction dispersion; construction and calculation of the defect edge structure enhancement index; calculation of the adaptive external energy scaling adjustment factor based on the defect edge structure enhancement index; definition of the energy function and iterative solution strategy of the improved active contour model.
[0035] S3.1. Determine the neighborhood window, obtain the structure tensor based on the gradient magnitude within the neighborhood window, and further calculate the local gradient direction dispersion.
[0036] On the surface of the pin shaft forging, even if there are forging textures formed by metal flow, the texture orientation in the normal area usually shows a certain direction dominance or gentle transition within a small local range (for example, on the scale of several pixels to a dozen or so pixels). In contrast, the appearance of defects (especially the sharp edges of fine cracks, early folds, or the boundaries of irregular pits) will suddenly interrupt this local direction continuity, making the pixel gradient directions at the defect edges and their adjacent areas show a significant, concentrated, and multi-directional discrete distribution. Therefore, in this embodiment, the local gradient direction dispersion is constructed to quantitatively describe the degree of chaos or divergence of the gradient directions within the neighborhood of each pixel point in the image, and this is used as a preliminary basis for screening potential defect candidate regions. The higher the value of a region, the more inconsistent the internal microstructure directions of the region are, and the more likely it is the location of a structural mutation.
[0037] For any pixel point in the two-dimensional grayscale image obtained in step S2, after preprocessing it (for example, slightly Gaussian smoothing to suppress random noise but retain edge details), within its neighborhood window with a size of (exemplarily, or pixels), preferably calculate according to the following steps: First, for each pixel in the window calculate its gradient vector , for example, the Sobel operator or the Scharr operator can be used; then set a gradient magnitude threshold , (For example, it can be set to 0.25 times the average global gradient magnitude of the image, or dynamically determined on the gradient magnitude map by methods such as the Otsu method) to filter out the weak gradients generated by noise in flat regions. Only consider those gradient magnitudes greater than the effective gradient vectors, and denote the set of these vectors as whose number is ; further, if (for example , that is, the number of effective gradients is too small), then ; otherwise, for each effective gradient vector in , calculate its normalized direction vector ; then construct the structure tensor (Structure Tensor) or second-order moment matrix of these direction vectors , there is: ; where represents the normalized gradient direction vector; based on the above matrix, calculate the two eigenvalues of matrix and ( ). Finally, calculate the local gradient direction discreteness as follows: ; where is a very small positive number, such as 1e - 6, to avoid a zero denominator.
[0038] reflects the energy (or consistency strength) of the gradient in the main direction, while reflects the energy (or inconsistency strength) in the direction orthogonal to the main direction. When the gradient directions within the neighborhood are highly consistent (for example, along a clear straight - line edge), is larger, while is very small, and at this time the value of tends to 0. When the gradient directions within the neighborhood are completely random or isotropically distributed (for example, at an ideal corner or the center of isotropic texture), , and at this time the value of tends to 1. When there are significant gradients in multiple different directions within the neighborhood (for example, at the center of complex cross - textures or certain defects such as star - shaped cracks), is relatively large, is also large but may not be overwhelming, and will take an intermediate value but is significantly greater than 0.
[0039] therefore, The higher the value, the better the pixel The more the gradient direction in the neighborhood is divergent, the less uniform it is. For the forging surface, defects (such as the end points, bifurcations, or the edges of irregular pits) usually lead to significant dispersion of the local gradient direction.
[0040] In one embodiment, for a forging surface image containing fine network cracks, its corresponding Atlas (i.e., each pixel The image composed of the values of values (for example, after normalization to the range [0,1], these areas may have values between 0.6-0.9); while in relatively flat or uniform textured areas between cracks, The value is lower (for example, less than 0.2).
[0041] S3.2. Construction and calculation of defect edge structure enhancement index.
[0042] Although the atlas can preliminarily mark the areas with inconsistent structural directions in the image, these areas may contain both real defect edges and some rough textures inherent in the forging surface (for example, the edges of oxide scale patches, or non-defective micro-undulations formed by material flow) and some image noise.
[0043] Real defect edges, especially linear defects (such as cracks, scratches, fold lines, etc.), have high In addition, these high The value usually forms a ridge or band distribution with certain spatial continuity and directionality along the direction of the defect. Therefore, in this embodiment, the defect edge structure enhancement index is further constructed. , aims to analyze The local linear structural features of the high-value areas in the spectrum are used to specifically enhance the signals that are more likely to correspond to the edges of real defects, while suppressing isolated, non-structural high Noise point.
[0044] For pixels and its corresponding value, and by all Image of values , Preferably, the calculation is performed according to the following steps: First of all The image is enhanced by applying a multi-directional linear structure filter. For example, a series of predefined directions can be used. Linear structure elements (e.g., one every 22.5°, a total of 8 directions) (e.g., with a length of pixels and a width of 1 or 3 pixels, where can take 7 or 9) are used for morphological opening-closing combined operations (Opening-by-Reconstruction followed by Closing-by-Reconstruction, or simplified line segment detection filters) or directly for multi-directional linear filtering (such as mean or Gaussian weighting).
[0045] In one embodiment, an enhancement method based on the eigenvalues of the Hessian matrix can be adopted to detect the ridge line structure in the image, such as a variant of the Steger algorithm or the Frangi vessel enhancement algorithm.
[0046] In another embodiment, for each direction , the average value of the values on the line segment (with a length of , centered on ) in this direction is calculated, and is obtained as: Calculated as: is: ; The meaning of this formula is to multiply the original value by the maximum difference in the average values along different directions in its neighborhood. If a point lies on a ridge line formed by high values, the average value along the ridge direction will be higher, while the average value perpendicular to the ridge direction will be lower, and the difference between the two is larger. If the
[0047] value of the pixel point is high, and its neighborhood shows an obvious linear extensibility along a certain direction in the distribution of high values (i.e., is large and the difference from the average values in other directions is also large), then will be significantly enhanced. This indicates that the point is likely to be located on a clearly structured and directional defect edge (such as the main part of a crack). If the
[0048] value of the pixel point is high, but the surrounding distribution is relatively diffuse and lacks obvious directionality (e.g., an isolated noise point or an isotropic small-area rough region), then the differences in the values in different directions are not large, resulting in The enhancement relative to is not obvious and may even be suppressed due to a small multiplicative factor.
[0049] Therefore, it is possible to more effectively purify and enhance the structural signals that are more likely to be real defect edges and have continuous linear or curved forms from complex backgrounds.
[0050] Exemplary illustration: For the surface of a forging that previously contained fine reticulated cracks, the corresponding spectrum will show that the value of the "linear" part of the crack network is greatly increased and becomes very prominent (for example, assuming is normalized, its value may be in the range of 1.5 - 2.5), while some diffuse high-brightness regions that may exist in the previous spectrum due to minute surface irregularities will be significantly weakened in the spectrum (for example, the value drops below 0.5).
[0051] S3.3. Calculate the adaptive external energy scaling adjustment factor based on the defect edge structure enhancement index.
[0052] In traditional active contour models, the weight of the external energy term is usually globally fixed or adjusted only once according to global image statistical characteristics. However, the complexity of the forging surface and the diversity of defects require that the application of external energy should be more discriminative and adaptable.
[0053] provides quantitative information about the likelihood (or significance) that each pixel point belongs to the real defect edge structure. Therefore, the present invention constructs an adaptive external energy scaling adjustment factor aiming to use the value to finely and pixel-by-pixel dynamically adjust the intensity of the external energy term applied to the active contour.
[0054] Its main purpose is: in the region where the value indicates a strong defect edge signal, significantly enhance the attractive effect of the external energy to ensure that the contour can be accurately captured by these high-confidence edges; while in the region where the value is low (which may be normal surface texture or noise), correspondingly weaken the influence of the external energy to prevent the contour from being misled by artifacts or prematurely stagnating at weak edges.
[0055] For pixel point and its corresponding defect edge structure enhancement index value, preferably through a non-linear mapping function Calculate as follows: ; Wherein represents the minimum value of the adaptive external energy scaling adjustment factor, which can be set to the empirical value of 0.1 in this embodiment to ensure that even in an extremely low region, the external energy still has a weak effect; represents the maximum value of the adaptive external energy scaling adjustment factor, which can be set to the empirical value of 2.0 in this embodiment and determines the maximum amplification factor of the external energy; and respectively represent the lower threshold and the upper threshold of the piecewise mapping function. In this embodiment can be set to the 10th percentile of all non-zero values in the spectrum, can be set to the 90th percentile of all non-zero values in the spectrum; represents the exponent of the piecewise mapping function, which is used to control the curve shape, and ; exemplarily, it can be an S-shaped function (such as a Sigmoid function or a piecewise cubic Hermite interpolation function) or a piecewise function with a threshold, which smoothly maps the input value to the interval.
[0056] In one embodiment, there is: ; Wherein represents a reference symbol used to replace the in the above calculation formula; In another embodiment, a Sigmoid function is adopted, and there is: ; Wherein represents the midpoint parameter of the Sigmoid function, which corresponds to the input value when the output is 0.5; represents the shape parameter of the Sigmoid function, which is used to control the steepness of the transition band.
[0057] When the pixel point has a value that is relatively low (for example, lower than ), it indicates that this point is less likely to belong to a clearly structured defect edge. At this time the output of is close to 0, making the value close to its lower limit This means that in such regions, the external image energy applied to the active contour will be greatly weakened, and the contour evolution will be more dominated by its internal smoothness constraint, or more easily dominated by neighboring contours with higher are attracted by the area of values.
[0058] when Higher values (for example, higher than ), it indicates that the point is very likely located on the edge of a significant, structural defect. The output is close to 1, making The value is close to its upper limit This means that in such areas, the attraction of external image energy will be significantly enhanced, thereby strongly guiding the active contour to accurately converge and closely fit to these high-confidence defect edges. and Between value, Will be in and Smooth transition between.
[0059] therefore, The factor enables the active contour model to focus highly on those The indicator identifies the most structurally significant potential defect edges while effectively ignoring interference from background textures and random noise.
[0060] For example: For the previous The crack network part that is significantly enhanced in the spectrum corresponds to The value will be raised to approximately (e.g. 2.0), so that these crack edges have a strong attraction to the active contour. The background area with lower value The value is maintained close to (e.g. 0.1), the contribution of external energy is effectively suppressed.
[0061] S3.4. Energy function definition and iterative solution strategy of the improved active contour model.
[0062] Based on the above analysis and the constructed adaptive adjustment factor, the total energy function of the improved active contour model (IACM) of this embodiment is Preferably defined as: ; in It is still a parameterized contour curve; Still represents internal energy, In this embodiment, Set it as the empirical value 0.2, Set it as the empirical value 0.4; That is, the adaptive external energy scaling adjustment factor calculated at the position of the contour point ; is a basic external energy term. Exemplarily, it can still be constructed based on the image gradient magnitude, and there is or (where is a Gaussian smoothing kernel, is a basic gradient energy weight constant, such as the empirical value 1.0. Thus, the basic external energy term is now directly modulated by the spatially varying factor.
[0063] Furthermore, to solve for the contour that minimizes , in this embodiment, an iterative optimization strategy based on gradient descent is preferably adopted. The evolution equation of the contour can be expressed as: ; Specifically, when implemented, the contour can be discretized into a series of control points , and then the deformation of the contour is achieved by iteratively updating the positions of each control point. In each iteration, each control point will be affected by the combined force from the internal energy (making the distances between its adjacent points uniform and the curve smooth) and the modulated external energy (pushing it towards the trough, that is, the region with high gradient and high ). The iterative process continues until the contour energy change is less than a preset threshold, the contour shape change tends to be stable, or the preset maximum number of iterations (such as 300 times) is reached.
[0064] S4. Accurate segmentation and extraction of defects based on the improved active contour model; detecting the quality of the pin shaft forging based on the extracted features.
[0065] After constructing the improved active contour model with an adaptive external energy adjustment mechanism, this step details its specific application in the segmentation of surface defects of the pin shaft forging.
[0066] To improve the segmentation efficiency and accuracy, the placement of the initial contour preferably adopts an automated strategy. Exemplarily, first, threshold processing is performed on the defect edge structure enhancement index map (constituted by all values) generated in S3.2 (for example, using the Otsu method or a preset empirical threshold, and selecting Regions with higher values), and perform simple connected component analysis. For each connected component with an area larger than a certain threshold (e.g., 20 pixels), calculate its bounding rectangle or minimum enclosing circle, and use this as the initial contour for the evolution of the improved active contour model. This approach can concentrate computational resources on the regions most likely to have defects.
[0067] Further, place each of the initial contours generated in S3.1 into the improved active contour model defined in step S3.4. Under the guidance of an adaptive external energy field containing rich information, each initial contour begins iterative evolution. Due to the action of the factor, the contour will be preferentially attracted by those defect edges with high values and clear structures, and can effectively resist interference from low value regions (such as background textures).
[0068] Then, perform the final extraction and identification of the defect regions: When all active contours reach the convergence condition, the finally formed closed curves precisely outline the boundaries of the detected surface defects. Further, the pixel regions enclosed by these closed contours are identified and extracted as independent defect targets. Each defect target is assigned a unique ID, and its exact coordinates and contour point set in the original image are recorded.
[0069] Exemplary illustration: After this step, for an image region taken in S1 containing a microcrack approximately 3 mm long and 0.05 mm wide and two pits approximately 0.3 mm in diameter, the improved active contour model can exemplarily accurately segment the complete contour of this crack (even if some of its sections have low contrast) and the clear boundaries of the two pits, without mistakenly including the surrounding normal forging flow lines or slightly oxidized scale patches. The output results are the contour point coordinate sequences and binarized mask images for each defect.
[0070] Based on the successful segmentation of each defect region in the above steps, this step performs quantitative feature description and preliminary type determination of these defects for subsequent comprehensive evaluation. Specifically, for each segmented defect region (defined by its contour or mask): First, calculate a series of its geometric parameters, exemplarily including: area (number of pixels or converted to actual physical units, such as mm²), perimeter, equivalent diameter, length of the minimum bounding rectangle ( ), width ( ), principal axis orientation angle, elongation ( ), circularity (4π×area / perimeter²), compactness, Hu invariant moments, etc.
[0071] Then, the statistical grayscale features of the pixels inside the defect area (such as average grayscale, grayscale standard deviation, grayscale entropy) and the contrast features with the adjacent background area are calculated. Optionally, the local texture features of the defect area (such as LBP features, gray level co-occurrence matrix GLCM features, etc.) can also be extracted.
[0072] Finally, based on the quantitative features extracted above, combined with a pre-established defect knowledge base (which contains typical characteristic parameter ranges of different types of forging defects) and a set of exemplary classification rules (for example, implemented by simple threshold logic or a lightweight traditional classifier such as a decision tree or K-nearest neighbor (KNN) algorithm): If the defect elongation is >8 and the area is <(preset maximum allowable crack width × length), it is initially judged as a "linear defect (suspected crack)"; If the defect circularity is greater than 0.7 and the equivalent diameter is less than the preset maximum allowable point defect diameter, it is initially judged as a "point defect (suspected pit / pit)"; If the defect elongation is between 2 and 8 and has specific texture or grayscale characteristics, it may be judged as a "scratch" or "early fold".
[0073] Exemplary explanation: For the 3mm long crack segmented above, its elongation may be calculated as 60, for example, and its area is 0.15mm², which is successfully classified as a "linear defect". The circularity of two 0.3mm diameter pits may be calculated as 0.88 and 0.91, for example, and they are classified as "point defects". Each defect will be accompanied by a detailed list of its characteristic parameters.
[0074] After completing the precise segmentation and preliminary feature analysis of the pin forging surface defects, this embodiment can conduct a systematic and comprehensive evaluation of the test results. For example, according to the quality acceptance standard for the specific model of pin forgings pre-entered into the system (the standard may exemplarily stipulate: cracks longer than 1.5 mm are not allowed; the number of point defects with a diameter greater than 0.5 mm does not exceed 3 / dm²; no detectable defects are allowed in specific key stress-bearing areas (such as the transition fillet of the journal), etc.), the above-mentioned defect information (type, size, location, quantity, density, etc.) is strictly checked for compliance. Through the automated logic judgment program, the overall surface quality of the pin forging is finally judged. For example, the conclusion can be: "qualified", "unqualified (with the details of the main defects exceeding the standard)" or "pending manual review (for example, defects of certain critical sizes or difficult types)".
[0075] An embodiment of a pin forging quality inspection system: On the other hand, the present invention also provides a pin forging quality inspection system. Figure 2As shown, a quality inspection system for pin forging forming includes a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement a quality inspection method for pin forging forming according to the first aspect of the present invention.
[0076] A quality inspection system for pin forging forming further includes other components well-known to those skilled in the art such as a communication interface. Its settings and functions are known in the art, so they will not be elaborated here.
[0077] In the present invention, the aforementioned memory can be any tangible medium that contains or stores a program, and this program can be used by or combined with an instruction execution system, device, or component. For example, a computer-readable storage medium can be any suitable magnetic storage medium or magneto-optical storage medium. For instance, resistive random access memory (RRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (EDRAM), high-bandwidth memory (HBM), hybrid memory cube (HMC), etc., or any other medium that can be used to store the required information and can be accessed by an application, module, or both. Any such computer storage medium can be part of the device or accessible or connectable to the device. Any application or module described in the present invention can be implemented using computer-readable / executable instructions stored or otherwise held by such a computer-readable medium.
Claims
1. A method for detecting the forging quality of a pin shaft, characterized in that, The method includes: Obtaining a surface image of a pin forging to be detected; determining a total energy function of an active contour model, where the total energy function includes an internal energy term and an external energy term; Determining a pixel neighborhood window, obtaining a structure tensor based on the gradient magnitudes of each pixel within the pixel neighborhood window, and further calculating the local gradient direction dispersion of each pixel point; calculating a defect edge structure enhancement index for each pixel point based on the spatial distribution and local morphological features of the local gradient direction dispersion; Setting the minimum value and maximum value of an adaptive external energy scaling adjustment factor and calculating the difference between the minimum value and the maximum value; taking the defect edge structure enhancement index as the independent variable of a preset non-linear mapping function to obtain a mapped value, calculating the product of the mapped value and the difference and summing it with the minimum value to obtain the adaptive external energy scaling adjustment factor; using the adaptive external energy scaling adjustment factor as a multiplicative weight and directly acting on the basic external energy term in the total energy function of the active contour model to obtain an improved total energy function and thus obtain an improved active contour model; Using the improved active contour model to perform contour segmentation and extraction of potential defects in the surface image; performing feature extraction and quantification on the segmented defect regions, and determining the processing and forming quality of the pin forging based on a preset quality acceptance standard.
2. The quality inspection method for pin shaft forging forming according to claim 1, wherein The local gradient direction discreteness is denoted as , and the specific calculation method is as follows: For a pixel point and its neighborhood window , count the set of valid gradient vectors within the window whose gradient magnitude is greater than a preset threshold ; If the number of vectors is less than the set minimum effective gradient number, the local gradient direction discreteness is set to 0; Otherwise, for each valid gradient vector in normalize to obtain the direction vector , there is , and construct the structure tensor ; Calculation of the two eigenvalues and , then , where is a small positive number to avoid a zero denominator.
3. A pin forging quality inspection method according to claim 2, characterized in that, The specific calculation method of the defect edge structure enhancement index is as follows: ; Among them represents the defect edge structure enhancement index of the pixel point ; represents the local gradient direction discreteness; represents the point on the line segment in the set direction average value of the values; and represent the maximum value function and the minimum value function respectively.
4. A pin forging quality inspection method according to claim 1, characterized in that The specific calculation method of the adaptive external energy scaling adjustment factor is as follows: ; wherein and respectively represent the minimum and maximum values of the set adaptive external energy scaling adjustment factor; represents the pixel point defect edge structure enhancement index; is a non - linear mapping function, and its parameters include the lower threshold for calibrating the mapping interval, upper threshold and the exponent for controlling the curve shape.
5. A pin forging forming quality detection method according to claim 4, characterized in that, The non-linear mapping function includes at least one of the Sigmoid function or the following piecewise function, specifically: ; wherein represents a reference symbol for referring to the defect edge structure enhancement index.
6. The pin shaft forging forming quality inspection method according to claim 1, characterized in that The improved energy function is specifically defined as: ; Among them represents the defined expression of the improved energy function; , represents the parameterized contour curve; represents the internal energy, and there is , where and are the set weights; represents the adaptive external energy scaling adjustment factor calculated at the position of the contour point ; is a basic external energy term, constructed based on the image gradient magnitude, and there is , where is the Gaussian smoothing kernel, is the set gradient energy weight constant.
7. A method for detecting the quality of forged pin forming according to claim 1, characterized in that Before obtaining the surface image of the pin forging to be detected, it further includes: Performing surface cleaning, cooling, and precise positioning on the pin forging to be detected; Using at least one industrial camera in cooperation with a telecentric lens and a programmable combined light source system to perform image acquisition on the surface to be detected of the pin forging under multi-angle or multi-mode illumination, and performing necessary camera calibration and light field calibration.
8. A pin forging forming quality detection method according to claim 7, wherein It further includes preprocessing the surface image: Performing grayscale processing on the surface image; Performing adaptive histogram equalization on the grayscale image; Performing median filtering denoising on the grayscale image.
9. A pin forging quality inspection method according to claim 1, characterized in that After using the improved active contour model to perform contour segmentation and extraction of potential defects in the surface image, it further includes: Automatically calculating geometric feature parameters for each segmented defect region, where the geometric feature parameters at least include area, perimeter, equivalent diameter, length and width of the minimum circumscribed rectangle, major axis direction angle, elongation, and circularity; And calculating its grayscale feature parameters, where the grayscale feature parameters at least include the average grayscale within the region, grayscale standard deviation, and average contrast with the adjacent background region.
10. A quality inspection system for forged forming of pin shafts, characterized in that, It includes a processor and a memory, and the memory stores computer program instructions, and when the computer program instructions are executed by the processor, it implements a method for detecting the forming quality of a pin forging according to any one of claims 1 to 9.
Citation Information
Patent Citations
Method for mounting large-sized rolling mills
CN101275400A
Automatic pin shaft machining method and system
CN116213613A
Mould plate quality detection method and system based on machine vision
CN118587226A
Welding quality comprehensive evaluation method and system
CN119672025A
Hole protection cap detection method and apparatus, computer device and storage medium
WO2021000524A1
Cited By
Laminated slab quality detection method and system based on image processing
CN120598967A
Method for evaluating surface flatness of autoclaved aerated concrete plate
CN120747042A
LCD defect automatic lightening detection and classification method and system
CN120953276A
A method and system for automatic defect lighting detection and classification of LCDs
CN120953276B
Fabricated building construction quality safety management monitoring method and system
CN121032302A