Sea-land port segmentation method based on space and semantic alignment fusion
By combining the deep convolutional neural network and Transformer, the spatial and semantic alignment fusion method is used to solve the accuracy problem of ship target segmentation in the port area in remote sensing images, achieving accurate identification and segmentation of land and sea boundaries and ship targets, and improving The segmentation effect and model training accuracy are improved.
Patent Information
- Application Number
- CN202411170116.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-08-26
AI Technical Summary
Existing remote sensing image land and sea segmentation technology has problems of missing and wrong classification when identifying and segmenting ship targets in port areas, and cannot effectively handle complex port backgrounds, resulting in inaccurate segmentation.
Using a method based on spatial and semantic alignment and fusion, the deep convolutional neural network and Transformer are combined to extract spatial and semantic features, and the KL divergence alignment loss function is used to perform feature alignment and fusion to improve the segmentation accuracy of the network in the port area.
It achieves accurate segmentation of small targets on land and sea borders and port ships, and improves the segmentation effect and model training accuracy of land and sea port segmentation tasks.
Smart Images

Figure CN118691827A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of deep learning and computer vision technology, and in particular to a sea and land port segmentation method based on spatial and semantic alignment fusion. Background Art
[0002] Optical remote sensing images use remote sensing technology to capture information about the Earth's surface. These images are generated through data collected by remote optical sensors (such as satellites, aircraft, drone cameras, etc.). Due to their high resolution, rich spectral information, and excellent temporal resolution, optical remote sensing images are able to provide detailed surface information. These images are crucial for remote sensing analysis of land and sea segmentation because they provide strong data support, making the analysis more accurate and efficient.
[0003] Remote sensing image segmentation technology achieves accurate identification of different geographical areas by carefully classifying the pixels of the image. Usually, the sea-land segmentation task of remote sensing images divides the image into two categories: ocean and land. However, when facing the port area in remote sensing sea-land images, the sea-land segmentation method shows its limitations and shortcomings. These methods often cannot effectively identify ship targets in the port area, affecting the integrity of port target segmentation. Therefore, the sea-land port segmentation task in the port scene is particularly important.
[0004] Traditional remote sensing image land-sea segmentation techniques, such as threshold segmentation, edge detection, and region growing, mainly rely on the grayscale and texture differences between ocean and land in image pixels for segmentation. However, these methods are often affected by image noise and may ignore the semantic information in the image, resulting in inaccurate segmentation of land-sea boundaries.
[0005] Although the existing land-sea segmentation methods for remote sensing images have been well developed, due to the characteristics of remote sensing images and the complex background of port areas, the land-sea and port segmentation still has the following shortcomings: (1) There are many small targets of ships docked at the dock, and their shapes and sizes are different. These targets are highly similar to the color and texture of port docks and buildings. Therefore, the existing land-sea segmentation network model is difficult to identify and segment ship targets in the port area, and it is easy to miss or misclassify. (2) The port area includes a variety of complex structures such as ships, docks, containers, etc. There may be occlusion and overlap between ships and port facilities. These complex background conditions make the land-sea and port segmentation task more difficult. Summary of the invention
[0006] In order to make up for the above shortcomings, the present invention provides a sea and land port segmentation method based on spatial and semantic alignment fusion, aiming to improve the problem that it is difficult to identify and segment ship targets in port areas, and provide more accurate and reliable segmentation results.
[0007] To achieve the above object, the present invention provides the following technical solution: a method for segmenting land and sea ports based on spatial and semantic alignment fusion, comprising the following steps: S1. Dataset preprocessing: crop and preprocess high-resolution optical remote sensing sea and land images to form a preprocessed dataset, and divide the dataset into training set, validation set, and test set; S2, data enhancement: perform general data enhancement or standardization on the data set to obtain a data-enhanced remote sensing land and sea image data set; S3, feature extraction: The training set images of the dataset are input into the deep convolutional neural network and the feature extraction module of the Transformer in the dual-branch encoder in batches to obtain feature maps at four different levels; S4, spatial and semantic feature alignment and fusion: The features extracted by the deep convolutional neural network and the features extracted by the Transformer are spatially and semantically aligned, and the KL divergence (Kullback-Leibler Divergence) of the feature value distribution of the CNN branch features to be aligned and the Transformer branch features to be aligned is calculated. The network parameters are updated by backpropagation during training to ensure the consistency of the spatial and semantic feature extraction of the Transformer and CNN dual-branch encoders, and then the aligned features are fused; S5. Multi-scale feature fusion: In the decoder stage, the resolution of the deep features after semantic alignment fusion is restored layer by layer by upsampling layer by layer, and the features after spatial alignment fusion and semantic alignment fusion are added at each stage to finally obtain four decoder features of different scales. The four decoder features of different scales are uniformly sampled to the original Figure 1 / 4 resolution size, multi-scale feature fusion, cross entropy loss calculation of the predicted probability value of the multi-scale fusion feature and the true value of the label, and use the auxiliary loss function to supervise and back propagate the multi-scale features; S6, segmentation prediction: upsample the fused features to the original image resolution, perform segmentation prediction, and obtain the final sea and land image segmentation result; S7. Network model training: The segmentation results predicted by the sea-land segmentation network are calculated with the actual sea-land segmentation labels through cross entropy loss, and the network parameters are updated through back propagation to improve the accuracy of the prediction results of the sea-land segmentation network.
[0008] Preferably, in S3, the dual-branch encoder includes a Transformer encoder and a CNN encoder; in the CNN branch encoder, a pre-trained ResNet50 network is used to perform feature extraction to obtain local spatial detail features; in the Transformer branch encoder, a pre-trained SegFormer network is used to perform feature extraction to obtain global contextual semantic features.
[0009] Preferably, S3 comprises the following steps: In the CNN branch encoder, the ResNet50 network obtains four CNN features with spatial local information through four stages of residual blocks and pooling downsampling. ,in , and represents the width and height of the input image, ; In the Transformer branch encoder, the SegFormer network first divides the input image into multiple overlapping image blocks and extracts image features through overlapping feature block embeddings; then the feature blocks pass through 4 stacked Transformer blocks, and the resolution of the feature map becomes 100% of the original image after each Transformer block. , and finally obtain four global semantic information, ,in , and represents the width and height of the input image, .
[0010] Preferably, step S4 comprises the following steps: S401, extract the first two shallow features of the CNN branch and the Transformer branch from the dual-branch encoder and ,in , respectively align the spatial features of the first two shallow layers of the dual-branch encoder; The shallow features of the CNN branch Shallow features with Transformer branches As the input of the spatial feature alignment module, the CNN branch features are Convolution achieves dimensionality reduction and obtains the features to be aligned for the CNN branches , linearly map the Transformer branch features to obtain the Transformer branch features to be aligned The above process can be expressed as (1) (2) in, and represents the width and height of the input feature map, and Represents the number of channels of CNN feature map and Transformer feature map respectively, represents the feature alignment channel dimension, express convolution, Represents a linear mapping, the number of channels The input is linearly mapped to the number of channels Output: S402, perform spatial feature alignment on the features to be aligned of the two branches, and reduce the difference in feature distribution of the two branches by calculating the KL divergence between the feature distributions of the CNN and Transformer branches. The specific calculation formulas of the alignment loss function and the KL divergence are as follows: (3) in, ( ) represents the KL divergence, and Represents CNN branch features and Transformer branch features respectively. The characteristic value distribution of samples, Indicates the total number of sample pixels of the feature map; S403, fusion of shallow features extracted by the dual-branch encoder, first CNN branch features are used in the spatial feature fusion module Convolution achieves dimensionality reduction and obtains the characteristics of CNN branches , combining CNN features with the features of the Transformer branch Features are concatenated by channel, where and Represents the height and width of the input feature map, Indicates the number of feature map channels, and then performs maximum pooling and average pooling on the concatenated features, and passes a Convolution is used to capture local spatial relationships and reduce channel dimensions. After convolution layer processing and Sigmoid activation function, the model outputs a two-dimensional spatial attention weight map. , use the spatial attention weight map to perform element-wise multiplication on the features of the two branches to obtain two spatial attention enhanced features and Finally, the enhanced features are added element by element to obtain the spatially fused features , the above calculation process formula is as follows: (4) (5) (6) in, represents the characteristics of the double-branch channel after splicing, [ ] indicates channel splicing operation, ( ) represents the Sigmoid activation function, express convolution, ( )and ( ) represent the average pooling operation and the maximum pooling operation respectively, Represents element-wise multiplication operation; S404, extract the last two shallow features of the CNN branch and the Transformer branch from the dual-branch encoder and ,in , respectively align the semantic features of the last two deep layers of the dual-branch encoder; The deep features of CNN branches Deep features with Transformer branches As the input of the semantic feature alignment module, and represents the width and height of the input feature map, and Represents the number of channels of CNN feature map and Transformer feature map respectively; In the semantic feature alignment module, a learnable linear mapping is added to the CNN feature alignment process, the purpose of which is to retain the local detail information of the branch features and supplement the global context information and deep semantic information from the Transformer branch; After linear mapping, the CNN branch features to be aligned are obtained ,use Convolution performs channel dimension reduction on the Transformer branch features to obtain the Transformer branch features to be aligned ; The above process is shown in the following formula: (7) (8) in, represents the feature alignment channel dimension, express convolution, Represents a linear mapping, the number of channels The input is linearly mapped to the number of channels Output: S405, semantic feature alignment of the features to be aligned of the two branches: by calculating the KL divergence between the feature distributions of the CNN and Transformer branches, the difference in feature distributions of the two branches is reduced. The specific calculation formulas of the alignment loss function and the KL divergence are as follows: (9) in, ( ) represents the KL divergence, and Represents CNN branch features and Transformer branch features respectively. The characteristic value distribution of samples, Represents the total number of sample pixels of the feature map; S406, fusion of deep features extracted by the dual-branch encoder: First, the features of the CNN branches are and the characteristics of the Transformer branch Perform linear mapping to obtain the query matrix generated by CNN branch features , key matrix Sum Matrix , and the query matrix generated by the Transformer branch , key matrix Sum Matrix , the specific calculation formula is as follows: (10) (11) in, and represents the width and height of the input feature map, and Represents the number of channels of CNN feature map and Transformer feature map respectively, Indicates the number of channels of the linear mapping; The semantic feature fusion module needs to perform cross-attention calculations on the CNN branch and the Transformer branch respectively. According to the characteristics of the deep features of the two branches, it is divided into global enhanced cross-attention and local enhanced cross-attention. In the global enhanced criss-cross attention module, the query matrix of the Transformer branch is As the query matrix of the cross attention, the key matrix of the CNN branch Sum Matrix As the key matrix and value matrix of criss-cross attention, to calculate the global enhanced criss-cross attention feature ; In the local enhanced criss-cross attention module, the query matrix of the CNN branch As the query matrix of the cross attention, the key matrix of the Transformer branch Sum Matrix As the key matrix and value matrix of criss-cross attention, to calculate the global enhanced criss-cross attention feature The specific calculation process of the global enhanced cross attention module and the local enhanced cross attention module is as follows: (12) (13) in, ( ) indicates cross attention, ( )express Activation function, Indicates the number of cross attention heads; Then the original features of the two branches are spliced through channels, using Convolution is used to reduce the dimension of channels and obtain the fusion features of the two branches. The features are superimposed element by element with the global enhanced cross attention features and the local enhanced cross attention features to achieve the fusion between the original two-branch fusion features and the cross attention enhanced features. Finally, the features after feature fusion are output. ; The calculation process is as follows: (14) in, [ ] indicates channel-by-channel splicing operation.
[0011] Preferably, S5 comprises the following steps: S501. First, semantic feature fusion is performed on the features extracted by the dual-branch encoder in the fourth stage. The decoder uses the bilinear interpolation method to upsample the fused deep features layer by layer. During the upsampling process, the fusion features of the semantic feature fusion module and the spatial feature fusion model are added to obtain four decoder features of different scales. ,in , and represents the width and height of the input image, Indicates the number of channels of the four decoded features; S502: Upsample the decoder features of four different scales to the original image Resolution size, channel fusion of the four features, and then use Convolution performs channel dimension reduction to achieve multi-scale fusion and obtain fusion features Finally, the fused features are upsampled to the original image resolution, segmentation prediction is performed, and auxiliary loss function calculation is performed; the specific calculation process is as follows: (15) (16) in, express convolution, [ ] represents the feature channel concatenation operation, represents the auxiliary loss function, and Respectively represent the predicted probability value and label true value of the multi-scale fusion feature, Represents the total number of pixels of the sample image, represents the total number of segmentation categories, and Respectively represent The samples belong to The predicted probability and true value of the class segmentation.
[0012] Preferably, a land and sea port segmentation system based on spatial and semantic alignment fusion uses the land and sea port segmentation method based on spatial and semantic alignment fusion, the system includes a preprocessing and data enhancement module, a dual-branch encoder, a spatial and semantic alignment fusion module and a multi-scale fusion module; The preprocessing and data enhancement module is used to perform image cropping and data enhancement on the input high-resolution optical remote sensing sea and land segmentation image to form a preprocessed image data set; The dual-branch encoder inputs the preprocessed image dataset into the pre-trained ResNet50 backbone network and the SegFormer backbone network for feature encoding, and extracts four different levels of features; The spatial and semantic alignment fusion module performs feature alignment on the features extracted by the dual-branch encoder, optimizes the dual-branch feature alignment process through back propagation, and then performs feature fusion on the aligned features; The multi-scale fusion module uses an auxiliary loss function to perform fusion supervision and back-propagation on the multi-scale features based on the decoder features fused by the spatial and semantic alignment fusion modules, thereby improving the multi-scale expression and generalization capabilities of the model. Finally, the fused features are sampled to the original image resolution size, segmentation prediction is performed, and the predicted remote sensing land and sea segmentation results are output to the user.
[0013] Preferably, the module based on spatial and semantic feature alignment and fusion includes a spatial alignment fusion module and a semantic alignment fusion module, the spatial alignment fusion module is composed of a spatial feature alignment module and a spatial feature fusion module, and the semantic alignment fusion module is composed of a semantic feature alignment module and a semantic feature fusion module.
[0014] Preferably, the deep convolutional neural network based on the spatial and semantic alignment fusion module is an encoder-decoder architecture, the encoder part includes dual-branch feature encoding and feature alignment fusion, and the decoder part includes multi-scale feature fusion and segmentation prediction modules.
[0015] The present invention has the following beneficial effects: 1. The present invention is based on Transformer and CNN, which can fully utilize and integrate local detail information and global semantic information, so that the network model can accurately segment the sea-land boundary and small targets of port ships at the same time, thereby improving the segmentation effect of the sea-land-port segmentation task.
[0016] 2. The present invention proposes a spatial and semantic feature alignment and fusion method, which will enhance the dual-branch encoder's ability to extract spatial features and semantic features, and at the same time be able to fuse the Transformer's global and CNN's local detail features, thereby accurately capturing and understanding the global correlation between port targets and improving the sea and land port segmentation effect.
[0017] 3. In the present invention, reverse gradient propagation is performed through the segmentation loss function to train and update the network model parameters, improve the accuracy of sea and land port boundary segmentation, and improve the training accuracy of the network model in remote sensing sea and land port image segmentation. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 This is a network architecture diagram of land and sea port segmentation based on spatial and semantic alignment fusion in the present invention; Figure 2 is a schematic diagram of a spatial alignment fusion module in the present invention; Figure 3 Schematic diagram of the semantic alignment fusion module in the present invention; Figure 4 The segmentation effect diagram and segmentation label diagram of the remote sensing image sea and land port segmentation network of the present invention on the HRSC2016-SL dataset; Figure 5 This is the segmentation effect diagram and segmentation label diagram of the remote sensing image sea, land and port segmentation network on the ISDSD dataset. DETAILED DESCRIPTION
[0019] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0020] Reference Figure 1-Figure 5 , an embodiment provided by the present invention: a method for segmenting land and sea ports based on spatial and semantic alignment fusion, comprising the following steps: S1. Dataset preprocessing: crop and preprocess high-resolution optical remote sensing sea and land images to form a preprocessed dataset, and divide the dataset into training set, validation set, and test set; S2, data enhancement: perform general data enhancement or standardization on the data set to obtain a data-enhanced remote sensing land and sea image data set; S3, feature extraction: The training set images of the dataset are input into the deep convolutional neural network and the feature extraction module of the Transformer in the dual-branch encoder in batches to obtain feature maps at four different levels; S4, spatial and semantic feature alignment and fusion: spatially and semantically align the features extracted by the deep convolutional neural network and the features extracted by the Transformer, calculate the KL divergence of the feature value distribution of the CNN branch features to be aligned and the Transformer branch features to be aligned, back-propagate and update the network parameters during training to ensure the consistency of the Transformer and CNN dual-branch encoders in spatial and semantic feature extraction, and then fuse the aligned features; S5. Multi-scale feature fusion: In the decoder stage, the resolution of the deep features after semantic alignment fusion is restored layer by layer by upsampling layer by layer, and the features after spatial alignment fusion and semantic alignment fusion are added at each stage to finally obtain four decoder features of different scales. The four decoder features of different scales are uniformly sampled to the original Figure 1 / 4 resolution size, multi-scale feature fusion, cross entropy loss calculation of the predicted probability value of the multi-scale fusion feature and the true value of the label, and use the auxiliary loss function to supervise and back propagate the multi-scale features; S6, segmentation prediction: upsample the fused features to the original image resolution, perform segmentation prediction, and obtain the final sea and land image segmentation result; S7. Network model training: The segmentation results predicted by the sea-land segmentation network are calculated with the actual sea-land segmentation labels through cross entropy loss, and the network parameters are updated through back propagation to improve the accuracy of the prediction results of the sea-land segmentation network.
[0021] Among them, reference Figure 1In S3, the dual-branch encoder includes a Transformer encoder and a CNN encoder; in the CNN branch encoder, a pre-trained ResNet50 network is used to extract features to obtain local spatial detail features; in the Transformer branch encoder, a pre-trained SegFormer network is used to extract features to obtain global contextual semantic features.
[0022] Specifically, S3 includes the following steps: In the CNN branch encoder, the ResNet50 network obtains four CNN features with spatial local information through four stages of residual blocks and pooling downsampling. ,in , and represents the width and height of the input image, ; In the Transformer branch encoder, the SegFormer network first divides the input image into multiple overlapping image blocks and extracts image features by embedding overlapping feature blocks; then the feature blocks pass through 4 stacked Transformer blocks, and the resolution of the feature map becomes 1 / 2 of the original image after each Transformer block. , and finally obtain four global semantic information, ,in , and represents the width and height of the input image, .
[0023] refer to Figure 2 and Figure 3 , step S4 comprises the following steps: S401, extract the first two shallow features of the CNN branch and the Transformer branch from the dual-branch encoder and ,in , respectively align the spatial features of the first two shallow layers of the dual-branch encoder; The shallow features of the CNN branch Shallow features with Transformer branches As the input of the spatial feature alignment module, the CNN branch features are Convolution achieves dimensionality reduction and obtains the features to be aligned for the CNN branches , linearly map the Transformer branch features to obtain the Transformer branch features to be aligned , the above process is expressed by the formula: (1) (2) in, and represents the width and height of the input feature map, and Represents the number of channels of CNN feature map and Transformer feature map respectively, represents the feature alignment channel dimension, express convolution, Represents a linear mapping, the number of channels The input is linearly mapped to the number of channels Output: S402, perform spatial feature alignment on the features to be aligned of the two branches, and reduce the difference in feature distribution of the two branches by calculating the KL divergence between the feature distributions of the CNN and Transformer branches. The specific calculation formulas of the alignment loss function and the KL divergence are as follows: (3) in, ( ) represents the KL divergence, and Represents CNN branch features and Transformer branch features respectively. The characteristic value distribution of samples, Represents the total number of sample pixels of the feature map; S403, fusion of shallow features extracted by the dual-branch encoder, first CNN branch features are used in the spatial feature fusion module Convolution achieves dimensionality reduction and obtains the characteristics of CNN branches , combining CNN features with the features of the Transformer branch Features are concatenated by channel, where and Represents the height and width of the input feature map, Indicates the number of feature map channels, and then performs maximum pooling and average pooling on the concatenated features, and passes a Convolution is used to capture local spatial relationships and reduce channel dimensions. After convolution layer processing and Sigmoid activation function, the model outputs a two-dimensional spatial attention weight map. , use the spatial attention weight map to perform element-wise multiplication on the features of the two branches to obtain two spatial attention enhanced features and Finally, the enhanced features are added element by element to obtain the spatially fused features , the above calculation process formula is as follows: (4) (5) (6) in, represents the characteristics of the double-branch channel after splicing, [ ] indicates channel splicing operation, ( ) represents the Sigmoid activation function, express convolution, ( )and ( ) represent the average pooling operation and the maximum pooling operation respectively, Represents element-wise multiplication operation; S404, extract the last two shallow features of the CNN branch and the Transformer branch from the dual-branch encoder and ,in , respectively align the semantic features of the last two deep layers of the dual-branch encoder; The deep features of CNN branches Deep features with Transformer branches As the input of the semantic feature alignment module, and represents the width and height of the input feature map, and Represents the number of channels of CNN feature map and Transformer feature map respectively; In the semantic feature alignment module, a learnable linear mapping is added to the CNN feature alignment process, the purpose of which is to retain the local detail information of the branch features and supplement the global context information and deep semantic information from the Transformer branch; After linear mapping, the CNN branch features to be aligned are obtained ,use Convolution performs channel dimension reduction on the Transformer branch features to obtain the Transformer branch features to be aligned ; The above process is shown in the following formula: (7) (8) in, represents the feature alignment channel dimension, express convolution, Represents a linear mapping, the number of channels The input is linearly mapped to the number of channels Output: S405, semantic feature alignment of the features to be aligned of the two branches: by calculating the KL divergence between the feature distributions of the CNN and Transformer branches, the difference in feature distributions of the two branches is reduced. The specific calculation formulas of the alignment loss function and the KL divergence are as follows: (9) in, ( ) represents the KL divergence, and Represents CNN branch features and Transformer branch features respectively. The characteristic value distribution of samples, Represents the total number of sample pixels of the feature map; S406, fusion of deep features extracted by the dual-branch encoder: First, the features of the CNN branches are and the characteristics of the Transformer branch Perform linear mapping to obtain the query matrix generated by CNN branch features , key matrix Sum Matrix , and the query matrix generated by the Transformer branch , key matrix Sum Matrix , the specific calculation formula is as follows: (10) (11) in, and represents the width and height of the input feature map, and Represents the number of channels of CNN feature map and Transformer feature map respectively, Indicates the number of channels of the linear mapping; The semantic feature fusion module needs to perform cross-attention calculations on the CNN branch and the Transformer branch respectively. According to the characteristics of the deep features of the two branches, it is divided into global enhanced cross-attention and local enhanced cross-attention. In the global enhanced criss-cross attention module, the query matrix of the Transformer branch is As the query matrix of the cross attention, the key matrix of the CNN branch Sum Matrix As the key matrix and value matrix of criss-cross attention, to calculate the global enhanced criss-cross attention feature ; In the local enhanced criss-cross attention module, the query matrix of the CNN branch As the query matrix of the cross attention, the key matrix of the Transformer branch Sum Matrix As the key matrix and value matrix of criss-cross attention, to calculate the global enhanced criss-cross attention feature The specific calculation process of the global enhanced cross attention module and the local enhanced cross attention module is as follows: (12) (13) in, ( ) indicates cross attention, ( )express Activation function, Indicates the number of cross attention heads; Then the original features of the two branches are spliced through channels, using Convolution is used to reduce the dimension of channels and obtain the fusion features of the two branches. The features are superimposed element by element with the global enhanced cross attention features and the local enhanced cross attention features to achieve the fusion between the original two-branch fusion features and the cross attention enhanced features. Finally, the features after feature fusion are output. ; The calculation process is as follows: (14) in, [ ] indicates channel-by-channel splicing operation.
[0024] The S5 comprises the following steps: S501. First, semantic feature fusion is performed on the features extracted by the dual-branch encoder in the fourth stage. The decoder uses the bilinear interpolation method to upsample the fused deep features layer by layer. During the upsampling process, the fusion features of the semantic feature fusion module and the spatial feature fusion model are added to obtain four decoder features of different scales. ,in , and represents the width and height of the input image, Indicates the number of channels of the four decoded features; S502: Upsample the decoder features of four different scales to the original image Resolution size, channel fusion of the four features, and then use Convolution performs channel dimension reduction to achieve multi-scale fusion and obtain fusion features Finally, the fused features are upsampled to the original image resolution, segmentation prediction is performed, and auxiliary loss function calculation is performed; the specific calculation process is as follows: (15) (16) in, express convolution, [ ] represents the feature channel concatenation operation, represents the auxiliary loss function, and Respectively represent the predicted probability value and label true value of the multi-scale fusion feature, Represents the total number of pixels of the sample image, represents the total number of segmentation categories, and Respectively represent The samples belong to The predicted probability and true value of the class segmentation.
[0025] In this embodiment, the deep convolutional neural network is a ResNet50 structure.
[0026] A land and sea port segmentation system based on spatial and semantic alignment fusion, using a land and sea port segmentation method based on spatial and semantic alignment fusion, including a preprocessing and data enhancement module, a dual-branch encoder, a spatial and semantic alignment fusion module and a multi-scale fusion module; The preprocessing and data enhancement module is used to perform image cropping and data enhancement on the input high-resolution optical remote sensing sea and land segmentation images to form a preprocessed image dataset; The dual-branch encoder inputs the preprocessed image dataset into the pre-trained ResNet50 backbone network and the SegFormer backbone network for feature encoding, and extracts four different levels of features; Based on the spatial and semantic alignment fusion module, the features extracted by the dual-branch encoder are aligned, and the dual-branch feature alignment process is optimized through back propagation, and then the aligned features are fused.
[0027] The multi-scale fusion module uses an auxiliary loss function to perform fusion supervision and back-propagation on the multi-scale features based on the decoder features fused by the spatial and semantic alignment fusion modules, thereby improving the model's multi-scale expression and generalization capabilities. Finally, the fused features are sampled to the original image resolution size, segmentation prediction is performed, and the predicted remote sensing land and sea segmentation results are output to the user.
[0028] The spatial and semantic feature alignment fusion module includes a spatial alignment fusion module and a semantic alignment fusion module. The spatial alignment fusion module is composed of a spatial feature alignment module and a spatial feature fusion module. The semantic alignment fusion module is composed of a semantic feature alignment module and a semantic feature fusion module.
[0029] The deep convolutional neural network based on the spatial and semantic alignment fusion module is an encoder-decoder architecture. The encoder part includes dual-branch feature encoding and feature alignment fusion, and the decoder part includes multi-scale feature fusion and segmentation prediction modules.
[0030] The segmentation accuracy of this embodiment is compared with several state-of-the-art methods, including UNet, DeepLabv3+, DANet, SegFormer, BANet, UNetFormer, and Swin-UNet. The remote sensing land and sea segmentation datasets used in this experiment are the ISDSD dataset and the HSRC2016-SL dataset. The comparative experiment uses the model methods UNet, DeepLabv3+, DANet, SegFormer, BANet, UNetFormer, and Swin-UNet methods as originally performed.
[0031] After experiments, Table 1 shows the comparative experimental results of the present invention and other methods for land and sea segmentation of remote sensing images on the HRSC2016-SL dataset, where F1 is the F1 score, OA is the overall pixel accuracy, and mIoU is the mean intersection over union index. The results are shown in the following table: Table 1
[0032] After experiments, Table 2 shows the comparative experimental results of the present invention and other methods for land and sea segmentation of remote sensing images on the ISDSD dataset, where F1 is the F1 score, OA is the overall pixel accuracy, and mIoU is the mean intersection over union index. The results are shown in the following table: Table 2
[0033] According to Table 1 and Table 2, the sea and land port segmentation method based on spatial and semantic alignment fusion proposed in the present invention has higher accuracy than other methods on the two data sets.
[0034] Finally, it should be noted that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, it is still possible for those skilled in the art to modify the technical solutions described in the aforementioned embodiments or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for sea and land port segmentation based on spatial and semantic alignment fusion, characterized in that: The following steps are involved: S1. Dataset preprocessing: crop and preprocess high-resolution optical remote sensing sea and land images to form a preprocessed dataset, and divide the dataset into training set, validation set, and test set; S2, data enhancement: perform general data enhancement or standardization on the data set to obtain a data-enhanced remote sensing land and sea image data set; S3, feature extraction: The training set images of the dataset are input into the deep convolutional neural network and the feature extraction module of the Transformer in the dual-branch encoder in batches to obtain feature maps at four different levels; In S3, the dual-branch encoder includes a Transformer encoder and a CNN encoder; in the CNN branch encoder, a pre-trained ResNet50 network is used to extract features to obtain local spatial detail features; in the Transformer branch encoder, a pre-trained SegFormer network is used to extract features to obtain global context semantic features; The S3 comprises the following steps: In the CNN branch encoder, the ResNet50 network obtains four CNN features with spatial local information through four stages of residual blocks and pooling downsampling. ,in , and represents the width and height of the input image, ; In the Transformer branch encoder, the SegFormer network first divides the input image into multiple overlapping image blocks and extracts image features by embedding overlapping feature blocks; The feature block then passes through four stacked Transformer blocks. After each Transformer block, the resolution of the feature map becomes , and finally obtain four global semantic information, ,in , and represents the width and height of the input image, ; S4, spatial and semantic feature alignment and fusion: spatially and semantically align the features extracted by the deep convolutional neural network and the features extracted by the Transformer, calculate the KL divergence of the feature value distribution of the CNN branch features to be aligned and the Transformer branch features to be aligned, back-propagate and update the network parameters during training to ensure the consistency of the Transformer and CNN dual-branch encoders in spatial and semantic feature extraction, and then fuse the aligned features; S5, multi-scale feature fusion: In the decoder stage, the resolution of the deep features after semantic alignment fusion is restored layer by layer by upsampling layer by layer, and the features after spatial alignment fusion and semantic alignment fusion are added at each stage to finally obtain four decoder features of different scales. The four decoder features of different scales are uniformly sampled to 1 / 4 of the resolution of the original image, and multi-scale feature fusion is performed. The predicted probability value of the multi-scale fusion feature and the true value of the label are calculated by cross entropy loss, and the multi-scale features are supervised and back-propagated using an auxiliary loss function; S6, segmentation prediction: upsample the fused features to the original image resolution, perform segmentation prediction, and obtain the final sea and land image segmentation result; S7. Network model training: The segmentation results predicted by the sea-land segmentation network are calculated with the actual sea-land segmentation labels through cross entropy loss, and the network parameters are updated through back propagation to improve the accuracy of the prediction results of the sea-land segmentation network.
2. The method for sea and land port segmentation based on spatial and semantic alignment fusion according to claim 1 is characterized by: The step S4 comprises the following steps: S401, extract the first two shallow features of the CNN branch and the Transformer branch from the dual-branch encoder and ,in , respectively align the spatial features of the first two shallow layers of the dual-branch encoder; The shallow features of the CNN branch Shallow features with Transformer branches As the input of the spatial feature alignment module, the CNN branch features are Convolution achieves dimensionality reduction and obtains the features to be aligned for the CNN branches , linearly map the Transformer branch features to obtain the Transformer branch features to be aligned The above process can be expressed as (1) (2) in, and represents the width and height of the input feature map, and Represents the number of channels of CNN feature map and Transformer feature map respectively, represents the feature alignment channel dimension, express convolution, Represents a linear mapping, the number of channels The input is linearly mapped to the number of channels Output: S402, perform spatial feature alignment on the features to be aligned of the two branches, and reduce the difference in feature distribution of the two branches by calculating the KL divergence between the feature distributions of the CNN and Transformer branches. The specific calculation formulas of the alignment loss function and the KL divergence are as follows: (3) in, ( ) represents the KL divergence, and Represents CNN branch features and Transformer branch features respectively. The characteristic value distribution of samples, Indicates the total number of sample pixels of the feature map; S403, fusion of shallow features extracted by the dual-branch encoder, first CNN branch features are used in the spatial feature fusion module Convolution achieves dimensionality reduction and obtains the characteristics of CNN branches , combining CNN features with the features of the Transformer branch Features are concatenated by channel, where and Represents the height and width of the input feature map, Indicates the number of feature map channels, and then performs maximum pooling and average pooling on the concatenated features, and passes a Convolution is used to capture local spatial relationships and reduce channel dimensions. After convolution layer processing and Sigmoid activation function, the model outputs a two-dimensional spatial attention weight map. , use the spatial attention weight map to perform element-wise multiplication on the features of the two branches to obtain two spatial attention enhanced features and Finally, the enhanced features are added element by element to obtain the spatially fused features , the above calculation process formula is as follows: (4) (5) (6) in, represents the characteristics of the double-branch channel after splicing, [ ] indicates channel splicing operation, ( ) represents the Sigmoid activation function, express convolution, ( )and ( ) represent the average pooling operation and the maximum pooling operation respectively, Represents element-wise multiplication operation; S404, extract the last two shallow features of the CNN branch and the Transformer branch from the dual-branch encoder and ,in , respectively align the semantic features of the last two deep layers of the dual-branch encoder; The deep features of CNN branches Deep features with Transformer branches As the input of the semantic feature alignment module, and represents the width and height of the input feature map, and Represents the number of channels of CNN feature map and Transformer feature map respectively; In the semantic feature alignment module, a learnable linear mapping is added to the CNN feature alignment process, the purpose of which is to retain the local detail information of the branch features and supplement the global context information and deep semantic information from the Transformer branch; After linear mapping, the CNN branch features to be aligned are obtained ,use Convolution performs channel dimension reduction on the Transformer branch features to obtain the Transformer branch features to be aligned ; The above process is shown in the following formula: (7) (8) in, represents the feature alignment channel dimension, express convolution, Represents a linear mapping, the number of channels The input is linearly mapped to the number of channels Output: S405, semantic feature alignment of the features to be aligned of the two branches: by calculating the KL divergence between the feature distributions of the CNN and Transformer branches, the difference in feature distributions of the two branches is reduced. The specific calculation formulas of the alignment loss function and the KL divergence are as follows: (9) in, ( ) represents the KL divergence, and Represents CNN branch features and Transformer branch features respectively. The characteristic value distribution of samples, Indicates the total number of sample pixels of the feature map; S406, fusion of deep features extracted by the dual-branch encoder: First, the features of the CNN branches are and the characteristics of the Transformer branch Perform linear mapping to obtain the query matrix generated by CNN branch features , key matrix Sum Matrix , and the query matrix generated by the Transformer branch , key matrix Sum Matrix , the specific calculation formula is as follows: (10) (11) in, and represents the width and height of the input feature map, and Represents the number of channels of CNN feature map and Transformer feature map respectively, Indicates the number of channels of the linear mapping; The semantic feature fusion module needs to perform cross-attention calculations on the CNN branch and the Transformer branch respectively. According to the characteristics of the deep features of the two branches, it is divided into global enhanced cross-attention and local enhanced cross-attention. In the global enhanced criss-cross attention module, the query matrix of the Transformer branch is As the query matrix of the cross attention, the key matrix of the CNN branch Sum Matrix As the key matrix and value matrix of criss-cross attention, to calculate the global enhanced criss-cross attention feature ; In the local enhanced criss-cross attention module, the query matrix of the CNN branch As the query matrix of the cross attention, the key matrix of the Transformer branch Sum Matrix As the key matrix and value matrix of criss-cross attention, to calculate the global enhanced criss-cross attention feature The specific calculation process of the global enhanced cross attention module and the local enhanced cross attention module is as follows: (12) (13) in, ( ) indicates cross attention, ( )express Activation function, Indicates the number of cross attention heads; Then the original features of the two branches are spliced through channels, using Convolution is used to reduce the dimension of channels and obtain the fusion features of the two branches. The features are superimposed element by element with the global enhanced cross attention features and the local enhanced cross attention features to achieve the fusion between the original two-branch fusion features and the cross attention enhanced features. Finally, the features after feature fusion are output. ; The calculation process is as follows: (14) in, [ ] indicates channel-by-channel splicing operation.
3. The method for sea and land port segmentation based on spatial and semantic alignment fusion according to claim 1 is characterized by: The S5 comprises the following steps: S501. First, semantic feature fusion is performed on the features extracted by the dual-branch encoder in the fourth stage. The decoder uses the bilinear interpolation method to upsample the fused deep features layer by layer. During the upsampling process, the fusion features of the semantic feature fusion module and the spatial feature fusion model are added to obtain four decoder features of different scales. ,in , and represents the width and height of the input image, Indicates the number of channels of the four decoded features; S502: Upsample the decoder features of four different scales to the original image Resolution size, channel fusion of the four features, and then use Convolution performs channel dimension reduction to achieve multi-scale fusion and obtain fusion features Finally, the fused features are upsampled to the original image resolution, segmentation prediction is performed, and auxiliary loss function calculation is performed; the specific calculation process is as follows: (15) (16) in, express convolution, [ ] represents the feature channel concatenation operation, represents the auxiliary loss function, and Respectively represent the predicted probability value and label true value of the multi-scale fusion feature, Represents the total number of pixels of the sample image, represents the total number of segmentation categories, and Respectively represent The samples belong to The predicted probability and true value of the class segmentation.
4. A land and sea port segmentation system based on spatial and semantic alignment fusion, characterized by: Using the sea and land port segmentation method based on spatial and semantic alignment fusion as described in any one of claims 1 to 3, the system includes a preprocessing and data enhancement module, a dual-branch encoder, a spatial and semantic alignment fusion module, and a multi-scale fusion module; The preprocessing and data enhancement module is used to perform image cropping and data enhancement on the input high-resolution optical remote sensing sea and land segmentation image to form a preprocessed image data set; The dual-branch encoder inputs the preprocessed image dataset into the pre-trained ResNet50 backbone network and the SegFormer backbone network for feature encoding, and extracts four different levels of features; The spatial and semantic alignment fusion module performs feature alignment on the features extracted by the dual-branch encoder, optimizes the dual-branch feature alignment process through back propagation, and then performs feature fusion on the aligned features; The multi-scale fusion module uses an auxiliary loss function to perform fusion supervision and back-propagation on the multi-scale features based on the decoder features fused by the spatial and semantic alignment fusion modules, thereby improving the multi-scale expression and generalization capabilities of the model. Finally, the fused features are sampled to the original image resolution size, segmentation prediction is performed, and the predicted remote sensing land and sea segmentation results are output to the user.
5. The sea and land port segmentation system based on spatial and semantic alignment fusion according to claim 4 is characterized by: The module based on spatial and semantic feature alignment and fusion includes a spatial alignment and fusion module and a semantic alignment and fusion module. The spatial alignment and fusion module is composed of a spatial feature alignment module and a spatial feature fusion module. The semantic alignment and fusion module is composed of a semantic feature alignment module and a semantic feature fusion module.
6. The sea and land port segmentation system based on spatial and semantic alignment fusion according to claim 4 is characterized by: The deep convolutional neural network based on the spatial and semantic alignment fusion module is an encoder-decoder architecture, the encoder part includes dual-branch feature encoding and feature alignment fusion, and the decoder part includes multi-scale feature fusion and segmentation prediction modules.
Citation Information
Patent Citations
Cross-modal double-branch complementary fusion image segmentation method and device
CN115482241A
Remote sensing image semantic segmentation method based on double-branch feature fusion
CN115797931A
Sea-land segmentation method based on context attention and boundary perception guidance
CN117635628A
Medical image segmentation method based on boundary perception and bidirectional fusion
CN117830628A
Systems and methods for multi-source domain adaptation for semantic segmentation
WO2021097774A1
Cited By
Hyperspectral image self-supervised clustering method based on local-global double-branch network
CN119380059A
High-resolution remote sensing image semantic segmentation method based on multi-scale depth supervision
CN119559403A
Chinese ancient book entity extraction method based on deep active learning strategy
CN119761372A
Remote sensing image target segmentation method based on multistage feature aggregation and segmentation
CN119919658A
A remote sensing image target segmentation method based on multi-level feature aggregation and segmentation
CN119919658B
