Valley-ridge line extraction method, electronic device, and storage medium
Patent Information
- Application Number
- CN202511328531.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-17
- Publication Date
- 2026-09-15
- Estimated Expiration
- 2045-09-17
AI Technical Summary
[0003]现有山谷山脊线提取方法主要是基于水文分析的方法,而水文分析法依赖汇流阈值,主要依据人工经验,缺乏地貌自适应机制,易造成次级地貌丢失,难以适用繁杂地形图的需要
本申请提供的一种山谷山脊线的提取方法、电子设备及存储介质,通过根据待提取区域的数字高程数据中的各像元以及各像元的高程值计算各像元的自适应高程阈值以及邻域平均高程值;与固定高程阈值相比,计算的各像元的自适应高程阈值能够根据不同地形区域的高程分布特性进行动态调整,从而提高地形特征识别的准确性与鲁棒性,并且,通过高程标准差确定的自适应高程阈值,能够有效捕获短小支脊、微型谷线等次级地形特征,更好地满足复杂的地形区山谷线和山脊线的需求。之后根据各像元的自适应高程阈值以及邻域平均高程值进行特征像元分析,对各像元进行类别识别,提升了地形特征识别精度,并且基于邻域平均高程值来判断山谷特征以及山脊特征,避免了分水岭分割法的水流模拟累积误差,能够更准确的判断山谷特征像元的位置以及山脊特征像元的位置,继而使得提取出来的山谷线以及山脊线更精确。又分别对提取出来的山谷线以及山脊线进行骨架化处理,将横跨多个像元宽度的山谷线以及横跨多个像元宽度的山脊线均细化为单像元宽度的骨架线,可以使得到的最终山谷线以及最终山脊线均是更精细的线条,进一步提升了山谷线以及山脊线的提取精度。另外,将栅格形式存储的山谷像元以及山脊像元转换为矢量形式存储,能够从端到端生成拓扑结构完备的矢量线,更有利于后续实际应用分析。
Smart Images

Figure CN121147240B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of geographic information technology, and more specifically, to a method for extracting valley ridgelines, an electronic device, and a storage medium. Background Technology
[0002] Ridge lines and valley lines are two important types of landform lines in geographical research. They are the dividing lines of topographic relief. Therefore, the extraction of ridge lines and valley lines is very important for geomorphological analysis.
[0003] Existing methods for extracting valley and ridge lines are mainly based on hydrological analysis. However, hydrological analysis relies on runoff thresholds and is largely based on human experience, lacking a geomorphological adaptive mechanism. This can easily lead to the loss of secondary geomorphological features and makes it unsuitable for complex topographic maps. Furthermore, the extracted valley and ridge lines have low accuracy, making it difficult to determine the precise location of valleys and ridges. Also, the output format is raster, while practical applications require vector data, and the raster-to-vector conversion process can easily lead to further loss of accuracy. Summary of the Invention
[0004] The purpose of this application is to address the shortcomings of the prior art by providing a method, electronic device, and storage medium for extracting valley ridgelines, thereby improving the accuracy of valley ridgeline extraction.
[0005] To achieve the above objectives, the technical solutions adopted in the embodiments of this application are as follows: In a first aspect, embodiments of this application provide a method for extracting valley ridgelines, the method comprising: Obtain digital elevation data of the area to be extracted, wherein the digital elevation data includes multiple pixels and the elevation value of each pixel; Calculate the adaptive elevation threshold and neighborhood average elevation value of each pixel based on each pixel and the elevation value of each pixel; Based on the adaptive elevation threshold of each pixel and the average elevation value of the neighborhood, terrain feature pixel analysis is performed to generate a valley binary feature map and a ridge binary feature map. The valley binary feature map includes an initial valley pixel and a background pixel, and the ridge binary feature map includes an initial ridge pixel and a background pixel. The binary feature maps of valleys and ridges are respectively processed into skeletonized maps to obtain a valley feature skeleton map and a ridge feature skeleton map. The valley feature skeleton map includes each target valley pixel after thinning, and the ridge feature skeleton map includes each target ridge pixel after thinning. The valley line vector is determined based on each target valley pixel in the valley feature skeleton map, and the ridge line vector is determined based on each target ridge pixel in the ridge feature skeleton map.
[0006] Optionally, the step of calculating the adaptive elevation threshold and neighborhood average elevation value of each pixel based on each pixel and the elevation value of each pixel includes: A local window for the pixel is determined, the local window including at least one window pixel; Based on the elevation values of each window cell within the local window, an adaptive elevation threshold for the cell is determined. The neighborhood average elevation value of the pixel is determined based on the elevation values of each window pixel within the local window and the weights of the convolution kernel.
[0007] Optionally, determining the adaptive elevation threshold of the pixel based on the elevation values of each window pixel within the local window includes: Calculate the average elevation based on the elevation values of each window cell; The square of the difference between each non-empty window pixel and the average elevation is calculated to obtain the first parameter of each non-empty window pixel; The sum of the first parameters of all the non-empty window pixels is divided by the total number of non-empty window pixels in the local window to obtain the second parameter. The root mean square of the second parameter is calculated to obtain the elevation standard deviation of the pixel. The elevation standard deviation is then multiplied by a preset value to obtain the adaptive elevation threshold of the pixel.
[0008] Optionally, determining the neighborhood average elevation value of a pixel based on the elevation values of each window pixel within the local window and the weights of the convolution kernel includes: The third parameter of each window pixel is obtained by multiplying the elevation value of each window pixel by the weight of the convolution kernel. The sum of the third parameters of all window cells is used as the neighborhood average elevation value of the cell.
[0009] Optionally, the step of performing terrain feature pixel analysis based on the adaptive elevation threshold of each pixel and the neighborhood average elevation value to determine the valley binary feature map and the ridge binary feature map includes: The fourth parameter of each pixel is obtained by summing the adaptive elevation threshold of each pixel with the neighborhood average elevation value of each pixel. The difference between the neighborhood average elevation value of each pixel and the adaptive elevation threshold of each pixel is calculated to obtain the fifth parameter of each pixel; Based on the elevation value, the fourth parameter, and the fifth parameter of each pixel, the category of each pixel is determined, and a valley binary feature map and a ridge binary feature map are generated based on the category of each pixel.
[0010] Optionally, determining the category of each pixel based on its elevation value, its fourth parameter, and its fifth parameter includes: If the elevation value of the pixel is greater than the fourth parameter of the pixel, then the pixel is determined to be a ridge feature pixel; If the elevation value of the pixel is less than the fifth parameter of the pixel, then the pixel is determined to be a valley feature pixel; If the elevation value of a pixel is less than or equal to the fourth parameter of the pixel and greater than or equal to the fifth parameter of the pixel, then the pixel is determined to be a background pixel, wherein the fourth parameter is greater than the fifth parameter.
[0011] Optionally, the process of skeletonizing the valley binary feature map and the ridge binary feature map to obtain the valley feature skeleton map and the ridge feature skeleton map respectively includes: Iteratively traverse each initial valley cell in the valley binary feature map, delete the initial valley cells that meet the first preset condition or the second preset condition, and use the valley binary feature map at the end of the iteration as the valley feature skeleton map. Iteratively traverse each initial ridge pixel in the binary feature map of the ridge, delete the initial ridge pixels that meet the first preset condition or the second preset condition, and use the binary feature map of the ridge at the end of the iteration as the ridge feature skeleton map.
[0012] Optionally, determining the valley line vector based on each target valley pixel in the valley feature skeleton map includes: Convert the row and column indices of each target valley cell into geographic coordinates; If a target valley pixel has only one neighboring pixel that is a valley feature pixel, then the target valley pixel is taken as the endpoint of the valley line vector. If the number of neighboring pixels of the target valley pixel that are valley feature pixels is greater than or equal to a preset number, then the target valley pixel is taken as the intersection point of the valley line vector.
[0013] Secondly, embodiments of this application also provide a device for extracting valley ridgelines, the device comprising: The acquisition module is used to acquire digital elevation data of the area to be extracted, wherein the digital elevation data includes multiple pixels and the elevation value of each pixel; The determination module is used to calculate the adaptive elevation threshold and the neighborhood average elevation value of each pixel based on each pixel and the elevation value of each pixel. The generation module is used to perform terrain feature pixel analysis based on the adaptive elevation threshold of each pixel and the neighborhood average elevation value, and generate a valley binary feature map and a ridge binary feature map. The valley binary feature map includes an initial valley pixel and a background pixel, and the ridge binary feature map includes an initial ridge pixel and a background pixel. The processing module is used to perform skeletonization processing on the binary feature map of the valley and the binary feature map of the ridge respectively to obtain the valley feature skeleton map and the ridge feature skeleton map. The valley feature skeleton map includes each target valley pixel after thinning, and the ridge feature skeleton map includes each target ridge pixel after thinning. The determination module is used to determine the valley line vector based on each target valley pixel in the valley feature skeleton map, and to determine the ridge line vector based on each target ridge pixel in the ridge feature skeleton map.
[0014] Optionally, the determining module is specifically used for: A local window for the pixel is determined, the local window including at least one window pixel; Based on the elevation values of each window cell within the local window, an adaptive elevation threshold for the cell is determined. The neighborhood average elevation value of the pixel is determined based on the elevation values of each window pixel within the local window and the weights of the convolution kernel.
[0015] Optionally, the determining module is specifically used for: Calculate the average elevation based on the elevation values of each window cell; The square of the difference between each non-empty window pixel and the average elevation is calculated to obtain the first parameter of each non-empty window pixel; The sum of the first parameters of all the non-empty window pixels is divided by the total number of non-empty window pixels in the local window to obtain the second parameter. The root mean square of the second parameter is calculated to obtain the elevation standard deviation of the pixel. The elevation standard deviation is then multiplied by a preset value to obtain the adaptive elevation threshold of the pixel.
[0016] Optionally, the determining module is specifically used for: The third parameter of each window pixel is obtained by multiplying the elevation value of each window pixel by the weight of the convolution kernel. The sum of the third parameters of all window cells is used as the neighborhood average elevation value of the cell.
[0017] Optionally, the generation module is specifically used for: The fourth parameter of each pixel is obtained by summing the adaptive elevation threshold of each pixel with the neighborhood average elevation value of each pixel. The difference between the neighborhood average elevation value of each pixel and the adaptive elevation threshold of each pixel is calculated to obtain the fifth parameter of each pixel; Based on the elevation value, the fourth parameter, and the fifth parameter of each pixel, the category of each pixel is determined, and a valley binary feature map and a ridge binary feature map are generated based on the category of each pixel.
[0018] Optionally, the generation module is specifically used for: If the elevation value of the pixel is greater than the fourth parameter of the pixel, then the pixel is determined to be a ridge feature pixel; If the elevation value of the pixel is less than the fifth parameter of the pixel, then the pixel is determined to be a valley feature pixel; If the elevation value of a pixel is less than or equal to the fourth parameter of the pixel and greater than or equal to the fifth parameter of the pixel, then the pixel is determined to be a background pixel, wherein the fourth parameter is greater than the fifth parameter.
[0019] Optionally, the processing module is specifically used for: Iteratively traverse each initial valley cell in the valley binary feature map, delete the initial valley cells that meet the first preset condition or the second preset condition, and use the valley binary feature map at the end of the iteration as the valley feature skeleton map. Iteratively traverse each initial ridge pixel in the binary feature map of the ridge, delete the initial ridge pixels that meet the first preset condition or the second preset condition, and use the binary feature map of the valley at the end of the iteration as the ridge feature skeleton map.
[0020] Optionally, the determining module is specifically used for: Convert the row and column indices of each target valley cell into geographic coordinates; If a target valley pixel has only one neighboring pixel that is a valley feature pixel, then the target valley pixel is taken as the endpoint of the valley line vector. If the number of neighboring pixels of the target valley pixel that are valley feature pixels is greater than or equal to a preset number, then the target valley pixel is taken as the intersection point of the valley line vector.
[0021] Thirdly, embodiments of this application also provide an electronic device, including: a processor, a storage medium, and a bus, wherein the storage medium stores program instructions executable by the processor, and when the application runs, the processor communicates with the storage medium via the bus, and the processor executes the program instructions to perform the steps of the valley ridgeline extraction method described in the first aspect above.
[0022] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which is read and executes the steps of the valley ridgeline extraction method described in the first aspect.
[0023] The beneficial effects of this application are: This application provides a method, electronic device, and storage medium for extracting valley and ridge lines. It calculates an adaptive elevation threshold and a neighborhood average elevation value for each pixel in the digital elevation data of the area to be extracted, based on the pixels and their elevation values. Compared to a fixed elevation threshold, the calculated adaptive elevation threshold can be dynamically adjusted according to the elevation distribution characteristics of different terrain regions, thereby improving the accuracy and robustness of terrain feature recognition. Furthermore, the adaptive elevation threshold determined by the elevation standard deviation can effectively capture secondary terrain features such as short ridges and micro-valley lines, better meeting the needs of valley and ridge lines in complex terrain areas. Subsequently, feature pixel analysis is performed based on the adaptive elevation threshold and neighborhood average elevation value of each pixel, classifying each pixel and improving the accuracy of terrain feature recognition. Furthermore, judging valley and ridge features based on the neighborhood average elevation value avoids the cumulative error of water flow simulation in watershed segmentation methods, enabling more accurate determination of the location of valley and ridge feature pixels, thus resulting in more precise extracted valley and ridge lines. Furthermore, the extracted valley and ridge lines were subjected to skeletonization processing. Valley and ridge lines spanning multiple pixel widths were refined into single-pixel-width skeleton lines, resulting in finer final lines and further improving extraction accuracy. Additionally, converting the raster-stored valley and ridge pixels into vector format enabled the generation of topologically complete vector lines from end-to-end, which is more beneficial for subsequent practical analysis. Attached Figure Description
[0024] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 A flowchart illustrating a method for extracting valley ridgelines provided in this application embodiment; Figure 2 A flowchart illustrating the second method for extracting valley ridgelines provided in this application embodiment; Figure 3A schematic diagram of a partial window provided in an embodiment of this application; Figure 4 A flowchart illustrating the third method for extracting valley ridgelines provided in this application embodiment; Figure 5 A flowchart illustrating the fourth method for extracting valley ridgelines provided in this application embodiment; Figure 6 A flowchart illustrating the fifth method for extracting valley ridgelines provided in this application embodiment; Figure 7 A schematic diagram of an apparatus for extracting valley ridgelines according to an embodiment of this application; Figure 8 This is a structural block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.
[0027] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0028] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.
[0029] Optionally, the valley ridgeline extraction method provided in this application embodiment can be applied to an electronic device, such as a mobile phone, tablet computer, laptop computer, PDA, desktop computer, or other terminal device with computing power and display function, or it can be a server. Specifically, it can be applied to applications in terminal devices, such as mobile phone applications (APP) and computer application systems.
[0030] The following is a detailed explanation of the specific implementation process for extracting valley ridgelines provided in the embodiments of this application.
[0031] Figure 1 This is a flowchart illustrating a method for extracting valley ridgelines provided in an embodiment of this application. The execution subject of this method is the aforementioned electronic device. Figure 1 As shown, the method includes: S101. Obtain the digital elevation data of the area to be extracted.
[0032] The digital elevation data may include multiple pixels and the elevation value of each pixel.
[0033] The area to be extracted can be a mountainous area, a hilly area, or other areas.
[0034] Optionally, the digital elevation data of the area to be extracted refers to the digital elevation model (DEM) data of the area to be extracted, which represents a digital model of the surface topography and is used to describe the elevation value of a certain point on the surface. The acquired digital elevation data of the area to be extracted is stored in a raster format, including multiple pixels, each pixel having a raster location (m, n) and an elevation value.
[0035] S102. Calculate the adaptive elevation threshold and neighborhood average elevation value of each pixel based on each pixel and its elevation value.
[0036] The adaptive elevation threshold refers to a reference elevation value dynamically calculated based on the local or overall statistical characteristics of digital elevation data, used for terrain feature identification, region segmentation, or classification. The adaptive elevation threshold can be dynamically adjusted according to the elevation distribution characteristics of different terrain regions.
[0037] The neighborhood average elevation value refers to the average elevation of pixels within a certain range surrounding a given pixel in digital elevation data. For each pixel in the digital elevation data, an adaptive elevation threshold and a neighborhood average elevation value can be calculated.
[0038] Specifically, the elevation standard deviation can be calculated using a local window method to generate an adaptive elevation threshold for each pixel, and a convolution algorithm can be used to calculate the neighborhood average elevation value for each pixel.
[0039] S103. Based on the adaptive elevation threshold of each pixel and the average elevation value of the neighborhood, perform feature pixel analysis to generate a valley binary feature map and a ridge binary feature map.
[0040] The valley binary feature map includes initial valley pixels and background pixels, while the ridge binary feature map includes initial ridge pixels and background pixels.
[0041] Optionally, pixel analysis specifically analyzes the category of the pixel, which may include: ridge feature pixels, valley feature pixels, and background pixels.
[0042] Optionally, feature pixel analysis can be performed on each pixel by combining the adaptive elevation threshold of each pixel and the average elevation value of its neighborhood, thereby determining the category of the pixel. After determining the category of each pixel, a binary feature map of valleys can be constructed based on all valley feature pixels and background pixels, and a binary feature map of ridges can be constructed based on all ridge feature pixels and background pixels. Furthermore, in the binary feature map of valleys, the values of each initial valley pixel belonging to the valley feature pixels can be set to 1, and the background pixels can be set to 0. The binary feature map of valleys can also include valley lines composed of multiple consecutive initial valley pixels. Similarly, in the binary feature map of ridges, the values of each initial ridge pixel belonging to the ridge feature pixels can be set to 1, and the background pixels can be set to 0. The binary feature map of ridges can also include ridge lines composed of multiple consecutive initial ridge pixels.
[0043] S104. Perform skeletonization processing on the binary feature maps of valleys and ridges respectively to obtain the feature skeleton maps of valleys and ridges.
[0044] The valley feature skeleton map includes the refined pixels of each target valley, and the ridge feature skeleton map includes the refined pixels of each target ridge.
[0045] Optionally, the width of the initial valley cell in the valley line of the valley binary feature map is a width spanning multiple pixels, meaning the valley line may be a thick line with a width of multiple pixels; similarly, the width of the initial ridge cell in the ridge line of the ridge binary feature map is a width spanning multiple pixels, meaning the ridge line may be a thick line with a width of multiple pixels. Therefore, the valley lines in the valley feature map can be skeletonized, that is, the thick valley lines can be thinned into skeleton lines with a width of one pixel. In other words, each initial valley cell is thinned to obtain each thinned target valley cell, and the width of the target valley cell is smaller than the width of the initial valley cell; similarly, the ridge lines in the ridge feature map can be skeletonized, that is, the thick ridge lines can be thinned into skeleton lines with a width of one pixel. In other words, each initial ridge cell is thinned to obtain each thinned target ridge cell, and the width of the target ridge cell is smaller than the width of the initial ridge cell.
[0046] S105. Determine the valley line vector based on each target valley pixel in the valley feature skeleton map, and determine the ridge line vector based on each target ridge pixel in the ridge feature skeleton map.
[0047] Optionally, since the target valley pixels in the obtained valley feature skeleton map are stored in raster form, converting the raster form of each target valley pixel into vector form yields the location information of each target valley pixel in the determined valley line vector. Similarly, since the target valley pixels in the obtained ridge feature skeleton map are stored in raster form, converting the raster form of each target ridge pixel into vector form yields the location information of each target ridge pixel in the determined ridge line vector.
[0048] In this embodiment, an adaptive elevation threshold and a neighborhood average elevation value are calculated for each pixel in the digital elevation data of the area to be extracted. Compared with a fixed elevation threshold, the calculated adaptive elevation threshold can be dynamically adjusted according to the elevation distribution characteristics of different terrain regions, thereby improving the accuracy and robustness of terrain feature recognition. Furthermore, the adaptive elevation threshold determined by the elevation standard deviation can effectively capture secondary terrain features such as short ridges and micro-valley lines, better meeting the needs of valley lines and ridge lines in complex terrain areas. Subsequently, feature pixel analysis is performed based on the adaptive elevation threshold and neighborhood average elevation value of each pixel to classify each pixel, improving the accuracy of terrain feature recognition. Moreover, judging valley and ridge features based on the neighborhood average elevation value avoids the cumulative error of water flow simulation in the watershed segmentation method, enabling more accurate determination of the location of valley and ridge feature pixels, thus making the extracted valley and ridge lines more precise. Furthermore, the extracted valley and ridge lines were subjected to skeletonization processing. Valley and ridge lines spanning multiple pixel widths were refined into single-pixel-width skeleton lines, resulting in finer final lines and further improving extraction accuracy. Additionally, converting the raster-stored valley and ridge pixels into vector format enabled the generation of topologically complete vector lines from end-to-end, which is more beneficial for subsequent practical analysis.
[0049] Figure 2 A flowchart illustrating the second method for extracting valley ridgelines provided in this application embodiment is shown below. Figure 2 As shown, S102 above, which calculates the adaptive elevation threshold and neighborhood average elevation value of each pixel based on each pixel and its elevation value, may include: S201. Determine the local window of the pixel.
[0050] The local window includes at least one window cell. Each cell in the digital elevation data is stored in raster form, and the local window is a k*k cell-sized local window centered on that cell. Figure 3 A schematic diagram of a partial window provided in an embodiment of this application, such as... Figure 3 As shown, a local window of size 3*3 is created with pixel P1 as the center. In addition to the window pixel centered on P1, the local window also includes other pixels adjacent to P1, such as pixels P2, P3, P4, P5, P6, P7, P8, and P9.
[0051] It is worth noting that, Figure 3The size of the local window in this embodiment is only one example, and other window sizes can also be set, which is not limited here.
[0052] For example, for cells at edge locations, such as Figure 3 In this context, cell P9 is located at the edge. Since there are no other cells to its left, top, bottom left, and top right, a local window is created for cell P9. The values of other cells in the created local window are the values of their adjacent cells. For example, the value of the cell to the left of P9 is the elevation value of cell P9, the value of the cell to the bottom left of P9 is the value of cell P8, the value of the cell to the top of P9 is the elevation value of cell P9, the value of the cell to the top right of P9 is the elevation value of cell P2, and so on, thus obtaining the local window for P9.
[0053] S202. Determine the adaptive elevation threshold of the pixels based on the elevation values of each pixel within the local window.
[0054] Specifically, the adaptive elevation threshold of a pixel can be calculated using the elevation standard deviation based on the elevation values of each window pixel within the local window of that pixel.
[0055] For example, the adaptive elevation threshold of pixel P1 can be calculated using the elevation standard deviation algorithm based on the elevation values of pixel P1, pixel P2, pixel P3, pixel P4, pixel P5, pixel P6, pixel P7, pixel P8, and pixel P9.
[0056] S203. Determine the neighborhood average elevation value of the pixel based on the elevation values of each window pixel within the local window and the weight of the convolution kernel.
[0057] Specifically, the average neighborhood elevation of a pixel can be calculated using a two-dimensional convolution algorithm based on the elevation values of all pixels within its local window and the weights of the convolution kernel. The weights of the convolution kernel vary depending on the pixel's position within the local window. Since different pixel positions are offset from the central pixel position, the kernel weights for the central pixel can also refer to the weights at different offsets. When the local window contains NoData values (i.e., when there are empty pixels within the local window), the kernel weights need to be dynamically adjusted. For example, if the local window size is 3×3 and all 9 pixels within the window contain elevation values (no NoData values), then the weight of the convolution kernel at each window pixel position can be set to 1 / 9; if one pixel in the 3×3 window has a NoData value, then the weight of the convolution kernel at each window pixel position is adjusted to 1 / 8; if two pixels in the 3×3 window have NoData values, then the weight of the convolution kernel at each window pixel position is adjusted to 1 / 7, and so on.
[0058] In this embodiment, by calculating the adaptive elevation threshold of each pixel, secondary terrain features such as short ridges and micro valley lines can be effectively captured, better meeting the needs of valley lines and ridge lines in complex terrain areas. Furthermore, the neighborhood average elevation value of a pixel can accurately characterize the average elevation state of the terrain within a specified neighborhood centered on that pixel, providing a reference surface for subsequent terrain feature identification.
[0059] Figure 4 A flowchart illustrating the third method for extracting valley ridgelines provided in this application embodiment is shown below. Figure 4 As shown, S202 above, determining the adaptive elevation threshold of a pixel based on the elevation values of each pixel within the local window, may include: S301. Calculate the average elevation value based on the elevation value of each window pixel, and calculate the square of the difference between each non-empty window pixel and the average elevation value to obtain the first parameter of each non-empty window pixel.
[0060] Among them, non-empty window cells refer to window cells within a local window whose elevation value is not a NoData value.
[0061] Specifically, you can first calculate the sum of the elevation values of all window cells, and then divide the sum of the elevation values by the total number of all window cells within the local window to obtain the average elevation. Calculate the squared difference between each window cell and the average elevation. Specifically, the first parameter of each non-empty window cell is... ,in, This represents the elevation value of each non-empty window pixel.
[0062] S302. Sum of the first parameters of all non-empty window pixels divided by the total number of non-empty window pixels in the local window to obtain the second parameter, and calculate the root mean square of the second parameter to obtain the elevation standard deviation of the pixel, and multiply the elevation standard deviation by a preset value to obtain the adaptive elevation threshold of the pixel.
[0063] The second parameter can be determined according to the formula. We obtain, where L is the total number of non-empty window pixels within the local window.
[0064] Specifically, the standard deviation of pixel elevation std can be obtained by the following formula (i).
[0065] std= Formula (1) in, Let be the elevation value of the i-th non-empty cell within the local window. L is the average elevation value, and L is the total number of non-empty window pixels within the local window.
[0066] The preset value can be 0.3. Multiplying the standard deviation of the pixel's elevation by 0.3 yields the adaptive elevation threshold for that pixel. =0.3 * std, where, This refers to the grid position of a pixel.
[0067] In this embodiment, the adaptive elevation threshold can dynamically change with the terrain undulation. In flat terrain areas, the adaptive elevation threshold of the pixel is small and the sensitivity is high; in areas with drastic terrain undulation, the adaptive elevation threshold of the pixel is large and the noise resistance is strong.
[0068] Optionally, in step S203 above, the neighborhood average elevation value of a pixel is determined based on the elevation values of each window pixel within the local window and the weight of each window pixel.
[0069] Optionally, the product of the elevation value of each window cell and the weight of the convolution kernel can be calculated to obtain the third parameter of each window cell; the sum of the third parameters of all window cells can be used as the neighborhood average elevation value of the cell.
[0070] The third parameter of each window pixel is determined according to the formula. get.
[0071] Specifically, the neighborhood average elevation value of each pixel can be obtained through the following formula (ii).
[0072] Formula (II) Where (i, j) refers to the grid position of the pixel, that is, the grid position of the central window pixel within the local window, s refers to the vertical offset of the pixel, and z refers to the horizontal offset of the pixel. refers to the weight of the convolution kernel at the offset , is the elevation value of the pixel (i, j) at the offset , is the average neighborhood elevation value of the pixel (i, j).
[0073] For example, as shown in Figure 3 , the P1 pixel is the central window pixel in the local window. When s=-1 and z=0, refers to the P2 pixel; when s=-1 and z=-1, refers to the P9 pixel.
[0074] Figure 5 is a schematic flow chart of the fourth valley and ridge line extraction method provided in the embodiment of the present application. As shown in Figure 5 , the above step S103 of performing feature pixel analysis according to the adaptive elevation threshold of each pixel and the average neighborhood elevation value to generate a valley binary feature map and a ridge binary feature map may include: S401: Calculate the sum of the adaptive elevation threshold of each pixel and the average neighborhood elevation value of each pixel to obtain a fourth parameter of each pixel.
[0075] Specifically, the fourth parameter of each pixel = , wherein refers to the raster row and column position of the pixel.
[0076] S402: Calculate the difference between the average neighborhood elevation value of each pixel and the adaptive elevation threshold of each pixel to obtain a fifth parameter of each pixel.
[0077] Specifically, the fifth parameter of each pixel = , wherein refers to the raster row and column position of the pixel, and the fourth parameter is greater than the fifth parameter.
[0078] S403: Determine the category of each pixel according to the elevation value of each pixel, the fourth parameter of each pixel and the fifth parameter of each pixel, and generate a valley binary feature map and a ridge binary feature map according to the category of each pixel.
[0079] Specifically, according to the elevation value of the pixel , the fourth parameter of the pixel and the fifth parameter of the pixel , a preset method is used to determine the category of the pixel at the raster position .
[0080] Optionally, after determining the category of each pixel, a binary feature map of valleys can be constructed based on all valley feature pixels and background pixels, and a binary feature map of ridges can be constructed based on all ridge feature pixels and background pixels.
[0081] Optionally, S403 above, determining the category of each pixel based on its elevation value, its fourth parameter, and its fifth parameter, may include: If the elevation value of a pixel is greater than the fourth parameter of the pixel, then the pixel is determined to be a ridge feature pixel. Specifically, if > When, the grid position is determined as The pixel at that location is classified as a ridge feature pixel.
[0082] If the elevation value of a pixel is less than the fifth parameter of the pixel, then the pixel is determined to be a valley feature pixel. Specifically, if... < When, the grid position is determined as The pixel at that location is classified as a valley feature pixel.
[0083] If the elevation value of a pixel is less than or equal to the fourth parameter of the pixel, and greater than or equal to the fifth parameter of the pixel, then the pixel is determined to be a background pixel. ≤ When, the grid position is determined as The pixel at that location is classified as a background pixel.
[0084] Figure 6 A flowchart illustrating the fifth method for extracting valley ridgelines provided in this application embodiment is shown below. Figure 6 As shown, S104 above performs skeletonization processing on the binary feature maps of valleys and ridges respectively, resulting in valley feature skeleton maps and ridge feature skeleton maps, which may include: S501. Iterate through each initial valley pixel in the valley binary feature map, delete the initial valley pixels that meet the first preset condition or the second preset condition, and use the valley binary feature map at the end of the iteration as the valley feature skeleton map.
[0085] Optionally, the first preset condition is 2<=N(p1)<=6 and S(P1)=1 and P2*P4*P6=0 and P4*P6*P8=0.
[0086] Optionally, the second preset condition is 2<=N(p1)<=6 and S(P1)=1 and P2*P4*P8=0 and P2*P6*P8=0.
[0087] Where N(p1) represents the number of valley feature pixels among the 8 pixels adjacent to P1; S(P1) represents the cumulative number of times the 0→1 change occurs in pixels P2~P9~P2, where 0 represents the background and 1 represents the valley feature pixel.
[0088] Optionally, after traversing the valley binary feature map once, each initial valley cell that meets the first or second preset condition is deleted to obtain a new valley binary feature map. The new valley binary feature map is then traversed again until there are no cells in the new valley binary feature map that meet the first or second preset condition. The iteration ends then, and the new valley binary feature map at the end of the iteration is used as the valley feature skeleton map. The obtained valley feature skeleton map is the skeleton of the valley binary image after thinning.
[0089] S502. Iterate through each initial ridge pixel in the binary feature map of the ridge, delete the initial ridge pixels that meet the first preset condition or the second preset condition, and use the binary feature map of the ridge at the end of the iteration as the obtained ridge feature skeleton map.
[0090] Optionally, the first preset condition is 2<=N(p1)<=6 and S(P1)=1 and P2*P4*P6=0 and P4*P6*P8=0.
[0091] Optionally, the second preset condition is 2<=N(p1)<=6 and S(P1)=1 and P2*P4*P8=0 and P2*P6*P8=0.
[0092] Where N(p1) represents the number of ridge feature pixels among the 8 pixels adjacent to P1; S(P1) represents the cumulative number of times the values of pixels P2~P9~P2 change from 0 to 1, where 0 represents the background and 1 represents the ridge feature pixel.
[0093] Optionally, after traversing the valley binary feature map once, each initial ridge pixel that meets the first or second preset condition is deleted to obtain a new ridge binary feature map. The new ridge binary feature map is then traversed again until there are no pixels in the new ridge binary feature map that meet the first or second preset condition. The iteration ends then, and the new ridge binary feature map at the end of the iteration is used as the ridge feature skeleton map. The obtained ridge feature skeleton map is the skeleton of the ridge binary image after thinning.
[0094] Optionally, S105 above, determining the valley line vector based on each target valley pixel in the valley feature skeleton map, may include: The row and column indices of each target valley cell are converted into geographic coordinates. If only one of the target valley cell's neighboring cells is a valley feature cell, then the target valley cell is used as the endpoint of the valley line vector. For example, if cell P1 is the target valley cell, and if only one of P1's neighboring cells, such as P2, P3, P4, P5, P6, P7, P8, and P9, is a valley feature cell, then P1 is the path endpoint, i.e., P1 is used as the endpoint of the valley line vector.
[0095] If the number of neighboring pixels of the target valley pixel that are valley feature pixels is greater than or equal to a preset number, then the target valley pixel is taken as the intersection point of the valley line vector. The preset number can be 3. For example, if pixel P1 is the target valley pixel, and if four of the neighboring pixels of P1, such as pixels P2, P3, P4, P5, P6, P7, P8, and P9, are valley feature pixels, then pixel P1 is the path intersection point, that is, pixel P1 is taken as the intersection point of the valley line vector.
[0096] Figure 7 A schematic diagram of an apparatus for extracting valley ridgelines provided in an embodiment of this application is shown below. Figure 7 As shown, the device includes: The acquisition module 601 is used to acquire digital elevation data of the area to be extracted, wherein the digital elevation data includes multiple pixels and the elevation value of each pixel; The determining module 602 is used to calculate the adaptive elevation threshold and the neighborhood average elevation value of each pixel based on each pixel and the elevation value of each pixel. The generation module 603 is used to perform terrain feature pixel analysis based on the adaptive elevation threshold of each pixel and the neighborhood average elevation value, and generate a valley binary feature map and a ridge binary feature map. The valley binary feature map includes an initial valley pixel and a background pixel, and the ridge binary feature map includes an initial ridge pixel and a background pixel. The processing module 604 is used to perform skeletonization processing on the binary feature map of the valley and the binary feature map of the ridge respectively to obtain the valley feature skeleton map and the ridge feature skeleton map. The valley feature skeleton map includes each target valley pixel after thinning, and the ridge feature skeleton map includes each target ridge pixel after thinning. The determining module 602 is used to determine the valley line vector based on each target valley pixel in the valley feature skeleton map, and to determine the ridge line vector based on each target ridge pixel in the ridge feature skeleton map.
[0097] Optionally, the determining module 602 is specifically used for: A local window for the pixel is determined, the local window including at least one window pixel; Based on the elevation values of each window cell within the local window, an adaptive elevation threshold for the cell is determined. The neighborhood average elevation value of the pixel is determined based on the elevation values of each window pixel within the local window and the weights of the convolution kernel.
[0098] Optionally, the determining module 602 is specifically used for: Calculate the average elevation based on the elevation values of each window cell; The square of the difference between each non-empty window pixel and the average elevation is calculated to obtain the first parameter of each non-empty window pixel; The sum of the first parameters of all the non-empty window pixels is divided by the total number of non-empty window pixels in the local window to obtain the second parameter. The root mean square of the second parameter is calculated to obtain the elevation standard deviation of the pixel. The elevation standard deviation is then multiplied by a preset value to obtain the adaptive elevation threshold of the pixel.
[0099] Optionally, the determining module 602 is specifically used for: The third parameter of each window pixel is obtained by multiplying the elevation value of each window pixel by the weight of the convolution kernel. The sum of the third parameters of all window cells is used as the neighborhood average elevation value of the cell.
[0100] Optionally, the 603 generation module is specifically used for: The fourth parameter of each pixel is obtained by summing the adaptive elevation threshold of each pixel with the neighborhood average elevation value of each pixel. The difference between the neighborhood average elevation value of each pixel and the adaptive elevation threshold of each pixel is calculated to obtain the fifth parameter of each pixel; Based on the elevation value, the fourth parameter, and the fifth parameter of each pixel, the category of each pixel is determined, and a valley binary feature map and a ridge binary feature map are generated based on the category of each pixel.
[0101] Optionally, the generation module 603 is specifically used for: If the elevation value of the pixel is greater than the fourth parameter of the pixel, then the pixel is determined to be a ridge feature pixel; If the elevation value of the pixel is less than the fifth parameter of the pixel, then the pixel is determined to be a valley feature pixel; If the elevation value of a pixel is less than or equal to the fourth parameter of the pixel and greater than or equal to the fifth parameter of the pixel, then the pixel is determined to be a background pixel, wherein the fourth parameter is greater than the fifth parameter.
[0102] Optionally, the processing module 604 is specifically used for: Iteratively traverse each initial valley cell in the valley binary feature map, delete the initial valley cells that meet the first preset condition or the second preset condition, and use the valley binary feature map at the end of the iteration as the valley feature skeleton map. Iteratively traverse each initial ridge pixel in the binary feature map of the ridge, delete the initial ridge pixels that meet the first preset condition or the second preset condition, and use the binary feature map of the ridge at the end of the iteration as the ridge feature skeleton map.
[0103] Optionally, the determining module 602 is specifically used for: Convert the row and column indices of each target valley cell into geographic coordinates; If a target valley pixel has only one neighboring pixel that is a valley feature pixel, then the target valley pixel is taken as the endpoint of the valley line vector. If the number of neighboring pixels of the target valley pixel that are valley feature pixels is greater than or equal to a preset number, then the target valley pixel is taken as the intersection point of the valley line vector.
[0104] Figure 8 This is a structural block diagram of an electronic device 700 provided in an embodiment of this application. (See diagram below.) Figure 8 As shown, the electronic device may include: a processor 701 and a memory 702.
[0105] Optionally, a bus 703 may also be included, wherein the memory 702 is used to store machine-readable instructions executable by the processor 701. When the electronic device 700 is running, the processor 701 and the memory 702 communicate via the bus 703. When the machine-readable instructions are executed by the processor 701, the method steps in the above method embodiments are performed.
[0106] This application also provides a computer-readable storage medium storing a computer program, which, when run by a processor, executes the method steps described in the above-described method for extracting valley ridgelines.
[0107] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the method embodiments, and will not be repeated here. In the several embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces; the indirect coupling or communication connection of devices or modules may be electrical, mechanical, or other forms.
[0108] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.
[0109] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A method for extracting valley ridgelines, characterized in that, The method includes: Obtain digital elevation data of the area to be extracted, wherein the digital elevation data includes multiple pixels and the elevation value of each pixel; Calculate the adaptive elevation threshold and neighborhood average elevation value of each pixel based on each pixel and the elevation value of each pixel; Based on the adaptive elevation threshold of each pixel and the average elevation value of the neighborhood, terrain feature pixel analysis is performed to generate a valley binary feature map and a ridge binary feature map. The valley binary feature map includes an initial valley pixel and a background pixel, and the ridge binary feature map includes an initial ridge pixel and a background pixel. The binary feature maps of valleys and ridges are respectively processed into skeletonized maps to obtain a valley feature skeleton map and a ridge feature skeleton map. The valley feature skeleton map includes each target valley pixel after thinning, and the ridge feature skeleton map includes each target ridge pixel after thinning. The valley line vector is determined based on each target valley pixel in the valley feature skeleton map, and the ridge line vector is determined based on each target ridge pixel in the ridge feature skeleton map.
2. The method for extracting valley ridgelines according to claim 1, characterized in that, The step of calculating the adaptive elevation threshold and neighborhood average elevation value of each pixel based on each pixel and the elevation value of each pixel includes: A local window for the pixel is determined, the local window including at least one window pixel; Based on the elevation values of each window cell within the local window, an adaptive elevation threshold for the cell is determined. The neighborhood average elevation value of the pixel is determined based on the elevation values of each window pixel within the local window and the weights of the convolution kernel.
3. The method for extracting valley ridgelines according to claim 2, characterized in that, The step of determining the adaptive elevation threshold of a pixel based on the elevation values of each window pixel within the local window includes: Calculate the average elevation based on the elevation values of each window cell; The square of the difference between each non-empty window pixel and the average elevation is calculated to obtain the first parameter of each non-empty window pixel; The sum of the first parameters of all the non-empty window pixels is divided by the total number of non-empty window pixels in the local window to obtain the second parameter. The root mean square of the second parameter is calculated to obtain the elevation standard deviation of the pixel. The elevation standard deviation is then multiplied by a preset value to obtain the adaptive elevation threshold of the pixel.
4. The method for extracting valley ridgelines according to claim 2, characterized in that, The step of determining the neighborhood average elevation value of a pixel based on the elevation values of each window pixel within the local window and the weights of the convolution kernel includes: The third parameter of each window pixel is obtained by multiplying the elevation value of each window pixel by the weight of the convolution kernel. The sum of the third parameters of all window cells is used as the neighborhood average elevation value of the cell.
5. The method for extracting valley ridgelines according to claim 1, characterized in that, The step of performing terrain feature pixel analysis based on the adaptive elevation threshold of each pixel and the average elevation value of the neighborhood to determine the binary feature map of the valley and the binary feature map of the ridge includes: The fourth parameter of each pixel is obtained by summing the adaptive elevation threshold of each pixel with the neighborhood average elevation value of each pixel. The difference between the neighborhood average elevation value of each pixel and the adaptive elevation threshold of each pixel is calculated to obtain the fifth parameter of each pixel; Based on the elevation value, the fourth parameter, and the fifth parameter of each pixel, the category of each pixel is determined, and a valley binary feature map and a ridge binary feature map are generated based on the category of each pixel.
6. The method for extracting valley ridgelines according to claim 5, characterized in that, The step of determining the category of each pixel based on its elevation value, its fourth parameter, and its fifth parameter includes: If the elevation value of the pixel is greater than the fourth parameter of the pixel, then the pixel is determined to be a ridge feature pixel; If the elevation value of the pixel is less than the fifth parameter of the pixel, then the pixel is determined to be a valley feature pixel; If the elevation value of a pixel is less than or equal to the fourth parameter of the pixel and greater than or equal to the fifth parameter of the pixel, then the pixel is determined to be a background pixel, wherein the fourth parameter is greater than the fifth parameter.
7. The method for extracting valley ridgelines according to claim 1, characterized in that, The process of skeletonizing the binary feature maps of the valleys and ridges to obtain the valley feature skeleton map and the ridge feature skeleton map includes: Iteratively traverse each initial valley cell in the valley binary feature map, delete the initial valley cells that meet the first preset condition or the second preset condition, and use the valley binary feature map at the end of the iteration as the valley feature skeleton map. Iteratively traverse each initial ridge pixel in the binary feature map of the ridge, delete the initial ridge pixels that meet the first preset condition or the second preset condition, and use the binary feature map of the ridge at the end of the iteration as the ridge feature skeleton map.
8. The method for extracting valley ridgelines according to claim 1, characterized in that, The step of determining the valley line vector based on each target valley pixel in the valley feature skeleton map includes: Convert the row and column indices of each target valley cell into geographic coordinates; If a target valley pixel has only one neighboring pixel that is a valley feature pixel, then the target valley pixel is taken as the endpoint of the valley line vector. If the number of neighboring pixels of the target valley pixel that are valley feature pixels is greater than or equal to a preset number, then the target valley pixel is taken as the intersection point of the valley line vector.
9. An electronic device, characterized in that, It includes a memory and a processor, the memory storing a computer program executable by the processor, and the processor executing the computer program to implement the steps of the valley ridgeline extraction method according to any one of claims 1-8.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the valley ridgeline extraction method as described in any one of claims 1-8.
Citation Information
Patent Citations
Power transmission line easy-icing micro-terrain classification method
CN113688903A
Hill terrain feature line extraction method and hill land DEM refined production method
CN114596490A