Water body color anomaly detection method and device and electronic equipment
By combining image preprocessing and water area segmentation techniques with HSV color space transformation, the problem of low accuracy in water monitoring technology under complex environments has been solved, and efficient detection of water color anomalies has been achieved.
Patent Information
- Application Number
- CN202511603656.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-04
- Publication Date
- 2026-02-13
AI Technical Summary
Existing water monitoring technologies struggle to accurately identify water color in complex environments, and their accuracy in detecting anomalies is low due to environmental factors.
Using image preprocessing, water area segmentation, and color space transformation techniques, the system performs preset position cruise through image acquisition equipment to enhance image quality and segment water areas, and converts the image to the HSV color space for anomaly detection.
It improves the accuracy and efficiency of detecting abnormal water color, and can stably identify changes in water color in complex environments, providing timely alarms.
Smart Images

Figure CN121527489A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of water color anomaly detection technology, and more specifically, to a method, apparatus, and electronic device for detecting water color anomalies. Background Technology
[0002] With the rapid development of intelligent monitoring technology, the water conservancy and environmental protection industries have placed higher demands on real-time monitoring and anomaly detection of wide-area water bodies. While existing water monitoring technologies have made significant progress in video image processing, they still face the challenge of accurately identifying water color in complex environments. This challenge mainly stems from the following aspects:
[0003] Limitations of wide-area monitoring: Traditional water color recognition technology relies heavily on close-range ground photography, which is insufficient to meet the real-time monitoring needs of large water areas. In addition, ground photography is limited by geographical location, making it difficult to fully grasp the overall state of the water body.
[0004] Interference from environmental factors: Changes in light, weather conditions (such as fog and rain), and seasonal factors can all affect the identification of water color, causing the accuracy of existing technologies to decline under adverse conditions.
[0005] There is currently no effective solution to the above problems. Summary of the Invention
[0006] This application provides a method, apparatus, and electronic device for detecting abnormal water color, in order to at least solve the technical problem that the accuracy of existing water monitoring technologies is low due to the influence of environmental factors.
[0007] According to one aspect of this application, a method for detecting anomalies in water color is provided, comprising: preprocessing an image to be detected to obtain a target image, wherein the image to be detected is a water image captured by an image acquisition device through a preset position cruise mode, and the image preprocessing is used at least to enhance the image quality of the image to be detected if the image quality score is less than or equal to a preset score; segmenting the water area included in the target image to obtain L water area sub-images, wherein L is a positive integer, and the length and width of the minimum bounding matrix corresponding to each of the L water area sub-images are both greater than or equal to a preset side length value; performing spatial transformation on the original pixel data of each pixel included in each water area sub-image to obtain target pixel data of each pixel included in each water area sub-image, wherein the original pixel data includes the three primary color values of the pixel, and the target pixel data includes the hue value, saturation value, and brightness value of the pixel; and performing anomaly detection operation on the water color of the water area based on the target pixel data of each pixel included in each water area sub-image.
[0008] Optionally, image preprocessing is performed on the image to be detected to obtain the target image, including: performing quality detection on the image to be detected based on the multi-scale image features corresponding to the image to be detected to obtain an image quality score; if the image quality score is greater than a preset score, the image to be detected is used as the target image; if the image quality score is less than or equal to the preset score, the image quality of the image to be detected is iteratively enhanced using a target enhancement model until the image quality score of the last enhanced image is greater than the preset score, wherein the target enhancement model is a neural network model trained based on M water area images and the preset score of each water area image, where M is a positive integer; and updating the image size of the last enhanced image to obtain the target image.
[0009] Optionally, the water area included in the target image is segmented to obtain L water area sub-images, including: extracting features from the target image using a target segmentation model to obtain pixel features of X pixels included in the target image, wherein the target segmentation model is a neural network model trained based on N water area images, where X and N are both positive integers, and the pixel features are used to characterize the color information, brightness information, and position information of the pixels; determining the confidence level of each pixel based on the pixel features of each pixel, wherein the confidence level is used to characterize the probability that the pixel belongs to the water area; selecting pixels with a confidence level less than or equal to a preset confidence level as pixels to be deleted; deleting the pixels to be deleted from the X pixels to obtain Y pixels, where Y is a positive integer less than or equal to X; and segmenting the water area included in the target image based on the Y pixel features corresponding to the Y pixels to obtain L water area sub-images.
[0010] Optionally, based on the Y pixel features corresponding to the Y pixels, the water area included in the target image is segmented to obtain L water area sub-images, including: segmenting the water area included in the target image based on the Y pixel features corresponding to the Y pixels to obtain N water area sub-images, where N is a positive integer greater than or equal to L; obtaining the minimum bounding matrix corresponding to each of the N water area sub-images; if the length or width of the minimum bounding matrix is less than a preset side length value, the water area sub-image corresponding to the minimum bounding matrix is taken as a sub-image to be deleted; deleting the sub-images to be deleted from the N water area sub-images to obtain L water area sub-images.
[0011] Optionally, based on the target pixel data of each pixel in each water area sub-image, an anomaly detection operation is performed on the water color of the water area, including: performing a clustering operation on the target pixel data of all pixels in each water area sub-image to obtain three cluster centers for each water area sub-image, wherein the three cluster centers include a hue cluster center, a saturation cluster center, and a brightness cluster center; determining the mean hue, mean saturation, and mean brightness of each water area sub-image based on the three cluster centers of each water area sub-image; and performing anomaly detection on the water color of the water area corresponding to each water area sub-image based on the mean hue, mean saturation, and mean brightness of each water area sub-image.
[0012] Optionally, based on the average hue, average saturation, and average brightness of each water area sub-image, an anomaly detection operation is performed on the water color of the water area corresponding to each water area sub-image, including: obtaining a preset abnormal color of the water area corresponding to the i-th water area sub-image; determining a preset hue range, preset saturation range, and preset brightness range corresponding to the i-th water area sub-image based on the preset abnormal color; determining that the water color of the water area corresponding to the i-th water area sub-image is in an abnormal state if the average hue of the i-th water area sub-image is within the preset hue range, the average saturation of the i-th water area sub-image is within the preset saturation range, and the average brightness of the i-th water area sub-image is within the preset brightness range; and generating an alarm message if the water color of the water area corresponding to the i-th water area sub-image is in an abnormal state.
[0013] Optionally, based on the target pixel data of each pixel in each water area sub-image, an anomaly detection operation is performed on the water color of the water area, including: identifying pixels in the j-th water area sub-image whose saturation value is greater than a preset saturation value and whose brightness value is greater than a preset brightness value as pixels to be detected; identifying the maximum value among the hue values of all pixels to be detected in the j-th water area sub-image as a first hue value; identifying the minimum value among the hue values of all pixels to be detected in the j-th water area sub-image as a second hue value; determining that the water color of the water area corresponding to the j-th water area sub-image is in an abnormal state if the difference between the first hue value and the second hue value is greater than a preset difference; and generating an alarm message if the water color of the water area corresponding to the j-th water area sub-image is in an abnormal state.
[0014] According to another aspect of this application, an anomaly detection device for water color is also provided, comprising: an image preprocessing unit, used to preprocess an image to be detected to obtain a target image, wherein the image to be detected is a water image captured by an image acquisition device through a preset position cruise mode, and the image preprocessing is used at least to enhance the image quality of the image to be detected if the image quality score is less than or equal to a preset score; a water area segmentation unit, used to segment the water area included in the target image to obtain L water area sub-images, wherein L is a positive integer, and the length and width of the minimum bounding matrix corresponding to each of the L water area sub-images are both greater than or equal to a preset side length value; a color space transformation unit, used to perform a color space transformation on the original pixel data of each pixel included in each water area sub-image to obtain target pixel data of each pixel included in each water area sub-image, wherein the original pixel data includes the three primary color values of the pixel, and the target pixel data includes the hue value, saturation value, and brightness value of the pixel; and an anomaly detection unit, used to perform anomaly detection operation on the water color of the water area based on the target pixel data of each pixel included in each water area sub-image.
[0015] According to another aspect of this application, a computer program product is also provided, which stores a computer program, wherein, when the computer program is running, it controls the computer program product to execute any of the above-mentioned methods for detecting abnormal water color.
[0016] According to another aspect of this application, an electronic device is also provided, wherein the electronic device includes one or more processors and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the water color anomaly detection method described above.
[0017] In this application, the image to be detected is first preprocessed to obtain a target image. The image to be detected is a water area image captured by an image acquisition device using a preset position cruise mode. The image preprocessing is used at least to enhance the image quality of the image to be detected if the image quality score is less than or equal to a preset score. Then, the water area included in the target image is segmented to obtain L water area sub-images, where L is a positive integer. The length and width of the minimum bounding matrix corresponding to each of the L water area sub-images are both greater than or equal to a preset side length value. Then, the original pixel data of each pixel in each water area sub-image is spatially transformed to obtain target pixel data of each pixel in each water area sub-image. The original pixel data includes the three primary color values of the pixel, and the target pixel data includes the hue value, saturation value, and brightness value of the pixel. Finally, based on the target pixel data of each pixel in each water area sub-image, the application performs anomaly detection operation on the water color of the water area.
[0018] As can be seen from the above, this application uses a controlled image acquisition device to cruise the water area at a preset position, which overcomes the problem of insufficient close-up shooting angle of the water area in the prior art. This application achieves the purpose of improving the image quality of the images used for detecting abnormal water color by enhancing the image quality of the original water area images acquired.
[0019] Furthermore, this application utilizes water area segmentation technology to effectively separate water and non-water areas in an image, ensuring the targeting and accuracy of subsequent water color anomaly detection. This application converts pixel RGB color values (i.e., the three primary color values) into HSV values (i.e., hue, saturation, and brightness values) through pixel color space transformation, thereby enhancing the color recognition capability under varying lighting conditions in complex environments. This achieves the technical effect of improving the accuracy of water color anomaly detection, thus solving the technical problem of low accuracy in water color anomaly detection caused by environmental factors in existing water monitoring technologies. Attached Figure Description
[0020] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0021] Figure 1 This is a flowchart of an optional method for detecting abnormal water color according to an embodiment of this application;
[0022] Figure 2 This is a flowchart of an optional water color detection method based on video images according to an embodiment of this application;
[0023] Figure 3 This is a schematic diagram of an optional water color anomaly detection device according to an embodiment of this application;
[0024] Figure 4 This is a structural block diagram of an electronic device according to an embodiment of this application. Detailed Implementation
[0025] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0026] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0027] It should also be noted that all relevant information (including but not limited to information related to user flight segments) and data (including but not limited to data used for display and analysis) involved in this application are information and data authorized by the user or fully authorized by all parties. For example, if there is an interface between this system and the relevant user or organization, before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain the relevant information only after receiving consent from the aforementioned user or organization.
[0028] Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of relevant information and data involved in this application all comply with the relevant laws, regulations, and standards of the relevant regions, and necessary confidentiality measures have been taken. This application does not violate public order and good morals. In addition, this application provides a corresponding operation entry point for users to choose to agree to or refuse authorization. If the user chooses to refuse authorization, the corresponding expert decision-making process will be initiated.
[0029] In one optional embodiment, a method for water color discrimination based on mobile phone photos is provided, including the following steps:
[0030] S1: Turn off the smart mode of the phone camera, select the normal shooting mode, ensure the focal length of the phone is 1.0x, and output in original image format; S2: Place the standard color chart on the water body to be tested; S3: Take a picture of the standard color chart and the water surface from above the water body, with the standard color chart in the center of the shooting area; S4: Measure the turbidity of the water body to be tested; S5: Import the photo obtained in S3 into color recognition software, perform color correction on the water body photo, and obtain the HSB value of the water body color; S6: Import the water turbidity from S4 and the water color HSB value from S5 into the color discrimination model to obtain the discrimination result of the water body color to be tested.
[0031] The aforementioned methods rely on mobile phone photography to capture images and directly identify the color of targets in the images, which cannot achieve automated monitoring of color changes in wide-area water bodies. This application, based on video monitoring of wide-area water bodies from mid-to-high-level locations, first performs preprocessing operations such as de-raining and de-fogging on the captured images, then segments the water body regions, next identifies the colors of the segmented water areas, and finally judges abnormal color alarms, thereby overcoming the technical difficulties of automated wide-area water body monitoring.
[0032] The present invention will now be described in detail with reference to various embodiments.
[0033] Example 1
[0034] According to an embodiment of this application, an embodiment of a method for detecting anomalies in water color is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0035] This application provides a water color anomaly detection system (hereinafter referred to as the detection system) for performing the water color anomaly detection method of this application. Figure 1 This is a flowchart of an optional method for detecting anomalies in water color according to an embodiment of this application, such as... Figure 1 As shown, the method includes the following steps:
[0036] Step S101: Perform image preprocessing on the image to be detected to obtain the target image. The image to be detected is a water area image captured by the image acquisition device through a preset position cruise mode. The image preprocessing is used at least to enhance the image quality of the image to be detected if the image quality score is less than or equal to the preset score.
[0037] Optionally, the image acquisition device is mounted on a high point of the tower. The image acquisition device captures video images of a wide area by cruising at preset positions to obtain the image to be detected.
[0038] Optionally, image preprocessing includes, but is not limited to, a series of operations such as size normalization, noise removal, and image quality enhancement. During image preprocessing, the detection system needs to score the quality of the image to be detected captured by the image acquisition device through a preset position cruise mode. If the score is lower than the preset score, image quality enhancement is performed to improve the accuracy of subsequent image analysis.
[0039] Optionally, preset position cruise refers to the camera of the image acquisition device moving and shooting according to a preset path / preset position to ensure that the acquired video images fully cover the area where the water is located.
[0040] In step S101, the detection system can effectively reduce the impact of external factors such as weather and lighting on image quality through the image quality enhancement step in image preprocessing, ensuring that the detection system can obtain clear and high-quality water area images even under harsh conditions, providing a solid data foundation for the accurate analysis of water color in the subsequent process.
[0041] Step S102: Segment the water area included in the target image to obtain L water area sub-images, where L is a positive integer, and the length and width of the minimum bounding matrix corresponding to each of the L water area sub-images are both greater than or equal to the preset side length value.
[0042] Optionally, water segmentation refers to the precise separation of water areas from a complex image background, which can be achieved through computer vision algorithms, such as target semantic segmentation.
[0043] Alternatively, the minimum bounding matrix, also known as the minimum enclosing rectangle or minimum bounding box, is used in the fields of computer vision and image processing to describe the smallest rectangular box surrounding one or more objects.
[0044] Optionally, water area segmentation helps to accurately locate and extract water color information, avoid interference from non-water area targets, and thus improve the accuracy of color anomaly detection. In addition, the setting of the preset side length value can further eliminate false detections and ensure that the water area targets analyzed in the subsequent analysis are meaningful and not isolated noise points, further improving the accuracy of water color anomaly detection.
[0045] Step S103: Perform spatial transformation on the original pixel data of each pixel in each water area sub-image to obtain the target pixel data of each pixel in each water area sub-image. The original pixel data includes the three primary color values of the pixel, and the target pixel data includes the hue value, saturation value, and brightness value of the pixel.
[0046] Optionally, raw pixel data refers to the pixel color information in the RGB (Red Green Blue) color space.
[0047] Optionally, the target pixel data refers to the corresponding information of the pixel in the HSV (Hue Saturation Value) color space.
[0048] Optionally, the HSV color space is closer to how the human eye perceives color. When processing color recognition tasks, HSV color space transformation can effectively reduce the impact of changes in lighting, making color recognition more stable and accurate, and thus improving the accuracy of subsequent abnormal color detection to a certain extent.
[0049] Step S104: Based on the target pixel data of each pixel in each water area sub-map, perform anomaly detection on the water color of the water area.
[0050] Optionally, the detection system can more accurately identify abnormal changes in water color by performing anomaly detection based on target pixel data, i.e., HSV color values, especially for common polluted colors (such as yellow and green), thereby improving the response speed and treatment efficiency for abnormal water conditions.
[0051] In summary, this technical solution comprehensively improves the accuracy and efficiency of color anomaly detection in wide-area waters through steps such as image preprocessing, water area segmentation, color space conversion, and anomaly detection, providing strong technical support for the water conservancy and environmental protection industries. Each step has been optimized to address the limitations of existing technologies, ensuring the efficiency and reliability of the entire process.
[0052] As can be seen from the above, this application uses a controlled image acquisition device to cruise the water area at a preset position, which overcomes the problem of insufficient close-up shooting angle of the water area in the prior art. This application achieves the purpose of improving the image quality of the images used for detecting abnormal water color by enhancing the image quality of the original water area images acquired.
[0053] Furthermore, this application utilizes water area segmentation technology to effectively separate water and non-water areas in an image, ensuring the targeting and accuracy of subsequent water color anomaly detection. This application converts pixel RGB color values (i.e., the three primary color values) into HSV values (i.e., hue, saturation, and brightness values) through pixel color space transformation, thereby enhancing the color recognition capability under varying lighting conditions in complex environments. This achieves the technical effect of improving the accuracy of water color anomaly detection, thus solving the technical problem of low accuracy in water color anomaly detection caused by environmental factors in existing water monitoring technologies.
[0054] In one optional embodiment, during image preprocessing, the detection system first performs quality detection on the image to be detected based on the multi-scale image features corresponding to the image to be detected, and obtains an image quality score. Then, if the image quality score is greater than a preset score, the detection system uses the image to be detected as the target image. If the image quality score is less than or equal to the preset score, the detection system iteratively enhances the image quality of the image to be detected using a target enhancement model until the image quality score of the last enhanced image is greater than the preset score. The target enhancement model is a neural network model trained based on M water area images and the preset score of each water area image, where M is a positive integer. Finally, the detection system updates the image size of the last enhanced image to obtain the target image.
[0055] Optionally, by extracting multi-scale image features from the image to be detected, the detection system can capture local details and global structure in the image, thereby improving the accuracy of the subsequent image quality score.
[0056] Optionally, the detection system can determine the image quality score based on HyperIQA (Adaptive Hyper Network for Blind Image Quality Assessment) technology. The HyperIQA algorithm can automatically judge the image quality based on multi-scale image features without referring to the original lossless image, thereby improving the speed of image quality scoring. Then, an image quality score S in the range of 0 to 1 is obtained.
[0057] Optionally, the default score priority is set to 0.5.
[0058] Optionally, the detection system can quickly filter out high-quality images that do not require additional processing by comparing preset scores, and directly input them into the subsequent water color detection process, saving computing resources and improving processing efficiency.
[0059] Optionally, the detection system can enhance the quality of the image to be detected based on the MPMF-Net model. The MPMF-Net model is trained on the China Tower's own spatial governance image sample library, transferring knowledge of wide-area monitoring scenarios to the current image enhancement application. The enhanced image is then scored again as described above. If it passes the test, it proceeds to the subsequent detection process.
[0060] Optionally, when performing image quality enhancement, the detection system uses a target enhancement model trained on a large number of water images that can automatically adapt to the image enhancement needs under different environments and conditions. The iterative enhancement process ensures that clear and usable images can be obtained even under adverse weather or low light conditions.
[0061] In summary, the detection system achieves an efficient image preprocessing workflow by comprehensively utilizing multi-scale feature analysis, intelligent model enhancement, condition filtering, and size standardization steps, aiming to provide high-quality image input conditions for the anomaly detection of color in wide-area water bodies.
[0062] In one optional embodiment, during the segmentation of the water area included in the target image, the detection system first extracts features from the target image using a target segmentation model to obtain pixel features of X pixels included in the target image. The target segmentation model is a neural network model trained on N water area images, where X and N are both positive integers. The pixel features are used to characterize the color, brightness, and position information of the pixels. Then, based on the pixel features of each pixel, the detection system determines the confidence level of each pixel, where the confidence level characterizes the probability that the pixel belongs to the water area. Next, the detection system identifies pixels with confidence levels less than or equal to a preset confidence level as pixels to be deleted. Subsequently, the detection system deletes the pixels to be deleted from the X pixels, obtaining Y pixels, where Y is a positive integer less than or equal to X. Finally, based on the Y pixel features corresponding to the Y pixels, the detection system segments the water area included in the target image to obtain L water area sub-images.
[0063] Optionally, the default confidence level is preferably set to 0.5.
[0064] Optionally, by combining the color, brightness, and position information of pixels, the detection system extracts pixel features of the target image, enabling the target segmentation model to understand and locate water areas more comprehensively and accurately. This feature extraction, which integrates multiple information, not only improves the model's recognition ability but also provides a solid data foundation for subsequent pixel classification and water area segmentation.
[0065] Optionally, the detection system can quantify the probability that each pixel belongs to the water area by calculating the confidence level. This helps to accurately separate water areas from non-water areas in subsequent steps. The preset confidence level ensures that only pixels with a high probability of belonging to the water area are retained, thereby improving the accuracy and reliability of water area segmentation.
[0066] Optionally, the detection system further purifies the water information in the target image by directly deleting non-water pixels with low confidence, reducing the complexity of subsequent processing and improving the accuracy and efficiency of water segmentation. At the same time, the number of pixels to be calculated in subsequent calculations is reduced, improving the effective utilization of computing resources.
[0067] Optionally, after completing pixel-level water area identification and deletion of non-water area pixels, the detection system segments the Y pixels into water area sub-images. This can accurately delineate different water area ranges, providing clear boundaries for subsequent color analysis. This segmentation ensures that subsequent abnormal color detection is focused only on the valid water area sub-images, improving detection speed and accuracy, while also avoiding interference from non-water area colors.
[0068] In summary, through the progressive processing of multiple steps in the above embodiments, the detection system effectively automates the entire process from image preprocessing to feature extraction, pixel classification, and water area sub-image segmentation. Each step addresses specific problems in image processing, ultimately making water color recognition not only more efficient but also more accurate.
[0069] In one optional embodiment, during the segmentation of the water area included in the target image, the detection system first segments the water area included in the target image based on the Y pixel features corresponding to Y pixels, obtaining N water area sub-images, where N is a positive integer greater than or equal to L; then, the detection system obtains the minimum bounding matrix corresponding to each of the N water area sub-images; then, if the length or width of the minimum bounding matrix is less than a preset side length value, the detection system uses the water area sub-image corresponding to the minimum bounding matrix as a sub-image to be deleted; finally, the detection system deletes the sub-images to be deleted from the N water area sub-images, obtaining L water area sub-images.
[0070] Optionally, the detection system can segment the water area included in the target image based on the Y pixel features corresponding to the Y pixels, thereby finely distinguishing the water area from the non-water area in the image and obtaining a more accurate water area sub-image.
[0071] Optionally, the detection system can effectively define the boundary of each water area sub-map by obtaining the minimum bounding matrix of each sub-map. The minimum bounding matrix provides accurate information on size and location, which facilitates subsequent size filtering and color analysis, thereby achieving the goal of avoiding misjudgment and reducing computational load in subsequent processing.
[0072] Optionally, the detection system performs size filtering based on the length and width (i.e., side length) of the minimum bounding matrix. This can eliminate missegments that may be caused by noise or minor interference, retaining only the larger sub-images that are more likely to represent the real water area. This helps improve the accuracy of subsequent color analysis and reduces the potential impact of non-water areas on the results, making the color analysis more accurate and improving the reliability of abnormal water body color identification.
[0073] In summary, the steps in the above embodiments ensure the accuracy and efficiency of water area segmentation. Through precise size control, the impact of small interference areas on the entire system is avoided, further improving the accuracy and reliability of abnormal water color recognition and providing a more effective and intelligent processing method for the detection system.
[0074] In one optional embodiment, during the anomaly detection operation on the water color of a water body based on the target pixel data of each pixel included in each water body sub-image, the detection system first performs a clustering operation on the target pixel data of all pixels included in each water body sub-image to obtain three cluster centers for each water body sub-image, wherein the three cluster centers include a hue cluster center, a saturation cluster center, and a brightness cluster center; then, based on the three cluster centers of each water body sub-image, the detection system determines the mean hue, mean saturation, and mean brightness of each water body sub-image; finally, based on the mean hue, mean saturation, and mean brightness of each water body sub-image, the detection system performs anomaly detection operation on the water color of the water body corresponding to each water body sub-image.
[0075] Optionally, the three cluster centers refer to the cluster centers in the color space found by a clustering algorithm (such as K-Means Clustering Algorithm), which correspond to the hue cluster center, saturation cluster center, and brightness cluster center, respectively. The three cluster centers are used to summarize the color distribution characteristics of the water area sub-map.
[0076] Optionally, the detection system can automatically discover typical color patterns in water areas—namely, cluster centers for hue, saturation, and brightness—by performing clustering operations on all pixels of each water area sub-image. This statistically based analysis method effectively summarizes the color characteristics of water areas, providing a solid data foundation for subsequent anomaly detection. Compared to traditional manual threshold setting, this method is more flexible and objective, and can adapt to water area color recognition under different lighting conditions and environmental changes.
[0077] Optionally, the mean hue, mean saturation, and mean brightness refer to the overall average values calculated based on the three cluster centers of each water area submap. These average values represent the most common color patterns in that water area submap.
[0078] Optionally, the detection system simplifies complex color distribution information into easily understandable and comparable average values by calculating the mean. In this way, even if the colors of the water body exhibit some diversity, the detection system can quickly determine the dominant color state using the mean, providing a standardized comparison benchmark for subsequent anomaly color detection. This method can eliminate the influence of individual extreme values, making color analysis more robust.
[0079] Optionally, the detection system can automatically identify abnormal water colors, such as pollution or algal blooms, by comparing the average values of hue, saturation, and brightness with a preset normal color range. The entire detection process requires no manual intervention, thus enabling timely and accurate alarms. In addition, this solution can flexibly adjust the threshold for abnormal detection according to different environmental conditions and water quality standards, greatly enhancing the system's adaptability and monitoring accuracy.
[0080] In summary, through the steps in the above embodiments, the detection system effectively transforms complex image color analysis into operable statistical indicators, realizing automated and intelligent detection of water color anomalies, improving efficiency and accuracy, and providing strong technical support for water quality monitoring and pollution early warning.
[0081] In one optional embodiment, during the anomaly detection operation of the water color corresponding to each water sub-map based on the average hue, average saturation, and average brightness of each water sub-map, the detection system first obtains the preset abnormal color of the water corresponding to the i-th water sub-map; then, based on the preset abnormal color of the i-th water sub-map, the detection system determines the preset hue range, preset saturation range, and preset brightness range of the i-th water sub-map; then, if the average hue of the i-th water sub-map is within the preset hue range / the average saturation of the i-th water sub-map is within the preset saturation range / the average brightness of the i-th water sub-map is within the preset brightness range, the detection system determines that the water color of the water corresponding to the i-th water sub-map is in an abnormal state; subsequently, if the water color of the water corresponding to the i-th water sub-map is in an abnormal state, the detection system generates an alarm message.
[0082] Optionally, the preset abnormal color of the water area corresponding to the i-th water area sub-map refers to the abnormal color threshold or range set for the specific water area based on historical data, environmental standards, or specific scenario requirements. These preset abnormal colors include range values of hue, saturation, and brightness.
[0083] Optionally, by acquiring preset abnormal colors, the detection system provides a clear basis for subsequent anomaly detection, ensuring the consistency and rationality of the detection standards. These preset values are often derived from a large amount of observation data and professional analysis, reflecting the color distribution of a specific water area under normal conditions. Thus, when an abnormal color is detected, the system can react quickly, improving the accuracy and reliability of anomaly identification.
[0084] Optionally, the preset hue range, preset saturation range, and preset brightness range corresponding to the preset abnormal colors obtained by the detection system are abnormal ranges of hue, saturation, and brightness set according to the characteristics of the i-th water area sub-image. These range values are used to compare with the average of actual measurements to determine whether there is an abnormality.
[0085] Optionally, by setting preset hue, saturation, and brightness ranges, the detection system can transform the complex problem of abnormal color recognition into numerical judgment within specific ranges, simplifying the anomaly detection process and making it more standardized and automated. This step ensures that the system can quickly and accurately identify anomalies based on the color characteristics of the water area sub-map, without being affected by external conditions such as lighting and weather.
[0086] Optionally, the detection system can quantitatively determine whether the water color is abnormal by comparing the mean with a preset range. This method can effectively identify early signs of water quality changes, such as excessive algae growth and pollutant discharge, providing timely early warning information for environmental protection and water conservancy departments, and helping to take measures to prevent water quality deterioration and protect water resources.
[0087] Optionally, by generating alarm information, the detection system ensures that abnormal situations can be quickly and accurately notified to relevant personnel, improving response speed and reducing oversights and delays in manual monitoring. Through timely alarms, relevant departments can take action as soon as possible, such as water quality testing and pollution source investigation.
[0088] In summary, through the steps in the above embodiments, this application achieves automated detection and alarm of abnormal colors in specific water area sub-maps, which not only improves the efficiency and accuracy of monitoring, but also provides strong technical support for water resource management and environmental protection. By combining the intelligent processing capabilities of deep learning and the accuracy of statistical analysis, the detection system can effectively meet the monitoring needs of water color changes in wide-area video surveillance scenarios.
[0089] In one optional implementation, during the anomaly detection operation of the water color of a water body based on the target pixel data of each pixel included in each water body sub-image, the detection system first identifies pixels in the j-th water body sub-image whose saturation value is greater than a preset saturation value and whose brightness value is greater than a preset brightness value as pixels to be detected. Then, the detection system uses the maximum value among the hue values corresponding to all pixels to be detected in the j-th water body sub-image as the first hue value. Next, the detection system uses the minimum value among the hue values corresponding to all pixels to be detected in the j-th water body sub-image as the second hue value. Subsequently, if the difference between the first hue value and the second hue value is greater than a preset difference, the detection system determines that the water color of the water body corresponding to the j-th water body sub-image is in an abnormal state. Finally, if the water color of the water body corresponding to the j-th water body sub-image is in an abnormal state, the detection system generates an alarm message.
[0090] Optionally, the detection system defines a set of filtering rules based on the detection conditions of "saturation value greater than preset saturation value" and "brightness value greater than preset brightness value" to filter out pixels that may represent abnormal colors.
[0091] Optionally, by setting filtering rules, namely by setting dual thresholds for saturation and brightness, it is possible to filter out pixels with abnormally bright colors and high brightness. These pixels usually represent areas in the water where pollutants may exist or where there are special environmental changes. This method can more accurately locate the source of abnormal colors, reduce false alarms, and improve monitoring efficiency.
[0092] Optionally, the first hue value refers to the maximum value among all the hue values corresponding to the pixels to be detected in the j-th water area sub-image. It represents the brightest hue of the abnormal color. By calculating the maximum hue value of the pixels to be detected, the extreme performance of abnormal colors in the water area can be captured, providing intuitive data support for assessing the severity of water quality problems.
[0093] Optionally, the second hue value refers to the minimum hue value among all the hue values corresponding to the pixels to be detected. In contrast to the first hue value, it represents the darkest hue of the abnormal color. By calculating the minimum hue value, together with the maximum value, the range of hue variation of the abnormal color can be comprehensively measured, which is crucial for understanding the complexity of water quality changes. By comparing the maximum and minimum hue values, it can be determined whether the color anomaly has a significant hue difference, further refining the dimensions of anomaly judgment.
[0094] Optionally, the detection system can quantitatively determine the degree of color abnormality in water by comparing the hue difference with a preset difference. If the difference is greater than the preset value, it means that there is a significant hue difference in the water, which may be a sign of water pollution, algal blooms, or other environmental factors. This method is particularly effective for detecting complex changes in water quality and can capture water quality problems that cannot be reflected by a single hue.
[0095] In summary, through the steps in the above embodiments, the detection system further refines the detection and alarm mechanism for abnormal water body colors in the water area sub-map. In the above embodiments, not only the brightness and saturation of the color are considered, but the distribution of the hue is also analyzed in depth. By calculating the maximum and minimum values of the hue and the differences between them, water quality changes can be identified more comprehensively and meticulously, further improving the accuracy of water area monitoring results.
[0096] As can be seen from the above, this application uses a controlled image acquisition device to cruise the water area at a preset position, which overcomes the problem of insufficient close-up shooting angle of the water area in the prior art. This application achieves the purpose of improving the image quality of the images used for detecting abnormal water color by enhancing the image quality of the original water area images acquired.
[0097] Furthermore, this application utilizes water area segmentation technology to effectively separate water and non-water areas in an image, ensuring the targeting and accuracy of subsequent water color anomaly detection. This application converts pixel RGB color values (i.e., the three primary color values) into HSV values (i.e., hue, saturation, and brightness values) through pixel color space transformation, thereby enhancing the color recognition capability under varying lighting conditions in complex environments. This achieves the technical effect of improving the accuracy of water color anomaly detection, thus solving the technical problem of low accuracy in water color anomaly detection caused by environmental factors in existing water monitoring technologies.
[0098] According to an embodiment of this application, a water color detection method based on video images is also provided. Figure 2 This is a flowchart of an optional water color detection method based on video images according to an embodiment of this application, such as... Figure 2 As shown, the method includes the following steps:
[0099] (1) Video image input: The high-definition camera mounted on the high point of the iron tower captures video images of a wide area through preset position cruise mode, and transmits the captured image data to the subsequent water color recognition process.
[0100] (2) Image preprocessing: The input image is first judged by the HyperIQA algorithm and outputs a quality score S in the range of 0 to 1. If S>0.5, it is considered a qualified image and is input into the subsequent processing flow; otherwise, it is input into the image quality enhancement model. The image enhancement algorithm adopts the integrated image enhancement method MPMF-Net[4]. This model is trained based on the space governance image sample library of the tower and transfers the knowledge of wide-area monitoring scenarios to the current image enhancement application. The enhanced image is scored again as described above. If it is qualified, it enters the subsequent process; otherwise, the alarm process is terminated. The qualified image input is size normalized and the longest side is limited to 1080. The other side is scaled proportionally.
[0101] (3) Water body region segmentation: For the processed image, the trained target semantic segmentation model [5] is called to extract all pixel information of the water body region. A pixel confidence filtering process is set up, specifically, pixels with a confidence greater than 0.5 are retained and the rest are filtered out; a region size filtering process is set up, specifically, if the width and height of the minimum bounding rectangle of the segmented region are less than 100 pixels, the region is considered too small and will not enter the subsequent process; after filtering, all the retained pixels are integrated into a tensor containing RGB information and transmitted to the next step of processing.
[0102] (4) Color space transformation: The water area pixels obtained in the previous step are transformed from RGB space to HSV space. The specific calculation formula is as follows:
[0103]
[0104]
[0105]
[0106] In the above formula, R, G, and B are the red, green, and blue color values corresponding to the pixel, respectively, and H, S, and V are the hue, saturation, and brightness values of the pixel, respectively. The converted HSV water space is more in line with human color perception and can reduce the interference of light on water color recognition to a certain extent.
[0107] (5) Color Clustering Analysis of Water Areas: Three color cluster centers were determined for unsupervised clustering, which can be performed using the K-means clustering algorithm. Specifically, three centroids were randomly selected based on the HSV value of each pixel. The Euclidean distance from any point to these three centroids was calculated, and pixels with the same nearest centroid were grouped together. Then, the center position within each group was calculated to obtain new centroids. The above calculation process was repeated until the new centroids were the same as the previous centroids. Finally, the three color cluster centers and the hue mean of the HSV space were obtained. Mean saturation average brightness .
[0108] (6) Feedback on abnormal water color alarm results: Based on the actual scenario requirements, abnormal water bodies are defined as abnormal yellow, abnormal green, and water bodies containing multiple colors with significant differences. For abnormal yellow, the upper and lower limits of hue H are [16,34], saturation S is [43,255], and brightness V is [46,255]. For abnormal green, the upper and lower limits of hue H are [35,77], saturation S is [43,255], and brightness V is [46,255].
[0109] If the average HSV value obtained in the previous step falls within the upper and lower limits here, it is determined to be an abnormal water color and an alarm is triggered. In addition, the hue H values of pixels with saturation S>43 and brightness V>46 are counted, and the difference between the maximum and minimum hue H values of these pixels is calculated. If the difference is greater than the preset threshold of 60, it is determined that there is a significant color difference in the water area, and an abnormal water color alarm is triggered.
[0110] Example 2
[0111] This application embodiment can also provide a water color anomaly detection device. It should be noted that the water color anomaly detection device of this application embodiment can be used to execute the water color anomaly detection method provided in this application embodiment. The water color anomaly detection device provided in this application embodiment will be described below.
[0112] According to an embodiment of this application, an apparatus for implementing the above-described method for detecting anomalies in water color is also provided. Figure 3 This is a schematic diagram of an optional water color anomaly detection device according to an embodiment of this application, as shown below. Figure 3 As shown, the device includes: an image preprocessing unit 301, a water area segmentation unit 302, a color space transformation unit 303, and an anomaly detection unit 304.
[0113] Optionally, the image preprocessing unit 301 is used to preprocess the image to be detected to obtain a target image, wherein the image to be detected is a water area image captured by the image acquisition device through a preset position cruise mode, and the image preprocessing is used at least to enhance the image quality of the image to be detected if the image quality score is less than or equal to the preset score; the water area segmentation unit 302 is used to segment the water area included in the target image to obtain L water area sub-images, wherein L is a positive integer, and the length and width of the minimum bounding matrix corresponding to each of the L water area sub-images are both greater than or equal to the preset side length value; the color space transformation unit 303 is used to perform a color space transformation on the original pixel data of each pixel included in each water area sub-image to obtain the target pixel data of each pixel included in each water area sub-image, wherein the original pixel data includes the three primary color values of the pixel, and the target pixel data includes the hue value, saturation value, and brightness value of the pixel; the anomaly detection unit 304 is used to perform anomaly detection operation on the water color of the water area based on the target pixel data of each pixel included in each water area sub-image.
[0114] In one optional embodiment, the image preprocessing unit 301 includes: a quality detection subunit, a target image determination subunit, a quality enhancement subunit, and a size update subunit.
[0115] Optionally, the quality detection subunit is used to perform quality detection on the image to be detected based on the multi-scale image features corresponding to the image to be detected, and obtain an image quality score; the target image determination subunit is used to take the image to be detected as the target image when the image quality score is greater than a preset score; the quality enhancement subunit is used to iteratively enhance the image quality of the image to be detected through the target enhancement model when the image quality score is less than or equal to the preset score, until the image quality score of the last enhanced image is greater than the preset score, wherein the target enhancement model is a neural network model trained based on M water area images and the preset score of each water area image, where M is a positive integer; and the size update subunit is used to update the image size of the last enhanced image to obtain the target image.
[0116] In one optional embodiment, the water area segmentation unit 302 includes: a feature extraction subunit, a confidence determination subunit, a pixel to be deleted determination subunit, a pixel deletion subunit, and a water area segmentation subunit.
[0117] Optionally, the feature extraction subunit is used to extract features from the target image using a target segmentation model to obtain pixel features of X pixels in the target image. The target segmentation model is a neural network model trained on N water area images, where X and N are both positive integers. The pixel features are used to characterize the color, brightness, and position information of the pixels. The confidence determination subunit is used to determine the confidence level of each pixel based on its pixel features. The confidence level characterizes the probability that a pixel belongs to a water area. The pixel to be deleted subunit is used to identify pixels with a confidence level less than or equal to a preset confidence level as pixels to be deleted. The pixel deletion subunit is used to delete the pixels to be deleted from the X pixels, obtaining Y pixels, where Y is a positive integer less than or equal to X. The water area segmentation subunit is used to segment the water areas in the target image based on the Y pixel features corresponding to the Y pixels, obtaining L water area sub-images.
[0118] In one optional embodiment, the water area segmentation subunit includes: a water area segmentation module, a minimum outer matrix determination module, a subgraph to be deleted determination module, and a subgraph deletion module.
[0119] Optionally, the water area segmentation module is used to segment the water area included in the target image based on the Y pixel features corresponding to Y pixels, to obtain N water area sub-images, where N is a positive integer greater than or equal to L; the minimum bounding matrix determination module is used to obtain the minimum bounding matrix corresponding to each of the N water area sub-images; the sub-image to be deleted determination module is used to determine the water area sub-image corresponding to the minimum bounding matrix as the sub-image to be deleted if the length or width of the minimum bounding matrix is less than a preset side length value; and the sub-image deletion module is used to delete the sub-image to be deleted from the N water area sub-images to obtain L water area sub-images.
[0120] In one optional embodiment, the anomaly detection unit 304 includes: a clustering subunit, a color mean determination subunit, and an anomaly detection subunit.
[0121] Optionally, a clustering subunit is used to perform clustering operations on the target pixel data of all pixels included in each water area sub-image to obtain three cluster centers for each water area sub-image, wherein the three cluster centers include a hue cluster center, a saturation cluster center, and a brightness cluster center; a color mean determination subunit is used to determine the hue mean, saturation mean, and brightness mean of each water area sub-image based on the three cluster centers of each water area sub-image; and an anomaly detection subunit is used to perform anomaly detection operations on the water color of the water body corresponding to each water area sub-image based on the hue mean, saturation mean, and brightness mean of each water area sub-image.
[0122] In one optional embodiment, the anomaly detection subunit includes: a preset anomaly color acquisition subunit, a preset color range determination subunit, a first anomaly state determination subunit, and an alarm information generation subunit.
[0123] Optionally, a preset color acquisition subunit is used to acquire a preset abnormal color of the water body corresponding to the i-th water body sub-image; a preset color range determination subunit is used to determine a preset hue range, a preset saturation range, and a preset brightness range corresponding to the i-th water body sub-image based on the preset abnormal color corresponding to the i-th water body sub-image; a first abnormal state determination subunit is used to determine that the water color of the water body corresponding to the i-th water body sub-image is in an abnormal state when the average hue of the i-th water body sub-image is within the preset hue range / the average saturation of the i-th water body sub-image is within the preset saturation range / the average brightness of the i-th water body sub-image is within the preset brightness range; and an alarm information generation subunit is used to generate alarm information when the water color of the water body corresponding to the i-th water body sub-image is in an abnormal state.
[0124] In an optional embodiment, the anomaly detection unit 304 further includes: a pixel point determination subunit, a first hue value determination subunit, a second hue value determination subunit, a second anomaly state determination subunit, and an alarm information generation subunit.
[0125] Optionally, the pixel to be detected subunit is used to identify pixels whose saturation value is greater than a preset saturation value and whose brightness value is greater than a preset brightness value among all pixels included in the j-th water area sub-image as pixels to be detected; the first hue value determination subunit is used to identify the maximum hue value among all hue values corresponding to the pixels to be detected included in the j-th water area sub-image as the first hue value; the second hue value determination subunit is used to identify the minimum hue value among all hue values corresponding to the pixels to be detected included in the j-th water area sub-image as the second hue value; the second abnormal state determination subunit is used to determine that the water color of the water body corresponding to the j-th water area sub-image is in an abnormal state if the difference between the first hue value and the second hue value is greater than a preset difference; and the alarm information generation subunit is used to generate alarm information when the water color of the water body corresponding to the j-th water area sub-image is in an abnormal state.
[0126] It should be noted that the image preprocessing unit 301, water area segmentation unit 302, color space transformation unit 303, and anomaly detection unit 304 mentioned above correspond to steps S101 to S104 in the method embodiment. The instances and application scenarios implemented by the above units and the corresponding steps are the same, but are not limited to the content disclosed in the above embodiment.
[0127] Example 3
[0128] Embodiments of this application can also provide an electronic device. Figure 4 This is a structural block diagram of an electronic device according to an embodiment of this application, such as... Figure 4 As shown, the electronic device includes: one or more ( Figure 4 (Only one is shown) Processor 402, memory 404, memory controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0129] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the methods and devices in the embodiments of this application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby realizing the above-mentioned method for detecting abnormal water color.
[0130] The memory may include high-speed random access memory (RAM), and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, which can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks (LANs), mobile communication networks, and combinations thereof.
[0131] The processor can access information and applications stored in the memory via a transmission device to perform the following steps: Preprocessing the image to be detected to obtain a target image, wherein the image to be detected is a water area image captured by an image acquisition device using a preset position cruise mode; the image preprocessing is used at least to enhance the image quality of images to be detected whose image quality score is less than or equal to a preset score; segmenting the water area included in the target image to obtain L water area sub-images, where L is a positive integer, and the length and width of the minimum bounding matrix corresponding to each of the L water area sub-images are both greater than or equal to a preset side length value; performing spatial transformation on the original pixel data of each pixel in each water area sub-image to obtain target pixel data of each pixel in each water area sub-image, wherein the original pixel data includes the three primary color values of the pixel, and the target pixel data includes the hue value, saturation value, and brightness value of the pixel; and performing anomaly detection on the water color of the water area based on the target pixel data of each pixel in each water area sub-image.
[0132] The processor can access the information and application program stored in the memory via the transmission device to execute the following steps: Based on the multi-scale image features corresponding to the image to be detected, perform quality detection on the image to be detected to obtain an image quality score; if the image quality score is greater than a preset score, use the image to be detected as the target image; if the image quality score is less than or equal to the preset score, iteratively enhance the image quality of the image to be detected using a target enhancement model until the image quality score of the last enhanced image is greater than the preset score, wherein the target enhancement model is a neural network model trained based on M water area images and the preset score of each water area image, where M is a positive integer; update the image size of the last enhanced image to obtain the target image.
[0133] The processor can access the information and application programs stored in the memory via a transmission device to execute the following steps: Extracting features from the target image using a target segmentation model to obtain pixel features of X pixels in the target image. The target segmentation model is a neural network model trained on N water area images, where X and N are both positive integers. The pixel features characterize the color, brightness, and location information of the pixels. Determining the confidence level of each pixel based on its pixel features, where the confidence level characterizes the probability that the pixel belongs to the water area. Pixels with confidence levels less than or equal to a preset confidence level are designated as pixels to be deleted. Deleting the pixels to be deleted from the X pixels yields Y pixels, where Y is a positive integer less than or equal to X. Segmenting the water area in the target image based on the Y pixel features corresponding to the Y pixels yields L water area sub-images.
[0134] The processor can access the information and application program stored in the memory via the transmission device to perform the following steps: based on the Y pixel features corresponding to Y pixels, segment the water area included in the target image to obtain N water area sub-images, where N is a positive integer greater than or equal to L; obtain the minimum bounding matrix corresponding to each of the N water area sub-images; if the length or width of the minimum bounding matrix is less than a preset side length value, use the water area sub-image corresponding to the minimum bounding matrix as the sub-image to be deleted; delete the sub-image to be deleted from the N water area sub-images to obtain L water area sub-images.
[0135] The processor can access the information and application programs stored in the memory via the transmission device to perform the following steps: performing clustering operations on the target pixel data of all pixels included in each water area sub-map to obtain three cluster centers for each water area sub-map, wherein the three cluster centers include a hue cluster center, a saturation cluster center, and a brightness cluster center; determining the mean hue, mean saturation, and mean brightness of each water area sub-map based on the three cluster centers; and performing anomaly detection operations on the water color of the corresponding water area for each water area sub-map based on the mean hue, mean saturation, and mean brightness of each water area sub-map.
[0136] The processor can access information and applications stored in the memory via a transmission device to perform the following steps: obtain the preset abnormal color of the water body corresponding to the i-th water body sub-image; based on the preset abnormal color of the i-th water body sub-image, determine the preset hue range, preset saturation range, and preset brightness range of the i-th water body sub-image; if the average hue of the i-th water body sub-image is within the preset hue range / the average saturation of the i-th water body sub-image is within the preset saturation range / the average brightness of the i-th water body sub-image is within the preset brightness range, determine that the water color of the water body corresponding to the i-th water body sub-image is in an abnormal state; if the water color of the water body corresponding to the i-th water body sub-image is in an abnormal state, generate an alarm message.
[0137] The processor can access the information and application program stored in the memory via the transmission device to perform the following steps: Pixels whose saturation value is greater than a preset saturation value and whose brightness value is greater than a preset brightness value among all pixels included in the j-th water area sub-image are designated as pixels to be detected; the maximum value among the hue values corresponding to all pixels to be detected in the j-th water area sub-image is designated as the first hue value; the minimum value among the hue values corresponding to all pixels to be detected in the j-th water area sub-image is designated as the second hue value; if the difference between the first hue value and the second hue value is greater than a preset difference, the water color of the water body corresponding to the j-th water area sub-image is determined to be in an abnormal state; if the water color of the water body corresponding to the j-th water area sub-image is in an abnormal state, an alarm message is generated.
[0138] This application provides a scheme for detecting anomalies in water color. It overcomes the problem of insufficient close-up shooting angles in existing technologies by controlling an image acquisition device to cruise the water area at a preset position. Furthermore, it improves the image quality of the images used for detecting water color anomalies by enhancing the image quality of the acquired raw water area images.
[0139] Furthermore, this application utilizes water area segmentation technology to effectively separate water and non-water areas in an image, ensuring the targeting and accuracy of subsequent water color anomaly detection. This application converts pixel RGB color values (i.e., the three primary color values) into HSV values (i.e., hue, saturation, and brightness values) through pixel color space transformation, thereby enhancing the color recognition capability under varying lighting conditions in complex environments. This achieves the technical effect of improving the accuracy of water color anomaly detection, thus solving the technical problem of low accuracy in water color anomaly detection caused by environmental factors in existing water monitoring technologies.
[0140] Those skilled in the art will understand that Figure 4 The structure shown is for illustrative purposes only. Electronic devices can also be smartphones, tablets, PDAs, mobile internet devices, PADs, and other terminal devices. Figure 4 This does not limit the structure of the aforementioned electronic device. For example, electronic devices may also include components that are more... Figure 4 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 4 The different configurations shown.
[0141] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0142] Example 4
[0143] Embodiments of this application may also provide a storage medium.
[0144] Optionally, in this embodiment of the application, the storage medium can be used to store the program code executed by the water color anomaly detection method provided in the above method embodiment.
[0145] Optionally, in this embodiment, the storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.
[0146] This application also provides a computer program product, which, when executed on a data processing device, is suitable for performing steps of a method for detecting anomalies in water color.
[0147] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0148] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0149] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0150] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0151] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0152] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0153] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for detecting abnormal water color, characterized in that, include: Image preprocessing is performed on the image to be detected to obtain the target image. The image to be detected is a water area image captured by the image acquisition device through a preset position cruise mode. The image preprocessing is used at least to enhance the image quality of the image to be detected if the image quality score is less than or equal to the preset score. The target image is segmented into L water area sub-images, where L is a positive integer. The length and width of the minimum bounding matrix corresponding to each of the L water area sub-images are both greater than or equal to a preset side length value. A spatial transformation is performed on the original pixel data of each pixel in each water area sub-image to obtain the target pixel data of each pixel in each water area sub-image. The original pixel data includes the three primary color values of the pixel, and the target pixel data includes the hue value, saturation value, and brightness value of the pixel. Based on the target pixel data of each pixel point included in each water area sub-map, an anomaly detection operation is performed on the water color of the water area.
2. The method for detecting abnormal water color according to claim 1, characterized in that, Image preprocessing is performed on the image to be detected to obtain the target image, including: Based on the multi-scale image features corresponding to the image to be detected, the image to be detected is subjected to quality detection to obtain an image quality score; If the image quality score is greater than the preset score, the image to be detected is taken as the target image; If the image quality score is less than or equal to the preset score, the image to be detected is iteratively enhanced using a target enhancement model until the image quality score of the last enhanced image is greater than the preset score. The target enhancement model is a neural network model trained based on M water area images and the preset score of each water area image, where M is a positive integer. The image size of the last obtained enhanced image is updated to obtain the target image.
3. The method for detecting abnormal water color according to claim 1, characterized in that, The target image is segmented into L sub-images representing the water areas, including: The target image is subjected to feature extraction by a target segmentation model to obtain the pixel features of X pixels in the target image. The target segmentation model is a neural network model trained on N water area images, where X and N are both positive integers. The pixel features are used to characterize the color information, brightness information and position information of the pixels. Based on the pixel features of each pixel, the confidence level of each pixel is determined, wherein the confidence level is used to characterize the probability that the pixel belongs to the water area; Pixels with a confidence level less than or equal to a preset confidence level are designated as pixels to be deleted. Delete the pixels to be deleted from the X pixels to obtain Y pixels, where Y is a positive integer less than or equal to X; Based on the Y pixel features corresponding to the Y pixels, the water area included in the target image is segmented to obtain L water area sub-images.
4. The method for detecting abnormal water color according to claim 3, characterized in that, Based on the Y pixel features corresponding to the Y pixels, the water area included in the target image is segmented to obtain L water area sub-images, including: Based on the Y pixel features corresponding to the Y pixels, the water area included in the target image is segmented to obtain N water area sub-images, where N is a positive integer greater than or equal to L; Obtain the minimum outer matrix corresponding to each of the N water area subgraphs; If the length or width of the minimum bounding matrix is less than the preset side length value, the water area subgraph corresponding to the minimum bounding matrix is taken as the subgraph to be deleted. The subgraphs to be deleted from the N water area subgraphs are deleted to obtain the L water area subgraphs.
5. The method for detecting abnormal water color according to claim 1, characterized in that, Based on the target pixel data of each pixel point included in each water area sub-map, an anomaly detection operation is performed on the water color of the water area, including: Clustering is performed on the target pixel data of all pixels included in each water area sub-image to obtain three cluster centers for each water area sub-image, wherein the three cluster centers include a hue cluster center, a saturation cluster center, and a brightness cluster center. Based on the three cluster centers of each water area sub-map, the mean hue, mean saturation, and mean brightness of each water area sub-map are determined. Based on the average hue, average saturation, and average brightness of each water area sub-image, an anomaly detection operation is performed on the water color of the corresponding water area for each water area sub-image.
6. The method for detecting abnormal water color according to claim 5, characterized in that, Based on the average hue, average saturation, and average brightness of each water area sub-map, anomaly detection is performed on the water color of the corresponding water area for each water area sub-map, including: Obtain the preset abnormal color of the water area corresponding to the i-th water area sub-image; Based on the preset abnormal color corresponding to the i-th water area sub-image, determine the preset hue range, preset saturation range, and preset brightness range corresponding to the i-th water area sub-image; If the average hue value of the i-th water area sub-image is within a preset hue range, the average saturation value of the i-th water area sub-image is within a preset saturation range, and the average brightness value of the i-th water area sub-image is within a preset brightness range, then the water color of the water area corresponding to the i-th water area sub-image is determined to be in an abnormal state. If the water color of the water body corresponding to the i-th water area sub-map is in an abnormal state, an alarm message is generated.
7. The method for detecting abnormal water color according to claim 1, characterized in that, Based on the target pixel data of each pixel point included in each water area sub-map, an anomaly detection operation is performed on the water color of the water area, including: Pixels whose saturation value is greater than a preset saturation value and whose brightness value is greater than a preset brightness value are included in the j-th water area sub-image and are selected as pixels to be detected. The maximum value among all the hue values corresponding to the pixels to be detected included in the j-th water area sub-image is taken as the first hue value; The minimum value among all the hue values corresponding to the pixels to be detected included in the j-th water area sub-image is taken as the second hue value; If the difference between the first hue value and the second hue value is greater than a preset difference, it is determined that the water color of the water body corresponding to the j-th water body sub-map is in an abnormal state. If the water color of the water body corresponding to the j-th water area sub-map is in an abnormal state, an alarm message is generated.
8. A device for detecting abnormal water color, characterized in that, include: An image preprocessing unit is used to perform image preprocessing on the image to be detected to obtain a target image. The image to be detected is a water area image captured by an image acquisition device in a preset position cruise mode. The image preprocessing is used at least to enhance the image quality of the image to be detected if the image quality score is less than or equal to the preset score. The water area segmentation unit is used to segment the water area included in the target image to obtain L water area sub-images, where L is a positive integer, and the length and width of the minimum bounding matrix corresponding to each of the L water area sub-images are both greater than or equal to a preset side length value. The color space transformation unit is used to perform a space transformation on the original pixel data of each pixel in each water area sub-image to obtain the target pixel data of each pixel in each water area sub-image. The original pixel data includes the three primary color values of the pixel, and the target pixel data includes the hue value, saturation value, and brightness value of the pixel. An anomaly detection unit is used to perform anomaly detection operations on the water color of the water body based on the target pixel data of each pixel point included in each water body sub-map.
9. A computer program product, characterized in that, The computer program product includes a computer program, wherein, when the computer program is executed, it controls the computer program product to perform the abnormal water color detection method according to any one of claims 1 to 7.
10. An electronic device, characterized in that, It includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the method for detecting abnormal water color as described in any one of claims 1 to 7.