A method and system for visual inspection of titanium alloy parts quality
By analyzing the edge pixel points characteristics in the titanium alloy part image, and using the isolated forest algorithm to identify abnormal pixel points, the problem of the edge detection algorithm misidentifying texture as crack defects is solved, and the accuracy and efficiency of titanium alloy part quality detection is achieved.
Patent Information
- Application Number
- CN202411238445.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2044-09-05
AI Technical Summary
When existing edge detection algorithms detect crack defects on the surface of titanium alloy parts, they are prone to misidentify the texture as crack defects, resulting in the inability to accurately detect the quality of titanium alloy parts.
By acquiring edge pixel points in the image of titanium alloy parts, analyzing texture continuous features and gradient consistent features, using an isolated forest algorithm to build a decision tree, filter out abnormal edge pixel points, accurately identify crack defect edge lines, avoid texture interference, and ensure quality detection accuracy.
Accurate detection of crack defects on the surface of titanium alloy parts is achieved, the accuracy and efficiency of quality inspection of titanium alloy parts is improved, and the product quality meets standards.
Smart Images

Figure CN118762002B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of edge detection, and in particular to a method and system for visually detecting the quality of titanium alloy parts. Background Art
[0002] Titanium alloy parts have the characteristics of high strength, corrosion resistance and light weight, so they have been widely used in many high-tech fields. During the processing of titanium alloy parts, there may be other external factors such as excessive stress, which may lead to crack defects on the surface of the generated titanium alloy parts. After the titanium alloy parts with crack defects are used, the strength and service life of the material will be reduced, causing certain harm and losses. Therefore, it is necessary to conduct crack defect detection on the processed titanium alloy parts to ensure that the quality of titanium alloy parts entering the market meets the standards.
[0003] In the existing method, the crack defect detection on the surface of titanium alloy parts is carried out through edge detection algorithm, and then the quality of titanium alloy parts is detected. However, in actual situations, when titanium alloy parts are processed and rolled, plastic flow will occur on the surface of titanium alloy parts to form textures. When the crack defects on the surface of titanium alloy parts are detected by edge detection algorithm, the texture on the surface of titanium alloy parts is easily misidentified as crack defects, resulting in the inability to accurately detect the crack defects on the surface of titanium alloy parts, and thus the inability to accurately detect the quality of titanium alloy parts. Summary of the invention
[0004] In order to solve the technical problem that when detecting crack defects on the surface of titanium alloy parts by edge detection algorithm, the texture on the surface of titanium alloy parts is easily misidentified as crack defects, resulting in the inability to accurately detect crack defects on the surface of titanium alloy parts, and thus the inability to accurately detect the quality of titanium alloy parts, the purpose of the present invention is to provide a titanium alloy part quality visual inspection method and system, and the technical scheme adopted is as follows:
[0005] In a first aspect, an embodiment of the present invention provides a method for visually inspecting the quality of titanium alloy parts, the method comprising the following steps:
[0006] Obtain edge pixel points in the titanium alloy part image;
[0007] Select an edge pixel point as the target pixel point, and obtain the texture continuity feature of the target pixel point according to the distribution of the edge pixel points of the edge line where the target pixel point is located on the straight line corresponding to the texture direction of the target pixel point;
[0008] Obtaining a gradient consistency feature of a target pixel point according to the difference in gradient amplitude in a vertical texture direction between the target pixel point and each of its preset neighborhood edge pixels;
[0009] According to the texture continuity feature and gradient consistency feature of each edge pixel in each node in the isolation forest algorithm, the split feature of each node is determined, and then the decision tree is obtained;
[0010] The evaluation depth of the target pixel is obtained according to the depth of each leaf node where the target pixel is located in the corresponding decision tree and the difference in the number of edge pixels between each leaf node where the target pixel is located and its sibling nodes;
[0011] Based on the evaluation depth, abnormal edge pixels are screened out to determine the crack defect edge line in the titanium alloy part image, and the quality of the titanium alloy part is detected.
[0012] Furthermore, the method for acquiring the texture continuity feature is:
[0013] The straight line corresponding to the texture direction of the target pixel point is used as the target straight line;
[0014] The number of edge pixel points of the edge line where the target pixel point is located on the target straight line is taken as the first number;
[0015] The ratio of the first number to the total number of edge pixels on the edge line where the target pixel is located is used as the texture continuity feature value of the target pixel.
[0016] Furthermore, the method for obtaining the gradient consistency feature is:
[0017] Obtaining the difference in the gradient amplitude in the vertical texture direction between the target pixel and each of its preset neighborhood edge pixels, each as a first difference;
[0018] The result of negatively correlating and normalizing the mean of the first difference is used as the gradient consistency feature of the target pixel.
[0019] Furthermore, the method for obtaining the split feature is:
[0020] For any node, the texture continuous eigenvalues and gradient consistent eigenvalues of all edge pixels in the node are constructed as a set respectively;
[0021] For any element in any set, use the element as the threshold to divide the set into two categories and obtain the inter-class variance of the element;
[0022] Get the number of elements in the two categories corresponding to the maximum between-class variance of each set, and use them as the reference number of the corresponding set;
[0023] According to the maximum inter-class variance of each set and the ratio of the minimum reference number to the maximum reference number, the credibility of the feature corresponding to each set is obtained; among which, the maximum inter-class variance is positively correlated with the credibility, and the ratio of the minimum reference number to the maximum reference number is negatively correlated with the credibility;
[0024] The features corresponding to the set with the highest credibility are used as the split features of the node; wherein the features corresponding to the set are texture continuous feature values and gradient consistent feature values.
[0025] Furthermore, the method for obtaining the evaluation depth is:
[0026] The decision trees where the target pixel point is located are all taken as the target decision trees, and the reasonable weight of the target pixel point in each target decision tree is obtained according to the difference in the number of edge pixels between the leaf node where the target pixel point is located and its sibling node in each target decision tree; wherein the difference in the number of edge pixels is positively correlated with the reasonable weight;
[0027] The product of the reasonable weight of the target pixel in each target decision tree and the depth of the leaf node where the target pixel is located in each target decision tree is used as the corrected depth of the target pixel in each target decision tree;
[0028] The average of all the corrected depths is used as the evaluation depth of the target pixel.
[0029] Furthermore, the method for obtaining the crack defect edge line is:
[0030] When the evaluation depth is less than or equal to the preset evaluation depth threshold, the corresponding edge pixel is an abnormal edge pixel;
[0031] The ratio of the number of abnormal edge pixels on each edge line to the number of all edge pixels on the corresponding edge line is used as the abnormality judgment value of each edge line;
[0032] When the abnormality judgment value is greater than a preset abnormality judgment value threshold, the corresponding edge line is a crack defect edge line.
[0033] Furthermore, the method for detecting the quality of titanium alloy parts is:
[0034] Obtain the number of crack defect edge lines in the titanium alloy part image as a quality assessment quantity;
[0035] When the quality assessment quantity is less than or equal to the preset first quality assessment quantity threshold, the quality of the titanium alloy part is good;
[0036] When the quality assessment quantity is greater than a preset first quality assessment quantity threshold and less than or equal to a preset second quality assessment quantity threshold, the quality of the titanium alloy part is qualified;
[0037] When the quality assessment quantity is greater than a preset second quality assessment quantity threshold, the quality of the titanium alloy part is unqualified.
[0038] Furthermore, the texture direction is the processing and rolling direction of the titanium alloy part.
[0039] Furthermore, the method for obtaining the edge pixels is:
[0040] The Canny edge detection algorithm is used to obtain edge pixel points in the titanium alloy part image.
[0041] In a second aspect, another embodiment of the present invention provides a visual inspection system for the quality of titanium alloy parts, the system comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the steps of any one of the above methods are implemented.
[0042] The present invention has the following beneficial effects:
[0043] The present invention obtains the texture continuity feature and gradient consistency feature of the target pixel point by analyzing the distribution of the edge pixel points of the edge line where the target pixel point is located on the straight line corresponding to the texture direction of the target pixel point, and the difference in the gradient amplitude in the vertical texture direction between the target pixel point and each of its preset neighborhood edge pixel points, so as to accurately reflect the characteristics of the target pixel point, which is conducive to accurately classifying the edge pixel points in the titanium alloy part image, so as to accurately detect the crack defect edge line later; in order to accurately and efficiently determine the abnormal edge pixel points corresponding to the crack defect in the titanium alloy part image, the splitting feature of each node is determined according to the texture continuity feature and gradient consistency feature of each edge pixel point in each node in the isolation forest algorithm, so as to improve the accuracy of splitting the edge pixel points in each node, and thus accurately The decision tree is accurately obtained so that the abnormality of each edge pixel can be accurately analyzed and the abnormal edge pixels can be accurately screened out subsequently; therefore, according to the depth of each leaf node where the target pixel is located in the corresponding decision tree, and the difference in the number of edge pixels between each leaf node where the target pixel is located and its brother nodes, the evaluation depth of the target pixel is obtained to accurately reflect the abnormality of the target pixel; then, based on the evaluation depth, the abnormal edge pixels in the titanium alloy part image are accurately screened out, and in order to further avoid the interference of the texture corresponding edge line on the detection of the crack defect edge line, the crack defect edge line in the titanium alloy part image is further accurately obtained according to the distribution of the abnormal edge pixels on each edge line, and then the quality of the titanium alloy parts is accurately tested to ensure that the quality of the titanium alloy parts entering the market meets the standards. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0045] Figure 1 A schematic flow chart of a method for visually inspecting the quality of titanium alloy parts provided by one embodiment of the present invention;
[0046] Figure 2 An image of a titanium alloy part having only a titanium alloy part provided for one embodiment of the present invention;
[0047] Figure 3 A flow chart of a method for acquiring texture continuity features provided by an embodiment of the present invention;
[0048] Figure 4 A flow chart of a method for obtaining gradient consistent features provided by an embodiment of the present invention;
[0049] Figure 5 A flow chart of a method for obtaining splitting features provided by an embodiment of the present invention;
[0050] Figure 6 A structural diagram of a titanium alloy parts quality visual inspection system provided by one embodiment of the present invention;
[0051] Figure 7 A schematic diagram of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0052] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of a titanium alloy parts quality visual inspection method and system proposed by the present invention, its specific implementation method, structure, characteristics and effects, in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0053] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0054] The specific scheme of a titanium alloy part quality visual inspection method and system provided by the present invention is described in detail below with reference to the accompanying drawings.
[0055] Embodiment 1:
[0056] The specific scenario of this embodiment is: in the existing method, the edge line in the titanium alloy part image is obtained by the edge detection algorithm, and the detected edge line is used as the crack defect edge line. However, in actual situations, the texture formed by the titanium alloy part during processing and rolling will also appear in the edge detection algorithm in the form of an edge line, resulting in the inability to accurately detect the crack defect edge line in the titanium alloy part image, and thus the inability to accurately detect the quality of the titanium alloy part. In order to accurately detect the crack defect on the surface of the titanium alloy part, this embodiment first analyzes the characteristics of each edge pixel point in the titanium alloy part image in the texture direction and the vertical texture direction, obtains the texture continuity feature and gradient consistency feature of each edge pixel point, and then obtains the evaluation depth of each edge pixel point in the titanium alloy part image according to the texture continuity feature and gradient consistency feature of each edge pixel point through the isolation forest algorithm, screens out the abnormal edge pixel points in the titanium alloy part image, and then accurately obtains the crack defect edge line, avoids the interference of the texture formed by processing and rolling on the crack defect detection, and then accurately detects the quality of the titanium alloy part. Among them, the isolation forest algorithm is a well-known technology and will not be repeated.
[0057] The present invention proposes a method for visual inspection of titanium alloy parts quality. Figure 1 , which shows a schematic flow chart of a method for visually inspecting the quality of titanium alloy parts provided by an embodiment of the present invention, the method comprising the following steps:
[0058] Step S1: Acquire edge pixel points in the titanium alloy part image.
[0059] Specifically, when the processed titanium alloy parts are transported on the conveyor belt, an industrial camera is installed directly above the conveyor belt, and the lens of the industrial camera is facing the titanium alloy parts. The image of each titanium alloy part is obtained through the industrial camera, wherein each titanium alloy part image must be a complete titanium alloy part. For the sake of clear description, this embodiment takes an image of a titanium alloy part as an example for analysis. It should be noted that the subsequent titanium alloy part images all refer to the same titanium alloy part image selected in this embodiment. Among them, the running direction of the conveyor belt is the processing and rolling direction of the titanium alloy parts, that is, the running direction of the conveyor belt is the texture direction.
[0060] In order to accurately and efficiently detect crack defects in titanium alloy part images, this embodiment uses a semantic segmentation network to obtain titanium alloy part images with only titanium alloy parts. Among them, the semantic segmentation network of this embodiment uses a U-net neural network, and the input is a titanium alloy part image containing titanium alloy parts; the output is a titanium alloy part image with only titanium alloy parts; the U-net neural network is trained and labeled in the following way: mark the area of the titanium alloy part as 1, and mark other areas as 0; the loss function of the U-net neural network is a cross-entropy loss function. Among them, the U-net neural network is a well-known technology and will not be described in detail here. It should be noted that the subsequent titanium alloy part images are all images of only titanium alloy parts, such as Figure 2 Shown is an image of a titanium alloy part provided by an embodiment of the present invention, which only contains a titanium alloy part.
[0061] It is known that crack defects must exist in the form of edge lines in the titanium alloy part image, and the texture of the titanium alloy part surface also appears in the form of edge lines in the titanium alloy part image. Therefore, this embodiment first obtains edge pixel points in the titanium alloy part image through the Canny edge detection algorithm, and then analyzes each edge pixel point to determine the abnormal edge pixel points in the titanium alloy part image, and then accurately obtains the crack defect edge line in the titanium alloy part image. Among them, the Canny edge detection algorithm is a well-known technology and will not be described in detail here.
[0062] Step S2: randomly select an edge pixel point as the target pixel point, and obtain the texture continuity feature of the target pixel point according to the distribution of the edge pixel points of the edge line where the target pixel point is located on the straight line corresponding to the texture direction of the target pixel point.
[0063] Specifically, during the rolling process, a strip texture consistent with the texture direction is formed on the surface of the titanium alloy part. In the titanium alloy part image, the edge line corresponding to the texture is continuous in the texture direction. For example, Figure 2 If the texture direction in the titanium alloy part image is vertical, then the edge line corresponding to the texture must be distributed vertically in the titanium alloy part image. Crack defects are randomly generated, so the distribution direction of the edge line corresponding to the crack defect in the titanium alloy part image is not fixed. In order to distinguish the edge lines corresponding to the texture and the crack defects, this embodiment analyzes each edge pixel point, wherein the edge pixel points on the edge line where the edge pixel points corresponding to the texture are located must be concentrated on the straight line where the texture direction is located. For better description, this embodiment randomly selects an edge pixel point as the target pixel point, and then obtains the texture continuity feature of the target pixel point based on the distribution of the edge pixel points of the edge line where the target pixel point is located on the straight line corresponding to the texture direction of the target pixel point. The larger the texture continuity feature, the more likely the target pixel point is to be the edge pixel point corresponding to the texture.
[0064] Preferably, in some possible implementations of this embodiment, the method for obtaining the texture continuity feature can be found in Figure 3 , which shows a flow chart of a method for acquiring texture continuity features provided by an embodiment of the present invention, the method comprising the following steps:
[0065] Step S201: Acquire the target straight line.
[0066] The straight line corresponding to the texture direction of the target pixel point is used as the target straight line; wherein the target straight line must be a straight line passing through the target pixel point and parallel to the texture direction.
[0067] Step S202: Obtain a first quantity.
[0068] The number of edge pixel points of the edge line where the target pixel point is located on the target straight line is taken as the first number; the larger the first number is, the more likely the edge line where the target pixel point is located is to be the edge line corresponding to the texture, which indirectly indicates that the target pixel point is more likely to be the edge pixel point corresponding to the texture. It should be noted that in actual situations, the edge line corresponding to the texture may have a certain inclination, that is, the edge line corresponding to the texture is not completely parallel to the straight line corresponding to the texture direction, and can be vaguely defaulted to be parallel as a whole. In order to more accurately determine the size of the first number, this embodiment sets the preset distance offset threshold to 5. The implementer can set the size of the preset distance offset threshold according to actual conditions, and it is not limited here. When the distance from a certain edge pixel point of the edge line where the target pixel point is located to the target straight line is less than or equal to the preset distance offset threshold, it is assumed that the edge pixel point is on the target straight line. At this point, the distribution of the edge pixel points of the edge line where the target pixel point is located on the target straight line is determined, and the first number is accurately obtained.
[0069] Step S203: Acquire texture continuity features.
[0070] It is known that the larger the first number is, the more likely the target pixel is to be an edge pixel corresponding to the texture. In order to clearly determine the possibility that the target pixel is an edge pixel corresponding to the texture, this embodiment specifically quantifies the texture continuity feature as a texture continuity feature value. The larger the texture continuity feature value is, the more likely the target pixel is to be an edge pixel corresponding to the texture. The texture continuity feature value is obtained by taking the ratio of the first number to the total number of edge pixels of the edge line where the target pixel is located as the texture continuity feature value of the target pixel. At this point, the texture continuity feature value of each edge pixel is obtained.
[0071] Step S3: Obtain the gradient consistency feature of the target pixel point based on the difference in gradient amplitude in the vertical texture direction between the target pixel point and each of its preset neighborhood edge pixels.
[0072] Specifically, it is known that the magnitude of the gradient amplitude in the vertical texture direction of the edge pixel points on the edge line corresponding to a texture is similar, while the distribution direction of the crack defect is uncertain, so the magnitude of the gradient amplitude in the vertical texture direction of the edge pixel points corresponding to the crack defect is uncertain. In order to more accurately distinguish the edge pixel points corresponding to the texture and the crack defect, this embodiment first determines the preset neighborhood edge pixel points of each edge pixel point, and then analyzes the possibility of each edge pixel point being an edge pixel point corresponding to the texture based on the difference in the gradient amplitude in the vertical texture direction between each edge pixel point and each of its preset neighborhood edge pixel points. For better description, this embodiment takes the target pixel point as an example for analysis, and then obtains the gradient consistency feature of the target pixel point based on the difference in the gradient amplitude in the vertical texture direction between the target pixel point and each of its preset neighborhood edge pixel points. The larger the gradient consistency feature, the more likely the target pixel point is an edge pixel point corresponding to the texture.
[0073] Preferably, in some possible implementations of this embodiment, the method for obtaining the gradient consistent feature can be found in Figure 4 , which shows a flow chart of a method for obtaining a gradient consistent feature provided by an embodiment of the present invention, the method comprising the following steps:
[0074] Step S301: Obtain preset neighborhood edge pixel points.
[0075] The method for obtaining the preset neighborhood edge pixel points of the target pixel point is: on the edge line where the target pixel point is located, with the target pixel point as the center, a first preset number of adjacent edge pixel points are taken on both sides of the target pixel point, and all of them are used as the preset neighborhood edge pixel points of the target pixel point. In this embodiment, the first preset number is set to 8, and the implementer can set the size of the first preset number according to actual conditions, which is not limited here. If the target pixel is the i-th edge pixel on the edge line where it is located, the preset neighborhood edge pixel of the target pixel is the i-8th edge pixel, i-7th edge pixel, i-6th edge pixel, i-5th edge pixel, i-4th edge pixel, i-3th edge pixel, i-2th edge pixel, i-1th edge pixel, i+1th edge pixel, i+2th edge pixel, i+3th edge pixel, i+4th edge pixel, i+5th edge pixel, i+6th edge pixel, i+7th edge pixel and i+8th edge pixel on the edge line where the target pixel is located. It should be noted that if the target pixel is a boundary edge pixel of the edge line where it is located, and the number of preset neighborhood edge pixel points on one side of it is less than the first preset number, only the preset neighborhood edge pixel points where the target pixel exists are analyzed.
[0076] Step S302: Obtain gradient consistent features.
[0077] Obtain the gradient amplitude in the vertical texture direction between the target pixel and each of its preset neighborhood edge pixels. When the gradient amplitude in the vertical texture direction between the target pixel and each of its preset neighborhood edge pixels is more equal, it means that the target pixel is more likely to be a texture pixel. Therefore, the present embodiment first obtains the absolute value of the difference in the gradient amplitude in the vertical texture direction between the target pixel and each of its preset neighborhood edge pixels, all of which are taken as the first difference; the smaller the first difference, the more likely the target pixel is a texture pixel; then the mean of the first difference is negatively correlated and normalized as the gradient consistent feature of the target pixel. The larger the gradient consistent feature, the more likely the target pixel is a texture pixel. In order to more accurately represent the possibility that the target pixel is a texture pixel, the present embodiment specifically quantifies the gradient consistent feature as a gradient consistent eigenvalue. The larger the gradient consistent eigenvalue, the more likely the target pixel is a texture pixel. Among them, the calculation formula of the gradient consistent eigenvalue is: ; In the formula, is the gradient consistent eigenvalue of the i-th edge pixel; D is the total number of edge pixels in the preset neighborhood of the i-th edge pixel; is the gradient amplitude in the vertical texture direction of the i-th edge pixel; is the gradient amplitude in the vertical texture direction of the d-th preset neighborhood edge pixel of the ith edge pixel; is the first preset constant, greater than 0; is the absolute value function; norm is the normalization function.
[0078] This embodiment will Set to 1 to avoid the denominator being 0. Implementers can set it according to actual conditions. The size of is not limited here. So far, the gradient consistent feature value of each edge pixel is obtained.
[0079] Step S4: According to the texture continuity feature and gradient consistency feature of each edge pixel in each node in the isolation forest algorithm, the split feature of each node is determined, and then a decision tree is obtained.
[0080] Specifically, in the titanium alloy part image, the edge lines corresponding to the crack defects are randomly distributed in different directions. Therefore, the edge pixels with larger texture continuity features and gradient consistency features may also be the edge pixels corresponding to the crack defects, but the edge pixels with smaller texture continuity features and gradient consistency features must be the edge pixels corresponding to the crack defects. At the same time, in the titanium alloy part image, there are more edge pixels corresponding to the texture, and fewer edge pixels corresponding to the crack defects. Therefore, this embodiment uses the isolation forest algorithm to perform abnormality detection on all edge pixels, and preliminarily determines the abnormal edge pixels that must correspond to the crack defects.
[0081] In this embodiment, the number of edge pixels for constructing each decision tree is first set to 200, and the height of each decision tree is 7. decision trees, where Z is the number of all edge pixels in the titanium alloy part image; Is the rounding symbol. The implementer can set the number of edge pixels for constructing each decision tree, the height of each decision tree and the number of decision trees to be constructed according to the actual situation. It is not limited here, but it is necessary to ensure that all edge pixels in the titanium alloy part image participate in the construction of the decision tree. In the process of constructing the decision tree, the splitting features corresponding to each node are texture continuity features and gradient consistency features, respectively. Therefore, it is necessary to split the edge pixels in each node according to the texture continuity features or gradient consistency features, but different edge pixels have different performance levels in texture continuity features and gradient consistency features. If the splitting features of each node are randomly selected, the splitting results of the corresponding nodes will be inaccurate, and the abnormal degree of each edge pixel cannot be analyzed. Therefore, this embodiment determines the splitting features of each node according to the texture continuity features and gradient consistency features of each edge pixel in each node in the isolation forest algorithm, accurately obtains each decision tree, and is conducive to the subsequent accurate detection of abnormal edge pixels.
[0082] Preferably, in some possible implementations of this embodiment, the method for obtaining the split feature can be found in Figure 5 , which shows a flow chart of a method for obtaining splitting features provided by an embodiment of the present invention, the method comprising the following steps:
[0083] Step S401: Obtain the between-class variance.
[0084] For any node, the texture continuous eigenvalues of all edge pixels in the node are constructed into a set as the first set, and the gradient consistent eigenvalues of all edge pixels in the node are constructed into a set as the second set; for any element in any set, the set is divided into two categories using the element as the threshold, and the inter-class variance of the element is obtained; the larger the inter-class variance, the greater the difference between the two categories divided by the element, which indirectly indicates that the features corresponding to the set can more accurately divide the edge pixels in the node, and the features corresponding to the set are more likely to be the split features of this node.
[0085] The calculation formula of between-class variance is: ; In the formula, is the between-class variance of the vth element in the ath set; The number of elements in one of the categories that the v-th element in the a-th set is classified into; The number of elements in another category that the v-th element in the a-th set is classified into; is the total number of all elements in the ath set; is the mean of all elements in one of the categories classified by the vth element in the ath set; is the mean of all elements in another category divided by the vth element in the ath set. The method for obtaining the inter-class variance is a well-known technique and will not be described in detail. So far, the inter-class variance of each element in the first set and the inter-class variance of each element in the second set are obtained.
[0086] Step S402: Obtain the credibility level.
[0087] It is known that the larger the inter-class variance is, the more likely the feature corresponding to the corresponding set is to be the split feature of the corresponding node. Considering that when the difference in the number of elements between the two categories corresponding to the maximum inter-class variance of a set is larger, it is more accurate to explain that the corresponding feature of the set can accurately analyze the edge pixels in the node, and the corresponding feature of the set is more likely to be the split feature of the corresponding node. Therefore, this embodiment obtains the number of elements in the two categories corresponding to the maximum inter-class variance of each set, and both are used as the reference number of the corresponding set; then, according to the maximum inter-class variance of each set, and the ratio of the minimum reference number to the maximum reference number, the credibility of the feature corresponding to each set is obtained; wherein, the maximum inter-class variance is positively correlated with the credibility, and the ratio of the minimum reference number to the maximum reference number is negatively correlated with the credibility. The greater the credibility, the more likely the feature corresponding to the corresponding set is to be the split feature of the corresponding node.
[0088] In order to determine the possibility that the feature corresponding to each set is the split feature of the corresponding node, this embodiment specifically quantifies the credibility as a credibility value. The larger the credibility value, the more likely the feature corresponding to the corresponding set is the split feature of the corresponding node. The calculation formula of the credibility value is: ; In the formula, is the credibility value of the feature corresponding to the ath set; is the maximum between-class variance of the a-th set; is the minimum reference quantity of the a-th set; is the maximum number of references for the ath set. The smaller, the and The greater the difference, the more accurately the features corresponding to the ath set can divide the edge pixels in the corresponding nodes. The bigger, So far, the credibility value of the texture continuity feature and the credibility value of the gradient consistency feature of each node are obtained.
[0089] Step S403: Obtain splitting features.
[0090] The splitting feature of each splittable node is selected from the texture continuity feature and the gradient consistency feature. It is known that the higher the credibility, the more likely the feature corresponding to the corresponding set is the splitting feature of the corresponding node. Therefore, in this embodiment, the feature corresponding to the corresponding set with the maximum credibility value is used as the splitting feature of the corresponding node. Among them, the feature corresponding to the first set is the texture continuity feature, and the feature corresponding to the second set is the gradient consistency feature. At this point, the splitting feature of each splitting node is obtained, and then each decision tree is accurately obtained, which is conducive to the subsequent accurate analysis of the abnormal edge pixel points corresponding to the crack defect.
[0091] Step S5: Obtain the evaluation depth of the target pixel point according to the depth of each leaf node where the target pixel point is located in the corresponding decision tree and the difference in the number of edge pixels between each leaf node where the target pixel point is located and its sibling nodes.
[0092] Specifically, it is known that in the isolation forest algorithm, when the leaf node where the target pixel is located is closer to the root node of the decision tree, the target pixel is more likely to be an abnormal edge pixel. Therefore, this embodiment analyzes the possibility that the target pixel is an abnormal edge pixel by the depth of the leaf node where the target pixel is located in the corresponding decision tree. Since the edge pixels in each decision tree are randomly selected, that is, the edge pixels in each decision tree are different, the depth of the leaf nodes where the same edge pixel is located in different decision trees may be different. When the depth of the leaf nodes where the target pixel is located in different decision trees is smaller, it means that the target pixel is more likely to be an abnormal edge pixel corresponding to a crack defect.
[0093] In order to more accurately analyze the abnormality of the target pixel, the difference in the number of edge pixels between the leaf node where the target pixel is located and its sibling node in different decision trees is further obtained. When the difference in the number of edge pixels between the leaf node where the target pixel is located and its sibling node in a decision tree is greater, it means that the classification result of the target pixel in the decision tree is more accurate, and the depth of the leaf node where the target pixel is located in the decision tree is more correct. Among them, each leaf node and its sibling node have the same parent node. Therefore, this embodiment obtains the evaluation depth of the target pixel according to the depth of each leaf node where the target pixel is located in the corresponding decision tree, and the difference in the number of edge pixels between each leaf node where the target pixel is located and its sibling node. The smaller the evaluation depth, the more likely the target pixel is to be an abnormal edge pixel corresponding to a crack defect.
[0094] Preferably, in some possible implementations of this embodiment, the method for obtaining the evaluation depth is: taking the decision trees where the target pixel is located as the target decision tree, and obtaining the reasonable weight of the target pixel in each target decision tree according to the difference in the number of edge pixels between the leaf node and its brother node where the target pixel is located in each target decision tree; wherein the difference in the number of edge pixels is positively correlated with the reasonable weight; the larger the reasonable weight, the more accurate the classification result of the target pixel in the corresponding target decision tree, which indirectly indicates that the depth of the leaf node where the target pixel is located in the corresponding target decision tree is more accurate. In order to more accurately analyze the abnormality of the target pixel, this embodiment corrects the depth of the leaf node where the target pixel is located in each target decision tree by a reasonable weight, and then accurately obtains the evaluation depth of the target pixel. The smaller the evaluation depth, the more likely the target pixel is to be an abnormal edge pixel.
[0095] In some possible implementations of this embodiment, the method for obtaining the evaluation depth is: taking the product of the reasonable weight of the target pixel in each target decision tree and the depth of the leaf node where the target pixel is located in each target decision tree as the corrected depth of the target pixel in each target decision tree; taking the average of all corrected depths as the evaluation depth of the target pixel. Therefore, the calculation formula for the evaluation depth is: ; In the formula, is the evaluation depth of the i-th edge pixel; J is the total number of target decision trees where the i-th edge pixel is located; is the number of edge pixels in the leaf node where the i-th edge pixel is located in the j-th target decision tree; is the number of edge pixels in the sibling nodes of the leaf node where the i-th edge pixel is located in the j-th target decision tree; is the absolute value function; norm is the normalization function; is a reasonable weight; is the depth of the leaf node where the i-th edge pixel is located in the j-th target decision tree.
[0096] At this point, the estimated depth of each edge pixel is obtained.
[0097] Step S6: based on the evaluation depth, abnormal edge pixel points are screened out to determine the crack defect edge line in the titanium alloy part image, and the quality of the titanium alloy part is detected.
[0098] Specifically, it is known that the smaller the evaluation depth, the more likely the corresponding edge pixel point is an abnormal edge pixel point corresponding to a crack defect. Therefore, this embodiment sets the preset evaluation depth threshold value to 3. The implementer can set the size of the preset evaluation depth threshold value according to the actual situation, which is not limited here. When the evaluation depth is less than or equal to the preset evaluation depth threshold value, the corresponding edge pixel point is an abnormal edge pixel point. Because crack defects are randomly distributed in the titanium alloy part image, there are some edge pixels corresponding to crack defects that are not abnormal edge pixels, but for an edge line corresponding to the crack defect, there must be a majority of abnormal edge pixels. Therefore, this embodiment uses the ratio of the number of abnormal edge pixels on each edge line to the number of all edge pixels on the corresponding edge line as the abnormal judgment value of each edge line. The larger the abnormal judgment value, the more likely the corresponding edge line is a crack defect edge line. This embodiment sets the preset abnormal judgment value threshold value to 0.5. The implementer can set the size of the preset abnormal judgment value threshold value according to the actual situation, which is not limited here. When the abnormal judgment value is greater than the preset abnormal judgment value threshold value, the corresponding edge line is a crack defect edge line. At this point, the crack defect edge line in the titanium alloy part image is determined.
[0099] In order to determine the quality of titanium alloy parts in titanium alloy part images, this embodiment obtains the number of crack defect edge lines in the titanium alloy part image as the quality assessment number; when the quality assessment number is less than or equal to the preset first quality assessment number threshold, the quality of the titanium alloy part is good; when the quality assessment number is greater than the preset first quality assessment number threshold and less than or equal to the preset second quality assessment number threshold, the quality of the titanium alloy part is qualified; when the quality assessment number is greater than the preset second quality assessment number threshold, the quality of the titanium alloy part is unqualified. In this embodiment, the preset first quality assessment number threshold is set to 1, and the preset second quality assessment number threshold is set to 5. The implementer can set the size of the first quality assessment number threshold and the second quality assessment number threshold according to the actual situation, which is not limited here. So far, the quality inspection of titanium alloy parts is accurately completed. Titanium alloy parts with unqualified quality cannot enter the market and need to be reprocessed to ensure that the titanium alloy parts on the market are qualified.
[0100] In summary, this embodiment obtains edge pixel points in the titanium alloy part image; according to the distribution of edge pixel points in the texture direction and the gradient amplitude in the vertical texture direction, the texture continuity feature and gradient consistency feature of the edge pixel points are obtained, and then the node splitting feature in the isolation forest algorithm is determined to obtain a decision tree; according to the depth of the leaf node where the edge pixel point is located in the corresponding decision tree, and the difference in the number of edge pixel points between the leaf node and its sibling node, the evaluation depth of the edge pixel point is obtained, and then the abnormal edge pixel points are screened out to determine the crack defect edge line, and the quality of the titanium alloy part is detected. The present invention accurately screens out abnormal edge pixel points by analyzing the characteristics of edge pixel points, avoids the interference of texture on the detection of crack defect edge lines, and enables accurate detection of the quality of titanium alloy parts.
[0101] Embodiment 2:
[0102] The present invention also proposes a titanium alloy parts quality visual inspection system, please refer to Figure 6 , which shows a structural diagram of a titanium alloy part quality visual inspection system provided by an embodiment of the present invention, the system includes: an acquisition module 10, a texture continuous feature acquisition module 20, a gradient consistent feature acquisition module 30, a decision tree acquisition module 40, an evaluation depth acquisition module 50 and a quality inspection module 60.
[0103] The acquisition module 10 acquires edge pixel points in the titanium alloy part image.
[0104] The texture continuity feature acquisition module 20 selects an edge pixel point as a target pixel point, and acquires the texture continuity feature of the target pixel point according to the distribution of the edge pixel points of the edge line where the target pixel point is located on the straight line corresponding to the texture direction of the target pixel point.
[0105] The gradient consistent feature acquisition module 30 acquires the gradient consistent feature of the target pixel point according to the difference in the gradient amplitude in the vertical texture direction between the target pixel point and each of its preset neighborhood edge pixels.
[0106] The decision tree acquisition module 40 determines the splitting feature of each node according to the texture continuity feature and gradient consistency feature of each edge pixel point in each node in the isolation forest algorithm, and then acquires the decision tree.
[0107] The evaluation depth acquisition module 50 obtains the evaluation depth of the target pixel point according to the depth of each leaf node where the target pixel point is located in the corresponding decision tree and the difference in the number of edge pixels between each leaf node where the target pixel point is located and its sibling nodes.
[0108] The quality detection module 60 selects abnormal edge pixels based on the evaluation depth to determine the crack defect edge line in the titanium alloy part image, and detects the quality of the titanium alloy part.
[0109] It should be noted that: the system provided in the above embodiment is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the computer device is divided into different functional modules to complete all or part of the functions described above. In addition, the titanium alloy part quality visual inspection system and the titanium alloy part quality visual inspection method embodiment provided in the above embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0110] Embodiment 3:
[0111] The present invention also proposes a titanium alloy part quality visual inspection device, which includes a memory and a processor, wherein the memory stores an executable program code, and the processor is used to call and execute the executable program code to execute a titanium alloy part quality visual inspection method provided in the embodiment of the present application. The device can be a chip, a component or a module, and the chip can include a connected processor and a memory; wherein the memory is used to store instructions, and when the processor calls and executes the instructions, the chip can execute a titanium alloy part quality visual inspection method provided in the above embodiment.
[0112] In addition, the present application embodiment also protects a computer device, see Figure 7 The computer device includes a memory 401, a processor 402, and a computer program 403 stored in the memory 401 and running on the processor 402, wherein when the processor 402 executes the computer program 403, the computer device can execute any one of the titanium alloy part quality visual inspection methods introduced above.
[0113] Embodiment 4:
[0114] This embodiment also provides a computer-readable storage medium, in which a computer program code is stored. When the computer program code is run on a computer, the computer executes the above-mentioned related method steps to implement a visual inspection method for the quality of titanium alloy parts provided in the above embodiment.
[0115] Embodiment 5:
[0116] This embodiment also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the above-mentioned related steps to implement a visual inspection method for the quality of titanium alloy parts provided in the above embodiment.
[0117] Among them, the device, computer-readable storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.
[0118] It should be noted that the sequence of the above embodiments of the present invention is only for description and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0119] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
Claims
1. A method for visual inspection of titanium alloy parts quality, characterized in that: The method comprises the following steps: Obtain edge pixel points in the titanium alloy part image; Select an edge pixel point as the target pixel point, and obtain the texture continuity feature of the target pixel point according to the distribution of the edge pixel points of the edge line where the target pixel point is located on the straight line corresponding to the texture direction of the target pixel point; Obtaining a gradient consistency feature of a target pixel point according to the difference in gradient amplitude in a vertical texture direction between the target pixel point and each of its preset neighborhood edge pixels; According to the texture continuity feature and gradient consistency feature of each edge pixel point in each node in the isolation forest algorithm, the split feature of each node is determined, and then a decision tree is obtained; wherein, in the process of constructing the decision tree, the split features corresponding to each node are texture continuity feature and gradient consistency feature respectively; The evaluation depth of the target pixel is obtained according to the depth of each leaf node where the target pixel is located in the corresponding decision tree and the difference in the number of edge pixels between each leaf node where the target pixel is located and its sibling nodes; Based on the evaluation depth, abnormal edge pixels are screened out to determine the crack defect edge line in the titanium alloy part image, and the quality of the titanium alloy part is tested; The method for obtaining the split feature is: For any node, the texture continuous eigenvalues of all edge pixels in the node are constructed into a set as a first set; the gradient consistent eigenvalues of all edge pixels in the node are constructed into a set as a second set; For any element in any set, use the element as the threshold to divide the set into two categories and obtain the inter-class variance of the element; Get the number of elements in the two categories corresponding to the maximum between-class variance of each set, and use them as the reference number of the corresponding set; According to the maximum inter-class variance of each set and the ratio of the minimum reference number to the maximum reference number, the credibility of the features corresponding to each set is obtained; among which, the maximum inter-class variance is positively correlated with the credibility, and the ratio of the minimum reference number to the maximum reference number is negatively correlated with the credibility; The features corresponding to the set with the highest credibility are used as the split features of the node; wherein the features corresponding to the first set are texture continuity features, and the features corresponding to the second set are gradient consistency features; The method for obtaining the evaluation depth is: The decision trees where the target pixel point is located are all taken as the target decision trees, and the reasonable weight of the target pixel point in each target decision tree is obtained according to the difference in the number of edge pixels between the leaf node where the target pixel point is located and its sibling node in each target decision tree; wherein the difference in the number of edge pixels is positively correlated with the reasonable weight; The product of the reasonable weight of the target pixel in each target decision tree and the depth of the leaf node where the target pixel is located in each target decision tree is used as the corrected depth of the target pixel in each target decision tree; Taking the average of all the corrected depths as the evaluation depth of the target pixel; The method for obtaining the crack defect edge line is: When the evaluation depth is less than or equal to the preset evaluation depth threshold, the corresponding edge pixel is an abnormal edge pixel; The ratio of the number of abnormal edge pixels on each edge line to the number of all edge pixels on the corresponding edge line is used as the abnormality judgment value of each edge line; When the abnormality judgment value is greater than a preset abnormality judgment value threshold, the corresponding edge line is a crack defect edge line.
2. A titanium alloy parts quality visual inspection method as claimed in claim 1, characterized in that: The method for acquiring the texture continuity feature is: The straight line corresponding to the texture direction of the target pixel point is used as the target straight line; The number of edge pixel points of the edge line where the target pixel point is located on the target straight line is taken as the first number; The ratio of the first number to the total number of edge pixels on the edge line where the target pixel is located is used as the texture continuity feature value of the target pixel.
3. A titanium alloy parts quality visual inspection method as claimed in claim 1, characterized in that: The method for obtaining the gradient consistent feature is: Obtaining the difference in the gradient amplitude in the vertical texture direction between the target pixel and each of its preset neighborhood edge pixels, each as a first difference; The result of negatively correlating and normalizing the mean of the first difference is used as the gradient consistency feature of the target pixel.
4. A titanium alloy parts quality visual inspection method as claimed in claim 1, characterized in that: The method for testing the quality of titanium alloy parts is as follows: Obtain the number of crack defect edge lines in the titanium alloy part image as a quality assessment quantity; When the quality assessment quantity is less than or equal to the preset first quality assessment quantity threshold, the quality of the titanium alloy part is good; When the quality assessment quantity is greater than a preset first quality assessment quantity threshold and less than or equal to a preset second quality assessment quantity threshold, the quality of the titanium alloy part is qualified; When the quality assessment quantity is greater than a preset second quality assessment quantity threshold, the quality of the titanium alloy part is unqualified.
5. A titanium alloy parts quality visual inspection method as claimed in claim 1, characterized in that: The texture direction is the processing and rolling direction of the titanium alloy part.
6. A titanium alloy parts quality visual inspection method as claimed in claim 1, characterized in that: The method for obtaining the edge pixel points is: The Canny edge detection algorithm is used to obtain edge pixel points in the titanium alloy part image.
7. A titanium alloy part quality visual inspection system, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When executing the computer program, the processor implements the steps of the titanium alloy part quality visual inspection method described in any one of claims 1 to 6.
