Image anomaly detection method and device, computer device, and storage medium

By identifying and filtering target color regions in an image, and combining proportion and continuity scores, the problem of insufficient accuracy in image anomaly detection in existing technologies is solved, and accurate identification and judgment of abnormal color regions are achieved.

CN123160927APending Publication Date: 2026-11-24TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510668924.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-22
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

Existing image anomaly detection methods rely on color thresholding techniques, which results in poor accuracy in detecting abnormal color regions, especially in identifying abnormal color images such as green and blue screens.

Method used

By identifying a first set of regions including the target color region in the target image, selecting interconnected target color regions to obtain a second set of regions, filtering according to region size, calculating the continuity score of the filtered color regions, and combining the proportion of the first set of regions in the target image with the continuity score, abnormal color regions are determined.

Benefits of technology

It improves the ability to accurately identify abnormal color images, achieves more accurate image anomaly detection, and can simultaneously assess the proportion and spatial continuity of the target color region.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123160927A_ABST
    Figure CN123160927A_ABST
Patent Text Reader

Abstract

This application relates to a method, apparatus, computer device, storage medium, and computer program product for detecting image anomalies. The method includes: identifying a first set of regions, including target color regions, in a target image; selecting interconnected target color regions from the first set of regions to obtain a second set of regions; filtering the second set of regions according to region size to obtain filtered color regions; determining a continuity score for the filtered color regions based on the number of filtered color regions; and identifying abnormal color regions in the first set of regions based on the proportion of the first set of regions in the target image and the continuity score. This method enables accurate judgment of abnormal color images, thereby effectively improving the accuracy of image anomaly detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, computer device, storage medium, and computer program product for detecting image anomalies. Background Technology

[0002] With the development of computer and internet technologies, anomalies inevitably occur during the acquisition, transmission, and display of various images. Among these anomalies, in addition to traditional black-and-white image anomalies, abnormal color images (such as "green screen" and "blue screen") are becoming increasingly common. These anomalies often manifest as abnormal color areas in the image, and their causes may include camera equipment malfunction, signal transmission interference, post-processing errors, and optical component problems. These factors can cause significant deviations in the size, shape, distribution, and continuity of certain color areas in the image, thus affecting the overall image quality and the accuracy of subsequent data processing.

[0003] However, current methods for detecting image anomalies typically rely on color thresholding techniques to perform simple area statistics and color judgments on green areas, resulting in poor accuracy in image anomaly detection. Summary of the Invention

[0004] Therefore, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium, and computer program product for detecting image anomalies, which can accurately judge abnormal color images and thus effectively improve the accuracy of image anomaly detection.

[0005] In a first aspect, this application provides a method for detecting image anomalies. The method includes: identifying a first set of regions in a target image that includes target color regions; selecting interconnected target color regions from the first set of regions to obtain a second set of regions; filtering the second set of regions according to region size to obtain filtered color regions; determining a continuity score for the filtered color regions based on the number of filtered color regions; and identifying abnormal color regions in the first set of regions based on the proportion of the first set of regions in the target image and the continuity score.

[0006] Secondly, this application also provides an image anomaly detection device. The device includes: an identification module for identifying a first set of regions including target color regions in a target image; a selection module for selecting interconnected target color regions from the first set of regions to obtain a second set of regions; a filtering module for filtering the second set of regions according to region size to obtain filtered color regions; and a determination module for determining a continuity score of the filtered color regions based on the number of filtered color regions; and determining abnormal color regions in the first set of regions based on the proportion of the first set of regions in the target image and the continuity score.

[0007] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor. The memory stores a computer program, and the processor, when executing the computer program, performs the following steps: identifying a first set of regions including target color regions in a target image; selecting interconnected target color regions from the first set of regions to obtain a second set of regions; filtering the second set of regions according to region size to obtain filtered color regions; determining a continuity score for the filtered color regions based on the number of filtered color regions; and identifying abnormal color regions in the first set of regions based on the proportion of the first set of regions in the target image and the continuity score.

[0008] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps: identifying a first set of regions including target color regions in a target image; selecting interconnected target color regions from the first set of regions to obtain a second set of regions; filtering the second set of regions according to region size to obtain filtered color regions; determining a continuity score for the filtered color regions based on the number of filtered color regions; and identifying abnormal color regions in the first set of regions based on the proportion of the first set of regions in the target image and the continuity score.

[0009] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps: identifying a first set of regions including target color regions in a target image; selecting interconnected target color regions from the first set of regions to obtain a second set of regions; filtering the second set of regions according to region size to obtain filtered color regions; determining a continuity score for the filtered color regions based on the number of filtered color regions; and identifying abnormal color regions in the first set of regions based on the proportion of the first set of regions in the target image and the continuity score.

[0010] The aforementioned image anomaly detection method, apparatus, computer equipment, storage medium, and computer program product identify a first set of regions including target color regions in a target image, and select interconnected target color regions from the first set of regions to obtain a second set of regions; further, filter the second set of regions according to region size to obtain filtered color regions, and determine the continuity score of the filtered color regions based on the number of filtered color regions; and determine abnormal color regions in the first set of regions based on the proportion of the first set of regions in the target image and the continuity score. Since the filtered color regions are obtained by filtering the second region set according to the region size, and the second region set is constructed from interconnected target color regions selected from the first region set, the continuity score of the filtered color regions, determined by the number of filtered color regions, can more accurately reflect the spatial continuity distribution and structural characteristics of the target color regions in the first region set. This makes the abnormal color regions identified in the first region set more accurate based on the proportion of the first region set in the target image and the continuity score of the filtered color regions. In other words, it can simultaneously evaluate the proportion and spatial continuity of the target color regions in the target image, realizing the determination of whether there are abnormal color regions in the target image not only based on the proportion of the target color regions in the target image, but also through the continuity score of the target color regions. This enables accurate judgment of abnormal color images, thereby effectively improving the accuracy of image anomaly detection. Attached Figure Description

[0011] Figure 1 This is an application environment diagram of an image anomaly detection method in one embodiment;

[0012] Figure 2 This is a flowchart illustrating an image anomaly detection method in one embodiment;

[0013] Figure 3 This is a display effect diagram of an image anomaly in one embodiment;

[0014] Figure 4 This is a schematic diagram illustrating the display effect of a local anomaly image provided in one embodiment;

[0015] Figure 5 This is a visualization of the results of image anomaly detection in one embodiment;

[0016] Figure 6 This is a visualization diagram of the image anomaly detection results in another scenario in one embodiment;

[0017] Figure 7 This is a flowchart illustrating the steps of displaying the proportion of the first region set in the target image, the continuity score, the number of filtered color regions, and the fragmentation ratio at a preset position in the result image in one embodiment.

[0018] Figure 8 This is a schematic flowchart illustrating the overall implementation of an image anomaly detection method provided in one embodiment;

[0019] Figure 9 This is a timing diagram of the overall processing of an image anomaly detection method provided in one embodiment;

[0020] Figure 10 This is a structural block diagram of an image anomaly detection device in one embodiment;

[0021] Figure 11 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0022] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0023] It should be noted that in the following description, the terms "first, second, and third" are used only to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, and third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0024] The image anomaly detection method provided in this application embodiment can be applied to, for example... Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed on a cloud or other network server. The terminal can acquire a target image and send it to the backend server of the image anomaly detection platform, i.e., server 104. Server 104 then identifies a first set of regions in the target image, including target color regions, and selects interconnected target color regions from the first set to obtain a second set of regions. Further, server 104 can filter the second set of regions according to region size to obtain filtered color regions, and determines the continuity score of the filtered color regions based on the number of filtered color regions. Based on the proportion and continuity score of the first set of regions in the target image, server 104 identifies anomalous color regions within the first set and returns the image anomaly detection results to terminal 102. Terminal 102 can visualize the image anomaly detection results returned by server 104.

[0025] Terminal 102 can be a smartphone, tablet, laptop, desktop computer, smart speaker, smart TV, smartwatch, IoT device, or portable wearable device. IoT devices can include smart in-vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc.

[0026] Server 104 can be an independent physical server or a service node in a blockchain system. The service nodes in the blockchain system form a peer-to-peer (Peer To Peer) network. The Peer To Peer protocol is an application layer protocol that runs on top of the Transmission Control Protocol (TCP).

[0027] In addition, server 104 can also be a server cluster consisting of multiple physical servers, which can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery network (CDN), and big data and artificial intelligence platforms.

[0028] Terminal 102 and server 104 can be connected via Bluetooth, USB (Universal Serial Bus) or network, etc., and this application does not impose any restrictions.

[0029] In one embodiment, such as Figure 2 As shown, a method for detecting image anomalies is provided. This method can be executed by the server or terminal alone, or by both the server and terminal. This method can be applied to... Figure 1 Taking the terminal in the example, the explanation includes the following steps:

[0030] Step 202: Identify a first set of regions in the target image that includes the target color region.

[0031] The target image refers to the image to be detected. For example, the target image in this application can be a single frame image, a series of multiple frames in a video (multiple frames), or each frame displayed during a live broadcast.

[0032] The first region set refers to a set that includes one or more target color regions. For example, the first region set in this application may be the set of all green regions (i.e., target color regions) identified in the target image.

[0033] The target color refers to a specific color. For example, the target color area in this application could be a green area in an image, which could further include: a normal green background area and an abnormal green area (i.e., an abnormal green screen). Figure 3 The image shown is a display effect diagram of image anomalies. The first region set in this application can be: in the following... Figure 3 All areas including green (e.g.) identified in the image shown Figure 3 The set of regions (where the grid-shaped rectangular area represents the green area).

[0034] Step 204: Select interconnected target color regions from the first region set to obtain the second region set.

[0035] Here, interconnected target color regions refer to target color regions that have spatial continuity (connectivity). For example, in this application, interconnected target color regions can be determined by applying a connected component detection algorithm to the binarized image of the target image. For instance, the detection algorithm cv2.connectedComponentsWithStats can be used to identify such interconnected components. Figure 3 The image shown contains all interconnected green regions (i.e., target color regions) in the target image. Alternatively, by traversing the pixel positions in the target image using a two-dimensional array (matrix), multiple blocks are obtained (e.g., dividing a target image into 16 marker blocks). Then, it is determined which blocks (marker blocks) are interconnected, i.e., marker blocks with spatial continuity (connectivity) are considered as interconnected target color regions.

[0036] The first and second region sets in this application are merely used to distinguish between different region sets. For example, the first region set in this application is used to represent the region set of all target color regions (such as green regions) identified in the target image, and the second region set is used to represent the interconnected (i.e., spatially continuous) target color regions selected from all identified target color regions (such as green regions).

[0037] Specifically, the image anomaly detection method provided in this application can be widely applied to various personalized image anomaly detection scenarios such as social networking, gaming, and film and television production (short video production). That is, the devices used by different users (operation objects) can interact with the multimedia information platform (or application). When a user (operation object) wants to detect whether an image in a specific scene is abnormal (such as detecting an image in a video captured in real time by a camera), the user can open the multimedia application (APP) on the terminal by triggering an operation, and enter the page of the multimedia application by selecting an operation. That is, the user can log in to the multimedia application (such as a short video application or a social application) by triggering an operation. Furthermore, the user can initiate an anomaly detection request for an image in a specific video by triggering an operation on the page displayed by the multimedia application. For example, on the main page of a video application (image acquisition application) displayed on the terminal, user A can trigger an anomaly detection request for a specific media work, video, or image by clicking icons such as "Detect image anomalies." The terminal responds to this request by user A, acquiring the target image (the image to be detected) and sending it to the application's backend server. The backend server can then identify a first set of regions, including target color areas, within the target image. For instance, the backend server can preprocess the target image to obtain a binarized image and identify the first set of regions, including target color areas, based on this binarized image. Further, the backend server can select interconnected target color areas from the first set to obtain a second set of regions. For example, the backend server can use a connected component detection algorithm to detect interconnected white pixels in the binarized image of the target image, thus identifying all interconnected target color areas (all interconnected white pixel areas in the binarized image), i.e., the second set of regions.

[0038] For example, let's illustrate this with a scenario where an image anomaly detection is performed using an intelligent image processing application. Assume the multimedia application is an intelligent image processing application, such as... Figure 4 The image shown is a schematic diagram illustrating the display effect of a local anomaly image provided in this application. Figure 4 The upper half of the image shown is normal, while the lower half is abnormally green, displayed as a green screen (abnormal green area). When user A (the user being operated on) wants to perform anomaly detection on an image in a specific scene, user A can trigger an operation to open the intelligent image processing application A on the terminal, and then enter the main page of the intelligent image processing application A. Furthermore, user A can initiate an image anomaly detection request (or a query request to determine if an image is abnormal) on the page displayed by the intelligent image processing application A. For example, on the page displayed on the terminal, user A can click the "Anomaly Detection" control on the page, causing the terminal to respond to user A's click and display an input page. After user A completes the input operation (e.g., user A selects the target image to be detected), user A can further initiate an image anomaly detection request by clicking the "Start" control on the page. The terminal, responding to user A's "Start" click (i.e., initiating the image anomaly detection request), obtains the target image input by user A as follows: Figure 4 Image A as shown, and for example... Figure 4 Image A, the target image shown, undergoes preprocessing. For example, the terminal can first process the image as follows: Figure 4 Image A, the target image, is transformed into a target color space image A (e.g., an HSV color space image). Then, based on a preset range of target colors (e.g., the HSV green range), target color space image A is binarized to obtain a binary image A, i.e., a mask for the target color region. For example, in this mask, pixels belonging to the green region (i.e., the target color region) are marked as white (255), and pixels belonging to other regions are marked as black (0). Furthermore, the terminal can identify a first set of regions including the target color region (green region) based on the binarized image A. For example, the first set of regions including all green regions identified by the terminal based on the binarized image A is: Figure 4 The lower half of the image shows the "gray rectangular area".

[0039] Furthermore, after the terminal identifies the first set of regions including the target color region (green region) based on the binarized image A, the terminal can further detect the interconnected white pixels in the binarized image A based on the connected component detection algorithm, thereby identifying all interconnected green regions (all interconnected white pixel regions in the binarized image) in the target image, i.e., the second set of regions.

[0040] Step 206: Filter the second region set according to the region size to obtain the filtered color regions.

[0041] The region size refers to the threshold condition used to filter the target color region (size). For example, the region size in this application can be a pre-set area threshold used to filter connected components (target color region size). For example, by setting the area threshold of the smallest connected component (i.e. the smallest target color region) (such as min_component_size = 500 pixels), these small regions can be filtered out, and only the valid green components (retaining the valid target color region) can be retained.

[0042] The filtered color region refers to the target color region obtained by filtering out some regions from the second region set that do not meet the area threshold of the minimum connected component (i.e., the minimum target color region). For example, assuming that the second region set includes green region A, green region A11, and green region B, then based on the preset area threshold of the minimum connected component (i.e., the minimum target color region) (such as min_component_size = 500 pixels), some regions that do not meet the area threshold of the minimum connected component (i.e., the minimum target color region) are filtered out from the second region set (since the number of pixels in green region A11 is 400, which is less than the area threshold of 500 pixels). The resulting filtered color region only includes green region A and green region B, and green region A11 is the filtered target color region.

[0043] Specifically, after the terminal selects interconnected target color regions from the first region set to obtain the second region set, the terminal can filter each target color region in the second region set according to the region size. For example, the terminal can obtain a preset area threshold for connected components and filter out some regions (fragmented regions) in the second region set by the area threshold, retaining only the filtered effective regions (effective connected components). That is, the terminal can obtain the area of ​​each target color region in the second region set and compare the area of ​​each target color region in the second region set with the preset area threshold for connected components. Finally, the target color region with an area greater than the area threshold for connected components is taken as the filtered color region.

[0044] For example, suppose the terminal selects interconnected target color regions from the first region set, and the resulting second region set includes green region A, green region A11, and green region B. Then, based on a preset area threshold for the minimum connected component (i.e., the minimum target color region) (e.g., min_component_size = 500 pixels), the terminal filters out some regions from the second region set that do not meet the area threshold of the minimum connected component (i.e., the minimum target color region). (Since the number of pixels in green region A11 is 400, which is less than the area threshold of 500 pixels, green region A11 will be filtered out.) The resulting filtered color regions only include green region A and green region B, where the number of pixels in both green region A and green region B is greater than min_component_size (500 pixels).

[0045] Step 208: Determine the continuity score of the filtered color regions based on the number of filtered color regions.

[0046] The continuity score is an index used to evaluate the spatial continuity of the filtered color region (effective connected components), reflecting the spatial distribution and structural characteristics of the filtered color region (effective connected components). For example, the range of the continuity score in this application can be limited to 0 to 1. That is, when the number of effective connected components is small (i.e., the continuity is good), the continuity score is closer to 1; when the number of components is large, the continuity score tends to 0. In other words, the more continuous the filtered color region (effective connected components) is, the larger the continuity score and the closer it is to 1.

[0047] Specifically, the terminal performs region filtering on the second region set according to the region size. After obtaining the filtered color regions, the terminal can determine the continuity score of the filtered color regions based on the number of filtered color regions. For example, the terminal can first determine the ratio (N / C) between the number of filtered color regions N and a first preset value (such as a preset normalization constant C), then determine the relationship between the ratio (N / C) and a second preset value (such as constant 1), and determine the target value based on the relationship, using the target value as the continuity score of the filtered color regions; or, the terminal can determine the continuity score of the filtered color regions based on a third preset value (such as constant 1) and the target value. For example, the terminal can use the difference between the third preset value (such as constant 1) and the target value as the continuity score of the filtered color regions.

[0048] In one embodiment, the continuity score can be calculated as shown in the following formula (1):

[0049] (1)

[0050] Here, S represents the continuity score, N is the number of effective components (i.e., the number of filtered color regions), and generally, the more continuous the green regions (target color regions), the lower the N value should be; conversely, if the green regions (target color regions) in the image are scattered, the N value will be higher; C is a preset normalization constant (e.g., C=10) to ensure that the scoring result (continuity score) is limited to between 0 and 1. When the number of effective connected components N is small (i.e., good continuity), the S value is close to 1; when the number of components N is large, the S value tends to 0. In addition, the fragmentation ratio can also be calculated, that is, the proportion of small regions filtered out to the total green region (total target color region), as an auxiliary indicator for judging whether it is abnormal.

[0051] Step 210: Based on the proportion and continuity score of the first region set in the target image, determine the abnormal color region in the first region set.

[0052] The proportion of the first region set in the target image refers to the proportion of all target color regions included in the first region set in the target image. For example, in this application, the proportion of the first region set in the target image can be the ratio obtained by dividing the number of pixels of all target color regions included in the first region set by the total number of pixels in the target image. This ratio is the proportion of the first region set in the target image.

[0053] Abnormal color areas refer to color abnormalities in the target image (the original color image is not displayed normally). For example, abnormal color areas in this application include, but are not limited to, abnormal green areas (i.e., green screen), abnormal blue areas (i.e., blue screen), abnormal black areas (i.e., black screen), and other abnormal color display images.

[0054] Specifically, after determining the continuity score of the filtered color regions based on the number of filtered color regions, the terminal can identify abnormal color regions within the first region set based on the proportion of the first region set in the target image and the continuity score. That is, the terminal can first determine the first number of target pixels (e.g., white pixels) in the binarized image of the target image and use this first number as the total number of pixels in the target color region. Then, it can determine the ratio between the total number of pixels in the target color region and the total number of pixels in the binarized image, and use this ratio as the proportion of the first region set in the target image. Further, the terminal can compare the proportion of the first region set in the target image with a preset proportion threshold to obtain a first comparison result, and compare the continuity score with a preset continuity scoring threshold to obtain a second comparison result. Based on the first and second comparison results, abnormal color regions are identified within the first region set. For example, if the first comparison result indicates that the proportion is less than the proportion threshold, or the second comparison result indicates that the continuity score is less than the continuity scoring threshold, the first region set is marked as an abnormal color region (i.e., an abnormal color image, such as a green screen). For example, when the first comparison result indicates that the proportion is not less than the proportion threshold, and the second comparison result also indicates that the continuity score is not less than the continuity score threshold, the first region set is marked as a normal color region (i.e., the first region set is determined to be a normal color region).

[0055] In addition, the terminal can determine the fragmentation ratio based on the proportion of the filtered color region in the first region set, or based on the proportion of the filtered color region (the target color region filtered out from the second region set) in the first region set, and determine the abnormal color region in the first region set based on the proportion of the first region set in the target image, the continuity score, and the fragmentation ratio.

[0056] For example, such as Figure 5 The image shown is a visualization of the results of image anomaly detection. Assuming the terminal determines the continuity score S=0.10 for the filtered color regions based on the number of filtered color regions, the terminal can first determine... Figure 5The first number of target pixels (e.g., white pixels) in the binarized image of the target image shown is used as the total number of pixels in the target color region. The ratio between the total number of pixels in the target color region and the total number of pixels in the binarized image is determined to be R=41.01%, and this ratio is used as the proportion of the first region set in the target image R=41.01%. Furthermore, the terminal can compare the proportion R=41.01% of the first region set in the target image with a preset proportion threshold ratio_threshold=0.05 to obtain a first comparison result (R=41.01%>ratio_threshold = 0.05), and compare the continuity score S=0.10 with a preset continuity scoring threshold continuity_threshold=0.5 to obtain a second comparison result (S=0.10<continuity_threshold=0.5). That is, when either the first comparison result or the second comparison result indicates that it is less than the anomaly judgment threshold (including the continuity scoring threshold and the proportion threshold), for example, when the second comparison result indicates that the continuity score is less than the continuity scoring threshold (S=0.10<continuity_threshold=0.5), the first region set is marked as an abnormal color region (i.e., an abnormal color image, such as a green screen). Furthermore, the terminal can... Figure 4 The target image (original image) shown is overlaid with its binarized form to generate an image like this. Figure 5 The anomaly detection results are shown in the image, and in... Figure 5 The results image is displayed at a preset position (e.g., the upper left of the results image), showing the percentage of the first region set (i.e., the green region) in the target image: Green Ratio: 41.01% (R=41.01%), Continuity Score: 0.10 (S=0.10), Number of filtered color regions: Components: 1, and Fragmented Ratio: 0.00%.

[0057] In this embodiment, a first set of regions including target color regions is identified in the target image, and interconnected target color regions are selected from the first set of regions to obtain a second set of regions. Further, the second set of regions is filtered according to the region size to obtain filtered color regions, and the continuity score of the filtered color regions is determined based on the number of filtered color regions. Based on the proportion of the first set of regions in the target image and the continuity score, abnormal color regions are identified in the first set of regions. Since the filtered color regions are obtained by filtering the second region set according to the region size, and the second region set is constructed from interconnected target color regions selected from the first region set, the continuity score of the filtered color regions, determined by the number of filtered color regions, can more accurately reflect the spatial continuity distribution and structural characteristics of the target color regions in the first region set. This makes the abnormal color regions identified in the first region set more accurate based on the proportion of the first region set in the target image and the continuity score of the filtered color regions. In other words, it can simultaneously evaluate the proportion and spatial continuity of the target color regions in the target image, realizing the determination of whether there are abnormal color regions in the target image not only based on the proportion of the target color regions in the target image, but also through the continuity score of the target color regions. This enables accurate judgment of abnormal color images, thereby effectively improving the accuracy of image anomaly detection.

[0058] In one embodiment, the method further includes:

[0059] The target image is preprocessed to obtain a binarized version of the target image;

[0060] The process of identifying a first set of regions in the target image, including the target color region, includes:

[0061] Based on the binarized image, a first set of regions including the target color region is identified.

[0062] Preprocessing refers to performing operations such as color space conversion and color thresholding on the target image. For example, the preprocessing performed on the target image in this application includes, but is not limited to, color space conversion and binarization.

[0063] It is understood that in some cases, the binarized image in this application can also be called a mask (image) of the target color region. For example, when the target color region is a green region, the binarized image in this application is a mask of the green region in the target image. In this mask, pixels belonging to the green region are marked as white (255), and pixels in other regions are marked as black (0).

[0064] Specifically, let's take a local anomaly image as the target image as an example. Assume the terminal acquires an image like... Figure 4 After the target image shown is the image to be detected, the terminal can first process it as follows: Figure 4 The target image shown is preprocessed to obtain a binarized image of the target image, i.e., as shown below. Figure 4 The image shown is a mask (image) of the gray area (lower half of the target image) included in the target image. Further, the terminal can identify a first set of regions including the target color region (i.e., the gray area) based on the binarized image, i.e., the mask (image) of the gray area (lower half of the target image): [Image showing...] Figure 4 The "gray rectangular area" shown in the diagram enables accurate identification of abnormal colors in images, thereby effectively improving the accuracy of image anomaly detection.

[0065] In one embodiment, the step of preprocessing the target image to obtain a binarized image of the target image includes:

[0066] Perform color space conversion on the target image to obtain the target color space image;

[0067] Based on the preset range of target color values, the target color space image is binarized to obtain a binarized image of the target image.

[0068] In this application, the target color space image may be an HSV color space image.

[0069] The preset target color value range condition refers to the upper and lower limits of the target color value set in advance. For example, the target color value range condition in this application can be a preset HSV green range, such as: lower_green = [35, 40, 40] and upper_green = [85, 255, 255]. Then, the terminal performs binarization processing on the HSV color space image according to the preset HSV green range condition (i.e., lower_green = [35, 40, 40] and upper_green = [85, 255, 255]) to obtain the binarized image of the target image (i.e., the mask of the green area).

[0070] Specifically, let's take a local anomaly image as the target image as an example. Assume the terminal acquires an image like... Figure 4 After the target image shown is the image to be detected, the terminal can first process it as follows: Figure 4 The target image shown is preprocessed; for example, the terminal can first process the image as shown in the figure. Figure 4The target image shown is converted to an HSV color space image. It is understood that the reason for performing this color space conversion on the target image in this application is to better distinguish green features. For example, the terminal first converts the input image (target image) from the BGR color space to the HSV color space because hue provides a more intuitive description of color in the HSV space, facilitating subsequent extraction of green areas and improving the accuracy of green area extraction.

[0071] Furthermore, the terminal performs binarization processing on the HSV color space image based on preset target color value range conditions (such as the lower bound of the HSV green range, lower_green, and the upper bound, upper_green), thus obtaining the image as shown below. Figure 4 The binarized image of the target image shown is a mask of the green area in the target image. In this mask, pixels belonging to the green area (i.e., the target color area) are marked as white (255), and other areas are marked as black (0). This enables accurate judgment of abnormal color images, thereby effectively improving the accuracy of image anomaly detection.

[0072] In one embodiment, the step of identifying a first set of regions including the target color region based on a binarized image includes:

[0073] The regions corresponding to white pixels in the binarized image are used as the first region set.

[0074] Here, white pixels refer to pixels marked as white in a binary image. For example, in this application, white pixels are used to indicate that the area corresponding to the pixel belongs to the target color area (such as the green area).

[0075] Specifically, the terminal then performs binarization processing on the HSV color space image based on preset target color value range conditions (such as the lower bound of the HSV green range, lower_green, and the upper bound, upper_green), to obtain, as shown below. Figure 4 The binarized image of the target image shown is a mask of the green area in the target image. Since pixels belonging to the green area (i.e., the target color area) are marked as white (255) and other areas are black (0) in this mask, the terminal can traverse the binarized image of the target image and take the area corresponding to the white (255) pixels in the binarized image, i.e., the mask, as the first region set (all green areas in the target image). This enables accurate judgment of abnormal color scenes, thereby effectively improving the accuracy of image anomaly detection.

[0076] In one embodiment, the step of selecting interconnected target color regions from the first region set to obtain the second region set includes:

[0077] The second region set is obtained by detecting the interconnected white pixels in the binarized image of the target image.

[0078] Specifically, after the terminal identifies a first set of regions, including the target color region (green region), based on the binarized image, it can then use a connected component detection algorithm to detect interconnected white pixels in the binarized image. This allows it to identify all interconnected green regions in the target image (which are also all interconnected white pixel regions in the binarized image), i.e., the second set of regions. Alternatively, the terminal can divide the binarized image into blocks using a two-dimensional array (matrix) to obtain corresponding identifier blocks. By detecting interconnected identifier blocks, it can obtain all interconnected identifier blocks in the target image (which are also all interconnected white pixel regions in the binarized image), i.e., the second set of regions. This enables accurate judgment of abnormal color scenes, thereby effectively improving the accuracy of image anomaly detection.

[0079] In one embodiment, the region size includes a preset area threshold for connected components; the step of filtering the second region set according to the region size to obtain the filtered color region includes:

[0080] Obtain the area of ​​each target color region in the second region set;

[0081] The target color region whose area is greater than the area threshold of the connected component is used as the filtered color region.

[0082] The area of ​​each target color region refers to the number of pixels contained in each target color region. For example, if target color region A contains 600 pixels, then the area of ​​target color region A is 500 pixels.

[0083] Specifically, let's take a local anomaly image as the target image as an example. Assume the terminal acquires an image like... Figure 3 The target image shown is the image to be detected. After that, the terminal... Figure 3The target image shown identifies a first set of regions including green areas. Connected green regions are then selected from this first set, resulting in a second set of regions including green region A, green region A11, and green region B. The terminal can then obtain the area of ​​each target color region in the second set. Assuming the terminal obtains the areas of each target color region in the second set as: green region A (600 pixels), green region A11 (400 pixels), and green region B (800 pixels), the terminal can then determine the area based on a preset area threshold for connected components, i.e., a preset area threshold for the smallest connected component (i.e., the smallest target color region) (e.g., min_component_size = ...). The terminal filters out regions from the second region set that do not meet the area threshold of the minimum connected component (i.e., the minimum target color region). Since the green region A11 contains 400 pixels, which is less than 500 pixels, the terminal filters out the green region A11 based on the preset area threshold of the connected component. That is, the terminal uses the target color regions (green region A and green region B) with areas greater than the area threshold of the connected component as the filtered color regions. The final filtered color regions only include green region A and green region B, where the number of pixels in green region A and green region B is greater than the preset area threshold of the connected component min_component_size (500 pixels). This enables accurate judgment of abnormal color images, thereby effectively improving the accuracy of image anomaly detection.

[0084] In one embodiment, before determining abnormal color regions in the first region set based on the proportion and continuity score of the first region set in the target image, the method further includes:

[0085] The target color region whose area is not greater than the area threshold of the connected component is used as the filter color region;

[0086] Determine the proportion of the filtered color region in the first region set and use the proportion as the fragmentation ratio; or, determine the difference between the fourth preset value and the proportion and use the difference as the fragmentation ratio.

[0087] Specifically, let's take a local anomaly image as the target image as an example. Assume the terminal obtains the areas of each target color region in the second region set as: green region A (600 pixels), green region A11 (400 pixels), and green region B (800 pixels). Then, the terminal can determine the area threshold based on a preset connected component area threshold, i.e., a preset minimum connected component (i.e., the minimum target color region) area threshold (e.g., min_component_size = ...). The terminal filters out regions from the second region set that do not meet the area threshold of the minimum connected component (i.e., the minimum target color region). Since the number of pixels in the green region A11 is less than 500, the terminal filters out the green region A11 based on the preset area threshold of the connected component. That is, the terminal uses the target color region (green region A11) whose area is not greater than the area threshold of the connected component as the filtered color region and determines the proportion S1 of the filtered color region, i.e., the green region A11, in the first region set. This proportion S1 is used as the fragmentation ratio. For example, the terminal can calculate the ratio between the removed continuous block (green region A11) and the total continuous block (the total green region in the target image, i.e., the first region set). This ratio is the proportion S1 of the filtered color region, i.e., the green region A11, in the first region set. Alternatively, the terminal can determine the difference (1-S1) between the fourth preset value (e.g., the preset constant 1) and this proportion S1, and use this difference (1-S1) as the fragmentation ratio. This enables accurate identification of abnormal color images, thereby effectively improving the accuracy of image anomaly detection.

[0088] In one embodiment, the step of determining the continuity score of the filtered color regions based on the number of filtered color regions includes:

[0089] Determine the ratio between the number of filtered color regions and the first preset value;

[0090] Determine the relationship between the ratio and the second preset value;

[0091] The target value is determined based on the magnitude relationship, and this target value is used as the continuity score for the filtered color region; or...

[0092] The continuity score of the filtered color region is determined based on the third preset value and the target value.

[0093] In this application, the first preset value, the second preset value, and the third preset value are only used to distinguish different preset values. That is, the first preset value, the second preset value, and the third preset value can be the same value or different values. For example, the first preset value in this application can be a normalization constant C (e.g., C=10), and the second preset value and the third preset value can be preset constants 1.

[0094] Specifically, the terminal performs region filtering on the second region set according to the region size. After obtaining the filtered color regions, the terminal can determine the continuity score of the filtered color regions based on the number of filtered color regions. For example, the terminal can first determine the ratio (N / C) between the number of filtered color regions N and a first preset value (such as a preset normalization constant C), then determine the size relationship between this ratio (N / C) and a second preset value (such as a constant 1), and determine the target value min(N / C, 1) based on the size relationship, and use the target value as the continuity score of the filtered color regions; or, the terminal can determine the continuity score of the filtered color regions based on a third preset value (such as a constant 1) and the target value. For example, the terminal can use the difference 1 - min(N / C, 1) between the third preset value (such as a constant 1) and the target value as the continuity score of the filtered color regions. For example, the calculation method of the continuity score in this application can be as shown in the aforementioned formula (1). This enables accurate judgment of abnormal color images, thereby effectively improving the accuracy of image anomaly detection.

[0095] In one embodiment, the step of determining abnormal color regions in the first region set based on the proportion and continuity score of the first region set in the target image includes:

[0096] The fragmentation ratio is determined based on the proportion of the filtered color regions in the first region set.

[0097] Based on the proportion, continuity score, and fragmentation ratio of the first region set in the target image, abnormal color regions are identified in the first region set.

[0098] The fragmentation ratio refers to the proportion of the target color area that has been filtered out to the total target color area. It is used to reflect the proportion of small fragments in the target image caused by noise, data corruption or other factors.

[0099] Specifically, the terminal filters the second region set according to region size to obtain filtered color regions. Then, the terminal can determine the fragmentation ratio based on the proportion of the filtered color regions in the first region set. For example, the terminal can calculate the proportion S1 of the filtered color regions in the first region set and calculate the difference (1-S1) between a preset value 1 and the proportion S1. This difference (1-S1) is used as the fragmentation ratio, allowing the terminal to identify abnormal color regions in the first region set based on the proportion R of the first region set in the target image, the continuity score S, and the fragmentation ratio (1-S1). This allows the terminal to calculate the fragmentation ratio—that is, the proportion of filtered small regions to the total green region—and use the fragmentation ratio as an auxiliary judgment indicator, enabling a comprehensive evaluation of the green regions in the image and further improving the accuracy of image anomaly detection.

[0100] In one embodiment, before determining abnormal color regions in the first region set based on the proportion and continuity score of the first region set in the target image, the method further includes:

[0101] Determine the first number of target pixels in the binarized image of the target image, and use the first number as the total number of pixels in the target color region;

[0102] Determine the ratio between the total number of pixels in the target color region and the total number of pixels in the binarized image, and use this ratio as the proportion of the first region set in the target image.

[0103] In this context, the target pixel refers to the pixel in the binarized image used to identify the region belonging to the target color. For example, the target pixel in this application can be a white pixel in the binarized image, and the black pixel is a pixel belonging to other regions (regions other than the target color region).

[0104] Specifically, such as Figure 5 The image shown is a visualization of the results of image anomaly detection. Assuming the terminal determines the continuity score S=0.10 for the filtered color regions based on the number of filtered color regions, the terminal can first determine... Figure 5 The target image shown is represented by a binary image containing a first number of target pixels (e.g., white pixels), which is then used as the total number of pixels in the target color region. The ratio R between the total number of pixels in the target color region and the total number of pixels in the binary image is determined, and this ratio is used as the proportion R of the first region set in the target image. The formula for calculating the proportion R of the first region set in the target image is shown in formula (2) below:

[0105] (2)

[0106] The number of green region pixels (i.e. the total number of pixels in the target color region) represents the total number of pixels in the green region. It is obtained by counting the number of white pixels in the binary mask. By dividing the number of green region pixels by the total number of pixels in the target image, the proportion R of the green region in the target image can be obtained.

[0107] In this embodiment, by calculating the proportion R of the green area (target color area) in the target image, this proportion can provide an intuitive area indicator for subsequent anomaly judgment, enabling a comprehensive evaluation of the green area in the image. It calculates the area occupied by the green area in the image and judges whether there is anomaly by the continuity of the green area, thereby effectively improving the accuracy of anomaly detection in the green area of ​​the image.

[0108] In one embodiment, the step of determining abnormal color regions in the first region set based on the proportion and continuity score of the first region set in the target image includes:

[0109] The percentage is compared with a preset percentage threshold to obtain the first comparison result;

[0110] The continuity score is compared with a preset continuity scoring threshold to obtain a second comparison result;

[0111] When the first comparison result indicates that the proportion is less than the proportion threshold, or the second comparison result indicates that the continuity score is less than the continuity score threshold, the first region set is marked as an abnormal color region.

[0112] In this application, both the preset proportion threshold and the preset continuity scoring threshold are anomaly detection thresholds used to determine whether an image is abnormal. For example, the preset proportion threshold could be a green proportion threshold: ratio_threshold = 0.05 (5%). Similarly, the preset continuity scoring threshold could be set to continuity_threshold = 0.5. It is understood that the preset proportion threshold and preset continuity scoring threshold in this application can be determined through testing with a large number of sample images to balance detection accuracy and adaptability.

[0113] Specifically, assuming the terminal determines the continuity score S=0.10 for the filtered color regions based on the number of filtered color regions, the terminal can first determine, for example,... Figure 5The target image shown is binarized into a binary image containing a first number of target pixels (e.g., white pixels), and this first number is used as the total number of pixels in the green region. The ratio between the total number of pixels in the green region and the total number of pixels in the binarized image is determined to be R=41.01%, and this ratio is used as the proportion of the first region set (total green region) in the target image, R=41.01%. Furthermore, the terminal can compare the proportion R=41.01% of the first region set (total green area) in the target image with a preset proportion threshold ratio_threshold=0.05 to obtain a first comparison result (R=41.01%>ratio_threshold = 0.05), and compare the continuity score S=0.10 with a preset continuity scoring threshold continuity_threshold=0.5 to obtain a second comparison result (S=0.10<continuity_threshold=0.5). That is, when either the first comparison result or the second comparison result indicates that it is less than the anomaly judgment threshold (the anomaly judgment threshold includes the proportion threshold and the continuity scoring threshold), the first region set is marked as an abnormal color region. For example, when the second comparison result indicates that the continuity score is less than the continuity scoring threshold (S=0.10<continuity_threshold=0.5), the first region set is marked as an abnormal color region (i.e., an abnormal color image, such as a green screen). This enables accurate identification of abnormal colors in images, thereby effectively improving the accuracy of image anomaly detection.

[0114] In one embodiment, the method further includes:

[0115] When the first comparison result indicates that the proportion is not less than the proportion threshold, and the second comparison result indicates that the continuity score is not less than the continuity score threshold, the first region set is marked as a normal color region.

[0116] Specifically, such as Figure 6 The image shown is a visualization of the results of image anomaly detection in another scenario. Assuming the terminal determines the continuity score S=0.00 for the filtered color regions based on the number of filtered color regions, the terminal can first determine... Figure 6The first number of target pixels (e.g., white pixels) in the binarized image of the target image shown is used as the total number of pixels in the green region. The ratio between the total number of pixels in the green region and the total number of pixels in the binarized image is determined to be R=0.09%, and this ratio is used as the proportion of the first region set (total green region) in the target image R=0.09%. Furthermore, the terminal can compare the proportion R=0.09% of the first region set (total green area) in the target image with a preset proportion threshold ratio_threshold=0.05% to obtain a first comparison result (R=0.09%>ratio_threshold = 0.05%), and compare the continuity score S=0.00 with a preset continuity scoring threshold continuity_threshold=0.00 to obtain a second comparison result (S=0.00=continuity_threshold=0.00). That is, when both the first and second comparison results indicate that the proportion is not less than the anomaly judgment threshold (the anomaly judgment threshold includes the proportion threshold and the continuity scoring threshold), that is, when the first comparison result indicates that the proportion is not less than the proportion threshold, and the second comparison result indicates that the continuity score is not less than the continuity scoring threshold, the first region set is marked as a normal color region. Figure 6 The green areas in the target image shown are normal (background) green areas. This enables accurate identification of abnormal color scenes, thereby effectively improving the accuracy of image anomaly detection.

[0117] In one embodiment, such as Figure 7 As shown, after identifying abnormal color regions in the first region set based on its proportion and continuity score in the target image, the method further includes:

[0118] Step 702: Obtain the binarized image of the target image.

[0119] Step 704: Overlay the binarized image with the target image to obtain the result image of image anomaly detection.

[0120] Step 706: Display the proportion of the first region set in the target image, its continuity score, the number of filtered color regions, and the fragmentation ratio at a preset position in the result image.

[0121] Specifically, assuming the terminal determines the continuity score S=0.10 for the filtered color regions based on the number of filtered color regions, the terminal can first determine, for example,... Figure 5The first number of target pixels (e.g., white pixels) in the binarized image of the target image shown is used as the total number of pixels in the target color region. The ratio between the total number of pixels in the target color region and the total number of pixels in the binarized image is determined to be R=41.01%, and this ratio is used as the proportion of the first region set in the target image R=41.01%. Furthermore, the terminal can compare the proportion R=41.01% of the first region set in the target image with a preset proportion threshold ratio_threshold=0.05 to obtain a first comparison result (R=41.01%>ratio_threshold = 0.05), and compare the continuity score S=0.10 with a preset continuity scoring threshold continuity_threshold=0.5 to obtain a second comparison result (S=0.10<continuity_threshold=0.5). That is, when either the first comparison result or the second comparison result indicates that it is less than the threshold, for example, when the second comparison result indicates that the continuity score is less than the continuity scoring threshold (S=0.10<continuity_threshold=0.5), the first region set is marked as an abnormal color region (i.e., an abnormal color image, such as a green screen). Furthermore, the terminal can... Figure 5 The target image (original image) shown is overlaid with its binarized form to generate an image like this. Figure 5 The image anomaly detection result diagram is shown below, and in the image as shown below. Figure 5 The results image, displayed at a preset location (e.g., the upper left corner), shows the percentage of the first region set in the target image: GreenRatio: 41.01% (R=41.01%), Continuity Score: 0.10 (S=0.10), Number of filtered color regions: Components: 1, and Fragmented Ratio: 0.00%. This enables accurate identification of abnormal color scenes, thereby effectively improving the accuracy of image anomaly detection.

[0122] In one embodiment, a method for detecting image anomalies is provided. This method can be executed by a server or a terminal alone, or by both a server and a terminal. The method can be applied to... Figure 1Taking a terminal as an example, the method includes the following steps: identifying a first set of regions including target color regions in the target image; selecting interconnected target color regions from the first set of regions to obtain a second set of regions; filtering the second set of regions according to region size to obtain filtered color regions; determining the continuity score of the filtered color regions based on the number of filtered color regions; and identifying abnormal color regions in the first set of regions based on the proportion of the first set of regions in the target image and the continuity score.

[0123] In one embodiment, the method further includes: preprocessing the target image to obtain a binarized image of the target image; identifying a first set of regions including the target color region in the target image includes: identifying a first set of regions including the target color region based on the binarized image.

[0124] In one embodiment, the step of preprocessing the target image to obtain a binarized image of the target image includes: performing color space conversion on the target image to obtain a target color space image; and performing binarization processing on the target color space image according to a preset range of target color values ​​to obtain a binarized image of the target image.

[0125] In one embodiment, the step of identifying a first set of regions including the target color region based on a binarized image includes: taking the region corresponding to the white pixel in the binarized image as the first set of regions.

[0126] In one embodiment, the step of selecting interconnected target color regions in a first region set to obtain a second region set includes: detecting interconnected white pixels in a binarized image of the target image to obtain a second region set.

[0127] In one embodiment, the region size includes a preset area threshold of the connected components; the step of filtering the second region set according to the region size to obtain the filtered color region includes: obtaining the area of ​​each target color region in the second region set; and taking the target color region with an area greater than the area threshold of the connected components as the filtered color region.

[0128] In one embodiment, before determining abnormal color regions in the first region set based on the proportion and continuity score of the first region set in the target image, the method further includes: taking the target color region with an area not greater than the area threshold of the connected component as the filtered color region; determining the proportion of the filtered color region in the first region set and using the proportion as the fragmentation ratio; or, determining the difference between the fourth preset value and the proportion and using the difference as the fragmentation ratio.

[0129] In one embodiment, the step of determining the continuity score of the filtered color regions based on the number of filtered color regions includes: determining the ratio between the number of filtered color regions and a first preset value; determining the size relationship between the ratio and a second preset value; determining a target value based on the size relationship, and using the target value as the continuity score of the filtered color regions; or, determining the continuity score of the filtered color regions based on a third preset value and the target value.

[0130] In one embodiment, the step of determining abnormal color regions in the first region set based on the proportion and continuity score of the first region set in the target image includes: determining the fragmentation ratio based on the proportion of the filtered color regions in the first region set; and determining abnormal color regions in the first region set based on the proportion, continuity score, and fragmentation ratio of the first region set in the target image.

[0131] In one embodiment, before determining abnormal color regions in the first region set based on the proportion and continuity score of the first region set in the target image, the method further includes: determining a first number of target pixels in the binarized image of the target image, and using the first number as the total number of pixels in the target color region; determining the ratio between the total number of pixels in the target color region and the total number of pixels in the binarized image, and using the ratio as the proportion of the first region set in the target image.

[0132] In one embodiment, the step of determining abnormal color regions in the first region set based on the proportion and continuity score of the first region set in the target image includes: comparing the proportion with a preset proportion threshold to obtain a first comparison result; comparing the continuity score with a preset continuity score threshold to obtain a second comparison result; and marking the first region set as an abnormal color region when the first comparison result indicates that the proportion is less than the proportion threshold or the second comparison result indicates that the continuity score is less than the continuity score threshold.

[0133] In one embodiment, the method further includes: when the first comparison result indicates that the proportion is not less than the proportion threshold and the second comparison result indicates that the continuity score is not less than the continuity score threshold, marking the first region set as a normal color region.

[0134] In one embodiment, after determining abnormal color regions in the first region set based on the proportion and continuity score of the first region set in the target image, the method further includes: obtaining a binarized image of the target image; overlaying the binarized image with the target image to obtain a result image of image anomaly detection; and displaying the proportion, continuity score, number of filtered color regions, and fragmentation ratio of the first region set in the target image at a preset position in the result image.

[0135] This application also provides an application scenario in which the above-described image anomaly detection method is applied. Specifically, the image anomaly detection method is applied in this scenario as follows:

[0136] During user interaction with the image intelligence platform, the aforementioned image anomaly detection method can be employed. When a user (the object of operation) wants to detect image anomalies, they can log into the image intelligence platform and input the image to be detected (the target image). The platform's backend server can then identify a first set of regions, including target color areas, from the target image. From this first set, interconnected target color areas are selected to obtain a second set of regions. Further, the backend server can filter the second set of regions according to their size, obtaining filtered color areas. Based on the number of filtered color areas, a continuity score is determined. Based on the proportion and continuity score of the first set of regions in the target image, it is determined whether the first set of regions is an anomalous color area (e.g., an abnormal green screen). The image anomaly detection result is then returned to the terminal for visualization. This improves the user experience of image anomaly detection and provides convenience.

[0137] The method provided in this application embodiment can be applied to various image anomaly detection scenarios. The following example illustrates the image anomaly detection method provided in this application embodiment, using a scenario of user interaction with an image intelligence platform as an example.

[0138] With the widespread application of digital imaging technology and intelligent image processing systems, anomalies inevitably occur during the acquisition, transmission, and display of various images. Among these anomalies, in addition to traditional black-and-white image anomalies, abnormal green images (commonly known as the "green screen" problem) are becoming increasingly common. This anomaly often manifests as a darker green area in the image, and its causes may include camera equipment malfunction, signal transmission interference, post-processing errors, and optical component problems. These factors can cause significant deviations in the size, shape, distribution, and continuity of the green areas in the image, thus affecting the overall image quality and the accuracy of subsequent data processing.

[0139] In practical applications, traditional image anomaly detection methods mainly rely on color thresholding techniques to perform simple area statistics and color judgments on green areas. However, simply relying on the proportion of green areas is often insufficient to fully reflect anomalies, because abnormal green screen problems involve not only color deviations but also changes in the continuity and connectivity of green areas within the region. Therefore, developing a detection method that can simultaneously assess the proportion of green areas and spatial continuity in an image is particularly important, as this is of practical significance for distinguishing between normal green backgrounds and abnormal green screen phenomena.

[0140] In other words, traditional methods primarily target global anomaly detection schemes. Figure 3 The images shown can achieve good recognition results, but they are difficult to recognize images with local anomalies, such as... Figure 4 The image shown has normal content in the upper half and abnormal green blocks in the lower half. Using a global method could easily result in a large number of false negatives and false negatives.

[0141] The technical solution provided in this application can solve these problems simultaneously through the design of an innovative and complete process:

[0142] This application proposes a software-based algorithm for detecting abnormal green areas. The algorithm utilizes color space conversion, HSV thresholding, and connected component analysis to comprehensively evaluate green regions in an image, thereby accurately identifying abnormal green screens. Through quantitative analysis of the continuity and connectivity of green regions, this paper provides a multi-dimensional and dynamic anomaly detection method, offering effective technical support for subsequent image quality control, environmental monitoring, and intelligent detection systems. Figure 8 The diagram shows the overall implementation flow of the image anomaly detection method provided in this application. Step 1: Green Region Detection: 1.1 Convert the input image from the BGR color space to the HSV color space. 1.2 Use LowerBound and UpperBound for threshold segmentation to obtain a binary mask. 1.3 Calculate the green ratio = (number of non-zero pixels in the mask) / (total number of pixels). Step 2: Green Continuity Evaluation: 2.1 Perform connected component analysis on the binary mask. 2.2 Filter out components with an area smaller than MinComponentSize to obtain valid components. 2.3 Let N be the number of valid components. 2.4 Calculate continuity_score = 1 - min(N / Constant, 1), where Constant is a normalization factor (e.g., 10), selected based on empirical data. Step 3: Anomaly Judgment: If (green ratio < ratio threshold) or (continuity score < continuity threshold), then the anomaly flag = true; otherwise, the anomaly flag = false. Step 4: Result Visualization: 4.1 Overlay the binary mask and calculated metrics (such as green ratio, continuity score, etc.) onto the original image. 4.2 Generate visualization output and return the green ratio, continuity score, anomaly markers, and visualization results.

[0143] The key technical points involved in the technical solution of this application are as follows:

[0144] 1. Evaluate the presence of green anomalies in images using pure algorithm software.

[0145] This application proposes a software method based on pure algorithms that can detect and evaluate anomalies in green areas of images without the need for additional hardware devices or external calibration data.

[0146] 2. By identifying abnormal green areas through green continuity and connected components, it is possible to effectively distinguish between normal green images and abnormal green images.

[0147] The technical solution provided in this application uses algorithms such as connected component analysis and continuity scoring to perform in-depth analysis and anomaly judgment on green areas from the perspective of spatial distribution and structural characteristics. It effectively distinguishes between normal green backgrounds and abnormal green areas, and can accurately judge abnormal color images, thereby effectively improving the accuracy of image anomaly detection.

[0148] On the product side, the technical solution provided in this application can quickly identify and filter low-quality green image modules using traditional algorithms, and can effectively distinguish them from real green scene images (such as images of green grasslands). By detecting abnormal graphic content caused by data corruption or modification during storage and transfer, data quality can be effectively improved.

[0149] On the technical side, the image anomaly detection method proposed in this application, based on image processing algorithms, comprehensively evaluates the green regions in an image through steps such as color space conversion, color threshold segmentation, and connected component analysis. It calculates the area occupied by the green regions in the image and determines the presence of anomalies based on the continuity of the green regions. Figure 9 The diagram shown is a timing diagram of the overall processing of the image anomaly detection method provided in this application. The overall process of the method provided in this application includes the following key steps:

[0150] 1.1 Green Area Detection

[0151] This method first processes and transforms the image based on color, which facilitates the normalization process of the algorithm.

[0152] 1. Color space conversion

[0153] To better distinguish green features, the input image is first converted from the BGR color space to the HSV color space. In the HSV space, hue provides a more intuitive description of color, facilitating the subsequent extraction of green areas.

[0154] 2. Color threshold segmentation

[0155] Based on a predefined HSV green range (e.g., lower_green = [35, 40, 40], upper_green = [85, 255, 255]), the HSV image is binarized to generate a mask for the green region. In this mask, pixels belonging to the green region are marked as white (255), and other regions are marked as black (0).

[0156] 3. Area Calculation

[0157] By counting the number of white pixels in the binarized mask, the total number of pixels in the green area can be obtained. The proportion R of the green area is calculated by dividing the number of green pixels by the total number of pixels in the image. The formula for calculating the proportion R is as shown in the aforementioned formula (2). This proportion, or proportion R, provides an intuitive area indicator for subsequent anomaly detection.

[0158] 1.2 Green Continuity Assessment

[0159] Connectivity component analysis:

[0160] To analyze the spatial continuity of the green regions, a connected component detection algorithm (e.g., cv2.connectedComponentsWithStats) is applied to the binarized mask. This step identifies all interconnected green regions in the image.

[0161] Connectivity component filtering:

[0162] Given that there may be small fragments in the image due to noise, data corruption or other factors, these small areas are filtered out by setting a minimum connected component area threshold (e.g., min_component_size = 500 pixels), leaving only the valid green components.

[0163] Continuity score calculation:

[0164] The number of effective connected components is counted and denoted as N. Generally speaking, the more continuous the green area, the smaller the value of N should be; while if the green areas in the image are scattered, the value of N will be higher. Therefore, a normalization formula is used to score the continuity, and the calculation formula for the continuity score can be shown in the aforementioned formula (1). In addition, the fragmentation ratio, that is, the proportion of small areas filtered out to the total green area, can also be calculated as an auxiliary judgment indicator.

[0165] 1.3 Code Structure and Functional Modules

[0166] In terms of software implementation, this method completes the entire detection process through the coordinated implementation of the following modules:

[0167] 1. Green area detection module, responsible for image preprocessing, color space conversion, HSV threshold segmentation and green area calculation.

[0168] 2. The green continuity assessment module uses connected component analysis to segment green areas, filter noise, and calculate the continuity score and fragmentation ratio.

[0169] 3. Anomaly detection module: Based on preset green ratio threshold (e.g., ratio_threshold = 0.05) and continuity score threshold (e.g., continuity_threshold = 0.5), determine whether the green background in the image is abnormal.

[0170] 4. The results visualization module overlays the green mask onto the original image, annotating the proportion of green areas, continuity score, number of effective components, and fragmentation ratio to generate an intuitive detection result image.

[0171] 1.4. Parameter Settings and Adjustments

[0172] HSV Green Range:

[0173] Lower bound: lower_green = [35, 40, 40]

[0174] Upper bound: upper_green = [85, 255, 255]

[0175] Adjustment suggestion: Adjust the upper and lower boundaries of HSV appropriately according to the actual lighting conditions and green hue of the image to improve the accuracy of green area extraction.

[0176] Minimum size of connected components:

[0177] Parameter: min_component_size = 500

[0178] Adjustment suggestion: Set an appropriate threshold to filter out noise and small fragments, based on the image resolution and the expected size of the green area.

[0179] Anomaly detection threshold:

[0180] Green coverage threshold: ratio_threshold = 0.05 (5%)

[0181] Continuity rating threshold: continuity_threshold = 0.5

[0182] Recommended adjustment: Determine the optimal threshold through extensive testing of numerous sample images to balance detection accuracy and adaptability.

[0183] The beneficial effects of the technical solution in this application include:

[0184] 1. Low implementation cost and easy integration

[0185] This solution is based on traditional image processing algorithms, requires no expensive dedicated hardware, and can run directly on existing computing platforms, thereby significantly reducing system deployment and maintenance costs. It can also be easily integrated into various image acquisition, detection, and post-processing systems.

[0186] 2. Flexible parameters and strong adaptability

[0187] The solution supports dynamic adjustment of the HSV threshold range, minimum area of ​​connected components, and anomaly detection threshold, and can adapt to different lighting conditions, image resolutions, and green hue variations, thereby significantly improving the robustness and application scope of detection.

[0188] 3. Strong real-time processing capability

[0189] The algorithm exhibits excellent real-time performance when running on standard computing platforms, enabling it to process large numbers of images quickly and meet the demands for efficient, real-time detection and automated processing.

[0190] 4. Efficiently distinguishes between normal and abnormal green images

[0191] This scheme can accurately distinguish between large areas of normal green images and green abnormal images, with an extremely low false alarm rate, ensuring high reliability of the detection results.

[0192] It should be understood that although the steps in the flowcharts of the embodiments described above 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 steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0193] Based on the same inventive concept, this application also provides an image anomaly detection apparatus for implementing the image anomaly detection method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more image anomaly detection apparatus embodiments provided below can be found in the limitations of the image anomaly detection method described above, and will not be repeated here.

[0194] In one embodiment, such as Figure 10 As shown, an image anomaly detection device is provided, comprising: an identification module 1002, a selection module 1004, a filtering module 1006, and a determination module 1008, wherein:

[0195] The recognition module 1002 is used to identify a first set of regions, including the target color region, in the target image.

[0196] The selection module 1004 is used to select interconnected target color regions from the first region set to obtain a second region set.

[0197] The filtering module 1006 is used to perform region filtering on the second region set according to the region size to obtain the filtered color region.

[0198] The determining module 1008 is used to determine the continuity score of the filtered color regions based on the number of filtered color regions; and to determine abnormal color regions in the first region set based on the proportion of the first region set in the target image and the continuity score.

[0199] In one embodiment, the apparatus further includes: a processing module for preprocessing the target image to obtain a binarized image of the target image; and a recognition module for recognizing a first set of regions including the target color region based on the binarized image.

[0200] In one embodiment, the processing module is further configured to perform color space conversion on the target image to obtain a target color space image; and to perform binarization processing on the target color space image according to a preset range of target color values ​​to obtain a binarized image of the target image.

[0201] In one embodiment, the region size includes a preset area threshold for connected components; the device further includes: an acquisition module, configured to acquire the area of ​​each target color region in the second region set; the determination module is further configured to use the target color region whose area is greater than the area threshold of the connected components as the filtered color region.

[0202] In one embodiment, the determining module is further configured to use the target color region corresponding to the area not greater than the area threshold of the connected component as the filtered color region; determine the proportion of the filtered color region in the first region set, and use the proportion as the fragmentation ratio; or, determine the difference between the fourth preset value and the proportion, and use the difference as the fragmentation ratio.

[0203] In one embodiment, the determining module is further configured to determine the ratio between the number of filtered color regions and a first preset value; determine the size relationship between the ratio and a second preset value; determine a target value based on the size relationship, and use the target value as the continuity score of the filtered color regions; or, determine the continuity score of the filtered color regions based on a third preset value and the target value.

[0204] In one embodiment, the determining module is further configured to determine the fragmentation ratio based on the proportion of the filtered color region in the first region set; and to determine abnormal color regions in the first region set based on the proportion of the first region set in the target image, the continuity score, and the fragmentation ratio.

[0205] In one embodiment, the determining module is further configured to determine a first number of target pixels in the binarized image of the target image, and use the first number as the total number of pixels in the target color region; determine the ratio between the total number of pixels in the target color region and the total number of pixels in the binarized image, and use the ratio as the proportion of the first region set in the target image.

[0206] In one embodiment, the device further includes: a comparison module, configured to compare the percentage with a preset percentage threshold to obtain a first comparison result; and compare the continuity score with a preset continuity scoring threshold to obtain a second comparison result; and a marking module, configured to mark the first region set as an abnormal color region when the first comparison result indicates that the percentage is less than the percentage threshold or the second comparison result indicates that the continuity score is less than the continuity scoring threshold.

[0207] In one embodiment, the marking module is further configured to mark the first region set as an abnormal color region when the first comparison result indicates that the proportion is not less than the proportion threshold and the second comparison result indicates that the continuity score is not less than the continuity score threshold.

[0208] In one embodiment, the apparatus further includes: an acquisition module for acquiring a binarized image of the target image; a processing module for overlaying the binarized image with the target image to obtain a result image of image anomaly detection; and a display module for displaying, at a preset position in the result image, the proportion of the first region set in the target image, the continuity score, the number of filtered color regions, and the fragmentation ratio.

[0209] Each module in the aforementioned image anomaly detection device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.

[0210] In one embodiment, a computer device is provided, which may be a terminal or a server. In this embodiment, the computer device is described as a terminal, and its internal structure diagram is as follows. Figure 11 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational 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 stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements a method for detecting image anomalies. The display unit of the computer device is used to form a visually visible image. It can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0211] Those skilled in the art will understand that Figure 11 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0212] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.

[0213] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0214] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0215] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0216] Those skilled in the art will understand that all or part of the processes in 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 described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, etc., and are not limited to these.

[0217] 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.

[0218] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for detecting image anomalies, characterized in that, The method includes: Identify a first set of regions in the target image that includes the target color region; Select interconnected target color regions from the first region set to obtain the second region set; The second set of regions is filtered according to the region size to obtain the filtered color regions. Based on the number of filtered color regions, a continuity score for the filtered color regions is determined. Based on the proportion of the first region set in the target image and the continuity score, abnormal color regions are determined in the first region set.

2. The method according to claim 1, characterized in that, The method further includes: The target image is preprocessed to obtain a binarized image of the target image; The process of identifying a first set of regions in the target image, including the target color region, includes: Based on the binarized image, a first set of regions including the target color region is identified.

3. The method according to claim 2, characterized in that, The preprocessing of the target image to obtain a binarized image of the target image includes: The target image is converted to a different color space to obtain a target color space image. Based on the preset range of target color values, the target color space image is binarized to obtain the binarized image of the target image.

4. The method according to claim 1, characterized in that, The region size includes a preset area threshold for connected components; The step of filtering the second region set according to region size to obtain filtered color regions includes: Obtain the area of ​​each target color region in the second region set; The target color region whose area is greater than the area threshold of the connected component is used as the filtered color region.

5. The method according to claim 4, characterized in that, Before determining abnormal color regions in the first region set based on the proportion of the first region set in the target image and the continuity score, the method further includes: The target color region whose area is not greater than the area threshold of the connected component is used as the filter color region; Determine the proportion of the filtered color region in the first region set, and use the proportion as the fragmentation ratio; or, determine the difference between the fourth preset value and the proportion, and use the difference as the fragmentation ratio.

6. The method according to claim 1, characterized in that, Determining the continuity score of the filtered color regions based on the number of filtered color regions includes: Determine the ratio between the number of filtered color regions and a first preset value; Determine the relationship between the ratio and the second preset value; Based on the aforementioned size relationship, a target value is determined, and this target value is used as the continuity score for the filtered color region; or... The continuity score of the filtered color region is determined based on the third preset value and the target value.

7. The method according to claim 1, characterized in that, The step of determining abnormal color regions in the first region set based on the proportion of the first region set in the target image and the continuity score includes: The fragmentation ratio is determined based on the proportion of the filtered color region in the first region set. Based on the proportion of the first region set in the target image, the continuity score, and the fragmentation ratio, abnormal color regions are determined in the first region set.

8. The method according to claim 1, characterized in that, Before determining abnormal color regions in the first region set based on the proportion of the first region set in the target image and the continuity score, the method further includes: Determine a first number of target pixels in the binarized image of the target image, and use the first number as the total number of pixels in the target color region; Determine the ratio between the total number of pixels in the target color region and the total number of pixels in the binarized image, and use the ratio as the proportion of the first region set in the target image.

9. The method according to claim 1, characterized in that, The step of determining abnormal color regions in the first region set based on the proportion of the first region set in the target image and the continuity score includes: The percentage is compared with a preset percentage threshold to obtain a first comparison result; The continuity score is compared with a preset continuity scoring threshold to obtain a second comparison result; When the first comparison result indicates that the proportion is less than the proportion threshold or the second comparison result indicates that the continuity score is less than the continuity score threshold, the first region set is marked as an abnormal color region.

10. The method according to claim 9, characterized in that, The method further includes: When the first comparison result indicates that the proportion is not less than the proportion threshold, and the second comparison result indicates that the continuity score is not less than the continuity score threshold, the first region set is marked as a normal color region.

11. The method according to any one of claims 1 to 10, characterized in that, After determining the abnormal color regions in the first region set based on the proportion of the first region set in the target image and the continuity score, the method further includes: Obtain the binarized image of the target image; The binarized image is superimposed on the target image to obtain the result image of image anomaly detection; At a preset location in the result image, the percentage of the first region set in the target image, the continuity score, the number of filtered color regions, and the fragmentation ratio are displayed.

12. An image anomaly detection device, characterized in that, The device includes: The recognition module is used to identify a first set of regions, including the target color region, in the target image; The selection module is used to select interconnected target color regions from the first region set to obtain a second region set; The filtering module is used to filter the second set of regions according to the region size to obtain the filtered color regions; The determination module is used to determine the continuity score of the filtered color regions based on the number of filtered color regions; and to determine abnormal color regions in the first region set based on the proportion of the first region set in the target image and the continuity score.

13. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 11.

14. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 11.

15. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 11.