A method for detecting surface defects of titanium rods
By improving the growth criteria of the regional growth algorithm, combining the difference between the texture matrix and the structural matrix, and combining the support vector machine model, the problem of inaccurate detection of surface defects of titanium rods is solved, and more accurate defect recognition is achieved.
Patent Information
- Application Number
- CN202510585940.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-08
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2045-05-08
AI Technical Summary
The growth criteria of the regional growth algorithm in the prior art are single, resulting in inaccurate detection of surface defects of titanium rods and the inability to reasonably divide each divided area.
The comprehensive degree of difference is used as the growth criterion, and by calculating the difference between the norms of the texture matrix and the structural matrix of pixel points, combined with the support vector machine model, the defect type of the titanium rod surface is identified.
It improves the accuracy and rationality of surface defect detection of titanium rods, and can better identify various types of defects.
Smart Images

Figure CN120107259B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and particularly to a method for detecting surface defects of titanium rods. Background Art
[0002] Due to its excellent properties such as high strength, corrosion resistance, and biocompatibility, titanium rods are widely used in key components such as aeroengine blades and medical implants. However, during the processing such as forging and rolling of titanium rods, surface defects such as cracks and scratches are likely to occur, which will significantly reduce their mechanical properties and fatigue life. For example, micron-level cracks may expand into macroscopic fractures under stress, leading to system failures. Therefore, efficient and accurate detection of surface defects of titanium rods is a necessary step to ensure product reliability.
[0003] Traditional defect detection methods mainly rely on manual visual inspection, which has disadvantages such as low efficiency and strong subjectivity. With the development of automatic detection technology based on machine vision, high-efficiency and high-accuracy defect detection can be achieved. Among them, the region growing algorithm, as a defect detection algorithm, has advantages such as simple principle and convenient implementation, and is widely used in the field of defect detection of parts. The region growing algorithm is an image segmentation technology based on the similarity between pixel points. Its main steps include: selecting some pixel points from the image as seed points; merging the neighboring pixel points with high similarity to the seed points into a growing region according to the growth criterion, where the growth criterion is the difference in gray values between pixel points; repeating the above step with the merged pixel points as new seed points until no new pixel points can be merged into the corresponding growing region, and finally obtaining multiple segmented regions. Finally, the defect conditions of each region are determined according to the characteristics such as the size, shape, and gray value of each segmented region.
[0004] However, in the prior art, the region growing algorithm has a problem of a single growth criterion, that is, only the similarity of gray values is considered. The surface of a titanium rod contains various defect types such as cracks, scratches, impurities, and dirt. Using only the similarity of gray values for the growth of the growing region makes the division of each segmented region unreasonable, thereby resulting in inaccurate detection of the surface defects of the titanium rod. Summary of the Invention
[0005] The present invention provides a method for detecting surface defects of titanium rods, aiming to solve the technical problem that the single growth criterion of the region growing algorithm in the prior art makes the division of each segmented region unreasonable, thereby resulting in inaccurate detection of the surface defects of the titanium rod.
[0006] The present invention provides a method for detecting surface defects of titanium rods, including the following steps:
[0007] Obtain a grayscale image of the titanium rod;
[0008] Segment the grayscale image using the region growing algorithm to obtain multiple segmented regions;
[0009] Among them, the growth criterion of the region growing algorithm is the comprehensive difference degree between the pixel points of the grayscale image; the comprehensive difference degree is the value after normalizing the sum of the absolute value of the difference between the norms of the texture matrices of two pixel points and the absolute value of the difference between the norms of the structure matrices; the texture matrix consists of the defect-free indices between all two preset directions within the local window centered on the corresponding pixel point; the defect-free index is inversely correlated with the absolute value of the difference between the entropies of the gray-level co-occurrence matrices of the defect-free degrees of all pixel points within the corresponding local window in two preset directions, and is positively correlated with the mean value of each defect-free degree; the defect-free degree represents the degree of no defect in the gray-level feature of the corresponding pixel point; the structure matrix consists of the frequencies of the differences between the pixel points in each partition within the corresponding local window and the central pixel point of the local window falling within each interval; the difference degree is the value after normalizing the difference between the means of the defect-free indices between two pixel points in all two preset directions; the partition is obtained by equally dividing the local window with rays radiating outward from the corresponding pixel point; the interval is obtained by equally dividing the range from 0 to 1;
[0010] Input all the segmented regions into the support vector machine and output the defect types of each segmented region.
[0011] In the above solution, by calculating the texture matrix and structure matrix of the pixel points, the comprehensive difference degree between two pixel points is obtained, which can comprehensively reflect the differences between two pixel points in gray-level feature, texture feature and structure feature, making the growth criterion of the region growing algorithm more reasonable, and further making the segmented regions more reasonable and the detection of the surface defects of the titanium rod more accurate.
[0012] Preferably, the defect-free degree is inversely correlated with the absolute value of the difference between the average gray-level value of each neighboring pixel point of the corresponding pixel point and the defect-free pixel point, and is inversely correlated with the absolute value of the difference between the gray-level value of the corresponding pixel point and the gray-level values of its neighboring pixel points.
[0013] Preferably, the defect-free degree of the pixel point is:
[0014] ;
[0015] In the formula, is the gray-level value of the th neighboring pixel point of the pixel point , is the average gray-level value of the defect-free pixel points, is the gray-level value of the pixel point , is the total number of neighboring pixel points of the pixel point , is the first preset parameter, .
[0016] In the above solution, by comparing the differences between the neighboring pixels of the corresponding pixel points and the defect-free pixel points, and comparing the differences between the corresponding pixel points and their neighboring pixel points, various types of defect regions can be comprehensively reflected, making the calculation results more accurate.
[0017] Preferably, the defect-free pixel points are the pixel points within the gray level interval with the largest frequency among the gray level values of all pixel points in the gray scale image; the gray level interval is obtained by equally dividing the gray level value range from 0 to 255.
[0018] Preferably, for the pixel point in the corresponding local window, the defect-free index between the th and the th preset directions is:
[0019] ;
[0020] In the formula, is the average value of the defect-free degrees of all pixel points in the local window corresponding to the pixel point , and are the entropies of the gray level co-occurrence matrices of all pixel points in the local window corresponding to the pixel point in the th direction and the th direction respectively, is the second preset parameter, .
[0021] In the above solution, by the average value of the defect-free degrees of all pixel points in the local window and the differences of the gray level co-occurrence matrices of all defect-free degrees in different preset directions, the differences in gray level features and texture features between pixel points can be reflected.
[0022] Preferably, the local window is a square centered on the corresponding pixel point with a side length of pixel points, where is an integer greater than or equal to 1.
[0023] Preferably, the number of partitions is 8 and the number of intervals is 10.
[0024] In the above solution, by dividing into multiple partitions and multiple intervals, the distribution of the difference degrees between the pixel points at different positions in the corresponding local window and the central pixel point can be characterized.
[0025] Preferably, the preset directions are four directions corresponding to the rays that rotate counterclockwise by 0°, 45°, 90°, and 135° in turn with the ray horizontally to the right with the corresponding pixel point in the gray scale image as the endpoint.
[0026] Preferably, the inputting all the segmented regions into the support vector machine includes:
[0027] Obtaining the parameters of all the segmented regions, where the parameters include the length and width of the minimum circumscribed rectangle corresponding to the segmented region and the average value of the gray values of all the pixel points within the corresponding segmented region;
[0028] Inputting the parameters of each segmented region into the trained support vector machine model.
[0029] In the above solution, according to the parameters of the segmented regions, various defect types can be identified and determined more conveniently and accurately.
[0030] Preferably, the grayscale image is obtained by collecting and graying processing using three image acquisition devices evenly distributed circumferentially along the titanium rod.
[0031] In the above solution, collecting images by three image acquisition devices is more convenient for identifying defects in the images. And graying processing the images can speed up the processing speed, reduce the calculation amount, and highlight the structure and texture characteristics of the images, facilitating the subsequent segmentation processing of the images.
[0032] The beneficial effects are:
[0033] The solution of the present invention improves the growth criterion of the region growing algorithm, and obtains the comprehensive difference degree between two pixel points by using the texture matrix and the structure matrix of the two pixel points, which can comprehensively reflect the differences in gray feature, texture feature and structure feature between the two pixel points. Compared with the prior art that only characterizes the growth criterion by a single feature of gray scale, it can more reasonably and accurately reflect various defect types, make the segmented regions more reasonable, and further make the detection of the surface defects of the titanium rod more accurate. Description of the Drawings
[0034] Figure 1 It is the step flow chart of the method for detecting the surface defects of the titanium rod according to the embodiment of the present invention;
[0035] Figure 2 It is the step flow chart of obtaining the texture matrix of the corresponding pixel point according to the embodiment of the present invention;
[0036] Figure 3 It is the step flow chart of obtaining the structure matrix of the corresponding pixel point according to the embodiment of the present invention. Detailed Embodiments
[0037] The embodiments described below with reference to the drawings are exemplary and are intended to explain the present invention and should not be construed as limiting the present invention.
[0038] As Figure 1As shown in the figure, the present invention provides a method for detecting surface defects of titanium rods, which includes the following steps:
[0039] S1. Obtain the grayscale image of the titanium rod.
[0040] In this step, since the titanium rod is a cylinder, when photographing the titanium rod, only a 180° range of the cylindrical surface of the titanium rod can be photographed, and the closer to the edge of the titanium rod, the more difficult it is to clearly observe the defects from the photographed image. Therefore, the present invention collects the image of the titanium rod through three image acquisition devices evenly distributed along the circumferential direction of the titanium rod, that is, the adjacent two image acquisition devices are spaced 120°, which is more convenient for identifying the defects in the image in the subsequent steps. The image acquisition device of the present invention is a high-definition camera.
[0041] In order to simplify the image processing process, reduce the calculation amount, speed up the processing speed, and highlight the structure and texture characteristics of the image, facilitate the subsequent image segmentation processing, the collected image is grayscale processed to obtain the corresponding grayscale image.
[0042] Since the grayscale image will inevitably be affected by noise interference, the noise includes the vibration of machine equipment, electromagnetic interference generated by current, etc., so it is necessary to denoise the grayscale image. For example, the Wiener filtering denoising algorithm is used to denoise the grayscale image. Of course, other denoising algorithms can also be used. Moreover, since the surface of the titanium rod has strong reflectivity, resulting in some defects being not obvious in the grayscale image, in order to enhance the significance of the surface defects of the titanium rod and improve the defect detection efficiency and accuracy in the subsequent steps, the present invention uses the AHE adaptive contrast enhancement algorithm to enhance the denoised grayscale image.
[0043] S2. Use the region growing algorithm to segment the grayscale image to obtain multiple segmented regions.
[0044] The region growing algorithm belongs to the prior art, and its basic idea is to gather pixel points with similar properties to form a growing region. The algorithm starts from a set of seed points, and by comparing the grayscale values of these seed points with their neighboring pixel points, the neighboring pixel points with higher similarity are merged into the growing region where the seed points are located. Then, taking these newly merged pixel points as new seed points, the region growing continues until the termination condition is met. Specifically, the region growing algorithm includes the following steps:
[0045] S21. Select seed points: The selection of seed points is based on the features of the image, such as grayscale values.
[0046] S22. Determine the growth criterion: The growth criterion defines the condition for a pixel point to be merged into the growing region, usually based on the difference in grayscale values between pixel points. For example, if the difference in grayscale values between the seed point and its neighboring pixel points is less than the set threshold, then the neighboring pixel point is merged into the growing region where the seed point is located.
[0047] S23, Region growing: Starting from the seed points, merge the neighboring pixel points that meet the conditions into the growing region according to the growing criterion, and update the seed points. Repeat this step.
[0048] S24, Termination condition: The growth process of the growing region needs to have a termination condition, which can be that the growing region reaches a certain size, there are no pixel points that meet the conditions to be merged, or the preset number of iterations is reached, etc. After the growing region stops growing, the respective segmented regions are obtained accordingly.
[0049] After obtaining the respective segmented regions of the grayscale image using the region growing algorithm, then determine the defect types of the respective segmented regions according to the characteristics of the respective segmented regions.
[0050] However, in step S22 of the prior art, there is a problem of a single growing criterion in the region growing algorithm, that is, only by calculating the difference in grayscale values to control the region growing process, without considering various defect types on the surface of the titanium rod. Specifically, the surface of the titanium rod contains various defect types such as cracks, scratches, impurities, dirt, etc. Using only the single feature of grayscale value cannot reasonably reflect various defect types on the surface of the titanium rod, making the division of the respective segmented regions unreasonable, and further resulting in inaccurate detection of the defects on the surface of the titanium rod.
[0051] Aiming at the problem of a single growing criterion in the prior art, the growing criterion of the region growing algorithm of the present invention is the comprehensive difference degree between pixel points of the grayscale image. The comprehensive difference degree characterizes the comprehensive difference degree of pixel points in terms of grayscale value, texture, and structure, and can accurately reflect the true situation of pixel points of various defect types, making the division of the respective segmented regions more reasonable, and further making the detection of the defects on the surface of the titanium rod more accurate.
[0052] Therefore, the present invention improves step S22 in the prior art. The key lies in obtaining the comprehensive difference degree between pixel points of the grayscale image. The comprehensive difference degree is the value after normalization of the sum of the absolute value of the difference between the norms of the texture matrices of two pixel points and the absolute value of the difference between the norms of the structure matrices. Therefore, the obtaining of the comprehensive difference degree includes the following steps:
[0053] S221, Obtain the texture matrix of each pixel point in the grayscale image.
[0054] The texture matrix is composed of the defect-free indices between all two preset directions within the local window centered on the corresponding pixel point. In the present invention, the local window is a square centered on the corresponding pixel point and with a side length of pixel points in length, where is an integer greater than or equal to 1. The defect-free index is inversely correlated with the absolute value of the difference in entropy between the gray-level co-occurrence matrices in two preset directions of the defect-free degrees of all pixel points in the corresponding local window, and is positively correlated with the mean value of each defect-free degree. This is because the defect-free index characterizes the degree of defect-freeness of the corresponding pixel point in terms of gray-level features and texture features. The defect-free degree characterizes the degree of defect-freeness of the corresponding pixel point in terms of gray-level features, and the defect-free degree is calculated through the gray-level value, which is applicable to planar defects, such as dirt and impurity defects, because there are large differences in the gray-level values between the inside and outside of the defect area. Therefore, the defect-free degree can characterize the degree of no planar defects. For linear defects, such as cracks and scratches, which are single-directional defects, there are large differences in the entropy of the gray-level co-occurrence matrices in two preset directions of the defect-free degrees of all pixel points in the corresponding local window. Therefore, the linear defects can be characterized by comparing the magnitudes of the entropy of the gray-level co-occurrence matrices in two preset directions. The defect-free index can comprehensively reflect the degree of defect-freeness of the corresponding pixel point in terms of gray-level features and texture features. Therefore, as Figure 2 shown, step S221 further includes the following steps:
[0055] S2211. Obtain the defect-free degrees of all pixel points in the local window corresponding to each pixel point.
[0056] The defect-free degree is inversely correlated with the absolute value of the difference between the average gray-level value of each neighboring pixel point and the defect-free pixel point corresponding to the pixel point, and is inversely correlated with the absolute value of the difference between the gray-level value of the pixel point and its neighboring pixel points. This is because for defect types such as cracks, impurities, and dirt, the defect area is relatively obvious, and there will be large differences in the gray-level values between the corresponding pixel point and the defect-free pixel point. The greater the difference, the smaller the possibility that the pixel point is located in the defect-free area, that is, the smaller the defect-free degree of the pixel point. For the defect area of the scratch type, the defect area is relatively not obvious, and the difference in the gray-level values between the corresponding pixel point and the defect-free pixel point is relatively not obvious. However, because the scratch defect has slight texture along a certain direction, it can be judged by the difference between the gray-level values of the corresponding pixel point and its neighboring pixel points. The greater the difference, the smaller the possibility that the pixel point is located in the defect-free area, that is, the smaller the defect-free degree of the pixel point. In step S2211, the neighboring pixel points are the eight neighboring pixel points of the corresponding pixel point, and of course, they can also be the four neighboring pixel points.
[0057] In the present invention, a defect-free pixel is a pixel whose gray value among all pixels in a gray-scale image lies within the gray-scale interval with the largest frequency. And the lengths of all gray-scale intervals are equal. Since the range of gray values is from 0 to 255, the gray-scale intervals are obtained by equally dividing the gray-value range from 0 to 255. For example, if the gray-value range is divided into 16 gray-scale intervals, the length of each gray-scale interval is 16. Taking each gray-scale interval as each bin of a histogram and the frequency of pixels corresponding to each bin as the height of the corresponding bin, the pixels within the highest bin are taken as defect-free pixels. This is because the proportion of the defective part in the gray-scale image of the titanium rod is small, and the vast majority of pixels are defect-free pixels. Therefore, the pixels within the bin with the highest frequency can be used as defect-free pixels. Of course, the defect-free pixels can also be pixels with a preset gray value.
[0058] In one embodiment, the defect-free degree of a pixel is:
[0059] ;
[0060] In the formula, is the gray value of the th neighboring pixel of the pixel is the average gray value of defect-free pixels, is the gray value of the pixel is the total number of neighboring pixels of the pixel is the first preset parameter, ; is the first preset parameter, .
[0061] In the formula of this embodiment, the purpose of setting the first preset parameter is to prevent the denominator of the fraction from being 0 so that the formula cannot be calculated.
[0062] This is a calculation method for the defect-free degree of a single pixel in this embodiment. The calculation method for the defect-free degree of all pixels within the corresponding local window is the same and will not be elaborated here.
[0063] In step S2211, by comparing the differences between each neighboring pixel of the corresponding pixel and the defect-free pixels, the defective areas of crack, impurity, and dirt types can be reflected. By comparing the differences between the corresponding pixel and its neighboring pixels, the defective areas of scratch type can be reflected. Furthermore, various types of defective areas can be comprehensively reflected, making the calculation result more accurate.
[0064] S2212. Obtain the defect-free index between two preset directions within the local window corresponding to each pixel.
[0065] In one embodiment, the non - defect index between two preset directions of a pixel is described. Then, for the pixel in the corresponding local window, the non - defect index between the th and the th preset directions is:
[0066] ;
[0067] In the formula, is the average of the non - defect degrees of all pixels in the local window corresponding to the pixel , and are the entropies of the gray - level co - occurrence matrices of all pixels in the local window corresponding to the pixel in the th direction and the th direction respectively, is the second preset parameter, .
[0068] In the formula of this embodiment, the purpose of setting the second preset parameter is to prevent the denominator of the fraction from being 0 so that the formula cannot be calculated.
[0069] This embodiment is a calculation method for the non - defect index between two preset directions of a pixel in its corresponding local window. The calculation methods for the non - defect indices between all two preset directions of all pixels are the same and will not be elaborated here.
[0070] Among them, the gray - level co - occurrence matrix belongs to the prior art and is a statistical method for image texture analysis. In the present invention, the gray - level co - occurrence matrix is obtained based on the non - defect degrees of each pixel in the corresponding local window. Different gray - level co - occurrence matrices correspond to different preset directions in the local window centered on the corresponding pixel. In the present invention, the preset directions are four directions corresponding to the rays starting from the corresponding pixel in the grayscale image and rotating counter - clockwise by 0°, 45°, 90°, and 135° in sequence horizontally to the right. That is, one gray - level co - occurrence matrix can be obtained for each preset direction. Each element in the gray - level co - occurrence matrix represents the frequency of occurrence of the non - defect degrees corresponding to two pixels in the local window in the preset direction. The gray - level co - occurrence matrix in each preset direction characterizes the distribution of texture features in that preset direction. Therefore, by comparing the entropies of the gray - level co - occurrence matrices in different preset directions, the non - defect index between any two preset directions can be obtained. The entropy of the gray - level co - occurrence matrix measures the randomness of the types of pixels included in the grayscale image and represents the complexity of the grayscale image. The calculation of entropy is the prior art and will not be elaborated here.
[0071] S2213. Obtain the texture matrix of each pixel.
[0072] Therefore, for the pixel The texture matrix is as follows:
[0073] ;
[0074] In the formula, is the pixel point corresponding to the th and the th defect-free indices between any two preset directions within the corresponding local window. For example, is the defect-free index between the 1st and the 2nd preset directions within the local window corresponding to the pixel point , that is, the defect-free index between the two preset directions of 0° and 45°.
[0075] In step S221, by using the defect-free indices between any two preset directions within the local window centered on the corresponding pixel point to characterize the texture matrix, the distribution of the difference degrees of the gray level features and texture features of this pixel point in different preset directions can be comprehensively considered.
[0076] S222. Obtain the structure matrix of each pixel point.
[0077] The structure matrix consists of the frequencies of the difference degrees between the pixel points in each partition within the corresponding local window and the central pixel point of the local window falling within each interval. Therefore, as Figure 3 shown, step S222 further includes the following steps:
[0078] S2221. Calculate the difference degree between the pixel points in each partition and the central pixel point of the local window.
[0079] The difference degree is the value obtained by normalizing the difference between the means of the defect-free indices between all two preset directions of two pixel points. The partitions are obtained by equally dividing the local window with rays radiating outward from the corresponding pixel point as the center. The intervals are obtained by equally dividing the range from 0 to 1.
[0080] In one embodiment, the difference degree between the pixel point in the partition and the central pixel point of the local window
[0081] is as follows:
[0082] In the formula, is the absolute value of the difference between the means of the defect-free indices between all two preset directions of the pixel point and the pixel point , is the maximum value of the absolute values of the differences between the means of the defect-free indices between all two preset directions of each pixel point in the partition and the central pixel point of the local window.
[0083] In the present invention, there are 8 partitions. For example, the included angle between adjacent rays is 45°, that is, the corresponding local window is equally divided into eight parts, and the direction of the ray emitted to the right with the corresponding pixel point as the endpoint is the 0° direction, and the counterclockwise rotation is the positive direction. Then the first partition is the area between the 0° direction and the 45° direction, the second partition is the area between the 45° direction and the 90° direction, and the remaining partitions are similar and will not be elaborated.
[0084] The interval is set to 10. The range from 0 to 1 is equally divided into 10 intervals, and the length of each interval is 0.1. Then the first interval is [0, 0.1], the second interval is (0.1, 0.2], the third interval is (0.2, 0.3], and the remaining partitions are similar and will not be elaborated.
[0085] S2222. Statistically count the frequency of the difference degree between the pixel points in each partition within the corresponding local window and the central pixel point of the local window falling within each interval.
[0086] S2223. Obtain the structure matrix of each pixel point.
[0087] Therefore, the structure matrix of the pixel point is:
[0088] ;
[0089] In the formula, is the frequency of the difference degree between each pixel point in the th partition within the corresponding local window of the pixel point and the pixel point falling within the th interval. For example, is the frequency of the difference degree between each pixel point in the second partition within the corresponding local window of the pixel point and the pixel point falling within the third interval, where the second partition is the area between the 45° direction and the 90° direction, and the third interval is the interval (0.2, 0.3].
[0090] In step S222, the structure matrix is characterized by the difference degree between the pixel points in each interval of each partition within the local window corresponding to the pixel point, reflecting the structural characteristics of each pixel point within the local window centered on the corresponding pixel point.
[0091] S223. Obtain the comprehensive difference degree between the corresponding two pixel points.
[0092] Therefore, the comprehensive difference degree between the pixel point and the pixel point is:
[0093] ;
[0094] In the formula, is the pixel point of the texture matrix of the norm, is the pixel point of the texture matrix of the norm, is the pixel point of the structure matrix of the norm, is the pixel point of the structure matrix of the norm, is the standard normalization function.
[0095] Among them, the norm of the matrix is used to measure the overall size of the matrix, which is the square root of the sum of the squares of the elements in the matrix.
[0096] In step S223, by calculating the differences between the texture matrices and the structure matrices of two pixel points, the comprehensive difference degree between the two pixel points is obtained, which can comprehensively reflect the difference degree between the two pixel points from the gray-scale feature, texture feature and structure feature, thereby making the calculation result more accurate.
[0097] The comprehensive difference degree between the two pixel points obtained according to steps S221 to S223 is used as the growth criterion of the region growing algorithm of the present invention. Specifically, calculate the comprehensive difference degree between the pixel point serving as the seed point and its neighboring pixel points. If the comprehensive difference degree is greater than the determination threshold, it indicates that the two pixel points have large differences in gray-scale feature, texture feature and structure feature, and the neighboring pixel points cannot be segmented into the growth region where the seed point is located. If the comprehensive difference degree is less than or equal to the determination threshold, it indicates that the two pixel points have small differences in gray-scale feature, texture feature and structure feature, and the neighboring pixel points should be segmented into the growth region where the seed point is located, and the neighboring pixel point is used as a new seed point to continue growing according to this growth criterion until the termination condition is reached. Among them, the determination threshold in this embodiment is 0.7, and it can also be selected according to the actual situation.
[0098] S3. Input all the segmented regions into a support vector machine, and output the defect types of each segmented region.
[0099] Specifically, step S3 includes the following steps:
[0100] S31. Obtain the parameters of each segmented region, and the parameters include the length and width of the minimum circumscribed rectangle corresponding to the segmented region and the mean value of the gray-scale values of all pixel points within the corresponding segmented region.
[0101] In this step, the length and width of the minimum bounding rectangle of the corresponding segmented region are obtained because the shapes and sizes of different defect type regions are different, and the aspect ratios of the minimum bounding rectangles of the segmented regions corresponding to crack and scratch defects are relatively large, while the aspect ratios of the minimum bounding rectangles of the segmented regions corresponding to impurity and dirt defects are relatively small. Therefore, it is easier to identify and determine the types of various defects. Moreover, the gray values of the pixel points within the segmented regions corresponding to different defect types vary greatly. Based on these parameters of the segmented regions, it is more convenient and accurate to identify and determine the types of various defects.
[0102] S32. Input the parameters of each segmented region into the trained support vector machine model.
[0103] Among them, the trained support vector machine model is obtained by inputting the gray images of different defect types of titanium rods into the support vector machine model for training. Training the support vector machine model and corresponding output of the defect types of each segmented region both belong to the prior art and will not be elaborated here.
[0104] In the present invention, three gray images of titanium rods are obtained at the same acquisition moment. Steps S1 to S3 are described only by taking one gray image as an example. In actual calculation, the three gray images at the same acquisition moment are processed simultaneously, and then the output results of the three gray images are synthesized as the result of the corresponding acquisition moment of the titanium rod.
[0105] In the method for detecting surface defects of the titanium rod of the present invention, first, the defect-free degree of the pixel points is calculated to obtain the corresponding defect-free index, then the corresponding texture matrix and structure matrix are obtained, and finally, the comprehensive difference degree between two pixel points is obtained by using the texture matrix and structure matrix of the two pixel points and used as the growth criterion for segmenting the gray image. Since the comprehensive difference degree can comprehensively characterize the difference degree between two pixel points from multiple aspects such as gray features, texture features, and structure features, compared with the prior art where only the single feature of gray is used to characterize the difference degree, the division of the segmented region is more reasonable, and thus the detection of surface defects of the titanium rod is more accurate.
[0106] Although this specification has shown and described multiple embodiments of the present invention, it is obvious to those skilled in the art that such embodiments are provided only by way of example. Those skilled in the art will think of many changes, alterations, and alternative ways without departing from the spirit and concept of the present invention. It should be understood that various alternative solutions to the embodiments of the present invention described herein can be adopted in the practice of the present invention.
Claims
1. A method for detecting surface defects of a titanium rod, characterized in that, It includes the following steps: Obtain the grayscale image of the titanium rod; Use the region growing algorithm to segment the grayscale image to obtain multiple segmented regions; Among them, the growth criterion of the region growing algorithm is the comprehensive difference degree between the pixel points of the grayscale image; the comprehensive difference degree is the value after normalization of the sum of the absolute value of the difference between the norms of the texture matrices of two pixel points and the absolute value of the difference between the norms of the structure matrices; the texture matrix is composed of the defect-free indices between all two preset directions within the local window centered on the corresponding pixel point; the defect-free index is inversely correlated with the absolute value of the difference between the entropies of the gray-level co-occurrence matrices of the defect-free degrees of all pixel points within the corresponding local window in two preset directions, and is positively correlated with the mean value of each defect-free degree; the defect-free degree characterizes the degree of defect-free of the corresponding pixel point in the gray-level feature; the structure matrix is composed of the frequencies of the differences between the pixel points in each partition within the corresponding local window and the central pixel point of the local window falling within each interval; the difference degree is the value after normalization of the difference between the means of the defect-free indices between all two preset directions of two pixel points; the partition is obtained by equally dividing the local window by the rays radiating outward from the corresponding pixel point; the interval is obtained by equally dividing the range from 0 to 1; Pixel Degree of integrity is as follows: , is the gray value of the th neighboring pixel of the pixel, is the average gray value of the defect-free pixels, is the gray value of the pixel , is the total number of neighboring pixels of the pixel , is the first preset parameter, ; Input all the segmented regions into the support vector machine and output the defect types of each segmented region.
2. The titanium rod surface defect detection method according to claim 1, characterized in that, The defect-free degree is inversely correlated with the absolute value of the difference between the average gray-level value of each neighboring pixel point of the corresponding pixel point and the defect-free pixel point, and is inversely correlated with the absolute value of the difference between the gray-level value of the corresponding pixel point and the gray-level values of its neighboring pixel points.
3. The titanium rod surface defect detection method according to claim 2, characterized in that, The defect-free pixel points are the pixel points within the gray-level interval with the largest frequency among the gray-level intervals where the gray-level values of all pixel points in the grayscale image are located; The gray-level interval is obtained by equally dividing the gray-level value range from 0 to 255.
4. The titanium rod surface defect detection method according to claim 1, characterized in that, Pixel point In the corresponding local window, the th missing index between the preset directions and the is: ; Wherein, is the average of the integrity degrees of all pixel points within the local window corresponding to the pixel point , and are the entropies of the gray-level co-occurrence matrices of the integrity degrees of all pixel points within the local window corresponding to the pixel point in the th direction and the th direction respectively, is the second preset parameter .
5. The titanium rod surface defect detection method according to claim 1, characterized in that, The local window is a square centered on the corresponding pixel point and with a side length of pixel points, where is an integer greater than or equal to 1.
6. The titanium rod surface defect detection method according to claim 1, characterized in that, There are 8 partitions and 10 intervals.
7. The titanium rod surface defect detection method according to claim 1, characterized in that The preset directions are the four directions corresponding to the rays rotating counterclockwise by 0°, 45°, 90° and 135° in turn with the ray horizontally to the right with the corresponding pixel point in the grayscale image as the endpoint.
8. The titanium rod surface defect detection method according to claim 1, characterized in that, The step of inputting all the segmented regions into the support vector machine includes: Obtain the parameters of all the segmented regions, and the parameters include the length and width of the minimum circumscribed rectangle of the corresponding segmented region and the mean value of the gray-level values of all pixel points within the corresponding segmented region; Input the parameters of each segmented region into the trained support vector machine model.
9. The titanium rod surface defect detection method according to claim 1, characterized in that, The grayscale image is obtained by collecting and gray-level processing by three image acquisition devices evenly distributed along the circumferential direction of the titanium rod.
Citation Information
Patent Citations
Industrial product defect detection method and device
CN115272340A
Metal bar defect detection method and system based on image recognition
CN117876364A