A method and system for castings defect rating based on x-ray images

By expanding the defect annotation box area and enhancing the image of the X-ray image of the casting, and combining it with a multi-dimensional feature screening matrix, the automated rating of casting defects was realized, which solved the problems of instability and low efficiency of manual rating and improved the accuracy and efficiency of rating.

CN115908261BActive Publication Date: 2025-11-18HUAZHONG UNIV OF SCI & TECH +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211295842.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-21
Publication Date
2025-11-18
Estimated Expiration
2042-10-21

AI Technical Summary

Technical Problem

Existing manual rating methods for castings based on X-ray images yield unstable rating results and are labor-intensive, making it difficult to meet the rating requirements for casting defects in large-scale industrial production and resulting in difficulties in effectively controlling the quality of casting products.

Method used

By expanding the defect annotation box area of ​​the X-ray image of the casting and extracting the defect sub-image, and combining image enhancement, edge detection and multi-dimensional feature filtering matrix, the casting defects are automatically identified and rated. The Canny algorithm is used to detect edges, and the defect level is calculated by combining the rating quantification system.

Benefits of technology

It has achieved automation and standardization of casting defect rating, improved the accuracy and efficiency of rating, reduced manual labor intensity, overcome the limitation of lacking clear numerical indicators, and solved the problem of interference from complex structures on the enhancement of defect characteristics.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115908261B_ABST
    Figure CN115908261B_ABST
Patent Text Reader

Abstract

The application provides a casting X-ray image-based defect grading method and system, and belongs to the field of casting product quality detection.The method comprises the following steps: expanding the defect labeling frame region of the casting X-ray image, and obtaining a defect sub-image by using the expanded defect labeling frame region for interception; performing image enhancement on the defect sub-image according to the size and category of the defect in the defect sub-image; if there is a defect with a size exceeding a threshold value in the defect sub-image after image enhancement, a multi-dimensional feature screening matrix corresponding to the defect sub-image is established to exclude an interference region; the Canny algorithm is used to obtain the contour information of the defect in the defect sub-image; the pixel area of the defect is converted into the actual area of the casting defect, and the defect grade is obtained by referring to a grading quantification system; and the application realizes full-automatic casting defect grading, and overcomes the problems of unstable grading results, high labor intensity and difficult efficiency improvement of the existing manual grading method for casting X-ray images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of casting product quality inspection, and more specifically, relates to a defect rating method and system based on X-ray images of castings. Background Technology

[0002] The manufacturing process of complex castings for major equipment in industries such as aviation, aerospace, automobiles, rail transportation, and construction machinery faces common challenges such as out-of-tolerance standards for key quality points and large quality fluctuations, which result in the inability of major equipment to meet reliability and service life requirements.

[0003] Currently, casting defects such as inclusions, porosity, shrinkage cavities, and shrinkage porosity are inevitable in the casting production process. In various industries where castings are used, these defects can seriously affect the safe use of cast products, and severe defects often lead to the scrapping of the entire casting. Product quality directly impacts the profitability of manufacturing enterprises, and quality inspection is a crucial link in improving product quality. Therefore, quality inspection of castings is indispensable during the casting production process. X-ray flaw detection and defect rating of the X-ray images are common methods in casting quality inspection. Currently, defect rating in industrial production is mainly done manually, but manual rating cannot adequately meet the needs of large-scale industrial production for rating casting defects, making it difficult to effectively control the quality of cast products. Summary of the Invention

[0004] In view of the shortcomings of the existing technology, the purpose of this invention is to provide a defect rating method and system based on X-ray images of castings, which aims to solve the problems of unstable rating results, high manual labor intensity and difficulty in improving efficiency of existing manual rating methods based on X-ray images of castings.

[0005] To achieve the above objectives, on the one hand, the present invention provides a defect rating method based on X-ray images of castings, comprising the following steps:

[0006] S1: Expand the defect annotation box area of ​​the X-ray image of the casting, and then use the expanded defect annotation box area to extract the defect sub-image from the X-ray image of the casting.

[0007] S2: Enhance the defect sub-image based on the size and type of the defect in the defect sub-image;

[0008] S3: If there are defects in the enhanced defect sub-image that exceed the threshold size, then establish a multi-dimensional feature filtering matrix corresponding to the defect sub-image based on the edge contour, feature distribution and area threshold to exclude the interference area in the enhanced defect sub-image.

[0009] S4: The Canny algorithm is used to detect the edges of the defect sub-image after processing S3, and the contour extraction function is used to obtain the contour information of the defect and calculate the pixel area of ​​the defect.

[0010] S5: Convert the pixel area of ​​the defect into the actual area of ​​the casting defect, and obtain the defect level by comparing it with the rating and quantification system;

[0011] The method for establishing the rating quantification system is as follows: area is selected as the rating index for inclusions, porosity, shrinkage cavities and shrinkage porosity. Based on the defect rating reference image, the proportion of defect region pixels in the defect rating reference image is calculated within the defect rating reference image pixels. The reference area of ​​each level of defect is calculated to complete the establishment of the rating quantification system.

[0012] More preferably, the following step is performed between S1 and S2: if the defect category and image position of the current defect sub-image are highly overlapping with those of the previous defect sub-image, then the two defect sub-images are integrated into one defect sub-image.

[0013] More preferably, S2 specifically comprises:

[0014] If the defect sub-image contains inclusions and pores exceeding a size threshold, the image enhancement method is as follows:

[0015] a. Calculate the weighted average of the gray values ​​of pixels surrounding a preset radius of each central pixel in the defect sub-image using a Gaussian distribution-based weighted average method, and replace the gray value of the central pixel with the weighted average.

[0016] b. Apply Gaussian blur to the image processed by a, convert the image processed by a and the image processed by Gaussian blur by a proportional conversion, and then convert the result of the proportional conversion to the pixel value range of 0 to 255 by the same proportion.

[0017] c. Calculate the image histogram obtained by b, traverse the pixel threshold from 0 to 255, and in the histogram, the pixels greater than the pixel threshold are the foreground and the rest are the background. Calculate the proportion of pixels in the foreground and the average pixel value in the background respectively.

[0018] d. Calculate the inter-class variance at each pixel threshold, and use the pixel threshold that maximizes the inter-class variance to binarize the image obtained by b, and obtain the defect sub-image after image enhancement;

[0019] If other defects exist in the defect sub-image, a 3×3 Gaussian template is used to scan each pixel in the defect sub-image. Based on the Gaussian template, a weighted average gray value is calculated for the pixels in the neighborhood centered on the selected pixel. This weighted average gray value is then used to replace the value of the central pixel in the template, resulting in the enhanced defect sub-image. More preferably, the multi-dimensional feature selection matrix is:

[0020]

[0021] For inclusions or porosity defects, the centroid distance is recorded as 0; for shrinkage cavities or shrinkage porosity defects, the regularity is recorded as 0; other parameters are handled as follows:

[0022] Edge curvature: Calculate the edge curvature of each region in the defect sub-image. If a region has multiple edge curvature values ​​that exceed the preset curvature, the edge curvature is recorded as 1; otherwise, it is recorded as 0.

[0023] Regularity: For images of inclusions or pore defects, calculate the minimum circumcircle of each region in the defect sub-image, and then determine the proportion of the area of ​​each region in the circle. If the proportion is less than 65%, it is recorded as 1, otherwise it is recorded as 0.

[0024] Centroid distance: For images of shrinkage cavities and shrinkage porosity defects, calculate the centroid position of each region. Starting from the central region, calculate the centroid distance between the region and the nearest adjacent region. If the distance exceeds the preset distance, the centroid distance is recorded as 1; otherwise, it is recorded as 0.

[0025] Location: Determine the position of each region relative to the position of the original image. If all regions are located outside the original image, this item is recorded as 1; otherwise, it is recorded as 0.

[0026] Area: Determine the area occupied by each region. If the occupied area is less than 1 mm... 2 If the area is 1, then the area is recorded as 1; otherwise, it is recorded as 0.

[0027] By using the multidimensional feature filtering matrix corresponding to each region in the defect sub-image, the rank of the multidimensional feature filtering matrix is ​​calculated. If the rank is not 0, the corresponding region is determined to be an interference region and is discarded; if the rank is 0, the corresponding region is determined to be a defect region and is retained.

[0028] More preferably, the defect rating reference image is selected from standard GB / T 11346-2018.

[0029] On the other hand, the present invention provides a defect rating system based on X-ray images of castings, comprising:

[0030] The pixel expansion module is used to expand the defect annotation box area of ​​the X-ray image of the casting by pixels;

[0031] The screenshot module is used to extract defect sub-images from the X-ray image of the casting using the expanded defect annotation box area;

[0032] The image enhancement module is used to enhance the defect sub-image based on the size and category of the defect in the defect sub-image.

[0033] The interference region exclusion module is used to exclude interference regions in the image-enhanced defect sub-image if there are defects with a size exceeding a threshold in the defect sub-image. It establishes a multi-dimensional feature filtering matrix based on edge contour, feature distribution and area threshold.

[0034] The Canny algorithm module is used to perform edge detection on defective sub-images using the Canny algorithm.

[0035] The contour extraction module is used to obtain the contour information of the defect using a contour extraction function and to calculate the pixel area of ​​the defect.

[0036] The defect level assessment module is used to convert the pixel area of ​​the defect sub-image into the area of ​​the actual casting defect, and obtain the defect level by comparing it with the rating and quantification system.

[0037] The module for establishing the rating quantification system is used to select area as the rating index for inclusions, porosity, shrinkage cavities, and shrinkage porosity. Based on the defect rating reference image, it calculates the proportion of defect region pixels in the defect rating reference image pixels and calculates the reference area of ​​each level of defect to complete the establishment of the rating quantification system.

[0038] More preferably, the defect rating system also includes an image integration module, which integrates two defect sub-images into one defect sub-image when the defect category and image position of the current defect sub-image and the previous defect sub-image are highly overlapping.

[0039] More preferably, the image enhancement module includes a defect discrimination unit, a Gaussian distribution weighted average unit, a Gaussian blur conversion unit, a binarization processing unit, and a template scanning unit;

[0040] The defect discrimination unit is used to determine the type and size of defects present in the defect sub-image;

[0041] The Gaussian distribution weighted average unit is used to calculate the weighted average of the gray values ​​of pixels around the center pixel in the defect sub-image if there are inclusions and pores with a size exceeding the size threshold in the defect sub-image. The weighted average method based on Gaussian distribution is used to calculate the weighted average of the gray values ​​of pixels around the center pixel in the defect sub-image, and the weighted average value is used to replace the gray value of the center pixel.

[0042] The Gaussian blur conversion unit is used to perform Gaussian blur on the image. It performs a proportional conversion between the image processed by the Gaussian distribution weighted average unit and the image processed by Gaussian blur, and then converts the proportional conversion result to the pixel value range of 0 to 255.

[0043] The binarization unit is used to calculate the image histogram obtained by the Gaussian blur conversion unit. It iterates through pixel thresholds from 0 to 255. Pixels in the histogram that are greater than the pixel threshold are considered foreground, and the rest are considered background. It calculates the proportion of pixels in the foreground and background and the average pixel value. It calculates the inter-class variance at each pixel threshold and uses the pixel threshold that maximizes the inter-class variance to binarize the image obtained by the Gaussian weighted averaging unit to obtain the enhanced defect sub-image.

[0044] The template scanning unit is used to scan each pixel in the defect sub-image using a preset template if other defects exist in the defect sub-image. The weighted average gray value of the pixels in the neighborhood determined by the template is used to replace the value of the center pixel of the template to obtain the enhanced defect sub-image.

[0045] More preferably, the multidimensional feature selection matrix is:

[0046]

[0047] For inclusions and porosity defects, the centroid distance is recorded as 0; for shrinkage cavities and shrinkage porosity defects, the regularity is recorded as 0; for other parameters, the following treatment applies:

[0048] Edge curvature: Calculate the edge curvature of each region in the defect sub-image. If a region has multiple edge curvature values ​​that exceed the preset curvature, the edge curvature is recorded as 1; otherwise, it is recorded as 0.

[0049] Regularity: For images of inclusions and pores, calculate the minimum circumcircle of each region in the defect sub-image, and then determine the proportion of the area of ​​each region in the circle. If the proportion is less than 65%, it is recorded as 1, otherwise it is recorded as 0.

[0050] Centroid distance: For images of shrinkage cavities and shrinkage porosity defects, calculate the centroid position of each region. Starting from the central region, calculate the centroid distance between the region and the nearest adjacent region. If the distance exceeds the preset distance, the centroid distance is recorded as 1; otherwise, it is recorded as 0.

[0051] Location: Determine the relationship between the location of each region and the location of the image before expansion. If the region is entirely outside the image, this item is recorded as 1; otherwise, it is recorded as 0.

[0052] Area: Determine the area occupied by each region. If the occupied area is less than 1 mm... 2 If the area is 1, then the area is recorded as 1; otherwise, it is recorded as 0.

[0053] By using the multidimensional feature filtering matrix corresponding to each region in the defect sub-image, the rank of the multidimensional feature filtering matrix is ​​calculated. If the rank is not 0, the corresponding region is determined to be an interference region and is discarded; if the rank is 0, the corresponding region is determined to be a defect region and is retained.

[0054] In summary, compared with the prior art, the above-described technical solutions conceived by this invention have the following advantages:

[0055] Beneficial effects:

[0056] This invention selects area as the rating index for inclusions, porosity, shrinkage cavities, and shrinkage porosity. Based on the defect diagrams provided in the standard GB / T 11346-2018, the reference area of ​​each level of defect is calculated to complete the establishment of a quantitative rating index, which breaks through the limitation of existing casting defect ratings that lack clear numerical indicators.

[0057] In this invention, the defect area on the entire X-ray image of the casting is expanded to obtain a defect sub-image, which can fully extract the regional grayscale information of the entire X-ray image of the casting. Combined with feature enhancement methods, this can solve the problem of interference of the complex structure of the casting on the enhancement of defect features.

[0058] This invention, based on the defect category and location information obtained from the automatic defect identification system, conducts research on an automatic image discrimination and integration algorithm to achieve integrated rating of defects of the same type that are centrally distributed but individually labeled, thereby improving the reference value for production.

[0059] In this invention, if large inclusions and pores are present in the defect sub-image, Gaussian weighted averaging, Gaussian blurring, and binarization are performed sequentially to enhance the image. For other defects with insufficient clarity of morphological features, to avoid introducing too much background interference, a preset template is used to scan each pixel in the defect sub-image, and the weighted average gray value of the pixels in the neighborhood determined by the template is used to replace the value of the central pixel of the template; thus achieving image enhancement. Different defect feature enhancement methods are adopted for defects of different sizes and types, overcoming the limitation of unclear defect information in component defect inspection images.

[0060] In this invention, for large-size defect images, many discretely distributed interference regions appear in the background after feature enhancement. A multi-dimensional feature filtering matrix is ​​used to judge all regions and remove interference terms, thus overcoming the limitation that background errors are easily introduced after feature enhancement of large-size images. Attached Figure Description

[0061] Figure 1 This is a flowchart of the X-ray image processing of castings provided in an embodiment of the present invention;

[0062] Figure 2 This is a comparison chart of the rating results obtained by the defect rating method based on X-ray images of castings provided in this embodiment of the invention and the expert evaluation results. Detailed Implementation

[0063] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0064] Example

[0065] like Figure 1 As shown, on one hand, the present invention provides a defect rating method based on X-ray images of castings, including the following steps:

[0066] S1: Establishment of a quantitative rating system:

[0067] Area was selected as the rating index for inclusions, porosity, shrinkage cavities and shrinkage porosity. Based on the defect rating reference image given in the standard GB / T 11346-2018, the proportion of defect area pixels in the whole pattern pixels was calculated to calculate the reference area of ​​each level of defect in order to complete the establishment of the rating quantification system, as shown in the table below.

[0068]

[0069] S2: Image Acquisition

[0070] The defect annotation box area obtained by the automatic defect identification system is expanded to a certain extent, generally by 20-50 pixels. Then, the expanded area is used to extract the defect sub-image from the entire flaw detection image. This effectively avoids the situation where the gray value of the image is not fully considered at the boundary of the original image area.

[0071] S3: Image Integration Rating:

[0072] For each defect sub-image, the automatic defect identification system provides the corresponding defect category and location information. The system analyzes the defect category and location information and compares it with the previous image. If the two images have the same defect category and their locations highly overlap, they are considered the same image, and the rating result is consistent with the previous image, thus achieving unified rating for defects of the same type that are centrally distributed but individually labeled.

[0073] S4: Image Enhancement

[0074] The segmented X-ray defect images of the castings are subjected to different image enhancement processes based on the size and type of the defects. For large inclusions and porosity defects, whose morphological features are more obvious, the following image enhancement steps are adopted:

[0075] S4.1: Calculate the weighted average of the gray values ​​of the pixels surrounding a given pixel using a Gaussian distribution-based weighted average method, and replace the gray value of the center pixel with this value;

[0076] S4.2: Apply Gaussian blur to the image obtained in S4.1, convert the image obtained in S4.1 and the image after Gaussian blur processing by a certain ratio, and finally convert the result to a pixel value range of 0 to 255 by the same ratio.

[0077] The conversion formula is as follows:

[0078]

[0079] Where iamge_gauss represents the image after Gaussian blur processing; image represents the image after processing with S4.1; image_1 represents the image after scaling the image processed with S4.1 and the image after Gaussian blur processing; in this invention, w is taken as 1 / 3, so the original formula simplifies to:

[0080] image_1=1.5image-0.5image_gauss

[0081] S4.3: Calculate the histogram of the image and the number of pixels occupied by each pixel value. Traverse the threshold from 0 to 255. Pixels greater than the threshold are foreground and the rest are background. Calculate the proportion of pixels occupied by the foreground and background pixels and the average pixel value respectively.

[0082] S4.4: Calculate the inter-class variance at each pixel threshold, and use the threshold that maximizes the inter-class variance to binarize the image;

[0083] For large images of shrinkage cavities and porosity defects, and for small images, the morphological features are not clear enough. Using the above method would introduce too much background interference. Therefore, the following image enhancement steps are used for such images:

[0084] Use a preset template to scan each pixel in the defect sub-image, and replace the value of the center pixel of the template with the weighted average gray value of the pixels in the neighborhood determined by the template.

[0085] S5: Multidimensional feature selection matrix discrimination, constructing a multidimensional feature selection matrix:

[0086] The feature parameters include: (1) edge contour: edge curvature and regularity; (2) feature distribution: centroid distance and position; (3) area threshold: area; For large-size defect images after image enhancement, many discretely distributed interference regions may appear in the background. A multi-dimensional feature filtering matrix is ​​used to perform full-area discrimination on the image. The interference regions in the background differ from the defect regions in terms of the above features. This difference is used to remove the interference regions in the background; The multi-dimensional feature filtering matrix is ​​as follows:

[0087]

[0088] If the defect is an inclusion or a porosity defect, the centroid distance is recorded as 0; if the defect is a shrinkage cavity or a shrinkage porosity defect, the regularity is recorded as 0.

[0089] Calculate the edge curvature of each region in the defect sub-image. If there are several edge curvature values ​​in the region that exceed the preset curvature, the edge curvature is recorded as 1, otherwise it is recorded as 0.

[0090] If the defect is an inclusion or a porosity defect, calculate the minimum circumcircle of each region in the defect sub-image, and determine the proportion of the area of ​​each region in the minimum circumcircle. If the proportion is less than 65%, the regularity is recorded as 1, otherwise it is recorded as 0.

[0091] If the defect is a shrinkage cavity or shrinkage porosity defect, calculate the centroid position of each region in the defect sub-image. Starting from the central region, calculate the centroid distance between the region and the nearest adjacent region. If the distance exceeds the preset distance, the centroid distance is recorded as 1, otherwise it is recorded as 0.

[0092] Determine the positional relationship between each region and the original image. If the region is entirely outside the original image, the position is recorded as 1; otherwise, it is recorded as 0.

[0093] Determine the area occupied by each region in the defect sub-image. If the area occupied is less than 1 mm... 2 If the area is 1, then the area is recorded as 1; otherwise, it is recorded as 0.

[0094] The rank of the multidimensional feature selection matrix is ​​calculated by using the multidimensional feature selection matrix corresponding to each region in the defect sub-image. If the rank is not 0, the corresponding region is determined to be an interference region and is discarded; if the rank is 0, the corresponding region is determined to be a defect region and is retained.

[0095] S6: Image edge detection:

[0096] The Canny function is used to perform edge detection on the enhanced image. The choice of the two thresholds in the Canny algorithm will affect the edge detection effect to a certain extent. After testing, the Canny algorithm used in this invention is set with the high threshold set to 100 and the low threshold set to 50. After Canny edge detection, only the white curve representing the edge of the defect remains in the image, and the background color becomes black.

[0097] S7: Image Contour Extraction

[0098] The image is processed using a contour extraction function. This function can identify the white boundary region in a black background image and store this information, thereby obtaining the contour information of the defect. This information can be used to calculate the contour position, perimeter, and area, etc. At the same time, this information is displayed in the defect sub-image as a purple block so that it can be compared and verified with the defect sub-image.

[0099] S8: Defect Rating:

[0100] The pixel area of ​​the defect can be calculated from the defect contour information obtained in S7. The conversion relationship between the defect pixel area and the actual area is obtained based on the proportional relationship determined by the actual field data during image acquisition. The pixel area of ​​the defect is converted into the actual area. The obtained actual area is compared with the rating quantification system established in S1 to obtain the defect level. At the same time, the rating range corresponding to the defect level is displayed.

[0101] S9: System Development

[0102] By integrating the above functions, a system was developed that can perform defect rating on input defective images. Figure 2 The figure shows a comparison between the rating results obtained by the defect rating method based on X-ray images of castings and the expert evaluation results. As can be seen from the figure, the defect rating method provided by the present invention has extremely high accuracy.

[0103] On the other hand, the present invention provides a defect rating system based on X-ray images of castings, comprising:

[0104] The pixel expansion module is used to expand the defect annotation area of ​​the X-ray image of the casting obtained by the automatic defect identification system.

[0105] The screenshot module is used to extract defect sub-images from the X-ray image of the casting using the expanded defect annotation box area;

[0106] The image enhancement module is used to enhance the defect sub-image based on the size and category of the defect in the defect sub-image.

[0107] The interference region exclusion module is used to establish a multi-dimensional feature filtering matrix corresponding to the defect sub-image based on edge contour, feature distribution and area threshold, and exclude interference regions in the defect sub-image after image enhancement.

[0108] The Canny algorithm module is used to perform edge detection on defective sub-images using the Canny algorithm.

[0109] The contour extraction module is used to obtain the contour information of the defect using a contour extraction function and to calculate the pixel area of ​​the defect.

[0110] The defect level assessment module is used to convert the pixel area of ​​the defect sub-image into the area of ​​the actual casting defect, and obtain the defect level by comparing it with the rating and quantification system.

[0111] The module for establishing the rating quantification system is used to select area as the rating index for inclusions, porosity, shrinkage cavities, and shrinkage porosity. Based on the defect rating reference image, it calculates the proportion of defect region pixels in the defect rating reference image pixels and calculates the reference area of ​​each level of defect to complete the establishment of the rating quantification system.

[0112] More preferably, the defect rating system also includes an image integration module, which integrates two defect sub-images into one defect sub-image when the defect category and image position of the current defect sub-image and the previous defect sub-image are highly overlapping.

[0113] More preferably, the image enhancement module includes a defect discrimination unit, a Gaussian distribution weighted average unit, a Gaussian blur conversion unit, a binarization processing unit, and a template scanning unit;

[0114] The defect discrimination unit is used to determine the type and size of defects present in the defect sub-image;

[0115] The Gaussian distribution weighted average unit is used to calculate the weighted average of the gray values ​​of pixels around the center pixel in the defect sub-image if there are inclusions and pores with a size exceeding the size threshold in the defect sub-image. The weighted average method based on Gaussian distribution is used to calculate the weighted average of the gray values ​​of pixels around the center pixel in the defect sub-image, and the weighted average value is used to replace the gray value of the center pixel.

[0116] The Gaussian blur conversion unit is used to perform Gaussian blur on the image. It performs a proportional conversion between the image processed by the Gaussian distribution weighted average unit and the image processed by Gaussian blur, and then converts the proportional conversion result to the pixel value range of 0 to 255.

[0117] The binarization unit is used to calculate the image histogram obtained by the Gaussian blur conversion unit. It iterates through pixel thresholds from 0 to 255. Pixels in the histogram that are greater than the pixel threshold are considered foreground, and the rest are considered background. It calculates the proportion of pixels in the foreground and background and the average pixel value. It calculates the inter-class variance at each pixel threshold and uses the pixel threshold that maximizes the inter-class variance to binarize the image obtained by the Gaussian weighted averaging unit to obtain the enhanced defect sub-image.

[0118] The template scanning unit is used to scan each pixel in the defect sub-image using a 3×3 Gaussian template if other defects exist in the defect sub-image. Based on the Gaussian template, a weighted average gray value is calculated for the pixels in the neighborhood centered on the selected pixel, and this weighted average gray value replaces the value of the center pixel of the template, thus obtaining the enhanced defect sub-image. Further preferably, the multi-dimensional feature selection matrix is:

[0119]

[0120] If the defect is an inclusion or a porosity defect, the centroid distance is recorded as 0; if the defect is a shrinkage cavity or a shrinkage porosity defect, the regularity is recorded as 0.

[0121] Calculate the edge curvature of each region in the defect sub-image. If there are several edge curvature values ​​in the region that exceed the preset curvature, the edge curvature is recorded as 1, otherwise it is recorded as 0.

[0122] If the defect is an inclusion or a porosity defect, calculate the minimum circumcircle of each region in the defect sub-image, and determine the proportion of the area of ​​each region in the minimum circumcircle. If the proportion is less than 65%, the regularity is recorded as 1, otherwise it is recorded as 0.

[0123] If the defect is a shrinkage cavity or shrinkage porosity defect, calculate the centroid position of each region in the defect sub-image. Starting from the central region, calculate the centroid distance between the region and the nearest adjacent region. If the distance exceeds the preset distance, the centroid distance is recorded as 1, otherwise it is recorded as 0.

[0124] Determine the positional relationship between each region and the original image. If the region is entirely outside the original image, the position is recorded as 1; otherwise, it is recorded as 0.

[0125] Determine the area occupied by each region in the defect sub-image. If the area occupied is less than 1 mm... 2 If the area is 1, then the area is recorded as 1; otherwise, it is recorded as 0.

[0126] By using the multidimensional feature filtering matrix corresponding to each region in the defect sub-image, the rank of the multidimensional feature filtering matrix is ​​calculated. If the rank is not 0, the corresponding region is determined to be an interference region and is discarded; if the rank is 0, the corresponding region is determined to be a defect region and is retained.

[0127] This invention selects area as the rating index for inclusions, porosity, shrinkage cavities, and shrinkage porosity. Based on the defect diagrams provided in the standard GB / T 11346-2018, the reference area of ​​each level of defect is calculated to complete the establishment of a quantitative rating index, which breaks through the limitation of existing casting defect ratings that lack clear numerical indicators.

[0128] In summary, compared with the prior art, the present invention has the following advantages:

[0129] In this invention, the defect area on the entire X-ray image of the casting is expanded to obtain a defect sub-image, which can fully extract the regional grayscale information of the entire X-ray image of the casting. Combined with feature enhancement methods, this can solve the problem of interference of the complex structure of the casting on the enhancement of defect features.

[0130] This invention, based on the defect category and location information obtained from the automatic defect identification system, conducts research on an automatic image discrimination and integration algorithm to achieve integrated rating of defects of the same type that are centrally distributed but individually labeled, thereby improving the reference value for production.

[0131] In this invention, if large inclusions and pores are present in the defect sub-image, Gaussian weighted averaging, Gaussian blurring, and binarization are performed sequentially to enhance the image. For other defects with insufficient clarity of morphological features, to avoid introducing too much background interference, a preset template is used to scan each pixel in the defect sub-image, and the weighted average gray value of the pixels in the neighborhood determined by the template is used to replace the value of the central pixel of the template; thus achieving image enhancement. Different defect feature enhancement methods are adopted for defects of different sizes and types, overcoming the limitation of unclear defect information in component defect inspection images.

[0132] In this invention, for large-size defect images, many discretely distributed interference regions appear in the background after feature enhancement. A multi-dimensional feature filtering matrix is ​​used to judge all regions and remove interference terms, thus overcoming the limitation that background errors are easily introduced after feature enhancement of large-size images.

[0133] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for defect rating based on X-ray images of castings, characterized in that, The method comprises the following steps: S1: pixel expansion is performed on the defect labeling box region of the casting X-ray image, and then the expanded defect labeling box region is used to obtain a defect sub-image by image interception on the casting X-ray image; S2: image enhancement is performed on the defect sub-image according to the size and type of the defect in the defect sub-image; S3: if there is a defect with a size exceeding a threshold value in the image-enhanced defect sub-image, a multi-dimensional feature screening matrix corresponding to the defect sub-image is established based on edge contour, feature distribution and area threshold value, and an interference region in the image-enhanced defect sub-image is excluded; S4: edge detection is performed on the defect sub-image processed in S3 by using a Canny algorithm, contour information of the defect is obtained by using a contour extraction function, and a pixel area of the defect is calculated; S5: the pixel area of the defect is converted into an actual area of the casting defect, and a defect grade is obtained by comparing with a rating quantization system; The method for establishing the rating quantization system is: selecting area as a rating index of inclusion, blowhole, shrinkage cavity and shrinkage porosity, calculating a proportion of pixels of a defect region in a defect rating reference image in the defect rating reference image, and calculating a reference area of each level of defect to complete establishment of the rating quantization system; The multi-dimensional feature screening matrix is: If the defect is an inclusion or a blowhole defect, the centroid distance is recorded as 0; if the defect is a shrinkage cavity or a shrinkage porosity defect, the regularity is recorded as 0; The edge curvatures of each region in the defect sub-image are calculated, if there are several edge curvature values exceeding a preset curvature in the region, the edge curvature is recorded as 1, otherwise as 0; If the defect is an inclusion or a blowhole defect, the minimum circumscribed circle of each region in the defect sub-image is calculated, the proportion of the area of each region in the minimum circumscribed circle is judged, if the proportion is less than 65%, the regularity is recorded as 1, otherwise as 0; If the defect is a shrinkage cavity or a shrinkage porosity defect, the centroid positions of each region in the defect sub-image are calculated, the centroid distance between the region and the adjacent nearest region is calculated from the central region, if the distance exceeds a preset distance, the centroid distance is recorded as 1, otherwise as 0; The position relationship between each region and the image before expansion is judged, if all the region positions are located outside the image before expansion, the position is recorded as 1, otherwise as 0; If the area of each region in the defect sub-image is determined, and if the area is less than 1 mm 2 , then the area is recorded as 1, otherwise as 0. The rank of the multi-dimensional feature screening matrix is calculated through the multi-dimensional feature screening matrix corresponding to each region in the defect sub-image, if the rank is not 0, it is determined that the corresponding region is an interference region, and the interference region is discarded; if the rank is 0, it is determined that the corresponding region is a defect region, and the defect region is retained.

2. The defect ranking method of claim 1, wherein, A step is performed between S1 and S2: if the defect type and image position of the current defect sub-image are highly coincident with those of the previous defect sub-image, the two defect sub-images are integrated into one defect sub-image.

3. The defect ranking method of claim 1 or 2, wherein, S2 is specifically: If there are inclusions and blowholes with a size exceeding a size threshold value in the defect sub-image, the image enhancement method is: a. The weighted average value of the pixel gray value of each center pixel point in the defect sub-image within a preset radius is calculated by using a weighted average method based on Gaussian distribution, and the weighted average value is used to replace the gray value of the center pixel point; b. Apply Gaussian blur to the image processed by a, convert the image processed by a and the image processed by Gaussian blur by a proportional conversion, and then convert the result of the proportional conversion to the pixel value range of 0~255 by the same proportion. c. Calculate the image histogram obtained by b, traverse the pixel threshold from 0 to 255, and in the histogram, the pixels greater than the pixel threshold are the foreground and the rest are the background. Calculate the proportion of pixels in the foreground and the average pixel value in the background respectively. d. Calculate the inter-class variance at each pixel threshold, and use the pixel threshold that maximizes the inter-class variance to binarize the image obtained by b, and obtain the defect sub-image after image enhancement; If other defects exist in the defect sub-image, a 3×3 Gaussian template is used to scan each pixel in the defect sub-image. The weighted average gray value of the pixels in the neighborhood centered on the selected pixel is calculated based on the Gaussian template, and the value of the center pixel of the template is replaced by the weighted average gray value to obtain the enhanced defect sub-image.

4. A casting X-ray image-based defect rating system, characterized by, include: The pixel expansion module is used to expand the defect annotation box area of ​​the X-ray image of the casting by pixels; The screenshot module is used to extract defect sub-images from the X-ray image of the casting using the expanded defect annotation box area; The image enhancement module is used to enhance the defect sub-image based on the size and category of the defect in the defect sub-image. The interference region exclusion module is used to exclude interference regions in the image-enhanced defect sub-image if there are defects with a size exceeding a threshold in the defect sub-image. It establishes a multi-dimensional feature filtering matrix based on edge contour, feature distribution and area threshold. The Canny algorithm module is used to perform edge detection on defective sub-images using the Canny algorithm. The contour extraction module is used to obtain the contour information of the defect using a contour extraction function and to calculate the pixel area of ​​the defect. The defect level assessment module is used to convert the pixel area of ​​a defect into the area of ​​the actual casting defect and obtain the defect level by comparing it with the rating and quantification system. The module for establishing the rating quantification system is used to select area as the rating index for inclusions, porosity, shrinkage cavities and shrinkage porosity. Based on the defect rating reference image, it calculates the proportion of defect region pixels in the defect rating reference image pixels and calculates the reference area of ​​each level of defect to complete the establishment of the rating quantification system. The multidimensional feature selection matrix is: If the defect is an inclusion or a porosity defect, the centroid distance is recorded as 0; if the defect is a shrinkage cavity or a shrinkage porosity defect, the regularity is recorded as 0. Calculate the edge curvature of each region in the defect sub-image. If there are several edge curvature values ​​in the region that exceed the preset curvature, the edge curvature is recorded as 1, otherwise it is recorded as 0. If the defect is an inclusion or a porosity defect, calculate the minimum circumcircle of each region in the defect sub-image, and determine the proportion of the area of ​​each region in the minimum circumcircle. If the proportion is less than 65%, the regularity is recorded as 1, otherwise it is recorded as 0. If the defect is a shrinkage cavity or shrinkage porosity defect, calculate the centroid position of each region in the defect sub-image. Starting from the central region, calculate the centroid distance between the region and the nearest adjacent region. If the distance exceeds the preset distance, the centroid distance is recorded as 1, otherwise it is recorded as 0. Determine the positional relationship between each region and the original image. If the region is entirely outside the original image, the position is recorded as 1; otherwise, it is recorded as 0. If the area of each region in the defect sub-image is determined, and if the area is less than 1 mm 2 , then the area is recorded as 1, otherwise as 0. By using the multidimensional feature filtering matrix corresponding to each region in the defect sub-image, the rank of the multidimensional feature filtering matrix is ​​calculated. If the rank is not 0, the corresponding region is determined to be an interference region and is discarded; if the rank is 0, the corresponding region is determined to be a defect region and is retained.

5. The defect rating system of claim 4, wherein, It also includes an image integration module, which integrates two defect sub-images into one defect sub-image when the defect category and image position of the current defect sub-image are highly overlapping with those of the previous defect sub-image.

6. A defect ranking system according to claim 4 or 5, wherein, The image enhancement module includes a defect discrimination unit, a Gaussian distribution weighted average unit, a Gaussian blur conversion unit, a binarization processing unit, and a template scanning unit. The defect discrimination unit is used to determine the type and size of defects present in the defect sub-image; The Gaussian distribution weighted average unit is used to calculate the weighted average of the gray values ​​of pixels around the center pixel in the defect sub-image if there are inclusions and pores with a size exceeding the size threshold in the defect sub-image. The weighted average method based on Gaussian distribution is used to calculate the weighted average of the gray values ​​of pixels around the center pixel in the defect sub-image, and the weighted average value is used to replace the gray value of the center pixel. The Gaussian blur conversion unit is used to perform Gaussian blur on the image. It performs a proportional conversion between the image processed by the Gaussian distribution weighted average unit and the image processed by Gaussian blur, and then converts the proportional conversion result to the pixel value range of 0~255. The binarization unit is used to calculate the image histogram obtained by the Gaussian blur conversion unit. It traverses the pixel threshold from 0 to 255. Pixels in the histogram that are greater than the pixel threshold are foreground and the rest are background. The proportion of pixels in the foreground and background and the average pixel value are calculated respectively. Calculate the inter-class variance at each pixel threshold, and use the pixel threshold that maximizes the inter-class variance to binarize the image obtained by the weighted average unit of Gaussian distribution, and obtain the defect sub-image after image enhancement. The template scanning unit is used to scan each pixel in the defect sub-image using a 3×3 Gaussian template if other defects exist in the defect sub-image. Based on the Gaussian template, the weighted average gray value of the pixels in the neighborhood centered on the selected pixel is calculated, and the value of the center pixel of the template is replaced with the weighted average gray value to obtain the enhanced defect sub-image.

Citation Information

Patent Citations

  • Method and system for generating dendritic shrinkage porosity defect simulation image of casting

    CN104091327A

  • Method for detecting potential defects of complicated-structure castings on basis of vertical cross line contour features

    CN107808378A