Casting appearance quality detection method based on machine vision
By analyzing the characteristics of the thickness area and local maximum points in the casting X-ray grayscale image, calculating the probability of the pore edge, and determining the seed points of the watershed algorithm, the problem of inconsistent thickness areas in the finished casting affecting the positioning of the pore defects, and achieving accurate positioning and efficient detection of the pore defect areas.
Patent Information
- Application Number
- CN202510691854.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-27
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2045-05-27
AI Technical Summary
The regional characteristics of different thicknesses and thicknesses in the finished casting structure affect the accuracy of pore defect positioning.
By obtaining the thick and thin areas in the casting X-ray grayscale image, as well as all local maxima points, the analysis pixel points are determined, and the probability of the pore edge is calculated based on their characteristic performance in the color domain and spatial domain, and the seed points of the watershed algorithm are determined.
The accurate positioning of the pore defect area in the casting X-ray grayscale image is achieved, avoiding the influence of inconsistent thickness areas on seed point selection, and improving the accuracy of pore defect detection.
Smart Images

Figure CN120198442A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of casting image data processing. More specifically, the present invention relates to a method for detecting the appearance quality of castings based on machine vision. Background Art
[0002] A casting refers to a formed workpiece with a certain shape and size obtained by pouring molten metal liquid into a mold cavity adapted to the shape of the required part and waiting for it to cool and solidify. In order to ensure the use effect of the finished product, it is necessary to detect the quality of the casting after completion.
[0003] The development of machine vision provides a new solution for detecting the appearance quality of castings. During the process of detecting the appearance quality of castings, X-rays are used to penetrate the castings and construct two-dimensional images to display the internal structure of the castings, and more subtle appearance defects of the castings can be detected, such as porosity defects in the castings. Porosity defects are defects caused by gas staying in the molten metal during the casting process and finally remaining inside or on the surface of the casting after solidification.
[0004] Currently, the watershed algorithm is mostly used to segment and locate the porosity defect areas in the X-ray images of castings. The watershed algorithm describes the gray value of the image as a topographic map and simulates the process of water flowing from local minima and gradually filling the terrain, and finally divides the image into different regions to extract the porosity defect areas. However, there are usually areas with different thicknesses in the structure of the casting finished product, and such differences in thickness are reflected as uneven brightness in the X-ray images of the castings, resulting in poor selection of seed points during the process of using the watershed algorithm to segment the porosity defects, and finally leading to missed detection of pixel points in the bubble defect areas.
[0005] Therefore, it is urgent to solve the influence of the regional characteristics of different thicknesses in the structure of the casting finished product on the accuracy of porosity defect location. Summary of the Invention
[0006] To solve the above technical problem of the influence of the regional characteristics of different thicknesses in the structure of the casting finished product on the accuracy of porosity defect location, the present invention proposes a method for detecting the appearance quality of castings based on machine vision, which includes the following steps: Obtain the thick regions and thin regions in the X-ray grayscale image of the casting, as well as all local maximum points. Determine the analysis pixels from the local maximum points according to the gradient magnitude between the local maximum points and their eight-neighbor pixels; determine the probability that the analysis pixel belongs to the pore edge in the color domain according to the difference between the grayscale value of the analysis pixel and the grayscale mean value of the thick region or thin region where the analysis pixel is located, and the grayscale variance of the eight-neighbor pixels of the analysis pixel; obtain multiple other analysis pixels in the texture direction perpendicular to the gradient direction of the analysis pixel to construct the reference domain of the analysis pixel, and calculate the probability that the i-th analysis pixel belongs to the pore edge in the spatial domain : ; is the gradient amplitude of the i-th analysis pixel, is the gradient direction variance of the analysis pixels in the reference domain of the i-th analysis pixel, is the maximum value of the gradient direction variances of the analysis pixels in the reference domains of all analysis pixels, is the average Euclidean distance between each analysis pixel in the reference domain of the i-th analysis pixel and the i-th analysis pixel, is the maximum value of the average Euclidean distances between each analysis pixel in the reference domains of all analysis pixels and the i-th analysis pixel; Determine the seed points of the watershed algorithm according to the probability that the analysis pixel belongs to the pore edge in the color domain and the probability that it belongs to the pore edge in the spatial domain, so as to obtain the casting appearance quality detection result.
[0007] The present invention can accurately locate the pore defect regions in the X-ray grayscale image of the casting by processing the X-ray grayscale image of the casting through the watershed algorithm. In the process of processing the X-ray grayscale image of the casting through the watershed algorithm, the present invention takes into account that there are regions with inconsistent thickness in the casting, and its bright parts are uneven, which will affect the accuracy of the selection of the seed points of the watershed algorithm; Therefore, the present invention analyzes the characteristic performance of each analysis pixel that may be a seed point in the color domain and the spatial domain, and obtains the probability that each analysis pixel belongs to the pore edge, so as to accurately locate the pore defect regions on the casting.
[0008] According to the casting appearance quality detection method based on machine vision provided by the present invention, before the step of obtaining the thick regions and thin regions in the X-ray grayscale image of the casting, it further includes: collecting the X-ray image of the casting and performing preprocessing to obtain the X-ray grayscale image of the casting.
[0009] In the present invention, when considering positioning the pore defect area, local maximum points that may be the edges of pore defects can be used as seed points. However, the watershed algorithm usually uses local minimum points as seed points for growth. Therefore, before processing the X-ray gray-scale image of the casting, the present invention can perform gradient inversion preprocessing on the X-ray gray-scale image of the casting to convert local minimum points into local maximum points to prepare for the subsequent steps.
[0010] According to the method for detecting the appearance quality of a casting based on machine vision provided by the present invention, the obtaining of the thick regions, thin regions, and all local maximum points in the X-ray gray-scale image of the casting includes: processing the pixel points in the X-ray gray-scale image of the casting using the Otsu threshold method to obtain the pixel points of the thick regions and the pixel points of the thin regions; using the non-maximum suppression algorithm to obtain the local maximum points in the X-ray gray-scale image of the casting.
[0011] According to the method for detecting the appearance quality of a casting based on machine vision provided by the present invention, the determining of the analysis pixel points from the local maximum points according to the gradient magnitude of the local maximum points and their eight-neighbor pixel points includes: if the gradient magnitude of a local maximum point is greater than the gradient magnitudes of its eight-neighbor pixel points, then this local maximum point is an analysis pixel point.
[0012] According to the method for detecting the appearance quality of a casting based on machine vision provided by the present invention, the determining of the probability that the analysis pixel point belongs to the pore edge in the color domain includes: ; is the probability that the i-th analysis pixel point belongs to the pore edge in the color domain, is the gray value of the i-th analysis pixel point, is the gray mean value of the thick region or thin region where the i-th analysis pixel point is located, is the gray variance in the eight-neighborhood of the i-th analysis pixel point, is the absolute value symbol, is the linear normalization function.
[0013] In the present invention, considering that in the color domain, there are significant differences in gray values between the analysis pixel points and the background of the thick regions or thin regions where they are located, and the gray value changes in their neighborhoods are large. Therefore, by obtaining the difference between the gray value of the analysis pixel point and the gray mean value of the thick region or thin region where it is located, and the gray variance in the eight-neighborhood of this analysis pixel point, the probability that each analysis pixel point belongs to the pore edge in the color domain can be accurately obtained.
[0014] According to the method for detecting the appearance quality of castings based on machine vision provided by the present invention, obtaining a plurality of other analysis pixel points in the texture direction perpendicular to the gradient direction of the analysis pixel point to construct the reference domain of the analysis pixel point includes: respectively obtaining m other analysis pixel points above and below the texture direction perpendicular to the gradient direction of the analysis pixel point, and obtaining the reference domain of the analysis pixel point composed of 2m other analysis pixel points; where m is the number of other analysis pixel points on one side.
[0015] According to the method for detecting the appearance quality of castings based on machine vision provided by the present invention, determining the seed points of the watershed algorithm according to the probability that the analysis pixel point belongs to the edge of the air hole in the color domain and the probability that it belongs to the edge of the air hole in the spatial domain includes: taking the average value of the probability that the analysis pixel point belongs to the edge of the air hole in the color domain and the probability that it belongs to the edge of the air hole in the spatial domain as the probability that the analysis pixel point is the edge of the air hole; determining the seed points of the watershed algorithm according to the comparison result between the probability that the analysis pixel point is the edge of the air hole and the probability threshold.
[0016] The present invention can accurately obtain the probability that the analysis pixel point is the edge of the air hole by combining the degree to which the analysis pixel point conforms to the edge of the air hole defect in the spatial domain and the color domain, so that the edge pixel points belonging to the edge of the air hole can be accurately obtained from the analysis pixel points based on this.
[0017] According to the method for detecting the appearance quality of castings based on machine vision provided by the present invention, determining the seed points of the watershed algorithm according to the comparison result between the probability that the analysis pixel point is the edge of the air hole and the probability threshold includes: if the probability that the analysis pixel point is the edge of the air hole is greater than or equal to the probability threshold, then the analysis pixel point is the seed point of the watershed algorithm.
[0018] The present invention can effectively avoid the influence of thick and thin regions with different brightness on the selection of seed points by taking the edge pixel points of the air hole defect on the surface of the casting as seed points for region growing, so that the air hole defect region in the X-ray gray-scale image of the casting can be accurately segmented based on this.
[0019] According to the method for detecting the appearance quality of castings based on machine vision provided by the present invention, determining the seed points of the watershed algorithm according to the probability that the analysis pixel point belongs to the edge of the air hole in the color domain and the probability that it belongs to the edge of the air hole in the spatial domain to obtain the detection result of the appearance quality of the casting includes: marking the seed points and inputting them into the watershed algorithm to obtain the air hole defect region of the X-ray gray-scale image of the casting; evaluating the appearance quality of the casting according to the area ratio of the air hole defect region in the X-ray gray-scale image of the casting.
[0020] According to the method for detecting the appearance quality of castings based on machine vision provided by the present invention, evaluating the appearance quality of castings according to the area ratio of the pore defect area in the X-ray grayscale image of the casting includes: taking the number of pixel points in the pore defect area as the area of the pore defect area; if the ratio of the area of the pore defect area to the area of the X-ray grayscale image of the casting is greater than the defect threshold, the evaluation result of the X-ray grayscale image of the casting is unqualified.
[0021] The present invention has the following beneficial effects: Based on the above technical solution, in the method for detecting the appearance quality of castings based on machine vision provided by the present invention, when obtaining the pore defects on the casting, the watershed algorithm is used to process the X-ray grayscale image of the casting, and the pore defect area in the X-ray grayscale image of the casting can be accurately located. In the process of processing the X-ray grayscale image of the casting by the watershed algorithm, the present invention takes into account that there are areas with inconsistent thickness on the casting, and the bright parts are uneven, which will affect the accuracy of the selection of seed points in the watershed algorithm; therefore, the present invention analyzes the characteristic performance of each analysis pixel point that may be a seed point in the color domain and the spatial domain, and obtains the probability that each analysis pixel point belongs to the pore edge, so as to accurately locate the pore defect area on the casting. Description of the Drawings
[0022] Figure 1 It is a flowchart of the steps of the method for detecting the appearance quality of castings based on machine vision provided by the embodiment of the present invention. Detailed Embodiments
[0023] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments.
[0024] In order to accurately extract the defects on the surface of the casting, the embodiment of the present invention discloses a method for detecting the appearance quality of castings based on machine vision. Please refer to Figure 1 , Figure 1 It is a flowchart of the steps of the method for detecting the appearance quality of castings based on machine vision provided by the embodiment of the present invention. The method includes the following steps: S1: Obtain each pixel point in the X-ray grayscale image of the casting.
[0025] It should be noted that the watershed algorithm performs image segmentation by simulating the process of water flowing from local minima and gradually filling the terrain. The gray value of the image represents the height of the terrain. In the X-ray gray image of the casting, the gray value at the edge of the pore defect is usually relatively high, and the local maximum points represent high-value regions, corresponding to a relatively high possibility of the pore defect region in the image. Therefore, when segmenting the pore defect region based on the watershed algorithm, the local maximum values that may be the edges of the pore defects can be used as possible seed points for analysis, and filling can be performed from high to low.
[0026] Exemplarily, in the embodiment of the present invention, before obtaining the thick region and the thin region in the X-ray gray image of the casting, it further includes: collecting the X-ray image of the casting and performing preprocessing to obtain the X-ray gray image of the casting.
[0027] Specifically, during preprocessing, the X-ray image of the casting can be grayscale processed to convert it into a grayscale image; Gaussian filtering or median filtering can be used to eliminate noise to avoid interference by noise in subsequent gradient calculations; the image gradient can be calculated through the Sobel operator or morphology to generate a gradient amplitude map of the X-ray gray image of the casting; adaptive histogram equalization processing can be performed on the X-ray gray image of the casting to improve the brightness and contrast in the gray image; sharpening technology can be used to enhance the details of the gray image of the casting, and finally the X-ray gray image of the casting is obtained.
[0028] Among them, the preprocessing method can be specifically set according to actual needs, and the embodiment of the present invention does not limit it too much here.
[0029] Based on the above steps, each pixel point in the X-ray gray image of the casting can be obtained. However, the thicknesses of different regions on the casting are different, and the attenuation degrees of X-rays passing through these regions are different. Among them, when X-rays pass through the thick region, the attenuation is large, resulting in a darker image brightness in the thick region; when X-rays pass through the thin region, the attenuation is small, resulting in a brighter image brightness in the thin region. Uneven brightness changes will occur in the finally obtained X-ray gray image of the casting, thus affecting the accuracy of seed point selection.
[0030] Based on this, the embodiment of the present invention can first obtain the thick region and the thin region in the X-ray gray image of the casting based on the global histogram analysis method, and analyze the possibility of each local maximum point being a pore edge pixel point for different regions to determine the seed points, thereby effectively reducing the influence of uneven image brightness on seed point selection and accurately obtaining the pore defect region in the X-ray gray image of the casting, that is, performing the following steps.
[0031] S2: Obtain the thick region and the thin region in the X-ray gray image of the casting, as well as all local maximum points, and determine the analysis pixel points from the local maximum points according to the gradient amplitude sizes between the local maximum points and their eight-neighbor pixel points.
[0032] It should be noted that the Otsu threshold method is a global histogram analysis method. It divides regions based on the statistical characteristics of the image. By maximizing the between-class variance, the thick regions and thin regions in the X-ray grayscale image of the casting can be accurately divided.
[0033] Exemplarily, in the embodiment of the present invention, obtaining the thick regions and thin regions in the X-ray grayscale image of the casting includes: processing the pixel points in the X-ray grayscale image of the casting using the Otsu threshold method to obtain the pixel points of the thick regions and the pixel points of the thin regions.
[0034] Specifically, when processing the pixel points in the X-ray grayscale image of the casting using the Otsu threshold method to obtain the pixel points of the thick regions and the pixel points of the thin regions, each gray value in the X-ray grayscale image of the casting can be used as a threshold to form a set of possible thresholds; based on each threshold in the set of possible thresholds, the X-ray grayscale image of the casting is divided into an initial thick region and an initial thin region, where the pixel points greater than or equal to the threshold are marked as the pixel points in the initial thin region, and the pixel points less than the threshold are marked as the pixel points in the initial thick region; calculate the between-class variance between the initial thick region and the initial thin region, and use the threshold corresponding to the maximum between-class variance as the target threshold; based on the target threshold, obtain the pixel points of the thick regions and the pixel points of the thin regions.
[0035] Based on the above steps, the thick regions and thin regions in the X-ray grayscale image of the casting can be obtained. The local maximum points are the pixel points that may be the edges of the pore defect regions. However, the number of local maximum points in the X-ray grayscale image is usually large. To reduce the data processing volume, after obtaining the local maximum points, the local maximum points can be finely screened to accurately locate the analysis pixel points that may be the edge pixel points of the pore defect regions.
[0036] Exemplarily, in the embodiment of the present invention, obtaining the local maximum points in the X-ray grayscale image of the casting includes: using the non-maximum suppression algorithm to obtain the local maximum points in the X-ray grayscale image of the casting.
[0037] Among them, the specific steps of obtaining the local maximum points in the X-ray grayscale image of the casting through the non-maximum suppression algorithm can be implemented by the prior art, and the embodiments of the present invention will not elaborate here.
[0038] Exemplarily, in the embodiment of the present invention, determining the analysis pixel points from the local maximum points according to the gradient magnitude of the local maximum points and their eight-neighborhood pixel points includes: if the gradient magnitude of the local maximum point is greater than the gradient magnitude of its eight-neighborhood pixel points, then the local maximum point is the analysis pixel point.
[0039] Based on the above steps, the embodiments of the present invention can obtain the thick regions and thin regions in the X-ray grayscale image of the casting, as well as the analysis pixel points, so that the edge pixel points of the pore defects in the thick regions and thin regions can be accurately obtained from the analysis pixel points.
[0040] It should be further noted that there are significant differences between the analysis pixel points in the thick regions and thin regions in the X-ray grayscale image of the casting and the pore defect edges in the color domain and the spatial domain. Among them, the differences in the color domain are specifically reflected in the differences in grayscale values and the differences in the grayscale value distributions of neighboring pixel points; the differences in the spatial domain are specifically reflected in the differences in the changes in the gradient directions. Next, the embodiments of the present invention will analyze the probabilities of each analysis pixel point belonging to the pore edge in the color domain and the spatial domain respectively through the following steps S3 and S4.
[0041] S3: Determine the probability of the analysis pixel point belonging to the pore edge in the color domain according to the difference between the grayscale value of the analysis pixel point and the grayscale mean value of the thick region or thin region where the analysis pixel point is located, and the grayscale variance of the eight neighboring pixel points of the analysis pixel point.
[0042] It should be noted that in the color domain, overall, there are significant differences between the grayscale values of the thick regions and thin regions and the grayscale values of the pore edge pixel points. Among them, the difference in the grayscale value between the thick region and the pore edge pixel points is relatively large, and the contrast is greater; compared with the thick region and the pore edge pixel points, the difference in the grayscale value between the thin region and the pore edge pixel points is relatively small, and the contrast between the thin region and the pore edge pixel points is smaller. In addition, overall, the degree of chaos in the grayscale distribution in the neighborhood of the analysis pixel points in the thick regions and thin regions is less than that in the pore defect region, but in the thick regions and thin regions, the degree of chaos in the grayscale distribution in the thin region is usually higher than that in the thick region.
[0043] Based on this, the embodiments of the present invention can obtain the grayscale difference between each analysis pixel point and the grayscale of the thick region or thin region where it is located, as well as the degree of chaos in the grayscale distribution in the neighborhood of the analysis pixel point, and evaluate the possibility of each analysis pixel point belonging to the pore edge in the color domain.
[0044] Exemplarily, in the embodiments of the present invention, to calculate the probability of the analysis pixel point belonging to the pore edge in the color domain, the following relational expression can be specifically referred to: ; is the probability of the i-th analysis pixel point belonging to the pore edge in the color domain, is the grayscale value of the i-th analysis pixel point, is the grayscale mean value of the thick region or thin region where the i-th analysis pixel point is located, is the grayscale variance in the eight neighboring regions of the i-th analysis pixel point, is the absolute value symbol, is a linear normalization function.
[0045] It can be understood that if the i-th analyzed pixel is in the thick region, then is the average gray value of the thick region; conversely, if the i-th analyzed pixel is in the thin region, then is the average gray value of the thin region.
[0046] In the above formula, represents the normalized difference value between the gray value of the i-th analyzed pixel and the average gray value of the region where it is located. The larger this value is, the greater the difference between the gray value of the i-th analyzed pixel and the background gray value of the region where it is located, and the higher the possibility that the i-th analyzed pixel is an edge pixel of the pore defect region.
[0047] is used to characterize the degree of gray distribution disorder in the eight-neighborhood of the i-th analyzed pixel. The larger the gray variance in the eight-neighborhood is, the higher the degree of gray distribution disorder is, the closer its characteristics are to the characteristics of the edge pixels of the pore defect region, and the higher the possibility of being an edge pixel of the pore defect region.
[0048] Based on the above steps, analyzing the gray value of each analyzed pixel and the gray value distribution of neighboring pixels in the color domain, the probability that each analyzed pixel belongs to the pore edge in the color domain can be accurately obtained.
[0049] S4: Obtain multiple other analyzed pixels in the texture direction perpendicular to the gradient direction of the analyzed pixel to construct the reference domain of the analyzed pixel, and calculate the probability that the analyzed pixel belongs to the pore edge in the spatial domain.
[0050] It should be noted that in the spatial domain, the gradient direction of the edge pixels in the same pore defect region changes relatively chaotically, and the pore distribution is relatively dense. Therefore, the Euclidean distance between the edge pixels in the same pore defect region is relatively small, while for the analyzed pixels caused by the uneven thickness on the casting surface, the change of their gradient direction is relatively uniform and continuous, and the Euclidean distance between the edge pixels is relatively large.
[0051] Based on this, the embodiment of the present invention can obtain multiple other analyzed pixels adjacent to the current analyzed pixel as the reference domain of the current analyzed pixel in the texture direction perpendicular to the gradient direction of each analyzed pixel, analyze the change of the gradient direction and the Euclidean distance difference of the current analyzed pixel in the reference domain, and evaluate the possibility that the current analyzed pixel belongs to the pore edge in the spatial domain.
[0052] Exemplarily, in the embodiments of the present invention, obtaining a plurality of other analysis pixel points in the texture direction perpendicular to the gradient direction of the analysis pixel point to construct the reference domain of the analysis pixel point includes: respectively obtaining m other analysis pixel points above and below the texture direction perpendicular to the gradient direction of the analysis pixel point, and obtaining the reference domain of the analysis pixel point composed of 2m other analysis pixel points.
[0053] Wherein, m is the number of other analysis pixel points on one side of the texture direction perpendicular to the gradient direction of the analysis pixel point, and m can be set to 10; the value of m can be specifically set according to actual needs.
[0054] Specifically, along the texture direction perpendicular to the gradient direction of the current analysis pixel point, respectively obtain the m other analysis pixel points closest to the current analysis pixel point, and a total of 2m other analysis pixel points are obtained.
[0055] It can be understood that the above-mentioned other analysis pixel points are only used to distinguish the current analysis pixel point from other analysis pixel points except the current analysis pixel point, and have no other meaning. If the number of other analysis pixel points on one side of the texture direction perpendicular to the gradient direction of the current analysis pixel point is less than m, analysis can be performed based on the actual number of other analysis pixel points obtained.
[0056] Exemplarily, in the embodiments of the present invention, calculating the probability that the analysis pixel point belongs to the pore edge in the spatial domain can be specifically referred to the following relational expression: ; is the probability that the i-th analysis pixel point belongs to the pore edge in the spatial domain, is the gradient amplitude of the i-th analysis pixel point, is the variance of the gradient directions of the analysis pixel points in the reference domain of the i-th analysis pixel point, is the maximum value of the variance of the gradient directions of the analysis pixel points in the reference domains of all analysis pixel points, is the average Euclidean distance between each analysis pixel point in the reference domain of the i-th analysis pixel point and the i-th analysis pixel point, is the maximum value of the average Euclidean distance between each analysis pixel point in the reference domains of all analysis pixel points and the i-th analysis pixel point.
[0057] In the above formula, represents the normalized value of the gradient amplitude of the i-th analysis pixel point, represents the normalized value of the variance of the gradient directions of the analysis pixel points in the reference domain of the i-th analysis pixel point, represents the normalized value of the average Euclidean distance between each analysis pixel point in the reference domain of the i-th analysis pixel point and the i-th analysis pixel point.
[0058] The larger the normalized value of the variance of the gradient direction in the reference domain of the i-th analyzed pixel, the more chaotic the gradient direction of the i-th analyzed pixel. If the normalized value of the average Euclidean distance between each analyzed pixel in the reference domain of the i-th analyzed pixel and the i-th analyzed pixel is smaller, it indicates that the distance between each analyzed pixel in the reference domain of the i-th analyzed pixel and the i-th analyzed pixel is closer, and the aggregation degree is higher.
[0059] In summary, if and are larger, and is smaller, then the probability that the i-th analyzed pixel belongs to the pore edge in the spatial domain is greater. Based on the above steps, the probability that each analyzed pixel in the X-ray grayscale image of the casting belongs to the pore edge in the spatial domain can be obtained.
[0060] S5: Determine the seed points of the watershed algorithm according to the probability that the analyzed pixel belongs to the pore edge in the color domain and the probability that it belongs to the pore edge in the spatial domain, so as to obtain the detection result of the appearance quality of the casting.
[0061] It can be understood that there is no fixed order between the above steps S3 and S4. Step S3 can be executed first, and then step S4; or step S4 can be executed first, and then step S3. Specifically, it can be set according to actual needs, and the embodiments of the present invention do not limit this too much here.
[0062] After analyzing the probability that each analyzed pixel belongs to the pore edge in the color domain and the spatial domain respectively based on the above steps, the probability that each analyzed pixel is the pore edge can be accurately obtained based on the probability that each analyzed pixel belongs to the pore edge in the color domain and the spatial domain respectively, so that the edge pixels of the pore defect area can be accurately obtained based on this.
[0063] Exemplarily, in the embodiments of the present invention, determining the seed points of the watershed algorithm according to the probability that the analyzed pixel belongs to the pore edge in the color domain and the probability that it belongs to the pore edge in the spatial domain includes: taking the average of the probability that the analyzed pixel belongs to the pore edge in the color domain and the probability that it belongs to the pore edge in the spatial domain as the probability that the analyzed pixel is the pore edge; determining the seed points of the watershed algorithm according to the comparison result between the probability that the analyzed pixel is the pore edge and the probability threshold.
[0064] Among them, the probability threshold can be set to 0.6; the probability threshold can be specifically set according to actual needs, and the embodiments of the present invention do not limit this too much here.
[0065] It can be understood that if the probability that the analyzed pixel point is the edge of the air hole is greater than or equal to the probability threshold, it indicates that the analyzed pixel point is the edge pixel point of the air hole defect area. When identifying the air hole defect area in the X-ray gray-scale image of the casting based on the watershed algorithm, the edge pixel points of the air hole defect area can be used as the seed points of the watershed algorithm, and the seed points can be used as the initial markers, and finally the air hole defect area in the X-ray gray-scale image of the casting can be accurately obtained.
[0066] Exemplarily, in the embodiment of the present invention, determining the seed points of the watershed algorithm according to the comparison result between the probability that the analyzed pixel point is the edge of the air hole and the probability threshold includes: if the probability that the analyzed pixel point is the edge of the air hole is greater than or equal to the probability threshold, then the analyzed pixel point is the seed point of the watershed algorithm.
[0067] Exemplarily, in the embodiment of the present invention, determining the seed points of the watershed algorithm according to the probability that the analyzed pixel point belongs to the edge of the air hole in the color domain and the probability that the analyzed pixel point belongs to the edge of the air hole in the spatial domain to obtain the detection result of the appearance quality of the casting includes: after marking the seed points, inputting them into the watershed algorithm to obtain the air hole defect area of the X-ray gray-scale image of the casting; evaluating the appearance quality of the casting according to the area ratio of the air hole defect area in the X-ray gray-scale image of the casting.
[0068] Specifically, mark the seed points, start growing from the seed points, construct watersheds at the boundaries of different regions. When all pixel points are assigned to the corresponding regions, the watersheds divide the regions in the X-ray gray-scale image of the casting and perform morphological operations, and finally obtain the air hole defect area of the X-ray gray-scale image of the casting.
[0069] Exemplarily, in the embodiment of the present invention, evaluating the appearance quality of the casting according to the area ratio of the air hole defect area in the X-ray gray-scale image of the casting includes: taking the number of pixel points in the air hole defect area as the area of the air hole defect area; if the ratio of the area of the air hole defect area to the area of the X-ray gray-scale image of the casting is greater than the defect threshold, the evaluation result of the X-ray gray-scale image of the casting is unqualified; otherwise, the evaluation result of the X-ray gray-scale image of the casting is qualified.
[0070] Among them, the defect threshold can be set to 8% of the area of the X-ray gray-scale image of the casting; the defect threshold can be specifically set according to the quality standard of the casting, and the embodiment of the present invention does not limit it too much here.
[0071] It can be seen that in the embodiments of the present invention, when evaluating the quality of the X-ray grayscale image of the casting, the thick regions and thin regions in the X-ray grayscale image of the casting, as well as all local maximum points, can be obtained. The analysis pixel points are determined from the local maximum points according to the gradient magnitude between the local maximum points and their eight-neighbor pixel points; according to the difference between the grayscale value of the analysis pixel point and the grayscale mean value of the thick region or thin region where the analysis pixel point is located, and the grayscale variance of the eight-neighbor pixel points of the analysis pixel point, the probability that the analysis pixel point belongs to the pore edge in the color domain is determined; multiple other analysis pixel points are obtained in the texture direction perpendicular to the gradient direction of the analysis pixel point to construct the reference domain of the analysis pixel point, and the probability that the i-th analysis pixel point belongs to the pore edge in the spatial domain is calculated. : ; is the gradient amplitude of the i-th analysis pixel point, is the gradient direction variance of the analysis pixel points in the reference domain of the i-th analysis pixel point, is the maximum value of the gradient direction variances of the analysis pixel points in the reference domains of all analysis pixel points, is the average Euclidean distance between each analysis pixel point in the reference domain of the i-th analysis pixel point and the i-th analysis pixel point, is the maximum value of the average Euclidean distances between each analysis pixel point in the reference domains of all analysis pixel points and the i-th analysis pixel point; the seed points of the watershed algorithm are determined according to the probability that the analysis pixel point belongs to the pore edge in the color domain and the probability that the analysis pixel point belongs to the pore edge in the spatial domain, so as to obtain the detection result of the appearance quality of the casting, effectively improving the accuracy of the quality evaluation of the casting.
[0072] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for detecting the appearance quality of castings based on machine vision, characterized in that Including: Obtain the thick regions, thin regions, and all local maximum points in the X-ray grayscale image of the casting. Determine the analysis pixel points from the local maximum points according to the gradient magnitude between the local maximum points and their eight-neighbor pixel points. Determine the probability that the analysis pixel point belongs to the pore edge in the color domain according to the difference between the grayscale value of the analysis pixel point and the grayscale mean value of the thick region or thin region where the analysis pixel point is located, and the grayscale variance of the eight-neighbor pixel points of the analysis pixel point. Obtain multiple other analysis pixel points in the texture direction perpendicular to the gradient direction of the analysis pixel point to construct the reference domain of the analysis pixel point, and calculate the probability that the i-th analysis pixel point belongs to the pore edge in the spatial domain : ; is the gradient magnitude of the i-th analyzed pixel point, is the variance of the gradient directions of the analyzed pixel points in the reference domain of the i-th analyzed pixel point, is the maximum value of the variances of the gradient directions of the analyzed pixel points in the reference domains of all analyzed pixel points, is the average Euclidean distance between each analyzed pixel point and the i-th analyzed pixel point in the reference domain of the i-th analyzed pixel point, is the maximum value of the average Euclidean distances between each analyzed pixel point and the i-th analyzed pixel point in the reference domains of all analyzed pixel points; determine the seed points of the watershed algorithm according to the probability that the analyzed pixel point belongs to the pore edge in the color domain and the probability that it belongs to the pore edge in the spatial domain, so as to obtain the detection result of the appearance quality of the casting.
2. The method for detecting the appearance quality of castings based on machine vision according to claim 1, wherein Before the step of obtaining the thick regions and thin regions in the X-ray grayscale image of the casting, it further includes: Collect the X-ray image of the casting and perform preprocessing to obtain the X-ray grayscale image of the casting.
3. The method for detecting the appearance quality of castings based on machine vision according to claim 1, characterized in that, The step of obtaining the thick regions, thin regions, and all local maximum points in the X-ray grayscale image of the casting includes: Use the Otsu threshold method to process the pixel points in the X-ray grayscale image of the casting to obtain the pixel points of the thick regions and the pixel points of the thin regions. Use the non-maximum suppression algorithm to obtain the local maximum points in the X-ray grayscale image of the casting.
4. The method for detecting the appearance quality of castings based on machine vision according to claim 1, wherein The step of determining the analysis pixel points from the local maximum points according to the gradient magnitude between the local maximum points and their eight-neighbor pixel points includes: If the gradient magnitude of the local maximum point is greater than the gradient magnitudes of its eight-neighbor pixel points, then the local maximum point is the analysis pixel point.
5. The method for detecting the appearance quality of castings based on machine vision according to claim 1, wherein, The step of determining the probability that the analysis pixel point belongs to the pore edge in the color domain includes: ; is the probability that the i-th analyzed pixel belongs to the pore edge in the color domain, is the gray value of the i-th analyzed pixel, is the average gray value of the thick or thin region where the i-th analyzed pixel is located, is the gray variance in the eight-neighborhood of the i-th analyzed pixel, is the absolute value symbol, is the linear normalization function.
6. The method for detecting the appearance quality of castings based on machine vision according to claim 1, characterized in that, The step of obtaining multiple other analysis pixel points in the texture direction perpendicular to the gradient direction of the analysis pixel point to construct the reference domain of the analysis pixel point includes: Obtain m other analysis pixel points respectively above and below the texture direction perpendicular to the gradient direction of the analysis pixel point to obtain the reference domain of the analysis pixel point composed of 2m other analysis pixel points; where m is the number of other analysis pixel points on one side.
7. The method for detecting the appearance quality of castings based on machine vision according to claim 1, characterized in that, The step of determining the seed points of the watershed algorithm according to the probability that the analysis pixel point belongs to the pore edge in the color domain and the probability that the analysis pixel point belongs to the pore edge in the spatial domain includes: Take the average of the probability that the analysis pixel point belongs to the pore edge in the color domain and the probability that the analysis pixel point belongs to the pore edge in the spatial domain as the probability that the analysis pixel point is the pore edge. Determine the seed points of the watershed algorithm according to the comparison result between the probability that the analysis pixel point is the pore edge and the probability threshold.
8. The method for detecting the appearance quality of castings based on machine vision according to claim 7, wherein The step of determining the seed points of the watershed algorithm according to the comparison result between the probability that the analysis pixel point is the pore edge and the probability threshold includes: If the probability that the analysis pixel point is the pore edge is greater than or equal to the probability threshold, then the analysis pixel point is the seed point of the watershed algorithm.
9. The method for detecting the appearance quality of castings based on machine vision according to claim 1, wherein, The step of determining the seed points of the watershed algorithm according to the probability that the analysis pixel point belongs to the pore edge in the color domain and the probability that the analysis pixel point belongs to the pore edge in the spatial domain to obtain the casting appearance quality detection result includes: Mark the seed points and input them into the watershed algorithm to obtain the pore defect region in the X-ray grayscale image of the casting; evaluate the casting appearance quality according to the area ratio of the pore defect region in the X-ray grayscale image of the casting.
10. The method for detecting the appearance quality of castings based on machine vision according to claim 9, wherein, The step of evaluating the casting appearance quality according to the area ratio of the pore defect region in the X-ray grayscale image of the casting includes: Take the number of pixel points in the pore defect area as the area of the pore defect area; if the ratio of the area of the pore defect area to the area of the X-ray gray-scale image of the casting is greater than the defect threshold, the evaluation result of the X-ray gray-scale image of the casting is unqualified.
Citation Information
Patent Citations
Method for segmenting abdominal organ in medical image
CN101013503A
Method and device for identifying bezel of light bundling device, computer equipment and storage medium
CN114266799A
Casting surface defect detection method based on computer vision
CN116758061A
OCA film bubble detection method based on computer vision
CN117557573A
Alloy casting machining quality detection method based on machine vision
CN118762028A
Cited By
Compressor casting quality evaluation method and system based on metallographic analysis
CN122200204A
A method and system for quality assessment of compressor castings based on metallographic analysis
CN122200204B