A method, system and electronic device for processing defects in a flaw detection image
By employing merging methods and contour expansion techniques for different types of defects in casting flaw detection images, the problem of inaccurate defect identification in casting flaw detection images has been solved, improving detection accuracy and completeness.
Patent Information
- Application Number
- CN202310697437.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-12
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2043-06-12
AI Technical Summary
The existing defects in casting flaw detection images are not very accurate, and there are problems such as repeated identification of defects, segmented identification, dense occurrence of defects, and missed detection in some areas, which affects the judgment of product quality.
Merging methods for different types of defects are adopted, including merging the annotation boxes within the circle with the defect center as the center and unifying the annotation boxes based on Hamming distance. Combined with defect contour expansion, the defect detection accuracy is improved.
It enables accurate identification of defects, improves the detection accuracy and completeness of casting flaw detection images, and reduces missed detections.
Smart Images

Figure CN116805305B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of quality inspection of casting products, and more specifically, relates to a method, system and electronic equipment for processing defects in flaw detection images. 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 problems such as "out-of-tolerance for critical quality points and large quality fluctuations," which result in the reliability and service life of major equipment in my country failing to meet requirements.
[0003] In the casting production process, defects are inevitable, such as inclusions, porosity, shrinkage cavities, and shrinkage porosity. However, in existing intelligent defect detection processes, some defects, such as cracks, have a large span, which may lead to repeated or segmented identification of the defect, affecting the final product quality assessment; or some defects are small in scale and appear densely, such as high-density inclusions, resulting in overly dense marking of similar defects, affecting detection quality and hindering subsequent manual review; or the detection results for a certain defect are incomplete, with some defect areas missed, affecting detection accuracy. A method for merging similar defect areas in flaw detection images for accurate classification can solve these problems to some extent, improve the quality of intelligent defect detection, and facilitate accurate defect identification. Summary of the Invention
[0004] In view of the shortcomings of the prior art, the purpose of this invention is to provide a method, system and electronic device for processing defects in flaw detection images, which aims to solve the problem of low defect recognition accuracy in existing casting flaw detection images.
[0005] To achieve the above objectives, in a first aspect, the present invention provides a method for processing defects in flaw detection images, comprising the following steps:
[0006] Determine the type and location of defects within the image; the defects include a first type of defect and a second type of defect. The first type of defect consists of defects whose size span does not exceed a threshold and which appear densely, while the second type of defect consists of defects whose size span exceeds the threshold.
[0007] For any type of defect in the first category, draw a circle with the center of the label box of any defect as the center and the diagonal length as the radius. Label all label boxes within the circle whose overlapping area with the circle is greater than a preset ratio of the original label box area. Repeat the above circle drawing and labeling operations for the labeled label boxes until no label boxes can be found. Then, construct a minimum label box to cover all labeled label boxes to merge the same type of defect in the first category.
[0008] For any type of defect within the second category, if the shortest distance between any two defect annotation boxes is less than a preset ratio of the diagonal length of the relatively smaller annotation box, then the annotation boxes of the two defects are made to the same size. Then, the hash value of the pixel grayscale of the annotation boxes is calculated, and the Hamming distance between the two annotation boxes is calculated based on the hash value. If the Hamming distance between a defect annotation box and at least one annotation box is less than a preset distance, then a minimum annotation box is constructed to cover the annotation box of the defect with all annotation boxes whose Hamming distance is less than the preset value, so as to merge the same type of defect within the second category.
[0009] In one possible implementation, before or after merging similar defects, the following steps are also included:
[0010] For a single defect annotation frame, the area of the annotation frame is expanded. Then, defect contour detection is performed on the expanded annotation frame. If the first ratio of the area of the expanded defect contour region to the area of the defect contour region before expansion exceeds a preset ratio, the expanded annotation frame is used as a new annotation frame, and the above operations of annotation frame area expansion, defect contour detection, and defect contour area comparison are repeated until the first ratio does not exceed the preset ratio. The preset ratio is related to the proportion of annotation frame area expansion.
[0011] In one possible implementation, if the image is divided into multiple sub-images for defect detection during the image defect detection process, the aforementioned merging of the same type of defect and expansion of the single defect annotation box are first performed on the defects detected in each sub-image. Then, all sub-images are merged to obtain a complete image, and the aforementioned merging of the same type of defect and expansion of the single annotation box are performed on the complete image.
[0012] In one possible implementation, if the image is divided into multiple sub-images for defect detection during the image defect detection process, the aforementioned same-type defect merging operation is first performed on the defects detected in each sub-image. Then, all sub-images are merged to obtain a complete image, and the aforementioned same-type defect merging and single bounding box expansion operations are performed on the complete image.
[0013] In one possible implementation, if the image is divided into multiple sub-images for defect detection during the image defect detection process, all sub-images are first merged to obtain a complete image, and then the above-mentioned operations of merging the same type of defects and expanding individual bounding boxes are performed on the complete image.
[0014] In one possible implementation, the preset distance corresponding to the Hamming distance is related to the scaling scale of the uniform size of the annotation box.
[0015] In one possible implementation, the first type of defect includes: high-density inclusion defects and pinhole defects;
[0016] The second category of defects includes: porosity defects, crack defects, pore defects, low-density inclusion defects, and segregation defects.
[0017] Secondly, the present invention provides a system for processing defects in flaw detection images, comprising:
[0018] A defect determination unit is used to determine the type and location of defects within an image; the defects include a first type of defect and a second type of defect, the first type of defect being defects whose size span does not exceed a threshold and which appear densely, and the second type of defect being defects whose size span exceeds a threshold;
[0019] The first defect merging unit is used to draw a circle with the center of the annotation box of any defect as the center and the diagonal length as the radius for any type of defect in the first category of defects. All annotation boxes within the circle whose overlapping area with the circle is greater than a preset ratio of the original annotation box area are labeled. The above circle drawing and labeling operations are repeated for the labeled annotation boxes until no annotation boxes that can be labeled are found. Then, a minimum annotation box is constructed to cover all labeled annotation boxes in order to merge the same type of defects in the first category of defects.
[0020] The second defect merging unit is used to, for any type of defect within the second category of defects, if the shortest distance between any two defect annotation boxes is less than a preset ratio of the diagonal length of the relatively smaller annotation box, then the annotation boxes of the two defects are made to the same size, and then the hash value of the pixel grayscale of the annotation boxes is calculated respectively, and the Hamming distance between the two annotation boxes is calculated based on the hash value; if the Hamming distance between a defect annotation box and at least one annotation box is less than a preset distance, then a minimum annotation box is constructed to cover the annotation box of the defect with all annotation boxes whose Hamming distance is less than the preset value, so as to merge the same type of defects within the second category of defects.
[0021] In one possible implementation, the system also includes:
[0022] The defect expansion unit is used to expand the area of the annotation box of a single defect, and then perform defect contour detection on the expanded annotation box. If the first ratio of the area of the expanded defect contour region to the area of the defect contour region before expansion exceeds a preset ratio, the expanded annotation box is used as a new annotation box, and the above operations of annotation box area expansion, defect contour detection and defect contour area comparison are repeated until the first ratio does not exceed the preset ratio; the preset ratio is related to the proportion of annotation box area expansion.
[0023] Thirdly, the present invention provides an electronic device comprising: at least one memory for storing a program; and at least one processor for executing the program stored in the memory, wherein when the program stored in the memory is executed, the processor is configured to execute the method described in the first aspect or any possible implementation thereof.
[0024] Fourthly, the present invention provides a computer-readable storage medium storing a computer program that, when run on a processor, causes the processor to perform the method described in the first aspect or any possible implementation thereof.
[0025] Fifthly, the present invention provides a computer program product that, when run on a processor, causes the processor to perform the method described in the first aspect or any possible implementation thereof.
[0026] In summary, the technical solutions conceived by this invention have the following beneficial effects compared with the prior art:
[0027] This invention provides a method, system, and electronic device for processing defects in flaw detection images. Different defect merging methods are designed for densely occurring defects with a size span not exceeding a threshold and for defects with a size span exceeding the threshold, merging densely occurring defects or defects that are repeatedly identified and segmented. Furthermore, this invention designs a defect expansion method to avoid incomplete defect detection and reduce the possibility of missed defect areas. By designing different defect merging and expansion methods, this invention improves the accuracy of defect detection and achieves precise defect identification. Attached Figure Description
[0028] Figure 1 This is a flowchart of the method for processing defects in flaw detection images provided in an embodiment of the present invention;
[0029] Figure 2 This is an architecture diagram of the flaw detection image defect processing system provided in the embodiments of the present invention. Detailed Implementation
[0030] 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.
[0031] To address product quality defects, this invention aims to provide a method for merging similar defect areas in flaw detection images for accurate classification. In intelligent inspection of X-ray flaw detection images of castings, issues such as duplicate defect identification, segmented identification, dense occurrence of defects, and missed detection in some areas easily arise, affecting defect quality assessment. This invention achieves better accuracy in identifying defects in flaw detection images by using a method for merging similar defect areas, providing valuable reference for defect identification and classification in actual production processes.
[0032] Figure 1 This is a flowchart of a method for processing defects in flaw detection images provided in an embodiment of the present invention; as shown below. Figure 1 As shown, it includes the following steps:
[0033] S101, determine the type and location of defects in the image; the defects include a first type of defect and a second type of defect, the first type of defect is a defect whose size span does not exceed the threshold and appears densely, and the second type of defect is a defect whose size span exceeds the threshold;
[0034] S102, For any type of defect in the first category of defects, draw a circle with the center of the annotation box of any defect as the center and the diagonal length as the radius. Label all annotation boxes in the circle whose overlapping area with the circle is greater than the preset ratio of the original annotation box area. Repeat the above circle drawing and labeling operations for the labeled annotation boxes until no annotation boxes that can be labeled are found. Then, construct a minimum annotation box to cover all labeled annotation boxes in order to merge the same type of defects in the first category of defects.
[0035] S103, for any type of defect in the second category, if the shortest distance between any two defect annotation boxes is less than a preset ratio of the diagonal length of the relatively smaller annotation box, then the annotation boxes of the two defects are made to the same size, and then the hash value of the pixel grayscale of the annotation boxes is calculated respectively, and the Hamming distance between the two annotation boxes is calculated based on the hash value; if the Hamming distance between a certain defect annotation box and at least one annotation box is less than a preset distance, then a minimum annotation box is constructed to cover the annotation box of the defect with all annotation boxes whose Hamming distance is less than the preset value, so as to merge the same type of defect in the second category.
[0036] In a specific embodiment, to solve the above problems, the present invention adopts the following technical solution: a method for merging similar defect regions in flaw detection images for accurate classification, comprising the following steps:
[0037] 1. Obtaining sub-images:
[0038] The flaw detection image used in this invention has a resolution of 2400×3072, while the preset sub-image resolution is 416×416. This makes it difficult to achieve complete, non-overlapping segmentation. Therefore, a bilinear interpolation algorithm is first used to enlarge the height and width of the original image I to integer multiples of 416 (rounded up). The new image I... n The height and width are denoted as height. new and width new From equations (1.1) and (1.2), the resolution of the new image is 2496×3328.
[0039] height new =416×round up (2400÷416)=2496 (1.1)
[0040] width new=416×round up (3072 ÷ 416) = 3328 (1.2)
[0041] In the formula, round up (·) indicates the rounding operation of the logarithm ·. The new image is scanned in a zigzag pattern from left to right and from top to bottom with a window size of 416×416 and a step size of 416 to obtain the sub-images and sub-image indices of the corresponding regions.
[0042] 2. Intra-image defect classification based on multi-feature analysis
[0043] (1) Perform intelligent defect detection on each sub-image to obtain the defect detection results of each sub-image. The basic position of the detected defect will be marked with a rectangle.
[0044] (2) Defect contour extraction: The Canny edge detection algorithm is used to process each marked box region, and then the contour extraction function is used to extract the defect contour information of the region.
[0045] (3) Gray-scale analysis: Based on the defect contour information obtained above, pixel analysis is performed on the original image. If the pixel gray value is in the range of 0-127, it is determined to be a high-density inclusion defect. If the gray value is in the range of 128-255, subsequent processing is performed.
[0046] (4) Edge curvature distribution analysis: The curvature of the points on the defect contour area is calculated to obtain the curvature feature value of the image contour edge at each pixel point, and the maximum value is recorded as M1. If the proportion of pixels with curvature values greater than 0.7×M1 does not reach 20% of the total number of pixels, it is judged as a porosity or low-density inclusion defect. No specific distinction is made here, and it is recorded as a porosity defect; otherwise, subsequent calculations are performed.
[0047] (5) Area analysis: Calculate the pixel area S1 of the defect contour area and the pixel area S2 of the labeled rectangle, and calculate the ratio S = S1 / S2. If S > 0.6, it is judged as a shrinkage cavity or shrinkage porosity defect. Here, a defect judgment is made and recorded as a porosity defect. If S < 0.25, it is judged as a crack defect.
[0048] (6) Defects that cannot be classified after the above steps are recorded as other and are not within the scope of this discussion.
[0049] 3. Defect correlation matching within sub-images:
[0050] (1) Location analysis: After removing other defects and high-density inclusion defects, the location analysis of the defect areas is performed. A circle is drawn with the center of the marked rectangle as the center and the length of the diagonal of the rectangle as the radius. If one or more rectangular areas of the same type of defect appear in the circle, then the subsequent similarity calculation analysis is performed for each individual area.
[0051] (2) Similarity Calculation: The two defective regions to be compared are processed as follows: ① Reduce the size to 8×8. ② Calculate the average grayscale value of the pixels. ③ Calculate the hash value. Compare the grayscale value of each pixel with the average value. If it is greater than or equal to the average value, record it as 1; if it is less than the average value, record it as 0. This generates a binary array. ④ Image pairing, calculate the Hamming distance HD. If HD≤10, the two defective regions can be merged. Take the two vertices with the farthest distance between their bounding boxes and construct a new bounding box as the detection result of the defect. If HD>10, the two defective regions have low similarity and cannot be merged.
[0052] (3) High-density defect merging: For high-density inclusion defects appearing in the sub-image, draw a circle with the center of the labeled rectangle as the center and the length of the diagonal of the rectangle as the radius. Tag all high-density inclusion defects in the circle whose overlapping area of the rectangles is greater than half of the area of the original rectangle. Repeat the above operation for defects with the tag until there are no more defects. For the above high-density inclusion defects, construct a new labeled rectangle to cover all defects, that is, merge them into one high-density inclusion defect.
[0053] 4. Expanded multi-strategy defect marker box:
[0054] (1) For a single defect area, expand the length and width of the marked rectangle to 110% of the original to obtain a new area. Calculate the defect outline area S1 and S2 of the area before and after expansion. If S2 / S1 < 1.1, it means that the area does not need to be expanded. Otherwise, proceed with the next steps.
[0055] (2) Analyze the relationship between the position of the defect contour information and the position of the marker box to obtain the defect position trend, which is divided into three categories: horizontal distribution, vertical distribution and irregular distribution. For the above three cases, the rectangular box length is increased by 20%, the width is increased by 20%, and the length and width are increased by 10% respectively. The defect contour area S1 and S2 before and after the expansion are calculated. Repeat the operation until S2 / S1 < 1.1.
[0056] 5. Sub-image merging: After defect merging, the sub-images are stitched together according to their indexes to obtain a new image I. n The test result M n .
[0057] 6. Merging of similar defect regions in the new image: Defect correlation matching and defect marker box expansion are performed sequentially in the new image. The specific steps are the same as those above. This is used to merge defect regions that may need to be merged or expanded at the boundaries of adjacent sub-images, thereby improving detection accuracy.
[0058] 7. Place M n Reducing the image size to 2400×3072 yields the detection result M of the original image I.
[0059] It should be noted that the specific values in the above embodiments can be adjusted by those skilled in the art according to actual needs. All specific values within the protection scope of the present invention should be within the protection scope of the embodiments of the present invention.
[0060] Figure 2 This is an architecture diagram of a flaw detection image defect processing system provided in an embodiment of the present invention; as shown. Figure 2 As shown, it includes:
[0061] The defect determination unit 210 is used to determine the type and location of defects in the image; the defects include a first type of defect and a second type of defect, the first type of defect being a defect whose size span does not exceed a threshold and appears densely, and the second type of defect being a defect whose size span exceeds a threshold;
[0062] The first defect merging unit 220 is used to draw a circle with the center of the annotation box of any defect as the center and the diagonal length as the radius for any type of defect in the first category of defects. All annotation boxes within the circle whose overlapping area with the circle is greater than a preset ratio of the area of the original annotation box are labeled. The above circle drawing and labeling operations are repeated for the labeled annotation boxes until no annotation boxes that can be labeled are found. Then, a minimum annotation box is constructed to cover all labeled annotation boxes in order to merge the same type of defects in the first category of defects.
[0063] The second defect merging unit 230 is used to, for any type of defect in the second category of defects, if the shortest distance between any two defect annotation boxes is less than a preset ratio of the diagonal length of the relatively smaller annotation box, then the annotation boxes of the two defects are made to the same size, and then the hash value of the pixel grayscale of the annotation boxes is calculated respectively, and the Hamming distance between the two annotation boxes is calculated based on the hash value; if the Hamming distance between a defect annotation box and at least one annotation box is less than a preset distance, then a minimum annotation box is constructed to cover the annotation box of the defect with all annotation boxes whose Hamming distance is less than the preset value, so as to merge the same type of defects in the second category of defects.
[0064] The defect expansion unit 240 is used to expand the area of the annotation box of a single defect, and then perform defect contour detection on the expanded annotation box. If the first ratio of the area of the expanded defect contour region to the area of the defect contour region before expansion exceeds a preset ratio, the expanded annotation box is used as a new annotation box, and the above-mentioned annotation box area expansion, defect contour detection and defect contour area comparison operations are repeated until the first ratio does not exceed the preset ratio; the preset ratio is related to the proportion of annotation box area expansion.
[0065] It should be understood that the above system is used to execute the methods in the above embodiments. The corresponding program units in the system are similar in implementation principle and technical effect to those described in the above methods. The working process of the system can be referred to the corresponding process in the above methods, and will not be repeated here.
[0066] Based on the methods described in the above embodiments, this invention provides an electronic device. The device may include at least one memory for storing a program and at least one processor for executing the program stored in the memory. When the program stored in the memory is executed, the processor performs the methods described in the above embodiments.
[0067] Based on the methods in the above embodiments, this embodiment of the invention provides a computer-readable storage medium storing a computer program that, when run on a processor, causes the processor to execute the methods in the above embodiments.
[0068] Based on the methods in the above embodiments, this embodiment of the invention provides a computer program product that, when run on a processor, causes the processor to execute the methods in the above embodiments.
[0069] It is understood that the processor in the embodiments of the present invention can be a central processing unit (CPU), or 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 can be a microprocessor or any conventional processor.
[0070] The method steps in the embodiments of the present invention can be implemented in hardware or by a processor executing software instructions. The software instructions can consist of corresponding software modules, which can be stored in 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), registers, hard disks, portable hard disks, CD-ROMs, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor, enabling the processor to read information from 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 reside in an ASIC.
[0071] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially as 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, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. 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 via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0072] It is understood that the various numerical designations used in the embodiments of the present invention are merely for descriptive convenience and are not intended to limit the scope of the embodiments of the present invention.
[0073] 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 of processing a flaw image defect, characterized by, The method comprises the following steps: determining the type and location of defects in the image; the defects include first type defects and second type defects, the first type defects are defects with size span not exceeding a threshold and densely appearing, and the second type defects are defects with size span exceeding the threshold; for any one of the first type defects, taking the center of the label frame of the defect as the center of a circle and the diagonal of the label frame as the radius of the circle, marking the label frames in the circle with an area greater than a preset proportion of the area of the original label frame, repeating the operation of marking the label frames, and constructing a minimum label frame to cover all the marked label frames to merge the same defects in the first type defects; for any one of the second type defects, if the shortest distance between any two defect label frames is less than a preset proportion of the diagonal of the label frame with a relatively small area, resizing the label frames of the two defects, then calculating the hash value of the pixel gray scale of the label frames, and calculating the Hamming distance between the two label frames according to the hash value; if the Hamming distance between a defect label frame and at least one label frame is less than a preset distance, constructing a minimum label frame to cover the defect label frame and all the label frames with a Hamming distance less than the preset value to merge the same defects in the second type defects; wherein, before or after the same defects are merged, the following steps are further included: for a single defect label frame, expanding the area of the label frame, then performing defect contour detection on the expanded label frame, if the first ratio of the area of the defect contour region after expansion to the area of the defect contour region before expansion exceeds a preset ratio, taking the expanded label frame as a new label frame, and repeating the operations of label frame area expansion, defect contour detection and defect contour area comparison until the first ratio does not exceed the preset ratio; the preset ratio is related to the expansion ratio of the label frame area.
2. The method of claim 1, wherein, If the image is divided into multiple sub-images for defect detection during the image defect detection process, the defects detected in each sub-image are subjected to the above same defect merging and single defect label frame expansion operations, then all the sub-images are merged to obtain a complete image, and the complete image is subjected to the above same defect merging and single label frame expansion operations.
3. The method of claim 1, wherein, If the image is divided into multiple sub-images for defect detection during the image defect detection process, the defects detected in each sub-image are subjected to the above same defect merging operation, then all the sub-images are merged to obtain a complete image, and the complete image is subjected to the above same defect merging and single label frame expansion operations.
4. The method of claim 1, wherein, If the image is divided into multiple sub-images for defect detection during the image defect detection process, all the sub-images are merged to obtain a complete image, and the complete image is subjected to the above same defect merging and single label frame expansion operations.
5. The method of claim 1, wherein, The preset distance corresponding to the Hamming distance is related to the scaling scale of the uniform size of the label frame.
6. The method of claim 1, wherein, The first type defects include high-density inclusion defects and pinhole defects; The second type defects include hole loose defects, crack defects, air hole defects, low-density inclusion defects and segregation defects.
7. A processing system for detecting defects in a flaw detection image, characterized by The method comprises the following steps: a defect determination unit configured to determine a type and a location of a defect in an image; the defects include first-type defects and second-type defects, the first-type defects are defects with a size span not exceeding a threshold and densely appearing, and the second-type defects are defects with a size span exceeding the threshold; a first defect merging unit configured to, for any one of the first-type defects, take a center of a bounding box of the any one defect as a center of a circle and a diagonal of the bounding box as a radius of the circle, label all bounding boxes in the circle that have an overlapping area with the circle greater than a preset proportion of an area of the original bounding box, repeat the operation of taking a center of a bounding box of the any one defect as a center of a circle and a diagonal of the bounding box as a radius of the circle and labeling all bounding boxes in the circle that have an overlapping area with the circle greater than a preset proportion of an area of the original bounding box until no bounding box can be labeled, and then construct a minimum bounding box to cover all the labeled bounding boxes to merge the same defects in the first-type defects; a second defect merging unit configured to, for any one of the second-type defects, if a shortest distance between any two defect bounding boxes is less than a preset proportion of a diagonal of a bounding box with a smaller area, uniformly size the two defect bounding boxes, then calculate hash values of pixel gray scales of the two defect bounding boxes, and calculate a Hamming distance between the two defect bounding boxes according to the hash values; if a Hamming distance between a defect bounding box and at least one bounding box is less than a preset distance, construct a minimum bounding box to cover the defect bounding box and all bounding boxes with a Hamming distance less than the preset distance to merge the same defects in the second-type defects; a defect expanding unit configured to, for a single defect bounding box, expand an area of the defect bounding box, then perform defect contour detection on the expanded defect bounding box, if a first ratio of an area of a defect contour region after expansion to an area of a defect contour region before expansion exceeds a preset ratio, take the expanded defect bounding box as a new defect bounding box, and repeat the operation of expanding an area of a defect bounding box, performing defect contour detection on the expanded defect bounding box, and comparing a defect contour region area after expansion to a defect contour region area before expansion until the first ratio does not exceed the preset ratio; the preset ratio is related to a proportion of the area expansion of the defect bounding box.
8. An electronic device, comprising: comprise: at least one memory for storing programs; at least one processor for executing the programs stored in the memory, when the programs stored in the memory are executed, the processor is configured to execute the method of any one of claims 1-6.
Citation Information
Patent Citations
Defect merging method and device, computer equipment and storage medium
CN110728659A
Defect rating method and system based on casting X-ray image
CN115908261A