Underground pipe drainage design method and system for saline-alkali soil
Through intelligent image analysis and path optimization algorithms, waterlogged areas are automatically identified and scientific underground pipe routes are generated, solving the problems of insufficient scientificity and construction feasibility in traditional underground pipe design, and improving the drainage effect and engineering efficiency in saline-alkali land.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-12
- Publication Date
- 2026-03-27
AI Technical Summary
Traditional underground pipe design relies on manual experience, the pipe layout is not scientific enough, it is difficult to dynamically generate the optimal solution according to the changes in terrain, ignores the spatial changes in water distribution, lacks overall optimization, and does not consider the constraints of engineering construction feasibility.
Image intelligent analysis technology is used to identify waterlogged areas, semantic segmentation and K-means clustering are used to generate drainage points, and Dijkstra's algorithm is combined to optimize path planning. Directional penalties and angle constraints are added to generate continuous and constructable underground pipe paths.
It has achieved automation and scientific design of underground drainage in saline-alkali land, improved drainage effect and engineering efficiency, adapted to the dynamic adjustment capability of different plots, and avoided the problems of sawtooth and sharp angle.
Smart Images

Figure CN121744560A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of agricultural engineering, precision drainage design, and intelligent image analysis, specifically to a method and system for designing underground drainage systems in saline-alkali land. Background Technology
[0002] Salinization is a widespread soil degradation problem in irrigated areas and farmland in my country, seriously affecting crop yields and soil health. Underground pipe drainage systems are an engineering measure that uses underground pipes to remove salt from farmland with seepage water; it is one of the most effective methods for controlling salinization in saline-alkali areas.
[0003] Traditional underground pipe design relies on manual experience, resulting in unscientific pipe layouts that easily deviate from low-resistance paths and struggle to dynamically generate optimal solutions based on terrain changes. In terms of overall planning, the independent design of multiple pipes neglects the spatial variations in water distribution, lacking holistic optimization. While existing technologies utilize path planning algorithms for optimizing water supply or power network layout, they lack intelligent identification of soil waterlogging areas, modeling of farmland environmental variables, and collaborative optimization of multiple pipelines. Furthermore, they fail to consider engineering feasibility constraints such as "directional smoothing" and "acute angle limitations." Summary of the Invention
[0004] This invention aims to provide a design method and system for underground pipe drainage in saline-alkali land, realizing full automation of the entire process from "water accumulation area identification → drainage point generation → grid model construction → multi-pipeline optimization design → smooth curve generation", thereby improving the scientific nature, constructability and salt removal effect of underground pipe layout.
[0005] To achieve the above objectives, the present invention adopts the following technical solution: A method for designing concealed drainage systems in saline-alkali land includes the following steps: Step 1: Image acquisition and preprocessing; The acquired farmland surface image is processed using semantic segmentation coordinates and region extraction. The extracted local images are then processed using a multi-dimensional fusion algorithm that includes filtering, adaptive threshold segmentation, and morphological operations to generate a binary mask image of the waterlogged area. Step 2: Generation of drainage points in the target area; For the generated binary Mask graph of the water accumulation area, calculate the area of different water accumulation areas in the graph based on connected component analysis, and use the area as a reference to automatically allocate the number of drainage points to each water accumulation area using the cosine density distribution function. Based on the number of drainage points, evenly set drainage points in each water accumulation area and extract the spatial coordinates of the drainage points. Step 3: Generate the cost field for path planning based on the cost image; Discretize the cost image into a two-dimensional grid, construct the node cost by combining the cost information of the cost image, and construct the edge cost based on the node cost and distance to form the cost field for path planning; Step 4: Shortest path driven multi-pipeline optimization algorithm; Based on the extracted spatial coordinates of the drainage points and the cost field of the path planning, the Dijkstra algorithm is first used to calculate the shortest path distance of each drainage point along the cost field. The drainage points are then automatically grouped according to whether the distance between the points exceeds a set threshold, so that each group generates an independent drainage pipeline. Subsequently, the drainage points within the group are arranged in the order of nearest neighbors, and the shortest path algorithm is called segment by segment to splice them into a continuous line. To avoid jagged or sharp angle turns, direction change penalties and reversal angle threshold constraints are added during the path search and splicing process, thereby obtaining multiple optimized pipelines with continuous shape, natural turns, and suitable for underground pipe laying. Step 5: Automatically group drainage points using different set thresholds, repeat shortest path driven multi-pipeline optimization, and output the optimal concealed pipe design scheme; convert the paths of different drainage groups into continuous curve segments, and output drainage point coordinates, path nodes and fitted curves.
[0006] A further improvement of this invention lies in the following: In step two, the area of the binary mask graph of the water accumulation area is calculated based on connected component analysis. Using the area as a reference, the number of drainage points is automatically allocated to the water accumulation area using a cosine density distribution function. Based on the number of drainage points, drainage points are uniformly set within the water accumulation area, and the spatial coordinates of the drainage points are extracted, including: Perform connected component labeling on the binary Mask graph of the waterlogged area to extract all independent waterlogged areas, with each connected component representing an independent waterlogged patch; For any connected region, the area of the water accumulation area is calculated by counting the number of effective pixels inside it, and this area is used as the basis for allocating the number of drainage points. The spatial coordinates of the drainage points were extracted using the K-means clustering algorithm.
[0007] A further improvement of this invention lies in using the K-means clustering algorithm to extract the spatial coordinates of the drainage points, including: K elements are randomly selected from the set of pixel coordinates of the waterlogged area as the initial cluster centers; Calculate the Euclidean distance from each sample point to each cluster center, and assign each sample point to the nearest cluster in turn. After all objects are assigned, update the K cluster center positions. The cluster centers are updated to the mean of all elements in each coordinate dimension within the cluster. Compared with the K cluster centers obtained in the previous calculation, if the cluster centers have changed, calculate the Euclidean distance from each sample point to each cluster center and assign it to the nearest cluster one by one; otherwise, proceed to the next step. When the cluster centers no longer change, stop and output the clustering results; output the spatial coordinates of all drainage points in text or image format.
[0008] A further improvement of this invention is that, in step three, generating the cost field for path planning based on the cost image includes: The cost image is discretized into a two-dimensional grid, and the node cost is constructed by combining the cost information of the cost image; By combining node costs and distances to construct edge costs, a cost field for path planning is formed.
[0009] A further improvement of this invention is that, in step four, the shortest path distance along the cost field for each drainage point is calculated using Dijkstra's algorithm, including: After constructing the cost field, Dijkstra's shortest path algorithm is used to search using path costs in graph theory as weights. For each drainage point, it is used as the source point, and Dijkstra's algorithm is executed once on the entire graph to obtain the minimum cumulative cost from the drainage point to all grid nodes. By reading the distance labels at the locations of other drainage points, the shortest path distance between any two drainage points can be obtained. If the predecessor node information of each node is recorded at the same time, the corresponding shortest path trajectory can be obtained by backtracking. The node sequence of the shortest path trajectory is the broken line direction of the dark pipe in the grid space.
[0010] A further improvement of this invention is that, in step four, the drainage points are automatically grouped according to whether the distance between points exceeds a threshold, including: Read the spatial coordinates of all drainage points, use the single-source shortest path solver module based on Dijkstra's algorithm to calculate the graph shortest path distance between any two drainage points, and construct the distance matrix; Select a preset distance threshold, establish adjacency relationships for the drainage point index set based on the distance matrix, and generate an undirected graph; Perform a depth-first search or breadth-first search on an undirected graph to extract all connected components. For a set of drainage points of a uniform connected component, define it as the same drainage group.
[0011] A concealed drainage system for saline-alkali land includes: Image acquisition and preprocessing unit: The acquired farmland surface image is processed using semantic segmentation coordinates and region extraction. The extracted local images are processed using a multi-dimensional fusion algorithm that includes filtering, adaptive threshold segmentation and morphological operations to generate a binary mask image of the waterlogged area. Drainage point generation unit for object area: For the generated binary Mask graph of water accumulation area, calculate the area of different water accumulation areas in the graph based on connected component analysis, and use the area as a reference to automatically allocate the number of drainage points for each water accumulation area using the cosine density distribution function. Based on the number of drainage points, drainage points are evenly set in each water accumulation area, and the spatial coordinates of the drainage points are extracted. Cost field units for path planning are generated from the cost image: the cost image is discretized into a two-dimensional grid, the cost information of the cost image is combined to construct the node cost, and the edge cost is constructed based on the node cost and distance to form a cost field for path planning; The shortest path-driven multi-pipeline optimization algorithm unit: Based on the extracted spatial coordinates of drainage points and the cost field of path planning, the Dijkstra algorithm is first used to calculate the shortest path distance of each drainage point along the cost field. Then, the drainage points are automatically grouped according to whether the distance between points exceeds a set threshold, so that each group generates an independent drainage pipeline. Subsequently, the drainage points within the group are arranged in the order of nearest neighbors, and the shortest path algorithm is called segment by segment to splice them into a continuous line. In order to avoid jagged or sharp angle turns, direction change penalties and reversal angle threshold constraints are added during the path search and splicing process, so as to obtain multiple optimized pipelines with continuous shape, natural turns, and suitable for underground pipe laying. The optimal concealed pipe design output unit automatically groups drainage points using different set thresholds, repeats shortest path-driven multi-pipeline optimization, and outputs the optimal concealed pipe design; it converts the paths of different drainage groups into continuous curve segments and outputs drainage point coordinates, path nodes, and fitted curves.
[0012] A further improvement of this invention lies in that, in the object region drainage point generation unit, the area of the binary mask graph of the water accumulation region is calculated based on connected component analysis, and the number of drainage points is automatically allocated to the water accumulation region using a cosine density distribution function, based on the area, and drainage points are uniformly set within the water accumulation region according to the number of drainage points, and the spatial coordinates of the drainage points are extracted, including: Perform connected component labeling on the binary Mask graph of the waterlogged area to extract all independent waterlogged areas, with each connected component representing an independent waterlogged patch; For any connected region, the area of the water accumulation area is calculated by counting the number of effective pixels inside it, and this area is used as the basis for allocating the number of drainage points. The spatial coordinates of the drainage points were extracted using the K-means clustering algorithm.
[0013] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the described method for designing a concealed drainage system for saline-alkali land.
[0014] Compared with the prior art, the present invention has at least the following beneficial technical effects: This invention provides a method and system for designing underground drainage systems in saline-alkali land. By introducing machine vision processing technology, it achieves automatic identification of waterlogged areas in farmland and intelligent generation of drainage points, avoiding the reliance on manual surveying and experience-based judgments in traditional methods. By constructing a cost grid model based on image grayscale features and combining algorithms such as multi-source shortest path, distance threshold clustering, and directional constraint optimization, this invention can automatically generate multiple independent and non-interfering underground pipe laying paths globally. Simultaneously, angle penalty and curve smoothing mechanisms ensure the continuity and constructability of the output pipelines, avoiding geometric shapes such as sharp angles and jagged edges that are unfavorable for on-site laying. Compared to traditional manual design schemes, this invention not only improves the rationality of underground pipe layout and engineering efficiency but also possesses scalability and adaptability, enabling dynamic adjustment of drainage schemes according to different plots and waterlogging distributions, thereby significantly improving farmland salinity drainage capacity and land use efficiency. Attached Figure Description
[0015] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0016] Figure 1 Figure showing the cost results of camouflage pipe laying under different thresholds; Figure 2 This is a distribution map of drainage points on a binary Mask plot of the waterlogged area; Figure 3 This is the distribution map of the first dark pipe path on the cost image; Figure 4 This is a distribution map of the first underground pipe path on a binary mask map of the waterlogged area. Figure 5 This is a distribution map of the second dark pipe path on the cost image; Figure 6 This is a distribution map of the second underground pipe path on a binary mask map of the waterlogged area. Figure 7 This is a distribution map of the third concealed pipe path on the cost image; Figure 8 This is a distribution map of the third underground pipe path on a binary mask map of the waterlogged area. Figure 9 This is a structural block diagram of a concealed pipe drainage design system for saline-alkali land according to the present invention. Detailed Implementation
[0017] In the following description, only certain exemplary embodiments are briefly described. As those skilled in the art will recognize, the described embodiments can be modified in various ways without departing from the spirit or scope of the invention. Therefore, the drawings and description are considered to be exemplary in nature and not restrictive.
[0018] In the description of this invention, it should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0019] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0020] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0021] The accompanying drawings illustrate various structural schematic diagrams according to embodiments disclosed in this invention. These drawings are not to scale, and some details have been enlarged for clarity, and some details may have been omitted. The shapes of the various regions and layers shown in the drawings, as well as their relative sizes and positional relationships, are merely exemplary and may deviate from reality due to manufacturing tolerances or technical limitations. Furthermore, those skilled in the art can design regions / layers with different shapes, sizes, and relative positions as needed.
[0022] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0023] Example 1 This invention provides a method for designing concealed drainage pipes in saline-alkali land, comprising the following steps: Step 1: Image Acquisition and Preprocessing. The specific implementation method is as follows: S1, the present invention uses a multi-feature fusion method based on image processing to extract the water accumulation area, including color space transformation, adaptive threshold segmentation, texture recognition and edge weakening.
[0024] S2, for the mask image obtained based on multi-feature fusion, area threshold filtering and morphological operations are used to perform small-area denoising and large-area hole filling to obtain a standardized mask image.
[0025] The aforementioned color space transformation specifically involves mapping a JPG image to the HSV color space to enhance the difference between waterlogged and non-waterlogged areas. Because waterlogged areas have lower brightness, weaker color saturation, and different reflective properties compared to soil areas, they have lower V and S values in the HSV color space.
[0026] The aforementioned adaptive threshold segmentation specifically involves using OTSU thresholding or adaptive Gaussian thresholding to identify water accumulation areas, ensuring robustness under different lighting conditions.
[0027] The texture recognition mentioned refers specifically to identifying low-complexity smooth regions in an image using the LBP method, which have image features consistent with those of waterlogged areas.
[0028] The edge weakening mentioned refers specifically to: using the Canny operator to detect weak edge regions that match the image features of water accumulation areas, thereby identifying the water accumulation areas.
[0029] The aforementioned multi-feature fusion method specifically involves weighted accumulation of color space transformation, adaptive threshold segmentation, texture recognition, and edge weakening, followed by binarization to obtain the final binary mask image.
[0030] The area threshold filtering mentioned refers to setting a minimum area threshold Smin and removing areas in the image smaller than Smin.
[0031] The morphological operation mentioned refers to using closing operations to fill small holes in a region and avoid noise interference.
[0032] Step 2: Generating drainage points in the target area. The specific implementation method is as follows: S1, Perform connected component labeling on the binary Mask graph of the water accumulation area generated in step one, and extract all independent water accumulation areas. Each connected component represents an independent water accumulation patch.
[0033] S2, for any connected region, calculate the water accumulation area by counting the number of effective pixels inside it, and use this area as the basis for allocating the number of drainage points.
[0034] S3 uses the K-means clustering algorithm to extract the spatial coordinates of the drainage points.
[0035] Specifically, the connected component labeling method mentioned above involves a cosine function-based area mapping formula to ensure a smooth increase in the number of drainage points with increasing area. This formula normalizes the area and maps it to the number of drainage points, which can then change smoothly with increasing area in a quasi-linear or weakly nonlinear manner. The formula is shown below:
[0036] in, Set the number of actual drainage points. , These represent the upper limit and lower limit of the number of drainage points, respectively. The value can be changed according to actual needs, and is limited by the maximum number of drainage points that can be deployed at one time. The normalized area value is calculated using the following formula:
[0037] in, J The collection of areas of water accumulation. The area of each waterlogged area, The area of the largest waterlogged area in each waterlogged area. The area of the smallest waterlogged area in each waterlogged area. This represents the number of areas with water accumulation.
[0038] This mechanism can automatically allocate more drainage points to large waterlogged areas and fewer drainage points to small waterlogged areas, thereby achieving "area-driven drainage point density control".
[0039] The extraction of spatial coordinates of drainage points, as mentioned above, specifically involves generating spatial coordinates of drainage points based on the pixel coordinates of each connected component. When only one drainage point is needed for a certain region, the centroid of the pixel coordinates in that region is used as the spatial coordinates of the drainage point. When multiple drainage points are needed, all pixel coordinates within the connected component are considered as a dataset, and the number of pre-allocated drainage points is used as the cluster number for K-means clustering. The K-means algorithm clusters pixels with the goal of minimizing the sum of squared intra-cluster distances, and the final converged cluster centers are the final spatial coordinates of the drainage points. The K-means algorithm flow is as follows: S1 randomly selects K elements from the set of pixel coordinates of the water accumulation area as the initial cluster centers; S2 calculates the Euclidean distance from each sample point to each cluster center, and assigns each sample point to the nearest cluster. After all objects in S3 are assigned, update the K cluster center positions. The cluster centers are updated to the mean of all elements in each coordinate dimension within the cluster. S4 compares the K cluster centers obtained in the previous calculation. If the cluster centers have changed, proceed to step 2; otherwise, proceed to step 5. S5 stops and outputs the clustering results when the cluster centers no longer change. The spatial coordinates of all drainage points are output as text or images, overlaid on the original mask image for visualization, facilitating manual verification.
[0040] The final generated result is as follows Figure 1 As shown.
[0041] Step 3: Generate the cost field for path planning based on the cost image. The specific implementation method is as follows: S1, discretize the cost image into a two-dimensional grid, and construct the node cost by combining the cost information of the cost image.
[0042] S2 constructs edge costs based on node costs and distances, forming a cost field for path planning.
[0043] The aforementioned node construction cost is specifically as follows: The cost image is discretized into a regular grid diagram, with each pixel corresponding to a grid node. The row and column indices of the nodes are consistent with the image coordinates. For each node, based on its construction cost information in the cost image, a node cost value representing the degree of laying difficulty is calculated. The formula is explained below: The cost image is discretized into a regular grid diagram, and the pixel coordinates are plotted as shown in the following formula:
[0044] in, H , W Image size, in pixels. V It is a set of pixel coordinates.
[0045] Define the node cost field using the cost graph:
[0046] in, for The node value of coordinates, The grayscale value of the cost image.
[0047] In this embodiment, normalized grayscale values are preferably used as node costs. Areas with higher brightness typically represent waterlogged, muddy, or low-lying areas, which have higher laying costs; areas with lower brightness typically have lower costs. If necessary, the accuracy of cost modeling can be further enhanced by using information such as multi-channel texture filters, soil salinity maps, and terrain slope maps.
[0048] The mentioned edge cost construction specifically involves: after constructing the node cost, establishing connections between adjacent nodes in the grid and calculating the edge cost. Specifically, each node is connected to its eight neighboring nodes, allowing the path to move in a straight line or diagonally. For any two adjacent nodes, the edge cost consists of two parts: first, the basic distance cost between the nodes, typically a unit distance (1 for straight lines, √2 for diagonals); second, a weighted average of the node costs, reflecting the difficulty of traversing that region. This implementation example uses a linear combination of the basic distance and node costs to form the final edge cost, thus making the path planning algorithm tend to avoid regions with higher costs, as shown in the formula below: Take the 8-neighborhood and the edge set. for:
[0049] in, These are the coordinates of the two endpoints of the edge.
[0050] Then the endpoint Corresponding edge cost for:
[0051] in,
[0052] in, As cost weight, This is the edge foundation length coefficient.
[0053] In some implementations, to further meet construction characteristics, actual engineering constraints can be introduced into the cost model. For example, by setting the cost of buildings, roads, or prohibited construction areas within the region to infinite, they can be automatically avoided in path planning; by adding additional costs to high-slope areas, excessive slope changes in underground pipes can be avoided; or by setting penalties for changes in direction, paths with large continuous turns can have higher costs, thus avoiding sawtooth or abrupt change structures.
[0054] By constructing the node costs and edge costs described above, a complete cost field can be formed. This cost field serves as the input to the shortest path search algorithm, providing a unified cost basis for subsequent multi-pipeline path planning.
[0055] Step 4: Shortest path driven multi-pipeline optimization algorithm. The specific implementation is as follows: S1, use Dijkstra's algorithm to calculate the shortest path distance along the cost field for each drainage point.
[0056] S2, and automatically group the drainage points according to whether the distance between the points exceeds the set threshold, so that each group generates an independent drainage pipeline.
[0057] S3, set the location constraints for the drainage ditch.
[0058] S4 sorts the drainage points within the group using a nearest neighbor greedy algorithm and performs local optimization using 2-opt. To avoid jagged or sharp-angle turns, a direction change penalty and a reversal angle threshold constraint are added during the path search and splicing process, thereby obtaining multiple optimized pipelines with continuous shapes, natural turns, and suitable for underground pipe laying.
[0059] The mentioned method of using Dijkstra's algorithm to calculate the shortest path distance along the cost field for each drainage point specifically involves: After constructing the cost field, Dijkstra's shortest path algorithm is used to search using path costs in a graph theory sense as weights. For each drainage point, it is used as the source point, and Dijkstra's algorithm is executed once on the entire graph to obtain the minimum cumulative cost from that drainage point to all cost nodes. By reading the distance labels at the locations of other drainage points, the shortest path distance between any two drainage points can be obtained. During this process, if the predecessor node information of each node is recorded simultaneously, the corresponding shortest path trajectory can be obtained by backtracking. The node sequence of this trajectory represents the broken line direction of the culvert in the cost field.
[0060] The mentioned automatic grouping of drainage points based on whether the distance between points exceeds a threshold, specifically: S1 reads the spatial coordinates of all drainage points, uses the single-source shortest path solver module based on Dijkstra's algorithm to calculate the graph shortest path distance between any two drainage points, and constructs a distance matrix.
[0061] S2 selects a preset distance threshold, establishes adjacency relationships for the drainage point index set based on the distance matrix, and generates an undirected graph.
[0062] S3 performs a depth-first search or breadth-first search on an undirected graph to extract all connected components. For a set of drainage points of a uniform connected component, it is defined as the same drainage group.
[0063] The formula is shown below: Set of drainage points :
[0064] in, The number of drainage points. For the first i Cost field coordinates of each drainage point; According to Dijkstra's shortest path algorithm, define two arbitrary drainage points. , In the cost field G Shortest path distance for:
[0065] in, for A feasible path. Through the above steps, construct... Symmetric distance matrix ,in:
[0066] It describes the distance between any pair of drainage connection points under cost constraints; Set threshold If there is If they are adjacent, then an undirected graph is constructed accordingly.
[0067] in, For the set of vertices, ,correspond index Let be the set of edges. For the graph Based on the concept of connectivity, the components are grouped, with each connectivity corresponding to a drainage group.
[0068] The aforementioned location constraints for the drainage ditch are specifically as follows: In this embodiment, the drainage channels are set as the straight edges on both sides of the image. The point with the closest vertical distance from the same drainage group to the two drainage channels (i.e., the two sides of the image edge) is taken as an extra point and added to the drainage group to participate in subsequent collaborative optimization.
[0069] The nearest neighbor greedy algorithm mentioned is specifically: Select the point with the smallest index from the drainage points within the group as the starting point, denoted as the current point. Form an "unvisited set" from all drainage points except the current point. In the unvisited set, find the point with the closest graph distance to the current point (graph distance is based on the distance matrix D constructed in step S3). Add this point to the visit sequence and remove it from the unvisited set. Then update the current point. When the unvisited set is empty, a complete initial visit sequence is obtained.
[0070] The 2-top local optimization mentioned above specifically includes: To further shorten the total path length and avoid significant detours, this embodiment introduces 2-opt local exchange optimization based on the initial sequence. The formula is shown below: For any access sequence , of which The sorted coordinates of the drainage points define the total cost:
[0071] In the sequence, select two non-adjacent edges, and their corresponding numbers are: :
[0072] By disconnecting and reversing, the middle segment Reverse join, to obtain a new access sequence ; like ; Then update for .
[0073] All possibilities By iterating through the above operations, the optimal access sequence can be obtained. .
[0074] The mentioned commutation angle threshold constraint is expressed in the following formula: Three points on the discrete path Its coordinates are:
[0075] Define forward and backward direction vectors for:
[0076] This is the reversal angle.
[0077] The maximum allowed turning angle threshold is preset to 90 degrees. During the path construction process, if a candidate path segment or path splicing results in a local turning angle that is less than the preset threshold (i.e., the turn is too sharp), it is determined that the connection method does not meet the directional continuity constraint. In the path search or splicing stage, it is backtracked and attempts to replace it with other adjacent nodes or path segments to reduce the local turning angle.
[0078] The penalty for changing direction mentioned is specifically: A direction change penalty term is introduced into the path cost evaluation to expand the total path cost, as shown in the following formula:
[0079] in, For the reversal penalty weight, For commutation penalty function In this embodiment,
[0080] Step 5: Repeat step 4 with multiple thresholds to output the optimal concealed pipe design scheme. The specific implementation method is as follows: Different thresholds were used to group the drainage points, resulting in different underground pipe laying paths. The optimal path was selected based on the minimum total cost index, i.e., the sum of the edge costs of the path. In this embodiment, the thresholds used were [80, 120, 160, 220]. The calculation results are as follows: Figure 2 As shown in the figure. After obtaining the access sequence optimized by 2-opt and direction constraints, this embodiment calls the graph shortest path search module one by one according to the adjacent drainage points in the sequence to obtain the corresponding discrete path segments, and splices them into a single continuous underground pipe path in sequence. The final display effect of the underground pipe path on the cost image and the binary mask map of the water accumulation area is shown in the figure. Figure 3-8 As shown.
[0081] Example 2 like Figure 9 As shown, the present invention provides a concealed drainage system for saline-alkali land, comprising: Image acquisition and preprocessing unit: The acquired farmland surface image is processed using semantic segmentation coordinates and region extraction. The extracted local images are processed using a multi-dimensional fusion algorithm that includes filtering, adaptive threshold segmentation and morphological operations to generate a binary mask image of the waterlogged area. Drainage point generation unit for object area: For the generated binary Mask graph of water accumulation area, calculate the area of different water accumulation areas in the graph based on connected component analysis, and use the area as a reference to automatically allocate the number of drainage points for each water accumulation area using the cosine density distribution function. Based on the number of drainage points, drainage points are evenly set in each water accumulation area, and the spatial coordinates of the drainage points are extracted. Cost field units for path planning are generated from the cost image: the cost image is discretized into a two-dimensional grid, the cost information of the cost image is combined to construct the node cost, and the edge cost is constructed based on the node cost and distance to form a cost field for path planning; The shortest path-driven multi-pipeline optimization algorithm unit: Based on the extracted spatial coordinates of drainage points and the cost field of path planning, the Dijkstra algorithm is first used to calculate the shortest path distance of each drainage point along the cost field. Then, the drainage points are automatically grouped according to whether the distance between points exceeds a set threshold, so that each group generates an independent drainage pipeline. Subsequently, the drainage points within the group are arranged in the order of nearest neighbors, and the shortest path algorithm is called segment by segment to splice them into a continuous line. In order to avoid jagged or sharp angle turns, direction change penalties and reversal angle threshold constraints are added during the path search and splicing process, so as to obtain multiple optimized pipelines with continuous shape, natural turns, and suitable for underground pipe laying. The optimal concealed pipe design output unit automatically groups drainage points using different set thresholds, repeats shortest path-driven multi-pipeline optimization, and outputs the optimal concealed pipe design; it converts the paths of different drainage groups into continuous curve segments and outputs drainage point coordinates, path nodes, and fitted curves.
[0082] In the object region drainage point generation unit of this embodiment, the area of the binary mask graph of the water accumulation region is calculated based on connected component analysis. Using the area as a reference, a cosine density distribution function is used to automatically allocate the number of drainage points to the water accumulation region. Based on the number of drainage points, drainage points are evenly set within the water accumulation region, and the spatial coordinates of the drainage points are extracted, including: Perform connected component labeling on the binary Mask graph of the waterlogged area to extract all independent waterlogged areas, with each connected component representing an independent waterlogged patch; For any connected region, the area of the water accumulation area is calculated by counting the number of effective pixels inside it, and this area is used as the basis for allocating the number of drainage points. The spatial coordinates of the drainage points were extracted using the K-means clustering algorithm.
[0083] In this embodiment, the spatial coordinates of the drainage points are extracted using the K-means clustering algorithm, including: K elements are randomly selected from the set of pixel coordinates of the waterlogged area as the initial cluster centers; Calculate the Euclidean distance from each sample point to each cluster center, and assign each sample point to the nearest cluster in turn. After all objects are assigned, update the K cluster center positions. The cluster centers are updated to the mean of all elements in each coordinate dimension within the cluster. Compared with the K cluster centers obtained in the previous calculation, if the cluster centers have changed, calculate the Euclidean distance from each sample point to each cluster center and assign it to the nearest cluster one by one; otherwise, proceed to the next step. When the cluster centers no longer change, stop and output the clustering results; output the spatial coordinates of all drainage points in text or image format.
[0084] Example 3 The present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of a concealed pipe drainage design method for saline-alkali land.
[0085] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0086] This application is described with reference to flowchart illustrations and / or block diagrams of methods, systems, and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A system that specifies functions in one or more boxes.
[0087] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0088] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0089] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered illustrative and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the scope of the invention. No reference numerals in the claims should be construed as limiting the scope of the claims.
[0090] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can be appropriately combined to form other embodiments that can be understood by those skilled in the art. The above content is only for illustrating the technical concept of the present invention and should not be construed as limiting the scope of protection of the present invention. Any modifications made based on the technical concept proposed in this invention shall fall within the scope of protection of the claims of this invention.
Claims
1. A design method of subsurface drainage for saline-alkali soil, characterized in that, The method comprises the following steps: Step one: image acquisition and preprocessing; the acquired farmland surface image is processed by using semantic segmentation coordinates and region extraction, and the extracted local picture is processed by using a multi-dimensional fusion algorithm comprising filtering, adaptive threshold segmentation and morphological operation to generate a binary mask image of the waterlogging area; Step two: object region drainage point generation; the binary mask image of the generated waterlogging area is processed based on connected component analysis to calculate the area of different waterlogging areas in the image, and the area is used as a reference basis to automatically assign the number of drainage points to each waterlogging area by using a cos-type density distribution function, and the number of drainage points is evenly set in each waterlogging area according to the number of drainage points, and the spatial coordinates of the drainage points are extracted; Step three: cost field for path planning is generated according to the cost image; the cost image is discretized into a two-dimensional grid, the node cost is constructed in combination with the cost information of the cost image, and the edge cost is constructed according to the node cost and the distance to form a cost field for path planning; Step four: multi-pipeline optimization algorithm driven by the shortest path; the spatial coordinates of the extracted drainage points and the cost field for path planning are processed, the shortest path distance of each drainage point along the cost field is calculated by using the Dijkstra algorithm, and the drainage points are automatically grouped according to whether the distance between the points exceeds a set threshold, so that an independent drainage pipeline is generated for each group; subsequently, the drainage points in the group are arranged in the order of nearest neighbor, and the shortest path algorithm is called in segments to splice to form a continuous line; in order to avoid the occurrence of jagged or sharp turning, a direction change penalty and a turning angle threshold constraint are added in the path search and splicing process, so that a plurality of optimized pipelines which are morphologically continuous and have natural turning and are suitable for buried pipe laying are obtained; Step five: different set thresholds are used to automatically group the drainage points, the multi-pipeline optimization algorithm driven by the shortest path is repeated, and the optimal buried pipe design scheme is output; the paths of different drainage groups are converted into continuous curve segments, and the drainage point coordinates, path nodes and fitted curves are output.
2. The method of claim 1, wherein, In step two, the area of the binary mask image of the waterlogging area is calculated based on connected component analysis, and the number of drainage points is automatically assigned to the waterlogging area by using a cos-type density distribution function according to the area, and the spatial coordinates of the drainage points are extracted by evenly setting the drainage points in the waterlogging area according to the number of drainage points, comprising: Performing connected component labeling on the binary mask image of the waterlogging area to extract all independent waterlogging areas, and each connected area represents an independent waterlogging patch; For any connected area, the number of effective pixels in the area is counted to calculate the area of the waterlogging area, and the area is used as a reference basis for assigning the number of drainage points; The spatial coordinates of the drainage points are extracted by using a K-means clustering algorithm.
3. The method of subsurface drainage design for saline-alkali soil according to claim 2, characterized in that, The spatial coordinates of the drainage points are extracted by using a K-means clustering algorithm, comprising: Randomly selecting K elements from the pixel coordinate set of the waterlogging area as initial cluster centers; Calculating the Euclidean distance between each sample point and each cluster center, and assigning each sample point to the nearest cluster; After all objects are assigned, update the positions of the K cluster centers, and the cluster centers are updated to the mean values of all elements in each coordinate dimension in the cluster; If the cluster centers change compared with the K cluster centers obtained in the previous calculation, calculate the Euclidean distance of each sample point to each cluster center respectively, and assign it to the nearest cluster one by one, otherwise, proceed to the next step; When the class center no longer changes, stop and output the clustering result; output the spatial coordinates of all drainage points in text or image form.
4. The method of claim 1, wherein the method comprises: In step three, the cost field of path planning is generated according to the cost image, including: Discretize the cost image into a two-dimensional grid, and construct node cost combining the cost information of the cost image; Combine node cost and distance to construct edge cost, thereby forming the cost field for path planning.
5. The method of claim 1, wherein the method comprises: In step four, the shortest path distance of each drainage point along the cost field is calculated by using Dijkstra algorithm, including: After the cost field is constructed, search using Dijkstra shortest path algorithm with path cost in graph theory as weight; for each drainage point, take it as a source point, and execute Dijkstra algorithm once for the whole graph to obtain the minimum cumulative cost from the drainage point to all grid nodes; by reading the distance label at the position of other drainage points, the shortest path distance between any two drainage points can be obtained; if the predecessor node information at each node update is recorded at the same time, the corresponding shortest path trajectory can be obtained by backtracking, and the node sequence of the shortest path trajectory is the polyline trend of the buried pipe in the grid space.
6. The method of subsurface drainage design for saline-alkali soil according to claim 5, characterized in that, In step four, the drainage points are automatically grouped according to whether the distance between points exceeds a threshold, including: Read the spatial coordinates of all drainage points, calculate the graph shortest path distance between any two drainage points using the single-source shortest path solving module based on Dijkstra algorithm, and construct a distance matrix; Select a preset distance threshold, establish adjacency relationship for the drainage point index set according to the distance matrix, and generate an undirected graph; Perform depth-first search or breadth-first search on the undirected graph, extract all connected components, and define the drainage point set in the same connected component as the same drainage group.
7. A subsurface pipe drainage design system for saline-alkali soil, characterized in that, Including: An image acquisition and preprocessing unit: using semantic segmentation coordinates and region extraction on the acquired farmland surface image, and using a multi-dimensional fusion algorithm including filtering, adaptive threshold segmentation and morphological operation to process the extracted local picture and generate a binary Mask image of water accumulation area; An object region drainage point generation unit: based on connected component analysis, calculating the area of different water accumulation regions in the generated binary Mask image of water accumulation area, and using a cos-type density distribution function to automatically assign the number of drainage points to each water accumulation region according to the area as a reference, setting drainage points in each water accumulation region according to the number of drainage points, and extracting the spatial coordinates of the drainage points; A unit for generating a cost field for path planning according to a cost image: discretize the cost image into a two-dimensional grid, construct node cost combining the cost information of the cost image, and construct edge cost according to node cost and distance, thereby forming a cost field for path planning. The shortest path driven multi-pipeline optimization algorithm unit: for the extracted spatial coordinates of the drainage points and the cost field of the path planning, firstly, the Dijkstra algorithm is used to calculate the shortest path distance of each drainage point along the cost field, and the drainage points are automatically grouped according to whether the distance between the points exceeds a set threshold, so that each group generates an independent drainage pipeline; subsequently, the drainage points in the group are arranged in the order of nearest neighbors, and the shortest path algorithm is called in segments to splice to form a continuous line; in order to avoid the occurrence of zigzag or sharp turning, a direction change penalty and a turning angle threshold constraint are added in the path search and splicing process, so that a plurality of optimized pipelines suitable for the laying of underground pipes are obtained, which are continuous in shape, natural in turning and suitable for the laying of underground pipes; The optimal underground pipe design scheme output unit: different set thresholds are used to automatically group the drainage points, and the shortest path driven multi-pipeline optimization is repeated to output the optimal underground pipe design scheme; the paths of different drainage groups are converted into continuous curve segments, and the drainage point coordinates, path nodes and fitted curves are output.
8. The subsurface drainage system for saline soil according to claim 7, wherein, In the object area drainage point generation unit, the area of the binary Mask graph of the waterlogging area is calculated based on connected component analysis, and the number of drainage points is automatically allocated to the waterlogging area by using a cos-type density distribution function as a reference, and the number of drainage points is used to set the drainage points in the waterlogging area uniformly, and the spatial coordinates of the drainage points are extracted, including: Performing connected component labeling on the binary Mask graph of the waterlogging area, extracting all independent waterlogging areas, and each connected area representing an independent waterlogging patch; For any connected area, the number of internal effective pixels is counted to calculate the area of the waterlogging area, and the area is used as the basis for allocating the number of drainage points; The spatial coordinates of the drainage points are extracted by using the K-means clustering algorithm.
9. The subsurface drainage design system for saline soils according to claim 8, wherein, The spatial coordinates of the drainage points are extracted by using the K-means clustering algorithm, including: Randomly selecting K elements from the pixel coordinate set of the waterlogging area as the initial cluster centers; Calculate the Euclidean distance of each sample point to each cluster center, and assign it to the nearest cluster one by one; After all the objects are assigned, update the positions of the K cluster centers, and the cluster centers are updated to the mean value of all elements in each coordinate dimension in the cluster; Compare the K cluster centers obtained in the previous calculation, if the cluster centers change, calculate the Euclidean distance of each sample point to each cluster center, and assign it to the nearest cluster one by one, otherwise go to the next step; When the class center no longer changes, stop and output the clustering result; output the spatial coordinates of all drainage points in the form of text or image.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the underground pipe drainage design method of the saline-alkali soil in any one of claims 1-6.