Titanium alloy bar identification method and system based on image analysis

By fusing gray-level co-occurrence matrix and color moment features, combined with Euclidean distance classification, the problems of high misjudgment rate and insufficient recognition accuracy in titanium alloy bar identification are solved, and efficient and accurate automatic identification of titanium alloy bars is achieved.

CN121033817BActive Publication Date: 2026-06-09BAOJI XINBAOTAI METAL MATERIAL PROCESSING CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BAOJI XINBAOTAI METAL MATERIAL PROCESSING CO LTD
Filing Date
2025-10-24
Publication Date
2026-06-09

Smart Images

  • Figure CN121033817B_ABST
    Figure CN121033817B_ABST
Patent Text Reader

Abstract

The application discloses a kind of titanium alloy bar identification method and system based on image analysis, and the application relates to image recognition technical field.The steps include image acquisition, feature extraction, feature fusion, classification and identification, and high-precision identification is realized by fusing texture features and color features.Gray level co-occurrence matrix is used to extract texture features, and color statistics information is obtained by combining color moments, effectively depicting the differences on the surface of the material.Feature normalization eliminates the influence of dimension, balances the weight of each feature in classification, and improves the stability and robustness of the model.In the image preprocessing stage, median filtering and grayscale are introduced to remove noise interference and reduce data dimension, improving computational efficiency and analysis reliability.The average Euclidean distance is used to judge similarity during classification, reducing single sample error and improving result consistency.The overall method has high recognition accuracy, strong anti-interference ability and fast operation speed, and is suitable for the automatic and real-time detection of titanium alloy bars in industrial production lines.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image recognition technology, specifically to a method and system for identifying titanium alloy bars based on image analysis. Background Technology

[0002] Titanium alloys, as high-strength, corrosion-resistant, and lightweight high-performance metallic materials, are widely used in key fields such as aerospace, medical devices, and high-end equipment manufacturing. However, in actual production processes, titanium alloy bars often need to be processed or stored together with other metal bars such as stainless steel. Due to the high similarity in surface texture and color of some metal bars, traditional identification methods are difficult to achieve efficient and accurate differentiation.

[0003] Currently, the identification of metal bars mainly relies on manual visual inspection or simple physical property testing. Manual identification is not only inefficient, but also subject to subjective factors such as operator experience and fatigue, resulting in a high error rate. While physical property testing methods such as density measurement and hardness testing can differentiate materials, they require contact testing of the bars, which is complex and may damage the material surface, making them unsuitable for the rapid testing needs of production lines.

[0004] With the development of machine vision technology, image analysis-based methods for metal material recognition have gradually attracted attention. In existing technologies, some solutions identify metals by extracting single features (such as texture or color) from their surfaces. However, because the surface feature differences between titanium alloys and some stainless steels are subtle under specific lighting conditions, the distinguishing power of a single feature is limited, easily leading to misidentification. Other solutions employ multi-feature fusion strategies, but these have shortcomings in feature selection and fusion methods, failing to effectively capture the essential differences between different metal materials, and their recognition accuracy is insufficient to meet the high standards required for industrial production.

[0005] Therefore, for metal rods with similar surface features, developing a titanium alloy rod identification method that can accurately extract and fuse effective features and significantly improve the identification and differentiation is of great practical significance and application value for improving the level of production automation and reducing quality control costs. Summary of the Invention

[0006] (a) Technical problems to be solved

[0007] To address the shortcomings of existing technologies, this invention provides a method and system for identifying titanium alloy bars based on image analysis, which solves the problems mentioned in the background section.

[0008] (II) Technical Solution

[0009] To achieve the above objectives, the present invention provides the following technical solution: a method for identifying titanium alloy bars based on image analysis, comprising the following steps:

[0010] Step 1: Image Acquisition

[0011] An industrial camera is used to acquire images of several titanium alloy bars and several other metal bars, and the acquired images are used as image samples. The acquired image samples are two-dimensional digital images, denoted as W(x,y), where x and y are the pixel coordinates of the image in the horizontal and vertical directions, respectively, and W(x,y) represents the gray value of the pixel at coordinates (x,y), with the gray value ranging from 0 to 255.

[0012] Step 2, Feature Extraction:

[0013] For image samples corresponding to titanium alloy bars or other metal bars, a gray-level co-occurrence matrix (GLCM) is used to extract texture features. The GLCM describes the probability that a pixel with gray value i and a pixel with gray value j at a distance d and direction θ in the image sample will appear simultaneously. The GLCM is denoted as P. Texture features include energy, contrast, and correlation. At the same time, color moment features of the image sample are extracted. The color moments include the first moment (mean), the second moment (variance), and the third moment (skewness).

[0014] Step 3: Feature Fusion

[0015] For image samples corresponding to titanium alloy bars or other metal bars, the texture features and color features extracted from the image samples are fused into a comprehensive feature vector, and then each feature in the comprehensive feature vector F is normalized.

[0016] Step 4: Classification and Recognition

[0017] Based on the calculation method of comprehensive feature vector of image samples, the comprehensive feature vector of the bar image to be identified is extracted; at the same time, the comprehensive feature vector sets corresponding to all image samples of titanium alloy bar and other metal bars are extracted respectively; then the Euclidean distance between the vector to be identified and the two types of sample vectors is calculated, and the average distance between the vector to be identified and the two types of sample vectors is calculated respectively. Finally, by comparing the two average distances, it is determined whether the bar to be identified is a titanium alloy bar or other metal bar.

[0018] The preferred method for calculating texture features corresponding to energy, contrast, and correlation is as follows:

[0019] First, determine the number of gray levels k, and divide the gray value range [0,255] of the image sample into k intervals; for the image sample W(x,y), calculate the gray co-occurrence matrix P at distance d and direction θ, and label the element values ​​as P(i,j,d,θ), which represents the probability that a pixel with gray value i and a pixel with gray value j at distance d and direction θ appear simultaneously in the image, where i and j are the gray level indices after division, where i and j are both equal to 1, 2, ..., k, and i is not equal to j;

[0020] By summing the squares of each element value P(i,j,d,θ) in the gray-level co-occurrence matrix and then summing all the results, the energy in the texture feature is obtained and labeled as E.

[0021] The formula is:

[0022] By multiplying each element value P(i,j,d,θ) in the gray-level co-occurrence matrix by the square of the corresponding gray-level difference, and then summing all the results, the contrast in the texture feature is obtained and labeled as B.

[0023] The formula is:

[0024] By multiplying each element value P(i,j,d,θ) in the gray-level co-occurrence matrix by the deviation of the corresponding gray level from its mean, dividing by the product of their respective standard deviations, and finally summing all the results, the correlation in the texture features is obtained and labeled as X.

[0025] The formula is:

[0026] In the formula, μ i and μ j Let σ be the mean value of pixels with gray values ​​i and j in the gray-level co-occurrence matrix, respectively. i 2 and σ j 2 are the variances of pixels with gray values ​​i and j in the gray-level co-occurrence matrix, respectively.

[0027] The preferred method for calculating the mean, variance, and skewness corresponding to the color moment features is as follows:

[0028] Wherein, W(x,y) is the image sample.

[0029] The mean is equal to the sum of the gray values ​​W(x,y) of all pixels in the image, divided by the total number of pixels M×N; and the mean is denoted as μ. W ;

[0030] Variance is equal to the sum of the gray values ​​of each pixel and the mean μ. WThe square of the differences is then summed, and finally divided by the total number of pixels in the image, M×N. The variance is denoted as σ. W 2 ;

[0031] Skewness is equal to the gray value of each pixel minus the mean μ. W Cube the difference, sum all the results, and finally divide by the total number of pixels in the image, M×N. The skewness is denoted as S. W ;

[0032] Where M represents the height of the image sample in pixels; N represents the width of the image sample in pixels;

[0033] mean μ W σ W 2 skewness S W The calculation formula is as follows:

[0034] .

[0035] Preferably, the comprehensive feature vector is labeled as F=[E, B, X, μ]. W σ W 2 S W ];

[0036] The normalization process is as follows:

[0037] For a given feature in the composite feature vector F, extract that feature from the composite feature vector of all image samples and obtain its maximum value F. max and minimum value F min ;

[0038] Subtracting the minimum value Fmin of this feature across all image samples from F, and then dividing by the difference between the maximum value Fmax and the minimum value Fmin, yields the normalized comprehensive feature vector F1; that is, F1 = [E1, B1, X1, μ1]. W σ1 W 2 S1 W The formula is: .

[0039] Preferably, the Euclidean distance is obtained by comparing the comprehensive feature vector of the bar image to be identified with the comprehensive feature vector set of all image samples corresponding to titanium alloy bars or other metal bars, and calculating the square root of the sum of squared feature differences between them;

[0040] The Euclidean distance formula between the comprehensive feature vector corresponding to the image of the bar to be identified and the feature vector of the sample image of the titanium alloy bar is: ;

[0041] In the formula, g is the number of features in the comprehensive feature vector, g = 1, 2, ..., 6, and F1(a) represents the normalized comprehensive feature vector of the bar image to be identified. g This represents the g-th feature in the vector, where s = 1 to 6, corresponding to E1, B1, X1, and μ1 respectively. W σ1 W 2 S1 W , that is, F1(a) g Referencing E1(a), B1(a), X1(a), μ1 W (a) σ1 W 2 (a) S1 W (a) Feature index; F1(b) r F1(b) represents the normalized comprehensive feature vector of the titanium alloy bar sample image. r ) g For its g-th feature, i.e., F1(b) r ) g Refers to E1 (b) r ), B1 (b r ), X1 (b r μ1 W (b) r ), σ1 W 2 (b) r S1 W (b) r Feature index;

[0042] The Euclidean distance formula for each feature in the comprehensive feature vector corresponding to the image of the bar to be identified and the feature vectors of the corresponding images of other metal bars is: ;

[0043] In the formula, F1(c t ) g Refers to E1 (c t ), B1 (c t ), X1 (c t μ1 W (c) t ), σ1 W 2 (c) t S1 W (c) t Feature index;

[0044] Where F1(a) = [E1(a), B1(a), X1(a), μ1 W (a) σ1 W 2(a) S1 W [(a)] is the normalized comprehensive feature vector of the bar image to be identified;

[0045] F1(b) r =[E1(b) r ), B1 (b r ), X1 (b r μ1 W (b) r ), σ1 W 2 (b) r S1 W (b) r [)] represents the set of normalized comprehensive feature vectors for all image samples corresponding to the titanium alloy bar.

[0046] F1(c t =[E1(c) t ), B1 (c t ), X1 (c t μ1 W (c) t ), σ1 W 2 (c) t S1 W (c) t [)] is the set of normalized comprehensive feature vectors for all image samples corresponding to other metal rods;

[0047] Where a represents the bar to be identified, b represents the titanium alloy bar, c represents other metal bars, r = 1, 2, ..., e, where e represents the number of all image samples corresponding to the titanium alloy bar; t = 1, 2, ..., v, where v represents the number of all image samples corresponding to other metal bars.

[0048] The average distance between the bar image to be identified and the corresponding titanium alloy bar is obtained by calculating the sum of the Euclidean distances between the sample to be identified and all corresponding image samples of the titanium alloy bar, and then dividing by the total number of titanium alloy bar samples, and is denoted as d(a, b).

[0049] The formula for the average distance between the comprehensive feature vectors corresponding to all image samples of the titanium alloy bar and the image of the bar to be identified is: ;

[0050] The average distance between the image of the bar to be identified and other metal bars is obtained by calculating the sum of the Euclidean distances between the image samples of the sample to be identified and all image samples of other metal bars, and then dividing by the total number of other metal bar samples, and is denoted as d(a,c).

[0051] The formula for the average distance between the comprehensive feature vectors of all image samples corresponding to other metal bars and the image of the bar to be identified is: ;

[0052] If d(a, b) < d(a, c), then the bar to be identified is determined to be a titanium alloy bar; otherwise, it is determined to be another metal bar.

[0053] Preferably, the "other metal rods" refer to the same type of metal rod material; the two-dimensional digital image is a planar image composed of pixels, which is stored in digital form.

[0054] Preferably, in the image acquisition step:

[0055] When the acquired image is a color image W C (x, y), and then perform grayscale processing:

[0056] Color image W C (x,y) is formed by red R C Green G C Blue B C It consists of three channels, which are then used to pass through:

[0057] Multiply the red channel RC(x,y) by 0.299, add the green channel GC(x,y) multiplied by 0.587, and add the blue channel BC(x,y) multiplied by 0.114 to obtain the grayscale image W. H (x,y);

[0058] The formula is:

[0059] Among them, 0.299, 0.587, and 0.114 are weighting coefficients determined based on the human eye's perception of red, green, and blue colors; R C (x,y),G C (x,y),B C The (x,y) coordinates represent the red, green, and blue channel values ​​corresponding to the pixel at coordinates (x,y).

[0060] Preferably, in the image acquisition step, median filtering is also used to remove noise during the image acquisition process;

[0061] The window size for median filtering is set to n×n, where n is an odd number.

[0062] For each pixel at coordinates (x, y) in the image, take all pixel grayscale values ​​within an n×n window centered on the corresponding pixel, arrange all grayscale values ​​in ascending order, and then take the grayscale value at the middle position as the filtered grayscale value W of that pixel. L (x,y).

[0063] A titanium alloy bar identification system based on image analysis, the system being used to execute a titanium alloy bar identification method based on image analysis, the system comprising:

[0064] Image acquisition module, used to acquire two-dimensional digital images of titanium alloy bars and other metal bars through an industrial camera;

[0065] The image preprocessing module is used to convert the acquired color image to grayscale and remove noise using median filtering.

[0066] The feature extraction module is used to extract energy, contrast, and correlation from texture features based on the gray-level co-occurrence matrix, and to calculate the color features corresponding to mean, variance, and skewness through color moments;

[0067] The feature fusion and normalization module is used to combine texture features and color features into a comprehensive feature vector and to normalize each feature.

[0068] The classification and identification module is used to calculate the average Euclidean distance between the bar to be identified and the corresponding samples of known titanium alloy bars and other metal bars, and to determine the material category by comparing the distance.

[0069] This invention provides a method and system for identifying titanium alloy bars based on image analysis. Compared with existing technologies, it has the following advantages:

[0070] This invention effectively improves the accuracy of distinguishing titanium alloy bars from other metal bars by combining texture and color features for comprehensive identification. The grayscale co-occurrence matrix can capture the microscopic texture differences on the material surface, while the color moment can reflect the surface hue and brightness distribution characteristics. The fusion of the two makes the feature information more comprehensive, which helps to reduce the misjudgment rate of a single feature under different lighting, shooting angles, or surface oxidation levels.

[0071] This invention introduces normalization processing during feature extraction to ensure consistency in the magnitude of different features, avoiding the problem of some features having excessively large numerical ranges dominating the classification results. This processing allows the classifier to consider all features more evenly when calculating Euclidean distance, improving the stability and robustness of the recognition model and making it more practical in industrial production environments.

[0072] This invention employs median filtering to preprocess acquired images, effectively suppressing image noise, especially salt-and-pepper noise, thereby reducing the interference of noise on subsequent feature extraction and classification results. Simultaneously, grayscale processing of color images reduces data dimensionality, accelerates computation, and preserves brightness information sensitive to human vision, providing clearer and more reliable image data for subsequent analysis.

[0073] This invention determines the similarity between a sample to be identified and two types of metal rods by calculating the average Euclidean distance during the classification stage. This reduces the impact of random errors from a single sample on the final result, making the classification results more stable and reliable. Overall, this method features high accuracy, strong robustness, and low computational complexity, making it suitable for the rapid and automatic identification of titanium alloy rods in industrial production lines. Attached Figure Description

[0074] Figure 1 This is a system block diagram of a titanium alloy bar identification system based on image analysis according to the present invention.

[0075] Figure 2 This is a flowchart illustrating a titanium alloy bar identification method based on image analysis according to the present invention. Detailed Implementation

[0076] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0077] Please see Figure 1 and Figure 2 As shown, the embodiments of the present invention provide the following technical solutions:

[0078] As an embodiment of the present invention:

[0079] This invention relates to a method for identifying titanium alloy bars based on image analysis, comprising the following steps:

[0080] Step 1: Image Acquisition

[0081] Images of several titanium alloy bars and several other metal bars were acquired using an industrial camera, and the acquired images were used as image samples.

[0082] In this embodiment, "several other metal rods" refers to the same type of metal rod material. For example, "several other metal rods" refers to several stainless steel rods.

[0083] The acquired image samples are two-dimensional digital images, denoted as W(x,y), where x and y are the pixel coordinates of the image in the horizontal and vertical directions, respectively, and W(x,y) represents the gray value of the pixel at coordinate (x,y), with the gray value ranging from 0 to 255, where 0 represents black and 255 represents white.

[0084] Among them, a two-dimensional digital image is a planar image composed of pixels, which is stored in digital form;

[0085] Step 2, Feature Extraction:

[0086] Step 2.1, Texture Feature Extraction:

[0087] The gray-level co-occurrence matrix (GLCM) is used to extract texture features. The GLCM is used to describe the probability that a pixel with gray value i and a pixel with gray value j at a distance d and direction θ in an image sample will appear simultaneously.

[0088] Image samples corresponding to titanium alloy bars or other metal bars;

[0089] First, determine the number of gray levels k, and divide the gray value range [0,255] of the image samples into k intervals;

[0090] For an image sample W(x,y), calculate the gray-level co-occurrence matrix P at distance d and direction θ, and label the element values ​​as P(i,j,d,θ), representing the probability that a pixel with gray value i and a pixel with gray value j at distance d and direction θ appear simultaneously in the image, where i and j are the gray level indices after partitioning, where i and j are both equal to 1, 2, ..., k, and i is not equal to j;

[0091] Then, the following texture features are calculated based on the gray-level co-occurrence matrix:

[0092]

[0093] In the formula, E represents the energy in the texture feature;

[0094] Among them, energy reflects the uniformity of texture in image samples; the more uniform the texture, the greater the energy value.

[0095]

[0096] In the formula, B represents the contrast in the texture feature;

[0097] Contrast reflects the degree of difference in gray values ​​among image samples; the greater the difference, the greater the contrast value.

[0098]

[0099] In the formula, μ i and μ j Let σ be the mean value of pixels with gray values ​​i and j in the gray-level co-occurrence matrix, respectively. i 2 and σ j 2 , i and j are the variances of pixels with gray values ​​i and j in the gray-level co-occurrence matrix, respectively, and X is the correlation of gray values ​​in the image sample;

[0100] Among them, correlation reflects the degree of linear correlation of gray values ​​in image samples;

[0101] Step 2.2, Color Feature Extraction:

[0102] Image samples corresponding to titanium alloy bars or other metal bars;

[0103] Extract color moment features from image samples. Color moments include first moment (mean), second moment (variance), and third moment (skewness).

[0104] For image samples, W(x,y);

[0105] pass:

[0106] Calculate the first moment separately: mean μ W Second moment: variance σ W 2 And third moment: skewness S W ;

[0107] In the formula, M represents the height of the image sample in pixels, that is, the number of pixels contained in the image sample in the vertical direction; N represents the width of the image sample in pixels, that is, the number of pixels contained in the image sample in the horizontal direction.

[0108] Step 3: Feature Fusion

[0109] Image samples corresponding to titanium alloy bars or other metal bars;

[0110] The texture and color features extracted from the image samples are fused into a comprehensive feature vector F, i.e., F = [E, B, X, μ]. W σ W 2 S W ];

[0111] Then, each feature in the comprehensive feature vector F is normalized as follows:

[0112] For a given feature in the composite feature vector F, extract that feature from the composite feature vector of all image samples and obtain its maximum value F. max and minimum value F min ;

[0113] Subsequently passed:

[0114] Calculate the normalized comprehensive eigenvector F1, i.e., F1 = [E1, B1, X1, μ1]. W σ1 W 2 S1W ];

[0115] Step 4: Classification and Recognition

[0116] For the bar image to be identified, its comprehensive feature vector is extracted according to the comprehensive feature vector calculation method of image samples, and denoted as F1(a) = [E1(a), B1(a), X1(a), μ1]. W (a) σ1 W 2 (a) S1 W (a)];

[0117] Simultaneously, the set of comprehensive feature vectors corresponding to all image samples of the titanium alloy bar is labeled as F1(b). r =[E1(b) r ), B1 (b r ), X1 (b r μ1 W (b) r ), σ1 W 2 (b) r S1 W (b) r )]; The set of comprehensive feature vectors of all image samples corresponding to other metal rods is labeled as F1(c t =[E1(c) t ), B1 (c t ), X1 (c t μ1 W (c) t ), σ1 W 2 (c) t S1 W (c) t )];

[0118] Where a represents the bar to be identified, b represents the titanium alloy bar, c represents other metal bars, r = 1, 2, ..., e, where e represents the number of all image samples corresponding to the titanium alloy bar; t = 1, 2, ..., v, where v represents the number of all image samples corresponding to other metal bars.

[0119] Subsequently passed:

[0120] Select an image sample r corresponding to a titanium alloy bar;

[0121] Subsequently passed:

[0122] Calculate the Euclidean distance between the comprehensive feature vector corresponding to the image of the bar to be identified and the feature vector of each feature in the sample image of the titanium alloy bar; d(F1(a), F1(b) r));

[0123] In the formula, g is the number of features in the comprehensive feature vector, g = 1, 2, ..., 6, and F1(a) represents the normalized comprehensive feature vector of the bar image to be identified. g This represents the g-th feature in the vector, where s = 1 to 6, corresponding to E1, B1, X1, and μ1 respectively. W σ1 W 2 S1 W , that is, F1(a) g Referencing E1(a), B1(a), X1(a), μ1 W (a) σ1 W 2 (a) S1 W (a) Feature index; F1(b) r F1(b) represents the normalized comprehensive feature vector of the titanium alloy bar sample image. r ) g For its g-th feature, i.e., F1(b) r ) g Refers to E1 (b) r ), B1 (b r ), X1 (b r μ1 W (b) r ), σ1 W 2 (b) r S1 W (b) r Feature index;

[0124] Simultaneously through:

[0125] Calculate the Euclidean distance between the comprehensive feature vector corresponding to the image of the bar to be identified and the feature vectors of the corresponding image samples of other metal bars; d(F1(a), F1(c) t ));

[0126] In the formula, F1(c t ) g Refers to E1 (c t ), B1 (c t ), X1 (c t μ1 W (c) t ), σ1 W 2 (c) t S1 W (c) t Feature index;

[0127] Next, for all image samples corresponding to the titanium alloy bar, calculate the average distance between it and the comprehensive feature vector corresponding to the bar image to be identified, and denot it as d(a, b).

[0128] The formula is:

[0129]

[0130] Meanwhile, for all image samples corresponding to other metal bars, calculate the average distance between them and the comprehensive feature vector corresponding to the image of the bar to be identified, and denot it as d(a, c).

[0131] The formula is:

[0132]

[0133] If d(a, b) < d(a, c), then the bar to be identified is determined to be a titanium alloy bar; otherwise, it is determined to be another metal bar.

[0134] The image analysis-based titanium alloy bar identification method proposed in Example 1 acquires two-dimensional digital images of titanium alloy and other metal bars using an industrial camera. It fuses texture features (energy, contrast, correlation) and color moment features (mean, variance, skewness) extracted from the gray-level co-occurrence matrix to form a comprehensive feature vector. After normalization, it uses Euclidean distance to calculate the average distance between the sample to be identified and the two sample sets to achieve classification. This method, through multi-dimensional feature fusion, effectively captures the essential differences between titanium alloy and other metals in texture uniformity, gray-level differences, and color distribution. Combined with the classification logic of Euclidean distance, it ensures identification accuracy while possessing a clear principle and simple calculation process, making it suitable for identifying metal bars with significant differences in basic image features.

[0135] As a second embodiment of the present invention:

[0136] In specific implementation, compared with Embodiment 1, the technical solution of this embodiment differs from Embodiment 1 only in that: in the image acquisition step of this embodiment:

[0137] When the acquired image is a color image W C (x, y), and then perform grayscale processing:

[0138] Color image W C (x,y) is formed by red R C Green G C Blue B C It consists of three channels, which are then used to pass through:

[0139]

[0140] Calculate the grayscale image W H (x,y);

[0141] Among them, 0.299, 0.587, and 0.114 are weighting coefficients determined based on the human eye's perception of red, green, and blue colors; R C (x,y),G C (x,y),B C The (x,y) coordinates represent the red, green, and blue channel values ​​corresponding to the pixel at coordinates (x,y).

[0142] Simultaneously, median filtering is used to remove noise during the image acquisition process;

[0143] In this embodiment, the noise in the acquired image may be generated by factors such as ambient light and camera sensor.

[0144] The window size for median filtering is set to n×n; where n is an odd number, and in this embodiment, it takes the value of 3 or 5.

[0145] For each pixel at coordinates (x, y) in the image, take all pixel grayscale values ​​within an n×n window centered on the corresponding pixel, arrange all grayscale values ​​in ascending order, and then take the grayscale value at the middle position as the filtered grayscale value W of that pixel. L (x,y);

[0146] Example 2, building upon Example 1, performs grayscale processing on color images. A weighted formula converts the RGB three-channel information into grayscale values ​​that conform to human visual perception. Simultaneously, median filtering is introduced to remove noise caused by ambient light, sensor interference, and other factors. This improvement not only expands the applicability of the method to color images but also enhances image quality through noise suppression, reducing the impact of interference on subsequent feature extraction. The median filter's excellent suppression of impulse noise, combined with a suitable window size (3×3 or 5×5), optimizes feature stability while preserving image edge information, making subsequent texture and color feature extraction more accurate. This, in turn, improves the anti-interference capability and robustness of metal rod identification.

[0147] As an embodiment of the present invention:

[0148] In specific implementation, compared with Embodiment 1 and Embodiment 2, the technical solution of this embodiment is to combine the solutions of Embodiment 1 and Embodiment 2.

[0149] Example 3 combines the technical solutions of Examples 1 and 2, retaining the core logic of multi-feature fusion and Euclidean distance classification while integrating the advantages of color image grayscale processing and median filtering for noise reduction. This combined solution can handle more complex real-world application scenarios: for color images, grayscale processing converts them into a unified grayscale image format; median filtering effectively eliminates various noise interferences; and through the fusion and normalization of texture and color features, accurate classification is finally achieved. This comprehensive solution balances adaptability to different image types, noise suppression capabilities, and comprehensive feature extraction, further improving the accuracy, stability, and scenario applicability of titanium alloy bar identification, and better meeting the diverse image acquisition and recognition needs in industrial environments.

[0150] The present invention also provides an image analysis-based titanium alloy bar identification system, which is used to perform an image analysis-based titanium alloy bar identification method. The system includes:

[0151] Image acquisition module, used to acquire two-dimensional digital images of titanium alloy bars and other metal bars through an industrial camera;

[0152] The image preprocessing module is used to convert the acquired color image to grayscale and remove noise using median filtering.

[0153] The feature extraction module is used to extract energy, contrast, and correlation from texture features based on the gray-level co-occurrence matrix, and to calculate the color features corresponding to mean, variance, and skewness through color moments;

[0154] The feature fusion and normalization module is used to combine texture features and color features into a comprehensive feature vector and to normalize each feature.

[0155] The classification and identification module is used to calculate the average Euclidean distance between the bar to be identified and the corresponding samples of known titanium alloy bars and other metal bars, and to determine the material category by comparing the distance.

[0156] It should be stated that all user data collected in this application was collected with the user's consent and authorization, and the use of user data is legal and compliant, and the use and processing of user data comply with the relevant laws, regulations and standards of the relevant regions.

[0157] Furthermore, any content not described in detail in this specification is existing technology known to those skilled in the art.

[0158] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0159] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

[0160] The various embodiments of this application have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or improvement of the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.

Claims

1. A method for identifying titanium alloy bars based on image analysis, characterized in that, Includes the following steps: Step 1: Image Acquisition An industrial camera is used to acquire images of several titanium alloy bars and several other metal bars, and the acquired images are used as image samples. The acquired image samples are two-dimensional digital images, denoted as W(x,y), where x and y are the pixel coordinates of the image in the horizontal and vertical directions, respectively. Step 2, Feature Extraction: For image samples of titanium alloy bars or other metal bars, gray-level co-occurrence matrix is ​​used to extract texture features, including energy, contrast, and correlation. At the same time, color moment features of the image samples are extracted, including first moment: mean, second moment: variance, and third moment: skewness. Step 3: Feature Fusion For image samples corresponding to titanium alloy bars or other metal bars, the texture features and color features extracted from the image samples are fused into a comprehensive feature vector, and then each feature in the comprehensive feature vector F is normalized. Step 4: Classification and Recognition Based on the calculation method of comprehensive feature vector of image samples, the comprehensive feature vector of the bar image to be identified is extracted; at the same time, the comprehensive feature vector sets corresponding to all image samples of titanium alloy bar and other metal bars are extracted respectively; then the Euclidean distance between the vector to be identified and the two types of sample vectors is calculated, and the average distance between the vector to be identified and the two types of sample vectors is calculated respectively. Finally, by comparing the two average distances, it is determined whether the bar to be identified is a titanium alloy bar or other metal bar.

2. The method for identifying titanium alloy bars based on image analysis according to claim 1, characterized in that: in, The gray-level co-occurrence matrix is ​​used to describe the probability that a pixel with gray value i and a pixel with gray value j at a distance d and direction θ in an image sample will appear simultaneously. The gray-level co-occurrence matrix is ​​denoted as P, and its element values ​​are labeled as P(i,j,d,θ), where i and j are the gray level indices after partitioning. i and j are both equal to 1, 2, ..., k, and i is not equal to j. k represents the number of gray levels.

3. The method for identifying titanium alloy bars based on image analysis according to claim 2, characterized in that: The texture features corresponding to energy, contrast, and correlation are calculated as follows: By summing the squares of each element value P(i,j,d,θ) in the gray-level co-occurrence matrix and then summing all the results, the energy in the texture feature is obtained and labeled as E. By multiplying each element value P(i,j,d,θ) in the gray-level co-occurrence matrix by the square of the corresponding gray-level difference, and then summing all the results, the contrast in the texture feature is obtained and labeled as B. By multiplying each element value P(i,j,d,θ) in the gray-level co-occurrence matrix by the deviation of the corresponding gray level from its mean, dividing by the product of their respective standard deviations, and finally summing all the results, the correlation in the texture features is obtained and labeled as X.

4. The method for identifying titanium alloy bars based on image analysis according to claim 3, characterized in that: The mean, variance, and skewness are calculated as follows for the color moment characteristics: Wherein, W(x,y) is the image sample. The mean is equal to the sum of the gray values ​​W(x,y) of all pixels in the image, divided by the total number of pixels M×N; and the mean is denoted as μ. W ; Variance is equal to the sum of the gray values ​​of each pixel and the mean μ. W The square of the differences is then summed, and finally divided by the total number of pixels in the image, M×N. The variance is denoted as σ. W 2 ; Skewness is equal to the gray value of each pixel minus the mean μ. W Cube the difference, sum all the results, and finally divide by the total number of pixels in the image, M×N. The skewness is denoted as S. W ; Where M represents the height of the image sample in pixels; N represents the width of the image sample in pixels.

5. The method for identifying titanium alloy bars based on image analysis according to claim 4, characterized in that: The comprehensive feature vector is labeled as F=[E, B, X, μ]. W σ W 2 S W ]; The normalization process is as follows: For a given feature in the composite feature vector F, extract that feature from the composite feature vector of all image samples and obtain its maximum value F. max and minimum value F min ; Subtract the minimum value Fmin of the feature among all image samples from F, and then divide by the difference between the maximum value Fmax and the minimum value Fmin to obtain the normalized comprehensive feature vector F1. That is, F1 = [E1, B1, X1, μ1] W σ1 W 2 S1 W ].

6. The method for identifying titanium alloy bars based on image analysis according to claim 5, characterized in that: The Euclidean distance is calculated by comparing the comprehensive feature vector of the image of the bar to be identified with the comprehensive feature vector set of all image samples corresponding to titanium alloy bars or other metal bars, and calculating the square root of the sum of squared feature differences between them. The average distance between the bar image to be identified and the corresponding titanium alloy bar is obtained by calculating the sum of the Euclidean distances between the sample to be identified and all corresponding image samples of the titanium alloy bar, and then dividing by the total number of titanium alloy bar samples, and is denoted as d(a, b). The average distance between the image of the bar to be identified and other metal bars is obtained by calculating the sum of the Euclidean distances between the image samples of the sample to be identified and all image samples of other metal bars, and then dividing by the total number of other metal bar samples, and is denoted as d(a,c). If d(a, b) < d(a, c), then the bar to be identified is determined to be a titanium alloy bar; otherwise, it is determined to be another metal bar.

7. The method for identifying titanium alloy bars based on image analysis according to claim 1, characterized in that: in, Several other metal rods refer to the same type of metal rod material; a two-dimensional digital image is a planar image composed of pixels, which is stored in digital form.

8. The method for identifying titanium alloy bars based on image analysis according to claim 1, characterized in that: In the image acquisition step: When the acquired image is a color image W C (x, y), and then perform grayscale processing: Color image W C (x,y) is formed by red R C Green G C Blue B C It consists of three channels, which are then used to pass through: Multiply the red channel RC(x,y) by 0.299, add the green channel GC(x,y) multiplied by 0.587, and add the blue channel BC(x,y) multiplied by 0.114 to obtain the grayscale image W. H (x,y); Among them, 0.299, 0.587, and 0.114 are weighting coefficients determined based on the human eye's perception of red, green, and blue colors; R C (x,y),G C (x,y),B C The (x,y) coordinates represent the red, green, and blue channel values ​​corresponding to the pixel at coordinates (x,y).

9. The method for identifying titanium alloy bars based on image analysis according to claim 1, characterized in that: In the image acquisition step, median filtering is used to remove noise during the image acquisition process; The window size for median filtering is set to n×n, where n is an odd number. For each pixel at coordinates (x, y) in the image, take all pixel grayscale values ​​within an n×n window centered on the corresponding pixel, arrange all grayscale values ​​in ascending order, and then take the grayscale value at the middle position as the filtered grayscale value W of that pixel. L (x,y).

10. A titanium alloy bar identification system based on image analysis, the system being used to execute the titanium alloy bar identification method based on image analysis according to any one of claims 1-9, characterized in that, The system includes: Image acquisition module, used to acquire two-dimensional digital images of titanium alloy bars and other metal bars through an industrial camera; The image preprocessing module is used to convert the acquired color image to grayscale and remove noise using median filtering. The feature extraction module is used to extract energy, contrast, and correlation from texture features based on the gray-level co-occurrence matrix, and to calculate the color features corresponding to mean, variance, and skewness through color moments; The feature fusion and normalization module is used to combine texture features and color features into a comprehensive feature vector and to normalize each feature. The classification and identification module is used to calculate the average Euclidean distance between the bar to be identified and the corresponding samples of known titanium alloy bars and other metal bars, and to determine the material category by comparing the distance.