A Visual Inspection Method for Titanium Alloy Bars Based on Image Segmentation
Through the visual detection method of titanium alloy rods based on image segmentation, the problem of insufficient defect identification and classification capabilities of titanium alloy rods in the prior art is solved, and efficient and accurate defect detection and traceability analysis are achieved, supporting process optimization and defect prevention.
Patent Information
- Application Number
- CN202510466906.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-15
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2045-04-15
AI Technical Summary
Existing titanium alloy rod detection methods are difficult to accurately identify and classify defects, especially under small defects or complex textures. There is a lack of quantitative analysis of defect severity and in-depth research on causal correlation, making it difficult to optimize process and prevent defects.
The visual detection method of titanium alloy rods based on image segmentation is adopted, including pretreatment and feature enhancement, adaptive segmentation algorithm based on region growth, defect feature extraction, defect classification model, severity quantification model and causal chain model, to achieve efficient and accurate identification and classification of surface defects of titanium alloy rods, and to conduct defect traceability analysis.
The accuracy and robustness of defect detection are improved, efficient identification and classification of surface defects of titanium alloy rods are realized, and quantitative analysis of defect severity and in-depth research on causal correlation are carried out to support process optimization and defect prevention.
Smart Images

Figure CN119991670B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of metal detection, and specifically to a visualization detection method for titanium alloy bars based on image segmentation. Background Art
[0002] Due to their excellent mechanical properties and corrosion resistance, titanium alloy bars are widely used in fields such as aerospace, medical devices, and chemical engineering. However, during the production and processing process, defects such as cracks, inclusions, pores, and abnormal structures are likely to occur on the surface of titanium alloy bars, which seriously affect their mechanical properties and service life. Therefore, how to accurately detect and identify the defects of titanium alloy bars has become a technical problem that needs to be solved urgently.
[0003] Currently, traditional detection methods for titanium alloy bars mostly rely on ultrasonic flaw detection, X-ray detection, or manual visual inspection. These methods have the following deficiencies:
[0004] Insufficient defect recognition ability: Due to the diverse types of defects, a single detection method is often difficult to detect comprehensively, especially for micro-defects or complex textures.
[0005] Insufficient defect quantification analysis: Existing methods usually only make simple judgments on defects, lacking quantitative analysis and classification evaluation of the severity of defects.
[0006] Insufficient defect traceability and cause analysis: Currently, there is a lack of in-depth research on the causes and causal relationships of defect formation, making it difficult to optimize the process and prevent defects. Summary of the Invention
[0007] Aiming at the problem that it is difficult to optimize the process and prevent defects in the existing technology, the present invention proposes a visualization detection method for titanium alloy bars based on image segmentation.
[0008] The technical solution of the present invention is a visualization detection method for titanium alloy bars based on image segmentation, which specifically includes the following steps:
[0009] Step 1: Preprocess and enhance the features of the surface image of the collected titanium alloy bar.
[0010] Step 2: Construct an adaptive segmentation algorithm based on region growing to segment the defect regions of the surface image of the titanium alloy bar.
[0011] Step 3: Extract the defect features of the segmented defect regions.
[0012] Step 4: Construct a defect classification model to classify the defect types of the titanium alloy bar based on the defect features.
[0013] Step 5: Quantitatively analyze the severity of the defects through a defect severity quantification model.
[0014] Step 6: Establish a defect causal chain model, conduct defect traceability analysis and causal derivation;
[0015] Step 7: After completing the defect traceability analysis, conduct fusion analysis on multi-scale features, and give decision-making suggestions and operability guidance;
[0016] Preferably, the preprocessing described in Step 1 is specifically as follows:
[0017] Remove noise through adaptive median filtering, improve brightness uniformity by using local contrast equalization, and highlight the defect feature edges in combination with a difference enhancement operator;
[0018] The noise removal by the adaptive median filtering is specifically as follows:
[0019] The size of its filtering kernel is adaptively adjusted according to the noise level. Define the pixel value at position (x, y) in the original image The denoised and enhanced pixel value is:
[0020] ;
[0021] Among them, : The weighting coefficient of the i-th pixel in the horizontal direction and the j-th pixel in the vertical direction of the filtering window, adjusted according to the noise level;
[0022] : The size of the filtering window;
[0023] and respectively represent the pixel indices in the horizontal and vertical directions of the filtering window, that is, the position coordinates of the pixels within the window.
[0024] During the denoising process, first determine the size of the filtering window according to the noise level ;
[0025] Subsequently, calculate the weight to control the influence of different pixels on the enhancement result;
[0026] Through the sliding window operation, perform pixel-by-pixel convolution calculation on the original image to obtain the denoised enhanced image ;
[0027] The improvement of brightness uniformity by using local contrast equalization is specifically as follows:
[0028] Calculate the gradient value of the homogenized image, which is used to extract the prominent edge features in the image;
[0029] By adjusting the enhancement factor , amplify the gradient response to make the defect edges more prominent in the image. Especially when the background is complex, it can further highlight the difference in the defect area;
[0030] The local contrast equalization is as follows:
[0031] ;
[0032] Among them, : The pixel value of the homogenized image at position (x, y);
[0033] : The local mean value of the pixel at position (x, y);
[0034] : The local standard deviation of the pixel at position (x, y).
[0035] The core of brightness homogenization lies in adjusting the local brightness change to avoid uneven brightness caused by reflection or shadow. By calculating the mean value and the standard deviation in each window area, the brightness level can be dynamically adjusted to improve the contrast and uniformity of the image;
[0036] The highlighting process of the defect feature edges by combining the difference enhancement operator is as follows:
[0037] ;
[0038] Among them, : The pixel value of the image after feature enhancement at position (x, y);
[0039] : Enhancement factor;
[0040] : The image gradient at position (x, y).
[0041] Preferably, the construction of the adaptive segmentation algorithm based on region growing in step 2 for segmenting the defect area of the titanium alloy bar surface image is as follows:
[0042] Automatic selection of seed points: Calculate the pixel intensity mutation points through the image after feature enhancement, and define the seed point set :
[0043] ;
[0044] Among them, is the threshold, which is adaptively determined by the statistical characteristics of the image.
[0045] Represents the gradient magnitude of the representative image at position (x, y), measuring the degree of change in pixel intensity at that point.
[0046] Calculate the gradient value of the enhanced image and filter out the pixels with gradient values greater than the threshold as seed points. The threshold is calculated based on the characteristics of the image gradient distribution to ensure that representative starting points of defective areas can be selected in the presence of uneven brightness and noise;
[0047] Region growing decision criterion: Region growing is based on the similarity of adjacent pixels, and the growing decision criterion is as follows:
[0048] ;
[0049] Among them, represents the decision result of whether the pixel at coordinate belongs to the growing region. A value of 1 indicates belonging to the growing region, and a value of 0 indicates not belonging to the growing region;
[0050] : Coordinates of pixels in the already grown region, that is, the similarity judgment benchmark of the new pixel (x, y) to be compared with the pixels (x', y') in the already grown region during the region growing process;
[0051] Otherwise: It means that during the region growing process, if the candidate pixel (x, y) does not meet the growing conditions, this pixel will not be added to the already grown region.
[0052] : Similarity threshold, determined by statistical analysis;
[0053] Region growing expands based on pixel intensity similarity. By comparing the intensity difference between the seed point and adjacent pixels, it is determined whether to add to the growing region;
[0054] Similarity threshold is adaptively adjusted to cope with different defect characteristics. During the growing process, by gradually expanding the neighborhood, the boundary of the already grown region is dynamically adjusted to ensure complete coverage of the defective area;
[0055] Region growing stop condition: Define the growing stop criterion as the region change rate, then the region change rate is as follows:
[0056] ;
[0057] Among them, : Region change rate, representing the relative proportion of region change during the growing process;
[0058] : Total number or area of pixels in the current growing region;
[0059] : The sum of pixels or the area of the previous growth region;
[0060] : The convergence threshold, which controls the precision requirement for the growth to stop;
[0061] During the growth process, calculate the change rate between the new and old regions in real time , and determine whether the growth enters a stable state. When the change rate is lower than the convergence threshold , it is considered that the growth process reaches convergence and the expansion stops;
[0062] This strategy effectively prevents the overgrowth of regions and ensures accurate segmentation results with clear boundaries;
[0063] Preferably, the defect feature extraction for the segmented defect regions in step 3 includes geometric feature extraction and texture feature extraction;
[0064] The geometric feature extraction includes extracting the area, perimeter, and shape factor for each defect region; by statistically analyzing the pixels of the defect region, calculate its area and perimeter;
[0065] The texture feature extraction includes extracting texture features using the gray-level co-occurrence matrix, including energy, contrast, entropy, and correlation; by constructing the gray-level co-occurrence matrix, calculate the joint probability distribution of pixel pairs in the image block, and extract four features: energy, contrast, entropy, and correlation;
[0066] After the defect feature extraction, a feature vector is formed , providing input data for the defect classification model;
[0067] Preferably, step 4 is specifically as follows:
[0068] Using the feature vector as the input, extract deep features through multi-layer convolution and pooling operations, effectively improving the classification effect. At the same time, introduce a weighted cross-entropy loss function to perform weighted adjustment for class imbalance, thus having significant advantages in rare defect recognition;
[0069] The defect classification model uses a convolutional neural network CNN and is trained and predicted in combination with the feature vector;
[0070] The input layer of the CNN receives the feature vector , and extracts deep features through multi-layer convolution and pooling operations. The formula is as follows:
[0071] ;
[0072] Among them, is the convolutional kernel weight; is the bias term; The ReLU is used as the activation function;
[0073] The multi-layer convolution operation performs weighted summation and bias correction on the input features through a convolution kernel, and mines non-linear features through the activation function to form a deep feature representation;
[0074] The weighted cross-entropy loss function is adopted to optimize the classification accuracy of rare defect categories:
[0075] ;
[0076] Among them, : The classification loss function value, that is, the weighted cross-entropy loss value used to measure the difference between the model prediction result and the true label;
[0077] : The number of defect categories;
[0078] : The category weight of the c-th type of defect, adjusted according to the category imbalance;
[0079] : The true category label of the c-th type of defect;
[0080] : The model prediction probability of the c-th type of defect.
[0081] Cumulative calculation is performed on all defect categories to obtain the final classification loss value, and the optimization objective is to minimize the loss;
[0082] Preferably, in step 5, the quantitative analysis includes:
[0083] Construct a defect severity quantification model;
[0084] Determination of defect weight coefficients;
[0085] Severity level division;
[0086] The defect severity quantification model adopts weighted defect features for comprehensive evaluation:
[0087] ;
[0088] Among them, : The comprehensive value of defect severity;
[0089] : The number of defect features;
[0090] : The defect weight coefficient;
[0091] : Defect feature function, which quantifies the th feature in the feature vector;
[0092] By weighted summation of different defect features, a comprehensive value of defect severity is formed ;
[0093] Each defect feature function reflects the quantified value of an independent feature;
[0094] Weight coefficient is calculated by the Analytic Hierarchy Process (AHP);
[0095] For different defect categories and features, the Analytic Hierarchy Process is used to calculate the defect weight coefficient :
[0096] ;
[0097] Among them, : Feature importance coefficient, which is comprehensively calculated by domain expert scoring and statistical analysis, and reflects the weight of this feature in defect recognition;
[0098] : The th feature importance coefficient;
[0099] : The sum of all defect feature importance coefficients, which is used for weight normalization.
[0100] By calculating the normalized values of each feature importance coefficient, the relative weights of defect features are formed.
[0101] According to the comprehensive value of defect severity , thresholds are set to divide different levels:
[0102] ;
[0103] Among them, is the upper limit of the empirical threshold, is the lower limit of the empirical threshold, which is determined by historical data;
[0104] Preferably, step 6 is specifically as follows:
[0105] Based on the causal chain model of the Bayesian network, systematically and quantitatively deduce the formation causes and influencing factors of defects;
[0106] By comprehensively considering multiple process and material factors, use the maximum a posteriori probability to deduce the main causes of defects;
[0107] The formation of setting defects is caused by a combination of multiple process and material factors. A Bayesian network is used to construct a defect causal chain model:
[0108] ;
[0109] Among them, : The defect cause, that is, the process link that may cause the current defect, representing multiple candidate processing or manufacturing process steps, such as heat treatment, machining, surface treatment, etc.;
[0110] : The feature vector, a set of defect-related features obtained by image analysis, including size, shape, edge features, color change, surface roughness, etc.;
[0111] : The posterior probability of the defect cause under the given feature vector;
[0112] : The conditional probability of observing the feature vector under the defect cause;
[0113] : The prior probability of the defect cause;
[0114] : The total probability of the feature vector appearing;
[0115] Use the defect causal chain model to calculate the potential process links for defect formation, and output the main influencing factors and their weights. The causal derivation adopts the maximum posterior probability principle:
[0116] ;
[0117] : The operator, indicating to find the defect cause that makes obtain the maximum probability value , that is, the most likely defect formation process;
[0118] By analyzing the association strength between the nodes of the Bayesian network, determine the key defect formation processes and their corresponding parameters to guide process optimization;
[0119] By calculating the posterior probability , that is, under the given feature vector , the posterior probability that the defect cause causes the defect, indicating the degree of association of this process with the current defect, and select the defect cause with the maximum probability value, and the most likely process cause and influencing factors for defect formation can be obtained;
[0120] Preferably, step 7 is specifically as follows:
[0121] Adopt a scale - adaptive weighted fusion method, and use the particle swarm optimization algorithm to find the optimal weights to obtain the fused features after weighted fusion. Based on the fused features and the comprehensive value of the defect severity, give decision - making suggestions and operability guidance;
[0122] The beneficial effects of the present invention are as follows:
[0123] This visualization detection method for titanium alloy bars based on image segmentation can efficiently and accurately identify and classify the surface defects of titanium alloy bars, and through severity quantification and causal chain analysis, realize defect cause tracing and multi - scale feature fusion. Through the defect segmentation, feature extraction and classification algorithm based on convolutional neural network and the Bayesian causal chain model, it not only improves the accuracy and robustness of defect detection, but also effectively solves the deficiencies of traditional detection methods in terms of efficiency, recognition ability and quantitative analysis. In addition, through multi - scale fusion and adaptive weight optimization, the present invention further enhances the detection ability of complex defects, providing scientific support for the quality control and process optimization of titanium alloy bars. Brief Description of the Drawings
[0124] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0125] Figure 1 : Schematic diagram of the method flow of the embodiment of the present invention;
[0126] Figure 2 : Schematic diagram of the flow of the adaptive segmentation algorithm of the embodiment of the present invention; Detailed Embodiments
[0127] To make the above - mentioned objects, features and advantages of the present invention more obvious and understandable, the following will give a detailed description of the specific embodiments of the present invention with reference to the drawings in the specification.
[0128] In the following description, many specific details are set forth to fully understand the present invention. However, the present invention can also be implemented in other ways different from those described herein. Those skilled in the art can make similar promotions without departing from the connotation of the present invention. Therefore, the present invention is not limited by the specific embodiments disclosed below.
[0129] Secondly, the "one embodiment" or "embodiment" mentioned herein refers to specific features, structures or characteristics that may be included in at least one implementation manner of the present invention. The "in one embodiment" that appears in different places in this specification does not all refer to the same embodiment, nor is it an embodiment that is separate or selectively exclusive to other embodiments.
[0130] Embodiment 1:
[0131] Referring to Figures 1 to 2 , this is the first embodiment of the present invention. This embodiment provides a visualization detection method for titanium alloy bars based on image segmentation, including the following steps:
[0132] S1. Perform preprocessing and feature enhancement operations on the surface image of the collected titanium alloy bar.
[0133] In the prior art, in the image preprocessing of titanium alloy bar defect detection, simple filtering and global contrast enhancement methods are often used, such as Gaussian filtering and histogram equalization. However, when facing complex defect textures and background noises, these methods are prone to losing feature details or insufficient enhancement, especially for subtle defects, it is difficult to effectively highlight them.
[0134] In this embodiment, while removing noise through adaptive median filtering, local contrast equalization (LCE) is used to improve brightness uniformity, and a differential enhancement operator is combined to highlight the defect feature edges. The overall method has significant advantages in multi-scale and multi-feature fusion, and can still maintain a high defect feature resolution ability under complex backgrounds and subtle defects.
[0135] The preprocessing includes denoising processing and brightness uniformity, and the feature enhancement uses a differential enhancement operator to highlight the defect edges;
[0136] The denoising processing uses an adaptive median filtering algorithm to remove noise, and the filter kernel size is adaptively adjusted according to the noise level. Define the pixel value of the denoised and enhanced pixel value at the position (x, y) of the original image as:
[0137] ;
[0138] Where : The weighting coefficient of the i-th pixel in the horizontal direction and the j-th pixel in the vertical direction of the filtering window, adjusted according to the noise level;
[0139] : The size of the filtering window;
[0140] and respectively represent the pixel indices of the filtering window in the horizontal and vertical directions, that is, the position coordinates of the pixels within the window.
[0141] During the denoising process, first determine the size of the filtering window according to the noise level . Subsequently, calculate the weights to control the influence of different pixels on the enhancement result. Through the sliding window operation, perform pixel-by-pixel convolution calculation on the original image to obtain the enhanced image after denoising . This operation effectively removes the background noise while maintaining the clarity of the defect features.
[0142] Due to the uneven surface reflection, the local contrast equalization method is used for brightness uniformity:
[0143] ;
[0144] where : the pixel value of the homogenized image at the position (x, y);
[0145] : the local mean of the pixel at the position (x, y);
[0146] : the local standard deviation of the pixel at the position (x, y).
[0147] The core of brightness uniformity lies in adjusting the local brightness change to avoid uneven brightness caused by reflection or shadow. By calculating the mean and standard deviation within each window area, the brightness level can be dynamically adjusted to enhance the contrast and uniformity of the image.
[0148] The feature enhancement formula is as follows:
[0149] ;
[0150] where : the pixel value of the image after feature enhancement at the position (x, y);
[0151] : the enhancement factor;
[0152] : the image gradient at the position (x, y).
[0153] During the feature enhancement stage, first calculate the gradient value of the homogenized image, which is used to extract the prominent edge features in the image. By adjusting the enhancement factor , amplify the gradient response to make the defect edges more prominent in the image. Especially when the background is complex, it can further highlight the difference in the defect area.
[0154] S2. Construct an adaptive segmentation algorithm based on region growing to segment the defect area in the surface image of the titanium alloy bar.
[0155] In the prior art for defect detection of titanium alloy bars, methods based on threshold segmentation or traditional region growing algorithms are often used. The disadvantages are that the threshold selection depends on manual adjustment and is sensitive to noise, resulting in over-segmentation or under-segmentation easily in the case of complex defects and non-uniform backgrounds. In addition, the traditional region growing algorithm performs poorly in dealing with multi-scale defects and cannot adapt to different defect morphologies and features.
[0156] In this embodiment, an adaptive segmentation algorithm based on region growing is adopted to realize multi-layer optimization of automatic seed point selection, region growing determination, and growth stop conditions. Specifically, the seed points are automatically selected by using the pixel intensity mutation points, reducing manual intervention; the growth determination and stop control are carried out through the similarity of adjacent pixels and the regional change rate, making the algorithm have high robustness and self-adaptability in multi-scale and complex backgrounds.
[0157] In the adaptive segmentation algorithm, it further includes:
[0158] Automatic seed point selection: Through the image after feature enhancement calculate the pixel intensity mutation points and define the seed point set :
[0159] ;
[0160] Among them, is the threshold, which is adaptively determined by the statistical characteristics of the image.
[0161] represents the gradient amplitude at the position (x, y) of the image, measuring the change degree of the pixel intensity at this point.
[0162] After image preprocessing and feature enhancement, calculate the gradient value of the enhanced image, and screen the pixels with the gradient value greater than the threshold as the seed points. The threshold is obtained by calculating the gradient distribution characteristics of the image to ensure that representative starting points of the defect area can be selected in the case of uneven brightness and the presence of noise.
[0163] Region growing determination criterion: Region growing is based on the similarity of adjacent pixels, and the growing determination criterion is as follows:
[0164] ;
[0165] Among them, Indicates coordinates The determination result of whether the pixel at this position belongs to the growing region. A value of 1 indicates belonging to the growing region, and a value of 0 indicates not belonging to the growing region;
[0166] : Coordinates of pixels in the grown region, that is, the similarity determination benchmark of the new pixel (x, y) compared with the pixel (x', y') in the grown region during the region growing process;
[0167] Otherwise: It means that during the region growing process, if the candidate pixel (x, y) does not meet the growing conditions, this pixel will not be added to the grown region.
[0168] : Similarity threshold, determined by statistical analysis.
[0169] Region growing is extended based on pixel intensity similarity. By comparing the intensity difference between the seed point and adjacent pixels, it is judged whether to join the growing region. The similarity threshold Is adaptively adjusted to cope with different defect features. During the growing process, by gradually expanding the neighborhood, the boundary of the grown region is dynamically adjusted to ensure complete coverage of the defect region.
[0170] Region growing stop condition: Define the growth stop criterion as the region change rate, then the region change rate is as follows:
[0171] ;
[0172] Among them, : Region change rate, indicating the relative proportion of region change during the growing process;
[0173] : The total number or area of pixels in the current growing region;
[0174] : The total number or area of pixels in the previous round of growing region;
[0175] : Convergence threshold, controlling the precision requirement for growth stop.
[0176] During the growing process, the change rate of the new and old regions is calculated in real time To judge whether the growth enters a stable state. When the change rate is lower than the convergence threshold It is considered that the growth process reaches convergence and the expansion stops. This strategy effectively prevents overgrowth of the region and ensures accurate segmentation results with clear boundaries.
[0177] S3. Extract defect features from the segmented defect region.
[0178] Defect feature extraction includes geometric feature extraction and texture feature extraction. By using the method of combining geometric features and texture features, it can not only describe the morphological characteristics of defects, but also depict the texture differences on the defect surface, improving the comprehensiveness and accuracy of feature expression.
[0179] Geometric feature extraction includes extracting the area, perimeter and shape factor for each defect region; by counting the pixels in the defect region, its area and perimeter are calculated. The shape factor comprehensively reflects the morphological characteristics of defects through the area and perimeter, which helps to distinguish regular defects (such as holes) from irregular defects (such as cracks).
[0180] Texture feature extraction includes extracting texture features using the gray-level co-occurrence matrix, including energy, contrast, entropy and correlation; by constructing the gray-level co-occurrence matrix (GLCM), calculating the joint probability distribution of pixel pairs in the image block, and extracting four features: energy, contrast, entropy and correlation. These features can reflect the texture characteristics of the defect region. For example:
[0181] A larger energy indicates that the defect surface is smooth and uniform;
[0182] A higher contrast represents a drastic change in gray level, which is suitable for detecting scratches or cracks;
[0183] A higher entropy indicates complex texture, often corresponding to a rough surface;
[0184] A lower correlation indicates that the texture in the defect region is disordered or the randomness is enhanced.
[0185] After defect feature extraction, a feature vector is formed , providing input data for the defect classification model.
[0186] S4. Build a defect classification model to classify the defect types of titanium alloy bars based on defect features.
[0187] Taking the feature vector as the input, deep features are extracted through multi-layer convolution and pooling operations, effectively improving the classification effect. At the same time, a weighted cross-entropy loss function is introduced to perform weighted adjustment for class imbalance, thus having significant advantages in rare defect recognition.
[0188] The defect classification model uses a convolutional neural network CNN, which is trained and predicted in combination with the feature vector;
[0189] The input layer of the CNN receives the feature vector , and deep features are extracted through multi-layer convolution and pooling operations. The formula is as follows:
[0190] ;
[0191] Among them, is the convolution kernel weight; is the bias term; is the activation function, using ReLU;
[0192] The convolution operation performs weighted summation and bias correction on the input features through the convolution kernel, and mines the non-linear features through the activation function to form a deep feature representation.
[0193] Adopt a weighted cross-entropy loss function to optimize the classification accuracy of rare defect categories:
[0194] ;
[0195] where, : the classification loss function value, that is, the weighted cross-entropy loss value used to measure the difference between the model prediction result and the true label;
[0196] : the number of defect categories;
[0197] : the category weight of the c-th type of defect, adjusted according to the category imbalance;
[0198] : the true category label of the c-th type of defect;
[0199] : the model prediction probability of the c-th type of defect.
[0200] Cumulatively calculate for all defect categories to obtain the final classification loss value, and the optimization goal is to minimize the loss.
[0201] The classification result of the defect classification model is directly used as the input for subsequent severity quantification analysis.
[0202] S5. After completing the defect classification, perform a severity quantification analysis on the defect severity through a defect severity quantification model.
[0203] In the prior art for defect severity assessment, usually a single feature index or simple threshold judgment is adopted, lacking comprehensive quantitative analysis of multiple features. For example, some methods only classify based on the defect area or depth, ignoring comprehensive features such as defect morphology and texture, and it is difficult to comprehensively reflect the impact of defects on material properties. At the same time, in terms of defect weight determination, most of the existing methods rely on subjective experience and lack a scientific and reasonable weight allocation mechanism.
[0204] In the step S5, the severity quantification analysis includes:
[0205] Construct a defect severity quantification model;
[0206] Determination of defect weight coefficients;
[0207] Severity level classification.
[0208] The defect severity quantification model uses weighted defect features for comprehensive evaluation:
[0209] ;
[0210] Among them, : Comprehensive value of defect severity;
[0211] : Number of defect features;
[0212] : Defect weight coefficient;
[0213] : Defect feature function, which quantifies the th feature in the feature vector.
[0214] This formula forms the comprehensive value of defect severity .
[0215] Each defect feature function reflects the quantified value of an independent feature, such as defect area, morphological complexity, surface texture change, etc.
[0216] The weight coefficient is calculated by the Analytic Hierarchy Process (AHP), which can scientifically reflect the contribution degree of each feature to the severity and avoid the one-sidedness of simple averaging.
[0217] Through weighted synthesis, a unified severity index is formed, solving the problem of inconsistent scales of different features.
[0218] For different defect categories and features, the Analytic Hierarchy Process is used to calculate the defect weight coefficient :
[0219] ;
[0220] Among them, : Feature importance coefficient, which is comprehensively calculated by domain expert scoring and statistical analysis, reflecting the weight of this feature in defect recognition;
[0221] : th
[0222] : Sum of all defect feature importance coefficients, used for weight normalization.
[0223] By calculating the normalized values of the importance coefficients of each feature, the relative weights of the defect features are formed.
[0224] According to the comprehensive value of the defect severity , set thresholds to divide into different levels:
[0225] ;
[0226] Among them, is the upper limit of the empirical threshold, is the lower limit of the empirical threshold, which is determined by historical data.
[0227] By dividing into different levels through the threshold, the defect severity can be visually classified.
[0228] S6. After completing the quantitative analysis of the defect severity, establish a defect causal chain model and carry out defect traceability analysis and causal derivation.
[0229] In the aspect of defect cause analysis in the prior art, empirical methods are usually adopted, relying on the experience of process experts and historical data for speculation, lacking a quantitative analysis model. For example, the prior art may use simple causal relationships or rule-based methods, but these methods often cannot comprehensively consider the multi-factors and complex relationships in the formation of defects, easily leading to one-sidedness or deviation of the analysis results. In addition, there is a lack of a systematic derivation process in the existing methods, and often rely on manual judgment or incomplete statistical reasoning, unable to accurately reveal the deep relationship between different process parameters and defects.
[0230] In this embodiment, a causal chain model based on a Bayesian network is proposed to systematically and quantitatively derive the formation causes and influencing factors of defects. By comprehensively considering multiple process and material factors and using the maximum a posteriori probability to derive the main causes of defects, the subjectivity and incomplete information problems existing in the prior art are avoided. This method not only realizes scientific cause derivation, but also has strong self-adaptability and can be dynamically updated with the changes of data and process conditions.
[0231] It is assumed that the formation of defects is caused by the comprehensive action of multiple process and material factors, and a Bayesian network is used to construct a defect causal chain model:
[0232] ;
[0233] Among them, : Defect cause, that is, the process link that may cause the current defect, representing multiple candidate processing or manufacturing process steps, such as heat treatment, machining, surface treatment, etc.;
[0234] : Feature vector, a set of defect-related features obtained from image analysis, including size, shape, edge features, color variation, surface roughness, etc.;
[0235] : The posterior probability of the defect cause under the given feature vector;
[0236] : The conditional probability of observing the feature vector given the defect cause;
[0237] : The prior probability of the defect cause;
[0238] : The total probability of the feature vector occurring;
[0239] Use the defect causal chain model to calculate the potential process steps for defect formation, and output the main influencing factors and their weights. The causal derivation adopts the maximum a posteriori probability principle:
[0240] ;
[0241] : An operator indicating to find the defect cause that makes obtain the maximum probability value , that is, the most likely defect formation process.
[0242] By analyzing the association strength between the nodes of the Bayesian network, determine the key defect formation processes and their corresponding parameters to guide process optimization.
[0243] By calculating the posterior probability , that is, under the given feature vector , the posterior probability that the defect cause leads to the defect, indicating the degree of association of this process with the current defect, and select the defect cause with the maximum probability value , the most likely process cause and influencing factors for defect formation can be obtained. This process can scientifically locate the key links of the defect, helping with process optimization and quality improvement.
[0244] S7. After completing the defect traceability analysis, perform a fusion analysis on the multi-scale features, and give decision-making suggestions and operable guidance.
[0245] Considering the different scale distributions of defect features, adopt the scale adaptive weighted fusion method in the existing technology, and use the particle swarm optimization algorithm to find the optimal weights to obtain the fused features after weighted fusion. Based on the fused features and the comprehensive value of defect severity, give decision-making suggestions and operable guidance, such as process adjustment or surface repair suggestions.
[0246] Table 1 Comparison results of the visualization detection experiment of titanium alloy bars
[0247]
[0248] To verify the effectiveness of the proposed visualization detection method for titanium alloy bars based on image segmentation, comparative experiments were designed to analyze the performance of this method in terms of defect recognition accuracy, defect location precision, detection time consumption, and defect traceability ability. A total of 5 groups of titanium alloy bar samples with defects were prepared artificially in this experiment, including typical defect types such as pores, inclusions, cracks, etc. This method was compared with traditional methods based on gray threshold segmentation and Canny edge detection, as shown in Table 1.
[0249] Analysis of experimental results:
[0250] It can be seen from the experimental results that the visualization detection method for titanium alloy bars based on image segmentation proposed in the present invention is significantly superior to traditional methods in terms of recognition accuracy, defect location precision, and defect traceability ability. Especially in terms of defect recognition accuracy, it reaches 96.7% on average, which is about 8.6% higher than the Canny edge detection method and more than 14% higher than the gray threshold method. In terms of defect location deviation, this method is controlled within 2 pixels, with higher detail segmentation ability, which is helpful for subsequent defect size calculation and three-dimensional reconstruction. At the same time, the detection time consumption is controlled within 1 second, with good real-time performance. In summary, this method can significantly improve the intelligent level and process diagnosis ability of on-line detection of titanium alloy bars.
[0251] Embodiment 2:
[0252] This embodiment also provides a computer device, which is applicable to the situation of a visualization detection method for titanium alloy bars based on image segmentation, including a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement a visualization detection method for titanium alloy bars based on image segmentation as proposed in the above embodiment.
[0253] This embodiment also provides a storage medium, on which a computer program is stored, and when the program is executed by a processor, it implements a visualization detection method for titanium alloy bars based on image segmentation as proposed in the above embodiment.
[0254] The computer device may be a terminal, and the computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The communication interface of the computer device is used to communicate with external terminals in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a carrier network, NFC (Near Field Communication), or other technologies. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covering the display screen, or may be a button, a trackball, or a touchpad provided on the housing of the computer device, or may also be an external keyboard, a touchpad, or a mouse, etc.
[0255] If a function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes: USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs, etc., various media that can store program codes.
[0256] The logic and / or steps represented in the flowchart or described in other ways herein, for example, can be considered as a definite sequence list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other systems that can fetch instructions from the instruction execution system, apparatus, or device and execute the instructions), or in combination with these instruction execution systems, apparatus, or devices. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device.
[0257] More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection (electronic device) having one or more wirings, a portable computer diskette (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable media can even be paper or other suitable media on which a program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpretation, or otherwise processing it in a suitable manner if necessary, and then storing it in a computer memory.
[0258] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or a combination of the following techniques well known in the art can be used: discrete logic circuits having logic gate circuits for implementing logical functions on data signals, application specific integrated circuits having appropriate combinational logic gate circuits, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.
[0259] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present invention, and they should all be covered by the scope of the claims of the present invention.
Claims
1. A titanium alloy bar visualization detection method based on image segmentation, characterized in that: The following steps are involved: Step 1: Preprocessing and feature enhancement operations are performed on the collected surface image of the titanium alloy bar; Step 2: Construct an adaptive segmentation algorithm based on region growing to segment the defective area of the titanium alloy bar surface image; Step 3: Extract defect features from the segmented defect area; Step 4: Construct a defect classification model. The defect classification model uses a convolutional neural network (CNN) and combines feature vectors for training and prediction, and classifies the defect types of titanium alloy bars based on defect features. Step 5: Through the defect severity quantification model, weighted sum of different defect features is performed to form a comprehensive defect severity value, and the defect severity is quantitatively analyzed based on the comprehensive defect severity value; Step 6: Establish a defect causal chain model. The defect causal chain model is based on the Bayesian network. It systematically and quantitatively derives the causes and influencing factors of defects. By comprehensively considering process and material factors, the maximum a posteriori probability is used to deduce the causes of defects, and defect traceability analysis and causal deduction are carried out. The details are as follows: Assuming that defects are caused by a combination of multiple process and material factors, a Bayesian network is used to construct a defect causal chain model: ; in, : Defect cause, that is, the process link that may cause the current defect, represents multiple candidate processing or manufacturing process steps, such as heat treatment, machining, and surface treatment; : Feature vector, a set of defect-related features obtained by image analysis, including size, shape, edge features, color change, and surface roughness; : The posterior probability of the defect cause under a given feature vector; : The conditional probability of observing the feature vector under the defect cause; : Prior probability of defect cause; : The total probability of the feature vector appearing; The defect causal chain model is used to calculate the potential process links for defect formation, and the main influencing factors and their weights are output. The causal deduction adopts the maximum a posteriori probability principle: ; : operator, indicating that The defect cause with the highest probability value , i.e. the most likely defect formation process; By analyzing the correlation strength between Bayesian network nodes, key defect formation processes and their corresponding parameters are determined to guide process optimization; By calculating the posterior probability , that is, given the feature vector In the case of defects, the cause The posterior probability of causing the defect indicates the degree of relevance of the process to the current defect, and selects the defect cause with the largest probability value , the most likely process causes and influencing factors of defect formation can be obtained; Step 7: After completing the defect tracing analysis, perform a fusion analysis of the multi-scale features to provide decision-making recommendations and operational guidance.
2. The titanium alloy bar visualization detection method based on image segmentation according to claim 1 is characterized in that: The pretreatment in step 1 is specifically as follows: Adaptive median filtering is used to remove noise, local contrast equalization is used to improve brightness uniformity, and the edge of defect features is highlighted in combination with the difference enhancement operator.
3. The titanium alloy bar visualization detection method based on image segmentation according to claim 2 is characterized in that: The adaptive median filtering removes noise, specifically as follows: The filter kernel size is adaptively adjusted according to the noise level, defining the pixel value of the original image at position (x, y) Denoising and enhancing pixel values for: ; in, : The weighting coefficient of the filter window at the i-th pixel in the horizontal direction and the j-th pixel in the vertical direction, adjusted according to the noise level; : filter window size; and Respectively represent the pixel index of the filter window in the horizontal and vertical directions, that is, the position coordinates of the pixels in the window; When denoising, first determine the filter window size based on the noise level. ; Then calculate the weight To control the influence of different pixels on the enhancement results; Through the sliding window operation, the original image is convolved pixel by pixel to obtain the enhanced image after denoising. ; The local contrast equalization is used to improve the brightness uniformity, specifically as follows: Calculate the gradient value of the homogenized image , used to extract prominent edge features in images; By adjusting the enhancement factor , amplifying the gradient response, making the defect edge more prominent in the image, and highlighting the differences in the defect area when the background is complex; The local contrast equalization is specifically as follows: ; in, : The homogenized image pixel value at position (x, y); : The local mean of the pixel at position (x, y); : local standard deviation of the pixel at position (x, y); The core of brightness uniformity is to adjust local brightness changes to avoid uneven brightness caused by reflections or shadows; by calculating the average value in each window area and standard deviation , can dynamically adjust brightness levels to improve image contrast and uniformity; The combined difference enhancement operator is used to highlight the edge of the defect feature, as follows: ; in, : The image pixel value after feature enhancement at position (x, y); : enhancement factor; : The image gradient at position (x,y).
4. The titanium alloy bar visualization detection method based on image segmentation according to claim 3 is characterized in that: Step 2 constructs an adaptive segmentation algorithm based on region growing to segment the defect region of the titanium alloy bar surface image, as follows: Automatic seed point selection: image after feature enhancement Calculate pixel intensity mutation points and define seed point sets : ; in, is the threshold, which is adaptively determined by the statistical characteristics of the image; Represents the gradient amplitude of the image at position (x, y), which measures the degree of change in pixel intensity at that position; Calculate the gradient value of the enhanced image and filter the gradient value greater than the threshold The pixel is used as the seed point; the threshold is obtained by calculating the image gradient distribution characteristics to ensure that the starting point of the representative defect area can be selected in the case of uneven brightness and noise; Region growing criteria: Region growing is based on the similarity of adjacent pixels. The growth criteria are as follows: ; in, Representing coordinates The result of determining whether the pixel belongs to the growth area. A value of 1 indicates that the pixel belongs to the growth area, and a value of 0 indicates that the pixel does not belong to the growth area. : Pixel coordinates of the grown region, i.e., the similarity judgment criterion of the new pixel (x, y) used for comparison in the region growing process relative to the pixel (x', y') of the grown region; Otherwise: In the process of region growing, if the candidate pixel (x, y) does not meet the growing conditions, the pixel will not be added to the grown region; : Similarity threshold, determined by statistical analysis; Region growing is expanded based on the similarity of pixel intensity. By comparing the intensity difference between the seed point and the adjacent pixels, it is determined whether to add the growth region. Similarity Threshold Adaptive adjustment to cope with different defect characteristics; during the growth process, the boundaries of the grown area are dynamically adjusted by gradually expanding the neighborhood to ensure complete coverage of the defect area; Regional growth stop condition: The growth stop criterion is defined as the regional change rate, and the regional change rate is as follows: ; in, : Regional change rate, indicating the relative proportion of regional changes during the growth process; : The total number of pixels or area of the current growth area; : The total number of pixels or area of the last round of growth area; : Convergence threshold, controlling the accuracy requirement for growth stop; During the growth process, the change rate of new and old areas is calculated in real time , to determine whether the growth has entered a stable state; when the rate of change is lower than the convergence threshold When , the growth process is considered to have reached convergence and stopped expanding.
5. The titanium alloy bar visualization detection method based on image segmentation according to claim 4 is characterized in that: In step 3, defect feature extraction is performed on the segmented defect area, including geometric feature extraction and texture feature extraction; The geometric feature extraction includes extracting the area, perimeter and shape factor of each defect area; calculating the area and perimeter of the defect area by counting the pixels of the defect area; The texture feature extraction includes extracting texture features using a gray level co-occurrence matrix, including energy, contrast, entropy and correlation; By constructing the gray-level co-occurrence matrix, the joint probability distribution of pixel pairs in the image block is calculated, and four features, namely energy, contrast, entropy and correlation, are extracted; After defect feature extraction, feature vector is formed , providing input data for the defect classification model.
6. The titanium alloy bar visualization detection method based on image segmentation according to claim 5 is characterized in that: The step 4 is specifically as follows: The feature vector As input, deep features are extracted through multi-layer convolution and pooling operations to effectively improve the classification effect. At the same time, the weighted cross entropy loss function is introduced to make weighted adjustments for category imbalance, thus having significant advantages in rare defect identification. The input layer of the CNN receives the feature vector , deep features are extracted through multi-layer convolution and pooling operations, the formula is as follows: ; in, is the convolution kernel weight; is the bias term; As the activation function, ReLU is used; The multi-layer convolution operation performs weighted summation and bias correction on the input features through the convolution kernel, and mines the nonlinear features through the activation function to form a deep feature representation; A weighted cross entropy loss function is used to optimize the classification accuracy of rare defect categories: ; in, : The classification loss function value, that is, the weighted cross entropy loss value used to measure the difference between the model prediction result and the true label; : Number of defect categories; : The category weight of the c-th defect is adjusted according to the category imbalance; : The true category label of the c-th defect; : The model prediction probability of the cth defect; All defect categories are cumulatively calculated to obtain the final classification loss value, and the optimization goal is to minimize the loss.
7. The titanium alloy bar visualization detection method based on image segmentation according to claim 6 is characterized in that: In step 5, the quantitative analysis includes: Construct defect severity quantification model; Determination of defect weight coefficient; Severity levels.
8. The titanium alloy bar visualization detection method based on image segmentation according to claim 7 is characterized in that: The defect severity quantification model uses defect feature weighting for comprehensive evaluation: ; in, : Comprehensive value of defect severity; : defect feature number; : Defect weight coefficient; : Defect characteristic function, for the characteristic vector Middle Quantify the features; Each defect characteristic function They all reflect the quantitative value of an independent feature; Weight coefficient Calculated by AHP; According to different defect categories and characteristics, the defect weight coefficient is calculated using the hierarchical analysis method : ; in, : Feature importance coefficient, which is calculated by domain expert scoring and statistical analysis, reflecting the weight of the feature in defect identification; : No. The importance coefficient of each feature; : The sum of all defect feature importance coefficients, used for weight normalization; By calculating the normalized value of each feature importance coefficient, the relative weight of the defect feature is formed; According to the comprehensive value of defect severity , set thresholds to divide into different levels: ; in, is the upper limit of the experience threshold, It is the lower limit of the empirical threshold, determined by historical data.
9. The titanium alloy bar visualization detection method based on image segmentation according to claim 8 is characterized in that: The step 7 is specifically as follows: The scale-adaptive weighted fusion method is adopted, and the particle swarm optimization algorithm is used to find the optimal weight to obtain the fusion features after weighted fusion. Based on the fusion features and the comprehensive value of defect severity, decision-making suggestions and operational guidance are given.
Citation Information
Patent Citations
Method for predicting position change of internal defect of titanium alloy forge piece in forging process
CN116359467A
Casting material scanning electron microscope image defect identification and quantification method
CN116953006A