Anti-occlusion farmland road extraction method and device, equipment and medium
By using the improved DeepLabv3+ network, employing MobileNetV2 and normalized attention mechanisms, and combining content-aware feature recombination and morphological closing operations, the problems of boundary ambiguity, occlusion interference, and quantization in the extraction of roads in high-standard farmland were solved, enabling rapid and automated road detection and acceptance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENYANG AGRI UNIV
- Filing Date
- 2026-04-16
- Publication Date
- 2026-08-04
AI Technical Summary
Existing technologies for extracting roads in high-standard farmland suffer from problems such as thin, elongated strip distribution leading to blurred boundaries, broken sections, severe interference from shadows and obstructions, difficulty in achieving continuous and quantitative output, large model parameters, and low inference efficiency, failing to meet the needs of rapid batch detection.
The Xception backbone network is replaced by MobileNetV2 network. A normalized attention mechanism and a content-aware feature recombination upsampling module are introduced. Combined with morphological closing operation, the road centerline skeleton is extracted and quantized to output a complete and continuous farmland road topology network.
It significantly improves the robustness and speed of farmland road extraction, directly outputs the quantitative indicators required for project acceptance, realizes full-process automation from image to indicator, and reduces reliance on manual labor and time costs.
Smart Images

Figure CN122510718A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing, and in particular to a method, apparatus, electronic device and computer-readable storage medium for extracting farmland roads with anti-occlusion capabilities. Background Technology
[0002] After the construction of high-standard farmland is completed, it is necessary to inspect and verify the engineering indicators such as the scope, width, and accessibility of field roads. Current work usually relies on manual inspections, sampling measurements, and paper records, which has problems such as limited coverage and low efficiency.
[0003] Unmanned aerial vehicles (UAVs) equipped with visible light sensors can quickly acquire high-resolution orthophotos of farmland areas, offering advantages such as wide coverage, high acquisition efficiency, and excellent spatial resolution, providing a solid data foundation for the automated identification and extraction of field roads. Existing road extraction technologies mainly fall into two categories: one is traditional image processing methods based on threshold segmentation, texture analysis, morphological operations, and manually designed features; the other is deep learning methods based on semantic segmentation networks, with typical examples including U-Net, PSPNet, and DeepLabv3+.
[0004] Currently, while deep learning methods based on semantic segmentation networks can achieve pixel-level road recognition and significantly outperform traditional image processing methods in feature extraction, they still have the following technical shortcomings when applied to high-standard farmland road scenarios:
[0005] Firstly, field roads are mostly long and narrow strips, which can easily lead to problems such as blurred boundaries and broken sections after network sampling, making it difficult to ensure the continuity of road extraction.
[0006] Secondly, occlusions such as shadows, tree canopies, and crops can severely weaken road features, leading to gaps and breaks in the extraction results, and insufficient resistance to interference.
[0007] Third, most existing solutions only output road segmentation masks and cannot directly generate quantitative engineering indicators such as road width and road network connectivity required for acceptance. Additional post-processing calculations are required, and the "extraction-acceptance" integration cannot be achieved.
[0008] Fourth, some deep learning models have a large number of parameters and low inference efficiency, making them difficult to adapt to the needs of rapid batch detection of large-scale farmland images, thus limiting their practical application.
[0009] In summary, existing technologies often result in long, narrow strips of field roads, which are prone to blurred boundaries and broken sections after network downsampling. Furthermore, shading, tree canopies, and crops can severely weaken road features, leading to gaps, broken links, and insufficient anti-interference capabilities in the extraction results. To address these issues, the applicant has made corresponding explorations. Summary of the Invention
[0010] The purpose of this application is to solve the above-mentioned problems by providing a method, device, electronic device and computer-readable storage medium for extracting farmland roads that are not obstructed.
[0011] To achieve the various objectives of this application, the following technical solution is adopted:
[0012] A method for extracting farmland roads with anti-shading capability, proposed to meet one of the purposes of this application, includes:
[0013] Acquire images of farmland to be segmented, collected by drones, which include multiple sections of farmland roads;
[0014] The Xception backbone network in the encoder of the first farmland road segmentation model is replaced with the MobileNetV2 network. Normalized attention mechanism modules are introduced after the MobileNetV2 network, after the dilated convolutional layer in the dilated spatial pyramid pooling module, and after the convolutional layer in the decoder. The nearest neighbor interpolation upsampling module in the decoder is replaced with a content-aware feature reorganization upsampling module to construct the second farmland road segmentation model.
[0015] The farmland image to be segmented is input into the second farmland road segmentation model that has been trained to convergence, and the pixel-level mask image corresponding to each segment of farmland road is output.
[0016] Morphological closing operations are performed on the pixel-level mask image to fill in the road discontinuity areas caused by occlusion. Based on the pixel-level mask image after morphological closing operations, the single-pixel-width road centerline skeleton corresponding to each segment of farmland road is extracted. The road centerline skeleton corresponding to each segment of farmland road is then denoised, pruned, and its endpoints are bridged to obtain a continuous road centerline skeleton.
[0017] Based on the continuous road centerline skeleton, road connectivity quantification and road width quantification are performed to determine the road quantification results. The road structure is then optimized and corrected according to the road quantification results to output a complete and continuous farmland road topology network.
[0018] Optionally, the basic network architecture of the first farmland road segmentation model is the original DeepLabv3+ network; the basic network architecture of the second farmland road segmentation model is the improved DeepLabv3+ network.
[0019] Optionally, the step of inputting the farmland image to be segmented into a second farmland road segmentation model that has been trained to convergence, and outputting pixel-level mask images corresponding to each segment of farmland road, includes:
[0020] The farmland image to be segmented is input into the encoder of the second farmland road segmentation model that has been trained to convergence. The MobileNetV2 network in the encoder performs feature extraction to obtain the intermediate feature map of the first encoder.
[0021] The intermediate feature map of the first encoder is input into the normalized attention mechanism module for road feature enhancement to obtain the intermediate feature map of the second encoder.
[0022] The intermediate feature map of the second encoder is input into the hollow spatial pyramid pooling module in the encoder, and multi-scale context information is aggregated sequentially through hollow convolutional layers with different hollow rates to obtain multi-scale intermediate feature maps.
[0023] The multi-scale intermediate feature maps corresponding to each dilated convolutional layer are input into the normalized attention mechanism module to suppress shadow and occlusion interference, and the enhanced multi-scale intermediate feature maps are obtained.
[0024] The enhanced multi-scale intermediate feature maps are fused to obtain the road feature map output by the encoder.
[0025] Optionally, after fusing the enhanced multi-scale intermediate feature maps to obtain the road feature map output by the encoder, the method includes:
[0026] The road feature map output by the encoder is input into the decoder of the second farmland road segmentation model that has been trained to convergence. The resolution is restored and the features are reconstructed through the content-aware feature reconstruction and upsampling module to obtain the intermediate feature map of the first decoder.
[0027] The intermediate feature map of the first decoder is combined with the low-level detail features corresponding to the farmland image to be segmented by channel stitching and fusion to obtain a stitched feature map. The stitched feature map is then subjected to convolution processing in sequence to obtain the intermediate feature map of the second decoder.
[0028] The intermediate feature map of the second decoder is input into the normalized attention mechanism module to enhance the road boundary features, resulting in a boundary enhanced feature map.
[0029] Content-aware feature recombination upsampling is performed on the boundary enhancement feature map to obtain a high-resolution road feature map. Based on the high-resolution road feature map, pixel-level classification is performed to output a pixel-level mask image corresponding to the farmland road.
[0030] Optionally, the steps of performing morphological closing operations on the pixel-level mask image to fill in road discontinuities caused by occlusion, extracting the single-pixel-width road centerline skeleton corresponding to each segment of farmland road based on the pixel-level mask image after morphological closing operations, and performing denoising, pruning, and endpoint bridging on the road centerline skeleton corresponding to each segment of farmland road to obtain a continuous road centerline skeleton include:
[0031] Morphological closing operations are performed on the pixel-level mask images corresponding to each section of farmland road to fill in the narrow gaps and small gaps in the road caused by forest belts and canopies, eliminate non-real road discontinuities, and obtain continuous road mask images.
[0032] Based on the continuous road mask image, a single-pixel-wide road centerline skeleton is extracted, and the road centerline skeleton is denoised and pruned to remove burrs and false detection noise.
[0033] Endpoint detection is performed on the denoised and pruned road centerline skeleton. Distance constraints for endpoint association are set based on the maximum road width. Only when the Euclidean distance between the two endpoints of the road centerline skeleton satisfies the condition that the distance between the asphalt road and the distance between the concrete road and the gravel road does not exceed the first preset distance, it is determined that the two endpoints of the road centerline skeleton belong to the same road segment and are partially interrupted due to occlusion. They are then bridged to restore the short-distance discontinuity caused by occlusion and suppress false connections across roads, thus obtaining the continuous road centerline skeleton.
[0034] Optionally, the step of performing road connectivity quantization and road width quantization based on the continuous road centerline skeleton to determine the road quantization result includes:
[0035] Perform Euclidean distance transformation on the road segmentation mask corresponding to the continuous road centerline skeleton, obtain the distance value of each pixel in the image to the nearest road mask boundary, and generate a distance transformation map;
[0036] Select skeleton sampling points on the continuous road centerline skeleton, read the nearest boundary distance from each skeleton sampling point to the nearest road mask boundary from the distance transformation map, and take the maximum inscribed circle diameter at the skeleton sampling point as the local road width. Take the average of the local road widths of all skeleton sampling points in the same road segment to obtain the estimated pixel width of the road segment.
[0037] The estimated pixel width is converted into the actual road width based on the image ground resolution, and the actual road width is used as the road width quantification result of the farmland road topology network.
[0038] Optionally, the step of performing road connectivity quantization and road width quantization based on the continuous road centerline skeleton to determine the road quantization result includes:
[0039] All skeleton pixels in the continuous road centerline skeleton are constructed into a graph node set, and an undirected edge set is established between the nodes according to the neighborhood adjacency relationship to construct an undirected graph.
[0040] The undirected graph is decomposed into connected components to obtain the number of connected components. The largest connected component with the most nodes is extracted, and the connectivity index of the farmland road topology network is calculated based on the node ratio of the largest connected component. The connectivity index is used as the quantitative result of the road connectivity of the farmland road topology network.
[0041] By integrating the road width quantification results and the road connectivity quantification results, the road structure is optimized and corrected to output a complete and continuous farmland road topology network.
[0042] A device for extracting farmland roads that resists shading, provided for another purpose of this application, includes:
[0043] The farmland image acquisition module is set to acquire farmland images to be segmented, which are collected by drones and contain multiple segments of farmland roads;
[0044] The road segmentation model construction module is configured to replace the Xception backbone network in the encoder of the first farmland road segmentation model with the MobileNetV2 network, introduce a normalized attention mechanism module after the MobileNetV2 network, after the dilated convolutional layer in the dilated spatial pyramid pooling module, and after the convolutional layer in the decoder, and replace the nearest neighbor interpolation upsampling module in the decoder with a content-aware feature reorganization upsampling module to construct the second farmland road segmentation model.
[0045] The road mask output module is configured to input the farmland image to be segmented into the second farmland road segmentation model that has been trained to convergence, and output the pixel-level mask image corresponding to each segment of farmland road;
[0046] The road centerline determination module is configured to perform morphological closing operations on the pixel-level mask image to fill the road discontinuity areas caused by occlusion, extract the single-pixel-width road centerline skeleton corresponding to each segment of farmland road based on the pixel-level mask image after morphological closing operations, and perform noise reduction, pruning and endpoint bridging on the road centerline skeleton corresponding to each segment of farmland road to obtain a continuous road centerline skeleton.
[0047] The target road determination module is configured to perform road connectivity quantification and road width quantification based on the continuous road centerline skeleton to determine the road quantification result, and optimize and correct the road structure according to the road quantification result to output a complete and continuous farmland road topology network.
[0048] An electronic device provided for another purpose of this application includes a central processing unit and a memory, the central processing unit being configured to invoke and run a computer program stored in the memory to perform the steps of the anti-shading farmland road extraction method of this application.
[0049] A computer-readable storage medium is provided for another purpose of this application, which stores, in the form of computer-readable instructions, a computer program implemented according to the anti-shading farmland road extraction method, which, when invoked by a computer, executes the steps included in the corresponding method.
[0050] Compared to existing technologies, this application addresses the problems in existing technologies where field roads are often distributed in a long, narrow strip, which easily leads to blurred boundaries, broken sections, and other issues after network downsampling. Furthermore, occlusion by shadows, tree canopies, and crops severely weakens road features, resulting in hollow or broken extraction results and insufficient anti-interference capabilities. This application offers the following beneficial effects, including but not limited to:
[0051] Firstly, the improved DeepLabv3+ network in this application replaces the Xception backbone network with the MobileNetV2 network, which significantly reduces the number of model parameters and computational overhead. While ensuring segmentation accuracy, it significantly improves the processing speed of large-scale UAV farmland images, meeting the needs of rapid batch detection in engineering sites.
[0052] Secondly, the improved DeepLabv3+ network in this application introduces a normalized attention mechanism module after the MobileNetV2 network, after the dilated convolutional layer in the dilated spatial pyramid pooling module, and after the convolutional layer in the decoder. This can effectively enhance road features, suppress interference caused by shadows, tree canopies, and crop occlusion, reduce false negatives and false positives, and improve the robustness of road extraction in complex farmland scenarios.
[0053] Third, the improved DeepLabv3+ network in this application replaces the traditional nearest neighbor interpolation upsampling module with a content-aware feature recombination upsampling module, which aggregates contextual information in a larger receptive field, effectively improving the problems of blurred boundaries and local breaks in slender roads, making the road structure more complete and the edges smoother.
[0054] Fourth, this application fills in occlusion gaps through morphological closing operations, repairs road discontinuities by combining skeleton denoising, pruning and endpoint bridging, and optimizes and corrects the road structure based on the width and connectivity quantification results, and finally outputs complete, continuous and burr-free farmland roads, which greatly improves the quality of road extraction.
[0055] Fifth, this application automatically completes the quantification of road width and road network connectivity based on the road centerline skeleton, and directly outputs quantitative indicators that can be used for project acceptance without the need for manual sampling measurement, thus realizing full automation from image input to road indicator output.
[0056] Furthermore, this application achieves automated detection and index calculation entirely based on UAV visible light imagery, eliminating reliance on manual inspections, paper records, and sampling measurements, significantly improving acceptance efficiency and reducing labor and time costs, and can directly serve the acceptance and operation and maintenance management of high-standard farmland roads. Attached Figure Description
[0057] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0058] Figure 1 This is a flowchart illustrating the method for extracting farmland roads with anti-shading in this application embodiment;
[0059] Figure 2 This is a schematic diagram of the overall structure of the improved DeepLabv3+ network in the embodiments of this application;
[0060] Figure 3 This is a schematic diagram of the inverted residual bottleneck structure of the MobileNetV2 network in an embodiment of this application;
[0061] Figure 4 This is a schematic diagram of the normalized attention mechanism module in the embodiments of this application;
[0062] Figure 5 This is a schematic diagram of the content-aware feature reconstruction upsampling module in an embodiment of this application;
[0063] Figure 6 This is a graph showing the changes in training loss and validation loss of the improved DeepLabv3+ network in the embodiments of this application;
[0064] Figure 7 This is a comparison chart showing the effectiveness of different semantic segmentation models in extracting farmland roads in the embodiments of this application;
[0065] Figure 8 This is a schematic diagram showing the results of farmland road extraction and centerline skeleton extraction in the study area in this embodiment of the application;
[0066] Figure 9 This is a schematic diagram of the anti-shading farmland road extraction device in the embodiments of this application;
[0067] Figure 10 This is a schematic diagram of the structure of the computer device in the embodiments of this application. Detailed Implementation
[0068] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.
[0069] Those skilled in the art will understand that, unless explicitly stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this application’s specification means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we say an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein can include wireless connections or wireless coupling. The term “and / or” as used herein includes all or any units and all combinations of one or more associated listed items.
[0070] Those skilled in the art will understand that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as herein.
[0071] Those skilled in the art will understand that the terms "client," "terminal," and "terminal device" as used herein include both devices that receive wireless signals, devices that only possess wireless signal receiver capabilities without transmission capabilities, and devices with receiving and transmitting hardware, devices that have receiving and transmitting hardware capable of bidirectional communication over a bidirectional communication link. Such devices may include: cellular or other communication devices such as personal computers or tablets, having single-line displays, multi-line displays, or cellular or other communication devices without multi-line displays; PCS (Personal Communications Service) that can combine voice, data processing, fax, and / or data communication capabilities; PDAs (Personal Digital Assistants) that may include radio frequency receivers, pagers, internet / intranet access, web browsers, notebooks, calendars, and / or GPS (Global Positioning System) receivers; and conventional laptops and / or handheld computers or other devices that have and / or include radio frequency receivers. As used herein, "client," "terminal," and "terminal device" can be portable, transportable, installed in a means of transportation (air, sea, and / or land), or suitable and / or configured to operate locally and / or in a distributed manner, operating in any other location on Earth and / or in space. "Client," "terminal," and "terminal device" as used herein can also be a communication terminal, an internet access terminal, or a music / video playback terminal, such as a PDA, a MID (Mobile Internet Device), and / or a mobile phone with music / video playback capabilities, or a smart TV, set-top box, etc.
[0072] The hardware referred to by the names "server," "client," and "service node" in this application is essentially an electronic device with the equivalent capabilities of a personal computer. It is a hardware device with the necessary components revealed by the von Neumann architecture, such as a central processing unit (including an arithmetic logic unit and a control unit), memory, input devices, and output devices. The computer program is stored in its memory, and the central processing unit loads the program stored in the secondary storage into the main memory to run it, execute the instructions in the program, and interact with the input and output devices to complete specific functions.
[0073] It should be noted that the concept of "server" used in this application can also be extended to the case of server clusters. Based on the network deployment principles understood by those skilled in the art, the servers should be logically divided. Physically, these servers can be independent of each other but accessible through interfaces, or they can be integrated into a single physical computer or a computer cluster. Those skilled in the art should understand this flexibility and should not use it to constrain the implementation of the network deployment method in this application.
[0074] One or more of the technical features of this application, unless explicitly specified herein, can be deployed on a server and accessed by a client remotely calling the online service interface provided by the server, or can be directly deployed and run on a client for access.
[0075] Unless otherwise specified, the neural network models referenced or potentially referenced in this application may be deployed on a remote server and invoked remotely on the client, or deployed on a client with the capability to invoke directly. In some embodiments, when running on the client, the corresponding intelligence may be acquired through transfer learning in order to reduce the requirements on the client's hardware resources and avoid excessive consumption of the client's hardware resources.
[0076] Unless otherwise specified, all data involved in this application may be stored remotely on a server or on a local terminal device, as long as it is suitable for use by the technical solution of this application.
[0077] Those skilled in the art will understand that although the various methods in this application are described based on the same concept and thus present commonality among them, they can be performed independently unless otherwise specified. Similarly, the various embodiments disclosed in this application are all based on the same inventive concept; therefore, concepts expressed in the same way, as well as concepts that are appropriately changed for convenience but are expressed differently, should be understood equivalently.
[0078] Unless otherwise expressly stated, the various embodiments disclosed in this application can be combined in a cross-cutting manner to flexibly construct new embodiments, as long as such combination does not depart from the inventive spirit of this application and can meet the needs of the prior art or solve a certain deficiency in the prior art. Those skilled in the art should be aware of such modifications.
[0079] Please see Figure 1 In one embodiment of the method for extracting farmland roads with anti-shading capability, this application includes:
[0080] Step S10: Obtain images of farmland to be segmented, collected by the drone, which contain multiple segments of farmland roads;
[0081] The anti-obstruction farmland road extraction system in the terminal device can acquire farmland images containing multiple segments of farmland roads collected by drones. The drones, equipped with visible light sensors, can quickly acquire high-resolution orthophotos of the farmland area, providing a data foundation for automatic road recognition.
[0082] Step S20: Replace the Xception backbone network in the encoder of the first farmland road segmentation model with a MobileNetV2 network. Introduce normalized attention mechanism modules after the MobileNetV2 network, after the dilated convolutional layer in the dilated spatial pyramid pooling module, and after the convolutional layer in the decoder. Replace the nearest neighbor interpolation upsampling module in the decoder with a content-aware feature reorganization upsampling module to construct the second farmland road segmentation model.
[0083] After acquiring images of farmland to be segmented, including multiple segments of farmland roads, collected by a drone, the Xception backbone network in the encoder of the first farmland road segmentation model is replaced with a MobileNetV2 network. Normalized attention mechanisms are then introduced after the MobileNetV2 network, after the dilated convolutional layers in the Spatial Pyramid Pooling (ASPP) module, and after the convolutional layers in the decoder. The nearest neighbor interpolation upsampling module in the decoder is replaced with a content-aware reassembly of features (CARAFE) upsampling module to construct a second farmland road segmentation model. The basic network architecture of the first farmland road segmentation model is the original DeepLabv3+ network; the basic network architecture of the second farmland road segmentation model is an improved DeepLabv3+ network.
[0084] Please see Figure 2To address the issues of large model parameters and low road boundary detection accuracy in field road detection inherent in the original DeepLabv3+ network, an improved DeepLabv3+ network is proposed as the second farmland road segmentation model in this application. This improved DeepLabv3+ network uses a MobileNetv2 network as the backbone at the encoder, replacing the original Xception backbone to reduce the number of model parameters and the size of the weight file. To enhance the network's feature extraction and fusion capabilities, a normalization-based attention module (NAM) is introduced after the MobileNetv2 network, after the dilated convolutional layer in the Dilated Spatial Pyramid Pooling (ASPP) module, and after the convolutional layer in the decoder. This allows the model to better focus on road features, suppress interference from road shadows, and improve the detection accuracy of boundary details. At the decoder, to improve detection accuracy, contextual information is aggregated within a larger receptive field. The nearest neighbor interpolation upsampling module in the decoder is replaced with content-aware reassembly of features. Upsampling of features (CARAFE) increases the receptive field of the model without increasing the number of parameters.
[0085] Furthermore, this application employs the MobileNetV2 network as the feature extraction backbone to reduce the number of model parameters and improve the efficiency of farmland road recognition. The MobileNetV2 network achieves a lightweight design by introducing an inverted residual block and a linear bottleneck structure. Based on the use of depthwise separable convolution, it greatly reduces the number of model parameters and computational complexity, and accelerates the network convergence speed.
[0086] Please see Figure 3The inverted residual structure of the MobileNetV2 network first expands the channel dimension using 1×1 convolutions, increasing the number of channels in the feature map. Then, it extracts spatial features through 3×3 depthwise separable convolutional layers. Finally, it uses 1×1 convolutions to reduce dimensionality, decreasing the number of channels in the feature map. Compared to traditional residual structures, this inverted residual structure uses low-dimensional features as input and output, placing high-dimensional features in the intermediate computation stage. ReLU6 is used as the activation function, typically applied after expansion layers and depthwise separable convolutional layers. In expansion layers, ReLU6 enhances the model's ability to express non-linear features; after depthwise separable convolutional layers, ReLU6 helps extract richer spatial features. No non-linear activation function is introduced after the linear bottleneck layer to reduce information loss in the low-dimensional feature space. By employing an inverted residual structure and a linear bottleneck design, the MobileNetV2 network achieves high feature representation capabilities and computational efficiency while maintaining a lightweight architecture.
[0087] Furthermore, in order to improve the anti-interference ability of farmland roads against shadows and the accurate extraction of road boundaries, this application introduces a normalized attention mechanism (NAM) module after the MobileNetV2 network, after the dilated convolutional layer in the dilated spatial pyramid pooling (ASPP) module, and after the convolutional layer in the decoder. This enables the model to dynamically adjust its attention to different features, improves stability under different disturbances, and makes road-related features stand out before multi-scale fusion.
[0088] Please see Figure 4 Normalized Attention (NAM), as an efficient and lightweight attention mechanism, integrates and redesigns the channel attention module and spatial attention module using a Convolutional Block Attention Module (CBAM). For the channel attention module, a scaling factor from Batch Normalization (BN) is used to express the importance of channels through sparse weight penalties and standard deviation. For the input features... The output formula for batch normalization (BN) is expressed as:
[0089]
[0090] in, This represents the batch-normalized input features; This represents the output characteristics of batch normalization; This represents the mean of the features in the current batch; This represents the standard deviation of the characteristics of the current batch; Indicates the learnable scaling factor; Indicates a learnable translation factor; This indicates a numerically stable term, avoiding a denominator of 0.
[0091] The weight of each channel is obtained through... To obtain the spatial attention module, the same normalization method is applied to each pixel in the input feature map. Obtain the weight corresponding to each pixel, where, Indicates the first Attention weights for each channel; Indicates the first Learnable scaling factor for each channel; Indicates the first Learnable scaling factor for each channel;
[0092] To suppress insignificant weights, a regularization term is added to the loss function, and its calculation formula is expressed as:
[0093]
[0094] in, This represents the total loss of the model; This represents the input image of farmland to be segmented; Represents the actual label value; Indicates network weights; This represents the regularization penalty coefficient, used to balance the weights of the regularization term and the task loss. In road detection tasks, it can better suppress road shadows and occlusions, thereby improving recognition accuracy. express Norm penalty function Indicates the spatial attention scaling factor; Indicates the channel attention scaling factor; This represents the basic loss function for the segmentation task.
[0095] Furthermore, the upsampling modules in the original DeepLabv3+ network aim to improve the resolution of feature maps by using nearest-neighbor interpolation upsampling modules to fuse feature information at multiple scales, thereby enriching the spatial information contained in the feature maps. However, because they rely solely on weighted calculations of adjacent pixels in the image and ignore the comprehensive semantic content, the upsampling modules exhibit certain limitations when dealing with farmland scenes involving highly similar backgrounds, which contain a large amount of semantic information.
[0096] In contrast, the content-aware reassembly of features (CARAFE) upsampling module can perform content-aware processing on the input feature map, dynamically generate adaptive kernels, and obtain a larger receptive field, thereby significantly reducing feature loss and reconstructing the shadow areas of road images to present complete details of road boundaries. Furthermore, this module has wide applicability due to its fast computation speed and lightweight design. Therefore, this application utilizes the content-aware reassembly of features (CARAFE) upsampling module to replace the original upsampling module.
[0097] Please see Figure 5 The content-aware reassembly of features (CARAFE) upsampling module consists of an upsampling prediction module and a feature reconstruction module. In the upsampling prediction module, a 1×1 convolution is first used to reconstruct features of size [missing information]. The number of channels in the input feature map is compressed to The resulting size is Feature maps are used to reduce computation. Let the upsampling factor be... The upsampling kernel size is The content encoder uses convolutional layers based on the compressed feature maps, according to the prediction size. The upsampling kernel weights are then determined. Subsequently, through channel rearrangement and expansion in the spatial dimension, a kernel of size [size missing] is obtained. The upsampling kernel is then used. Finally, the generated upsampling kernel is normalized using the softmax function to ensure that the sum of the weights in the convolution kernel is 1. Indicates the original number of channels; Represents the spatial height of the feature map; Indicates the spatial width of the feature map; Indicates the upsampling factor; This represents the target number of channels after compression using a 1×1 convolution channel. Indicates the spatial size of the upsampling kernel; Indicates the number of channels in the upsampling kernel; This represents the tensor size of the upsampling kernel.
[0098] In the feature reconstruction module, each position in the output feature map is mapped one by one to the corresponding region in the input feature map, and a region of size [value missing] is extracted from the input feature map. The local neighborhood of the region is used; the features of this neighborhood are multiplied by the predicted upsampled kernel to complete the content-adaptive feature reorganization, ultimately obtaining a feature of size . The new feature map.
[0099] An improved DeepLabv3+ network was constructed as the second farmland road segmentation model in this application. After training it to convergence, it can be put into production use. While reducing the number of parameters, it accurately extracts farmland road features, suppresses shadow occlusion interference, and restores road boundaries and continuity, thus achieving efficient and high-precision semantic segmentation of farmland roads from UAV images.
[0100] Step S30: Input the farmland image to be segmented into the second farmland road segmentation model that has been trained to convergence, and output the pixel-level mask image corresponding to each segment of farmland road;
[0101] The Xception backbone network in the encoder of the first farmland road segmentation model is replaced with a MobileNetV2 network. Normalized attention mechanism modules are introduced after the MobileNetV2 network, after the dilated convolutional layer in the dilated spatial pyramid pooling module, and after the convolutional layer in the decoder. The nearest neighbor interpolation upsampling module in the decoder is replaced with a content-aware feature reorganization upsampling module. After constructing the second farmland road segmentation model, the farmland image to be segmented is input into the second farmland road segmentation model that has been trained to convergence, and the pixel-level mask images corresponding to each segment of farmland road are output.
[0102] In some embodiments, the step of inputting the farmland image to be segmented into a second farmland road segmentation model that has been trained to convergence, and outputting pixel-level mask images corresponding to each segment of farmland road, includes:
[0103] Step S301: Input the farmland image to be segmented into the encoder of the second farmland road segmentation model that has been trained to convergence, and extract features by the MobileNetV2 network in the encoder to obtain the intermediate feature map of the first encoder.
[0104] Step S302: Input the intermediate feature map of the first encoder into the normalized attention mechanism module for road feature enhancement to obtain the intermediate feature map of the second encoder;
[0105] Step S303: Input the intermediate feature map of the second encoder into the hole spatial pyramid pooling module in the encoder, and sequentially perform multi-scale context information aggregation through hole convolutional layers with different hole rates to obtain multi-scale intermediate feature maps;
[0106] Step S304: Input the multi-scale intermediate feature maps corresponding to each dilated convolutional layer into the normalized attention mechanism module to suppress shadow and occlusion interference, and obtain the enhanced multi-scale intermediate feature maps.
[0107] Step S305: Fuse the enhanced multi-scale intermediate feature maps to obtain the road feature map output by the encoder.
[0108] As shown in steps S301 to S305 above, using the MobileNetV2 network for feature extraction significantly reduces the number of model parameters and computational cost while maintaining feature representation capabilities, improving inference efficiency and adapting to rapid processing of large-scale farmland images. Introducing a normalized attention mechanism after the MobileNetV2 network strengthens core road features, suppresses background and noise interference, and improves feature discriminability and robustness. Multi-scale contextual information aggregation is achieved through a dilated spatial pyramid pooling module, expanding the receptive field and better adapting to the varying widths and shapes of farmland roads, thus improving road integrity. Applying a normalized attention mechanism after each dilated convolutional layer further suppresses feature weakening caused by shadows, crops, and occlusion, improving the stability of road features in complex scenes. The enhanced multi-scale features are fused, ensuring that the road feature map output by the encoder possesses detail accuracy, anti-interference capability, and structural continuity, laying a reliable foundation for subsequent high-precision segmentation.
[0109] In a further embodiment, after fusing the enhanced multi-scale intermediate feature maps to obtain the road feature map output by the encoder, the method includes:
[0110] Step S3001: Input the road feature map output by the encoder into the decoder of the second farmland road segmentation model that has been trained to convergence, and perform resolution restoration and feature reconstruction through the content-aware feature reconstruction upsampling module to obtain the intermediate feature map of the first decoder;
[0111] Step S3002: Channel stitching and fusion of the first decoder intermediate feature map and the low-level detail features corresponding to the farmland image to be segmented are performed to obtain a stitched feature map. The stitched feature map is then subjected to convolution processing in sequence to obtain the second decoder intermediate feature map.
[0112] Step S3003: Input the intermediate feature map of the second decoder into the normalized attention mechanism module to enhance the road boundary features and obtain the boundary enhancement feature map;
[0113] Step S3004: Perform content-aware feature reorganization upsampling on the boundary enhancement feature map to obtain a high-resolution road feature map. Based on the high-resolution road feature map, perform pixel-level classification and output a pixel-level mask image corresponding to the farmland road.
[0114] As described in steps S3001 to S3004 above, content-aware feature reconstruction upsampling replaces traditional interpolation upsampling, preserving more road details and contextual information during resolution restoration, effectively avoiding blurring, breakage, and distortion of narrow road boundaries. High-level semantic features and low-level detail feature channels are stitched together, taking into account both global structure and local edge information, significantly improving the boundary integrity and segmentation accuracy of farmland roads. A normalized attention mechanism is introduced into the decoder to specifically enhance road boundary features and suppress shadows and occlusion noise, making road outlines clearer and segmentation results more robust. A high-resolution road feature map is obtained through secondary content-aware upsampling, enabling accurate pixel-level classification, and ultimately outputting a complete, continuous, and smooth-edged farmland road mask image.
[0115] Step S40: Perform morphological closing operation on the pixel-level mask image to fill the road discontinuity area caused by occlusion. Based on the pixel-level mask image after morphological closing operation, extract the single-pixel-width road centerline skeleton corresponding to each segment of farmland road. Then, perform noise reduction, pruning and endpoint bridging on the road centerline skeleton corresponding to each segment of farmland road to obtain a continuous road centerline skeleton.
[0116] The farmland image to be segmented is input into a second farmland road segmentation model that has been trained to convergence. After outputting pixel-level mask images corresponding to each farmland road segment, morphological closing operations are performed on the pixel-level mask images to fill in road discontinuities caused by occlusion. Based on the pixel-level mask images after morphological closing operations, a single-pixel-wide road centerline skeleton corresponding to each farmland road segment is extracted. Then, the road centerline skeletons corresponding to each farmland road segment are denoised, pruned, and have endpoints bridged to obtain a continuous road centerline skeleton.
[0117] In some embodiments, the steps of performing morphological closing operations on the pixel-level mask image to fill in road discontinuities caused by occlusion, extracting the single-pixel-width road centerline skeleton corresponding to each segment of farmland road based on the pixel-level mask image after morphological closing operations, and performing denoising, pruning, and endpoint bridging on the road centerline skeleton corresponding to each segment of farmland road to obtain a continuous road centerline skeleton include:
[0118] Step S401: Perform morphological closing operation on the pixel-level mask image corresponding to each section of farmland road to fill in the narrow gaps and small gaps in the road caused by the shading of forest belts and tree canopies, eliminate the discontinuous areas of non-real roads, and obtain a continuous road mask image.
[0119] Step S402: Extract a single-pixel-wide road centerline skeleton based on the continuous road mask image, and perform noise reduction and pruning on the road centerline skeleton to remove burrs and false detection noise.
[0120] Step S403: Perform endpoint detection on the denoised and pruned road centerline skeleton. Set distance constraints for endpoint association based on the maximum road width. Only when the Euclidean distance between the two endpoints of the road centerline skeleton satisfies the condition that the asphalt road does not exceed the first preset distance and the concrete road and gravel road do not exceed the second preset distance, it is determined that the two endpoints of the road centerline skeleton belong to the same road segment and are partially interrupted due to occlusion. Bridge them to restore the short-distance discontinuity caused by occlusion, and at the same time suppress cross-road misconnection to obtain the continuous road centerline skeleton.
[0121] Specifically, the first preset distance can be 5m, etc., and the second preset distance can be 4m, etc. Those skilled in the art can determine the first preset distance and the second preset distance as needed according to the actual application scenario, without any limitation.
[0122] Morphological closing operations are performed on the pixel-level mask images corresponding to each section of farmland road to fill in narrow gaps and small openings caused by forest belts and canopies, eliminating discontinuous areas of non-realistic roads and obtaining continuous road mask images. A single-pixel-wide road centerline skeleton is extracted from the continuous mask image, and the skeleton is denoised and pruned to remove burrs and false detection noise. Endpoint detection is performed on the denoised and pruned skeleton, with distance constraints set based on the maximum road width. A local interruption is determined and bridged only when the Euclidean distance between the two endpoints of the road centerline skeleton meets the condition that the distance between them does not exceed 5m for asphalt roads and 4m for concrete and gravel roads, thus obtaining a continuous road centerline skeleton.
[0123] Step S50: Based on the continuous road centerline skeleton, perform road connectivity quantification and road width quantification to determine the road quantification result. Optimize and correct the road structure according to the road quantification result to output a complete and continuous farmland road topology network.
[0124] Morphological closing operations are performed on the pixel-level mask image to fill in road discontinuities caused by occlusion. Based on the pixel-level mask image after morphological closing, the single-pixel-width road centerline skeleton corresponding to each segment of farmland road is extracted. The road centerline skeleton corresponding to each segment of farmland road is then denoised, pruned, and its endpoints are bridged to obtain a continuous road centerline skeleton. Based on the continuous road centerline skeleton, road connectivity quantization and road width quantization are performed to determine the road quantization result. The road structure is then optimized and corrected according to the road quantization result to output a complete and continuous farmland road topology network.
[0125] In some embodiments, the step of performing road connectivity quantization and road width quantization based on the continuous road centerline skeleton to determine the road quantization result includes:
[0126] Step S501: Perform Euclidean distance transformation on the road segmentation mask corresponding to the continuous road centerline skeleton, obtain the distance value of each pixel in the image to the nearest road mask boundary, and generate a distance transformation map;
[0127] Step S502: Select skeleton sampling points on the continuous road centerline skeleton, read the nearest boundary distance from each skeleton sampling point to the nearest road mask boundary from the distance transformation map, and take the maximum inscribed circle diameter at the skeleton sampling point as the local road width. Take the average of the local road widths of all skeleton sampling points in the same road segment to obtain the estimated pixel width of the road segment.
[0128] Specifically, skeleton sampling points are selected on the centerline skeleton of the continuous road. Read each skeleton sampling point from the distance transformation map. Corresponding nearest boundary distance The maximum inscribed circle diameter at the skeleton sampling point is used as the local road width. , that is ;
[0129] All within the same road segment Local road width at each skeleton sampling point The average value is taken to obtain the estimated pixel width of the road segment. Its calculation formula is expressed as:
[0130]
[0131] in, This represents the estimated pixel width of the road segment; Indicates the total number of skeleton sampling points; Indicates the first Local road width at each skeleton sampling point; Indicates the first The distance from each skeleton sampling point to the nearest road mask boundary.
[0132] Step S503: Based on the estimated pixel width and the image ground resolution, the actual road width is converted into the actual road width, and the actual road width is used as the road width quantification result of the farmland road topology network.
[0133] Based on the pixel width estimate Combined with image ground resolution Converted to actual road width Its calculation formula is expressed as:
[0134]
[0135] in, Indicates the actual road width; This represents the estimated pixel width of the road segment; This represents the ground resolution of the image, and its possible values are... No restrictions are imposed here.
[0136] Ultimately based on the actual road width As a result of road width quantification.
[0137] In a further embodiment, the step of performing road connectivity quantization and road width quantization based on the continuous road centerline skeleton to determine the road quantization result includes:
[0138] Step S5001: Construct a graph node set by taking all the skeleton pixels of the continuous road centerline skeleton and establishing an undirected edge set between the nodes according to the neighborhood adjacency relationship to construct an undirected graph;
[0139] Construct a graph node set from all the skeleton pixels of the continuous road centerline skeleton. Based on the 8-neighbor adjacency relationship, establish a set of undirected edges between nodes. Construct an undirected graph .
[0140] Step S5002: Perform connected component decomposition on the undirected graph to obtain the number of connected components, extract the largest connected component with the most nodes, and calculate the connectivity index of the farmland road topology network based on the node ratio of the largest connected component. Use the connectivity index as the quantitative result of road connectivity of the farmland road topology network.
[0141] For the undirected graph Perform connected component decomposition to obtain the number of connected components. Extract the maximum connected component with the most nodes, and denote its number of nodes as . The total number of skeleton nodes is The connectivity index of the farmland road topology network is calculated based on the node proportion of the largest connected component. Among them, the connectivity index of farmland road topology network The calculation formula is expressed as:
[0142]
[0143] in, Indicators representing the connectivity of farmland road topology; This represents the total number of skeleton nodes (i.e., the total number of skeleton pixels of the continuous road centerline skeleton). This represents the number of nodes in the largest connected component, which has the most nodes. Typically, The larger the value, the more independent subgraphs the skeleton is broken down into, resulting in lower road connectivity; when... When the value is close to 1, it indicates that the skeleton nodes are mainly concentrated in the same connected component, suggesting good continuity of the road network; when... At lower values, it indicates that the skeleton is dispersed across multiple components, with weaker connectivity and more pronounced fragmentation.
[0144] Ultimately, connectivity metrics As a result of road connectivity quantification.
[0145] Step S5003: Integrate the road width quantification results and the road connectivity quantification results to optimize and correct the road structure, so as to output a complete and continuous farmland road topology network.
[0146] Integrating the actual road width With the connectivity index The results are used to quantify the overall road structure; the road structure is then optimized and corrected based on the overall quantification results, taking into account the actual road width. Remove falsely detected road areas with abnormal widths; based on connectivity indicators Determine the integrity of the road network, fill in the gaps in road connectivity, and finally output a complete and continuous farmland road topology network.
[0147] In some embodiments, to evaluate the road semantic segmentation performance, this application uses the Mean Intersection over Union (MIoU), Mean Pixel Accuracy (MPA), and Precision as the main indicators. MIoU and MPA are calculated separately for each category and then averaged to reflect the overall accuracy of multi-class segmentation; Precision measures the accuracy of road recognition. In addition to accuracy indicators, this application further uses the number of parameters and the frame rate (FPS) to compare and evaluate model complexity and inference efficiency, where parameters represent the total number of model parameters and FPS represents the model's inference speed. Simultaneously, to evaluate the accuracy of road width estimation, this application compares the predicted width with manually measured width and uses Mean Absolute Error (MAE), Root Mean Square Error (RMSE), and Mean Absolute Percentage Error (MAPE) as width measurement error indicators.
[0148] In some embodiments, please refer to Figure 6 The improved DeepLabv3+ model training and validation loss curves are as follows: Figure 6As shown in the figure, both training loss and validation loss exhibit a rapid decreasing trend in the early stages of training. After the 20th training epoch, the loss values drop below 0.05 and gradually stabilize. By the 100th training epoch, the training loss and validation loss converge to 0.0197 and 0.0303, respectively. With the increase in the number of training iterations, both the training and validation losses remain stable, indicating that the model has good convergence performance and training stability, providing strong support for improving the accuracy of farmland road segmentation.
[0149] In some embodiments, to further verify the impact of introducing the Normalized Attention (NAM) module, the Content-Aware Reassembly of Features (CARAFE) upsampling module, and replacing the backbone on the semantic segmentation performance of the DeepLabv3+ model, this application conducted multiple ablation experiments, and the experimental results are shown in Table 1. When the DeepLabv3+ backbone was replaced with MobileNetv2, the number of model parameters decreased significantly, but the mean intersection-over-union ratio (Intersection over Union), mean pixel precision, and accuracy decreased slightly. After adding the Normalized Attention (NAM) module and the Content-Aware Reassembly of Features (CARAFE) upsampling module, the number of model parameters increased slightly, but the mean intersection-over-union ratio (Intersection over Union), mean pixel precision, and accuracy all improved.
[0150] When the backbone network is the Xception network, after introducing the content-aware reassembly of features (CARAFE) upsampling module, MIoU, MPA, and Precision are 91.26%, 95.67%, and 97.47%, respectively, representing improvements of 0.23, 0.34, and 0.52 percentage points. After introducing NAM, MIoU, MPA, and Precision are 91.26%, 95.67%, and 97.47%, respectively, representing improvements of 1.05, 0.19, and 0.08 percentage points. When both are introduced simultaneously, MIoU, MPA, and Precision reach 92.23%, 96.91%, and 97.95%, respectively, representing improvements of 1.20, 1.58, and 1.00 percentage points. When the backbone network is MobileNetv2, after introducing the content-aware reassembly of features (CARAFE) upsampling module, MIoU, MPA, and Precision are 93.30%, 96.56%, and 98.01%, respectively, representing improvements of 2.78, 1.64, and 1.15 percentage points. After introducing NAM, MIoU, MPA, and Precision are 92.18%, 96.52%, and 98.23%, respectively, representing improvements of 1.66, 1.60, and 1.39 percentage points. When both are introduced simultaneously, MIoU, MPA, and Precision reach 94.19%, 97.92%, and 99.13%, respectively, representing improvements of 3.67, 3.00, and 2.29 percentage points. The results show that introducing the Normalized Attention (NAM) module and the Content-Aware Reassembly of Features (CARAFE) upsampling module can improve the segmentation accuracy of the model, and at the same time improve the MobileNetv2 backbone network even more. This allows the model to combine attention weights and spatial features when extracting object features, making up for the lack of detail in MobileNetv2 feature extraction, and ensuring segmentation accuracy while reducing the number of parameters.
[0151] Table 1. Results of ablation experiments using different models
[0152]
[0153] In some embodiments, to test the performance of the improved DeepLabv3+ network in farmland road extraction, it was compared with PSPNet
[30] , U-Net and the original DeepLabv3+ network under the same training and testing settings, and the results are shown in Table 2. It can be seen that the improved DeepLabv3+ model is better than PSPNet, U-Net and the original DeepLabv3+ network in segmentation accuracy. In terms of MIoU, MPA and Precision, it is improved by 5.83, 4.02, 6.05 and 4.26, 3.36 and 3.66 percentage points respectively compared with PSPNet and U-Net models. In terms of parameter quantity, the improved DeepLabv3+ has reduced the number of parameters compared with PSPNet and U-Net respectively. and In the image detection frame rate comparison, PSPNet, U-Net, and the original DeepLabv3+ network improved by 11.7, 14.06, and 13.34 frames per second, respectively. Therefore, the improved DeepLabv3+ model in this application improves both the accuracy and prediction efficiency of farmland road segmentation.
[0154] Table 2 Results of comparative experiments with different models
[0155]
[0156] In some embodiments, please refer to Figure 7 , Figure 7 The segmentation performance of U-Net, PSPNet, the original DeepLabv3+ network, and the improved DeepLabv3+ network of this application in farmland road scenes was compared. At corners and road edges, U-Net, PSPNet, and DeepLabv3+ all exhibited varying degrees of boundary blurring or jagged edges. At intersections, PSPNet was prone to road discontinuities accompanied by scattered noise. In areas obscured by trees and shaded, U-Net, PSPNet, and DeepLabv3+ were more likely to produce local breaks or misidentify vegetation edges as roads, resulting in jagged edges and redundant branches in the skeleton, thus affecting connectivity calculation. Furthermore, U-Net, PSPNet, and DeepLabv3+ misidentified farmland backgrounds as roads in some samples, causing redundant branches in the road network and affecting the accuracy of road connectivity calculation. Overall, the prediction results of the improved DeepLabv3+ network in this application are more consistent with the annotations, with clearer boundaries and better road continuity. Combined with skeleton denoising, pruning and fracture repair, the impact of fractures in occluded areas on centerline generation and road network index calculation can be further reduced.
[0157] In some embodiments, to evaluate the effectiveness of road width estimation, this application uses an improved road segmentation mask output by the DeepLabv3+ network as a basis, employs distance transformation and skeleton sampling to obtain the road segment width, and compares it with the results of manual measurement. For each road segment, both manual measurement and model prediction are repeated 5 times and the average value is taken to obtain the actual measured width and predicted width of the road segment. A total of 30 road segments are selected as evaluation samples, including 10 segments each of asphalt road, concrete road, and gravel road.
[0158] Table 3 shows the statistical results of the errors between the actual and predicted widths measured manually. The road width estimates obtained by the improved DeepLabv3+ network are quite close to the results of manual measurement. The mean deviations for the three types of roads are all within 10 cm, indicating that the width estimation based on segmentation mask and skeleton can accurately reflect the road geometry and meet the needs of statistical and comparative analysis of farmland road widths.
[0159] Table 3. Statistical results of the error between the actual width and the predicted width.
[0160]
[0161] In some embodiments, please refer to Figure 8 Based on the improved DeepLabv3+ network, the road segmentation mask of the study area is first extracted into the road region, and the road surface target is converted into a single pixel center line. In order to reduce the impact of noise and burrs on connectivity statistics, the skeleton is denoised, pruned and broken, and isolated short branches and local burrs are removed to make the center line more consistent with the actual road direction.
[0162] Based on the connectivity statistics of the road framework in the study area, the number of connected subgraphs is: Connectivity index The results indicate that the entire road network in the study area belongs to the same connected component, with no obvious breaks or fragmentation. The overall road network exhibits strong continuity, providing a reliable basis for subsequent road connectivity evaluation and road network analysis.
[0163] As can be seen from the above embodiments, compared with the prior art, this application addresses the problems in the prior art where field roads are mostly distributed in a long and narrow strip, which easily leads to blurred boundaries, broken sections, etc. after network downsampling, as well as the serious weakening of road features by shadows, tree canopies, crops, etc., resulting in holes, broken chains, and insufficient anti-interference ability in the extraction results. This application has, but is not limited to, the following beneficial effects:
[0164] Firstly, the improved DeepLabv3+ network in this application replaces the Xception backbone network with the MobileNetV2 network, which significantly reduces the number of model parameters and computational overhead. While ensuring segmentation accuracy, it significantly improves the processing speed of large-scale UAV farmland images, meeting the needs of rapid batch detection in engineering sites.
[0165] Secondly, the improved DeepLabv3+ network in this application introduces a normalized attention mechanism module after the MobileNetV2 network, after the dilated convolutional layer in the dilated spatial pyramid pooling module, and after the convolutional layer in the decoder. This can effectively enhance road features, suppress interference caused by shadows, tree canopies, and crop occlusion, reduce false negatives and false positives, and improve the robustness of road extraction in complex farmland scenarios.
[0166] Third, the improved DeepLabv3+ network in this application replaces the traditional nearest neighbor interpolation upsampling module with a content-aware feature recombination upsampling module, which aggregates contextual information in a larger receptive field, effectively improving the problems of blurred boundaries and local breaks in slender roads, making the road structure more complete and the edges smoother.
[0167] Fourth, this application fills in occlusion gaps through morphological closing operations, repairs road discontinuities by combining skeleton denoising, pruning and endpoint bridging, and optimizes and corrects the road structure based on the width and connectivity quantification results, and finally outputs complete, continuous and burr-free farmland roads, which greatly improves the quality of road extraction.
[0168] Fifth, this application automatically completes the quantification of road width and road network connectivity based on the road centerline skeleton, and directly outputs quantitative indicators that can be used for project acceptance without the need for manual sampling measurement, thus realizing full automation from image input to road indicator output.
[0169] Furthermore, this application achieves automated detection and index calculation entirely based on UAV visible light imagery, eliminating reliance on manual inspections, paper records, and sampling measurements, significantly improving acceptance efficiency and reducing labor and time costs, and can directly serve the acceptance and operation and maintenance management of high-standard farmland roads.
[0170] Please see Figure 9This application provides an anti-occlusion farmland road extraction device, comprising a farmland image acquisition module 1100, a road segmentation model construction module 1200, a road mask output module 1300, a road centerline determination module 1400, and a target road determination module 1500. The farmland image acquisition module 1100 is configured to acquire farmland images to be segmented, including multiple segments of farmland roads, collected by a UAV. The road segmentation model construction module 1200 is configured to replace the Xception backbone network in the encoder of a first farmland road segmentation model with a MobileNetV2 network, introduce a normalized attention mechanism module after the MobileNetV2 network, after the dilated convolutional layer in the dilated spatial pyramid pooling module, and after the convolutional layer in the decoder, and replace the nearest neighbor interpolation upsampling module in the decoder with a content-aware feature reorganization upsampling module to construct a second farmland road segmentation model. The road mask output module 1300 is configured to input the farmland image to be segmented into the trained and converged second... In the farmland road segmentation model, pixel-level mask images corresponding to each segment of farmland road are output. The road centerline determination module 1400 is configured to perform morphological closing operations on the pixel-level mask images to fill in road discontinuities caused by occlusion. Based on the pixel-level mask images after morphological closing operations, the single-pixel-width road centerline skeleton corresponding to each segment of farmland road is extracted, and the road centerline skeleton corresponding to each segment of farmland road is denoised, pruned, and endpoint bridged to obtain a continuous road centerline skeleton. The target road determination module 1500 is configured to perform road connectivity quantization and road width quantization based on the continuous road centerline skeleton to determine the road quantization result. The road structure is optimized and corrected according to the road quantization result to output a complete and continuous farmland road topology network.
[0171] Based on any embodiment of this application, please refer to Figure 10 Another embodiment of this application also provides an electronic device, which can be implemented by a computer device, such as... Figure 10The diagram shows the internal structure of a computer device. The computer device includes a processor, a computer-readable storage medium, a memory, and a network interface connected via a system bus. The computer-readable storage medium stores an operating system, a database, and computer-readable instructions. The database may store a sequence of control information. When executed by the processor, the computer-readable instructions enable the processor to implement a method for extracting farmland roads that resists shading. The processor provides computational and control capabilities, supporting the operation of the entire computer device. The memory stores computer-readable instructions, which, when executed by the processor, enable the processor to execute the method for extracting farmland roads that resists shading as described in this application. The network interface of the computer device is used for communication with a terminal. Those skilled in the art will understand that… Figure 10 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0172] In this embodiment, the processor is used to execute... Figure 9 The specific functions of each module are defined within the device, and the memory stores the program code and various data required to execute these modules. A network interface is used for data transmission between the user terminal and the server. In this embodiment, the memory stores the program code and data required to execute all modules in the anti-shading farmland road extraction device of this application, and the server can call the server's program code and data to execute the functions of all modules.
[0173] This application also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the anti-shading farmland road extraction method described in any embodiment of this application.
[0174] This application also provides a computer program product, including a computer program / instructions that, when executed by one or more processors, implement the steps of the anti-shading farmland road extraction method described in any embodiment of this application.
[0175] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0176] The above description is only a partial embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for extracting an anti-occlusion farmland road, characterized by, include: Acquire images of farmland to be segmented, collected by drones, which include multiple sections of farmland roads; The Xception backbone network in the encoder of the first farmland road segmentation model is replaced with the MobileNetV2 network. Normalized attention mechanism modules are introduced after the MobileNetV2 network, after the dilated convolutional layer in the dilated spatial pyramid pooling module, and after the convolutional layer in the decoder. The nearest neighbor interpolation upsampling module in the decoder is replaced with a content-aware feature reorganization upsampling module to construct the second farmland road segmentation model. The farmland image to be segmented is input into the second farmland road segmentation model that has been trained to convergence, and the pixel-level mask image corresponding to each segment of farmland road is output. Morphological closing operations are performed on the pixel-level mask image to fill in the road discontinuity areas caused by occlusion. Based on the pixel-level mask image after morphological closing operations, the single-pixel-width road centerline skeleton corresponding to each segment of farmland road is extracted. The road centerline skeleton corresponding to each segment of farmland road is then denoised, pruned, and its endpoints are bridged to obtain a continuous road centerline skeleton. Based on the continuous road centerline skeleton, road connectivity quantification and road width quantification are performed to determine the road quantification results. The road structure is then optimized and corrected according to the road quantification results to output a complete and continuous farmland road topology network.
2. The anti-occlusion farmland road extraction method of claim 1, wherein, The basic network architecture of the first farmland road segmentation model is the original DeepLabv3+ network; the basic network architecture of the second farmland road segmentation model is the improved DeepLabv3+ network.
3. The anti-occlusion farmland road extraction method of claim 2, wherein, The steps of inputting the farmland image to be segmented into the second farmland road segmentation model that has been trained to convergence, and outputting pixel-level mask images corresponding to each segment of farmland road, include: The farmland image to be segmented is input into the encoder of the second farmland road segmentation model that has been trained to convergence. The MobileNetV2 network in the encoder performs feature extraction to obtain the intermediate feature map of the first encoder. The intermediate feature map of the first encoder is input into the normalized attention mechanism module for road feature enhancement to obtain the intermediate feature map of the second encoder. The intermediate feature map of the second encoder is input into the hollow spatial pyramid pooling module in the encoder, and multi-scale context information is aggregated sequentially through hollow convolutional layers with different hollow rates to obtain multi-scale intermediate feature maps. The multi-scale intermediate feature maps corresponding to each dilated convolutional layer are input into the normalized attention mechanism module to suppress shadow and occlusion interference, and the enhanced multi-scale intermediate feature maps are obtained. The enhanced multi-scale intermediate feature maps are fused to obtain the road feature map output by the encoder.
4. The non-occlusion agricultural field road extraction method according to claim 3, characterized by, After fusing the enhanced multi-scale intermediate feature maps to obtain the road feature map output by the encoder, the following steps are included: The road feature map output by the encoder is input into the decoder of the second farmland road segmentation model that has been trained to convergence. The resolution is restored and the features are reconstructed through the content-aware feature reconstruction and upsampling module to obtain the intermediate feature map of the first decoder. The intermediate feature map of the first decoder is combined with the low-level detail features corresponding to the farmland image to be segmented by channel stitching and fusion to obtain a stitched feature map. The stitched feature map is then subjected to convolution processing in sequence to obtain the intermediate feature map of the second decoder. The intermediate feature map of the second decoder is input into the normalized attention mechanism module to enhance the road boundary features, resulting in a boundary enhanced feature map. Content-aware feature recombination upsampling is performed on the boundary enhancement feature map to obtain a high-resolution road feature map. Based on the high-resolution road feature map, pixel-level classification is performed to output a pixel-level mask image corresponding to the farmland road.
5. The anti-occlusion farmland road extraction method of claim 1, wherein, The steps of performing morphological closing operations on the pixel-level mask image to fill in road discontinuities caused by occlusion, extracting the single-pixel-width road centerline skeleton corresponding to each segment of farmland road based on the pixel-level mask image after morphological closing, and performing denoising, pruning, and endpoint bridging on the road centerline skeleton corresponding to each segment of farmland road to obtain a continuous road centerline skeleton include: Morphological closing operations are performed on the pixel-level mask images corresponding to each section of farmland road to fill in the narrow gaps and small gaps in the road caused by forest belts and canopies, eliminate non-real road discontinuities, and obtain continuous road mask images. Based on the continuous road mask image, a single-pixel-wide road centerline skeleton is extracted, and the road centerline skeleton is denoised and pruned to remove burrs and false detection noise. Endpoint detection is performed on the denoised and pruned road centerline skeleton. Distance constraints for endpoint association are set based on the maximum road width. Only when the Euclidean distance between the two endpoints of the road centerline skeleton satisfies the condition that the distance between the asphalt road and the distance between the concrete road and the gravel road does not exceed the first preset distance, it is determined that the two endpoints of the road centerline skeleton belong to the same road segment and are partially interrupted due to occlusion. They are then bridged to restore the short-distance discontinuity caused by occlusion and suppress false connections across roads, thus obtaining the continuous road centerline skeleton.
6. The shadowing-free farm track extraction method according to any one of claims 1, wherein, The steps for quantifying road connectivity and road width based on the continuous road centerline skeleton to determine the road quantization result include: Perform Euclidean distance transformation on the road segmentation mask corresponding to the continuous road centerline skeleton, obtain the distance value of each pixel in the image to the nearest road mask boundary, and generate a distance transformation map; Select skeleton sampling points on the continuous road centerline skeleton, read the nearest boundary distance from each skeleton sampling point to the nearest road mask boundary from the distance transformation map, and take the maximum inscribed circle diameter at the skeleton sampling point as the local road width. Take the average of the local road widths of all skeleton sampling points in the same road segment to obtain the estimated pixel width of the road segment. The estimated pixel width is converted into the actual road width based on the image ground resolution, and the actual road width is used as the road width quantification result of the farmland road topology network.
7. The anti-occlusion farmland road extraction method of claim 1, wherein, The steps for quantifying road connectivity and road width based on the continuous road centerline skeleton to determine the road quantization result include: All skeleton pixels in the continuous road centerline skeleton are constructed into a graph node set, and an undirected edge set is established between the nodes according to the neighborhood adjacency relationship to construct an undirected graph. The undirected graph is decomposed into connected components to obtain the number of connected components. The largest connected component with the most nodes is extracted, and the connectivity index of the farmland road topology network is calculated based on the node ratio of the largest connected component. The connectivity index is used as the quantitative result of the road connectivity of the farmland road topology network. By integrating the road width quantification results and the road connectivity quantification results, the road structure is optimized and corrected to output a complete and continuous farmland road topology network.
8. An anti-occlusion farmland road extraction device, characterized by, include: The farmland image acquisition module is set to acquire farmland images to be segmented, which are collected by drones and contain multiple segments of farmland roads; The road segmentation model construction module is configured to replace the Xception backbone network in the encoder of the first farmland road segmentation model with the MobileNetV2 network, introduce a normalized attention mechanism module after the MobileNetV2 network, after the dilated convolutional layer in the dilated spatial pyramid pooling module, and after the convolutional layer in the decoder, and replace the nearest neighbor interpolation upsampling module in the decoder with a content-aware feature reorganization upsampling module to construct the second farmland road segmentation model. The road mask output module is configured to input the farmland image to be segmented into the second farmland road segmentation model that has been trained to convergence, and output the pixel-level mask image corresponding to each segment of farmland road; The road centerline determination module is configured to perform morphological closing operations on the pixel-level mask image to fill the road discontinuity areas caused by occlusion, extract the single-pixel-width road centerline skeleton corresponding to each segment of farmland road based on the pixel-level mask image after morphological closing operations, and perform noise reduction, pruning and endpoint bridging on the road centerline skeleton corresponding to each segment of farmland road to obtain a continuous road centerline skeleton. The target road determination module is configured to perform road connectivity quantification and road width quantification based on the continuous road centerline skeleton to determine the road quantification result, and optimize and correct the road structure according to the road quantification result to output a complete and continuous farmland road topology network.
9. An electronic device comprising a central processing unit and a memory, characterized in that The central processing unit is used to invoke and run a computer program stored in the memory to perform the steps of the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It stores, in the form of computer-readable instructions, a computer program implemented according to any one of claims 1 to 7, which, when invoked by a computer, executes the steps included in the corresponding method.