Anomaly score graph binarization method and device based on the stability of the number of connected domains
By adaptively determining the threshold search space and analyzing the changes in the number of connected domains, the problem of false detection and missed detection of the binarization method in industrial anomaly detection is solved, and more accurate defect area segmentation is achieved.
Patent Information
- Application Number
- CN202411093690.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2044-08-09
AI Technical Summary
In existing industrial anomaly detection scenarios, binarization methods are difficult to effectively suppress both false defect detection and missed detection. In particular, the fixed threshold method and Otsu method have poor applicability between different anomaly detection models and data sets, resulting in high labor consumption and inaccurate binarization results.
By adaptively determining the threshold search space and adaptively estimating the threshold of each anomaly score map according to the change in the number of connected domains in the binarization result when the threshold changes, the binarization processing is performed using the stability of the number of connected domains.
The robustness and reliability of the binarization results are improved, the false detection and missed detection of defects are reduced, and the ability to accurately locate the defect position is enhanced.
Smart Images

Figure CN119027384B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision technology, and in particular to an anomaly score based on the stability of the number of connected domains. Figure 2 Value method and device. Background Art
[0002] Industrial anomaly detection technology plays a vital role in industrial automation and quality control. It can automatically detect defects in products on the production line, ensuring that product quality meets high standards. Industrial anomaly detection involves detecting images containing surface defects and the locations of the defects within a large amount of industrial product image data. Existing industrial anomaly detection methods generally quantify the probability of anomaly for each pixel in the input image and construct an anomaly score map, the same size as the original image. This is an effective means of assessing product surface defects. However, the anomaly score map only displays the probability of anomaly for each pixel and cannot determine which pixels are abnormal. Therefore, it is necessary to binarize the map to obtain a segmentation result of the abnormal regions in the image. Furthermore, binarization is an essential preprocessing step for many downstream tasks. For example, in the task of discovering new industrial anomaly categories, binarizing the anomaly score map beforehand to segment the abnormal regions facilitates the network's learning of the abnormal regions. In defect generation tasks, the anomaly images and their binarized segmentation results can be used to train a generative model to produce more abnormal images and corresponding annotations, saving the cost of manual annotation. It can be seen that binarization of anomaly score maps is a necessary task in actual industrial production lines and has great application prospects.
[0003] Existing methods for binarizing anomaly score maps in industrial scenarios include the fixed threshold method and the Otsu method. The fixed threshold method artificially applies a uniform threshold to all anomaly score images for binarization, setting the grayscale values of pixels with anomaly scores below the threshold to 0, and vice versa. This method requires manual threshold selection, requiring the trial and evaluation of as many thresholds as possible to select a threshold that minimizes false defect detections and omissions in the binarized results. Furthermore, the same threshold may not be applicable to anomaly score maps output by different anomaly detection models. Changing anomaly detection methods or datasets requires re-selecting the threshold, which is labor-intensive and has limited universality. The Otsu method assumes that each grayscale image to be binarized has a foreground and background (corresponding to defects and normal areas, respectively, in industrial anomaly detection scenarios) and exhibits a bimodal distribution (i.e., the foreground and background pixel groups each follow different distributions, with their corresponding means being far apart, meaning the two distributions are somewhat separable). The threshold is then selected to maximize the difference between the foreground and background after image segmentation (i.e., maximize the between-class variance). In the industrial anomaly detection scenario, the main disadvantage of Otsu's method is that most of the images in actual industrial production are normal images, with no distinction between foreground and background. Its assumption that "each grayscale image to be binarized has a foreground and background" is no longer valid, which will lead to a large number of false detections in the binarization results of these large numbers of normal images.
[0004] In summary, in industrial anomaly detection scenarios, both the fixed threshold method and the Otsu method have obvious drawbacks, and it is difficult to achieve the corresponding binary results with low false detection and missed defects.
[0005] In view of this, overcoming the defects of the prior art is an urgent problem to be solved in this technical field. Summary of the Invention
[0006] The technical problem to be solved by the present invention is that in industrial anomaly detection scenarios, it is difficult for existing technologies to achieve the effect of low false detection and missed detection of corresponding binarization results.
[0007] The present invention adopts the following technical solutions:
[0008] In the first aspect, the present invention provides an anomaly score based on the stability of the number of connected domains. Figure 2 Value methods include:
[0009] In step 201, the whole-image anomaly score corresponding to each anomaly score map is counted, and the search space of the threshold is adaptively determined;
[0010] In step 202, for the anomaly score graph A i , perform exhaustive search at equal intervals in the threshold search space, and count the number of A under each threshold iThe number of connected domains in the binarization result;
[0011] In step 203, for the anomaly score graph A i , according to the change in the number of connected domains of the binary result when the threshold changes, A is adaptively estimated i The corresponding threshold is then binarized;
[0012] In step 204, all anomaly score maps {A i |i∈[1,N]} Repeat steps 202 and 203 to obtain the corresponding binarization result {M i |i∈[1,N]}.
[0013] Preferably, the method of calculating the whole-image anomaly score corresponding to each anomaly score map and adaptively determining the search space of the threshold specifically includes:
[0014] Calculate {A i The anomaly score of each anomaly score map in |i∈[1,N]} is {s i |i∈[1,N]}, where s i is the anomaly score map A i Pixel value A i The maximum value of (p);
[0015] Further calculate the maximum value of the anomaly score corresponding to this batch of anomaly score maps: s max =max(s1,s2,…,s N ), s min =min(s1,s2,…,s N );
[0016] The search space for determining the threshold is [s min ,s max ].
[0017] Preferably, the exhaustive search is performed at equal intervals in the threshold search space, and the number of A under each threshold is counted. i The number of connected domains in the binarization result, including:
[0018] From the threshold interval [s min ,s max ] uniformly sample 64 thresholds to obtain {ε j |j∈[1,64]};
[0019] The interval between two adjacent thresholds is Using the threshold ε j To A i Perform binarization and set the value greater than or equal to the threshold ε j The pixel value is set to 1, which is less than the threshold ε j The pixel value is set to 0, thus obtaining a binary image
[0020] right Perform image erosion to remove noise and count the number of connected domains in the erosion result graph
[0021] Use {ε j Repeat the above operation for all thresholds in |j∈[1,64]} to obtain the sequence of the number of connected domains in the binarization result corresponding to the increasing threshold
[0022] Preferably, the size of the corrosion kernel used in the corrosion operation is 6×6.
[0023] Preferably, the adaptive estimation of A is performed according to the change in the number of connected domains of the binarization result when the threshold value changes. i The corresponding threshold is then binarized, including:
[0024] Take A i The number of connected components corresponding to the binarization result The mode of the number of connected domains with non-zero values in A is taken as i Estimated value of the number of corresponding defective areas
[0025] Finding the sequence of connected domain numbers middle All corresponding subsequences with the same value are determined according to the subsequence with the same value. i The corresponding threshold;
[0026] Estimated value based on threshold For the anomaly score graph A i Perform binarization to obtain image I i The corresponding binarization result M i .
[0027] Preferably, the sequence of finding the number of connected domains is middle All corresponding subsequences with the same value are determined according to the subsequence with the same value. i The corresponding thresholds include:
[0028] If it does not exist If the length of the corresponding subsequences of the same value or all subsequences of the same value is less than 4, change A i Estimated value of the number of corresponding defective areas is 0, take A i The corresponding threshold estimate is 1;
[0029] If exists For subsequences of the same value whose length is greater than or equal to 4, the longest sequence is selected to represent the sequence with the best regional quantity stability, and then the minimum threshold among all thresholds corresponding to the sequence is selected as A. i The corresponding threshold estimate
[0030] Preferably, before calculating the full-image anomaly score corresponding to each anomaly score map, the method further includes:
[0031] For a batch of product images {I i |i∈[1,N]}, N is the number of images, and the anomaly detection model is used to generate the corresponding anomaly score map {A i |i∈[1,N]}; where A i For image I i Corresponding predicted anomaly score map.
[0032] Preferably, the anomaly detection model is a MuSc model or a CPR model.
[0033] In the second aspect, the present invention also provides an anomaly score based on the stability of the number of connected domains. Figure 2 A quantification device for realizing the anomaly score based on the stability of the number of connected domains described in the first aspect Figure 2 A method for valuing a product, the device comprising:
[0034] At least one processor; and a memory in communication with the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the processor to perform the anomaly score based on the stability of the number of connected domains described in the first aspect. Figure 2 Value method.
[0035] In a third aspect, the present invention further provides a non-volatile computer storage medium, wherein the computer storage medium stores computer-executable instructions, and the computer-executable instructions are executed by one or more processors to complete the method described in the first aspect.
[0036] In a fourth aspect, a chip is provided, comprising: a processor and an interface, for calling and running a computer program stored in a memory to execute the method of the first aspect.
[0037] In a fifth aspect, a computer program product comprising instructions is provided, which, when executed on a computer or a processor, causes the computer or the processor to execute the method of the first aspect.
[0038] The present invention adaptively determines the threshold search space and adaptively obtains the binarization threshold of each anomaly score image according to the change in the number of connected domains in the binarization result when the threshold changes, thereby more accurately locating the position of defects in the original image, having a strong ability to suppress false omissions of defects, and thus enhancing the robustness and reliability of the binarization result. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. Those skilled in the art can also derive other drawings based on these drawings without inventive effort.
[0040] Figure 1 This is the first anomaly score based on the stability of the number of connected domains provided by the embodiment of the present invention. Figure 2 Flowchart of the valuation method;
[0041] Figure 2 This is the second anomaly score based on the stability of the number of connected domains provided by the embodiment of the present invention. Figure 2 Flowchart of the valuation method;
[0042] Figure 3 This is the third type of anomaly score based on the stability of the number of connected domains provided by the embodiment of the present invention. Figure 2 Flowchart of the valuation method;
[0043] Figure 4 This is the fourth type of anomaly score based on the stability of the number of connected domains provided by the embodiment of the present invention. Figure 2 Flowchart of the valuation method;
[0044] Figure 5 An abnormal score based on the stability of the number of connected domains provided by the embodiment of the present invention is Figure 2 Schematic diagram of the valueization method;
[0045] Figure 6 An abnormal score based on the stability of the number of connected domains provided by the embodiment of the present invention is Figure 2 Schematic diagram of the architecture of the value-added device. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present 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 only used to explain the present invention and are not intended to limit the present invention.
[0047] Unless the context requires otherwise, throughout the specification and claims, the term "including" is to be interpreted as meaning open inclusion, that is, "including, but not limited to". In the description of the specification, the terms "one embodiment", "some embodiments", "exemplary embodiments", "example", "specific example" or "some examples" and the like are intended to indicate that the specific features, structures, materials or characteristics associated with the embodiment or example are included in at least one embodiment or example of the present disclosure. The schematic representation of the above terms does not necessarily refer to the same embodiment or example. In addition, the specific features, structures, materials or characteristics may be included in any one or more embodiments or examples in any appropriate manner, that is, although they may be carried in the embodiments or examples of the above terms due to reasons such as the order and position of appearance, it is not limited to that they can be carried in combination by one embodiment or example.
[0048] In the description of the present invention, the terms "first" and "second" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present disclosure, unless otherwise specified, "multiple" means two or more. In addition, for example, the description may also use the method of adding "A" and "B" at the end to describe the same type of nouns as two independent individuals. In this case, the corresponding features defined as "A" and "B" are only used to distinguish the description purposes of the same type of individuals, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.
[0049] In the description of the present invention, the expression "A and / or B" (where A and B are used to formally represent specific characteristic contents) will be involved, and the corresponding expressions include the following three combinations: only A, only B, and a combination of A and B.
[0050] As used herein, "about," "substantially," or "approximately" includes the stated value and an average value that is within an acceptable range of deviation from the particular value as determined by one of ordinary skill in the art taking into account the measurements in question and the errors associated with the measurement of the particular quantity (i.e., the limitations of the measurement system).
[0051] In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0052] Embodiment 1:
[0053] Example 1 of the present invention provides an anomaly score based on the stability of the number of connected domains Figure 2 Value methods, such as Figure 1 Shown, including:
[0054] In step 201, the full-image anomaly score corresponding to each anomaly score map (i.e., the maximum anomaly score in the map) is counted, and the search space of the threshold is adaptively determined.
[0055] In step 202, for the anomaly score graph A i , perform exhaustive search at equal intervals in the threshold search space (i.e. the search space of the above threshold), and count the number of A under each threshold i The number of connected components in the binarization result.
[0056] In step 203, for the anomaly score graph A i , according to the change in the number of connected domains of the binary result when the threshold changes, A is adaptively estimated i The corresponding threshold is set and binarized.
[0057] In step 204, all anomaly score maps {A i |i∈[1,N]} Repeat steps 202 and 203 to obtain the corresponding binarization result {M i |i∈[1,N]}.
[0058] This embodiment adaptively determines the threshold search space and adaptively obtains the binarization threshold for each anomaly score image based on the change in the number of connected domains in the binarization result when the threshold changes. This allows for more accurate positioning of defects in the original image, has a strong ability to suppress false defect detections, and thus enhances the robustness and reliability of the binarization result.
[0059] In one embodiment, the whole-image anomaly score corresponding to each anomaly score map is counted, and the search space of the threshold is adaptively determined, such as Figure 2 As shown, specifically including:
[0060] In step 301, calculate {A i The anomaly score of each anomaly score map in |i∈[1,N]} is {s i |i∈[1,N]}, where s i is the anomaly score map A i Pixel value A i (p) maximum value; p represents the p-th pixel value.
[0061] In step 302, the maximum value of the anomaly score corresponding to this batch of anomaly score maps is further calculated: s max =max(s1,s2,…,s N ), s min =min(s1,s2,…,s N ); the maximum value includes the maximum value smax and minimum value s min .
[0062] In step 303, the search space for the threshold is determined to be [s min ,s max ].
[0063] In an optional embodiment, the exhaustive search is performed at equal intervals in the threshold search space, and the number of A under each threshold is counted. i The number of connected domains in the binarization result, such as Figure 3 As shown, specifically including:
[0064] In step 401, from the threshold interval [s min ,s max ] uniformly sample 64 thresholds to obtain {ε j |j∈[1,64]}, the interval between two adjacent thresholds is
[0065] In step 402, the threshold ε is used j To A i Perform binarization and set the value greater than or equal to the threshold ε j The pixel value is set to 1, which is less than the threshold ε j The pixel value is set to 0, thus obtaining a binary image
[0066] In step 403, Perform image corrosion operation to remove noise, obtain the corrosion result map, and count the number of connected domains in the corrosion result map
[0067] In step 404, use {ε j Repeat the above operation for all thresholds in |j∈[1,64]} to obtain the sequence of the number of connected domains in the binarization result corresponding to the increasing threshold Each connected domain represents a possible defect area.
[0068] The size of the corrosion kernel used in the corrosion operation is 6×6.
[0069] In a specific application scenario, the adaptive estimation of A is performed based on the change in the number of connected domains of the binarization result when the threshold changes. i The corresponding threshold is binarized, such as Figure 4 As shown, specifically including:
[0070] In step 501, take A i The number of connected components corresponding to the binarization result The mode of the number of connected domains with non-zero values in A is taken as iEstimated value of the number of corresponding defective areas
[0071] In step 502, find the number of connected components middle All corresponding subsequences with the same value are determined according to the subsequence with the same value. i The corresponding threshold.
[0072] In step 503, the threshold value is estimated based on For the anomaly score graph A i Perform binarization to obtain image I i The corresponding binarization result M i .
[0073] Wherein, the sequence of finding the number of connected domains middle All corresponding subsequences with the same value are determined according to the subsequence with the same value. i The corresponding thresholds include:
[0074] If it does not exist If all corresponding subsequences with the same value or all subsequences with the same value have lengths less than 4, change A i Estimated value of the number of corresponding defective areas is 0, take A i The corresponding threshold estimate is 1.
[0075] If exists For subsequences of the same value whose length is greater than or equal to 4, the longest sequence is selected to represent the sequence with the best regional quantity stability, and then the minimum threshold among all thresholds corresponding to the sequence is selected as A. i The corresponding threshold estimate
[0076] In actual use, before calculating the anomaly score of the entire image corresponding to each anomaly score map, the method also includes:
[0077] For a batch of product images {I i |i∈[1,N]}, N is the number of images, and the anomaly detection model is used to generate the corresponding anomaly score map {A i |i∈[1,N]}; where A i For image I i Corresponding predicted anomaly score map.
[0078] Any anomaly detection model can be used to generate the corresponding anomaly score map {A i |i∈[1,N]}, in an optional embodiment, the anomaly detection model is a MuSc model or a CPR model.
[0079] Example 2:
[0080] The present invention is based on the method described in Example 1, combined with specific application scenarios, and uses technical descriptions in related scenarios to illustrate the implementation process of the present invention in characteristic scenarios.
[0081] This embodiment provides an anomaly score based on the stability of the number of connected domains. Figure 2 Value method.
[0082] This embodiment takes a batch of anomaly score maps output by any anomaly detection model as an example, and the operation steps of this method are as follows:
[0083] 1. Adaptively determine the search space of the threshold.
[0084] 2. Perform an exhaustive search at fixed intervals within the search space and count the number of connected domains corresponding to the binarization results for each threshold.
[0085] 3. According to the change in the number of connected domains in the binarization result when the threshold changes, the threshold corresponding to the anomaly score map is adaptively estimated and binarized.
[0086] The result of step 1 is applicable to all given anomaly score maps. There is no need to repeat this step for different anomaly score maps. Just proceed to steps 2 and 3. This invention can greatly reduce the anomaly score. Figure 2 It can eliminate the false detection and omission of defects in the binarization results and improve the accuracy and reliability of the binarization effect.
[0087] The following defines the tasks and the symbols involved: For a batch of product images {I i |i∈[1,N]}, N is the number of images, use any anomaly detection model (such as MuSc model or CPR model, etc.) to generate the corresponding anomaly score map {A i |i∈[1,N]}, where A i For image I i The task goal is to transform the anomaly score map {A i |i∈[1,N]} is binarized to ensure that the number of false detections of defects in the binarization results is as small as possible.
[0088] In order to achieve the above object, the present invention provides the following technical solutions: Figure 5 As shown, the following steps are included:
[0089] In step S1, the full-image anomaly score corresponding to each anomaly score map (the maximum value of the anomaly score in the map) is counted, and the search space of the threshold is adaptively determined:
[0090] Calculate {Ai The anomaly score of each anomaly score map in |i∈[1,N]} is {s i |i∈[1,N]}, where s i is the anomaly score map A i Pixel value A i (p) and further calculate the maximum value of the anomaly score corresponding to this batch of anomaly score maps: s max =max(s1,s2,…,s N ), s min =min(s1,s2,…,s N ), the search space for determining the threshold is [s min ,s max ].
[0091] In step S2, for the anomaly score map A i , perform exhaustive search at equal intervals in the threshold search space, and count the number of A under each threshold i The number of connected components in the binarization result:
[0092] From the threshold interval [s min ,s max ] uniformly sample 64 thresholds to obtain {ε j |j∈[1,64]}, the interval between two adjacent thresholds is Using the threshold ε j To A i Perform binarization and set the value greater than or equal to the threshold ε j The pixel value is set to 1, which is less than the threshold ε j The pixel value is set to 0, thus obtaining a binary image right Perform image erosion (with an erosion kernel size of 6×6) to remove noise, and then count the number of connected domains in the erosion result graph. Use {ε j Repeat the above operation for all thresholds in |j∈[1,64]} to obtain the sequence of the number of connected domains in the binarization result corresponding to the increasing threshold Each connected domain represents a possible defect area.
[0093] In step S3, for the anomaly score map A i , according to the change in the number of connected domains of the binary result when the threshold changes, A is adaptively estimated i The corresponding threshold is set and binarized, wherein step S3 includes step S3-1, step S3-2 and step S3-3:
[0094] In step S3-1, take A i The number of connected components corresponding to the binarization result The mode of the number of connected domains with non-zero values in A is taken as i Estimated value of the number of corresponding defective areas
[0095] In step S3-2, find the number of connected domains middle All corresponding subsequences of the same value (i.e. consecutively taking the same value subsequence): 1. If it does not exist If the length of the corresponding subsequences of the same value or all subsequences of the same value is less than 4, change A i Estimated value of the number of corresponding defective areas is 0, take A i The corresponding threshold estimate 1; 2. If it exists For subsequences of the same value whose length is greater than or equal to 4, the longest sequence is selected to represent the sequence with the best regional quantity stability, and then the minimum threshold among all thresholds corresponding to the sequence is selected as A. i The corresponding threshold estimate
[0096] In step S3-3, the threshold value is estimated based on For the anomaly score graph A i Perform binarization to obtain image I i The corresponding binarization result M i .
[0097] In step S4, all anomaly score maps {A i |i∈[1,N]} Repeat steps S2 and S3 to obtain the corresponding binarization result {M i |i∈[1,N]}.
[0098] In general, the above technical solutions conceived by the present invention have the following advantages compared with the existing methods:
[0099] Beneficial effects:
[0100] This embodiment proposes a novel anomaly score image binarization method that can adaptively determine the threshold search space and adaptively obtain the binarization threshold for each anomaly score image based on the change in the number of connected domains in the binarization result when the threshold changes. This method can more accurately locate the position of defects in the original image, has a strong ability to suppress false defect detection, and thus enhances the robustness and reliability of the binarization result.
[0101] Example 3:
[0102] like Figure 6 As shown, it is an abnormal score based on the stability of the number of connected domains according to an embodiment of the present invention. Figure 2Schematic diagram of the architecture of the value-based device. The anomaly score based on the stability of the number of connected domains in this embodiment Figure 2 The quantification device includes one or more processors 21 and a memory 22. Figure 6 A processor 21 is taken as an example.
[0103] The processor 21 and the memory 22 may be connected via a bus or other means. Figure 6 The bus connection is taken as an example.
[0104] The memory 22 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs and non-volatile computer executable programs, such as the abnormality score based on the stability of the number of connected domains in Example 1. Figure 2 The processor 21 executes the anomaly score based on the stability of the number of connected domains by running the non-volatile software program and instructions stored in the memory 22. Figure 2 Value method.
[0105] The memory 22 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state memory device. In some embodiments, the memory 22 may optionally include a memory remotely located relative to the processor 21, and such remote memory may be connected to the processor 21 via a network. Examples of such networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0106] The program instructions / modules are stored in the memory 22, and when executed by the one or more processors 21, perform the anomaly score based on the stability of the number of connected components in the above embodiment 1. Figure 2 Value method.
[0107] It is worth noting that the information interaction, execution process, etc. between the modules and units within the above-mentioned devices and systems are based on the same concept as the processing method embodiment of the present invention. The specific content can be found in the description of the method embodiment of the present invention and will not be repeated here.
[0108] Those skilled in the art will understand that all or part of the steps in the various methods of the embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, which may include: read-only memory (ROM), random access memory (RAM), a disk or an optical disk, etc.
[0109] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for binarizing anomaly score graphs based on the stability of the number of connected domains, characterized in that: include: In step 201, the whole-image anomaly score corresponding to each anomaly score map is counted, and the threshold search space is adaptively determined; In step 202, for the anomaly score map , perform exhaustive search at equal intervals in the threshold search space, and count the number of The number of connected domains in the binarization result; In step 203, for the anomaly score map , adaptively estimate the number of connected domains of the binarized result according to the change in the threshold value The corresponding threshold estimate is used to Perform binarization; In step 204, all anomaly score maps Repeat steps 202 and 203 to obtain the corresponding binarization result ; The adaptive estimation is based on the change in the number of connected domains of the binarization result when the threshold changes. The corresponding threshold estimate is used to Binarization is performed, including: Pick The number of connected components corresponding to the binarization result The mode of the number of connected domains with non-zero values is Estimated value of the number of corresponding defective areas ; Finding the sequence of connected domain numbers middle All corresponding subsequences with the same value are determined according to the subsequence with the same value The corresponding threshold estimate ; Wherein, the same value subsequence is the number sequence of connected domains middle The value is continuous subsequence; Estimated value based on threshold Anomaly score map Binarize and get the image The corresponding binarization result .
2. The method for binarizing anomaly score graphs based on the stability of the number of connected components according to claim 1, characterized in that: The method of counting the full-image anomaly scores corresponding to each anomaly score map and adaptively determining the threshold search space specifically includes: calculate The anomaly score of each anomaly score map in ,in is the anomaly score map Pixel value The maximum value of Further calculate the maximum value of the anomaly score corresponding to this batch of anomaly score maps: , ; Determine the threshold search space as .
3. The method for binarizing anomaly score graphs based on the stability of the number of connected components according to claim 1, characterized in that: The exhaustive search is performed at equal intervals in the threshold search space, and the number of The number of connected domains in the binarization result, including: From the threshold Uniformly sample 64 thresholds to obtain , the interval between two adjacent thresholds is ; Utilizing Thresholds right Perform binarization and set the value greater than or equal to the threshold The pixel value is set to 1, which is less than the threshold The pixel value is set to 0, thus obtaining a binary image ; right Perform image erosion to remove noise and count the number of connected domains in the erosion result graph ; use Repeat the above operation for all thresholds in to obtain the sequence of connected domain numbers in the binarization result corresponding to the increasing threshold value. .
4. The method for binarizing anomaly score graphs based on the stability of the number of connected components according to claim 3, characterized in that: The size of the corrosion kernel used in the corrosion operation is .
5. The method for binarizing anomaly score graphs based on the stability of the number of connected components according to claim 1, characterized in that: The method of finding the number of connected domains middle All corresponding subsequences with the same value are determined according to the subsequence with the same value The corresponding threshold estimate , specifically including: If it does not exist If the length of the corresponding subsequences with the same value or all subsequences with the same value is less than 4, change Estimated value of the number of corresponding defective areas is 0, take The corresponding threshold estimate is 1; If exists For subsequences of the same value whose length is greater than or equal to 4, the longest sequence is selected to represent the sequence with the best regional quantity stability, and then the minimum threshold value among all threshold values corresponding to the sequence is selected as The corresponding threshold estimate .
6. The method for binarizing anomaly score graphs based on the stability of the number of connected components according to claim 1, characterized in that: Before calculating the anomaly score of the entire image corresponding to each anomaly score image, the method further includes: For a batch of product images , is the number of images, and the anomaly detection model is used to generate the corresponding anomaly score map ;in For images Corresponding predicted anomaly score map.
7. The method for binarizing anomaly score graphs based on the stability of the number of connected components according to claim 6, characterized in that: The anomaly detection model is a MuSc model or a CPR model.
8. A non-volatile computer storage medium, characterized in that The computer storage medium stores computer-executable instructions, which are executed by one or more processors to implement the method for binarizing anomaly score graphs based on the stability of the number of connected components according to any one of claims 1 to 7.
9. A device for binarizing anomaly score graph based on the stability of the number of connected domains, characterized in that: include: at least one processor; And, a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the processor to perform the anomaly score graph binarization method based on the stability of the number of connected domains according to any one of claims 1-7.
Citation Information
Patent Citations
Self-adaptive multi-black-spot detection and removal method for manuscript image
CN116935402A
Wafer defect detection method, device and equipment and readable storage medium
CN118115447A