3.2. Semantic Prompt Global–Local Mamba Block
With the continuous improvement of RSI spatial resolution, land-cover objects exhibit increasingly rich, fine-grained texture details, offering neural networks greater potential for learning discriminative representations. However, this also increases the risk of feature overlap among different categories, thereby exacerbating interclass confusion. Moreover, in complex scenarios—such as roads occluded by shadows cast by high-rise buildings—relying solely on local information often fails to provide sufficient context for accurate object recognition. By leveraging scene-level contextual cues, the network can characterize global spatial organization, such as road network continuity and holistic building contours, thereby effectively reducing misclassifications. Therefore, simultaneously modeling long-range global dependencies and multiscale local features is essential to obtain representations characterized by strong intraclass consistency and enhanced interclass separability.
As illustrated in
Figure 3b, the SPGLM block is designed to address the above challenges. In the global branch, the semantic-guided selective scanning 2D (SGSS2D) module injects semantic prompts into the output matrix of the SSM, facilitating semantic-aware adaptive retrieval. These learnable prompts can represent specific sets of pixels sharing similar semantic attributes, which effectively compensates for the loss of contextual details caused by sequential scanning, thereby establishing consistent feature associations across long-range spatial distances. In the local branch, asymmetric convolutions are employed to extract directional geometric details, thereby capturing fine-grained local representations of multiscale targets. By integrating global context and local structural details, SPGLM significantly enhances semantic segmentation performance for RSIs. The following sections detail the key components of the SPGLM block.
Compared with the original VSS block architecture (
Figure 3a) [
27], the proposed SPGLM is structurally optimized to leverage the advantage of SSMs in long-range dependency modeling with linear computational complexity [
51]. The input feature
was processed by two parallel global and local branches, as shown in
Figure 3b, where
B,
H,
W and
C denote the batch size, feature-map height, feature-map width, and channel dimension, respectively. The channel dimension
C was set to 512, 256, and 128 at the three decoder stages, respectively. In the global branch, the input feature first underwent layer normalization (LN) and linear projection to expand the channel dimension to
2C. The projected representation was then refined by a depthwise separable convolution followed by SiLU activation, and the resulting feature was passed to the SGSS2D module. Inspired by MambaIRv2 [
51], the SGSS2D enhances the original SS2D by modifying the output matrix
of the SSM (where
L = HW denotes the flattened image sequence length and
d represents the number of hidden states). Specifically, learnable semantic prompts were injected into matrix
CSSM to mitigate the lack of adaptive semantic awareness in the original SS2D when processing complex remote sensing scenes. This design facilitates the global querying of relevant pixels sharing similar semantic attributes across the image.
As shown in
Figure 3c, we first adopt a low-rank decoupling strategy to construct a prompt pool
comprising
T learnable semantic prompts:
where
denotes the semantic basis matrix used to construct prompts.
M is the coefficient matrix that combines the basis features within a specific block to generate instance-relevant prompts.
denotes the internal rank. This low-rank parameterization lowers the parameter overhead while improving the representation capacity of the prompts.
To achieve pixel-wise adaptive prompt selection, given the input feature
was projected from
C to
T channels via a linear layer. A LogSoftmax function was then applied to estimate the sampling probability of each prompt in
with respect to the current input
. Gumbel-Softmax trick [
52] was then utilized to generate a routing matrix
. Subsequently, instance-specific prompts were obtained through matrix multiplication
, where
. Finally, the generated instance-specific prompt P was incorporated into the output matrix
CSSM via residual addition (
Figure 3d). The corresponding formulation is expressed as:
where
denotes the timescale parameter used to discretize the continuous system parameters
and
into their discrete counterparts
and
;
xt and
yt denote the input feature and output feature at time step
t;
signifies the hidden state at time step
t;
CSSM is the output matrix;
indicates the generated instance-specific semantic prompt;
D represents the feed-forward projection parameters; and
L denotes the flattened image sequence length.
By incorporating prompt learning into the four-directional scanning paths, the SGSS2D module enables each query pixel to attend to regions sharing similar semantic attributes across the image via prompts. This mechanism facilitates adaptive aggregation of global contextual information and promotes deep feature interaction, thereby significantly enhancing intraclass consistency in land-cover representation. Subsequently, the one-dimensional sequence features extracted along different scanning directions were reshaped and reorganized into a 2-D representation aligned with the input spatial resolution. This process constructs a semantically guided global receptive field, facilitating effective global context modeling. The overall formulation is expressed as:
where
Xglobal denotes the output feature of the global branch;
denotes linear projection;
represents layer normalization;
signifies the activation function;
indicates depthwise separable convolution; and
refers to the SGSS2D module.
In the local branch, parallel horizontal and vertical strip convolutions were adopted to model the diverse geometric patterns and prominent directional properties of RSI objects. This design also mitigates the weakness of SSMs in fine-grained local feature representation due to their limited inductive bias [
53,
54]. This design employs orthogonal convolutional paths to effectively capture directional geometric patterns, thereby enhancing multiscale spatial detail representation. The process is formulated as follows:
where
represents a composite operator consisting sequentially of an
convolution, batch normalization and ReLU activation.
Finally, the global semantic features
Xglobal and the local geometric detail features
Xlocal were fused via channel-wise concatenation. A convolutional layer is subsequently applied to facilitate feature interaction and channel alignment, further enriching the semantic representation and yielding fine-grained global–local contextual features. The fusion process is defined as follows:
where
XSPGLM denotes the output feature of the SPGLM block;
represents channel concatenation.
3.3. High-Frequency Adaptive Fusion Module
RSIs contain abundant fine-grained details. However, small-scale objects (e.g., vehicles) often occupy only a few pixels, which makes their characteristics vulnerable to distortion or suppression from background clutter during downsampling. To mitigate this issue, skip connections are widely adopted to integrate multilevel features. Features at different depths exhibit significant representational disparities: shallow features maintain detailed spatial information but lack strong semantic representation, while deep features offer improved semantic discriminability at the cost of fine spatial structures. To effectively integrate shallow spatial features with deep semantic content, existing approaches often utilize element-wise addition or channel concatenation. These fusion strategies usually rely on fixed weighting schemes and cannot adaptively adjust feature contributions according to image content, limiting the complementary interaction between spatial details and semantic information. To address these limitations, we introduced HFAFM, illustrated in
Figure 4. This module explicitly enhances high-frequency details and introduces pixel-level local cross-attention to achieve cross-layer alignment and feature fusion guided by deep semantic information. By integrating shallow spatial information with deep semantics, HFAFM improves the discriminability and consistency of small-scale objects and structural features.
Specifically, the HFAFM comprises two submodules: the multiscale high-frequency enhancement feature module (MHFEM) and the local-window cross-attention adaptive fusion module (LCFM). As illustrated in
Figure 4a, the features output by the first ResBlock were fed into the MHFEM for small-object detail enhancement. MHFEM employs channel and spatial branches to selectively refine fine-grained feature responses. Since small-scale objects occupy only a limited proportion of the original feature maps, directly computing weights from global features is susceptible to interference from low-frequency homogeneous backgrounds. Therefore, we employ a high-pass filter
M that suppresses low-frequency components while preserving high-frequency information [
55,
56,
57], as defined below:
where
is set to 0.3 and controls the suppression range of low-frequency components, thereby reducing low-frequency content while retaining high-frequency information associated with object boundaries and textures.
H and
W denote the height and width of the image, respectively.
In the channel branch, to enhance channels containing critical detail information, a two-dimensional discrete cosine transform (DCT) first mapped the input feature
Fres to frequency-domain coefficients. The high-pass filter
M was then applied, followed by the inverse DCT (IDCT) to restore the feature to the spatial domain, yielding a preliminary enhanced feature
Fhigh_c. Considering that different channels contribute unequally to detail representation, the channel-wise statistics
Favg and
Fmax were derived from
Fhigh_c through average- and max-pooling operations with an output size of
k × k, where
k is set to 16. These statistics were further fused to generate channel attention weights, which were multiplied with
Fres to obtain
. The process is described below:
where
and
denote max pooling and average pooling with an output size of
k × k, respectively.
Within the spatial branch, high-pass filters were applied in parallel to the input feature map and its downsampled feature to capture multiscale structural information of small-scale targets. The frequency-domain features at the two scales were fused and subsequently mapped to the spatial domain via IDCT to yield a spatial attention mask
Mspatial. Multiplying this mask by the original feature map enhances feature responses in high-frequency salient regions, enhancing the edge and texture representations of small objects. This procedure is formulated as follows:
where
and
represent the discrete cosine transform and its inverse, respectively.
and
indicate the 2× downsampling and upsampling implemented by bilinear interpolation.
To adaptively combine the spatial and channel representations, a gated fusion mechanism was introduced at the final stage. Specifically,
Fspatial and
Fchannel were concatenated to dynamically generate an input-dependent gating weight
g, facilitating the weighted aggregation of both feature streams:
where
denotes channel concatenation;
represents the activation function;
denotes a
convolutional layer;
indicates group normalization; and
denotes activation function.
To enhance semantic consistency between deep and shallow features while facilitating cross-level alignment, the LCFM performs weighted fusion of the enhanced shallow high-frequency details
FMHFEM under the guidance of the deep semantic feature
Fx, thereby improving the representation of small-scale targets, as illustrated in
Figure 4b. Specifically, the deep representation
Fx was first upsampled to ensure that its spatial resolution is consistent with that of
FMHFEM. Subsequently, the upsampled
Fx was projected into the query matrix
Q, while
FMHFEM was projected into the key and value matrices
K and
V. To balance computational efficiency and local modeling capability, we divided the feature map into disjoint local windows along the spatial dimensions. The input feature is
, and the window size is
P = p1 × p2, where
. After a reshaping operation, the feature map is rearranged into a series of local windows, resulting in a feature representation of
. In each local window, the similarity between
Q and
K is computed, and the resulting attention weights are normalized using the Softmax function to aggregate
V. This process enables the deep feature representation to adaptively aggregate semantically relevant shallow detail information from
V within each window, thereby achieving pixel-wise adaptive feature interaction. The attention operation is defined as:
where
denotes the channel dimension and
is the scaling factor for normalization.
Finally, the attention output Fattention was merged with the upsampled Fx via a residual connection. The combined representation was refined by a 3 × 3 convolution for spatial integration. A pixel-wise weight map generated by a 1 × 1 convolution was further used to adaptively recalibrate the fused features. This design effectively preserves shallow edge and texture cues, improving the model’s performance in capturing small-scale objects and structural details in complex remote sensing scenes.
3.4. Loss Function
A multi-head supervision strategy was adopted to enhance the training stability of SPFMamba. This strategy consists of a semantic segmentation head and an auxiliary boundary head. The overall loss function is composed of a main loss and an auxiliary loss.
To mitigate class imbalance and preserve regional consistency, the main loss is defined below:
where
N gives the total pixel count;
K specifies the number of classes;
denotes the one-hot encoded ground-truth semantic label; and
represents the predicted probability that pixel
n belongs to class
k, where
.
Considering that multiscale features contain rich structural cues, we introduced an auxiliary boundary branch to explicitly enhance boundary awareness. Specifically, features from different decoder stages, namely
h2,
h3, and
h4 were resampled to a common spatial size, concatenated and then processed by a convolutional layer to obtain a boundary-aware representation. The auxiliary head then transforms this representation into a boundary estimate
yedge. Meanwhile, the ground-truth boundary label
gedge was constructed from the ground-truth segmentation mask using a Laplacian operator followed by binarization. Finally, a binary Dice loss was adopted to measure the consistency of the predicted boundary with ground-truth boundary. The overall loss is:
where
denotes the trade-off hyperparameter between the two loss terms, empirically determined as 0.4 through ablation experiments.