Casting X-ray flaw detection 16-bit grayscale image defect detection method and system

By performing a variety of image enhancement processing and deep learning model training on the cast X-ray detection 16-bit grayscale image, the problem of defect detection accuracy and efficiency caused by low image quality is solved, and efficient and accurate defect detection is achieved.

CN120147285APending Publication Date: 2025-06-13HUAZHONG UNIV OF SCI & TECH +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510277485.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-10
Publication Date
2025-06-13

AI Technical Summary

Technical Problem

The quality of the existing castings is low in X-ray detection 16-bit grayscale image, resulting in inaccuracy and inefficiency of defect detection.

Method used

By performing windowing, normalization, grayscale partitioning, sub-windowing and sub-normalization on the 16-bit grayscale images of the casting, five sets of enhanced image sets are generated, and deep learning models are trained using these image sets, defect detection is performed on the detected images, and the detection results are merged and deduplicated.

Benefits of technology

It improves image quality, highlights defect characteristics, improves the detection accuracy and efficiency of deep learning models, and realizes efficient and accurate defect detection, which is suitable for the rapid and accurate detection of a large number of castings in industrial production.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120147285A_ABST
    Figure CN120147285A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of industrial nondestructive testing, and discloses a casting X-ray flaw detection 16-bit grayscale image defect detection method, which comprises the following steps: respectively carrying out windowing processing, normalization processing, grayscale partitioning processing, sub-windowing processing and sub-normalization processing on each 16-bit grayscale image of a casting to obtain five groups of enhanced image sets; training a preset network model by using the enhanced image set to obtain five deep learning models; performing enhancement processing on a to-be-detected 16-bit grayscale image to obtain five enhanced images, and respectively inputting the enhanced images into the corresponding deep learning models for defect detection to obtain five groups of independent detection results; and combining the detection results and then de-weighting to obtain a defect detection result. According to the method, the defect features in the image can be highlighted from different angles, so that the defects are more obvious in the image, and the accuracy of subsequent deep learning model defect detection is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the technical field of industrial non-destructive testing, and more specifically, relates to a method and system for detecting defects in 16-bit grayscale images of X-ray flaw detection for castings. Background Art

[0002] Complex castings of light alloys such as titanium, aluminum, and magnesium are widely used in important national defense fields such as aviation, aerospace, navigation, and ordnance. Their quality directly affects the performance and safety of products. The existing internal defect detection methods are mainly X-ray flaw detection imaging + manual film evaluation, which have pain points such as easy missed detection and misdetection of defects, and inefficient and fluctuating film evaluation. With the development of computer vision and deep learning technologies, automated image processing and intelligent analysis methods have gradually been applied to the detection of casting defects. However, due to its high-range gray values and rich detail information, 16-bit grayscale images pose higher requirements for image processing and defect detection algorithms. Therefore, how to effectively enhance image quality and improve the accuracy and efficiency of defect detection has become a technical problem to be solved urgently. Summary of the Invention

[0003] Aiming at the defects of the existing technology, the purpose of this application is to provide a method and system for detecting defects in 16-bit grayscale images of X-ray flaw detection for castings, aiming to solve the problems of low quality of 16-bit grayscale images of X-ray flaw detection for castings, resulting in low accuracy and efficiency of defect detection.

[0004] To achieve the above purpose, this application provides a method for detecting defects in 16-bit grayscale images of X-ray flaw detection for castings, and the detection method includes: S1 Perform windowing processing, normalization processing, gray-scale partitioning processing, sub-windowing processing, and sub-normalization processing on each 16-bit grayscale image of the casting respectively to obtain five groups of enhanced image sets; S2 Use the enhanced image sets to train a preset network model respectively to obtain five deep learning models; S3 Process the 16-bit grayscale image to be detected according to step S1 to obtain five enhanced images, and input the enhanced images into the corresponding deep learning models respectively for defect detection to obtain five groups of independent detection results; S4 Merge and remove duplicates from the detection results. The steps of merging and removing duplicates are: merge the previous detection result with the next detection result, compare and remove duplicates to generate a new detection result, then merge the new detection result with the next detection result and remove duplicates until all detection results are merged and de-duplicated, and obtain the defect detection result.

[0005] Further, in step S4, the method of comparing and removing duplicates after merging the previous detection result with the next detection result is: S401 Merge the two detection results to obtain merged defect information; S402 compares the detected defects in the merged defect information, removes duplicates based on a preset confidence threshold, and outputs a new detection result.

[0006] Furthermore, in step S402, the method of comparing the detected defects in the merged defect information and removing duplicates based on a preset confidence threshold is as follows: S4021 first determines whether the categories of the detected defects in the two detection results are the same: if they are different, all detected defects are retained; if they are the same, the next step is executed; S4022 determines whether the confidence of the category of the detected defect in the latter detection result is less than the preset confidence threshold: if it is less than, it is determined that the corresponding detected defect overlaps or coincides with the detected defect in the previous detection result, and the rectangular marking frame with the larger confidence is retained as the detected defect; if it is not less than, the maximum circumscribed rectangle of the two overlapping or coinciding rectangular marking frames is obtained, and the maximum circumscribed rectangle is retained as the detected defect.

[0007] Further, in step S1, the steps of windowing the 16-bit grayscale image include: S101 takes the grayscale average value of the 16-bit grayscale image as the window center; obtains the standard deviation of the image grayscale values, and multiplies it by a preset coefficient as the window width; S102 calculates the value of each pixel after windowing based on the window center and window width; S103 linearly scales the windowed pixel values so that they are mapped from the grayscale values within the window range to the standard display range, obtaining the windowed image.

[0008] Further, in step S1, the steps of normalizing the 16-bit grayscale image include: S111 obtains the maximum grayscale value and minimum grayscale value of the 16-bit grayscale image, obtaining a second global grayscale range; S112 linearly scales each pixel value in the 16-bit grayscale image so that the pixel value is mapped from the second global grayscale range to the standard display range, obtaining a normalized image.

[0009] Further, in step S1, the steps of gray-level partitioning the 16-bit grayscale image include: S121 obtains the maximum grayscale value and minimum grayscale value of the 16-bit grayscale image, obtaining a third global grayscale range; S122 divides the third global grayscale range into multiple gray-level intervals according to a preset step size; S123 generates a mask for each gray-level interval to identify the pixels in the 16-bit grayscale image within the corresponding gray-level interval, and extracts the pixels to form an interval pixel data set; S124 Windowizes and merges the interval pixel data set to obtain a gray-scale partitioned image.

[0010] Further, in step S1, the steps of sub-windowizing a 16-bit gray-scale image include: S131 Divides the 16-bit gray-scale image into a plurality of first sub-images, and the number of the first sub-images is an integer multiple of the 16-bit gray-scale image to be detected; S132 Windowizes and merges each of the first sub-images to obtain a sub-windowized enhanced image.

[0011] Further, in step S1, the steps of sub-normalizing a 16-bit gray-scale image include: S141 Divides the 16-bit gray-scale image into a plurality of second sub-images, and the number of the second sub-images is an integer multiple of the 16-bit gray-scale image to be detected; S142 Normalizes and splices the second sub-images to obtain a sub-normalized enhanced image.

[0012] According to another aspect of the present application, there is also disclosed a system for implementing the method for detecting defects in 16-bit gray-scale images of X-ray flaw detection of castings as described in any one of the foregoing, the system includes: A first image enhancement processing module, configured to perform windowing processing, normalization processing, gray-scale partitioning processing, sub-windowing processing, and sub-normalization processing on each 16-bit gray-scale image of the casting respectively to obtain five groups of enhanced image sets; A model training module, configured to train a preset network model using the enhanced image sets respectively to obtain five deep learning models; A second image enhancement processing module, configured to process the 16-bit gray-scale image to be detected according to step S1 to obtain five enhanced images, input the enhanced images into the corresponding deep learning models respectively for defect detection, and obtain five groups of independent detection results; A defect detection result output module, configured to merge and de-duplicate the detection results, and the steps of merging and de-duplicating are: merging the previous detection result with the next detection result, comparing and de-duplicating to generate a new detection result, and then merging the new detection result with the next detection result and de-duplicating until all detection results are merged and de-duplicated to obtain the defect detection result.

[0013] Through the above technical solutions conceived by the present application, compared with the prior art, it has the following excellent effects: 1. The present application enhances the image through five methods, namely windowing processing, normalization processing, grayscale partitioning processing, sub-windowing processing, and sub-normalization processing, which can highlight the defect features in the image from different angles, making the defects more obvious in the image, thereby improving the accuracy of subsequent deep learning model detection.

[0014] 2. The present application uses five groups of image sets to train a preset network model respectively, obtaining five deep learning models. These models can learn the complex features of casting defects, perform accurate defect detection on the image to be detected, and achieve efficient and accurate defect detection through five different image enhancement schemes in combination with the deep learning model.

[0015] 3. The present application can efficiently process a large number of casting X-ray flaw detection images, is suitable for rapid and accurate defect detection of a large number of castings in industrial production, and helps to improve production efficiency and product quality control level.

[0016] 4. During the output process of the defect detection result, the present application combines and deduplicates the detection results in sequence, making full use of the defect data information in the 5 groups of detection results, which helps to more comprehensively and accurately evaluate the defect situation of the casting and provides richer data support for quality traceability and process optimization. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 is a schematic flowchart of a method for detecting defects in a 16-bit grayscale image of casting X-ray flaw detection provided by an embodiment of the present application; Figure 2 is a schematic flowchart of image enhancement processing provided by an embodiment of the present application; Figure 3 is a schematic structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0018] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application 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 only used to explain the present application and are not used to limit the present application.

[0019] In the description of the present application, it should be understood that the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the present application, "a plurality" means two or more unless otherwise specifically defined.

[0020] In addition, the reference to "one embodiment" throughout this specification; the language such as "one embodiment", "one example" or the like means that the specific features, structures or characteristics described in connection with that embodiment are included in at least one embodiment of the present application. Therefore, the appearance of the phrase "in one embodiment;" throughout the specification of "in one embodiment" and similar language may or may not all refer to the same embodiment.

[0021] An embodiment of the present application provides a method for defect detection of 16-bit grayscale images in X-ray flaw detection of castings, as Figure 1 and Figure 2 shown, the detection method includes: S1 Perform windowing processing, normalization processing, grayscale partitioning processing, sub-windowing processing and sub-normalization processing on each 16-bit grayscale image of the casting to obtain five groups of enhanced image sets; S2 Use the enhanced image sets to train a preset network model respectively to obtain five deep learning models; S3 Process the 16-bit grayscale image to be detected according to step S1 to obtain five enhanced images, input the enhanced images into the corresponding deep learning models respectively for defect detection, and obtain five groups of independent detection results; S4 Merge and deduplicate the detection results. The steps of merging and deduplicating are: merge the previous detection result with the next detection result, compare and deduplicate first to generate a new detection result, and then merge the new detection result with the next detection result and deduplicate until all detection results are merged and deduplicated, and obtain the defect detection result.

[0022] Specifically, in step S1, the specific scheme for creating five groups of enhanced image sets is: 1. Windowing processing for each 16-bit grayscale image (hereinafter referred to as the image). That is, by adjusting the grayscale value range of the image, the details in a specific grayscale interval are highlighted to enhance the contrast of the image. Specifically, it includes the following steps: (1) Calculate the average value of the image grayscale values as the window level (WL); calculate the standard deviation of the image grayscale values, and multiply it by a preset coefficient (such as 2, 3, 4, etc.) as the window width (WW); The window range is expressed as: ; (2) Linear scaling: Linearly scale each pixel value in the image so that its grayscale value within the window range is mapped to the standard display range [0, 255]. The scaling formula is as follows: ; where, is the original image grayscale value, is the enhanced image grayscale value; (3)Value limit: Values less than 0 are changed to 0; values greater than 255 are changed to 255; (4)Data type conversion: Convert the image data to 8-bit unsigned integer type (unit8) to obtain the windowed image.

[0023] 2. Normalize each image. Linearly map the grayscale values of the image to the range [0, 255] to enhance the overall contrast. The specific steps are as follows: (1)Obtain the maximum and minimum grayscale values of the image to get the global grayscale range [Max_Gray, Min_Gray] (i.e., the first global grayscale range); (2)Linearly scale each pixel value in the image so that it is mapped from the global grayscale range [Max_Gray, Min_Gray] to the standard display range [0, 255]. The scaling formula is as follows: ; where, is the original image grayscale value, is the enhanced image grayscale value; (3)Value limit: Values less than 0 are changed to 0, and values greater than 255 are changed to 255; (4)Data type conversion: Convert the image data to 8-bit unsigned integer type (unit8) to obtain the normalized image.

[0024] 3. Perform gray-level partitioning on each image. By dividing the range of image grayscale values into multiple intervals, windowing enhancement is applied to each interval separately to refine the contrast of different gray-level intervals and improve the detail performance of different gray levels. The specific steps are as follows: (1)Obtain the maximum and minimum grayscale values of the image to get the global grayscale range [Max_Gray, Min_Gray] (i.e., the third global grayscale range); (2)Set a step size (Step, for example, 5500), and divide the global grayscale range [Max_Gray, Min_Gray] into multiple intervals; each gray-level interval is [Start, end], where Start is the starting grayscale value of the current interval and end = start + Step; if end exceeds Max_Gray, then end = Max_Gray.

[0025] (3)Process interval by interval. Generate a mask (Mask) for each gray-level interval [Start, end] to identify the pixels in the image whose grayscale values are within the gray-level interval [Start, end]. Extract the pixel values within the mask area to form an interval data set, and perform the windowing process in step 1 on this interval data set.

[0026] (4)Merge the results. Merge the pixel values of the enhanced intervals after windowing processing back to the corresponding positions of the enhanced image to obtain the image processed by gray-scale partitioning.

[0027] 4. Perform sub-windowing processing on each image. By dividing the image into multiple first sub-images and applying windowing enhancement to each first sub-image respectively, the local contrast is improved, and the details of the image are enhanced. The specific steps are as follows: (1)Adjust the image size to an integer multiple of the size of the sub-graphs to be used for subsequent deep learning defect detection (such as an integer multiple of 416) for subsequent sub-graph cropping; (2)Evenly divide the adjusted image into multiple first sub-images of a fixed size (such as 416×416) by rows and columns; (3)Perform the windowing processing in step 1 on each first sub-image; (4)Reassemble all the enhanced first sub-images after windowing processing in the order of segmentation to restore them to a complete image, and the size of the assembled image is the same as that of the original image, so as to obtain the image enhanced by sub-windows.

[0028] 5. Perform sub-normalization processing on each image. By dividing the image into multiple sub-images and applying normalization enhancement to each sub-image respectively, the local contrast is improved, and the details of the image are enhanced. The specific steps are as follows: (1)Adjust the image size to an integer multiple of the size of the sub-graphs to be used for subsequent deep learning defect detection (such as an integer multiple of 416) for subsequent sub-graph cropping; (2)Evenly divide the adjusted image into multiple second sub-images of a fixed size (such as 416×416) by rows and columns; (3)Perform the normalization processing in step 2 on each second sub-image; (4)Reassemble all the enhanced second sub-images in the order of segmentation to restore them to a complete image; the size of the assembled image is the same as that of the original image, so as to obtain the image enhanced by sub-normalization.

[0029] In the aforementioned step S2, the steps of training the model using five groups of enhanced image sets are as follows: Use the enhanced image data sets obtained by five different enhancement schemes to train a preset network model respectively to generate five deep learning models. Among them, the input image size of the data set is the same as the size of the sub-graphs in the sub-windowing processing and the sub-normalization processing; the preset network model can be various deep learning models, and specifically, ASCUnet, YOLO (You Only Look Once), Faster R-CNN (Region-based Convolutional Neural Networks), etc. can be adopted.

[0030] In the aforementioned step S3, the 16-bit grayscale image to be detected is processed according to step S1 to obtain five enhanced images, and the enhanced images are respectively input into the corresponding deep learning models for defect detection to obtain five groups of independent detection results.

[0031] The detection results of each deep learning model are saved in the XML file format. Each XML file contains the following information: Image basic information, including file name, folder name, path name, image width, image height, etc.; Defect detection information, including defect category, upper left position coordinates of the defect marking box, lower right position coordinates, defect confidence, etc.

[0032] In the aforementioned step S4, the method for merging and comparing the XML format files corresponding to the previous detection result and the next detection result to remove duplicates is as follows: S401 Merge the XML format files corresponding to the two detection results to obtain merged defect information; First, perform an XML file check: First, check whether there is an XML file corresponding to the next detection result. If not, create a new XML file and write the next detection result into the XML file; if there is an XML file, read the content of the existing XML file (i.e., the content of the XML file of the previous detection result) and merge it with the XML file of the next detection result to ensure that all defect information detected by all models is retained in the form of a union.

[0033] S402 Compare the detected defects in the merged defect information, remove duplicates based on the preset confidence threshold, and output the new detection result; specifically, to ensure that the merged XML file does not contain duplicate or overlapping defect information, it is necessary to compare the detected defects in the next detection result with the detected defects in the previous detection result, and judge whether the two detected defects are duplicate or overlapping defects according to the preset confidence threshold. In this embodiment, the preset confidence threshold is 0.5.

[0034] Specifically, the method for comparing the detected defects in the merged defect information and removing duplicates based on the preset confidence threshold is as follows: S4021 First, judge whether the categories of the detected defects in the two detection results are the same: if they are different, retain all detected defects; if they are the same, proceed to the next step; S4022 Determine whether the confidence level of the category of the detected defect in the subsequent detection result is less than the preset confidence threshold: if it is less than, it is determined that the corresponding detected defect overlaps or coincides with the detected defect in the previous detection result, and the area in the rectangular marking box with the larger confidence level is retained as the detected defect; if it is not less than, obtain the minimum bounding rectangle of the two overlapping or coinciding rectangular marking boxes, and retain the area within the minimum bounding rectangle as the detected defect.

[0035] In another embodiment, there is also provided a system for implementing the casting X-ray flaw detection 16-bit grayscale image defect detection method provided in the foregoing embodiment. The system includes: A first image enhancement processing module, configured to perform windowing processing, normalization processing, grayscale partitioning processing, sub-windowing processing, and sub-normalization processing on each 16-bit grayscale image of the casting respectively to obtain five sets of enhanced image sets; A model training module, configured to train a preset network model using the enhanced image sets respectively to obtain five deep learning models; A second image enhancement processing module, configured to process the 16-bit grayscale image to be detected according to step S1 to obtain five enhanced images, input the enhanced images into the corresponding deep learning models respectively for defect detection, and obtain five sets of independent detection results; A defect detection result output module, configured to merge and remove duplicates from the detection results. The steps of merging and removing duplicates are: first compare and remove duplicates after merging the previous detection result and the subsequent detection result to generate a new detection result, then merge the new detection result with the next detection result and remove duplicates until all detection results are merged and de-duplicated to obtain the defect detection result.

[0036] It should be understood that the above device is used to execute the method in the foregoing embodiment. For the corresponding program modules in the device, their implementation principles and technical effects are similar to those described in the above method. The working process of the device can refer to the corresponding process in the above method and will not be elaborated here.

[0037] Based on the method in the foregoing embodiment, an embodiment of the present application provides an electronic device, which may include: a processor 810, a communication interface 820, a memory 830, and a communication bus 840. Among them, the processor 810, the communication interface 820, and the memory 830 communicate with each other through the communication bus 840. The processor 810 can call the logical instructions in the memory 830 to execute the method in the foregoing embodiment.

[0038] In addition, when the logical instructions in the above-mentioned memory 830 are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application.

[0039] Based on the method in the above-mentioned embodiments, an embodiment of this application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program runs on a processor, it causes the processor to execute the method in the above-mentioned embodiments.

[0040] Based on the method in the above-mentioned embodiments, an embodiment of this application provides a computer program product. When the computer program product runs on a processor, it causes the processor to execute the method in the above-mentioned embodiments.

[0041] It can be understood that the processor in the embodiments of this application may be a central processing unit (CPU), or may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. The general-purpose processor may be a microprocessor or any conventional processor.

[0042] The method steps in the embodiments of the present application can be implemented in a hardware manner or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in a random access memory (RAM), flash memory, read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), register, hard disk, removable hard disk, CD-ROM, or any other form of storage medium well-known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC.

[0043] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center in a wired manner (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or a wireless manner (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that the computer can access or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.

[0044] It can be understood that the various numerical numbers involved in the embodiments of the present application are only for the convenience of description and are not used to limit the scope of the embodiments of the present application.

[0045] Those skilled in the art can easily understand that the above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included within the protection scope of the present application.

Claims

1. A casting X-ray flaw detection 16-bit grayscale image defect detection method, characterized in that: The detection method comprises: S1 performs windowing, normalization, grayscale partitioning, sub-windowing and sub-normalization on each 16-bit grayscale image of the casting to obtain five sets of enhanced images; S2 uses the enhanced image set to train the preset network model to obtain five deep learning models; S3 processes the 16-bit grayscale image to be inspected according to step S1 to obtain five enhanced images, and inputs the enhanced images into the corresponding deep learning models for defect detection to obtain five independent detection results; S4 merges and removes duplicates of the detection results. The steps of merging and removing duplicates are as follows: merge the previous detection result with the next detection result, compare and remove duplicates to generate a new detection result, then merge the new detection result with the next detection result and remove duplicates, until all the detection results are merged and removed, and the defect detection result is obtained.

2. A casting X-ray flaw detection 16-bit grayscale image defect detection method as claimed in claim 1, characterized in that: In step S4, the method of combining the previous detection result and the next detection result and comparing and removing duplicates is: S401 combines the two detection results to obtain combined defect information; S402 compares the detected defects in the merged defect information, removes duplicates based on a preset confidence threshold, and outputs a new detection result.

3. A casting X-ray flaw detection 16-bit grayscale image defect detection method as claimed in claim 2, characterized in that: In step S402, the detected defects in the merged defect information are compared, and a method for deduplication based on a preset confidence threshold is as follows: S4021 first determines whether the categories of the detection defects in the two detection results are the same: if they are different, all the detection defects are retained; if they are the same, the next step is executed; S4022 determines whether the confidence of the category of the detection defect in the subsequent detection result is less than the preset confidence threshold: if it is less than, it is determined that the corresponding detection defect overlaps or coincides with the detection defect in the previous detection result, and the rectangular marking box with a large confidence is retained as the detection defect; if it is not less than, the maximum circumscribed rectangular box of the two overlapping or coincident rectangular marking boxes is obtained, and the maximum circumscribed rectangular box is retained as the detection defect.

4. A casting X-ray flaw detection 16-bit grayscale image defect detection method as claimed in claim 1, characterized in that: In step S1, the step of performing window processing on the 16-bit grayscale image includes: S101 uses the grayscale average value of the 16-bit grayscale image as the window position; obtains the standard deviation of the image grayscale value, and multiplies it by a preset coefficient as the window width; S102 calculates the windowed value of each pixel value based on the window level and window width; S103 linearly scales the windowed pixel values ​​so as to map the grayscale values ​​within the window range to the standard display range, thereby obtaining a windowed image.

5. A casting X-ray flaw detection 16-bit grayscale image defect detection method as claimed in claim 1, characterized in that: In step S1, the step of normalizing the 16-bit grayscale image includes: S111 obtains the maximum grayscale value and the minimum grayscale value of the 16-bit grayscale image to obtain a second global grayscale range; S112 linearly scales each pixel value in the 16-bit grayscale image so that the pixel value is mapped from the second global grayscale range to a standard display range to obtain a normalized image.

6. A casting X-ray flaw detection 16-bit grayscale image defect detection method as claimed in claim 1, characterized in that: In step S1, the step of performing grayscale partitioning processing on the 16-bit grayscale image includes: S121 obtains the maximum grayscale value and the minimum grayscale value of the 16-bit grayscale image to obtain a third global grayscale range; S122 divides the third global grayscale range into a plurality of grayscale intervals according to a preset step size; S123 generates a mask for each grayscale interval to identify pixels of the 16-bit grayscale image in the corresponding grayscale interval, and extracts the pixels to form an interval pixel data set; S124 performs window processing on the interval pixel data sets and then merges them to obtain a grayscale partitioning processed image.

7. A casting X-ray flaw detection 16-bit grayscale image defect detection method as claimed in claim 1, characterized in that: In step S1, the step of performing sub-window processing on the 16-bit grayscale image includes: S131: dividing the 16-bit grayscale image into a plurality of first sub-images, wherein the number of the first sub-images is an integer multiple of the 16-bit grayscale image to be detected; S132 performs window processing on each of the first sub-images and merges them to obtain a sub-windowed enhanced image.

8. A casting X-ray flaw detection 16-bit grayscale image defect detection method as claimed in claim 1, characterized in that: In step S1, the step of performing sub-normalization processing on the 16-bit grayscale image includes: S141: dividing the 16-bit grayscale image into a plurality of second sub-images, wherein the number of the second sub-images is an integer multiple of the 16-bit grayscale image to be detected; S142 normalizes and splices the second sub-images to obtain sub-normalized enhanced images.

9. A system for implementing the casting X-ray flaw detection 16-bit grayscale image defect detection method according to any one of claims 1 to 8, characterized in that: The system comprises: The first image enhancement processing module is used to perform windowing processing, normalization processing, grayscale partitioning processing, sub-windowing processing and sub-normalization processing on each 16-bit grayscale image of the casting to obtain five sets of enhanced images; A model training module, used to respectively train the preset network model using the enhanced image set to obtain five deep learning models; The second image enhancement processing module is used to process the 16-bit grayscale image to be detected according to step S1 to obtain five enhanced images, and input the enhanced images into the corresponding deep learning model to perform defect detection to obtain five independent detection results; The defect detection result output module is used to merge and remove duplicates of the detection results. The steps of merging and removing duplicates are as follows: merge the previous detection result with the next detection result, compare and remove duplicates to generate a new detection result, then merge the new detection result with the next detection result and remove duplicates, until all detection results are merged and removed, and the defect detection result is obtained.