Anomaly water mass identification method, electronic device, and storage medium
Patent Information
- Application Number
- CN202611191281.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-07
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2046-08-07
AI Technical Summary
[0004]本申请提供一种异常水团识别方法、电子设备及存储介质,以便解决当前异常水团识别方法中,简单的数字图像处理技术易导致识别边界不清或特征提取失真,方法的鲁棒性不足,依赖人工观察的方式,识别精度有限,漏判率较高,结果呈现不直观,不利于非专业人员快速理解与决策的问题
[0025]本申请提供的异常水团识别方法,通过获取待检测水域的基准图像和实时拍摄的现状图像,生成基准图像和现状图像之间的差分图像,设置基准图像作为参照生成差分图像,在一定程度上抑制了静态背景的干扰,差分图像中可能存在因异常水团形成的运动点,因此,通过识别差分图像中的运动点,基于动态的运动点确定表征异常水团的聚类矩形框,实现将像素级差异转化为区域级对象,减少了孤立噪声点的影响,实现初步定位异常水团的可能位置和范围,通过基准图像和聚类矩形框,生成关于异常水团的初始识别图,确定聚类矩形框的形状特征,并基于形状特征确定聚类矩形框的基础形状分数,形状特征包括聚类矩形框的宽高比、聚类矩形框内运动点的紧凑度和密度,基础形状分数用于表征所述聚类矩形框与异常水团的匹配程度,本申请创新性地量化聚类矩形框的基础形状分数,从而通过基础形状分数对初始识别图的聚类矩形框进行筛选,得到并展示关于异常水团的目标识别图,通过识别聚类矩形框的宽高比、聚类矩形框内运动点的紧凑度和密度等形状特征,准确量化聚类矩形框的基础形状分数,有效解决了复杂干扰导致特征提取失真的问题,通过多维度几何与统计特征,有效区分云影、波纹等干扰与水团,显著提升了异常水团识别的准确度和鲁棒性,从而通过基础形状分数对初始识别图的聚类矩形框进行筛选,得到并展示关于异常水团的目标识别图,有助于将形状与密度不符合的聚类矩形框剔除,降低漏判与误判,将误检率有效降低8%-30%以上,并且解决了异常水团识别结果呈现不直观的问题,实现自动、准确识别水域水体中的异常水团,减少对人工观察的依赖,确保识别的实时性,无需人工干预,降低了识别的误判率,进一步提高了对水域水体中异常水团识别的精度,也便于非专业人员快速理解,支持快速决策。
Smart Images

Figure CN122695222B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the fields of inland water environment monitoring, water anomaly detection, and computer vision water quality analysis technology, and in particular relates to an abnormal water mass identification method, electronic equipment, and storage medium. Background Technology
[0002] In the fields of aquatic environment monitoring and water body analysis, the ability to quickly and accurately identify abnormal water masses in water bodies is of great significance for ecological environment monitoring and water quality early warning. Among them, abnormal water masses refer to water body units in which the physical, chemical or optical properties are significantly different from the surrounding background water bodies and form a certain continuous distribution in space. Abnormal water masses deviate from the normal state compared to normal water masses.
[0003] Currently, the identification of abnormal water masses mainly relies on two methods: digital image processing technology and manual observation. Manual observation involves personnel using on-site sampling and laboratory physicochemical analysis, or directly observing images from monitoring systems, relying on subjective experience to manually interpret, label, and characterize areas with abnormal water color. Digital image processing technology primarily employs algorithms such as fixed threshold segmentation, edge detection, or simple color space conversion to extract color and grayscale information from images, identifying areas exceeding a preset fixed threshold as abnormal water masses. However, these two methods of identifying abnormal water masses have significant limitations: First, due to the complex backgrounds and various interference factors in actual aquatic environments, such as changes in lighting, cloud cover, water surface ripples, and changes in water turbidity, traditional digital image processing technologies using fixed thresholds or fixed identification parameters are prone to unclear identification boundaries or distorted feature extraction when facing complex environments, making it difficult to accurately identify abnormal water masses. Second, relying on manual observation has limited identification accuracy and a high rate of false negatives. Third, the results are not intuitively presented, hindering quick understanding and decision-making by non-professionals. Summary of the Invention
[0004] This application provides an abnormal water mass identification method, electronic device, and storage medium to address the problems in current abnormal water mass identification methods, such as unclear identification boundaries or distorted feature extraction due to simple digital image processing techniques, insufficient robustness of the methods, reliance on manual observation, limited identification accuracy, high false negative rate, and unintuitive results presentation, which are not conducive to quick understanding and decision-making by non-professionals.
[0005] To solve the above-mentioned technical problems, this application is implemented as follows: In a first aspect, this application provides a method for identifying abnormal water masses, the method comprising: Acquire baseline images and real-time current status images of the water area to be detected; Generate a difference image between the reference image and the current image; Identify moving points in the difference image, and determine clustering rectangles representing abnormal water masses based on the moving points; An initial identification map of the abnormal water mass is generated using the baseline image and the clustering bounding box. The shape features of the clustering rectangle are determined, and the basic shape score of the clustering rectangle is determined based on the shape features; the shape features include the aspect ratio of the clustering rectangle, the compactness and density of moving points within the clustering rectangle, and the basic shape score is used to characterize the degree of matching between the clustering rectangle and the anomalous water mass; The clustering rectangles of the initial identification map are filtered using the basic shape scores to obtain and display the target identification map of the abnormal water mass.
[0006] Optionally, identifying moving points in the difference image and determining clustering bounding boxes representing anomalous water masses based on the moving points includes: For any pixel in the difference image, if the pixel difference corresponding to the pixel is greater than a first dynamic threshold, then the pixel is determined to be a moving point in the difference image; the moving point includes target moving points and non-target moving points. For any target moving point in the difference image, identify the neighboring points of the target moving point; wherein the Euclidean distance between the neighboring points of the target moving point and the target moving point is less than a distance threshold; Determine the total number of neighboring points for each target motion point; If the total number is greater than the number threshold, then the target movement point is determined to be the core point; Clustering the core point and its neighboring points yields clustering rectangles used to characterize abnormal water masses.
[0007] Optionally, determining the shape features of the clustering rectangle includes: For any clustering rectangle, calculate the height, width, and number of moving points within the clustering rectangle; Based on the height and width of the clustering rectangle, calculate the first ratio of height to width, the second ratio of width to height, the area and perimeter of the clustering rectangle; The larger value between the first ratio and the second ratio is determined as the aspect ratio of the clustering rectangle; The ratio between the square values of the area and the perimeter is determined as the compactness of the moving points within the clustering rectangle; The ratio of the number of moving points within the clustering rectangle to the area is determined as the density of moving points within the clustering rectangle. The aspect ratio of the moving points within the clustering rectangle is characterized by the following formula:
[0008] aspectRatio(C) is the aspect ratio of the clustering rectangle C, where width is the width of the clustering rectangle C and height is the height of the clustering rectangle C. The compactness of the moving points within the clustering rectangle is characterized by the following formula:
[0009] compactness(C) is the compactness of the moving points within the clustering rectangle C, width is the width of the clustering rectangle C, and height is the height of the clustering rectangle C; The density of moving points within the clustering rectangle is characterized by the following formula:
[0010] density(C) is the density of moving points within the clustering rectangle C, |C| is the number of moving points within the clustering rectangle C, and bboxArea(C) is the area of the clustering rectangle C.
[0011] Optionally, determining the basic shape score of the clustering rectangle based on the shape features includes: The reciprocal of the larger value between the aspect ratio and the preset benchmark value is determined as the aspect ratio fraction of the clustering rectangle. The smaller value between the compactness multiplied by the first factor and the benchmark value is determined as the compactness score of the clustering rectangle. The smaller value between the density multiplied by the second factor and the baseline value is determined as the density fraction of the clustering rectangle; The average of the aspect ratio score, compactness score, and density score is determined as the basic shape score of the clustering rectangle. The aspect ratio fraction is represented by the following formula:
[0012] aspectRatioScore is the aspect ratio score of the cluster rectangle, aspectRatio is the aspect ratio of the cluster rectangle, and Math.max() is to take the maximum value. The compactness score is represented by the following formula:
[0013] compactnessScore is the compactness score of the clustering rectangle, compactness is the compactness of the moving points within the clustering rectangle, 'a' is the first multiple, and Math.min() is to take the minimum value; The density fraction is characterized by the following formula:
[0014] densityScore is the density score of the clustering rectangle, density is the density of moving points within the clustering rectangle, b is a multiple of the second value, and Math.min() is used to take the minimum value. The basic shape fraction is represented by the following formula:
[0015] baseScore is the basic shape score of the clustering rectangle, aspectRatioScore is the aspect ratio score of the clustering rectangle, compactnessScore is the compactness score of the clustering rectangle, and densityScore is the density score of the clustering rectangle.
[0016] Optionally, the step of filtering the clustering rectangles of the initial recognition map using the basic shape scores to obtain and display the target recognition map for the abnormal water mass includes: For any clustering rectangle in the initial recognition image, the basic shape score of the clustering rectangle is compared with a preset score threshold; If the basic shape score is less than the score threshold, the clustering rectangle is determined to be an invalid clustering rectangle. If the basic shape score is greater than or equal to the score threshold, then the clustering rectangle is determined to be a valid clustering rectangle; Invalid clustering rectangles in the initial identification map are removed to obtain and display the target identification map for the abnormal water mass.
[0017] Optionally, after filtering the clustering rectangles of the initial recognition map using the basic shape scores to obtain and display the target recognition map for the abnormal water mass, the method further includes: Identify the RGB value of each pixel in the original image corresponding to the target recognition map; Extract the R channel, G channel, and B channel values from the RGB values; Based on the R channel values, G channel values, and B channel values, determine the actual proportion of the target object's corresponding channel values in the RGB values; If the actual proportion is greater than the second dynamic threshold, then the pixel is determined to be a feature point of the target object.
[0018] Optionally, after determining that the pixel is a feature point of the target object, the method further includes: For any clustered rectangle in the target recognition image, identify the number and proportion of target feature points within the clustered rectangle; The percentage and the basic shape score of the clustering rectangle are compared to determine the total similarity of the target objects in the clustering rectangle; The ratio of the sum of the similarities of the target objects to the number is determined as the average similarity of the target objects in the clustering rectangle; The product of the percentage and the average target object similarity is determined as the target object feature score of the clustering rectangle; Based on the basic shape score and target feature score of the clustered rectangle, update the target recognition map for the abnormal water mass; The update of the target recognition map for abnormal water masses based on the basic shape score and target feature score of the clustered rectangles is achieved by the following formula:
[0019] FinalScore is the overall score of the clustered rectangles, baseScore is the basic shape score of the clustered rectangles, abAlgaeScore is the target feature score of the clustered rectangles, and abAlgaeWeight is the weight of the target feature score.
[0020] Optionally, generating a difference image between the reference image and the current image includes: The reference image and the current image are subjected to grayscale conversion and edge detection to generate corresponding edge images. Feature points are extracted from their respective edge images, and the feature points are matched to obtain matching feature point pairs; The matching feature point pairs are filtered to obtain valid matching feature point pairs. Based on the valid matching feature point pairs, the spatial transformation parameters of the reference image and the current image are determined. Based on the spatial transformation parameters, the current image is aligned with the reference image; Calculate the pixel difference between the aligned current image and the reference image at the same coordinate point; Based on the pixel difference, a difference image is generated between the reference image and the current image.
[0021] Secondly, this application provides an abnormal water mass identification device, the device comprising: The first acquisition module is used to acquire a baseline image and a real-time captured image of the current status of the water area to be detected. The first generation module is used to generate a difference image between the reference image and the current image; The first identification module is used to identify moving points in the difference image and determine clustering rectangles representing abnormal water masses based on the moving points. The second generation module is used to generate an initial identification map of the abnormal water mass using the reference image and the clustering rectangle; The second identification module is used to determine the shape features of the clustering rectangle and determine the basic shape score of the clustering rectangle based on the shape features; the shape features include the aspect ratio of the clustering rectangle, the compactness and density of moving points within the clustering rectangle, and the basic shape score is used to characterize the degree of matching between the clustering rectangle and the anomalous water mass; The results display module is used to filter the clustering rectangles of the initial recognition map based on the basic shape score, and to obtain and display the target recognition map of the abnormal water mass.
[0022] Thirdly, this application provides an electronic device, including: a transceiver, a memory, a processor, and a program stored in the memory and executable on the processor; The processor is used to read the program in the memory to execute any of the above-described abnormal water mass identification methods.
[0023] Fourthly, this application provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform any of the above-described methods for identifying abnormal water masses.
[0024] Fifthly, this application provides a computer program product, including a computer program / instructions, which, when executed by a processor, implement the steps of the abnormal water mass identification method as described in the first aspect of this application.
[0025] The abnormal water mass identification method provided in this application acquires a reference image of the water area to be detected and a real-time captured current image, generates a difference image between the reference image and the current image, and sets the reference image as a reference to generate the difference image, which to a certain extent suppresses the interference of static background. Since there may be moving points in the difference image caused by abnormal water masses, by identifying the moving points in the difference image, clustering rectangles representing abnormal water masses are determined based on the dynamic moving points, realizing the transformation of pixel-level differences into region-level objects, reducing the influence of isolated noise points, and achieving preliminary location of the possible position and range of abnormal water masses. An initial identification image of the abnormal water masses is generated using the reference image and the clustering rectangles. The shape features of the clustering rectangles are determined, and a basic shape score is determined based on the shape features. The shape features include the aspect ratio of the clustering rectangles, the compactness and density of moving points within the clustering rectangles, and the basic shape score is used to characterize the degree of matching between the clustering rectangles and the abnormal water masses. This application innovatively quantifies the basic shape score of the clustering rectangles, thereby using the basic shape score to characterize the initial identification image. The system filters the clustered rectangles to obtain and display target identification maps of abnormal water masses. By identifying shape features such as the aspect ratio, compactness, and density of moving points within the clustered rectangles, it accurately quantifies the basic shape score of the clustered rectangles, effectively solving the problem of feature extraction distortion caused by complex interference. Through multi-dimensional geometric and statistical features, it effectively distinguishes interference such as cloud shadows and ripples from water masses, significantly improving the accuracy and robustness of abnormal water mass identification. The basic shape score is used to filter the clustered rectangles in the initial identification map to obtain and display target identification maps of abnormal water masses. This helps to remove clustered rectangles whose shape and density do not match, reducing missed and false detections, effectively reducing the false detection rate by 8%-30% or more. It also solves the problem of unintuitive presentation of abnormal water mass identification results, enabling automatic and accurate identification of abnormal water masses in water bodies, reducing reliance on manual observation, ensuring real-time identification, eliminating the need for manual intervention, reducing the false detection rate, further improving the accuracy of abnormal water mass identification in water bodies, and facilitating quick understanding by non-professionals, supporting rapid decision-making. Attached Figure Description
[0026] To more clearly illustrate the technical solutions in this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 This is a flowchart of the steps of an abnormal water mass identification method provided in this application; Figure 2 yes Figure 1The diagram shown is a schematic of the target interface during the image uploading stage in an abnormal water mass identification method provided in this application. Figure 3 yes Figure 1 The diagram shown is a schematic representation of the target interface in the image upload stage of an abnormal water mass identification method provided in this application. Figure 4 yes Figure 1 The diagram shown is an initial identification image in an abnormal water mass identification method provided in this application. Figure 5 yes Figure 1 The image shown is a schematic diagram of the target identification map in an abnormal water mass identification method provided in this application; Figure 6 This is a structural block diagram of an abnormal water mass identification device provided in this application; Figure 7 This is a structural block diagram of an electronic device provided in this application. Detailed Implementation
[0028] The technical solutions of this application will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0029] In inland water monitoring and hydrological analysis, the rapid and accurate identification of abnormal water masses is crucial for ecological environment monitoring and water quality early warning. Traditional methods for identifying abnormal water masses mainly rely on manual observation or simple image processing techniques. However, manual observation is inefficient and has a high false negative rate, while simple image processing techniques cannot cope with the effects of complex backgrounds and changes in lighting, resulting in poor robustness, limited accuracy in identifying abnormal water masses, poor visualization, and difficulty in intuitively displaying the identification results. To address these issues, this application provides an abnormal water mass identification method, electronic device, and storage medium.
[0030] Reference Figure 1 , Figure 1 This is a flowchart illustrating the steps of an abnormal water mass identification method provided in this application, as follows: Figure 1 As shown, the method may include: Step 101: Obtain the baseline image and the real-time captured current status image of the water area to be detected.
[0031] In this embodiment, the water area to be monitored refers to a specific water body area that requires monitoring for water quality anomalies, early warning of pollution, or ecological safety assessment. The water surface may be affected by factors such as wind, waves, sunlight, water flow, and biological activity, resulting in non-abnormal dynamic changes such as ripples, cloud shadows, and floating plants. The water surface background may include static objects such as shorelines, bridges, and buoys, as well as semi-static disturbances such as reflections, shadows, and water surface reflections. It is necessary to identify abnormal water masses in real time and accurately. An abnormal water mass refers to a local water mass in the water area to be monitored that differs significantly from normal water bodies in terms of physical, chemical, or biological characteristics. Common types of abnormal water masses include polluted water masses, algal water masses, suspended solids water masses, and water masses with abnormal turbidity / color. Polluted water masses include pollution belts formed by industrial wastewater, domestic sewage, oil spills, and chemical leaks. Algal water masses include algal blooms or scum layers formed by the massive proliferation of cyanobacteria and green algae. Suspended water masses, such as areas with high concentrations of silt, organic debris, or microplastics, and water masses with abnormal turbidity / color, such as red tides, milky white polluted water, and dye leaks.
[0032] In this embodiment, the reference image is an image of the water area to be detected when it is clean and free of or has very few floating objects, used as a benchmark for identifying and comparing abnormal water masses. The current situation image is a real-time image of the water area to be detected, which can be acquired in real time by a camera deployed on the shore of the water area or by related equipment carrying a camera. Because the results of abnormal water mass identification are not intuitive, this application sets up a target interface to display the uploaded reference image, current situation image, and subsequent target identification image. The reference image is... Figure 2 This diagram illustrates the target interface during the image upload stage of an abnormal water mass identification method provided in this application. During the image upload stage, the display of the target interface comprises two parts, such as... Figure 2 As shown, the left side allows you to click to upload the first image, which displays the current status image captured in real time. The right side allows you to click to upload the second image, which displays the baseline image. Each current status image captured in real time is compared with the baseline image.
[0033] In this embodiment, after the current image is uploaded to the image upload page, several checks need to be performed on the current image before loading it. These checks include verifying the file format of the current image, i.e., obtaining the file extension of the current image, converting it to lowercase, and verifying whether the extension is any one of jpg, jpeg, or png. If so, the file format verification is successful. The file size of the current image is also verified to determine whether it exceeds a file size threshold, such as 10MB. The file size threshold can be updated or adjusted as needed. If the file size of the current image is less than the file size threshold, the file size verification is successful. In this case, Canvas drawing technology can be used to adapt the size of the current image and display it within a preset fixed display area of the target interface.
[0034] In some embodiments of this application, the file format and file size of the current image can also be identified, the file format and file size can be verified, and if the verification is successful, the current image can be adjusted to fit the preset display area of the target interface and displayed in the display area.
[0035] When performing size adaptation processing, the original width and height of the current image are first obtained, and the original aspect ratio is calculated. A predefined fixed display area will have a pre-defined width and height, for example, 300px and 200px. Then, different adaptation algorithms are selected according to the requirements. Algorithm one maintains the original aspect ratio and scales the current image so that it fills the display area in at least one direction; any portion exceeding the display area is cropped. In this case, the image data within the display area is the size-adapted image data. Algorithm two maintains the original aspect ratio and scales the current image so that it completely fits within the display area. In this case, blank margins may remain in the display area, and the image data within the display area is the size-adapted image data. Algorithm three ignores the original aspect ratio and forcibly stretches or compresses the image to the specified width and height. In this case, the image data within the display area is the size-adapted image data, and the image may be distorted. Then, you can use the Canvas tool to render and create a 300px × 200px canvas, draw the adapted image data onto the canvas, and display it within the preset fixed display area of the target interface.
[0036] The above steps, by first verifying the compliance of image format and size, then standardizing and adapting the image and displaying it at a fixed size, ensure the stability, consistency and compatibility of the image preprocessing stage. This provides a reliable and intuitive visual input basis for subsequent abnormal water mass identification, while reducing the risk of misjudgment due to differences in the baseline image.
[0037] Step 102: Generate a difference image between the reference image and the current image.
[0038] In this embodiment of the application, after the reference image and the current image are uploaded to the target interface, they are preprocessed. (Refer to...) Figure 3 This diagram illustrates the target interface in the image upload stage of an abnormal water mass identification method provided in this application. The fixed display area is 300px wide and 200px high to ensure that the reference image and the current image are the same size. The target interface can then display images such as... Figure 3 The image shown is a schematic diagram of the uploaded stage. Dotted lines connect points of the same color to represent the same coordinate point between the current image and the reference image. Specifically, the current image and the reference image are aligned, and the pixel difference between the aligned current image and the reference image at the same coordinate point is calculated. Based on this pixel difference, a difference image between the reference image and the current image is generated. The value of each pixel in the difference image is the pixel difference between the current image and the reference image at the same coordinate point. A larger pixel difference indicates a higher probability of abnormal water masses in that pixel area, while a smaller pixel difference indicates a lower probability of abnormal water masses in that pixel area.
[0039] The above steps, by performing pixel-by-pixel difference calculations on the two aligned images, can efficiently and intuitively highlight the local pixel change areas caused by abnormal water masses, providing clean and focused input data for subsequent clustering and difference map generation, and significantly improving the sensitivity and accuracy of change detection.
[0040] Step 103: Identify moving points in the difference image and determine clustering rectangles representing abnormal water masses based on the moving points.
[0041] In this embodiment, a moving point refers to a difference point between the baseline image and the current image of the water body to be detected at the same geographical location. On the differential image, it is a spatial unit whose pixel value difference exceeds a preset threshold; that is, a moving point is a pixel with a pixel difference greater than a first preset value. For example, the baseline image displayed when there is no abnormal water mass in the water body to be detected, and the current image displayed after an abnormal water mass enters the water body to be detected, show points with significant differences. Moving points are used to represent abrupt changes in the optical properties of the water body and are a direct image representation of abnormal water masses such as algal blooms, high-turbidity plumes, and pollution zones. Therefore, a clustering rectangle representing the abnormal water mass is determined based on the moving points, where the clustering rectangle is the bounding rectangle of the detected abnormal water mass.
[0042] Step 104: Generate an initial identification map of the anomalous water clumps using the baseline image and clustering bounding boxes.
[0043] In this embodiment, an initial identification map of abnormal water masses can be generated using clustering bounding boxes. To facilitate observation of the distribution of abnormal water masses in the area to be detected, this application overlays a reference image with the clustering bounding boxes to generate the initial identification map of abnormal water masses. Figure 4 The diagram shows an initial identification image in an abnormal water mass identification method provided in this application, as shown below. Figure 4 As shown, the pixel value of the red pixel represents the pixel difference between the reference image and the current image after alignment, which is used to generate the difference image. The value of each pixel in the difference image is the pixel difference between the current image and the reference image at the same coordinate point. The larger the pixel difference, the more likely the abnormal water mass is to appear in this pixel area. The smaller the pixel difference, the less likely the abnormal water mass is to appear in this pixel area.
[0044] Step 105: Determine the shape features of the clustering rectangles and determine the basic shape scores of the clustering rectangles based on the shape features.
[0045] Shape features include the aspect ratio of the clustering rectangle, the compactness and density of moving points within the clustering rectangle, and the basic shape score is used to characterize the degree of matching between the clustering rectangle and the anomalous water mass.
[0046] After obtaining the initial recognition image, this application needs to further process it. At this time, it is necessary to first determine the shape features of each clustering rectangle in the initial recognition image, so as to determine the basic shape score of the clustering rectangle based on the shape features. The shape features include the aspect ratio of the clustering rectangle, the compactness and density of the moving points within the clustering rectangle. The aspect ratio of the clustering rectangle is the ratio of the width to the height of the clustering rectangle, which reflects the extension direction and morphological tendency of the abnormal water mass in spatial distribution. The compactness of the moving points within the clustering rectangle is used to measure the degree of aggregation of the moving points within the clustering rectangle, that is, the pixels that have changed significantly in the difference image, in spatial distribution. The moving points of the actual abnormal water mass usually show a continuous, dense, and non-void clustered distribution in space, that is, a high compactness. The density of moving points within a clustered rectangle is the ratio of the number of moving points to the area of the clustered rectangle. This density reflects the proportion of moving points within the rectangle. Actual anomalous water masses exhibit continuous regional chromatic aberrations or texture variations in imaging, resulting in a high density of moving points. Calculating the density of moving points within a clustered rectangle allows for the assessment of the point distribution density, facilitating the subsequent elimination of sparse noise regions. By jointly analyzing multiple shape features, the basic shape score of the clustered rectangle can be determined based on these features, effectively distinguishing between moving point clusters caused by actual anomalous water masses and regions caused by environmental noise or lighting changes.
[0047] This application allows setting dynamic and adjustable thresholds for aspect ratio, compactness, and density, and then removing a portion of the clustered rectangles based on these thresholds. For example, clustered rectangles with aspect ratios less than a certain threshold, compactness less than a certain threshold, and / or density less than a certain threshold are removed. The thresholds for aspect ratio, compactness, and density can be set according to the size or requirements of identifying abnormal water masses.
[0048] Step 106: Filter the clustering rectangles of the initial recognition map using basic shape scores to obtain and display the target recognition map of the abnormal water mass.
[0049] After obtaining the basic shape score, this application can filter the clustered rectangles of the initial recognition image based on the basic shape score. In this embodiment, the higher the basic shape score, the more representative the corresponding clustered rectangle is to the abnormal water mass. Therefore, a score threshold is preset. When the basic shape score of a clustered rectangle is less than the score threshold, the clustered rectangle and its internal motion points need to be removed. After removing all clustered rectangles that do not meet the conditions, the filtered result is the adjusted target recognition image of the abnormal water mass, which can then be intuitively displayed.
[0050] The abnormal water mass identification method provided in this application acquires a reference image of the water area to be detected and a real-time captured current image, generates a difference image between the reference image and the current image, and sets the reference image as a reference to generate the difference image, which to a certain extent suppresses the interference of static background. Since there may be moving points in the difference image caused by abnormal water masses, by identifying the moving points in the difference image, clustering rectangles representing abnormal water masses are determined based on the dynamic moving points, realizing the transformation of pixel-level differences into region-level objects, reducing the influence of isolated noise points, and achieving preliminary location of the possible position and range of abnormal water masses. An initial identification image of the abnormal water masses is generated using the reference image and the clustering rectangles. The shape features of the clustering rectangles are determined, and a basic shape score is determined based on the shape features. The shape features include the aspect ratio of the clustering rectangles, the compactness and density of moving points within the clustering rectangles, and the basic shape score is used to characterize the degree of matching between the clustering rectangles and the abnormal water masses. This application innovatively quantifies the basic shape score of the clustering rectangles, thereby using the basic shape score to characterize the initial identification image. The system filters the clustered rectangles to obtain and display target identification maps of abnormal water masses. By identifying shape features such as the aspect ratio, compactness, and density of moving points within the clustered rectangles, it accurately quantifies the basic shape score of the clustered rectangles, effectively solving the problem of feature extraction distortion caused by complex interference. Through multi-dimensional geometric and statistical features, it effectively distinguishes interference such as cloud shadows and ripples from water masses, significantly improving the accuracy and robustness of abnormal water mass identification. The basic shape score is used to filter the clustered rectangles in the initial identification map to obtain and display target identification maps of abnormal water masses. This helps to remove clustered rectangles whose shape and density do not match, reducing missed and false detections, effectively reducing the false detection rate by 8%-30% or more. It also solves the problem of unintuitive presentation of abnormal water mass identification results, enabling automatic and accurate identification of abnormal water masses in water bodies, reducing reliance on manual observation, ensuring real-time identification, eliminating the need for manual intervention, reducing the false detection rate, further improving the accuracy of abnormal water mass identification in water bodies, and facilitating quick understanding by non-professionals, supporting rapid decision-making.
[0051] In some embodiments of this application, the motion points include target motion points and non-target motion points. In step 103, identifying motion points in the difference image and determining clustering rectangles representing abnormal water masses based on the motion points can specifically include the following steps: Sub-step S11: For any pixel in the difference image, if the pixel difference corresponding to the pixel is greater than the first dynamic threshold, then the pixel is determined to be a moving point in the difference image; the moving point includes target moving points and non-target moving points. Sub-step S12: For any target moving point in the difference image, identify the neighboring points of the target moving point; wherein, the Euclidean distance between the neighboring points of the target moving point and the target moving point is less than the distance threshold. Sub-step S13: Determine the total number of neighboring points for each target movement point; Sub-step S14: If the total number is greater than the number threshold, then the target moving point is determined as the core point; Sub-step S15: Cluster the core point and its neighboring points to obtain a clustering rectangle used to characterize the abnormal water mass.
[0052] In this embodiment, pixels in the difference image whose pixel difference is greater than a first dynamic threshold are identified as moving points in the difference image. The pixel difference refers to the absolute value obtained by subtracting the grayscale value or the value of a certain color channel of a pixel in the reference image and the current image at the same coordinate position. The first dynamic threshold is a minimum pixel difference threshold dynamically set according to the required accuracy of identifying abnormal water masses. The higher the first dynamic threshold, the lower the detection sensitivity; only large changes will be identified as moving points.
[0053] The above steps use dynamically preset thresholds to binarize pixel differences, transforming continuous grayscale images of differences into discrete sets of moving points representing significant changes. This effectively filters out minor disturbances caused by slight changes in illumination, sensor noise, etc., thereby focusing on areas of significant change that may actually be caused by abnormal water mass movement, and greatly improving the signal purity and computational efficiency of subsequent clustering analysis.
[0054] In this embodiment, the clustering rectangle is the bounding rectangle of the detected abnormal water mass. The moving points include target moving points and non-target moving points. For any target moving point in the difference image, the neighboring points of the target moving point are identified. The Euclidean distance between the neighboring points of the target moving point and the target moving point is less than a distance threshold. It should be noted that the distance threshold used to identify the neighboring points corresponding to the moving point can be dynamically adjusted based on the location and range of the abnormal water mass. For example, the initial value of the distance threshold is set to 10.
[0055] In this embodiment, after identifying a moving point, its neighboring points are also identified. For ease of understanding, this application distinguishes moving points into target moving points and non-target moving points. A target moving point is any moving point currently being identified, and a non-target moving point is any moving point other than the target moving point being identified. The neighboring points of a target moving point are non-target moving points whose distance to the target moving point is less than a distance threshold. For example, suppose the distance threshold is... The identified moving points form a point set P = {P1, P2, ..., Pn}. For Pi, we perform identification; Pi is the target moving point, and the neighboring points of Pi are defined as N_ (pi)={pj∈P|distance(pi,pj)≤ } where distance(pi, pj) is the distance between the target moving point Pi and its corresponding neighbor point Pj. After identifying the corresponding neighbor points for each moving point, the total number of neighbor points corresponding to each moving point is determined. If the total number of a certain neighbor point is greater than a second preset value, then the neighbor point is determined to be a core point. This application combines the core point and the corresponding neighbor points of the core point into a cluster. A core point and its corresponding neighbor points are combined into a cluster, and then a clustering rectangle is generated for a cluster. When generating the clustering rectangle, the coordinates of the points within the corresponding cluster are first identified, and the minimum x-coordinate Xmin, maximum x-coordinate Xmax, minimum y-coordinate Ymin, and maximum y-coordinate Ymax are found. Based on these extreme coordinates, the boundary coordinates, width, and height of the clustering rectangle are determined, where width = Xmax - Xmin and height = Ymax - Ymin.
[0056] In this embodiment, the total number of neighboring points for each target moving point is determined. If the total number is greater than a threshold, the target moving point is determined as the core point. Based on the core point and its neighboring points, a clustering rectangle representing the abnormal water mass is determined. If the neighboring points corresponding to the core point overlap, the generated clustering rectangles will also overlap. The threshold for the total number of neighboring points can be dynamically adjusted according to the size of the clustering rectangle. This application does not limit the specific values of the distance threshold and the number threshold.
[0057] The above steps perform local neighborhood analysis on the target moving points in the differential image, select core points with a sufficient number of neighboring points, and construct clustering rectangles based on the core points. This effectively aggregates discrete moving points into continuous moving regions, effectively distinguishing between real abnormal water masses and random noise, thereby more accurately locating the overall outline and range of abnormal water masses.
[0058] In some embodiments of this application, step 105, determining the shape features of the clustering rectangle, may specifically include the following steps: Sub-step S21: For any clustering rectangle, calculate the height, width, and number of moving points within the clustering rectangle; Sub-step S22: Based on the height and width of the clustering rectangle, calculate the first ratio of height to width, the second ratio of width to height, the area and perimeter of the clustering rectangle; Sub-step S23: Determine the larger value between the first ratio and the second ratio as the aspect ratio of the clustering rectangle; Sub-step S24: The ratio between the square values of the area and the perimeter is determined as the compactness of the moving points within the clustering rectangle; Sub-step S25: The ratio of the number of moving points to the area within the clustering rectangle is determined as the density of moving points within the clustering rectangle.
[0059] In this embodiment, the shape features of the clustering rectangle are determined. These features include the aspect ratio of the clustering rectangle, and the compactness and density of the moving points within the rectangle. For any clustering rectangle, the height, width, and number of moving points within the rectangle are calculated. This is achieved by identifying the coordinates of each vertex of the rectangle, calculating the distance between points to obtain the height and width, counting the number of moving points using a counter, and calculating the first ratio of height to width, the second ratio of width to height, the area, and the perimeter of the rectangle based on its height and width. These details are not elaborated upon here.
[0060] As a specific implementation of this application, for any clustering rectangle C, the larger value between the first ratio and the second ratio is determined as the aspect ratio of the clustering rectangle, and the corresponding aspect ratio calculation formula (1) is: (1) Where aspectRatio(C) refers to the aspect ratio of the clustering rectangle C, width refers to the width of the clustering rectangle C, and height refers to the height of the clustering rectangle C. The aspect ratio is calculated as the ratio of the longest side to the shortest side in the clustering rectangle C.
[0061] For any clustering rectangle C, the ratio between the squares of the area and the perimeter is determined as the compactness of the moving points within the clustering rectangle. The formula (2) for calculating the compactness of the moving points within the clustering rectangle C is as follows: (2) Wherein, compactness(C) refers to the compactness of moving points within the clustering rectangle C, width refers to the width of the clustering rectangle C, height refers to the height of the clustering rectangle C, and compactness(C) is the ratio of the area of the clustering rectangle C to the square of its perimeter.
[0062] Furthermore, compactness can also be calculated using the Graham scan algorithm to determine the convex hull area of moving points within the clustering rectangle, and the ratio of the convex hull area to the area of the clustering rectangle to determine compactness. For any clustering rectangle C, the ratio of the number of moving points within the clustering rectangle to the area is determined as the density of moving points within the clustering rectangle. The formula (3) for calculating the density of moving points within the clustering rectangle is as follows: (3) Where density(C) refers to the density of moving points within the clustering rectangle C, |C| refers to the number of moving points within the clustering rectangle C, bboxArea(C) is the area of the clustering rectangle C, and bboxArea(C) is the product of the width and height of the clustering rectangle C.
[0063] The above steps calculate multiple shape features of the clustering rectangle, namely geometric and density features such as aspect ratio, compactness and point density, and quantitatively evaluate the morphological features of each candidate anomalous region from multiple dimensions such as shape regularity, spatial concentration and internal filling degree. This facilitates the effective screening of regions that conform to the physical characteristics of real anomalous water masses in the subsequent process, thereby improving the accuracy of identification.
[0064] In some embodiments of this application, step 105, determining the basic shape score of the clustering rectangle based on shape features, may specifically include the following steps: Sub-step S31: The reciprocal of the larger value between the aspect ratio and the preset baseline value is determined as the aspect ratio fraction of the clustering rectangle. Sub-step S32: The smaller value between the compactness multiplied by the first factor and the baseline value is determined as the compactness score of the clustering rectangle. Sub-step S33: The smaller value between the density multiplied by the second factor and the baseline value is determined as the density fraction of the clustering rectangle; Sub-step S34 determines the average of the aspect ratio score, compactness score, and density score as the basic shape score of the clustering rectangle.
[0065] In this embodiment, the basic shape score of the clustering rectangle is determined based on shape features, including the aspect ratio of the clustering rectangle, the compactness and density of moving points within the clustering rectangle, and the aspect ratio score, compactness score, and density score are calculated accordingly. Finally, the average of the aspect ratio score, compactness score, and density score is determined as the basic shape score of the clustering rectangle.
[0066] In this embodiment, the reciprocal of the larger value between the aspect ratio and the preset baseline value is determined as the aspect ratio fraction of the clustering rectangle. The preset baseline value can be 1. The formula (4) for calculating the aspect ratio fraction is: aspectRatioScore=1 / Math.max(1, aspectRatio)(4) Here, `aspectRatio` refers to the aspect ratio of the clustering rectangle, `Math.max()` returns the maximum value, and `aspectRatioScore` is the score for the aspect ratio. A larger aspect ratio indicates a more elongated and slender clustering rectangle, and a lower aspect ratio score.
[0067] In this embodiment, the smaller value between the compactness multiplied by the first factor and the baseline value is determined as the compactness score of the clustered rectangle. The formula (5) for calculating the compactness score is as follows: compactnessScore=Math.min(compactness ,1)(5) Here, compactness refers to the compactness of moving points within the clustering rectangle, Math.min() means taking the minimum value, compactnessScore is the compactness score of moving points within the clustering rectangle, and 'a' is the first multiple. In the formula, the first multiple 'a' can be 10. After multiplying the compactness by 10, the minimum value between the compactness multiplied by 10 and 1 is taken, limiting the maximum value of the compactness score to 1, thus amplifying the impact of compactness on the total score.
[0068] In this embodiment, the smaller value between the density multiplied by the second factor and the baseline value is determined as the density score of the clustering rectangle. The formula (6) for calculating the density score is as follows: densityScore = Math.min(density) ,1)(6) Here, density refers to the density of moving points within the clustering rectangle, Math.min() takes the minimum value, densityScore is the density score of the clustering rectangle, and b is a multiple of 2. In the formula, the multiple b can be 2. After multiplying the density by 2, the minimum value between the density multiplied by 2 and 1 is taken, and the density score is limited to a maximum value of 1 for simplified density normalization.
[0069] In this embodiment, the average of the aspect ratio score, compactness score, and density score is determined as the basic shape score of the clustering rectangle. The calculation formula (7) for the basic shape score of the clustering rectangle is as follows: baseScore=(aspectRatioScore+compactnessScore+densityScore) / 3(7) Among them, aspectRatioScore is the aspect ratio score of the clustering rectangle, compactnessScore is the compactness score of the clustering rectangle, densityScore is the density score of the clustering rectangle, and baseScore is the basic shape score of the clustering rectangle.
[0070] Among them, the values of the aspect ratio score, compactness score and density score mentioned above are between 0 and 1.
[0071] The above steps quantify the indicators of multiple key shape features of the clustering rectangle, namely aspect ratio, compactness, and density, into a unified score. By combining these scores, a basic shape score is formed, thereby transforming the complex morphological evaluation into a single quantifiable and comparable standard. This provides an accurate and objective decision-making basis for the subsequent screening of candidate regions whose shape, structure, and density are more consistent with real anomalous water masses.
[0072] In some embodiments of this application, step 106, filtering the clustering rectangles of the initial identification map using basic shape scores to obtain and display the target identification map for the abnormal water clumps, may specifically include the following steps: Sub-step S41: For any clustering rectangle in the initial recognition image, compare the basic shape score of the clustering rectangle with a preset score threshold. Sub-step S42: If the basic shape score is less than the score threshold, the clustering rectangle is determined to be an invalid clustering rectangle. Sub-step S43: If the basic shape score is greater than or equal to the score threshold, then the clustering rectangle is determined to be a valid clustering rectangle. Sub-step S44: Remove invalid clustering rectangles from the initial identification map to obtain and display the target identification map for the abnormal water mass.
[0073] The above steps automatically filter and remove invalid regions whose shape, compactness, or density does not conform to the characteristics of real abnormal water masses by comparing the quantified basic shape score with a preset score threshold, thereby refining the difference map and finally generating a target recognition map that only contains high-confidence abnormal water mass regions, and displaying the target recognition map of abnormal water masses, which significantly improves the accuracy and reliability of the detection results.
[0074] In this embodiment, when identifying abnormal water masses, the moving points are first clustered, and then several clustered rectangles are obtained based on the clustering results. By identifying the shape, compactness, or density of the clustered rectangles, the clustered rectangles that need to be retained are selected. However, when the initial identification image and the target identification image are actually displayed, they do not show the clustered rectangles, but rather the moving points actually contained in the clustered rectangles. Considering that common types of abnormal water masses include polluted water masses, algal water masses, suspended matter water masses, and abnormal turbidity / color water masses, and that common algal water masses such as algal blooms or scum layers formed by the large-scale proliferation of cyanobacteria and green algae, this application also includes the identification of target objects. Target objects can be polluted water masses, algal aggregates, suspended sediment, organic / inorganic debris, and complexes of these substances.
[0075] In some embodiments of this application, after filtering the clustering rectangles of the initial identification map by basic shape scores to obtain and display the target identification map of the abnormal water mass in step 106, it may further include: The target recognition map corresponds to the RGB value of each pixel in the original image; Extract the R, G, and B channel values from the RGB values; Based on the R channel values, G channel values, and B channel values, determine the actual proportion of the target object in the corresponding channel values of the RGB values; If the actual proportion is greater than the second dynamic threshold, then the pixel is determined to be a feature point of the target object.
[0076] In this embodiment, we take a polluted water mass as an example. Since the polluted water mass appears as blackish-gray in the image, the G value has a higher proportion in its corresponding RGB values. The pixel value of a pixel in the target recognition image represents the pixel difference between the current image and the reference image at the same coordinate point. Therefore, the RGB value of each pixel in the target recognition image is the pixel difference between the pixel and the current image and the reference image at the same coordinate point. For example, if the RGB value of pixel A in the target recognition image is (32, 31, 36), then the R channel value is 32, the G channel value is 31, and the B channel value is 36. The sum of all channel values and the typical RGB proportions are R channel 32 / 30≈1.07=107%, G channel 31 / 30≈1.03=103%, and B channel 36 / 35≈1.03=103%, respectively. If the target threshold is set to 90% to 120%, since 107% and 103% are greater than 90% and less than 120%, pixel A is determined to be a polluted water mass feature point.
[0077] In the above steps, by analyzing the RGB color channel information of each pixel in the target recognition image, the proportion of all channel values of the target object to the proportion of all channel values of the typical RGB values is determined. For example, if the target object is a polluted water mass, the proportions of the red, green, and blue channels are calculated. This allows for the accurate identification of pixels with significant spectral characteristics of the target object, thereby effectively filtering out target object feature points indicating target object enrichment from abnormal water mass regions.
[0078] In some embodiments of this application, after determining that a pixel is a feature point of a target object, the method may further include: For any clustered rectangle in the target recognition image, identify the number and proportion of feature points of the target object within the clustered rectangle; The total similarity of the target objects in the clustered rectangles is determined by comparing the proportions and the basic shape scores of the clustered rectangles. The ratio of the sum of the similarities of the target objects to the number of objects is determined as the average similarity of the target objects in the clustering rectangles; The product of the proportion and the average similarity of the target objects is determined as the target object feature score of the clustering rectangle; Based on the basic shape score of the clustered rectangle and the target feature score, update the target recognition map for abnormal water clumps.
[0079] In this embodiment, the target recognition map can be further optimized based on the identified target feature points. During optimization, firstly, the number of moving points and the number of target feature points within each clustered rectangle in the target recognition map are identified. Specifically, this application sets up a `points` array, storing the moving point data within each clustered rectangle; one `points` array corresponds to one clustered rectangle. Then, for any given clustered rectangle to be processed, the proportion of target feature points within that rectangle is calculated using the number of moving points and the number of target feature points. This proportion is obtained using formula (8): abPointRatio=abPointCount / points.length(8) Where abPointCount refers to the number of target feature points within the clustering rectangle to be processed, points.length refers to the number of moving points within the clustering rectangle to be processed, and abPointRatio refers to the proportion of target feature points within the clustering rectangle to be processed.
[0080] Compare the proportion of target object feature points within the clustering rectangle to be processed with the corresponding basic shape score. If the proportion of target object feature points is greater than the corresponding basic shape score, then the proportion of target object feature points is used as the sum of target object similarities within the clustering rectangle to be processed. If the proportion of target object feature points is less than the corresponding basic shape score, then the corresponding basic shape score is used as the sum of target object similarities within the clustering rectangle to be processed. If the two are equal, then any choice is made. Then calculate the average target object similarity within the clustering rectangle to be processed. Taking polluted water masses as an example, the average target object similarity within the clustering rectangle to be processed is shown in formula (9): avgAbSimilarity=totalAbSimilarity / abPointCount(9) Wherein, avgAbSimilarity refers to the average similarity of target objects within the clustering rectangle to be processed, totalAbSimilarity refers to the total similarity of target objects within the clustering rectangle to be processed, and abPointCount refers to the number of feature points of target objects within the clustering rectangle to be processed, and its value is not 0.
[0081] Based on the average similarity of the target objects within the cluster bounding box and the proportion of the target object feature points, the feature score of the target objects within the cluster bounding box can be calculated, as shown in formula (10): (10) Where abPointRatio is the proportion of target feature points within the clustering rectangle to be processed, avgAbSimilarity is the average target similarity within the clustering rectangle to be processed, and abAlgaeScore refers to the target feature score within the clustering rectangle to be processed.
[0082] After obtaining the feature scores of the target objects within the clustering rectangle, they can be weighted with the basic shape scores to obtain a final comprehensive score. In this embodiment, weights are pre-set for the feature scores of the target objects, for example, abAlgaeWeight=1.5. The weight values can be adjusted according to the situation. The comprehensive score is expressed by the following formula (11): (11) Among them, FinalScore refers to the overall score of the clustered rectangles in the target recognition map, baseScore refers to the basic shape score of the clustered rectangles in the target recognition map, abAlgaeScore refers to the target feature score of the clustered rectangles in the target recognition map, and abAlgaeWeight refers to the target feature score weight.
[0083] Based on this final score, the clustered bounding boxes within the target recognition map can be further optimized. Clustered bounding boxes with final scores greater than a certain threshold are selected and retained. Then, the motion points contained within the retained clustered bounding boxes are displayed on the target recognition map, as shown below. Figure 5 The diagram illustrates a target recognition map in an abnormal water mass recognition method provided in this application, as shown below. Figure 5 As shown, the motion points contained in the retained cluster rectangles are displayed on the target recognition map in the form of a heat map, and the red area represents the motion points contained in the retained cluster rectangles.
[0084] The above steps calculate a target feature score by comprehensively considering the spatial distribution (proportion and quantity) of target feature points and the intensity (average similarity) of target signals within the region. This score is then combined with the basic shape score previously used to measure morphology, ultimately achieving a quantitative assessment of the enrichment degree of target objects within the abnormal water mass and updating the identification map. This improves the detection result from the presence of abnormal water masses to the presence of abnormal water masses with target object features.
[0085] In some embodiments of this application, step 102, generating a difference image between the reference image and the current image, may specifically include the following steps: Sub-step S51: Perform grayscale conversion and edge detection on the reference image and the current image to generate their respective corresponding edge images; Sub-step S52: Extract feature points from the corresponding edge images and match the feature points to obtain matching feature point pairs; Sub-step S53: Filter the matching feature point pairs to obtain valid matching feature point pairs, and determine the spatial transformation parameters of the reference image and the current image based on the valid matching feature point pairs. Sub-step S54: Align the current image with the reference image based on the spatial transformation parameters; Sub-step S55: Calculate the pixel difference between the aligned current image and the reference image at the same coordinate point; Sub-step S56: Based on the pixel difference, generate a difference image between the reference image and the current image.
[0086] In this embodiment, the current image is first aligned with the reference image. After alignment, the pixel difference between the aligned current image and the reference image at the same coordinate point is calculated. A difference image is generated based on the pixel difference. The value of each pixel in the difference image is the pixel difference between the current image and the reference image at the same coordinate point. A larger pixel difference indicates that the pixel area is more likely to contain abnormal water masses, while a smaller pixel difference indicates that the pixel area is less likely to contain abnormal water masses. In this embodiment, grayscale conversion and edge detection are performed on the reference image and the current image to generate corresponding edge images. Feature points are extracted from the corresponding edge images, and these feature points are matched to obtain matching feature point pairs. These matching feature point pairs are then filtered to obtain valid matching feature point pairs. Based on the valid matching feature point pairs, spatial transformation parameters for the reference image and the current image are determined. Based on these spatial transformation parameters, the current image is aligned with the reference image.
[0087] In the above steps, to align the current image with the reference image, grayscale conversion is first performed on both the reference and current images. This requires obtaining the RGB values of the pixels in both images, and then using a weighted average method for grayscale conversion. For example, the weight coefficient for the green channel is 0.587, the weight coefficient for the red channel is 0.299, and the weight coefficient for the blue channel is 0.114. For instance, if the RGB values of a pixel in the reference image are R=30, G=30, B=35, after grayscale conversion using the set weight coefficients, the red channel contributes 30 × 0.299 = 8.97, the green channel contributes 30 × 0.587 = 17.61, and the blue channel contributes 35 × 0.114 = 3.99, resulting in a grayscale value of 8.97 + 17.61 + 3.99 = 30.57.
[0088] Next, edge detection is performed on the grayscale-converted reference image and the current image to obtain their respective edge images. Feature points are extracted from these edge images and feature point matching is performed to obtain several matching feature point pairs. Since there may be abnormal matches among the matching feature point pairs, they need to be filtered. During filtering, the offset between the two matching feature points in each matching feature point pair can be calculated first. If the offset is greater than a specified value, the matching feature point pair is determined to be an abnormal match and is deleted to ensure that the filtered matching feature point pairs are all valid matching feature point pairs. At this time, the spatial transformation parameters of the valid matching feature point pairs are calculated, and the average value of the spatial transformation parameters of the valid matching feature point pairs is used as the spatial transformation parameters of the reference image and the current image. Based on the spatial transformation parameters, the current image is aligned with the reference image. The spatial transformation parameters may include planar offset, rotation angle, and scaling factor, which will not be elaborated here.
[0089] The above steps involve converting the baseline image and the current image to grayscale, performing edge detection, extracting and matching feature points, and calculating spatial transformation parameters based on the selected effective matching points. This achieves high-precision automatic alignment of the two images, effectively eliminating spatial inconsistencies caused by shooting angle, position offset, etc., providing accurate and reliable pixel-level correspondence for subsequent difference detection, and significantly improving the robustness and accuracy of abnormal water mass identification.
[0090] Reference Figure 6 , Figure 6 This application provides a structural block diagram of an abnormal water mass identification device, which may include: The first acquisition module 201 is used to acquire a reference image of the water area to be detected and a real-time captured current status image; The first generation module 202 is used to generate a difference image between the reference image and the current image; The first identification module 203 is used to identify moving points in the difference image and determine clustering rectangles representing abnormal water masses based on the moving points. The second generation module 204 is used to generate an initial identification map of the abnormal water mass using the reference image and the clustering rectangle; The second identification module 205 is used to determine the shape features of the clustering rectangle and determine the basic shape score of the clustering rectangle based on the shape features; the shape features include the aspect ratio of the clustering rectangle, the compactness and density of the moving points within the clustering rectangle, and the basic shape score is used to characterize the degree of matching between the clustering rectangle and the anomalous water mass; The result display module 206 is used to filter the clustering rectangles of the initial recognition map through the basic shape score, and to obtain and display the target recognition map of the abnormal water mass.
[0091] Optionally, the first identification module 203 includes: The first determining submodule is used to determine that any pixel in the difference image is a moving point in the difference image if the pixel difference value corresponding to the pixel is greater than a first dynamic threshold; the moving point includes target moving points and non-target moving points. The first identification submodule is used to identify the neighboring points of any target moving point in the difference image; wherein the Euclidean distance between the neighboring points of the target moving point and the target moving point is less than a distance threshold. The second determining submodule is used to determine the total number of neighboring points of each target motion point; The third determining submodule is used to determine the target movement point as the core point if the total number is greater than the number threshold. The fourth determination submodule is used to cluster the core point and its neighboring points to obtain a clustering rectangle for characterizing the abnormal water mass.
[0092] Optionally, the second identification module 205 includes: The first calculation submodule is used to calculate the height, width, and number of moving points within any clustering rectangle. The second calculation submodule is used to calculate the first ratio of height to width, the second ratio of width to height, the area and perimeter of the clustering rectangle based on the height and width of the clustering rectangle. The fifth determining submodule is used to determine the larger value between the first ratio and the second ratio as the aspect ratio of the clustering rectangle; The sixth determining submodule is used to determine the ratio between the square values of the area and the perimeter as the compactness of the moving points within the clustering rectangle; The seventh determining submodule is used to determine the density of moving points within the clustering rectangle as the ratio of the number of moving points to the area. The aspect ratio of the moving points within the clustering rectangle is characterized by the following formula:
[0093] aspectRatio(C) is the aspect ratio of the clustering rectangle C, where width is the width of the clustering rectangle C and height is the height of the clustering rectangle C. The compactness of the moving points within the clustering rectangle is characterized by the following formula:
[0094] compactness(C) is the compactness of the moving points within the clustering rectangle C, width is the width of the clustering rectangle C, and height is the height of the clustering rectangle C; The density of moving points within the clustering rectangle is characterized by the following formula:
[0095] density(C) is the density of moving points within the clustering rectangle C, |C| is the number of moving points within the clustering rectangle C, and bboxArea(C) is the area of the clustering rectangle C.
[0096] Optionally, the second identification module 205 includes: The third calculation submodule is used to determine the reciprocal of the larger value between the aspect ratio and the preset benchmark value as the aspect ratio fraction of the clustering rectangle; The fourth calculation submodule is used to determine the smaller value between the compactness multiplied by the first factor and the benchmark value as the compactness score of the clustering rectangle; The fifth calculation submodule is used to determine the smaller value between the density multiplied by the second factor and the benchmark value as the density score of the clustering rectangle; The sixth calculation submodule is used to determine the average of the aspect ratio score, compactness score, and density score as the basic shape score of the clustering rectangle; The aspect ratio fraction is represented by the following formula:
[0097] aspectRatioScore is the aspect ratio score of the cluster rectangle, aspectRatio is the aspect ratio of the cluster rectangle, and Math.max() is to take the maximum value. The compactness score is represented by the following formula:
[0098] compactnessScore is the compactness score of the clustering rectangle, compactness is the compactness of the moving points within the clustering rectangle, 'a' is the first multiple, and Math.min() is to take the minimum value; The density fraction is characterized by the following formula:
[0099] densityScore is the density score of the clustering rectangle, density is the density of moving points within the clustering rectangle, b is a multiple of the second value, and Math.min() is used to take the minimum value. The basic shape fraction is represented by the following formula:
[0100] baseScore is the basic shape score of the clustering rectangle, aspectRatioScore is the aspect ratio score of the clustering rectangle, compactnessScore is the compactness score of the clustering rectangle, and densityScore is the density score of the clustering rectangle.
[0101] Optionally, the result display module 206 includes: The comparison submodule is used to compare the basic shape score of any clustering rectangle in the initial recognition image with a preset score threshold. The first determination submodule is used to determine the clustering rectangle as an invalid clustering rectangle if the basic shape score is less than the score threshold. The second determination submodule is used to determine the clustering rectangle as a valid clustering rectangle if the basic shape score is greater than or equal to the score threshold. The elimination submodule is used to eliminate invalid clustering rectangles in the initial identification map to obtain and display the target identification map of the abnormal water mass.
[0102] Optionally, the device further includes: The third recognition module is used to recognize the RGB value of each pixel in the original image corresponding to the target recognition map; The extraction module is used to extract the R channel values, G channel values, and B channel values from the RGB values; The proportion determination module is used to determine the actual proportion of the target object in the corresponding channel value of the RGB value based on the R channel value, G channel value and B channel value; The target determination module is used to determine that the pixel is a target feature point if the actual proportion is greater than the second dynamic threshold.
[0103] Optionally, after determining that the pixel is a feature point of the target object, the method further includes: The fourth identification module is used to identify the number and proportion of target feature points within any clustered rectangle in the target identification image; The comparison module is used to compare the proportion with the basic shape score of the clustering rectangle to determine the total similarity of the target objects in the clustering rectangle; A similarity determination module is used to determine the average target object similarity of the clustering rectangle by the ratio of the sum of the target object similarities to the number. The score determination module is used to determine the target object feature score of the clustering rectangle by multiplying the proportion by the average target object similarity. The update module is used to update the target recognition map of the abnormal water mass based on the basic shape score and target feature score of the clustered rectangle; The update module is implemented using the following formula:
[0104] FinalScore is the overall score of the clustered rectangles, baseScore is the basic shape score of the clustered rectangles, abAlgaeScore is the target feature score of the clustered rectangles, and abAlgaeWeight is the weight of the target feature score.
[0105] Optionally, the first generation module 202 includes: The first generation submodule is used to perform grayscale conversion and edge detection on the reference image and the current image to generate corresponding edge images; The extraction submodule is used to extract feature points from their respective edge images and match the feature points to obtain matching feature point pairs. The filtering submodule is used to filter the matching feature point pairs to obtain valid matching feature point pairs, and to determine the spatial transformation parameters of the reference image and the current image based on the valid matching feature point pairs. The alignment submodule is used to align the current image with the reference image based on the spatial transformation parameters. The seventh calculation submodule is used to calculate the pixel difference between the aligned current image and the reference image at the same coordinate point; The second generation submodule is used to generate a difference image between the reference image and the current image based on the pixel difference.
[0106] The abnormal water mass identification device provided in this application embodiment can realize the various processes implemented by the abnormal water mass identification method in the above embodiments of this application. To avoid repetition, it will not be described again here.
[0107] This application also provides an electronic device, such as Figure 7 As shown, it includes a processor 301, a communication interface 302, a memory 303, and a communication bus 304, wherein the processor 301, the communication interface 302, and the memory 303 communicate with each other through the communication bus 304. Memory 303 is used to store computer programs; When processor 301 executes a program stored in memory 303, it performs the following steps: Acquire baseline images and real-time current status images of the water area to be detected; Generate a difference image between the reference image and the current image; Identify moving points in the difference image, and determine clustering rectangles representing abnormal water masses based on the moving points; An initial identification map of the abnormal water mass is generated using the baseline image and the clustering bounding box. The shape features of the clustering rectangle are determined, and the basic shape score of the clustering rectangle is determined based on the shape features; the shape features include the aspect ratio of the clustering rectangle, the compactness and density of moving points within the clustering rectangle, and the basic shape score is used to characterize the degree of matching between the clustering rectangle and the anomalous water mass; The clustering rectangles of the initial identification map are filtered using the basic shape scores to obtain and display the target identification map of the abnormal water mass.
[0108] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into a physical address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0109] The communication interface is used for communication between the aforementioned terminal and other devices.
[0110] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0111] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0112] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the abnormal water mass identification method as described in any of the above embodiments of this application.
[0113] This application also provides a computer program product, including a computer program / instructions, which, when executed by a processor, implement the steps in the abnormal water mass identification method as described in any of the above embodiments of this application.
[0114] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).
[0115] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0116] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the apparatus embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0117] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.
Claims
1. A method for identifying abnormal water masses, characterized in that, The method includes: Acquire baseline images and real-time current status images of the water area to be detected; Generate a difference image between the reference image and the current image; Identify moving points in the difference image, and determine clustering rectangles representing abnormal water masses based on the moving points; An initial identification map of the abnormal water mass is generated using the baseline image and the clustering bounding box. The shape features of the clustering rectangle are determined, and the basic shape score of the clustering rectangle is determined based on the shape features; the shape features include the aspect ratio of the clustering rectangle, the compactness and density of moving points within the clustering rectangle, and the basic shape score is used to characterize the degree of matching between the clustering rectangle and the anomalous water mass; The clustering rectangles of the initial identification map are filtered using the basic shape scores to obtain and display the target identification map of the abnormal water mass.
2. The method according to claim 1, characterized in that, The step of identifying moving points in the difference image and determining clustering bounding boxes representing abnormal water masses based on the moving points includes: For any pixel in the difference image, if the pixel difference corresponding to the pixel is greater than a first dynamic threshold, then the pixel is determined to be a moving point in the difference image; the moving point includes target moving points and non-target moving points. For any target moving point in the difference image, identify the neighboring points of the target moving point; wherein the Euclidean distance between the neighboring points of the target moving point and the target moving point is less than a distance threshold; Determine the total number of neighboring points for each target motion point; If the total number is greater than the number threshold, then the target movement point is determined to be the core point; Clustering the core point and its neighboring points yields clustering rectangles used to characterize abnormal water masses.
3. The method according to claim 1, characterized in that, Determining the shape features of the clustering rectangle includes: For any clustering rectangle, calculate the height, width, and number of moving points within the clustering rectangle; Based on the height and width of the clustering rectangle, calculate the first ratio of height to width, the second ratio of width to height, the area and perimeter of the clustering rectangle; The larger value between the first ratio and the second ratio is determined as the aspect ratio of the clustering rectangle; The ratio between the square values of the area and the perimeter is determined as the compactness of the moving points within the clustering rectangle; The ratio of the number of moving points within the clustering rectangle to the area is determined as the density of moving points within the clustering rectangle. The aspect ratio of the moving points within the clustering rectangle is characterized by the following formula: aspectRatio(C) is the aspect ratio of the clustering rectangle C, where width is the width of the clustering rectangle C and height is the height of the clustering rectangle C. The compactness of the moving points within the clustering rectangle is characterized by the following formula: compactness(C) is the compactness of the moving points within the clustering rectangle C, width is the width of the clustering rectangle C, and height is the height of the clustering rectangle C; The density of moving points within the clustering rectangle is characterized by the following formula: density(C) is the density of moving points within the clustering rectangle C, |C| is the number of moving points within the clustering rectangle C, and bboxArea(C) is the area of the clustering rectangle C.
4. The method according to claim 1 or 3, characterized in that, The determination of the basic shape score of the clustering rectangle based on the shape features includes: The reciprocal of the larger value between the aspect ratio and the preset benchmark value is determined as the aspect ratio fraction of the clustering rectangle. The smaller value between the compactness multiplied by the first factor and the benchmark value is determined as the compactness score of the clustering rectangle. The smaller value between the density multiplied by the second factor and the baseline value is determined as the density fraction of the clustering rectangle; The average of the aspect ratio score, compactness score, and density score is determined as the basic shape score of the clustering rectangle. The aspect ratio fraction is represented by the following formula: aspectRatioScore is the aspect ratio score of the cluster rectangle, aspectRatio is the aspect ratio of the cluster rectangle, and Math.max() is to take the maximum value. The compactness score is represented by the following formula: compactnessScore is the compactness score of the clustering rectangle, compactness is the compactness of the moving points within the clustering rectangle, 'a' is the first multiple, and Math.min() is to take the minimum value; The density fraction is characterized by the following formula: densityScore is the density score of the clustering rectangle, density is the density of moving points within the clustering rectangle, b is a multiple of the second value, and Math.min() is used to take the minimum value. The basic shape fraction is represented by the following formula: baseScore is the basic shape score of the clustering rectangle, aspectRatioScore is the aspect ratio score of the clustering rectangle, compactnessScore is the compactness score of the clustering rectangle, and densityScore is the density score of the clustering rectangle.
5. The method according to claim 1, characterized in that, The step of filtering the clustering rectangles of the initial recognition map using the basic shape scores to obtain and display the target recognition map for the abnormal water mass includes: For any clustering rectangle in the initial recognition image, the basic shape score of the clustering rectangle is compared with a preset score threshold; If the basic shape score is less than the score threshold, the clustering rectangle is determined to be an invalid clustering rectangle. If the basic shape score is greater than or equal to the score threshold, then the clustering rectangle is determined to be a valid clustering rectangle; Invalid clustering rectangles in the initial identification map are removed to obtain and display the target identification map for the abnormal water mass.
6. The method according to claim 1, characterized in that, After filtering the clustering rectangles of the initial recognition map using the basic shape scores to obtain and display the target recognition map for the abnormal water mass, the method further includes: Identify the RGB value of each pixel in the original image corresponding to the target recognition map; Extract the R channel, G channel, and B channel values from the RGB values; Based on the R channel values, G channel values, and B channel values, determine the actual proportion of the target object's corresponding channel values in the RGB values; If the actual proportion is greater than the second dynamic threshold, then the pixel is determined to be a feature point of the target object.
7. The method according to claim 6, characterized in that, After determining that the pixel is a feature point of the target object, the method further includes: For any clustered rectangle in the target recognition image, identify the number and proportion of target feature points within the clustered rectangle; The percentage and the basic shape score of the clustering rectangle are compared to determine the total similarity of the target objects in the clustering rectangle; The ratio of the sum of the similarities of the target objects to the number is determined as the average similarity of the target objects in the clustering rectangle; The product of the percentage and the average target object similarity is determined as the target object feature score of the clustering rectangle; Based on the basic shape score and target feature score of the clustered rectangle, update the target recognition map for the abnormal water mass; The update of the target recognition map for abnormal water masses based on the basic shape score and target feature score of the clustered rectangles is achieved by the following formula: FinalScore is the overall score of the clustered rectangles, baseScore is the basic shape score of the clustered rectangles, abAlgaeScore is the target feature score of the clustered rectangles, and abAlgaeWeight is the weight of the target feature score.
8. The method according to claim 1, characterized in that, The generation of the difference image between the reference image and the current image includes: The reference image and the current image are subjected to grayscale conversion and edge detection to generate corresponding edge images. Feature points are extracted from their respective edge images, and the feature points are matched to obtain matching feature point pairs; The matching feature point pairs are filtered to obtain valid matching feature point pairs. Based on the valid matching feature point pairs, the spatial transformation parameters of the reference image and the current image are determined. Based on the spatial transformation parameters, the current image is aligned with the reference image; Calculate the pixel difference between the aligned current image and the reference image at the same coordinate point; Based on the pixel difference, a difference image is generated between the reference image and the current image.
9. An electronic device, characterized in that, include: A transceiver, a memory, a processor, and a program stored in the memory and executable on the processor; The processor is configured to read a program from the memory to implement the steps in the abnormal water mass identification method as described in any one of claims 1-8.
10. A readable storage medium for storing a program, characterized in that, When the stored program is executed by the processor, it implements the steps of the abnormal water mass identification method as described in any one of claims 1-8.
Citation Information
Patent Citations
Moving target detection method, electronic device and storage medium
CN109581378A
Abnormal water mass identification method and system, storage medium and electronic equipment
CN121884109A
