Method and device for extracting cultivated land based on SAM boundary constraint and semantic perception network

By constructing the SAM-SANet model and combining semantic perception and boundary constraint branches, the problem of farmland boundary extraction in remote sensing images was solved, achieving high-precision and high-flexibility farmland extraction results.

CN121600418APending Publication Date: 2026-03-03ZHENGZHOU UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511434537.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-09
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

Existing remote sensing image processing methods struggle to effectively extract farmland boundaries from high-resolution remote sensing images, especially in remote sensing scenarios with diverse farmland types and complex boundaries. Traditional methods rely on human experience and are unable to meet the needs of large-scale, high-precision extraction. Deep learning methods face challenges in remote sensing scenarios due to domain differences and fixed input size limitations.

Method used

A dual-branch architecture is constructed, combining a semantic perception branch and a boundary constraint branch in the SAM-SANet model. Through a multi-task collaborative training mechanism and a composite loss function, the accuracy of farmland area prediction is optimized collaboratively. A location embedding adapter is introduced to solve the limitation of fixed input resolution and improve the discrimination ability of boundary area information.

Benefits of technology

It effectively improves the overall accuracy and boundary consistency of farmland area extraction, and enhances the flexibility and precision in remote sensing image processing, especially the ability to identify farmland in complex terrain scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121600418A_ABST
    Figure CN121600418A_ABST
Patent Text Reader

Abstract

The invention discloses a cultivated land extraction method and device based on SAM boundary constraint and a semantic perception network. Accurate prediction of a cultivated land area can be realized. The method comprises the following steps: (1) constructing two remote sensing cultivated land data sets; (2) a double-branch collaborative SAM-SANet model combining a semantic perception branch SAB and a boundary constraint SAM branch BCB is built, the two branches share input, a multi-task collaborative training mechanism is adopted, a composite loss function fusing semantic segmentation loss and boundary constraint loss is built, the boundary loss is not only used for restraining mask generation in the BCB branch, but also used for restraining mask generation in the BCB branch, and the boundary constraint loss is also used for restraining mask generation in the BCB branch. Meanwhile, the signal is used as an auxiliary supervision signal to guide the structural expression of the SAB branch on the cultivated land area boundary; and (3) by adjusting network hyper-parameters and boundary loss weights, determining optimal experimental parameter setting for training and reasoning, completing a cultivated land extraction task, and performing comparative experimental analysis with other deep learning models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical field of intelligent processing of remote sensing images, and in particular to a method for extracting cultivated land based on SAM boundary constraints and semantic perception network, as well as a device for extracting cultivated land based on SAM boundary constraints and semantic perception network, which is applicable to applications such as precision agriculture management, cultivated land resource monitoring and land mapping. Background Technology

[0002] With the continuous advancement of precision agricultural management and the national food security strategy, the accurate extraction of the spatial distribution of arable land has become an important research direction in the field of remote sensing. High-resolution remote sensing images, due to their characteristics of large-scale coverage, high resolution, and ease of objective acquisition, provide abundant data information for the fine extraction of arable land. However, although high-resolution remote sensing images contain a large amount of ground feature details, the large intra-class differences and small inter-class differences within the images make the automatic extraction of arable land areas extremely challenging.

[0003] To achieve accurate, high-resolution farmland extraction, traditional methods relying on image segmentation and manual feature design, followed by mainstream deep learning-based farmland extraction methods, have emerged. Traditional high-resolution farmland extraction methods mainly include object-based and region-based image analysis techniques. The former often uses traditional image segmentation algorithms to divide the image into homogeneous regions, then extracts texture, geometric, and spectral features for classification; the latter uses methods such as region growing and clustering to group images. These methods are adaptable to conditions with high image quality and clear scene structure, but perform poorly in remote sensing scenes with diverse farmland types and complex boundaries, and heavily rely on manual experience and parameter tuning, making it difficult to meet the needs of large-scale, high-precision extraction. The rapid development of deep learning technology has driven research progress in semantic segmentation of remote sensing images. Architectures such as fully convolutional networks, U-Net, and DeepLabV3+ have achieved good results in pixel-level classification tasks. These methods enhance the multi-scale semantic representation capabilities of the model by introducing structures such as dilated convolution and pyramid pooling. Meanwhile, the Transformer model, due to its powerful global modeling capabilities, has been introduced into remote sensing image segmentation tasks, further improving segmentation performance in complex backgrounds by capturing long-distance pixel dependencies. Currently, researchers have attempted to construct hybrid architectures of CNN and Transformer to balance local and global feature modeling. However, these methods typically lack a dedicated focus on the fine depiction and structural preservation of farmland boundary contours, making it difficult to meet the higher demands for accurate farmland boundary segmentation in remote sensing scenarios.

[0004] Meta's Segment Anything Model (SAM), proposed in 2023, has garnered widespread attention as a general segmentation model with "zero-shot" capabilities. SAM can automatically generate target masks without class labeling, demonstrating excellent boundary segmentation capabilities. Although it has been gradually introduced into the field of remote sensing, such as as a downstream semantic segmentation model to guide mask generation and improve boundary localization capabilities, it faces domain-specific challenges when processing remote sensing images due to its lack of output class information and the fact that its training data is primarily natural images. Furthermore, SAM's fixed input size limits its efficiency and accuracy when processing remote sensing images with different input sizes. While some studies have attempted to improve SAM's adaptability in remote sensing scenarios by fine-tuning the ViT structure, introducing location embedding, or cross-scale feature fusion, most methods have still failed to effectively solve the problem of identifying the entire cultivated land area in high-resolution remote sensing. Summary of the Invention

[0005] To overcome the shortcomings of existing technologies, the technical problem to be solved by this invention is to provide a farmland extraction method based on SAM boundary constraints and semantic awareness network. This method constructs a dual-branch architecture and introduces semantic awareness branch and boundary constraint branch for collaborative optimization to achieve accurate prediction of farmland areas.

[0006] The technical solution of this invention is: a method for extracting cultivated land based on SAM boundary constraints and semantic awareness networks, comprising the following steps: (1) Construct two remote sensing farmland datasets. Each dataset divides the entire area into 16 sub-grids. The test set retains one complete grid as an independent evaluation area and does not participate in cropping. The training set and validation set are divided proportionally in the remaining grids and cut into 256×256 image blocks with a 50% overlap rate. (2) A dual-branch collaborative SAM-SANet model combining the semantic perception branch SAB and the boundary constraint SAM branch BCB is constructed. The two branches share the input and adopt a multi-task collaborative training mechanism to construct a composite loss function that integrates semantic segmentation loss and boundary constraint loss. The boundary loss is not only used to constrain the mask generation in the BCB branch, but also serves as an auxiliary supervision signal to guide the SAB branch to express the structured representation of the farmland boundary. (3) By adjusting the network hyperparameters and boundary loss weights, the optimal experimental parameter settings are determined for training and inference to complete the farmland extraction task, and comparative experimental analysis is conducted with other deep learning models.

[0007] This invention constructs two diverse remote sensing datasets and proposes a dual-branch farmland extraction method that integrates the Semantic Aware Branch (SAB) and the Boundary Constraint SAM Branch (BCB). By co-modeling semantics and boundaries, a composite loss function is introduced for joint optimization, effectively improving the overall accuracy and boundary consistency of farmland extraction. A location embedding adapter is introduced to overcome the limitation of the fixed resolution input of the original SAM structure, enhancing the flexibility of the method in remote sensing image processing. By fusing multi-scale boundary features, high-quality boundary cue embeddings are generated, improving the discrimination ability of boundary area information. Comparative experiments are conducted on datasets with two different geomorphic environments, comparing the SAM-SANet model with other deep learning methods, including two general semantic segmentation networks, UNet and DeepLabV3+, and two representative semantic segmentation networks in the remote sensing field, UNetformer and CMTFNet. The superiority of the proposed SAM-SANet model is demonstrated using evaluation metrics such as IoU, F1-score, Kappa, and overall accuracy.

[0008] A farmland extraction device based on SAM boundary constraints and semantic awareness network is also provided. The device includes: The dataset construction module constructs two remote sensing farmland datasets. Each dataset divides the entire region into 16 sub-grids. The test set retains one complete grid as an independent evaluation region without being cropped. The training and validation sets are divided proportionally in the remaining grids and cut into 256×256 image patches with a 50% overlap rate. The dual-branch collaborative module constructs a dual-branch collaborative SAM-SANet model that combines the semantic perception branch SAB and the boundary constraint SAM branch BCB. The two branches share the input and adopt a multi-task collaborative training mechanism to construct a composite loss function that integrates semantic segmentation loss and boundary constraint loss. The boundary loss is not only used to constrain the mask generation in the BCB branch, but also serves as an auxiliary supervision signal to guide the SAB branch in the structured representation of the farmland boundary. The comparative experiment analysis module determines the optimal experimental parameter settings for training and inference by adjusting network hyperparameters and boundary loss weights, completes the farmland extraction task, and conducts comparative experimental analysis with other deep learning models. Attached Figure Description

[0009] Figure 1 A flowchart of the farmland extraction method based on SAM boundary constraints and semantic awareness network according to the present invention is shown.

[0010] Figure 2 The overall architecture flowchart for remote sensing farmland extraction is shown.

[0011] Figure 3 The structure diagram of the SAM-SANet model is shown. Detailed Implementation

[0012] like Figure 1 As shown, this method for farmland extraction based on SAM boundary constraints and semantic awareness networks includes the following steps: (1) Construct two remote sensing farmland datasets. Each dataset divides the entire area into 16 sub-grids. The test set retains one complete grid as an independent evaluation area and does not participate in cropping. The training set and validation set are divided proportionally in the remaining grids and cut into 256×256 image blocks with a 50% overlap rate. (2) A dual-branch collaborative SAM-SANet model combining the semantic perception branch SAB and the boundary constraint SAM branch BCB is constructed. The two branches share the input and adopt a multi-task collaborative training mechanism to construct a composite loss function that integrates semantic segmentation loss and boundary constraint loss. The boundary loss is not only used to constrain the mask generation in the BCB branch, but also serves as an auxiliary supervision signal to guide the SAB branch to express the structured representation of the farmland boundary. (3) By adjusting the network hyperparameters and boundary loss weights, the optimal experimental parameter settings are determined for training and inference to complete the farmland extraction task, and comparative experimental analysis is conducted with other deep learning models.

[0013] This invention constructs two diverse remote sensing datasets and proposes a dual-branch farmland extraction method that integrates the Semantic Aware Branch (SAB) and the Boundary Constraint SAM Branch (BCB). By co-modeling semantics and boundaries, a composite loss function is introduced for joint optimization, effectively improving the overall accuracy and boundary consistency of farmland extraction. A location embedding adapter is introduced to overcome the limitation of the fixed resolution input of the original SAM structure, enhancing the flexibility of the method in remote sensing image processing. By fusing multi-scale boundary features, high-quality boundary cue embeddings are generated, improving the discrimination ability of boundary area information. Comparative experiments are conducted on datasets with two different geomorphic environments, comparing the SAM-SANet model with other deep learning methods, including two general semantic segmentation networks, UNet and DeepLabV3+, and two representative semantic segmentation networks in the remote sensing field, UNetformer and CMTFNet. The superiority of the proposed SAM-SANet model is demonstrated using evaluation metrics such as IoU, F1-score, Kappa, and overall accuracy.

[0014] Preferably, in step (1), two different agricultural landscape research areas are selected respectively, and the Gaofen-1 GF-1 satellite image provided by the Land Satellite Remote Sensing Application Center of the Ministry of Natural Resources of China is used as the remote sensing data source. The image has a spatial resolution of 2 meters panchromatic and 8 meters multispectral. The Gram-Schmidt algorithm is used to fuse the panchromatic and multispectral images to generate a composite image of red, green and blue bands with a resolution of 2 meters. Then, the Albers equal-area conic projection is used for geometric correction and spatial reference transformation. Remote sensing professionals perform visual interpretation and farmland labeling based on the fused composite image to clarify the scope of farmland and non-farmland.

[0015] Preferably, step (2) includes the following sub-steps: (2.1) Construction of the semantic awareness branch SAB based on UNetformer; (2.2) Input size adaptive position embedding adaptation mechanism; (2.3) Multi-scale boundary feature fusion and cue embedding generation; (2.4) Prompt-guided mask decoding and collaborative optimization; (2.5) Design the loss function.

[0016] Preferably, in step (2.1), as the backbone branch of the SAM-SANet network, the SAB branch undertakes the core task of identifying the overall cultivated land area. This branch dominates the model's semantic structure modeling ability on cultivated land images. During training, the SAB branch not only relies on semantic segmentation loss to optimize its own output, but also receives the boundary mask generated by the boundary constraint SAM branch as a structural supervision signal. The boundary supervision guides the semantic branch to form a clearer predictive response in the boundary-sensitive area through the joint loss mechanism. The SAB branch adopts the UNetFormer structure to construct an encoder-decoder system to extract semantic features of cultivated land areas at multiple scales. The encoder consists of multiple convolutional modules and uses a layer-by-layer downsampling method to extract shallow texture and deep semantic information of the image. The decoder stacks multiple Transformer modules to model long-distance pixel dependencies and capture the complexity and scale variation features of cultivated land shapes. Skip connections are established between the encoder and decoder to fuse local details and global contextual information. The decoder outputs pixel-level semantic prediction results of cultivated land areas.

[0017] Preferably, in step (2.2), the image encoder in the boundary constraint SAM branch is based on the Vision Transformer architecture, which uses a set of predefined absolute position codes. This coding mechanism is highly coupled with a fixed input size, treats the original position embedding matrix as a two-dimensional feature map, and spatially resamples it through bilinear interpolation. First, obtain the raw absolute position encoding tensor generated by the Vision Transformer architecture. Its shape is a two-dimensional tensor. L ori , C ], where C is the embedding dimension, which is reconstructed into a four-dimensional tensor form [1, C , H ori , W ori Based on the current input image resolution, determine the embedding size of the target location. H new × W new Calculate the length of the target sequence L new = H new × W new The reconstructed tensor is subjected to bilinear interpolation to obtain a new, adapted embedded tensor, which is then flattened into a two-dimensional tensor. .

[0018] Preferably, step (2.3) includes the following sub-steps: (2.3.1) Feature splicing and fusion: Select multiple shallow and deep Transformer layers to extract feature maps F i For each feature map F i By unifying the channel dimension through a 1×1 convolution operation, all the unified feature maps are concatenated along the channel dimension to construct a fused feature representation. The concatenated feature map contains rich boundary texture information and local contextual semantics from shallow to deep layers. (2.3.2) Deep convolution integration and nonlinear activation: In order to further integrate information from different levels, 3×3 convolution is used to extract local spatial information from the concatenated feature map and enhance the feature consistency of the boundary region. At the same time, BatchNormalization is introduced to improve training stability, and ReLU activation function is used to increase nonlinear expressive power. The final boundary-aware feature map is obtained for subsequent cue embedding generation. (2.3.3) Hint Embedding Generation: Apply 3×3 convolution to the obtained boundary-aware feature map to extract local spatial features, and obtain intermediate representation through ReLU activation function. Set up two parallel 1×1 convolution branches, one of which is used to predict the foreground probability. P objOne output measures the confidence of each candidate box as a cue; the other outputs bounding box offsets to adjust the position of the candidate boxes. The top K high-confidence regions are selected from the candidate boxes, their coordinates are normalized, and then input into the cue header in the SAM cue encoder to generate the final cue embedding vector, which serves as the guiding information for the subsequent SAM mask decoder.

[0019] Preferably, in step (2.4), a cue-guided mask decoding mechanism is constructed in the boundary constraint SAM branch BCB. Combining encoded features and cue information, it is used to more finely characterize the farmland boundary structure. The image features extracted by the Transformer encoder are jointly input into the SAM mask decoder along with the high-quality cue embedding vector generated in step (2.3). Class labels are further introduced into the decoder. By fusing image features, cue information, and class priors, the semantic modeling capability in the mask generation process is enhanced. The boundary mask generated in the BCB branch serves as a boundary supervision signal during the training phase. During the training process, it effectively constrains the boundary-sensitive areas in the semantic branch, realizing the collaborative optimization of the two branches in farmland area and boundary representation.

[0020] Preferably, step (2.5) includes the following sub-steps: (2.5.1) Semantic segmentation loss is optimized using pixel-level cross-entropy loss to guide the model in learning accurate classifications of cultivated and non-cultivated land areas. Let the model... i The pixel prediction belongs to the category cy The probability is The real label is Then the semantic segmentation loss is expressed as: (1) Where N is the number of pixels in the image, and C is the number of categories; (2.5.2) Boundary-aware loss is constructed using boundary-based F1 score loss. The continuous probability map output by the model is processed by a boundary extraction operator to obtain a soft boundary map, which is then matched with the true label boundary to calculate the boundary accuracy. Recall rate The boundary loss, along with the F1 score, is defined as: (2) (3) (4) in, This indicates the proportion of pixels that overlap between the predicted boundary and the true boundary. This indicates the proportion of the actual boundary that is covered by the predicted boundary. To prevent extremely small constants with a denominator of zero; (2.5.3) Total Loss Function and Co-optimization Mechanism: During model training, the following weighted combination method is used for joint optimization: (5) in, Here, represents the weight coefficients for the boundary loss, and represents an adjustable hyperparameter. Users set its value based on the boundary complexity of the actual training data to achieve a balanced optimization goal between semantics and boundary awareness. This applies to both datasets. Select to conduct experiments, choosing the optimal values ​​for each indicator in each dataset. coefficient as final coefficient.

[0021] Preferably, in step (3), the optimal value of the boundary loss weight on the two datasets is determined by testing the impact of different boundary loss weights on the comprehensive evaluation index. This value is then used for model training. Based on the same experimental environment, the SAM-SANet model is compared with other deep learning methods. The effectiveness of the method is analyzed and verified on the test set using evaluation indicators such as IoU (Intersection over Union), F1-score, Kappa (Kappa coefficient), and overall accuracy. Other deep learning methods include two general semantic segmentation networks: UNet (fully convolutional semantic segmentation network with encoder-decoder structure) and DeepLabV3+ (semantic segmentation network based on dilated convolution and spatial pyramid pooling), as well as two representative semantic segmentation networks in the remote sensing field: UNetformer (an improved version of UNet that integrates Transformer) and CMTFNet (multi-scale feature fusion network).

[0022] A farmland extraction device based on SAM boundary constraints and semantic awareness network is also provided. The device includes: The dataset construction module constructs two remote sensing farmland datasets. Each dataset divides the entire region into 16 sub-grids. The test set retains one complete grid as an independent evaluation region without being cropped. The training and validation sets are divided proportionally in the remaining grids and cut into 256×256 image patches with a 50% overlap rate. The dual-branch collaborative module constructs a dual-branch collaborative SAM-SANet model that combines the semantic perception branch SAB and the boundary constraint SAM branch BCB. The two branches share the input and adopt a multi-task collaborative training mechanism to construct a composite loss function that integrates semantic segmentation loss and boundary constraint loss. The boundary loss is not only used to constrain the mask generation in the BCB branch, but also serves as an auxiliary supervision signal to guide the SAB branch in the structured representation of the farmland boundary. The comparative experiment analysis module determines the optimal experimental parameter settings for training and inference by adjusting network hyperparameters and boundary loss weights, completes the farmland extraction task, and conducts comparative experimental analysis with other deep learning models.

[0023] The present invention will now be described in more detail.

[0024] Step 1: Data Preparation This invention uses two typical farmland remote sensing datasets, JY-CD and QX-CD, as training, verification and testing foundations. GF-1 satellite images of Juye County and Qixia City in Shandong Province are selected respectively, covering various farmland scenes such as regular plains and fragmented mountain plots. Artificial boundary labeling and rasterization are performed during the winter wheat jointing stage and the summer maize silking stage to obtain 256×256 resolution image samples as model input.

[0025] Step 2: Model Building and Training The training sample data described above were input into the SAM-SANet model constructed in this invention for training. The overall model structure consists of a semantic awareness branch (SAB) and a boundary constraint SAM branch (BCB). The SAB extracts multi-scale semantic features of cultivated land areas based on the UNetformer structure, while the BCB perceives boundary cues and optimizes the expression of cultivated land boundaries based on a fine-tuned SAM structure. The two branches share the input image and adopt a multi-task joint optimization strategy, using cross-entropy loss and boundary F1 loss as composite loss functions to guide the collaborative modeling of semantics and boundaries. During training, the optimizer uses stochastic gradient descent (SGD) for 50 rounds. The initial learning rate is set to 0.01, momentum to 0.9, and weight decay coefficient to 0.0005. A multi-stage learning rate adjustment strategy is adopted, with stepwise learning rate decay using a factor γ=0.1 in rounds 25, 35, and 45. In addition, the weight coefficient λ of the boundary loss is used as a key hyperparameter and is individually adjusted for different datasets. The optimal value is selected for each dataset through experiments to improve the overall cultivated land recognition capability under different landform types. After each training round, the mIoU of the current model is calculated using an independent validation set, and the weights of the model with the best performance during training are dynamically recorded. Finally, the model that achieves the highest mIoU on the validation set is selected as the optimal model for inference and evaluation during the testing phase, ensuring optimal farmland extraction performance.

[0026] Step 3: Inference and Performance Verification The optimal SAM-SANet model, saved after training, was used to perform inference and performance evaluation using a test set. Standard remote sensing semantic segmentation evaluation metrics were employed, including IoU, F1-score, Kappa coefficient, and overall accuracy (OA), to evaluate the model's pixel classification accuracy and overall farmland identification capability, respectively. Simultaneously, the performance of the SAM-SANet model was compared with other deep learning models during the testing phase to verify the adaptability of the proposed method in different terrain scenarios.

[0027] Step 4: Comparative Experiment Analysis To verify the effectiveness of the proposed SAM-SANet model, comparative experiments were conducted on two typical remote sensing farmland datasets—JY-CD and QX-CD—based on a unified experimental environment and training parameter settings. The methods compared included general semantic segmentation methods such as UNet and DeepLabV3+, as well as representative semantic segmentation networks for remote sensing scenarios such as UNetformer and CMTFNet. The experiments evaluated the adaptability of the proposed model in scenarios such as regular plains and fragmented mountain farmland from different perspectives. Evaluation metrics included IoU, F1-score, Kappa coefficient, and overall accuracy of OA.

[0028] As shown in Table 1, in the JY-CD dataset (representing a plain scene with regular farmland distribution and a single region), SAM-SANet further demonstrates its fine segmentation capabilities, achieving IoU and F1-scores of 95.88% and 97.96% respectively for farmland categories, with an overall mIoU of 91.17% and mF1 of 95.35%. Although the overall segmentation difficulty in plain areas is relatively low, this method still maintains a leading position in farmland recognition accuracy compared to other comparative models. In the QX-CD dataset (representing mountainous areas with fragmented farmland distribution), facing challenges such as irregular plot boundaries and complex terrain undulations, SAM-SANet achieves an overall mIoU of 71.39% and an F1-score of 82.21%, the highest accuracy among all comparative models, verifying the farmland recognition capability of the method in complex terrain scenes.

[0029] Experimental results fully demonstrate that the SAM-SANet model proposed in this invention exhibits superior segmentation performance compared to existing methods in various remote sensing farmland scenarios.

[0030] Table 1

[0031] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Any simple modifications, equivalent changes, and alterations made to the above embodiments based on the technical essence of the present invention shall still fall within the protection scope of the present invention.

Claims

1. A method for farmland extraction based on SAM boundary constraints and semantic awareness networks, characterized by: The method includes the following steps: (1) Construct two remote sensing farmland datasets. Each dataset divides the entire area into 16 sub-grids. The test set retains one complete grid as an independent evaluation area and does not participate in cropping. The training set and validation set are divided proportionally in the remaining grids and cut into 256×256 image blocks with a 50% overlap rate. (2) A dual-branch collaborative SAM-SANet model combining the semantic perception branch SAB and the boundary constraint SAM branch BCB is constructed. The two branches share the input and adopt a multi-task collaborative training mechanism to construct a composite loss function that integrates semantic segmentation loss and boundary constraint loss. The boundary loss is not only used to constrain the mask generation in the BCB branch, but also serves as an auxiliary supervision signal to guide the SAB branch to express the structured representation of the farmland boundary. (3) By adjusting the network hyperparameters and boundary loss weights, the optimal experimental parameter settings are determined for training and inference to complete the farmland extraction task, and comparative experimental analysis is conducted with other deep learning models.

2. The method for farmland extraction based on SAM boundary constraints and semantic awareness network according to claim 1, characterized in that: In step (1), two different agricultural landscape study areas were selected. The Gaofen-1 GF-1 satellite image provided by the Land Satellite Remote Sensing Application Center of the Ministry of Natural Resources of China was used as the remote sensing data source. The image has a spatial resolution of 2 meters panchromatic and 8 meters multispectral. The Gram-Schmidt algorithm was used to fuse the panchromatic and multispectral images to generate a composite image of red, green and blue bands with a resolution of 2 meters. Then, the Albers equal-area conic projection was used for geometric correction and spatial reference transformation. Remote sensing professionals performed visual interpretation and farmland labeling based on the fused composite image to clarify the scope of farmland and non-farmland.

3. The method for farmland extraction based on SAM boundary constraints and semantic awareness network according to claim 2, characterized in that: Step (2) includes the following sub-steps: (2.1) Construction of the semantic awareness branch SAB based on UNetformer; (2.2) Input size adaptive position embedding adaptation mechanism; (2.3) Multi-scale boundary feature fusion and cue embedding generation; (2.4) Prompt-guided mask decoding and collaborative optimization; (2.5) Design the loss function.

4. The method for farmland extraction based on SAM boundary constraints and semantic awareness network according to claim 3, characterized in that: In step (2.1), as the backbone branch of the SAM-SANet network, the SAB branch undertakes the core task of identifying the overall cultivated land area. This branch dominates the model's ability to model the semantic structure on cultivated land images. During training, the SAB branch not only relies on semantic segmentation loss to optimize its own output, but also receives the boundary mask generated by the boundary constraint SAM branch as a structural supervision signal. The boundary supervision guides the semantic branch to form a clearer predictive response in the boundary-sensitive area through the joint loss mechanism. The SAB branch adopts the UNetFormer structure to construct an encoder-decoder system to extract semantic features of cultivated land areas at multiple scales. The encoder consists of multiple convolutional modules and uses a layer-by-layer downsampling method to extract shallow texture and deep semantic information of the image. The decoder stacks multiple Transformer modules to model long-distance pixel dependencies, capturing the complexity and scale variation features of farmland shapes. Skip connections are established between the encoder and decoder to fuse local details and global contextual information. The decoder outputs pixel-level semantic prediction results for the farmland area.

5. The method for farmland extraction based on SAM boundary constraints and semantic awareness network according to claim 4, characterized in that: In step (2.2), the image encoder in the boundary constraint SAM branch is based on the visual Transformer architecture, which uses a set of predefined absolute position codes. This coding mechanism is highly coupled with a fixed input size, treats the original position embedding matrix as a two-dimensional feature map, and spatially resamples it through bilinear interpolation to match the input feature size. First, obtain the raw absolute position encoding tensor generated by the visual Transformer architecture. Its shape is a two-dimensional tensor. L ori , C ], where C is the embedding dimension, which is reconstructed into a four-dimensional tensor form [1, C , H ori , W ori Based on the current input image resolution, determine the embedding size of the target location. H new × W new Calculate the length of the target sequence L new = H new × W new The reconstructed tensor is subjected to bilinear interpolation to obtain a new, adapted embedded tensor, which is then flattened into a two-dimensional tensor. .

6. The method for farmland extraction based on SAM boundary constraints and semantic awareness network according to claim 5, characterized in that: Step (2.3) includes the following sub-steps: (2.3.1) Feature splicing and fusion: Select multiple shallow and deep Transformer layers to extract feature maps F i For each feature map F i By unifying the channel dimension through a 1×1 convolution operation, all the unified feature maps are concatenated along the channel dimension to construct a fused feature representation. The concatenated feature map contains rich boundary texture information and local contextual semantics from shallow to deep layers. (2.3.2) Deep convolution integration and nonlinear activation: In order to further integrate information from different levels, 3×3 convolution is used to extract local spatial information from the concatenated feature map and enhance the feature consistency of the boundary region. At the same time, BatchNormalization is introduced to improve training stability, and ReLU activation function is used to increase nonlinear expressive power. The final boundary-aware feature map is obtained for subsequent cue embedding generation. (2.3.3) Hint Embedding Generation: Apply 3×3 convolution to the obtained boundary-aware feature map to extract local spatial features, and obtain intermediate representation through ReLU activation function. Set up two parallel 1×1 convolution branches, one of which is used to predict the foreground probability. P obj Measure the confidence level of each candidate box as a cue; The other output bounding box offset is used to adjust the candidate box position. The top K high-confidence regions are selected from the candidate boxes, their coordinates are normalized, and then input into the cue header in the SAM cue encoder to generate the final cue embedding vector, which serves as the guiding information for the subsequent SAM mask decoder.

7. The method for farmland extraction based on SAM boundary constraints and semantic awareness network according to claim 6, characterized in that: In step (2.4), a cue-guided mask decoding mechanism is constructed in the boundary constraint SAM branch BCB. Combining encoded features and cue information, it is used to more finely characterize the farmland boundary structure. The image features extracted by the Transformer encoder are jointly input into the SAM mask decoder along with the high-quality cue embedding vector generated in step (2.3). Class labels are further introduced into the decoder. By fusing image features, cue information, and class priors, the semantic modeling capability in the mask generation process is enhanced. The boundary mask generated in the BCB branch serves as a boundary supervision signal during the training phase. During the training process, it effectively constrains the boundary-sensitive areas in the semantic branch, achieving collaborative optimization of the two branches in farmland area and boundary representation.

8. The method for farmland extraction based on SAM boundary constraints and semantic awareness network according to claim 7, characterized in that: Step (2.5) includes the following sub-steps: (2.5.1) Semantic segmentation loss is optimized using pixel-level cross-entropy loss to guide the model in learning accurate classifications of cultivated and non-cultivated land areas. Let the model... i The pixel prediction belongs to the category cy The probability is The real label is Then the semantic segmentation loss is expressed as: (1) Where N is the number of pixels in the image, and C is the number of categories; (2.5.2) Boundary-aware loss is constructed using boundary-based F1 score loss. The continuous probability map output by the model is processed by a boundary extraction operator to obtain a soft boundary map, which is then matched with the true label boundary to calculate the boundary accuracy. Recall rate The boundary loss, along with the F1 score, is defined as: (2) (3) (4) in, This indicates the proportion of pixels that overlap between the predicted boundary and the true boundary. This indicates the proportion of the true boundary that is covered by the predicted boundary. To prevent extremely small constants with a denominator of zero; (2.5.3) Total Loss Function and Co-optimization Mechanism: During model training, the following weighted combination method is used for joint optimization: (5) in, Here, represents the weight coefficients for the boundary loss, and represents an adjustable hyperparameter. Users set its value based on the boundary complexity of the actual training data to achieve a balanced optimization goal between semantics and boundary awareness. This applies to both datasets. Select to conduct experiments, choosing the optimal values ​​for each indicator in each dataset. coefficient as final coefficient.

9. The method for farmland extraction based on SAM boundary constraints and semantic awareness network according to claim 8, characterized in that: In step (3), the effects of different boundary loss weights on the comprehensive evaluation index on the two datasets are tested to determine the optimal value of the boundary loss weights on the two datasets for model training. Based on the same experimental environment, the SAM-SANet model is compared with other deep learning methods. The effectiveness of the method is analyzed and verified on the test set using the intersection-union ratio, F1 score, Kappa coefficient, and overall accuracy evaluation index. Other deep learning methods include fully convolutional semantic segmentation networks with encoder-decoder structure, semantic segmentation networks based on dilated convolution and spatial pyramid pooling, improved UNet that integrates Transformer, and multi-scale feature fusion networks.

10. A farmland extraction device based on SAM boundary constraints and semantic perception network, characterized in that: The device includes: The dataset construction module constructs two remote sensing farmland datasets. Each dataset divides the entire region into 16 sub-grids. The test set retains one complete grid as an independent evaluation region without being cropped. The training and validation sets are divided proportionally in the remaining grids and cut into 256×256 image patches with a 50% overlap rate. The dual-branch collaborative module constructs a dual-branch collaborative SAM-SANet model that combines the semantic perception branch SAB and the boundary constraint SAM branch BCB. The two branches share the input and adopt a multi-task collaborative training mechanism to construct a composite loss function that integrates semantic segmentation loss and boundary constraint loss. The boundary loss is not only used to constrain the mask generation in the BCB branch, but also serves as an auxiliary supervision signal to guide the SAB branch in the structured representation of the farmland boundary. The comparative experiment analysis module determines the optimal experimental parameter settings for training and inference by adjusting network hyperparameters and boundary loss weights, completes the farmland extraction task, and conducts comparative experimental analysis with other deep learning models.