Casting appearance quality inspection method based on machine vision

By analyzing the thickness and thinness area characteristics and the gradient differences of local maximum points in the X-ray grayscale image of the casting, combining the color and spatial domain characteristics, and selecting accurate seed points for watershed algorithm processing, the problem of uneven thickness in the finished casting structure affecting the positioning of porosity defects is solved, and the accuracy of casting appearance quality inspection is improved.

CN120198442BActive Publication Date: 2025-09-12陕西炬星海工贸有限责任公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510691854.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-27
Publication Date
2025-09-12
Estimated Expiration
2045-05-27

AI Technical Summary

Technical Problem

In the existing technology, the uneven thickness of regional features in the finished casting structure affects the accuracy of locating porosity defects, resulting in poor selection of seed points for the watershed algorithm and missed detection of pixels in the bubble defect area.

Method used

By acquiring the thick and thin areas in the X-ray grayscale image of the casting, analyzing the gradient amplitude and grayscale value difference of the local maximum point, combining the color domain and spatial domain characteristics, determining the probability of the pore edge, selecting the accurate seed point for watershed algorithm processing, and accurately locating the pore defect area.

Benefits of technology

The accuracy of casting appearance quality inspection is improved, the influence of uneven thickness areas on seed point selection is effectively reduced, and the complete segmentation of the porosity defect area is ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120198442B_ABST
    Figure CN120198442B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of casting image data processing, and more specifically, to a casting appearance quality detection method based on machine vision. The method comprises: determining an analysis pixel point in an X-ray grayscale image of a casting; determining the probability that the analysis pixel point belongs to a pore edge in a color domain based on a difference between a grayscale value of the analysis pixel point and a grayscale mean value of a thick region or a thin region where the analysis pixel point is located, and a grayscale variance of pixels in eight neighborhoods of the analysis pixel point; acquiring a plurality of other analysis pixels points in a texture direction perpendicular to a gradient direction of the analysis pixel point to construct a reference domain for the analysis pixel point, and calculating the probability that the analysis pixel point belongs to a pore edge in a spatial domain; and determining a seed point of a watershed algorithm based on the probability that the analysis pixel point belongs to a pore edge in the color domain and in the spatial domain, so as to obtain a casting appearance quality detection result, thereby effectively improving the accuracy of casting quality assessment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of casting image data processing, and more particularly to a casting appearance quality detection method based on machine vision. Background Art

[0002] A casting is a workpiece of a defined shape and size obtained by pouring molten metal into a mold cavity that matches the desired part shape. After cooling and solidifying, the finished part undergoes quality inspection to ensure its performance.

[0003] The development of machine vision has provided a new solution for inspecting the appearance quality of castings. During this process, X-rays are used to penetrate the casting and construct a two-dimensional image of the casting's internal structure, enabling the detection of subtler defects such as porosity. Porosity is caused by bubbles of gas trapped in the molten metal during the casting process, which eventually remain inside or on the surface of the casting after solidification.

[0004] Currently, the watershed algorithm is often used to segment and locate porosity defects in X-ray images of castings. This algorithm describes the image's grayscale values ​​as a topographic map and simulates the process of water flowing from a local minimum and gradually filling the terrain. Ultimately, the image is divided into distinct regions, allowing porosity defects to be extracted. However, finished castings often have areas of varying thickness. This variation manifests as uneven brightness in X-ray images of castings, leading to poor seed point selection when using the watershed algorithm to segment porosity defects, ultimately resulting in missed detection of pixels in the bubble defect area.

[0005] Therefore, it is urgent to solve the influence of the uneven thickness regional characteristics in the finished casting structure on the accuracy of porosity defect positioning. Summary of the Invention

[0006] In order to solve the technical problem that the uneven thickness of the finished casting structure affects the accuracy of locating porosity defects, the present invention proposes a method for detecting the appearance quality of castings based on machine vision, which includes the following steps:

[0007] Obtain thick and thin areas and all local maximum points in the X-ray grayscale image of the casting, and determine the analysis pixel from the local maximum point based on the gradient amplitude of the local maximum point and its eight neighboring pixel points; determine the probability that the analysis pixel belongs to the pore edge in the color domain based on the difference between the grayscale value of the analysis pixel point and the grayscale mean value of the thick or thin area where the analysis pixel point is located, and the grayscale variance of the eight neighboring pixel points of the analysis pixel point; obtain multiple other analysis pixels in the texture direction perpendicular to the gradient direction of the analysis pixel point to construct a reference domain for the analysis pixel point, and calculate the probability that the i-th analysis pixel point belongs to the pore edge in the spatial domain. :

[0008] ; is the gradient amplitude of the i-th analysis pixel, is the gradient direction variance of the analysis pixel in the reference domain of the i-th analysis pixel, is the maximum value of the gradient direction variance of the analysis pixel in the reference domain of all analysis pixels, is the mean Euclidean distance between each analysis pixel and the i-th analysis pixel in the reference domain of the i-th analysis pixel, The maximum value of the mean Euclidean distance between each analysis pixel and the i-th analysis pixel in the reference domain of all analysis pixels is determined; the seed point of the watershed algorithm is determined 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 to obtain the casting appearance quality inspection result.

[0009] The present invention uses a watershed algorithm to process X-ray grayscale images of castings, accurately locating pore defect areas within these images. In processing X-ray grayscale images using the watershed algorithm, the present invention takes into account that castings may have areas of inconsistent thickness and uneven brightness, which can affect the accuracy of the watershed algorithm's seed point selection. Therefore, the present invention analyzes the characteristic representation of each potential seed point in the color and spatial domains to determine the probability that each analysis pixel belongs to a pore edge, thereby accurately locating pore defect areas on the casting.

[0010] According to the method for detecting the appearance quality of castings based on machine vision provided by the present invention, the method of obtaining thick areas and thin areas in the X-ray grayscale image of the casting further includes: collecting the X-ray image of the casting and preprocessing it to obtain the X-ray grayscale image of the casting.

[0011] The present invention takes into account that when locating the pore defect area, the local maximum point that may be the edge of the pore defect can be used as the seed point, but the watershed algorithm usually grows the local minimum point as the seed point. Therefore, before processing the casting X-ray grayscale image, the present invention can perform gradient inversion preprocessing on the casting X-ray grayscale image to convert the local minimum point into the local maximum point to prepare for the subsequent process.

[0012] According to the method for detecting the appearance quality of castings based on machine vision provided by the present invention, the method of obtaining thick areas and thin areas, as well as all local maximum points, in the X-ray grayscale image of the casting includes: using the Otsu threshold method to process the pixel points in the X-ray grayscale image of the casting to obtain pixel points in the thick areas and pixel points in the thin areas; and using a non-maximum suppression algorithm to obtain local maximum points in the X-ray grayscale image of the casting.

[0013] According to the casting appearance quality inspection method based on machine vision provided by the present invention, the analysis pixel point is determined from the local maximum point according to the gradient amplitude of the local maximum point and its eight neighboring pixel points, including: if the gradient amplitude of the local maximum point is greater than the gradient amplitude of its eight neighboring pixel points, then the local maximum point is the analysis pixel point.

[0014] According to the casting appearance quality inspection method based on machine vision provided by the present invention, determining the probability that the analysis pixel point belongs to the edge of a pore in the color domain includes:

[0015] ;

[0016] 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 grayscale mean of the thick area or thin area where the i-th analysis pixel is located, is the grayscale variance in the eight neighborhoods of the i-th analyzed pixel, is the absolute value symbol, is a linear normalization function.

[0017] The present invention takes into account that in the color domain, there is a significant difference in the grayscale of the analysis pixel point and the thick area background or thin area background where it is located, and the grayscale variation in its neighborhood is large. Therefore, the present invention obtains the difference between the grayscale value of the analysis pixel point and the grayscale mean of the thick area or thin area where it is located, as well as the grayscale variance in the eight neighborhoods of the analysis pixel point, to accurately obtain the probability that each analysis pixel point belongs to the pore edge in the color domain.

[0018] According to the casting appearance quality inspection method based on machine vision provided by the present invention, the method of acquiring multiple other analysis pixels in a texture direction perpendicular to the gradient direction of the analysis pixel point to construct a reference domain of the analysis pixel point includes: acquiring m other analysis pixels above and below the texture direction perpendicular to the gradient direction of the analysis pixel point, respectively, to obtain a reference domain of the analysis pixel point composed of 2m other analysis pixels; where m is the number of other analysis pixels on a single side.

[0019] According to the casting appearance quality inspection method based on machine vision provided by the present invention, the seed point of the watershed algorithm is determined based on the probability of the analyzed pixel point belonging to the pore edge in the color domain and the probability of the analyzed pixel point belonging to the pore edge in the spatial domain, including: taking the average of the probability of the analyzed pixel point belonging to the pore edge in the color domain and the probability of the analyzed pixel point belonging to the pore edge in the spatial domain as the probability that the analyzed pixel point is the pore edge; and determining the seed point of the watershed algorithm based on the comparison result of the probability of the analyzed pixel point being the pore edge with the probability threshold.

[0020] By combining the degree to which the analysis pixel points conform to the pore defect edge in the spatial domain and the color domain, the present invention can accurately obtain the probability that the analysis pixel points are pore edges, and thus accurately obtain edge pixel points belonging to the pore edge from the analysis pixel points.

[0021] According to the method for detecting the appearance quality of castings based on machine vision provided by the present invention, the seed point of the watershed algorithm is determined based on the comparison result of the probability that the analysis pixel point is the edge of a pore and the probability threshold, including: if the probability that the analysis pixel point is the edge of a pore is greater than or equal to the probability threshold, then the analysis pixel point is the seed point of the watershed algorithm.

[0022] The present invention obtains the edge pixel points of the pore defects on the surface of the casting as seed points for region growth, which can effectively avoid the influence of thick and thin areas with different brightness on the selection of seed points, so that the pore defect area in the X-ray grayscale image of the casting can be accurately segmented based on this.

[0023] According to the machine vision-based casting appearance quality inspection method provided by the present invention, the seed points of the watershed algorithm are determined based on the probability of analyzing the pixel points belonging to the pore edge in the color domain and the probability of belonging to the pore edge in the spatial domain to obtain the casting appearance quality inspection results, including: marking the seed points and inputting them into the watershed algorithm to obtain the pore defect area in the casting X-ray grayscale image; and evaluating the casting appearance quality according to the area ratio of the pore defect area in the casting X-ray grayscale image.

[0024] According to the method for detecting the appearance quality of castings based on machine vision provided by the present invention, the method for evaluating the appearance quality of castings based on the area ratio of the porosity defect area in the X-ray grayscale image of the casting includes: taking the number of pixels in the porosity defect area as the area of ​​the porosity defect area; if the ratio of the area of ​​the porosity 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.

[0025] The present invention has the following beneficial effects:

[0026] Based on the above technical solution, the present invention provides a method for detecting the appearance quality of castings based on machine vision. When obtaining porosity defects on castings, the method processes the X-ray grayscale image of the casting using a watershed algorithm, and can accurately locate the porosity defect area in the X-ray grayscale image of the casting. In the process of processing the X-ray grayscale image of the casting using the watershed algorithm, the present invention takes into account that the casting may have areas of inconsistent thickness and uneven brightness, which will affect the accuracy of the watershed algorithm seed point selection; therefore, the present invention analyzes the characteristic performance of each analysis pixel point that may be a seed point in the color domain and spatial domain to obtain the probability that each analysis pixel point belongs to the edge of a porosity, thereby accurately locating the porosity defect area on the casting. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] Figure 1 The figure is a flowchart of the steps of the method for detecting the appearance quality of castings based on machine vision provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0028] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, but not all of the embodiments.

[0029] In order to accurately extract defects on the surface of castings, the embodiment of the present invention discloses a method for detecting the appearance quality of castings based on machine vision. Figure 1 , Figure 1 1 is a flowchart of a method for detecting the appearance quality of castings based on machine vision provided by an embodiment of the present invention, the method comprising the following steps:

[0030] S1: Obtain each pixel point in the X-ray grayscale image of the casting.

[0031] It should be noted that the watershed algorithm performs image segmentation by simulating the process of water flowing from the local minimum and gradually filling the terrain. The grayscale value of the image represents the height of the terrain. In the X-ray grayscale image of the casting, the grayscale value of the edge of the porosity defect is usually higher. The local maximum point represents a high-value area, which is more likely to correspond to the porosity defect area in the image. Therefore, when segmenting the porosity defect area based on the watershed algorithm, the local maximum point that may be the edge of the porosity defect can be analyzed as a possible seed point to fill it from high to low.

[0032] For example, in an embodiment of the present invention, obtaining thick areas and thin areas in an X-ray grayscale image of a casting further includes: acquiring an X-ray image of the casting and performing preprocessing to obtain an X-ray grayscale image of the casting.

[0033] Specifically, during preprocessing, the X-ray image of the casting can be grayscaled and converted into a grayscale image; Gaussian filtering or median filtering can be used to eliminate noise to avoid noise interference in subsequent gradient calculations; the image gradient is calculated through the Sobel operator or morphology to generate a gradient amplitude map of the X-ray grayscale image of the casting; adaptive histogram equalization is performed on the X-ray grayscale image of the casting to improve the brightness and contrast in the grayscale image; sharpening technology is used to enhance the details of the grayscale image of the casting, and finally the X-ray grayscale image of the casting is obtained.

[0034] The preprocessing method can be specifically set according to actual needs, and the embodiment of the present invention does not impose too many restrictions on this.

[0035] Based on the above steps, each pixel in the X-ray grayscale image of the casting can be obtained. However, different regions of the casting have different thicknesses, and the X-rays attenuate differently when penetrating these regions. X-rays attenuate more when penetrating thick regions, resulting in a darker image brightness. X-rays attenuate less when penetrating thin regions, resulting in a brighter image brightness. The resulting X-ray grayscale image of the casting will have uneven brightness variations, which affects the accuracy of seed point selection.

[0036] Based on this, the embodiment of the present invention can first obtain the thick areas and thin areas in the X-ray grayscale 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 in different areas to determine the seed point, thereby effectively reducing the impact of uneven image brightness on seed point selection, and accurately obtaining the pore defect area in the X-ray grayscale image of the casting, that is, executing the following steps.

[0037] S2: Obtain thick and thin areas and all local maximum points in the X-ray grayscale image of the casting, and determine the analysis pixel points from the local maximum points based on the gradient amplitude between the local maximum point and its eight neighboring pixels.

[0038] It should be noted that the Otsu threshold method is a global histogram analysis method that performs region division based on the statistical characteristics of the image. By maximizing the inter-class variance, it can accurately divide the thick and thin areas in the X-ray grayscale image of the casting.

[0039] For example, in an embodiment of the present invention, obtaining thick areas and thin areas in an X-ray grayscale image of a casting includes: using the Otsu threshold method to process pixel points in the X-ray grayscale image of the casting to obtain pixel points in the thick area and pixel points in the thin area.

[0040] Specifically, when the Otsu threshold method is used to process the pixel points in the X-ray grayscale image of the casting to obtain the pixel points in the thick area and the pixel points in the thin area, each grayscale value in the X-ray grayscale image of the casting can be used as a threshold to form a possible threshold set; based on each threshold in the possible threshold set, the X-ray grayscale image of the casting is divided into an initial thick area and an initial thin area, wherein the pixel points greater than or equal to the threshold are marked as pixel points in the initial thin area, and the pixel points less than the threshold are marked as pixel points in the initial thick area; the inter-class variance between the initial thick area and the initial thin area is calculated, and the threshold corresponding to the maximum value of the inter-class variance is used as the target threshold; based on the target threshold, the pixel points in the thick area and the pixel points in the thin area are obtained.

[0041] Based on the above steps, thick and thin areas in the X-ray grayscale image of the casting can be obtained, and the local maximum points are pixels that may be the edges of the porosity defect area. However, the number of local maximum points in the X-ray grayscale image is usually large. In order to reduce the amount of data processing, after obtaining the local maximum points, the local maximum points can be finely screened to accurately locate the analysis pixels that may be the edges of the porosity defect area.

[0042] For example, in an embodiment of the present invention, obtaining a local maximum point in an X-ray grayscale image of a casting includes: obtaining a local maximum point in the X-ray grayscale image of the casting using a non-maximum suppression algorithm.

[0043] The specific steps of obtaining the local maximum points in the X-ray grayscale image of the casting by using the non-maximum suppression algorithm can be implemented by existing technologies, and will not be described in detail in the embodiment of the present invention.

[0044] For example, in an embodiment of the present invention, an analysis pixel point is determined from a local maximum point based on the gradient amplitude of the local maximum point and its eight neighboring pixel points, including: if the gradient amplitude of the local maximum point is greater than the gradient amplitude of its eight neighboring pixel points, then the local maximum point is the analysis pixel point.

[0045] Based on the above steps, the embodiment of the present invention can obtain thick areas and thin areas in the casting X-ray grayscale image, as well as analysis pixel points, so that the edge pixel points of pore defects in the thick areas and thin areas can be accurately obtained from the analysis pixel points.

[0046] It should be further explained that the analysis pixels in thick and thin regions of a casting's X-ray grayscale image differ significantly from the edges of pore defects in both the color and spatial domains. The color domain differences manifest themselves in grayscale value differences and grayscale value distribution differences among neighboring pixels; the spatial domain differences manifest themselves in differences in gradient direction. This embodiment of the present invention analyzes the probability of each analysis pixel belonging to a pore edge in both the color and spatial domains, respectively, through steps S3 and S4.

[0047] S3: Determine the probability that the analysis pixel belongs to the stomatal edge in the color domain based on the difference between the grayscale value of the analysis pixel and the grayscale mean of the thick area or thin area where the analysis pixel is located, and the grayscale variance of the eight neighboring pixels of the analysis pixel.

[0048] It should be noted that in the color domain, the grayscale values ​​of thick and thin regions generally differ significantly from those of pixels at the pore edges. The grayscale value difference between thick and pore edge pixels is larger, resulting in greater contrast. The grayscale value difference between thin and pore edge pixels is smaller, resulting in less contrast. Furthermore, the grayscale distribution chaos within the neighborhood of the analyzed pixel is generally less in thick and thin regions than in the pore defect area. However, in both thick and thin regions, the grayscale distribution chaos in thin regions is generally higher than that in thick regions.

[0049] Based on this, the embodiment of the present invention can obtain the grayscale difference between the grayscale value of each analysis pixel point and the thick area or thin area where it is located, as well as the degree of grayscale distribution disorder in the neighborhood of the analysis pixel point, and evaluate the possibility that each analysis pixel point belongs to the pore edge in the color domain.

[0050] For example, in an embodiment of the present invention, the probability of a pixel point belonging to a pore edge in the color domain is calculated and analyzed. For details, see the following relationship:

[0051] ;

[0052] 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 grayscale mean of the thick area or thin area where the i-th analysis pixel is located, is the grayscale variance in the eight neighborhoods of the i-th analyzed pixel, is the absolute value symbol, is a linear normalization function.

[0053] It can be understood that if the i-th analysis pixel point is in a thick area, then is the grayscale mean of the thick area; conversely, if the i-th analysis pixel is in the thin area, then is the grayscale mean of the thin area.

[0054] In the above formula, It represents the normalized difference between the grayscale value of the i-th analysis pixel and the grayscale mean of the region where it is located. The larger the value, the greater the difference between the grayscale value of the i-th analysis pixel and the background grayscale of the region where it is located, and the higher the possibility that the i-th analysis pixel is the edge pixel of the pore defect region.

[0055] It is used to characterize the degree of grayscale distribution disorder in the eight-neighborhood of the i-th analyzed pixel. The larger the grayscale variance in the eight-neighborhood, the higher the degree of grayscale distribution disorder. The closer its characteristics are to those of the edge pixels of the pore defect area, the higher the possibility that it is the edge pixel of the pore defect area.

[0056] Based on the above steps, the grayscale value of each analysis pixel point in the color domain and the grayscale value distribution of the neighboring pixels are analyzed to accurately obtain the probability that each analysis pixel point belongs to the stomatal edge in the color domain.

[0057] S4: Acquire multiple other analysis pixels in a texture direction perpendicular to the gradient direction of the analysis pixel to construct a reference domain for the analysis pixel, and calculate the probability that the analysis pixel belongs to a pore edge in the spatial domain.

[0058] It should be noted that in the spatial domain, the gradient direction changes of the edge pixels in the same pore defect area are more chaotic, and the pores are distributed more densely. Therefore, the Euclidean distance between the edge pixels in the same pore defect area is small. However, the gradient direction changes of the analysis pixels caused by the inconsistent thickness on the casting surface are more uniform and continuous, and the Euclidean distance between the edge pixels is larger.

[0059] Based on this, an embodiment of the present invention can obtain multiple other analysis pixels adjacent to the current analysis pixel in the vertical texture direction of the gradient direction of each analysis pixel as a reference domain of the current analysis pixel, analyze the gradient direction change and Euclidean distance difference of the current analysis pixel in the reference domain, and evaluate the possibility that the current analysis pixel belongs to the pore edge in the spatial domain.

[0060] For example, in an embodiment of the present invention, a plurality of other analysis pixels are acquired in a texture direction perpendicular to the gradient direction of the analysis pixel to construct a reference domain of the analysis pixel, including: acquiring m other analysis pixels above and below the texture direction perpendicular to the gradient direction of the analysis pixel, respectively, to obtain a reference domain of the analysis pixel consisting of 2m other analysis pixels.

[0061] Here, m is the number of other analysis pixels on one side of the texture direction perpendicular to the gradient direction of the analysis pixel, and m can be set to 10. The value of m can be set according to actual needs.

[0062] Specifically, m other analysis pixels closest to the current analysis pixel are obtained along the texture direction perpendicular to the gradient direction of the current analysis pixel, and a total of 2m other analysis pixels are obtained.

[0063] It is understood that the aforementioned additional analysis pixels are merely used to distinguish the current analysis pixel from other analysis pixels other than the current analysis pixel and have no other meaning. If the number of additional analysis pixels on one side of the texture direction perpendicular to the gradient direction of the current analysis pixel is less than m, analysis may be performed based on the actual number of additional analysis pixels.

[0064] For example, in an embodiment of the present invention, the probability of a pixel point belonging to a pore edge in the spatial domain is calculated and analyzed. For details, see the following relationship:

[0065] ;

[0066] is 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 pixel in the reference domain of the i-th analysis pixel, is the maximum value of the gradient direction variance of the analysis pixel in the reference domain of all analysis pixels, is the mean Euclidean distance between each analysis pixel and the i-th analysis pixel in the reference domain of the i-th analysis pixel, It is the maximum mean value of the Euclidean distance between each analysis pixel and the i-th analysis pixel in the reference domain of all analysis pixels.

[0067] In the above formula, represents the normalized value of the gradient amplitude of the i-th analysis pixel, represents the normalized value of the gradient direction variance of the analysis pixel in the reference domain of the i-th analysis pixel, It represents the normalized mean Euclidean distance between each analysis pixel and the i-th analysis pixel in the reference domain of the i-th analysis pixel.

[0068] The larger the normalized value of the gradient direction variance in the reference domain of the i-th analysis pixel, the more chaotic the gradient direction of the i-th analysis pixel. The smaller the normalized value of the mean Euclidean distance between each analysis pixel in the reference domain of the i-th analysis pixel and the i-th analysis pixel, the closer the distance between each analysis pixel in the reference domain of the i-th analysis pixel and the i-th analysis pixel is, and the higher the degree of clustering.

[0069] In summary, if and The bigger, and The smaller , the greater the probability that the i-th analysis pixel point belongs to the pore edge in the spatial domain. Based on the above steps, the probability that each analysis pixel point in the casting X-ray grayscale image belongs to the pore edge in the spatial domain can be obtained.

[0070] S5: Determine the seed point of the watershed algorithm based on the probability of the pixel point belonging to the pore edge in the color domain and the probability of the pixel point belonging to the pore edge in the spatial domain to obtain the casting appearance quality inspection result.

[0071] It is understandable that there is no fixed order for 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. The specific order can be set according to actual needs, and the embodiments of the present invention do not impose too many restrictions on this.

[0072] After analyzing the probability of each analysis pixel point belonging to the pore edge in the color domain and the spatial domain respectively based on the above steps, the probability of each analysis pixel point being the pore edge can be accurately obtained based on the probability of each analysis pixel point belonging to the pore edge in the color domain and the spatial domain respectively, so that the edge pixel points of the pore defect area can be accurately obtained based on this.

[0073] For example, in an embodiment of the present invention, the seed point of the watershed algorithm is determined based on the probability that the analysis pixel point belongs to the stomatal edge in the color domain and the probability that it belongs to the stomatal edge in the spatial domain, including: taking the average of the probability that the analysis pixel point belongs to the stomatal edge in the color domain and the probability that it belongs to the stomatal edge in the spatial domain as the probability that the analysis pixel point is the stomatal edge; and determining the seed point of the watershed algorithm based on the comparison result of the probability that the analysis pixel point is the stomatal edge and the probability threshold.

[0074] The probability threshold may be set to 0.6. The probability threshold may be set according to actual needs, and the embodiment of the present invention does not impose any additional restrictions thereon.

[0075] It can be understood that if the probability that the analysis pixel point is the edge of a pore is greater than or equal to the probability threshold, it means that the analysis pixel point is the edge pixel point of the pore defect area. When identifying the pore defect area in the X-ray grayscale image of the casting based on the watershed algorithm, the edge pixel point of the pore defect area can be used as the seed point of the watershed algorithm, and the seed point can be used as the initial mark, and finally the pore defect area in the X-ray grayscale image of the casting can be accurately obtained.

[0076] For example, in an embodiment of the present invention, the seed point of the watershed algorithm is determined based on the comparison result of the probability that the analysis pixel point is the edge of a pore and the probability threshold, including: if the probability that the analysis pixel point is the edge of a pore is greater than or equal to the probability threshold, then the analysis pixel point is the seed point of the watershed algorithm.

[0077] For example, in an embodiment of the present invention, the seed point of the watershed algorithm is determined based on the probability of analyzing the pixel point belonging to the edge of the pore in the color domain and the probability of belonging to the edge of the pore in the spatial domain to obtain the casting appearance quality detection result, including: marking the seed point and inputting it into the watershed algorithm to obtain the pore defect area of ​​the casting X-ray grayscale image; evaluating the casting appearance quality according to the area ratio of the pore defect area in the casting X-ray grayscale image.

[0078] Specifically, the seed points are marked, growth starts from the seed points, and watersheds are constructed at the boundaries of different regions. When all pixel points are assigned to the corresponding regions, the watershed segments the regions in the X-ray grayscale image of the casting and performs morphological operations, finally obtaining the porosity defect region of the X-ray grayscale image of the casting.

[0079] For example, in an embodiment of the present invention, the appearance quality of a casting is evaluated based on the area ratio of the porosity defect area in the X-ray grayscale image of the casting, including: taking the number of pixels in the porosity defect area as the area of ​​the porosity defect area; if the ratio of the area of ​​the porosity defect area to the area of ​​the X-ray grayscale image of the casting is greater than the defect threshold, then the evaluation result of the X-ray grayscale image of the casting is unqualified; otherwise, the evaluation result of the X-ray grayscale image of the casting is qualified.

[0080] The defect threshold may be set to 8% of the area of ​​the X-ray grayscale image of the casting. The defect threshold may be specifically set according to the quality standard of the casting, and the embodiment of the present invention does not impose any excessive restrictions thereon.

[0081] It can be seen that in the embodiment of the present invention, when evaluating the quality of the X-ray grayscale image of the casting, the thick area and the thin area in the X-ray grayscale image of the casting, as well as all local maximum points, can be obtained, and the analysis pixel point is determined from the local maximum point according to the gradient amplitude of the local maximum point and its eight neighboring pixel points; the probability that the analysis pixel point belongs to the pore edge in the color domain is determined according to the difference between the grayscale value of the analysis pixel point and the grayscale mean value of the thick area or thin area where the analysis pixel point is located, and the grayscale variance of the eight neighboring pixel points of the analysis pixel point; a plurality of other analysis pixels are obtained in the texture direction perpendicular to the gradient direction of the analysis pixel point to construct a 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. :

[0082] ; is the gradient amplitude of the i-th analysis pixel, is the gradient direction variance of the analysis pixel in the reference domain of the i-th analysis pixel, is the maximum value of the gradient direction variance of the analysis pixel in the reference domain of all analysis pixels, is the mean Euclidean distance between each analysis pixel and the i-th analysis pixel in the reference domain of the i-th analysis pixel, The maximum value of the mean Euclidean distance between each analysis pixel and the i-th analysis pixel in the reference domain of all analysis pixels is determined; the seed point of the watershed algorithm is determined 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 to obtain the casting appearance quality inspection result, which effectively improves the accuracy of casting quality assessment.

[0083] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A casting appearance quality inspection method based on machine vision, characterized in that: include: Obtain thick and thin areas and all local maximum points in the X-ray grayscale image of the casting, and determine the analysis pixel from the local maximum points based on the gradient amplitude between the local maximum point and its eight neighboring pixels. Determine the probability that the analysis pixel belongs to the pore edge in the color domain based on the difference between the grayscale value of the analysis pixel and the grayscale mean of the thick or thin area where the analysis pixel is located, and the grayscale variance of the eight neighboring pixels of the analysis pixel. Acquire 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 pixel in the reference domain of the i-th analysis pixel, is the maximum value of the gradient direction variance of the analysis pixel in the reference domain of all analysis pixels, is the mean Euclidean distance between each analysis pixel and the i-th analysis pixel in the reference domain of the i-th analysis pixel, The maximum value of the mean Euclidean distance between each analysis pixel and the i-th analysis pixel in the reference domain of all analysis pixels is determined; the seed point of the watershed algorithm is determined 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 to obtain the casting appearance quality inspection result.

2. The casting appearance quality inspection method based on machine vision according to claim 1, characterized in that: The method of obtaining thick areas and thin areas in the X-ray grayscale image of the casting further includes: The X-ray images of the casting are collected and preprocessed to obtain the X-ray grayscale images 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 thick and thin areas and all local maximum points in the X-ray grayscale image of the casting are obtained, including: The pixel points in the X-ray grayscale image of the casting are processed using the Otsu threshold method to obtain the pixel points in the thick area and the pixel points in the thin area; The non-maximum suppression algorithm is used to obtain the local maximum points in the X-ray grayscale image of the casting.

4. The casting appearance quality inspection method based on machine vision according to claim 1, characterized in that: The step of determining the analysis pixel point from the local maximum point according to the gradient amplitude of the local maximum point and its eight neighboring pixel points includes: If the gradient amplitude of the local maximum point is greater than the gradient amplitude of its eight neighboring pixels, then the local maximum point is the analysis pixel point.

5. The casting appearance quality inspection method based on machine vision according to claim 1, characterized in that: Determining the probability that the analysis pixel point belongs to a 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 grayscale mean of the thick area or thin area where the i-th analysis pixel is located, is the grayscale variance in the eight neighborhoods of the i-th analyzed pixel, is the absolute value symbol, is a 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 acquiring a plurality of other analysis pixels in a texture direction perpendicular to the gradient direction of the analysis pixel to construct a reference domain for the analysis pixel includes: In the texture direction perpendicular to the gradient direction of the analysis pixel point, m other analysis pixels are obtained respectively, and a reference domain of the analysis pixel point consisting of 2m other analysis pixels is obtained; where m is the number of other analysis pixels on one side.

7. The casting appearance quality inspection method based on machine vision according to claim 1, characterized in that: The step of determining the seed point of the watershed algorithm based on analyzing the probability of the pixel point belonging to the stomatal edge in the color domain and the probability of the pixel point belonging to the stomatal edge in the spatial domain includes: The probability that the analysis pixel point belongs to the stomatal edge in the color domain and the probability that the analysis pixel point belongs to the stomatal edge in the spatial domain are taken as the average of the sum of the probabilities; The seed point of the watershed algorithm is determined based on the comparison result between the probability that the analyzed pixel point is the stomata edge and the probability threshold.

8. The method for detecting the appearance quality of castings based on machine vision according to claim 7, characterized in that: The step of determining the seed point of the watershed algorithm based on the comparison result of the probability that the analyzed pixel point is a pore edge and the probability threshold comprises: If the probability that the analyzed pixel point is a pore edge is greater than or equal to the probability threshold, the analyzed pixel point is used as the seed point of the watershed algorithm.

9. The casting appearance quality inspection method based on machine vision according to claim 1, characterized in that: The method of determining the seed point of the watershed algorithm based on the probability of the pixel point belonging to the pore edge in the color domain and the probability of the pixel point belonging to the pore edge in the spatial domain to obtain the casting appearance quality inspection result includes: The seed points are marked and then input into the watershed algorithm to obtain the porosity defect area in the X-ray grayscale image of the casting; the appearance quality of the casting is evaluated according to the area ratio of the porosity defect area in the X-ray grayscale image of the casting.

10. The method for detecting casting appearance quality based on machine vision according to claim 9, characterized in that: The method of evaluating the casting appearance quality according to the area ratio of the porosity defect region in the casting X-ray grayscale image comprises: The number of pixels in the pore defect area is taken as the area of ​​the pore defect area; if the ratio of the area of ​​the pore defect area to the area of ​​the casting X-ray grayscale image is greater than the defect threshold, the evaluation result of the casting X-ray grayscale image is unqualified.

Citation Information

Patent Citations

  • Method and device for identifying bezel of light bundling device, computer equipment and storage medium

    CN114266799A

  • OCA film bubble detection method based on computer vision

    CN117557573A