Abnormal area detection method, processor, device and readable storage medium
By ranking candidate abnormal regions in textile images based on their similarity, the problem of inaccurate abnormal region segmentation in textile images is solved, and efficient abnormal region detection is achieved.
Patent Information
- Application Number
- CN202311279491.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-28
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2043-09-28
AI Technical Summary
Existing technologies for detecting anomalies in textile images suffer from problems such as excessively large segmentation ranges of abnormal regions and misinterpreting background patterns as defects, leading to increased false alarm rates and wasted time and resources.
By acquiring candidate abnormal regions in an image, calculating their similarity, and ranking them, the final abnormal regions are determined, avoiding background pixel interference and improving detection accuracy.
It achieves accurate segmentation of abnormal regions in textile images, reduces detection time and resources, and improves detection efficiency.
Smart Images

Figure CN117315359B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to an abnormal region detection method, processor, device, and readable storage medium. Background Technology
[0002] Textile patterns are complex and diverse, and change with market demands and fashion trends, requiring experienced workers to perform manual visual inspection. By using computer vision technologies such as image segmentation and classification detection, and learning from labeled flawless training image samples, intelligent defect detection can be achieved for small batches of textiles with complex patterns, thereby reducing the cost of manual visual inspection and improving product quality and economic efficiency.
[0003] In existing technologies, when performing anomaly detection on textile images, there are often problems such as the abnormal region segmentation range being too large, and the possibility of mistaking patterns or designs in the background of the textile image as defects, leading to an increased false alarm rate. This wastes time and resources, and additional inspection and repair steps are required to correct these errors. Summary of the Invention
[0004] The purpose of this application is to provide an anomaly region detection method, processor, device, and computer-readable storage medium. The method sorts candidate anomaly regions in an image based on their similarity, and then determines the final anomaly region in the image based on the sorting result. This avoids the interference problem of background pixels in the image, helps to accurately segment anomaly regions in the image, reduces the time and resources required for anomaly region detection, and improves detection efficiency.
[0005] To achieve the above objectives:
[0006] In a first aspect, embodiments of this application provide an abnormal region detection method, the method comprising:
[0007] Identify at least one first candidate anomalous region in the image;
[0008] The at least one second candidate anomaly region is sorted according to the similarity between them; the at least one second candidate anomaly region is an adjacent first candidate anomaly region.
[0009] Based on the sorting results, abnormal regions in the image are determined from the at least one second candidate abnormal region.
[0010] In one embodiment, the step of acquiring at least one first candidate abnormal region in the image includes:
[0011] The image is detected using an anomaly detection model to obtain at least one initial candidate anomaly region and its corresponding confidence level.
[0012] The initial candidate abnormal regions with a confidence level greater than a preset first threshold are determined as the first candidate abnormal regions.
[0013] In one embodiment, the step of detecting the image using an anomaly region detection model to obtain at least one initial candidate anomaly region and its corresponding confidence level includes:
[0014] The image is detected using an anomaly region detection model to obtain at least one basic candidate anomaly region;
[0015] Obtain the intersection-union ratio (IUU) between each of the basic candidate anomaly regions and the image;
[0016] The cross-union ratio and the size information of the image are input into a filter to filter each of the basic candidate anomaly regions, thereby obtaining at least one initial candidate anomaly region and its corresponding confidence level.
[0017] In one embodiment, the step of ranking the at least one second candidate anomaly regions based on the similarity between them includes:
[0018] After vectorizing the pixel features of each second candidate anomaly region, the cosine similarity between each second candidate anomaly region is calculated based on the pixel features.
[0019] Based on the cosine similarity, an intensity map is generated to characterize the similarity between each of the second candidate anomaly regions;
[0020] The similarity between each of the second candidate abnormal regions is sorted according to the intensity map.
[0021] In one embodiment, the step of determining an anomalous region from at least one second candidate anomalous region based on the sorting result includes:
[0022] Based on the sorting result, at least one third candidate abnormal region whose sorting position is before the preset sorting position is determined from at least one second candidate abnormal region;
[0023] The at least one third candidate anomaly region is integrated to generate a fourth candidate anomaly region;
[0024] When the fourth candidate abnormal region meets the preset conditions, the fourth candidate abnormal region is determined as an abnormal region.
[0025] In one embodiment, the preset conditions include:
[0026] The proportion of the fourth candidate abnormal region in the image is less than the preset second threshold.
[0027] In one embodiment, the preset conditions further include:
[0028] When the proportion of the fourth candidate abnormal region in the image is greater than or equal to a preset second threshold, the length of the fourth candidate abnormal region is greater than a preset third threshold, and the width is less than a preset fourth threshold.
[0029] Secondly, embodiments of this application disclose a processor configured to execute the instructions for performing the abnormal region detection method as described in the first aspect.
[0030] Thirdly, embodiments of this application disclose an abnormal region detection device, the device including the processor described in the second aspect.
[0031] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, wherein when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is able to implement the abnormal region detection method as described in the first aspect.
[0032] This application provides an anomaly region detection method, processor, apparatus, and computer-readable storage medium. The method includes: acquiring at least one first candidate anomaly region in an image; sorting the at least one second candidate anomaly region according to the similarity between them; wherein the at least one second candidate anomaly region is an adjacent first candidate anomaly region; and determining an anomaly region in the image from the at least one second candidate anomaly region based on the sorting result. Thus, by sorting the candidate anomaly regions in the image according to the similarity between them, and then determining the final anomaly region in the image based on the sorting result, the interference problem of background pixels in the image is avoided, which helps to accurately segment the anomaly region in the image, reduces the time and resources required for anomaly region detection, and improves detection efficiency. Attached Figure Description
[0033] Figure 1 This is a flowchart illustrating the abnormal region detection method provided in an embodiment of the present invention;
[0034] Figure 2 This is a schematic diagram of anomaly region detection using an anomaly detection model in existing technologies;
[0035] Figure 3 This is a schematic diagram of a specific embodiment of the abnormal region detection method provided in this invention. Detailed Implementation
[0036] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0037] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, components, features, and elements with the same names in different embodiments of this application may have the same meaning or different meanings, the specific meaning of which must be determined by its interpretation in that specific embodiment or further in conjunction with the context of that specific embodiment.
[0038] It should be understood that although the terms first, second, third, etc., may be used herein to describe various information, such information should not be limited to these terms. These terms are used only to distinguish information of the same type from one another. For example, without departing from the scope of this document, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if," as used herein, can be interpreted as "when," "when," or "in response to determination." Furthermore, as used herein, the singular forms "a," "an," and "the" are intended to also include the plural forms unless the context indicates otherwise. It should be further understood that the terms "comprising," "including," indicate the presence of the stated feature, step, operation, element, component, item, kind, and / or group, but do not exclude the presence, occurrence, or addition of one or more other features, steps, operations, elements, components, items, kinds, and / or groups. The terms "or" and "and / or" as used herein are to be interpreted as inclusive, or mean any one or any combination thereof. Therefore, "A, B, or C" or "A, B, and / or C" means "any one of the following: A; B; C; A and B; A and C; B and C; A, B, and C". Exceptions to this definition will only occur if the combination of elements, functions, steps, or operations is inherently mutually exclusive in some way.
[0039] It should be understood that although the steps in the flowcharts of this application's embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least a portion of the sub-steps or stages of other steps.
[0040] It should be noted that step designations such as S101 and S102 are used in this document for the purpose of more clearly and concisely describing the corresponding content, and do not constitute a substantial limitation on the order. In specific implementation, those skilled in the art may execute S102 first and then S101, etc., but these should all be within the protection scope of this application.
[0041] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.
[0042] In the following description, the use of suffixes such as "module," "part," or "unit" to denote elements is solely for the purpose of illustrative purposes and has no specific meaning in itself. Therefore, "module," "part," or "unit" may be used interchangeably.
[0043] See Figure 1 This application provides an abnormal region detection method, which can be executed by an abnormal region detection device provided in this application. The abnormal region detection device can be implemented in software and / or hardware, such as electronic devices including processors, servers, computers, etc. The abnormal region detection method provided in this embodiment includes:
[0044] Step S1: Obtain at least one first candidate abnormal region in the image.
[0045] First, anomaly detection is performed on the image to obtain at least one basic candidate anomaly region. Second, a filter is used to detect the basic candidate anomaly region to obtain at least one initial candidate anomaly region and its corresponding confidence score. Finally, the initial candidate anomaly region is detected using the obtained confidence score to determine at least one first candidate anomaly region. The image can be a textile image, a person image, a building image, etc., and is not specifically limited here.
[0046] Optionally, the anomaly detection model can be an anomaly segmentation model (Segment Any Anomaly+, SAA+). Inspired by the powerful zero-shot generalization ability of basic large models such as Segment Anything, SAA+ explores the assembly and use of these large models, utilizing various multimodal prior knowledge for anomaly localization. For example... Figure 2 As shown, for anomaly segmentation of the nonparametric base model, SAA+ improves the accuracy of anomaly detection in the zero-shot case by combining hybrid cues derived from domain expert knowledge and target image context.
[0047] Optionally, descriptive information about image anomalies can be input into the anomaly detection model to detect anomalous regions and their corresponding anomaly types. Here, the image's anomaly information can be determined by the feature values or attributes describing the anomalous features, including descriptive information such as black holes, defects, and oil stains. After detecting the image's anomaly information using the anomaly detection model, corresponding anomaly prompts are given based on the image's anomaly type. Here, image anomaly types include two categories: class-independent and class-specific. Class-independent refers to general anomaly types that commonly appear in images, used to describe anomalies without a specific category, such as "anomaly" and "defect." Class-specific refers to special anomaly types designed by experts based on their understanding of anomaly patterns in similar products, used to supplement other anomaly types, such as "black holes" and "white bubbles."
[0048] Optionally, the obtained initial candidate exception regions can be exception regions of the same type. For example, the obtained initial candidate exception regions can all be class-independent exception regions, or the obtained initial candidate exception regions can all be class-specific exception regions. Optionally, the obtained initial candidate exception regions can also be exception regions of multiple exception types. For example, the obtained initial candidate exception regions can include both class-independent and class-specific exception regions.
[0049] In one embodiment, the step of acquiring at least one first candidate abnormal region in the image includes:
[0050] The image is detected using an anomaly detection model to obtain at least one initial candidate anomaly region and its corresponding confidence level.
[0051] The initial candidate abnormal regions with a confidence level greater than a preset first threshold are determined as the first candidate abnormal regions.
[0052] Optionally, the initial candidate anomaly regions are detected based on their confidence levels to avoid misidentifying normal regions as anomalies due to background color interference. Here, the confidence levels of each initial candidate anomaly region are compared with a preset first threshold. Initial candidate anomaly regions with confidence levels less than or equal to the preset first threshold are identified as negative samples, i.e., these regions are designated as the image background; initial candidate anomaly regions with confidence levels greater than the preset first threshold are identified as positive samples, i.e., they are designated as the first candidate anomaly regions.
[0053] In one embodiment, the step of detecting the image using an anomaly region detection model to obtain at least one initial candidate anomaly region and its corresponding confidence level includes:
[0054] The image is detected using an anomaly region detection model to obtain at least one basic candidate anomaly region;
[0055] Obtain the intersection-union ratio (IUU) between each of the basic candidate anomaly regions and the image;
[0056] The cross-union ratio and the size information of the image are input into a filter to filter each of the basic candidate anomaly regions, thereby obtaining at least one initial candidate anomaly region and its corresponding confidence level.
[0057] Optionally, since anomalies are typically located inside the object being detected, after obtaining the basic candidate anomaly regions in the image detected by the anomaly detection model, the intersection-over-union (IoU) ratio between the determined basic candidate anomaly regions and the detected image is calculated. It can be understood that the basic candidate anomaly regions should be smaller than the size of the detected image. Here, IoU is a metric used to measure the degree of overlap between two regions (here, the detected basic candidate anomaly regions and the object image). For anomaly detection, one region represents the object image being inspected, and the other region represents the region potentially containing an anomaly. An IoU less than a certain threshold means that the overlap between the two regions is very small, i.e., the anomaly is located inside the inspected object.
[0058] Optionally, the calculated IoU and the size of the detected image can be input into a filter to filter basic candidate anomalous regions according to preset rules. These preset rules can be set based on the experience of previous experts. Simultaneously, after the filter filters the basic candidate anomalous regions, at least one initial candidate anomalous region is obtained, and a confidence score is assigned to each initial candidate anomalous region to represent the probability of the presence of an anomalous object.
[0059] Step S2: Sort the at least one second candidate abnormal region according to the similarity between them; the at least one second candidate abnormal region is an adjacent first candidate abnormal region.
[0060] Optionally, adjacent first candidate anomaly regions are identified as second candidate anomaly regions, and the similarity between any two second candidate anomaly regions is calculated. Here, the similarity between second candidate anomaly regions can be determined based on the anomaly type, color of the anomaly, brightness of the anomaly, shape of the anomaly, etc., within the second candidate anomaly regions.
[0061] Optionally, the cross-union ratio (CUN) between each first candidate anomalous region is detected. A higher CUN from two first candidate anomalous regions indicates a higher probability of overlap. Here, a detection threshold can be set to determine whether the first candidate anomalous regions are adjacent. If the CUN from a first candidate anomalous region exceeds this threshold, it is determined to be a second candidate anomalous region. Alternatively, the proximity can be determined by calculating the shortest distance between two first candidate anomalous regions, or by determining their positions.
[0062] In one embodiment, the step of ranking the at least one second candidate anomaly regions based on the similarity between them includes:
[0063] After vectorizing the pixel features of each second candidate anomaly region, the cosine similarity between each second candidate anomaly region is calculated based on the pixel features.
[0064] Based on the cosine similarity, an intensity map is generated to characterize the similarity between each of the second candidate anomaly regions;
[0065] The similarity between each of the second candidate abnormal regions is sorted according to the intensity map.
[0066] Optionally, the pixel features of each second candidate anomaly region are vectorized to determine the feature vector corresponding to each second candidate anomaly region. The feature vectors characterize the color, brightness, texture, and other attributes of the pixels in each second candidate anomaly region. Cosine similarity is calculated based on the feature vectors of each second candidate anomaly region and the feature vectors of its N nearest neighbors. The formula for calculating cosine similarity can be expressed as:
[0067] Cosine similarity = (A·B) / (||A||*||B||)
[0068] Where A and B represent the feature vectors of the second candidate anomaly feature region, · represents the dot product of the feature vectors, and ||A|| and ||B|| represent the norms of the feature vectors of the second candidate anomaly region.
[0069] Here, a corresponding similarity score is obtained by calculating the cosine similarity, which determines the similarity between the pixel features of each second candidate anomaly region and the pixel features of other adjacent second candidate anomaly regions. Generally, the higher the similarity score, the more similar the second candidate anomaly regions are, and the lower the degree of anomaly; the lower the similarity score, the less similar the second candidate anomaly regions are, and the higher the degree of anomaly.
[0070] Optionally, the similarity scores between the second candidate abnormal bodies are calculated based on the set similarity score matrix. Here, the values of the similarity score matrix can be normalized to the range of [0,1] to generate an intensity map of the second candidate abnormal regions. Here, the similarity between the second candidate abnormal regions is sorted from largest to smallest according to the generated intensity map.
[0071] Step S3: Based on the sorting result, determine the abnormal region in the image from the at least one second candidate abnormal region.
[0072] Specifically, based on the ranking of the similarity of the second candidate anomaly regions, at least one second candidate anomaly region with high similarity is determined, and the determined at least one second candidate anomaly region is further detected to determine the final anomaly region.
[0073] In one embodiment, the step of determining an anomalous region from at least one second candidate anomalous region based on the sorting result includes:
[0074] Based on the sorting result, at least one third candidate abnormal region whose sorting position is before the preset sorting position is determined from at least one second candidate abnormal region;
[0075] The at least one third candidate anomaly region is integrated to generate a fourth candidate anomaly region;
[0076] When the fourth candidate abnormal region meets the preset conditions, the fourth candidate abnormal region is determined as an abnormal region.
[0077] Optionally, at least one third candidate anomaly region is identified in the sorting process, with its sorting position falling between preset sorting positions. These at least one third candidate anomaly region are then integrated into one region to be designated as the fourth candidate anomaly region. For example, if a target second candidate anomaly region has four adjacent second candidate anomaly regions, the similarity between these four adjacent second candidate anomaly regions and the target second candidate anomaly region is sorted. Based on the preset sorting positions, the first two second candidate anomaly regions are respectively designated as third candidate anomaly regions. These two designated third candidate anomaly regions are then integrated with the target second candidate anomaly region to form one anomaly region, which is then designated as the fourth candidate anomaly region.
[0078] In one embodiment, the preset conditions include:
[0079] The proportion of the fourth candidate abnormal region in the image is less than the preset second threshold.
[0080] Optionally, since anomalies are usually located inside the object being detected, their proportion in the image of the object being detected is generally less than a certain threshold. Therefore, a preset second threshold can be used to filter at least one fourth candidate anomaly region, thereby identifying at least one fourth candidate anomaly region with a proportion less than the second threshold as an anomaly region. The preset second threshold can be set according to the specific size of the image being detected or user requirements. For example, the second threshold can be set to 50%, 60%, 65%, etc., of the proportion in the image. For example, when the proportion of the detected fourth candidate anomaly region in the detected image is greater than 65%, then the fourth candidate anomaly region is not considered an anomaly region.
[0081] In one embodiment, the preset conditions further include:
[0082] When the proportion of the fourth candidate abnormal region in the image is greater than or equal to a preset second threshold, the length of the fourth candidate abnormal region is greater than a preset third threshold, and the width is less than a preset fourth threshold.
[0083] Optionally, if the proportion of the detected fourth candidate abnormal region in the image is greater than or equal to the second threshold, then it is further detected whether the fourth candidate abnormal region satisfies the condition that "the length of the fourth candidate abnormal region is greater than the preset third threshold and the width is less than the preset fourth threshold". If it is satisfied, then the fourth candidate abnormal region is determined to be an abnormal region. For example, if the detected fourth candidate abnormal region is a thin straight line, the proportion of the fourth candidate abnormal region in the image may be greater than or equal to the second threshold. Therefore, by further detecting whether the length and width of the fourth candidate abnormal region satisfy the condition that "the length of the fourth candidate abnormal region is greater than the preset third threshold and the width is less than the preset fourth threshold", the fourth candidate abnormal region is determined to be an abnormal region.
[0084] In other embodiments, a first candidate abnormal region without adjacent regions is determined, and the first candidate abnormal region without adjacent regions is directly determined as the fourth candidate abnormal region. When the fourth candidate abnormal region meets the above-mentioned preset conditions, the fourth candidate abnormal region is determined as an abnormal region.
[0085] In summary, the abnormal region detection method provided in the above embodiments sorts candidate abnormal regions in the image based on their similarity, and then determines the final abnormal region in the image based on the sorting result. This avoids the interference problem of background pixels in the image, helps to accurately segment abnormal regions in the image, reduces the time and resources required for detecting abnormal regions in the image, and improves detection efficiency.
[0086] Based on the same inventive concept as the foregoing embodiments, the abnormal region detection method provided in this embodiment will be described in detail below through a specific example. In this example, the image is a textile image, and the abnormal region detection model is an anomaly segmentation model (Segment Any Anomaly+, SAA+). The abnormal regions of the textile image are detected using the anomaly segmentation model, such as... Figure 3 As shown, it includes the following steps:
[0087] Step S101: Input the prompt words of the abnormal information into the SAA+ model to describe the abnormality of the textile through the prompt words.
[0088] Optionally, the anomaly detection model inputs descriptive information about image anomalies. Here, the anomaly information can be determined by the feature values or attributes describing the anomaly features. This includes descriptive information such as black holes, defects, and oil stains. After detecting the anomaly information in the image using the anomaly detection model, corresponding anomaly prompts are given based on the anomaly type. Here, image anomaly types include two categories: class-independent and class-specific. Class-independent refers to general anomaly types that commonly appear in images, used to describe anomalies without a specific category, such as "anomaly" and "defect." Class-specific refers to special anomaly types designed by experts based on their understanding of anomaly patterns in similar products, used to supplement other anomaly types, such as "black holes" and "white bubbles."
[0089] Step S102: Determine the intersection (IoU) between the potential abnormal region and the object being inspected, and the detection threshold for the abnormal region.
[0090] Optionally, since anomalies are typically located inside the object being detected, when detecting an image of the object, it is necessary to calculate the Intersection-over-Union (IoU) ratio between the determined initial candidate anomaly regions and the image being detected. It can be understood that the initial candidate anomaly regions should be smaller than the size of the image being detected. Here, IoU is a metric used to measure the degree of overlap between two regions (in this case, the initial candidate anomaly regions and the object image). For anomaly detection, one region represents the object being inspected, and the other region represents the region where an anomaly might occur. An IoU less than a certain threshold means that the overlap between the two regions is very small, i.e., the anomaly is located inside the object being inspected.
[0091] Step S103: Filter the candidate abnormal regions.
[0092] Optionally, the calculated IoU and the size of the detected image can be input into a filter to filter initial candidate anomalous regions according to preset rules. These preset rules can be set based on expert experience. After the filter filters the initial candidate anomalous regions, a confidence score can be assigned to each candidate region, representing the probability of an anomalous object being present. A secondary filtering of the initial candidate anomalous regions is then performed based on their confidence scores to avoid misidentifying normal regions as anomalous regions due to background color interference. Here, the confidence scores of each initial candidate anomalous region are compared with a preset first threshold. Initial candidate anomalous regions with confidence scores less than or equal to the preset first threshold are identified as negative samples, i.e., the image background; initial candidate anomalous regions with confidence scores greater than the preset first threshold are identified as positive samples, i.e., the first candidate anomalous regions.
[0093] Step S104: Calculate the cosine similarity between the candidate anomaly region and its adjacent regions after filtering to obtain the intensity map.
[0094] Optionally, the pixel features of each second candidate anomaly region are vectorized to determine the feature vector corresponding to each second candidate anomaly region. The feature vector is used to characterize the color, brightness, texture and other attributes of the pixels in each second candidate anomaly region. The cosine similarity is calculated based on the feature vector of each second candidate anomaly region and the feature vectors of its N nearest neighbors.
[0095] Here, a corresponding similarity score is obtained by calculating the cosine similarity, which determines the similarity between the pixel features of each second candidate anomaly region and the pixel features of other adjacent second candidate anomaly regions. Generally, the higher the similarity score, the more similar the second candidate anomaly regions are, and the lower the degree of anomaly; the lower the similarity score, the less similar the second candidate anomaly regions are, and the higher the degree of anomaly.
[0096] Optionally, the similarity scores between the second candidate abnormal bodies are calculated based on the set similarity score matrix. Here, the values of the similarity score matrix can be normalized to the range of [0,1] to generate an intensity map of the second candidate abnormal region.
[0097] Step S105: Sort and select the regions with the highest scores as anomalies.
[0098] Optionally, based on the generated intensity map, the similarity between the second candidate anomaly regions is sorted from largest to smallest, and at least one third candidate anomaly region whose sorting position is between preset sorting positions is determined. The at least one third candidate anomaly region is then integrated into one region and determined as the fourth candidate anomaly region.
[0099] Optionally, since anomalies are usually located inside the object being detected, their proportion in the image of the detected object is generally less than a certain threshold. Therefore, a preset second threshold can be used to filter at least one fourth candidate anomaly region, thereby identifying at least one fourth candidate anomaly region with a proportion less than the second threshold as an anomaly region. The preset second threshold can be set according to the specific size of the detected image or user requirements. For example, the second threshold can be set to 50%, 60%, 65%, etc., representing the proportion in the image. If the proportion of the detected fourth candidate anomaly region in the image is greater than or equal to the second threshold, it is further checked whether the fourth candidate anomaly region meets the condition that "the length of the fourth candidate anomaly region is greater than a preset third threshold, and the width is less than a preset fourth threshold." If this condition is met, the fourth candidate anomaly region is identified as an anomaly region.
[0100] In summary, the abnormal region detection method provided in the above embodiments sorts candidate abnormal regions in the image based on their similarity, and then determines the final abnormal region in the image based on the sorting result. This avoids the interference problem of background pixels in the image, helps to accurately segment abnormal regions in the image, reduces the time and resources required for detecting abnormal regions in the image, and improves detection efficiency.
[0101] Based on the same inventive concept as the foregoing embodiments, this embodiment of the invention provides a processor configured to execute the above-described abnormal region detection method.
[0102] Based on the same inventive concept as the foregoing embodiments, this embodiment also provides a computer-readable storage medium storing a computer program. The computer-readable storage medium can be a magnetic random access memory (FRAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM), etc.; it can also be various devices including one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc. When the computer program stored in the computer-readable storage medium is executed by a processor, it implements the above-mentioned abnormal area detection method. For the specific steps implemented when the computer program is executed by the processor, please refer to [reference needed]. Figure 1 The description of the illustrated embodiments will not be repeated here.
[0103] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0104] In this document, the terms “comprising,” “including,” or any other variations thereof are intended to cover non-exclusive inclusion, which includes not only the elements listed but also other elements not expressly listed.
[0105] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. An abnormal region detection method, characterized in that, The method includes: Identify at least one first candidate anomalous region in the image; The at least one second candidate anomaly region is sorted according to the similarity between them; the at least one second candidate anomaly region is an adjacent first candidate anomaly region. Based on the sorting result, an abnormal region in the image is determined from the at least one second candidate abnormal region; The step of sorting the at least one second candidate anomaly region based on the similarity between the at least one second candidate anomaly region includes: After vectorizing the pixel features of each second candidate anomaly region, the cosine similarity between each second candidate anomaly region is calculated based on the pixel features. Based on the cosine similarity, an intensity map is generated to characterize the similarity between each of the second candidate anomaly regions; The similarity between each of the second candidate anomaly regions is sorted according to the intensity map; The step of determining an abnormal region from at least one second candidate abnormal region based on the sorting result includes: Based on the sorting result, at least one third candidate abnormal region whose sorting position is before the preset sorting position is determined from at least one second candidate abnormal region; The at least one third candidate anomaly region is integrated to generate a fourth candidate anomaly region; When the fourth candidate abnormal region meets the preset conditions, the fourth candidate abnormal region is determined as an abnormal region.
2. The method according to claim 1, characterized in that, The step of obtaining at least one first candidate abnormal region in the image includes: The image is detected using an anomaly detection model to obtain at least one initial candidate anomaly region and its corresponding confidence level. The initial candidate abnormal regions with a confidence level greater than a preset first threshold are determined as the first candidate abnormal regions.
3. The method according to claim 2, characterized in that, The step of detecting the image using an anomaly region detection model to obtain at least one initial candidate anomaly region and its corresponding confidence level includes: The image is detected using an anomaly region detection model to obtain at least one basic candidate anomaly region; Obtain the intersection-union ratio (IU / U) between each of the basic candidate anomaly regions and the image; The cross-union ratio and the size information of the image are input into a filter to filter each of the basic candidate anomaly regions, thereby obtaining at least one initial candidate anomaly region and its corresponding confidence level.
4. The method according to claim 1, characterized in that, The preset conditions include: The proportion of the fourth candidate abnormal region in the image is less than the preset second threshold.
5. The method according to claim 1, wherein The preset conditions include: When the proportion of the fourth candidate abnormal region in the image is greater than or equal to a preset second threshold, the length of the fourth candidate abnormal region is greater than a preset third threshold, and the width is less than a preset fourth threshold.
6. A processor, characterized in that, It is configured to perform the abnormal region detection method according to any one of claims 1 to 5.
7. An abnormal area detection device, characterized in that, The device includes the processor according to claim 6.
8. A computer-readable storage medium, characterized in that, When the instructions in the computer-readable storage medium are executed by a processor, the abnormal region detection method as described in any one of claims 1-5 is implemented.
Citation Information
Patent Citations
Methods and systems for processing an image
CN113454646A
Single-color cloth defect detection method based on weak supervised learning
CN115205209A