Method, device and equipment for extracting river leader with water and storage medium
By extracting key points and mapping point pairs of water surface map spots, the river's flood line is cut off and attribute updates are solved, and the problems of low efficiency and low data quality of extracting irregular water surface watered river chiefs in the existing technology are solved, and accurate and efficient watered river chief extraction is achieved.
Patent Information
- Application Number
- CN202510284871.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-11
- Publication Date
- 2025-06-06
- Estimated Expiration
- 2045-03-11
AI Technical Summary
The prior art is difficult to accurately extract water-bearing river chiefs on irregular water surfaces, traditional methods are inefficient and data quality is limited by manual interpretation.
By obtaining the grayscale map of the water surface map of the target river, extracting key point information, determining the mapping point pair of the furthest key point pair, and truncated the central red line according to the mapping point pair, and updating the properties of the river section to determine the length of the water.
The precise treatment of irregular water surfaces is achieved, the efficiency of water-capped river chief extraction is improved, man-made errors are reduced, and spatial continuity between river sections is ensured.
Smart Images

Figure CN120107800A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of hydrology and water resources management, and in particular to a method, device, equipment and storage medium for extracting the length of a river with water. Background Art
[0002] The length of a river with water is a key indicator for judging the connectivity of a water system, and is often used as a key indicator for evaluating the benefits of ecological water replenishment. However, due to the irregular shape of the water surface, poor spatial connectivity, and the fact that most water surface patches do not intersect with the mid-channel line of the river, direct spatial intersection analysis and buffer analysis cannot obtain accurate data on the length of a river with water. In actual work, in order to ensure the effective implementation of related work, the length of a river with water is generally determined by manually visually interrupting the mid-channel line of the river, but this method is inefficient, and the data quality is limited by the working status and concentration of the interpreters, and often cross-checks can reveal missed or erroneous interruptions.
[0003] Therefore, there is an urgent need for a method to extract the length of a river with water that can adapt to the complex shapes of water surface patches and solve the limitations of traditional methods in dealing with irregular water surfaces. Summary of the invention
[0004] In view of this, the present application provides a method, device, equipment and storage medium for extracting the length of a river with water, which solves the limitations of traditional methods in dealing with irregular water surfaces. The technical solution is as follows.
[0005] In a first aspect, the present invention provides a method for extracting the length of a river containing water, the method comprising:
[0006] Obtain a grayscale image of the water surface patch of the target river;
[0007] Extract key points from the grayscale image to obtain key point information;
[0008] Extract the farthest key point pair from the key point information; the farthest key point pair is the two key points with the farthest distance in the direction of the midstream line of the target river in the water surface pattern;
[0009] Determine the mapping point pair of the farthest key point pair on the midstream line of the target river;
[0010] According to the mapping point pair, the midstream line of the target river is cut off to obtain several river sections of the target river;
[0011] Matching the starting point and the end point of the river segment with the mapping point pair, and updating the attributes of each river segment according to the matching result; the attributes of the river segment are used to indicate whether there is water in the river segment;
[0012] According to the updated attributes of the river section, the water length of the target river is obtained.
[0013] In an optional implementation, the step of obtaining a grayscale image of a water surface spot of a target river includes:
[0014] Obtain the water surface patch of the target river;
[0015] Performing rasterization processing on the water surface spots to obtain a raster map of the water surface spots;
[0016] The raster image of the water surface spot is binarized to obtain a grayscale image of the water surface spot.
[0017] In an optional implementation, key point extraction is performed on the grayscale image to obtain key point information, including:
[0018] Extract skeleton line information in the grayscale image;
[0019] The key points are extracted from the skeleton line information to obtain the key point information.
[0020] In an optional implementation, determining the mapping point pair of the farthest key point pair on the midstream line of the target river includes:
[0021] Calculate the foot of the perpendicular from the farthest key point pair to the mid-stream line of the target river, and obtain the mapping point pair of the farthest key point pair on the mid-stream line of the target river.
[0022] In an optional implementation, matching the start point and the end point of the river segment with the mapping point pair, and updating the attributes of each river segment according to the matching result, includes:
[0023] Matching the starting point and the end point of the river section with the mapping point pair in spatial position to obtain a matching result;
[0024] If the matching result does not exceed the matching threshold, the attribute of the river section is determined to be water;
[0025] If the matching result exceeds the matching threshold, the attribute of the river section is determined to be water-free.
[0026] In an optional implementation, obtaining the water-filled river length of the target river according to the updated attributes of the river section includes:
[0027] According to the updated attributes of the river section, several river sections with water are obtained;
[0028] Based on the starting point and end point of each river section with water, the length of each river section with water is obtained;
[0029] Based on the length of each river section with water, the water length of the target river is determined.
[0030] In an optional embodiment, the method further includes:
[0031] According to the attributes of the updated river section, several waterless river sections are obtained;
[0032] The attribute of the first dry river section is updated to have water; the first dry river section is a dry river section in which two adjacent river sections among the plurality of dry river sections are both water-containing river sections.
[0033] The method for extracting the length of a river with water of the present invention changes the attribute of a waterless river section that meets the threshold condition to "with water" if both the left and right river sections are water-filled river sections, thereby ensuring the continuity of the water-filled river section in space.
[0034] The method for extracting the length of a river with water provided by the present invention has the following advantages.
[0035] The method for extracting the length of a river with water provided by the present invention includes two steps: extracting key points of water surface spots and truncating the middle line and updating the attributes. First, the water surface interpretation result of the target river is obtained, which can be obtained through remote sensing image data and corresponding image processing technology. The water surface interpretation result is usually a vector data, which contains polygons of different water surface areas, that is, water surface spots. These vector water surface spots are converted into raster data. The resolution of the rasterization should be consistent with the resolution of the remote sensing image used during the interpretation, which can ensure that there will be no loss of accuracy due to resolution mismatch during the extraction process. Subsequently, the raster image is binarized to obtain a grayscale image of the water surface spots. Clear water surface areas and backgrounds can be extracted from complex water surface interpretation images, reducing the interference of noise in subsequent processing. Since the morphology of the water surface spots may be very complex, after binarization, the skeletonization method is used to simplify the shape and extract the skeleton structure line of the grayscale image. The skeletonized figure is a linear structure that only contains the main morphological features of the spots, which is convenient for subsequent key point extraction. On the basis of the skeleton line, key point information is further extracted. After extracting the key points, the mid-river line can be truncated. For each water surface patch, the two key points with the farthest distance in the mid-river line direction of the target river are analyzed one by one to obtain the farthest key point pair, and the mapping point pair of the farthest key point pair on the mid-river line of the target river is determined. The mapping point pair of the farthest key point pair can be determined by calculating the foot of the perpendicular (i.e., the shortest vertical distance) from the farthest key point pair to the mid-river line of the target river. According to the mapping point pair, the mid-river line of the target river is truncated to obtain several river sections. According to the comparison between the two end points of the truncated river section and the mapping point pair, the attributes of each river section are updated, i.e., the water or no water attribute. In particular, if the two adjacent river sections of a river section that meets the threshold length are both water sections, but the river section itself is a no water section, its attribute is updated to "water" to ensure the spatial continuity of the water river section. By calculating the length of all water river sections, the water length of the target river can be obtained. The method for extracting the length of a river with water in the present invention takes into account the irregularity of the water surface and the spatial characteristics of the river, can accurately extract the length of the river section with water, ensure the spatial continuity between different river sections, and effectively handle the complex morphology of the water surface. This solves the limitations of traditional methods in handling irregular water surfaces, improves efficiency, and reduces human errors.
[0036] In a second aspect, the present invention provides a device for extracting the length of a river with water, the device comprising:
[0037] An acquisition module is used to acquire a grayscale image of a water surface patch of a target river;
[0038] A key point extraction module is used to extract key points from the grayscale image to obtain key point information;
[0039] The farthest key point pair extraction module is used to extract the farthest key point pair from the key point information; the farthest key point pair is the two key points with the farthest distance in the direction of the midstream line of the target river in the water surface pattern;
[0040] A mapping point pair determination module, used to determine the mapping point pair of the farthest key point pair on the midstream line of the target river;
[0041] A truncation module is used to truncate the midstream line of the target river according to the mapping point pair to obtain several river sections of the target river;
[0042] An updating module, used for matching the starting point and the end point of the river segment with the mapping point pair, and updating the attributes of each river segment according to the matching result; the attributes of the river segment are used for indicating whether there is water in the river segment;
[0043] The calculation module is used to obtain the water length of the target river according to the updated attributes of the river section.
[0044] In an optional implementation, the acquisition module is specifically used to:
[0045] Obtain the water surface patch of the target river;
[0046] Performing rasterization processing on the water surface spots to obtain a raster map of the water surface spots;
[0047] The raster image of the water surface spot is binarized to obtain a grayscale image of the water surface spot.
[0048] In an optional implementation, the key point extraction module is specifically used to:
[0049] Extract skeleton line information in the grayscale image;
[0050] The key points are extracted from the skeleton line information to obtain the key point information.
[0051] In an optional implementation manner, the mapping point pair determination module is specifically used to:
[0052] Calculate the foot of the perpendicular from the farthest key point pair to the mid-stream line of the target river, and obtain the mapping point pair of the farthest key point pair on the mid-stream line of the target river.
[0053] In an optional implementation manner, the update module is specifically used to:
[0054] Matching the starting point and the end point of the river section with the mapping point pair in spatial position to obtain a matching result;
[0055] If the matching result does not exceed the matching threshold, the attribute of the river section is determined to be water;
[0056] If the matching result exceeds the matching threshold, the attribute of the river section is determined to be water-free.
[0057] In an optional implementation, the calculation module is specifically used to:
[0058] According to the updated attributes of the river section, several river sections with water are obtained;
[0059] Based on the starting point and end point of each river section with water, the length of each river section with water is obtained;
[0060] Based on the length of each river section with water, the water length of the target river is determined.
[0061] In an optional implementation manner, the update module is further used to:
[0062] According to the attributes of the updated river section, several waterless river sections are obtained;
[0063] The attribute of the first dry river section is updated to have water; the first dry river section is a dry river section in which two adjacent river sections among the plurality of dry river sections are both water-containing river sections.
[0064] In a third aspect, the present invention provides a computer device comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the method for extracting the length of a river with water according to the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0065] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method for extracting the length of a river with water according to the first aspect or any corresponding embodiment thereof.
[0066] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the method for extracting the length of a river with water according to the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0068] Figure 1 It is a schematic diagram of a method flow of a method for extracting the length of a river with water according to an exemplary embodiment.
[0069] Figure 2 is a schematic diagram of a key point distribution structure element according to an exemplary embodiment.
[0070] Figure 3 The figure is a schematic diagram of calculating key points of skeleton lines of water surface spots according to an exemplary embodiment.
[0071] Figure 4 It is a schematic diagram of the central line and water surface in a simulated test river according to an exemplary embodiment.
[0072] Figure 5 It is a schematic diagram of extracting key points of a water surface of a simulated test river according to an exemplary embodiment.
[0073] Figure 6 It is a schematic diagram of water surface key point mapping and river length extraction of a simulated test river according to an exemplary embodiment.
[0074] Figure 7 is a schematic diagram of an actual test area range according to an exemplary embodiment.
[0075] Figure 8 It is a schematic diagram of extracting the length of a river with water in an actual test area according to an exemplary embodiment.
[0076] Fig. 9 It is a structural schematic diagram of a water river length extraction device provided in an embodiment of the present application.
[0077] Fig.10 It is a structural schematic diagram of a computer device provided by an optional embodiment of the present invention. DETAILED DESCRIPTION
[0078] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of this application.
[0079] It should be understood that the "indication" mentioned in the embodiments of the present application can be a direct indication, an indirect indication, or an indication of an association relationship. For example, A indicates B, which can mean that A directly indicates B, for example, B can be obtained through A; it can also mean that A indirectly indicates B, for example, A indicates C, B can be obtained through C; it can also mean that there is an association relationship between A and B.
[0080] In the description of the embodiments of the present application, the term "corresponding" may indicate a direct or indirect correspondence between two items, or an association relationship between the two items, or a relationship between indication and being indicated, configuration and being configured, and the like.
[0081] In an embodiment of the present application, "predefinition" can be achieved by pre-saving corresponding codes, tables or other methods that can be used to indicate relevant information in a device (for example, including a terminal device and a network device). The present application does not limit its specific implementation method.
[0082] First, the terms involved in this application are introduced.
[0083] OpenCV: Open Source Computer Vision Library is an open source computer vision and machine learning software library that aims to provide efficient and simple tools to help developers perform computer vision, image processing, machine learning, video analysis, artificial intelligence and other related tasks.
[0084] THRESH_BINARY_INV: A threshold processing method in the OpenCV library that is used to binarize the image and invert the background and foreground after threshold processing.
[0085] ximgproc.thinning: It is an image processing function in OpenCV, used for image skeletonization (Thinning), that is, simplifying the structure of objects in the image into skeleton lines of single pixel width.
[0086] Arcpy: is a Python library in the ArcGIS platform that provides a rich set of functions and tools for processing spatial data, performing geoprocessing tasks, and automating geographic information system (GIS) workflows.
[0087] The length of a river with water is a key indicator for judging the connectivity of a water system and is often used as a key indicator for evaluating the benefits of ecological water replenishment. However, due to the irregular shape of the water surface, poor spatial connectivity and the fact that most water surface patches do not intersect with the mid-channel line of the river, it is impossible to obtain accurate data on the length of a river with water by directly using spatial intersection analysis or buffer analysis.
[0088] In actual work, in order to ensure the effective implementation of related work, the river chief generally adopts the method of manually visually interrupting the river's mid-channel. The artificial interruption method is to define the water part of the river through manual visual identification and intervention. Although this method can be applied in some small areas, it also has obvious shortcomings.
[0089] Specifically, on the one hand, manual interruption requires checking the intersection and mapping relationship between the river channel line and the water surface section by section and point by point. Especially in large areas, this process is very cumbersome and time-consuming. For a wide area, the speed of manual operation is far from meeting the needs of efficient work. When repeated inspections, corrections and cross-validations are required, the manual workload increases dramatically and cannot quickly adapt to changes in data volume and workload. On the other hand, manual interruption is highly dependent on the operator's energy and attention. Long-term work will cause fatigue, resulting in errors such as missed judgments, misjudgments or repeated interruptions. These errors are usually difficult to detect in time and may affect the overall accuracy of the data. Different operators may make different judgments based on personal experience, interpretation habits or standards when interrupting, resulting in differences in results, affecting the consistency and accuracy of the data. The accuracy of interruption is highly dependent on the operator's experience and judgment standards. The lack of unified standards and specifications may cause different people to obtain different results when interrupting in the same area, thus affecting the data quality. In complex terrain, complex water systems or irregular water surfaces, manual interruption is particularly prone to errors and requires more time and energy to correct. For areas with complex and interlaced water flows, the accuracy of manual identification is greatly reduced.
[0090] Therefore, in order to solve the limitations of traditional methods, the embodiment of the present invention provides a method for extracting the length of a river with water, which takes into account the irregularity of water surface patches and the spatial characteristics of the river, can accurately extract the length of the river section with water, and ensure the spatial continuity between different river sections, and can effectively handle the complex morphology of water surface patches. It solves the limitations of traditional methods in handling irregular water surfaces, and can improve efficiency and reduce human errors.
[0091] The method flow of the method for extracting the length of a river with water provided in this embodiment is as follows: Figure 1 As shown, the following steps are included.
[0092] S101, obtaining a grayscale image of a water surface patch of a target river.
[0093] Specifically, the first step is to obtain the water surface interpretation results. The water surface interpretation results include several water surface spots, which are usually obtained through remote sensing image processing. These spots represent the spatial area of water areas (such as rivers, lakes, reservoirs, etc.) and usually exist in the form of vectorized polygons. These vector water surface spots are converted into raster data. The resolution of the rasterization should be consistent with the resolution of the remote sensing image used in the interpretation, so as to ensure that there is no loss of accuracy due to resolution mismatch during the extraction process. Subsequently, the raster image is binarized, that is, the water surface area is marked as 255 (white, indicating water pixels) and the background area is marked as 0 (black, indicating non-water pixels), and the grayscale image of the water surface spots can be obtained. The purpose of this is to simplify the image and convert the processing problem into a clear binary classification problem, extracting clear water surface areas and backgrounds from the complex water surface interpretation results, and reducing the interference of noise in subsequent processing.
[0094] S102: extract key points from the grayscale image to obtain key point information.
[0095] Specifically, the core of this step is to extract the skeleton lines and key points of the water surface spots after binarization. The shape of the water surface spots may be very complex, so it is necessary to simplify the shape through skeletonization (or thinning) method, and finally extract the skeleton structure line of the spots. The skeletonized image is a linear structure that only contains the main morphological features of the spots. Based on the skeletonized image, key points can be extracted.
[0096] S103: extract the farthest key point pair from the key point information.
[0097] Specifically, the shape of water surface patches is usually irregular, so each water surface patch will generate multiple morphological key points. In order to accurately intercept the river section with water, it is necessary to determine the two farthest key points in the patch and calculate the length of these two key points in the river direction. For each water surface patch, select its two farthest key point pairs in the direction of the mid-stream line (the main direction or flow direction of the river).
[0098] S104, determining the mapping point pair of the farthest key point pair on the midstream line of the target river.
[0099] Specifically, by calculating the foot of the perpendicular from the farthest key point pair to the centerline of the target river, that is, the shortest vertical distance, the mapping point pair of the farthest key point pair can be obtained.
[0100] S105. According to the mapping point pair, the midstream line of the target river is cut off to obtain a plurality of river sections of the target river.
[0101] Specifically, according to the obtained mapping point pair information, the midstream line of the target river is truncated, and the target river is divided into several river sections.
[0102] S106: Match the starting point and the end point of the river segment with the mapping point pair, and update the attributes of each river segment according to the matching result.
[0103] Specifically, the attribute of the river segment is used to indicate whether the river segment has water. According to the comparison between the two ends of the truncated river segment and the corresponding mapping point pair, the attribute of each river segment, that is, the attribute of having water or not having water, is updated. According to the updated attribute of the river segment, it can be known whether each river segment has water.
[0104] S107. Obtain the river length with water of the target river according to the updated attributes of the river section.
[0105] Specifically, after determining whether each river section has water, the length of each river section with water is calculated to obtain the length of the target river with water.
[0106] Optionally, in step S101, the water surface spot vector data may be converted into raster data using a Rasterize tool (such as provided in QGIS and ArcGIS). Subsequently, the THRESH_BINARY_INV method in the OpenCV library is used to first convert the image into a grayscale image, and then the pixel value of the water surface area is set to 255 (white), and the pixel value of the background area is set to 0 (black), to obtain a grayscale image of the water surface spot of the target river.
[0107] In step S102, the ximgproc.thinning method in OpenCV can be used to iteratively slice edge pixels to transform the water surface pattern into a thin linear graphic, and convert the water surface pattern into a thin skeleton line. Then, through the morphological hit-miss transform (HMT), based on the skeleton line, a specific structural element is used to check which pixels meet the key point criteria. Only when some pixels of the structural element meet the specified pattern, the pixel is identified as a key point. The schematic diagram of the structural element is shown in FIG. Figure 2 As shown, for example, a 3×3 window is used to ensure the connectivity of the key points and their adjacent pixels. At least one direction in the window is connected to the water surface pixel. The pixels that meet this condition are detected by the HMT method to extract the key points of the water surface patch. Figure 2 Medium blue represents water surface pixels, white represents background pixels, italic shadows can be both water surface pixels and background pixels, and gray circles are key points.
[0108] In the above steps, the hit-miss transformation operation method is to find all pixels in the skeleton line of the water surface pattern that match the key point distribution structure element. The transformation operation calculation formula is as follows:
[0109]
[0110] Where I is the image calculated by key points, and B is the structural element extracted by key points.
[0111] Operation Instructions Figure 3 As shown, the graphs in column a represent the grid organization form of the skeleton line of the water surface pattern, the 3×3 grid in column b is the structural element for key point extraction, and the graphs in column c represent the key point extraction results of the skeleton line of the water surface pattern. In the graphs in columns a and c, blue represents the skeleton line pixels of the water surface pattern, white represents the background pixels, green represents the monitored key points, and gray is the expanded pixels designed to ensure the effectiveness of the structural element window sliding calculation.
[0112] Optionally, in the above step S105, the midstream line of the target river can be truncated by using tools in the Arcpy library.
[0113] In particular, in the above step S106, if two adjacent river sections of a river section that meets the threshold length are both river sections with water, but the river section itself is a river section without water, its attribute is updated to "with water" to ensure the spatial continuity of the river section with water.
[0114] In order to better illustrate the method for extracting the length of a river with water provided in the above embodiment, the embodiment of the present invention is further illustrated below in conjunction with a specific implementation case. The following real-time case includes simulated test data and actual test data.
[0115] The schematic diagram of the test river center line and water surface in the simulated test data is as follows Figure 4 As shown in the figure, taking two simulated data as an example, the blue curve is the river midline and the yellow spot is the water surface spot. Figure 5 As shown in the figure, the key points of the water surface patches are calculated after vector-to-raster conversion, binarization, skeleton line extraction and other operations. The green and red points are the key points of the test 1 river and the test 2 river respectively. Figure 6 As shown, the mapping point pair of the farthest key point pair on the river centerline is obtained, and finally the length of the river with water is calculated.
[0116] In order to verify the effectiveness of the method for extracting the length of a river with water in the above embodiment, actual test data is used for verification. A test area including both plains and mountainous terrains in a certain area is selected. The test area range is as follows: Figure 7 As shown, the area is 744km 2 , including 21 rivers with a total length of 256.63km.
[0117] The schematic diagram of extracting the length of the river with water in the actual test area is as follows Figure 8 As shown, Figure 8-a is the original input element of the method for extracting the length of a river with water provided in the above embodiment, including the interpretation result of the water surface patch and the river midline. The water surface and background pixels are separated by raster conversion and binarization, and are represented by blue and white respectively, as shown in FIG. Figure 8 -b. Based on the binarization processing, the morphological processing method is used to extract the main morphological lines of the water surface patch interpretation results, as shown in Figure 8 Then, the key point distribution structure element and the hit-miss change operation are used to obtain the morphological key points, as shown in Figure 8 -d, the acquisition of water surface key points has been completed.
[0118] Due to the complex morphology of water surface spots, the key point extraction results often contain multiple key points. In order to reduce the number of key points and improve the calculation efficiency of subsequent processes, it is necessary to compare the key points of the water surface spots one by one to obtain the farthest key point pair, such as Figure 8 -e, and calculate the mapping point pairs on the Zhonghong line, such as Figure 8 -f, and finally the middle line of the river is cut off with the position of the mapping point pair, and the coordinate relationship between the intercepted line segment and the mapping point pair is assigned, as shown in Figure 8 -g as shown.
[0119] By comparing the extraction results of the river length with water in the test area using the above method with the results extracted using the manual truncation method, it can be seen that most of the errors can be controlled within 5%, and the overall error in this area is 1.17%.
[0120] In summary, the method for extracting the length of a river with water provided by an embodiment of the present invention includes two steps: extracting key points of water surface spots and truncating the middle line and updating the attributes. First, the water surface interpretation result of the target river is obtained, which can be obtained through remote sensing image data and corresponding image processing technology. The water surface interpretation result is usually a vector data containing polygons of different water surface areas, that is, water surface spots. These vector water surface spots are converted into raster data. The resolution of the rasterization should be consistent with the resolution of the remote sensing image used during the interpretation, which can ensure that there is no loss of accuracy due to resolution mismatch during the extraction process. The raster image is then binarized to obtain a grayscale image of the water surface spots. Clear water surface areas and backgrounds can be extracted from complex water surface interpretation images, reducing the interference of noise in subsequent processing. Since the morphology of the water surface spots may be very complex, after binarization, the skeletonization method is used to simplify the shape and extract the skeleton structure line of the grayscale image. The skeletonized figure is a linear structure that only contains the main morphological features of the spots, which is convenient for subsequent key point extraction. On the basis of the skeleton line, key point information is further extracted. After extracting the key points, the mid-river line can be truncated. For each water surface patch, the two key points with the farthest distance in the mid-river line direction of the target river are analyzed one by one to obtain the farthest key point pair, and the mapping point pair of the farthest key point pair on the mid-river line of the target river is determined. The mapping point pair of the farthest key point pair can be determined by calculating the foot of the perpendicular (i.e., the shortest vertical distance) from the farthest key point pair to the mid-river line of the target river. According to the mapping point pair, the mid-river line of the target river is truncated to obtain several river sections. According to the comparison between the two end points of the truncated river section and the mapping point pair, the attributes of each river section are updated, i.e., the water or no water attribute. In particular, if the two adjacent river sections of a river section that meets the threshold length are both water sections, but the river section itself is a no water section, its attribute is updated to "water" to ensure the spatial continuity of the water river section. By calculating the length of all water river sections, the water length of the target river can be obtained. The method for extracting the length of a river with water in the present invention takes into account the irregularity of the water surface and the spatial characteristics of the river, can accurately extract the length of the river section with water, ensure the spatial continuity between different river sections, and effectively handle the complex morphology of the water surface. This solves the limitations of traditional methods in handling irregular water surfaces, improves efficiency, and reduces human errors.
[0121] In the embodiments of the present application, a device for extracting the length of a river with water is also provided, and the device is used to implement the above-mentioned embodiments and preferred embodiments, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0122] The embodiment of the present application provides a device for extracting the length of a river with water. Fig. 9 : is a schematic diagram of a structure of a water river length extraction device provided in an embodiment of the present application, the device comprising:
[0123] An acquisition module 901 is used to acquire a grayscale image of a water surface patch of a target river;
[0124] A key point extraction module 902 is used to extract key points from the grayscale image to obtain key point information;
[0125] The farthest key point pair extraction module 903 is used to extract the farthest key point pair from the key point information; the farthest key point pair is the two key points with the farthest distance in the direction of the midstream line of the target river in the water surface pattern;
[0126] A mapping point pair determination module 904 is used to determine the mapping point pair of the farthest key point pair on the midstream line of the target river;
[0127] A truncation module 905 is used to truncate the midstream line of the target river according to the mapping point pair to obtain a plurality of river sections of the target river;
[0128] An updating module 906 is used to match the starting point and the end point of the river segment with the mapping point pair, and update the attributes of each river segment according to the matching result; the attributes of the river segment are used to indicate whether the river segment has water;
[0129] The calculation module 907 is used to obtain the water length of the target river according to the updated attributes of the river section.
[0130] In an optional implementation, the acquisition module 901 is specifically configured to:
[0131] Obtain the water surface patch of the target river;
[0132] Performing rasterization processing on the water surface spots to obtain a raster map of the water surface spots;
[0133] The raster image of the water surface spot is binarized to obtain a grayscale image of the water surface spot.
[0134] In an optional implementation, the key point extraction module 902 is specifically used to:
[0135] Extract skeleton line information in the grayscale image;
[0136] The key points are extracted from the skeleton line information to obtain the key point information.
[0137] In an optional implementation, the mapping point pair determination module 904 is specifically configured to:
[0138] Calculate the foot of the perpendicular from the farthest key point pair to the mid-stream line of the target river, and obtain the mapping point pair of the farthest key point pair on the mid-stream line of the target river.
[0139] In an optional implementation, the updating module 906 is specifically configured to:
[0140] Matching the starting point and the end point of the river section with the mapping point pair in spatial position to obtain a matching result;
[0141] If the matching result does not exceed the matching threshold, the attribute of the river section is determined to be water;
[0142] If the matching result exceeds the matching threshold, the attribute of the river section is determined to be water-free.
[0143] In an optional implementation, the calculation module 907 is specifically configured to:
[0144] According to the updated attributes of the river section, several river sections with water are obtained;
[0145] Based on the starting point and end point of each river section with water, the length of each river section with water is obtained;
[0146] Based on the length of each river section with water, the water length of the target river is determined.
[0147] In an optional implementation, the updating module 906 is further configured to:
[0148] According to the attributes of the updated river section, several waterless river sections are obtained;
[0149] The attribute of the first dry river section is updated to have water; the first dry river section is a dry river section in which two adjacent river sections among the plurality of dry river sections are both water-containing river sections.
[0150] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0151] The water-filled river length extraction device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0152] The embodiment of the present invention also provides a computer device having the above Fig. 9 A water river length extraction device is shown.
[0153] See also Fig.10 , Fig.10is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Fig.10 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the computer device, including instructions stored in or on the memory to display graphic information in a graphical user interface on an external input / output device (such as a display device coupled to an interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Fig.10 A processor 10 is taken as an example.
[0154] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0155] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0156] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0157] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0158] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Fig.10 The example of connecting through bus is taken in the following.
[0159] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0160] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0161] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for extracting the length of a river with water, characterized in that: The method comprises: Obtain a grayscale image of the water surface patch of the target river; Extracting key points from the grayscale image to obtain key point information; Extract the farthest key point pair of each water surface spot from the key point information; the farthest key point pair is the two key points of the water surface spot with the farthest distance in the direction of the midstream line of the target river; Determine a mapping point pair of the farthest key point pair on the midstream line of the target river; According to the mapping point pairs, the midstream line of the target river is cut off to obtain several river sections of the target river; Matching the starting point and the end point of the river segment with the mapping point pair, and updating the attributes of each river segment according to the matching result; the attributes of the river segment are used to indicate whether there is water in the river segment; According to the updated attributes of the river section, the water length of the target river is obtained.
2. The method according to claim 1, characterized in that The step of obtaining a grayscale image of a water surface spot of a target river includes: Obtain the water surface patch of the target river; Performing rasterization processing on the water surface spots to obtain a raster map of the water surface spots; The raster image of the water surface spots is binarized to obtain a grayscale image of the water surface spots.
3. The method according to claim 2, characterized in that The step of extracting key points from the grayscale image to obtain key point information includes: Extracting skeleton line information in the grayscale image; Key point extraction is performed on the skeleton line information to obtain key point information.
4. The method according to claim 3, characterized in that Determining the mapping point pair of the farthest key point pair on the midstream line of the target river includes: Calculate the foot of the perpendicular from the farthest key point pair to the mid-stream line of the target river, and obtain the mapping point pair of the farthest key point pair on the mid-stream line of the target river.
5. The method according to claim 4, characterized in that The matching of the starting point and the end point of the river segment with the mapping point pair and updating the attributes of each river segment according to the matching result includes: Matching the starting point and the end point of the river section with the mapping point pair in spatial position to obtain a matching result; If the matching result does not exceed the matching threshold, it is determined that the attribute of the river section is water; If the matching result exceeds the matching threshold, the attribute of the river segment is determined to be water-free.
6. The method according to claim 5, characterized in that The step of obtaining the water-filled river length of the target river according to the updated attributes of the river segment includes: According to the updated attributes of the river section, several river sections with water are obtained; Based on the starting point and end point of each river section with water, the length of each river section with water is obtained; Based on the length of each river section with water, the water length of the target river is determined.
7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: According to the attributes of the updated river section, several waterless river sections are obtained; The attribute of the first dry river section is updated to have water; the first dry river section is a dry river section in which two adjacent river sections among the plurality of dry river sections are both water-containing river sections.
8. A device for extracting the length of a river with water, characterized in that: The device comprises: An acquisition module is used to acquire a grayscale image of a water surface patch of a target river; A key point extraction module, used to extract key points from the grayscale image to obtain key point information; A farthest key point pair extraction module is used to extract the farthest key point pair of each water surface spot from the key point information; the farthest key point pair is the two key points of the water surface spot with the farthest distance in the direction of the midstream line of the target river; A mapping point pair determination module, used to determine the mapping point pair of the farthest key point pair on the midstream line of the target river; A truncation module, used for truncating the midstream line of the target river according to the mapping point pair to obtain a plurality of river sections of the target river; An updating module, used for matching the starting point and the end point of the river segment with the mapping point pair, and updating the attributes of each river segment according to the matching result; the attributes of the river segment are used to indicate whether there is water in the river segment; The calculation module is used to obtain the water length of the target river according to the updated attributes of the river section.
9. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for extracting the length of a river with water according to any one of claims 1 to 7 by executing the computer instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method for extracting the length of a river with water according to any one of claims 1 to 7.
Citation Information
Patent Citations
Automatic meander extraction method
CN108319902A
Automatic extraction method for river curve envelope line
CN109934890A
Urban water map and manufacturing and displaying method thereof
CN110910471A
River channel extraction method based on water surface data
CN118334530A
Vector surface river center line extraction method and system
CN118941622A