A false judgment prevention method and device for internal defect detection, a terminal and a storage medium

By acquiring product inspection images to generate candidate contour sets, extracting and dilating binarized features, and calculating the cumulative probability density function of the grayscale image, the problems of misjudgment and missed judgment in the existing technology are solved, and efficient and accurate internal defect detection is achieved.

CN122391066APending Publication Date: 2026-07-14GUANGDONG ZHENGYE TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUANGDONG ZHENGYE TECH CO LTD
Filing Date
2026-03-09
Publication Date
2026-07-14

Smart Images

  • Figure CN122391066A_ABST
    Figure CN122391066A_ABST
Patent Text Reader

Abstract

This invention discloses a method, device, terminal, and storage medium for preventing false positives in internal defect detection. The method includes: extracting binarized features for each candidate contour in a candidate contour set generated based on a product inspection image, and performing morphological dilation to obtain updated binarized features; generating neighborhood features based on the binarized features and updated binarized features; generating a contour grayscale image and a neighborhood grayscale image based on the product inspection image, the binarized features, and the neighborhood features; calculating a cumulative probability density function for each grayscale image based on grayscale statistical information and determining the overlapping grayscale state; and determining the probability that the candidate contour is an internal defect based on the overlapping grayscale state. This invention eliminates the need for cumbersome parameter tuning and optimization processes. Instead, it constructs a new internal defect detection judgment logic through candidate contour feature analysis and grayscale feature quantization comparison, effectively reducing false positives and fundamentally avoiding the risk of missed detections due to optimization operations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of defect detection technology, and in particular to a method, device, terminal and storage medium for preventing false positives in internal defect detection. Background Technology

[0002] In the field of nondestructive testing, the detection of internal defects in products is of great significance to ensuring product quality and safety. Among them, industrial X-ray inspection technology has become one of the best choices for internal defect detection due to its ability to penetrate the interior of products and clearly present the internal structure. It is also widely used in the quality control process of various industrial products.

[0003] In industrial production processes, defects such as air bubbles (cavities) or foreign objects existing inside products are collectively referred to as internal defects. The presence of such defects can seriously compromise the structural integrity and mechanical properties of products, thereby affecting their quality stability and safety in use. Therefore, accurate detection of air bubbles (cavities) and foreign objects inside products is one of the key requirements in the field of industrial non-destructive testing.

[0004] Currently, for the quantitative detection of internal cavities or foreign objects in products, existing technologies mainly employ two types of segmentation algorithms: traditional segmentation algorithms and AI-trained segmentation algorithms. The purpose of both types of algorithms is to achieve accurate identification and judgment of internal defects in products through the processing and analysis of the detected images, thereby providing a basis for product quality assessment.

[0005] However, both traditional segmentation algorithms and AI-trained segmentation algorithms inevitably produce false positives in practical applications. Current technologies primarily reduce these false positives through parameter adjustment, algorithm optimization, or model optimization. However, these methods all require repeated parameter tuning and testing, iterative algorithm optimization, and dataset training optimization. This process is cumbersome, time-consuming, and labor-intensive, significantly increasing detection costs and cycles, severely impacting industrial production efficiency. More importantly, while reducing the false positive rate through these methods, false negatives are also highly likely. False negatives mean that actual internal voids or foreign object defects in the product are not identified, posing significant quality and safety risks. In short, current technologies cannot effectively balance the need to reduce false positive rates with the risk of false negatives, failing to meet the actual needs of industrial production for accurate detection of internal product defects.

[0006] Therefore, existing technologies still need improvement and development. Summary of the Invention

[0007] The technical problem to be solved by the present invention is to provide a method, device, terminal and storage medium for preventing false judgments in internal defect detection, in order to address the above-mentioned deficiencies of the prior art. The aim is to solve the problems that existing defect detection algorithms require repeated parameter tuning and testing and optimization of dataset training, resulting in high maintenance costs, and the risk of missed judgments may occur in the process of reducing false judgments.

[0008] The technical solution adopted by this invention to solve the problem is as follows: In a first aspect, embodiments of the present invention provide a method for preventing false positives in internal defect detection, the method comprising: Obtain a candidate contour set generated based on the product detection image. For each candidate contour in the candidate contour set, extract the corresponding binarized features and perform morphological dilation on the binarized features to obtain updated binarized features. The neighborhood features corresponding to the candidate contour are generated based on the binarized features and the updated binarized features; Based on the product detection image, the binarization features, and the neighborhood features, generate the grayscale image of the candidate contour and the grayscale image of the neighborhood. For each grayscale image in the outline grayscale image and the neighborhood grayscale image, a cumulative probability density function is calculated based on the grayscale statistical information of the grayscale image; The overlapping grayscale state is determined based on the cumulative probability density functions corresponding to the outline grayscale image and the neighborhood grayscale image, respectively. Based on the overlapping grayscale states, the probability that the candidate contour is an internal defect is determined.

[0009] In one implementation, the step of generating neighborhood features corresponding to the candidate contour based on the binarized features and the updated binarized features includes: The neighborhood features are obtained by subtracting the binarized features from the updated binarized features.

[0010] In one implementation, the step of generating the contour grayscale image and the neighborhood grayscale image corresponding to the candidate contour based on the product detection image, the binarization features, and the neighborhood features includes: The contour grayscale image is generated based on the product detection image and the binarized features; The neighborhood grayscale image is generated based on the product detection image and the neighborhood features.

[0011] In one embodiment, the step of generating the contour grayscale image based on the product detection image and the binarized features includes: All pixels of the candidate contour are selected from the product detection image based on the binarized features; Extract the grayscale values ​​of all pixels of the candidate contour to form the contour grayscale image.

[0012] In one embodiment, the step of generating the neighborhood grayscale image based on the product detection image and the neighborhood features includes: Based on the neighborhood features, select all pixels in the neighborhood region corresponding to the candidate contour from the product detection image; Extract the grayscale values ​​of all pixels in the neighborhood region to form the neighborhood grayscale image.

[0013] In one embodiment, the step of calculating the cumulative probability density function based on the grayscale statistical information of the grayscale image includes: Count the frequency and probability of each grayscale value in the grayscale image; The cumulative probability density function of the grayscale image is calculated based on the frequency and probability of occurrence of each grayscale value.

[0014] In one implementation, the step of determining the overlapping grayscale state based on the cumulative probability density functions corresponding to the contour grayscale image and the neighborhood grayscale image includes: The overlapping grayscale interval is determined based on the cumulative probability density functions corresponding to the outline grayscale image and the neighborhood grayscale image, respectively. Calculate the weight of the overlapping grayscale interval in the cumulative probability density of the neighboring grayscale image to obtain the first weight; The weight of the overlapping grayscale interval in the cumulative probability density of the outline grayscale image is calculated to obtain the second weight; The first weight and the second weight are compared with their respective weight thresholds, and the overlapping grayscale state is determined based on the comparison results.

[0015] Secondly, embodiments of the present invention also provide a device for preventing false positives in internal defect detection, the device comprising: The feature extraction module is used to obtain a candidate contour set generated based on the product detection image. For each candidate contour in the candidate contour set, the module extracts the corresponding binarized features and performs morphological dilation on the binarized features to obtain updated binarized features. The feature processing module is used to generate neighborhood features corresponding to the candidate contour based on the binarized features and the updated binarized features; The grayscale image generation module is used to generate a contour grayscale image and a neighborhood grayscale image corresponding to the candidate contour based on the product detection image, the binarization features, and the neighborhood features. The grayscale image statistics module is used to calculate the cumulative probability density function for each grayscale image among the outline grayscale image and the neighborhood grayscale image, based on the grayscale statistical information of the grayscale image. The overlap calculation module is used to determine the overlapping grayscale state based on the cumulative probability density functions corresponding to the outline grayscale image and the neighborhood grayscale image, respectively. The defect judgment module is used to determine the probability that the candidate contour is an internal defect based on the overlapping grayscale state.

[0016] Thirdly, embodiments of the present invention also provide a terminal, the terminal including a memory and one or more processors; the memory stores one or more programs; the programs include instructions for executing the anti-false positive method for internal defect detection as described above; the processor is used to execute the programs.

[0017] Fourthly, embodiments of the present invention also provide a computer-readable storage medium having stored thereon a plurality of instructions adapted to be loaded and executed by a processor to implement the steps of the method for preventing false positives in internal defect detection as described above.

[0018] The beneficial effects of this invention are as follows: This invention eliminates the need for cumbersome parameter tuning and optimization processes. Instead, it constructs a new internal defect detection and judgment logic through candidate contour feature analysis and grayscale feature quantization comparison, which effectively reduces misjudgment and fundamentally avoids the risk of missed judgment due to optimization operations. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a flowchart illustrating the method for preventing false positives in internal defect detection provided in this embodiment of the invention.

[0021] Figure 2 This is a schematic diagram of the binarization features, updated binarization features, and neighborhood features provided in the embodiments of the present invention.

[0022] Figure 3 These are the grayscale ROI images of the binarized features and the neighborhood features provided in the embodiments of the present invention.

[0023] Figure 4 This is a schematic diagram of the overlapping grayscale range provided in an embodiment of the present invention.

[0024] Figure 5 This is a schematic diagram of the module of the anti-false judgment device for internal defect detection provided in an embodiment of the present invention.

[0025] Figure 6 This is a schematic diagram of the terminal provided in the embodiment of the present invention. Detailed Implementation

[0026] This invention discloses a method, apparatus, terminal, and storage medium for preventing false positives in internal defect detection. To make the objectives, technical solutions, and effects of this invention clearer and more explicit, the invention is 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 for explaining the invention and are not intended to limit the invention.

[0027] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this specification means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we say an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein can include wireless connections or wireless coupling. The term “and / or” as used herein includes all or any units and all combinations of one or more associated listed items.

[0028] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as herein.

[0029] To address the aforementioned deficiencies in existing technologies, this invention provides a method for preventing false positives in internal defect detection. The method includes: acquiring a candidate contour set generated from a product inspection image; for each candidate contour in the candidate contour set, extracting the corresponding binarized features and performing morphological dilation on the binarized features to obtain updated binarized features; generating neighborhood features corresponding to the candidate contour based on the binarized features and the updated binarized features; generating a contour grayscale image and a neighborhood grayscale image corresponding to the candidate contour based on the product inspection image, the binarized features, and the neighborhood features; calculating a cumulative probability density function for each grayscale image in the contour grayscale image and the neighborhood grayscale image based on the grayscale statistical information of the grayscale image; determining an overlapping grayscale state based on the cumulative probability density functions corresponding to the contour grayscale image and the neighborhood grayscale image respectively; and determining the probability that the candidate contour is an internal defect based on the overlapping grayscale state. This invention eliminates the need for cumbersome parameter tuning and optimization processes. Instead, it constructs a new logic for detecting and judging internal defects by analyzing candidate contour features and comparing grayscale features, which effectively reduces misjudgments and fundamentally avoids the risk of missed judgments due to optimization operations.

[0030] like Figure 1 As shown, the method includes: Step S100: Obtain a candidate contour set generated based on the product detection image. For each candidate contour in the candidate contour set, extract the corresponding binarized features and perform morphological dilation on the binarized features to obtain updated binarized features.

[0031] Specifically, the preliminary feature processing of product inspection images includes: obtaining a candidate contour set, extracting binarized features, and morphological dilation. First, the product inspection image is processed using a segmentation algorithm to identify and segment all contour regions suspected of being internal defects, generating a candidate contour set based on these regions. This candidate contour set is the object of all subsequent feature extraction and analysis operations, defining the initial range for determining internal defects. Next, for each candidate contour in the candidate contour set, its corresponding binarized features are extracted and defined as `mask_dst`. Binarization features can isolate candidate contours from the complex background of the product inspection image, clearly representing their morphological features in a black-and-white binary form, thus eliminating background interference. After obtaining the binarized features corresponding to each candidate contour, a morphological dilation operation is performed on these features. This morphological dilation process reasonably expands the contour shape of the binarized features, resulting in an updated binarized feature, which is defined as `mask_dilate`. The purpose of morphological dilation is to capture the morphological information of the surrounding neighborhood of the candidate contour, so that the updated binarized features retain the morphological features of the original candidate contour and also incorporate the morphological features of its surrounding area.

[0032] Step S200: Generate neighborhood features corresponding to the candidate contour based on the binarized features and the updated binarized features.

[0033] Further, the step of generating neighborhood features corresponding to the candidate contour based on the binarized features and the updated binarized features includes: The neighborhood features are obtained by subtracting the binarized features from the updated binarized features.

[0034] Specifically, in the preceding steps, the candidate contour's corresponding binarized features have been extracted, and updated binarized features have been obtained through morphological dilation of the binarized features. The binarized features precisely represent only the region of the candidate contour itself, while the updated binarized features extend outwards from the binarized features, encompassing both the candidate contour's own region and its surrounding neighborhood. This difference in morphological range provides a data foundation for extracting neighborhood features. This embodiment utilizes this morphological difference to perform a feature subtraction operation, subtracting the original binarized features of the candidate contour from the updated binarized features obtained through morphological dilation. This subtraction operation accurately eliminates the overlapping regions of the candidate contour itself, retaining only the newly added surrounding neighborhood regions around the candidate contour in the updated binarized features, thus obtaining the neighborhood features corresponding to the candidate contour (e.g., the original binarized features of the candidate contour). Figure 2As shown in the figure, this neighborhood feature is defined as mask_background. The generated neighborhood feature can accurately and independently represent the neighborhood region information around the candidate contour, realizing feature separation between the candidate contour itself and the surrounding neighborhood region.

[0035] Step S300: Based on the product detection image, the binarized features, and the neighborhood features, generate the contour grayscale image and the neighborhood grayscale image corresponding to the candidate contour.

[0036] Specifically, the binarized features and neighborhood features obtained in the previous steps are combined with the product inspection image. The grayscale information of the product inspection image is extracted regionally through feature masking, thereby obtaining the grayscale images of the candidate contour itself and its surrounding neighborhood, namely the contour grayscale image and the neighborhood grayscale image, which provides data support for subsequent judgment of internal defects by comparing grayscale features.

[0037] In one implementation, the step of generating the contour grayscale image and the neighborhood grayscale image corresponding to the candidate contour based on the product detection image, the binarization features, and the neighborhood features includes: The contour grayscale image is generated based on the product detection image and the binarized features; The neighborhood grayscale image is generated based on the product detection image and the neighborhood features.

[0038] Further, the step of generating the contour grayscale image based on the product detection image and the binarized features includes: All pixels of the candidate contour are selected from the product detection image based on the binarized features; Extract the grayscale values ​​of all pixels of the candidate contour to form the contour grayscale image.

[0039] Further, the step of generating the neighborhood grayscale image based on the product detection image and the neighborhood features includes: Based on the neighborhood features, select all pixels in the neighborhood region corresponding to the candidate contour from the product detection image; Extract the grayscale values ​​of all pixels in the neighborhood region to form the neighborhood grayscale image.

[0040] Specifically, the generation of the contour grayscale image includes: using the binarized feature mask_dst obtained in the aforementioned steps as the basis for region delimitation, accurately selecting all pixels in the candidate contour region from the product detection image (i.e., the original image) to exclude background pixels unrelated to the candidate contour, ensuring that the subsequently extracted grayscale information belongs only to the candidate contour itself; after the selection is completed, further extracting the grayscale values ​​of all pixels of these selected candidate contours to form the contour grayscale image corresponding to the candidate contour. This contour grayscale image can be regarded as a grayscale ROI image and is defined as gray_dst, its function being to completely preserve the grayscale distribution characteristics of the candidate contour itself. The generation of the neighborhood grayscale image is basically the same as that of the contour grayscale image, the only difference being the region delimitation basis and the extracted region. When generating the neighborhood grayscale image, the neighborhood feature mask_background obtained in the aforementioned steps is also used as the basis for region delimitation to accurately select all pixels in the neighborhood region corresponding to the candidate contour from the product detection image, ensuring that only the effective pixels of the neighborhood region are retained. Subsequently, the grayscale values ​​of all selected pixels within the neighborhood are extracted to form a neighborhood grayscale map corresponding to the candidate contour. This neighborhood grayscale map can also be regarded as a grayscale ROI map and is defined as gray_background. Its function is to completely preserve the grayscale distribution features of the neighborhood region surrounding the candidate contour (e.g., Figure 3 (As shown).

[0041] Step S400: For each grayscale image in the contour grayscale image and the neighborhood grayscale image, calculate the cumulative probability density function based on the grayscale statistical information of the grayscale image.

[0042] Further, the step of calculating the cumulative probability density function based on the grayscale statistical information of the grayscale image includes: Count the frequency and probability of each grayscale value in the grayscale image; The cumulative probability density function of the grayscale image is calculated based on the frequency and probability of occurrence of each grayscale value.

[0043] In summary, this embodiment quantifies the grayscale distribution characteristics of a statistical grayscale image through grayscale statistics and cumulative operations, generating a cumulative probability density function that reflects the cumulative pattern of grayscale, thus providing a data foundation for subsequent comparison of the grayscale feature differences between candidate contours and neighboring regions. Specifically, for the two features, gray_dst (contour grayscale image) and gray_background (neighboring grayscale image), grayscale statistics and cumulative probability calculations need to be performed on each grayscale image separately: First, the frequency and probability of occurrence of each grayscale value in the grayscale image are counted. For any grayscale image, the entire grayscale interval is defined as L, and the range of grayscale level k is [0, L]. The number n pixels with grayscale level k is obtained through statistics. kThis value can be represented by the function f(k), i.e., n k =f(k). Based on this, calculate the probability p of the occurrence of gray level k. k It is the number of pixels n with gray level k. k Divide by the total number of pixels in the grayscale image, W*H, that is, p k =f(k) / (W*H), where W*H represents the product of the width and height of the current ROI grayscale image, i.e., the total number of pixels. The above calculation process can be summarized as follows:

[0044] The probability p of each grayscale value is obtained. k Next, the cumulative probability density function F(k) of the ROI grayscale image is calculated. The calculation method is as follows: for all probabilities p from grayscale level 0 to the current grayscale level k... k To perform a cumulative summation, that is... .

[0045] Understandably, this accumulation process essentially reflects the cumulative probability of gray values ​​from 0 to k in the grayscale image. For example, when k is L, F(L) is the sum of the probabilities of all gray levels, with a value of 1. By calculating the cumulative probability density function for the contour grayscale image gray_dst and the neighborhood grayscale image gray_background respectively, the cumulative grayscale distribution characteristics of the two grayscale images can be obtained. These characteristics can be directly used to determine the overlapping grayscale state of the two images, thus providing a key basis for determining whether the region corresponding to the candidate contour is an internal defect.

[0046] Step S500: Determine the overlapping grayscale state based on the cumulative probability density functions corresponding to the contour grayscale image and the neighborhood grayscale image, respectively.

[0047] Further, the step of determining the overlapping grayscale state based on the cumulative probability density functions corresponding to the contour grayscale image and the neighborhood grayscale image respectively includes: The overlapping grayscale interval is determined based on the cumulative probability density functions corresponding to the outline grayscale image and the neighborhood grayscale image, respectively. Calculate the weight of the overlapping grayscale interval in the cumulative probability density of the neighboring grayscale image to obtain the first weight; The weight of the overlapping grayscale interval in the cumulative probability density of the outline grayscale image is calculated to obtain the second weight; The first weight and the second weight are compared with their respective weight thresholds, and the overlapping grayscale state is determined based on the comparison results.

[0048] In summary, this embodiment requires performing interval operations and threshold comparisons on the cumulative probability density functions of the outline grayscale image and the neighboring grayscale image to transform the overlap relationship of their grayscale distributions into a quantifiable weight index, thereby accurately determining the degree of overlap between grayscale intervals. Specifically, given the cumulative probability density function of the neighboring grayscale image gray_background... The cumulative probability density function of the grayscale image gray_dst Based on this, the first step is to determine the overlapping grayscale range. ,in This represents the lower limit of the grayscale value of the overlapping grayscale range. This represents the upper limit of the grayscale values ​​in the overlapping grayscale range. A simple grayscale histogram of both regions can be plotted in the same grayscale space to visually represent the overlapping portion of the grayscale distribution, thus clarifying the range of the overlapping region (e.g., ...). Figure 4 (As shown).

[0049] Next, it is necessary to calculate the weight of the overlapping grayscale region in the cumulative probability density of each of the two grayscale images. For the neighboring grayscale image gray_background, the first weight of its overlapping region is... The cumulative probability density is the difference between the endpoints of the interval. This value reflects the cumulative probability that the gray values ​​in the neighboring grayscale images fall within the overlapping interval, and its value ranges from [0,1]. Similarly, for the contour grayscale image gray_dst, its second weight for the overlapping interval is... This is the difference in cumulative probability density at the endpoints of the interval. This value reflects the cumulative probability that the gray value in the contour grayscale image falls within the overlapping interval, and its value ranges from [0,1]. The specific calculation process is summarized as follows: ; in, This refers to the high grayscale weight corresponding to the neighboring grayscale image. This refers to the low grayscale weight corresponding to the outline grayscale image.

[0050] Finally, the calculated first weight Second weight Each is compared with a pre-set weight threshold. , A comparison is made to quantify the overlapping grayscale state between the neighborhood grayscale image and the outline grayscale image. This is the weight threshold for the grayscale information of neighboring areas within the overlapping region; The weight threshold for the grayscale information of the outline.

[0051] For example, the method for determining the overlapping grayscale state of the neighborhood grayscale image and the outline grayscale image is as follows: 1. When Greater than or equal to ,and Less than or equal to At that time, the overlapping grayscale state of the neighborhood grayscale image and the contour grayscale image is: the overlapping grayscale has a small proportion of grayscale in both the candidate contour and the candidate contour neighborhood.

[0052] 2. When Less than ,and Less than or equal to At this time, the overlapping grayscale state of the neighborhood grayscale image and the outline grayscale image is: the overlapping grayscale has a large proportion of grayscale in the neighborhood of the candidate outline, but a small proportion of grayscale in the candidate outline.

[0053] 3. When Greater than or equal to ,and Greater than At that time, the overlapping grayscale state of the neighborhood grayscale image and the outline grayscale image is: the overlapping grayscale has a small proportion of grayscale in the neighborhood of the candidate outline, but a large proportion of grayscale in the candidate outline.

[0054] 4. When Less than ,and Greater than At that time, the overlapping grayscale state of the neighborhood grayscale image and the contour grayscale image is: the overlapping grayscale has a large proportion of grayscale in both the candidate contour and the candidate contour neighborhood.

[0055] Step S600: Based on the overlapping grayscale state, determine the possibility that the candidate contour is an internal defect.

[0056] Specifically, if the overlap gray level is high, it indicates that the candidate contour is more likely not a real bubble or foreign object, that is, the candidate contour is more likely to be a false defect; if the overlap gray level is low, it indicates that the candidate contour is more likely to be a real bubble or foreign object, that is, the candidate contour is more likely to be a real internal defect.

[0057] For example, the method for determining whether a candidate contour is an internal defect is as follows: 1. When Greater than or equal to ,and Less than or equal to When this condition is met, it indicates that the candidate contour and its neighborhood belong to different grayscale features. This situation is a strong condition, and the candidate contour is determined to be a bubble. 2. When Less than ,and Less than or equal to When this condition occurs, it means that most of the high grayscale regions in the neighborhood of the candidate contour are located in a small part of the low grayscale regions of the candidate contour. This condition is a weak condition, which can filter out inconspicuous bubbles, but may also fail to filter out noise with similar grayscale characteristics to inconspicuous bubbles.

[0058] 3. When Greater than or equal to ,and Greater than When the grayscale range of the candidate contour neighborhood includes most of the grayscale range of the candidate contour, the candidate contour is determined not to be a bubble.

[0059] 4. When Less than ,and Greater than When the gray levels of the candidate contour and its neighborhood are basically overlapping, the candidate contour is determined not to be a bubble.

[0060] The advantages of this invention include: This invention can accurately filter out non-real defects and effectively avoid missed detections. By calculating the cumulative probability density information of each gray level in the segmented candidate contour region and its neighborhood, the gray level interval of the overlapping part is obtained. Then, the cumulative probability weight of the overlapping interval in the candidate region and its neighborhood is calculated. Finally, the degree of gray level overlap of the candidate region and its neighborhood is quantified by a weight threshold, thereby filtering out non-real bubbles or foreign objects and achieving the effect of correcting the algorithm. From a technical design perspective, it avoids missed detections. The key lies in extracting feature regions and their neighborhoods in the gray space and accurately judging real and false defects by quantifying the overlapping gray level state, thus reducing the false detection rate and avoiding the risk of missed detections.

[0061] Secondly, this invention effectively solves the maintenance pain points of existing algorithms. In existing technologies, reducing false judgments often relies on repeated parameter tuning, model optimization, or iterative training of datasets, which is cumbersome and time-consuming. However, this invention uses weight thresholds to quantify the degree of grayscale overlap, eliminating the need for complex parameter tuning or model reconstruction. Algorithm correction can be achieved simply through standardized grayscale statistics and weight calculation, greatly simplifying the algorithm maintenance process and improving detection efficiency and stability.

[0062] Furthermore, the principle of this invention has strong universality. Although it is a statistical quantification of the gray values ​​of pixels in gray space, the principle is not limited to gray space. For other scenarios that require the separation of signals or elements, the core logic of this invention is still effective. It has cross-scenario technical extensibility and can be transferred to more detection scenarios that require the distinction between target and background, signal and noise, and has high reuse value.

[0063] Based on the above embodiments, the present invention also provides a device for preventing false positives in internal defect detection, such as... Figure 5 As shown, the device includes: The feature extraction module 01 is used to obtain a candidate contour set generated based on the product detection image. For each candidate contour in the candidate contour set, the module extracts the corresponding binarized feature and performs morphological dilation on the binarized feature to obtain an updated binarized feature. Feature processing module 02 is used to generate neighborhood features corresponding to the candidate contour based on the binarized features and the updated binarized features; The grayscale image generation module 03 is used to generate a grayscale image of the candidate contour and a grayscale image of the neighborhood based on the product detection image, the binarization features and the neighborhood features. The grayscale image statistics module 04 is used to calculate the cumulative probability density function for each grayscale image among the outline grayscale image and the neighborhood grayscale image, based on the grayscale statistical information of the grayscale image. The overlap calculation module 05 is used to determine the overlapping grayscale state based on the cumulative probability density functions corresponding to the outline grayscale image and the neighborhood grayscale image, respectively. The defect judgment module 06 is used to determine the possibility that the candidate contour is an internal defect based on the overlapping grayscale state.

[0064] Based on the above embodiments, the present invention also provides a terminal, the principle block diagram of which can be as follows: Figure 6 As shown, the terminal includes a processor, memory, network interface, and display screen connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements a method to prevent false positives in internal defect detection. The display screen can be an LCD screen or an e-ink screen.

[0065] Those skilled in the art will understand that Figure 6 The schematic diagram shown is merely a partial structural diagram related to the present invention and does not constitute a limitation on the terminal to which the present invention is applied. A specific terminal may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0066] In one implementation, the terminal's memory stores one or more programs, and these programs are configured to be executed by one or more processors, and include instructions for a method to prevent false positives in internal defect detection.

[0067] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided by this invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0068] In summary, this invention discloses a method, apparatus, terminal, and storage medium for preventing false positives in internal defect detection. The method includes: acquiring a candidate contour set generated based on a product inspection image; for each candidate contour in the candidate contour set, extracting the corresponding binarized features and performing morphological dilation on the binarized features to obtain updated binarized features; generating neighborhood features corresponding to the candidate contour based on the binarized features and the updated binarized features; generating a contour grayscale image and a neighborhood grayscale image corresponding to the candidate contour based on the product inspection image, the binarized features, and the neighborhood features; calculating a cumulative probability density function for each grayscale image in the contour grayscale image and the neighborhood grayscale image based on the grayscale statistical information of the grayscale image; determining the overlapping grayscale state based on the cumulative probability density functions corresponding to the contour grayscale image and the neighborhood grayscale image respectively; and determining the probability that the candidate contour is an internal defect based on the overlapping grayscale state. This invention eliminates the need for cumbersome parameter tuning and optimization processes. Instead, it constructs a new logic for detecting and judging internal defects by analyzing candidate contour features and comparing grayscale features, which effectively reduces misjudgments and fundamentally avoids the risk of missed judgments due to optimization operations.

[0069] It should be understood that the application of the present invention is not limited to the examples above. Those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.

Claims

1. A method for preventing false positives in internal defect detection, characterized in that, The method includes: Obtain a candidate contour set generated based on the product detection image. For each candidate contour in the candidate contour set, extract the corresponding binarized features and perform morphological dilation on the binarized features to obtain updated binarized features. The neighborhood features corresponding to the candidate contour are generated based on the binarized features and the updated binarized features; Based on the product detection image, the binarization features, and the neighborhood features, generate the grayscale image of the candidate contour and the grayscale image of the neighborhood. For each grayscale image in the outline grayscale image and the neighborhood grayscale image, a cumulative probability density function is calculated based on the grayscale statistical information of the grayscale image; The overlapping grayscale state is determined based on the cumulative probability density functions corresponding to the outline grayscale image and the neighborhood grayscale image, respectively. Based on the overlapping grayscale states, the probability that the candidate contour is an internal defect is determined.

2. The method for preventing false positives in internal defect detection according to claim 1, characterized in that, The step of generating neighborhood features corresponding to the candidate contour based on the binarized features and the updated binarized features includes: The neighborhood features are obtained by subtracting the binarized features from the updated binarized features.

3. The method for preventing false positives in internal defect detection according to claim 1, characterized in that, The steps of generating the grayscale image of the candidate contour and the grayscale image of its neighborhood based on the product detection image, the binarized features, and the neighborhood features include: The contour grayscale image is generated based on the product detection image and the binarized features; The neighborhood grayscale image is generated based on the product detection image and the neighborhood features.

4. The method for preventing false positives in internal defect detection according to claim 3, characterized in that, The step of generating the contour grayscale image based on the product detection image and the binarized features includes: All pixels of the candidate contour are selected from the product detection image based on the binarized features; Extract the grayscale values ​​of all pixels of the candidate contour to form the contour grayscale image.

5. The method for preventing false positives in internal defect detection according to claim 3, characterized in that, The step of generating the neighborhood grayscale image based on the product detection image and the neighborhood features includes: Based on the neighborhood features, select all pixels in the neighborhood region corresponding to the candidate contour from the product detection image; Extract the grayscale values ​​of all pixels in the neighborhood region to form the neighborhood grayscale image.

6. The method for preventing false positives in internal defect detection according to claim 1, characterized in that, The steps for calculating the cumulative probability density function based on the grayscale statistics of the grayscale image include: Count the frequency and probability of each grayscale value in the grayscale image; The cumulative probability density function of the grayscale image is calculated based on the frequency and probability of occurrence of each grayscale value.

7. The method for preventing false positives in internal defect detection according to claim 1, characterized in that, The steps for determining the overlapping grayscale state based on the cumulative probability density functions corresponding to the contour grayscale image and the neighborhood grayscale image respectively include: The overlapping grayscale interval is determined based on the cumulative probability density functions corresponding to the outline grayscale image and the neighborhood grayscale image, respectively. Calculate the weight of the overlapping grayscale interval in the cumulative probability density of the neighboring grayscale image to obtain the first weight; The weight of the overlapping grayscale interval in the cumulative probability density of the outline grayscale image is calculated to obtain the second weight; The first weight and the second weight are compared with their respective weight thresholds, and the overlapping grayscale state is determined based on the comparison results.

8. A device for preventing false positives in internal defect detection, characterized in that, The device includes: The feature extraction module is used to obtain a candidate contour set generated based on the product detection image. For each candidate contour in the candidate contour set, the module extracts the corresponding binarized features and performs morphological dilation on the binarized features to obtain updated binarized features. The feature processing module is used to generate neighborhood features corresponding to the candidate contour based on the binarized features and the updated binarized features; The grayscale image generation module is used to generate a contour grayscale image and a neighborhood grayscale image corresponding to the candidate contour based on the product detection image, the binarization features, and the neighborhood features. The grayscale image statistics module is used to calculate the cumulative probability density function for each grayscale image among the outline grayscale image and the neighborhood grayscale image, based on the grayscale statistical information of the grayscale image. The overlap calculation module is used to determine the overlapping grayscale state based on the cumulative probability density functions corresponding to the outline grayscale image and the neighborhood grayscale image, respectively. The defect judgment module is used to determine the probability that the candidate contour is an internal defect based on the overlapping grayscale state.

9. A terminal, characterized in that, The terminal includes a memory and one or more processors; the memory stores one or more programs; the programs contain instructions for executing the method for preventing false positives in internal defect detection as described in any one of claims 1 to 7; the processors are used to execute the programs.

10. A computer-readable storage medium storing a plurality of instructions thereon, characterized in that, The instructions are applicable to be loaded and executed by a processor to implement the steps of the method for preventing false positives in the detection of internal defects as described in any one of claims 1 to 7.