Methods and systems for water area extraction in complex scenarios
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-28
- Publication Date
- 2026-08-14
AI Technical Summary
[0005]1、由于测试场景环境的复杂多变,会影响水体区域分割的准确性,当训练的水体分割数据集达到要求时,在实际测试过程中除了获得真实的水体区域外,还会出现额外非水体区域的轮廓,在使用分割的水体区域进行业务判断时,会产生一定误差
[0073]1、本发明提出的水体轮廓后处理算法,可用于任何水体分割模型结果做后处理,特别是复杂开放场景下;由于水体分割模型训练数据集与测试场景数据分布不同,因此会产生额外小轮廓或者非连续的线段,使用本发明提供的轮廓后处理方法则能提高水体轮廓检测的准确率。
Smart Images

Figure CN118072226B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of water body recognition technology and image processing technology, specifically to a method and system for extracting water body regions in complex scenarios. Background Technology
[0002] To collect statistical information about the Earth's surface, water area identification is typically applied to remote sensing images covering a large geographical area. However, with technological advancements and the rapid development of video surveillance systems, the application scenarios for water area identification are gradually increasing. Therefore, it is necessary to utilize continuous images acquired via remote video for real-time and accurate water area delineation.
[0003] Deep learning-based water region segmentation algorithms typically train convolutional neural network models using manually labeled datasets. Once the trained model achieves reliable accuracy, it can be used to segment water regions in test scenarios. Although deep learning algorithms have powerful generalization capabilities, the lack of training datasets, the complexity and variability of the environment, and the influence of video quality can all interfere with the accuracy of image segmentation.
[0004] In summary, existing water segmentation algorithms have the following two problems in their output:
[0005] 1. Due to the complexity and variability of the test environment, the accuracy of water body segmentation will be affected. When the training water body segmentation dataset meets the requirements, in the actual test process, in addition to obtaining the real water body area, the outline of additional non-water body area will also appear. When using the segmented water body area for business judgment, a certain error will occur.
[0006] 2. When the outline of a water body is composed of a large number of discontinuous line segments, it is impossible to obtain a complete outline of the water body edge for subsequent business judgment.
[0007] Chinese patent document CN115482410A discloses a method and apparatus for detecting water level gauges, belonging to the field of artificial intelligence technology. The method includes the following steps: collecting water level gauge image data; processing the image data to obtain processed water level gauge data; constructing a water level gauge detection model based on the processed water level gauge data; training the water level gauge detection model and saving the model parameters; receiving an input water level gauge image to be detected; calculating the position of the water level gauge according to the water level gauge detection model; and outputting the detection result. This patent document uses a convolutional neural network as the water level detection model. In the model classification stage, it combines Bézier curves to improve the loss function and, unlike the segmentation model, performs multiple sampling operations, thus improving the model's inference speed. However, this algorithm is only suitable for water level detection in specific simple scenarios, and the results will be affected when the test scenario is changed. The contour post-processing algorithm of this invention can be used to post-process the water level output of the above algorithm. When additional small contours or discontinuous line segments are detected, the water body contour post-processing algorithm can improve the accuracy of water level detection.
[0008] Chinese patent document CN117036805A discloses a method, apparatus, electronic device, and medium for extracting water bodies from remote sensing images based on CNN-□Transformer. The method includes: inputting the remote sensing image to be extracted into a pre-trained deep learning model based on CNN-□Transformer; performing feature encoding on the remote sensing image using CNN-based multi-scale feature extraction technology to obtain multi-scale encoded features of the remote sensing image; processing the multi-scale encoded features based on the Unfold-□Transformer-□Fold structure of MobileViT to obtain global encoded features of the remote sensing image; decoding the global encoded features to obtain decoded features; fusing multi-scale encoded features and decoded features of the same size in pairs based on a coordinated attention mechanism to obtain fused features; and decoding the fused features to obtain water body regions in the remote sensing image. This patent document improves the encoding and decoding network by combining CNN and Transformer. It first extracts global encoding features from remote sensing images, and then fuses multi-scale encoding and decoding features of the same size based on an attention mechanism. In summary, it modifies the network structure but doesn't add any additional post-processing, still resulting in contour anomalies. In contrast, the contour post-processing algorithm of this invention can be embedded into the output of the aforementioned neural network for post-processing of abnormal contours, without requiring additional GPU resources, especially in open scenes, and without the need for additional model training. This reduces the consumption of human and financial resources and improves the accuracy of water body contour segmentation. Summary of the Invention
[0009] To address the shortcomings of existing technologies, the purpose of this invention is to provide a method and system for extracting water areas in complex scenarios.
[0010] A method for extracting water areas in complex scenarios according to the present invention includes:
[0011] Step S1: Collect water flow data;
[0012] Step S2: Preprocess the water flow data based on the trained water body segmentation model;
[0013] Step S3: Process the water flow data based on the water body segmentation contour post-processing algorithm to obtain a closed water body contour region.
[0014] Preferably, step S1 includes using camera F j Collect water flow data to obtain video frames from each device. Where j represents the index of the camera device.
[0015] Preferably, step S2 includes the following sub-steps:
[0016] Step S2.1: Train a water segmentation model based on the existing water segmentation dataset, and segment the video frames in the test scenario. As input to the water body segmentation model, the output is a mask binary image pred; the binary image includes water body region classes and non-water body region classes;
[0017] Step S2.2: Extract the water region from the binary image pred and perform edge detection to obtain the contour set C = {C0, C1, C2, ..., C}. i}, where i represents the number of contours.
[0018] Preferably, step S3 includes the following sub-steps:
[0019] Step S3.1: Create a contour set C = {C0, C1, C2, ..., C...} i Iterate through each C in a loop. i Perform area calculation:
[0020] Area i =AR min (C i );
[0021] Among them, AR min Area represents the area of the smallest outer rectangle that gives the contour. i The contour C obtained for equivalence i The area;
[0022] Step S3.2: Calculate the number of contours with areas less than Δ (cnt) and compare it with the total number of contours:
[0023]
[0024]
[0025] Where Δ represents the set threshold, L represents the total number of contours, k is the set ratio, and key is the parameter for logical judgment;
[0026] Step S3.3: If key is True, output the contour set C and perform logical judgment for the water body contour closure algorithm; the contour set C includes discontinuous line segments and is an unclosed contour region; if key is not True, traverse the contour set and calculate the number L of each contour point set. i Maximum value in a point set and minimum value And find the difference set Re. i :
[0027]
[0028] Where len(x) is the contour point set calculation function, and a is the range 0-L. i The index;
[0029] Step S3.4: Set the α parameter for threshold filtering:
[0030]
[0031] in, This represents the index of the i-th contour in the set of contour points that satisfies the preset conditions. L represents the index of the i-th contour that satisfies the preset conditions of the difference set. max Re represents the contour with the most points in contour C. max Represents the contour with the largest difference in contour C;
[0032] Step S3.5: Find the intersection and retain the index set ind1 that satisfies the condition of the number of contour points and the difference distance.
[0033]
[0034] Step S3.6: Determine the value of ind1 to obtain the final water body region outline.
[0035] Preferably, step S3.6 includes outputting contour C if ind1 is less than 1. ind1 As the final water body contour region output by the algorithm, if ind1 is greater than or equal to 1, then from Area... i and Filter the index set to get Area ind1 and L ind1 Remove outlines that do not meet the preset conditions; for Area ind1 and L ind1 Sort the contours from largest to smallest, and check if the contour with the largest area has the largest number of contour points. If not, delete the contour with the largest number of contour points and continue iterating through L_s. ind2 This continues until the area-sorted sequence matches the point set number-sorted sequence, thus obtaining the Area. ind2 and L ind2 Where, ind2 = ind1 - ind1[0];
[0036] Using the ratio of the number of points to the area of the largest contour as a reference (std), the contours are traversed from largest to smallest to obtain the final water body region contour.
[0037] Area_s ind1 ,L_s ind1 =Sort(Area) ind1 ,L ind1 );
[0038]
[0039]
[0040] Where F(i) represents the judgment of the index condition. When the index condition is not met, the current traversal sequence in the original index set ind2 is removed, and i = 0, 1, ..., ind1; ind3 is the output index set.
[0041] A water area extraction system for complex scenarios provided by the present invention includes:
[0042] Module M1: Collects water flow data;
[0043] Module M2: Preprocesses water flow data based on the trained water body segmentation model;
[0044] Module M3: Processes water flow data based on a water body segmentation contour post-processing algorithm to obtain a closed water body contour region.
[0045] Preferably, the module M1 includes a camera-based F j Collect water flow data to obtain video frames from each device. Where j represents the index of the camera device.
[0046] Preferably, module M2 includes the following sub-modules:
[0047] Module M2.1: Trains a water segmentation model based on an existing water segmentation dataset, and segments video frames in a test scenario. As input to the water body segmentation model, the output is a mask binary image pred; the binary image includes water body region classes and non-water body region classes;
[0048] Module M2.2: Extracts the water region from the binary image pred and performs edge detection to obtain the contour set C = {C0, C1, C2, ..., C}. i}, where i represents the number of contours.
[0049] Preferably, module M3 includes the following sub-modules:
[0050] Module M3.1: Set the contour set C = {C0, C1, C2, ..., C...} i Iterate through each C in a loop. i Perform area calculation:
[0051] Area i =AR min (C i );
[0052] Among them, AR min Area represents the area of the smallest outer rectangle that gives the contour. i The contour C obtained for equivalence i The area;
[0053] Module M3.2: Calculates the number of contours with an area less than Δ (cnt) and compares it with the total number of contours.
[0054]
[0055]
[0056] Where Δ represents the set threshold, L represents the total number of contours, k is the set ratio, and key is the parameter for logical judgment;
[0057] Module M3.3: If key is True, output contour set C and perform logical judgment for the water body contour closure algorithm; the contour set C includes discontinuous line segments and is an unclosed contour region; if key is not True, traverse the contour set and calculate the number L of each contour point set. i Maximum value in a point set and minimum value And find the difference set Re. i :
[0058]
[0059] Where len(x) is the contour point set calculation function, and a is the range 0-L. i The index;
[0060] Module M3.4: Setting the α parameter for threshold filtering:
[0061]
[0062] in, This represents the index of the i-th contour in the set of contour points that satisfies the preset conditions. L represents the index of the i-th contour that satisfies the preset conditions of the difference set. max Re represents the contour with the most points in contour C. max Represents the contour with the largest difference in contour C;
[0063] Module M3.5: Find the intersection and retain the set of indices ind1 that satisfy the condition of the number of contour points and the difference distance.
[0064]
[0065] Module M3.6: Determines the value of ind1 to obtain the final water body region outline.
[0066] Preferably, module M3.6 includes outputting contour C if ind1 is less than 1. ind1 As the final water body contour region output by the algorithm, if ind1 is greater than or equal to 1, then from Area... i and Filter the index set to get Area ind1 and L ind1 Remove outlines that do not meet the preset conditions; for Area ind1 and L ind1 Sort the contours from largest to smallest, and check if the contour with the largest area has the largest number of contour points. If not, delete the contour with the largest number of contour points and continue iterating through L_s. ind2 This continues until the area-sorted sequence matches the point set number-sorted sequence, thus obtaining the Area. ind2 and L ind2 Where, ind2 = ind1 - ind1[0];
[0067] Using the ratio of the number of points to the area of the largest contour as a reference (std), the contours are traversed from largest to smallest to obtain the final water body region contour.
[0068] Area_s ind1 ,L_s ind1 =Sort(Area) ind1 ,L ind1 );
[0069]
[0070]
[0071] Where F(i) represents the judgment of the index condition. When the index condition is not met, the current traversal sequence in the original index set ind2 is removed, and i = 0, 1, ..., ind1; ind3 is the output index set.
[0072] Compared with the prior art, the present invention has the following beneficial effects:
[0073] 1. The water contour post-processing algorithm proposed in this invention can be used for post-processing of any water segmentation model results, especially in complex open scenes. Since the training dataset of the water segmentation model and the test scene data have different distributions, additional small contours or discontinuous line segments will be generated. Using the contour post-processing method provided in this invention can improve the accuracy of water contour detection.
[0074] 2. When a non-continuous water level line is detected, it will affect the business judgment of object detection within the water body area. By using the closed contour algorithm of the present invention, the non-continuous water level line can be reconstructed, thereby obtaining a closed water body contour for business judgment within the water body area, which greatly increases the application scenarios of the algorithm.
[0075] 3. The water body segmentation contour post-processing algorithm proposed in this invention can obtain a contour set using a semantic segmentation model, and then iterate through each contour to remove contours with non-closed line segments and contours with closed shapes that do not conform to the actual river shape, ensuring that the contours output by the algorithm are real water body areas, and thus have high practicality.
[0076] Other beneficial effects of the present invention will be explained in detail through the introduction of specific technical features and technical solutions in specific embodiments. Those skilled in the art should be able to understand the beneficial technical effects brought about by these technical features and technical solutions through the introduction of these technical features and technical solutions. Attached Figure Description
[0077] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0078] Figure 1 This is a flowchart of the method of the present invention.
[0079] Figure 2 This is a diagram of the contour area determination module in this invention.
[0080] Figure 3 This is a diagram of the additional small contour removal module in this invention.
[0081] Figure 4 This is a diagram of the abnormal contour removal module in this invention.
[0082] Figure 5 This is a display image showing the post-processing effect of the water body outline. Detailed Implementation
[0083] The present invention will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present invention, but do not limit the invention in any way. It should be noted that those skilled in the art can make several changes and improvements without departing from the concept of the present invention. These all fall within the scope of protection of the present invention.
[0084] Reference Figure 1 As shown, a method for extracting water areas in complex scenarios includes:
[0085] Step 1: Set up cameras F in complex scenes j River video is captured. Here, j represents the index of the camera device, and video frames from each device are obtained.
[0086] Step 2: Train a water segmentation model based on the existing water segmentation dataset, and then test the video frames in the test scenario. As input to the water body segmentation model, the output is a mask binary image pred, corresponding to two categories: water body and non-water body regions.
[0087] Step 3: Extract the water body region from the pred dataset and perform edge detection to obtain the contour set C = {C0, C1, C2, ..., C}. i}, where i represents the number of contours.
[0088] Step 4: Enter the water body segmentation contour post-processing algorithm to obtain the closed water body contour region.
[0089] The specific process of the water body segmentation contour post-processing algorithm is as follows:
[0090] First, define the contour set C = {C0, C1, C2, ..., C}. i Iterate through each C in a loop. i Perform area calculation:
[0091] Area i =AR min (C i );
[0092] Among them, AR min Determining the smallest outer rectangle of the contour and calculating its area is equivalent to finding the contour C. iThe area is Area i .
[0093] Calculate the number of contours with an area less than Δ (cnt), and compare it with the total number of contours. The result is used for subsequent judgment.
[0094]
[0095]
[0096] Where Δ represents the threshold value set, which is generally set to 10-20, L represents the total number of contours, and k is the set ratio, which is between 0 and 1. The obtained key is used for subsequent logical judgment.
[0097] If the key is True, the output is a contour set C, which consists of a large number of non-continuous line segments, representing an unclosed contour region. This is used for logical judgment in the water body contour closure algorithm. Otherwise, the contour set is traversed, and the number L of each contour point set is calculated. i The maximum value in the point set and minimum value And find the difference set Re. i :
[0098]
[0099] Where len(x) is the contour point set calculation function, and a is the range 0-L. i The index;
[0100] Set the α parameter (generally 0.3-0.5) according to the actual application scenario, and use it for threshold filtering of the results obtained in the above steps:
[0101]
[0102] in, The index of the i-th contour represents the set of contour points that satisfies the above formula. L represents the index of the i-th contour under the condition that the difference set satisfies the above formula. max Re represents the contour with the most points in contour C. max This represents the contour with the largest difference set in contour C.
[0103] Find the intersection of the results and retain the set of indices ind1 that satisfy the condition of the number of contour points and the difference distance:
[0104]
[0105] If ind1 is less than 1, then output contour C. ind1 As the final water body contour region output by the algorithm, if ind1 is greater than or equal to 1, then from Area...i and Extract the set of indices that meet the conditions to obtain the Area. ind1 and L ind1 Then remove abnormal outlines with long line segments but small areas; first, for the Area... ind1 and L ind1 Sort L_s from largest to smallest, and check if the contour with the largest area has the largest number of points. If not, delete the contour with the largest number of points, and then continue iterating through L_s. ind2 This continues until the area-sorted sequence matches the point set number-sorted sequence, thus obtaining the Area. ind2 and L ind2 Where, ind2 = ind1 - ind1[0].
[0106] Then, using the ratio of the number of points to the area of the largest area contour (std) as a reference, the contours are traversed from largest to smallest, and those that meet the conditions are retained. The resulting contours are used as the final water body region contours.
[0107] Area_s ind1 ,L_s ind1 =Sort(Area) ind1 ,L ind1 );
[0108]
[0109]
[0110] Where F(x) represents the index judgment that meets the condition. When the condition is not met, the current traversal sequence in the original index set ind2 will be removed, and i = 0, 1, ..., ind1; ind3 is the output index set.
[0111] The water contour post-processing algorithm proposed in this invention can be used for post-processing of any water segmentation model results, especially in complex open scenes. Because the training dataset and test scene data of the water segmentation model have different distributions, additional small contours or discontinuous line segments will be generated. Using the contour post-processing method provided in this invention can improve the accuracy of water contour detection. The water contour post-processing algorithm can use the semantic segmentation model to obtain the contour set, and then traverse it one by one to remove contours with non-closed line segments and contours with closed shapes that do not conform to the actual river shape, ensuring that the contours output by the algorithm are real water areas, and has high practicality.
[0112] The above are basic embodiments of the present invention. The technical solution of the present invention will be further described below through a preferred embodiment.
[0113] Example 1
[0114] Reference Figure 1 As shown, a method for extracting water areas in complex scenarios includes:
[0115] Step 1: Set up cameras F in complex scenes j River video is captured. Here, j represents the index of the camera device, and video frames from each device are obtained.
[0116] Step 2: Train a water segmentation model based on the existing water segmentation dataset, and then test the video frames in the test scenario. As input to the water body segmentation model, the output is a mask binary image pred, corresponding to two categories: water body and non-water body regions.
[0117] Step 3: Extract the water body region from the pred dataset and perform edge detection to obtain the contour set C = {C0, C1, C2, ..., C}. i}, where i represents the number of contours.
[0118] Step 4: Enter the water body segmentation contour post-processing algorithm to obtain the closed water body contour region.
[0119] Reference Figure 5 As shown, in this embodiment, the post-processing algorithm for water body segmentation contours adopts a water body contour closure algorithm:
[0120] First, define the contour set C = {C0, C1, C2, ..., C}. i The loop iterates through the unique list to obtain the contour set C. c .
[0121] Then outline C c The point set in the array is sorted in ascending order along the x and y directions, and the minimum and maximum values along the x direction are obtained, respectively x_min and x_max. cmin and x cmax The minimum and maximum values in the y-direction are respectively y cmin and y cmax .
[0122] Finally, by combining the results of the above steps, we obtain the minimum and maximum coordinates in each direction, i.e., (x... cmin y cmin ), (x cmin y cmax ), (x cmax y cmin ), (x cmax y cmax Then in the contour set C c The index I of the above four coordinates is obtained from the above. xmin,ymin ,I xmin,ymax ,I xmax,ymin ,I xmax,ymaxAccording to the index number in C c Extract the set of 4 points within the index range, for example: I xmin,ymin =5,I xmin,ymax =60,I xmax,ymin =270,I xmax,ymax =110, sort in ascending order and take C. c [5:60]、C c [60:110]、C c [110:270]、C c [270:], a total of 4 point sets are merged into a list C. c1 In this way, the closed water body outline region is obtained.
[0123] When a non-continuous water level line is detected, it will affect the business judgment of object detection within the water body area. By using the closed contour algorithm of the present invention, the non-continuous water level line can be reconstructed, thereby obtaining a closed water body contour for business judgment within the water body area, which greatly increases the application scenarios of the algorithm.
[0124] The present invention also provides a water area extraction system for complex scenarios. The water area extraction system for complex scenarios can be implemented by executing the process steps of the water area extraction method for complex scenarios. That is, those skilled in the art can understand the water area extraction method for complex scenarios as a preferred embodiment of the water area extraction system for complex scenarios.
[0125] Specifically, a water area extraction system for complex scenarios includes:
[0126] Module M1: Collects water flow data;
[0127] Module M2: Preprocesses water flow data based on the trained water body segmentation model;
[0128] Module M3: Processes water flow data based on a water body segmentation contour post-processing algorithm to obtain a closed water body contour region.
[0129] The module M1 includes a camera-based F j Collect water flow data to obtain video frames from each device. Where j represents the index of the camera device.
[0130] Module M2 includes the following sub-modules:
[0131] Module M2.1: Trains a water segmentation model based on an existing water segmentation dataset, and segments video frames in a test scenario. As input to the water body segmentation model, the output is a mask binary image pred; the binary image includes water body region classes and non-water body region classes;
[0132] Module M2.2: Extracts the water region from the binary image pred and performs edge detection to obtain the contour set C = {C0, C1, C2, ..., C}. i}, where i represents the number of contours.
[0133] The module M3 includes the following sub-modules:
[0134] Module M3.1: Set the contour set C = {C0, C1, C2, ..., C...} i Iterate through each C in a loop. i Perform area calculation:
[0135] Area i =AR min (C i );
[0136] Among them, AR min Area represents the area of the smallest outer rectangle that gives the contour. i The contour C obtained for equivalence i The area;
[0137] Module M3.2: Calculates the number of contours with an area less than Δ (cnt) and compares it with the total number of contours.
[0138]
[0139]
[0140] Where Δ represents the set threshold, L represents the total number of contours, k is the set ratio, and key is the parameter for logical judgment;
[0141] Module M3.3: If key is True, output contour set C and perform logical judgment for the water body contour closure algorithm; the contour set C includes discontinuous line segments and is an unclosed contour region; if key is not True, traverse the contour set and calculate the number L of each contour point set. i Maximum value in a point set and minimum value And find the difference set Re. i :
[0142]
[0143] Where len(x) is the contour point set calculation function, and a is the range 0-L. i The index;
[0144] Module M3.4: Setting the α parameter for threshold filtering:
[0145]
[0146] in, This represents the index of the i-th contour in the set of contour points that satisfies the preset conditions. L represents the index of the i-th contour that satisfies the preset conditions of the difference set. max Re represents the contour with the most points in contour C. max Represents the contour with the largest difference in contour C;
[0147] Module M3.5: Find the intersection and retain the set of indices ind1 that satisfy the condition of the number of contour points and the difference distance.
[0148]
[0149] Module M3.6: Determines the value of ind1 to obtain the final water body region outline.
[0150] The module M3.6 includes an output contour C if ind1 is less than 1. ind1 As the final water body contour region output by the algorithm, if ind1 is greater than or equal to 1, then from Area... i and Filter the index set to get Area ind1 and L ind1 Remove outlines that do not meet the preset conditions; for Area ind1 and L ind1 Sort the contours from largest to smallest, and check if the contour with the largest area has the largest number of contour points. If not, delete the contour with the largest number of contour points and continue iterating through L_s. ind2 This continues until the area-sorted sequence matches the point set number-sorted sequence, thus obtaining the Area. ind2 and L ind2 ;in,
[0151] ind2 = ind1 - ind1[0];
[0152] Using the ratio of the number of points to the area of the largest contour as a reference (std), the contours are traversed from largest to smallest to obtain the final water body region contour.
[0153] Area_s ind1 ,L_s ind1 =Sort(Area) ind1 ,L ind1 );
[0154]
[0155]
[0156] Where F(i) represents the judgment of the index condition. When the index condition is not met, the current traversal sequence in the original index set ind2 is removed, and i = 0, 1, ..., ind1; ind3 is the output index set.
[0157] Those skilled in the art will understand that, besides implementing the system and its various devices, modules, and units provided by this invention in the form of purely computer-readable program code, the same functions can be achieved entirely through logical programming of the method steps, making the system and its various devices, modules, and units of this invention function in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, the system and its various devices, modules, and units provided by this invention can be considered as a hardware component, and the devices, modules, and units included therein for implementing various functions can also be considered as structures within the hardware component; alternatively, the devices, modules, and units for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.
[0158] In the description of this application, it should be understood that the terms "upper", "lower", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application.
[0159] Specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. Unless otherwise specified, the embodiments and features described in this application can be arbitrarily combined with each other.
Claims
1. A method for extracting water areas in complex scenarios, characterized in that, include: Step S1: Collect water flow data; Step S2: Preprocess the water flow data based on the trained water body segmentation model; Step S3: Process the water flow data based on the water body segmentation contour post-processing algorithm to obtain a closed water body contour region; Step S3 includes the following sub-steps: Step S3.1: Set the contours Iterate through each... Perform area calculation: in, This represents the area of the smallest outer rectangle that yields the outline. The contour obtained for equivalence The area; Step S3.2: Calculate the contour area less than quantity And compare it with the total number of outlines: in, This indicates the set threshold. Indicates the total number of outlines. For the set ratio, Parameters for logical judgment; Step S3.3: If for Then the output contour set Logical judgment is performed for the water body contour closure algorithm; the contour set Includes discontinuous line segments and is an open contour region; if Not for Then iterate through the contour set and calculate the number of points for each contour set. Maximum value in a point set and minimum value And find the difference set : in, The function is used to calculate the contour point set, where a is the range 0- L i The index; Step S3.4: Setting Parameters are filtered using thresholds: in, This represents the set of contour points that satisfy the preset conditions. Index of a contour, The difference set represents the first set that satisfies the preset conditions. Index of a contour, Represents outline The contour with the most midpoints. Represents outline The contour with the largest difference set; Step S3.5: Find the intersection and retain the set of indices that satisfy the condition of the number of contour points and the difference distance. : Step S3.6: Determine The value is used to obtain the final water body region outline.
2. The method for extracting water areas in complex scenarios according to claim 1, characterized in that, Step S1 includes using a camera Collect water flow data to obtain video frames from each device. ,in, This represents the index of the camera device.
3. The method for extracting water areas in complex scenarios according to claim 2, characterized in that, Step S2 includes the following sub-steps: Step S2.1: Train a water segmentation model based on the existing water segmentation dataset, and segment the video frames in the test scenario. As input to the water segmentation model, the output is a mask binary image. The binary image includes water body region classes and non-water body region classes. Step S2.2: Extract the binary image The water body area is processed and edge detection is performed to obtain a contour set. ,in, Indicates the number of outlines.
4. The method for extracting water areas in complex scenarios according to claim 1, characterized in that, Step S3.6 includes if If the value is less than 1, then output the contour. As the water body contour region output by the final algorithm, if If greater than or equal to 1, then from and Filter the index set to obtain and Remove contours that do not meet the preset conditions; and Sort by size from largest to smallest and Check if the contour with the largest area has the largest number of contour points. If not, delete the contour with the largest number of contour points and continue the loop. This continues until the area-sorted sequence matches the point-set-number-sorted sequence, resulting in... and ;in, ; The ratio of the number of points to the area of the maximum area contour. As a reference, the contours are traversed from largest to smallest and selected as the final water body contours: in, This indicates the condition for indexing; if the condition is not met, the original index set is removed. The current traversal sequence in, and ; This is the set of indices for the output.
5. A water area extraction system for complex scenarios, characterized in that, include: Module M1: Collects water flow data; Module M2: Preprocesses water flow data based on the trained water body segmentation model; Module M3: Processes water flow data based on a water body segmentation contour post-processing algorithm to obtain a closed water body contour region; The module M3 includes the following sub-modules: Module M3.1: Sets the contours Iterate through each... Perform area calculation: in, This represents the area of the smallest outer rectangle that yields the outline. The contour obtained for equivalence The area; Module M3.2: Calculates contour area less than quantity And compare it with the total number of outlines: in, This indicates the set threshold. Indicates the total number of outlines. For the set ratio, Parameters for logical judgment; Module M3.3: If for Then the output contour set Logical judgment is performed for the water body contour closure algorithm; the contour set Includes discontinuous line segments and is an open contour region; if Not for Then iterate through the contour set and calculate the number of points for each contour set. Maximum value in a point set and minimum value And find the difference set : Module M3.4: Settings Parameters are filtered using thresholds: in, This represents the set of contour points that satisfy the preset conditions. Index of a contour, The difference set represents the first set that satisfies the preset conditions. Index of a contour, Represents outline The contour with the most midpoints. Represents outline The contour with the largest difference set; Module M3.5: Finds the intersection and retains the set of indices that satisfy the condition of the number of contour points and the difference distance. : Module M3.6: Judgment The value is used to obtain the final water body region outline.
6. The water area extraction system in a complex scenario according to claim 5, characterized in that, The module M1 includes a camera-based... Collect water flow data to obtain video frames from each device. ,in, This represents the index of the camera device.
7. The water area extraction system in a complex scenario according to claim 6, characterized in that, Module M2 includes the following sub-modules: Module M2.1: Trains a water segmentation model based on an existing water segmentation dataset, and segments video frames in a test scenario. As input to the water segmentation model, the output is a mask binary image. The binary image includes water body region classes and non-water body region classes. Module M2.2: Extracting Binary Images The water body area is processed and edge detection is performed to obtain a contour set. ,in, Indicates the number of outlines.
8. The water area extraction system in a complex scenario according to claim 5, characterized in that, The module M3.6 includes if If the value is less than 1, then output the contour. As the water body contour region output by the final algorithm, if If greater than or equal to 1, then from and Filter the index set to obtain and Remove contours that do not meet the preset conditions; and Sort the contours from largest to smallest, and check if the contour with the largest area has the largest number of contour points. If not, delete the contour with the largest number of contour points and continue the loop. This continues until the area-sorted sequence matches the point-set-number-sorted sequence, resulting in... and ;in, ; The ratio of the number of points to the area of the maximum area contour. As a reference, the contours are traversed from largest to smallest and selected as the final water body contours: in, This indicates the condition for indexing; if the condition is not met, the original index set is removed. The current traversal sequence in, and ; This is the set of indices for the output.
Citation Information
Patent Citations
Water gauge water line detection method and device
CN115482410A
CNN-Transform-based remote sensing image water body extraction method and device, electronic equipment and medium
CN117036805A
Method for extracting glacial lakes in highland area based on remote sensing satellite image
CN107730527A
Building information extraction method and system based on rule and sample fusion
CN110427961A