Explainable Superpixel-Guided Graph Vision Transformer for Hyperspectral Image Analysis Authors: Jieli Chen, Kah Phooi Seng, Chee Shen Lim, Li-Minn Ang, Jeremy Smith Published: 2026 ABSTRACT Hyperspectral imaging provides rich spectral–spatial information for fine-grained material discrimination, but effective and interpretable modeling remains challenging because land-cover regions often have irregular spatial structures and class-specific spectral responses. Conventional methods typically rely on fixed grid patches or local neighborhoods, which may not align with natural object boundaries, whereas pure superpixel or graph models may lose fine pixel-level details. This paper proposes an explainable superpixel-guided graph vision transformer (ESG-ViT) for hyperspectral image classification and analysis. The proposed framework contains two complementary branches: a graph superpixel vision transformer (GS-ViT) that represents hyperspectral scenes as adaptive superpixel tokens and injects graph topology into self-attention, and a windowed pixel vision transformer (WP-ViT) that preserves dense local spectral–spatial details through efficient local attention. The two representations are adaptively fused for pixel-wise classification. To support interpretability, the model further derives class-wise superpixel relevance maps and spectral channel importance from gradient responses, revealing both the spatial regions and wavelength channels that contribute to each category. Experiments on multiple benchmark hyperspectral datasets demonstrate that the proposed method improves classification accuracy while producing clearer, more human-aligned explanations. Visualization results show that the model highlights meaningful class-related superpixel regions and assigns distinct spectral-channel importance patterns to different classes. These results indicate that the proposed framework provides an accurate and explainable alternative to conventional patch-based transformers for hyperspectral image analysis. 1. Introduction Hyperspectral imaging records the reflectance of a scene across a large number of contiguous spectral bands. Compared with conventional imagery, hyperspectral images (HSIs) provide detailed spectral responses that support the identification of materials with similar visual appearances [1]. HSI classification has therefore been widely studied in applications such as agricultural monitoring, environmental analysis, mineral exploration, and urban land-cover mapping [2,3]. However, this task remains challenging because HSIs have high spectral dimensionality, limited labeled samples, complex spatial structures, and spectral variability within the same category [1]. Early HSI classification methods mainly relied on spectral features and traditional classifiers, such as support vector machines and sparse representation models [4]. Subsequent convolutional neural network (CNN) methods improved classification by jointly learning spectral and spatial information from local image neighborhoods [5,6]. Although CNNs are effective for local feature extraction, their receptive fields are usually defined by fixed square kernels. Such regular neighborhoods do not always match the irregular boundaries of land-cover regions. Graph convolutional networks (GCNs) address this limitation by representing an HSI as a graph and propagating information among adjacent regions. In particular, superpixel-based graphs reduce computational cost by grouping neighboring pixels into spatially coherent regions [7,8]. However, region aggregation may remove useful pixel-level details, especially near boundaries or within small objects. Vision transformers (ViTs) provide another approach to spatial-context modeling by using self-attention to capture dependencies among visual tokens [9]. Standard ViTs usually divide an image into fixed grid patches. While this representation is convenient, regular patches may cross natural region boundaries and mix pixels belonging to different materials. Applying global attention directly to all HSI pixels is also computationally expensive because the number of tokens increases rapidly with image size. These limitations suggest that a single token representation is insufficient: region-level tokens are useful for structural reasoning, while dense pixel-level tokens remain necessary for preserving local spectral–spatial information. Explainability is also important for HSI analysis. In practical applications, a classification map alone does not reveal why a model assigns a category to a region. It is useful to determine whether the prediction is supported by relevant spatial areas and whether different categories depend on different spectral channels. Existing explainability methods often focus on pixel-level saliency or general attention visualization [10,11]. However, pixel-level maps can be fragmented, and attention weights alone do not directly quantify how the input spectrum affects a class response. An explanation framework for HSI classification should therefore connect spatial regions, graph interactions, and spectral-channel contributions. To address these issues, we propose an Explainable Superpixel-Guided Graph Vision Transformer (ESG-ViT) for hyperspectral image classification. As shown in Figure 1, ESG-ViT uses a dual-branch architecture to model complementary spectral–spatial information. The first branch, named Graph Superpixel Vision Transformer (GS-ViT), represents the HSI as a graph of adaptive superpixel tokens. The superpixel construction follows an existing segmentation strategy [7], while the main design of GS-ViT lies in embedding the resulting graph structure into transformer reasoning. Instead of using graph propagation as an independent post-processing step, GS-ViT injects the normalized superpixel adjacency matrix into the self-attention logits. The graph prior encourages stronger interaction among adjacent and similar regions while retaining the adaptive token interaction of a transformer. The second branch, termed the Windowed Pixel Vision Transformer (WP-ViT), operates on dense pixel-level tokens. WP-ViT restricts self-attention to local windows and uses shifted windows across successive layers. This design reduces the cost of dense pixel modeling while allowing information exchange between neighboring windows. GS-ViT and WP-ViT play different roles: GS-ViT captures region-level context over irregular structures, while WP-ViT preserves local boundaries and spectral–spatial variations that may be weakened by superpixel aggregation. Their outputs are aligned on the original image grid and combined through adaptive pixel–graph transformer fusion. ESG-ViT further provides explanations at both spatial and spectral levels. For spatial interpretation, class-specific input gradients are aggregated within superpixel regions to produce coherent region relevance maps. These maps show which regions contribute most strongly to each category. For spectral interpretation, gradient responses are accumulated across spatial positions to estimate the importance of each spectral channel for each class. The resulting class-channel heatmaps show that different categories rely on different spectral responses. The main contributions of this work are summarized as follows:First, ESG-ViT introduces a dual-branch transformer architecture that combines graph–superpixel modeling with pixel-level complementary for HSI classification.Second, GS-ViT integrates the superpixel graph directly into self-attention, allowing graph topology to guide region-level feature interaction jointly.Third, WP-ViT preserves dense local information with efficient windowed attention and complements the region-level graph representation.Finally, the proposed explainability analysis derives class-specific superpixel relevance maps and spectral-channel importance heatmaps, providing spatial and spectral evidence for model predictions. First, ESG-ViT introduces a dual-branch transformer architecture that combines graph–superpixel modeling with pixel-level complementary for HSI classification. First, ESG-ViT introduces a dual-branch transformer architecture that combines graph–superpixel modeling with pixel-level complementary for HSI classification. Second, GS-ViT integrates the superpixel graph directly into self-attention, allowing graph topology to guide region-level feature interaction jointly. Second, GS-ViT integrates the superpixel graph directly into self-attention, allowing graph topology to guide region-level feature interaction jointly. Third, WP-ViT preserves dense local information with efficient windowed attention and complements the region-level graph representation. Third, WP-ViT preserves dense local information with efficient windowed attention and complements the region-level graph representation. Finally, the proposed explainability analysis derives class-specific superpixel relevance maps and spectral-channel importance heatmaps, providing spatial and spectral evidence for model predictions. Finally, the proposed explainability analysis derives class-specific superpixel relevance maps and spectral-channel importance heatmaps, providing spatial and spectral evidence for model predictions. 2. Related Work 2.1. Hyperspectral Image Classification Hyperspectral image classification requires the joint modeling of spectral responses and spatial context. CNN-based methods improve classification accuracy by exploiting local neighborhoods, but their receptive fields are usually defined by regular kernels. These kernels do not naturally describe land-cover regions with irregular boundaries [5,6]. Graph neural networks provide an alternative representation by propagating information between spatially adjacent pixels or regions [12,13]. Superpixel-based graphs reduce computational cost by grouping neighboring pixels into coherent regions and treating each region as a graph node. CEGCN combines pixel-level CNN features with superpixel-level graph features [7]. MSG-SGAT constructs multistage superpixel graphs and applies sparse graph attention [14]. CEGAT further combines convolutional features with an enhanced graph-attention branch under limited-label conditions [8]. These studies demonstrate the value of region-level graph representations. However, superpixel aggregation may remove useful local variations near boundaries and within small objects. In addition, graph propagation and attention modeling are often implemented as separate stages. More recently, hybrid neural networks that combine different structural architectures (e.g., CNNs, GCNs, and Vision Transformers) have gained considerable popularity in HSI analysis. For instance, Zhong et al. [15] proposed a dual-branch subpixel-guided network to handle fine spatial details alongside spectral signatures. Similarly, a global multiscale hybrid network was introduced by Wang et al. [16] to integrate multi-scale local features with global contextual dependencies. To capture structural relationships among irregular land cover features, GCGV [17] combines graph attention, CNNs, and transformers into a unified dual-branch network. Furthermore, hybrid architectures coupling Vision Transformers with Graph Convolutional Networks (GCNs) [18] have successfully bridged grid-like pixel domains and graph-like non-Euclidean structures for HSI classification. Unlike these hybrid networks that typically merge features from parallel branches at the decision level, ESG-ViT uniquely integrates grid-like and graph-like structures by embedding the irregular superpixel graph topology directly into the Transformer’s self-attention matrix. This allows the model to capture region-level context over irregular structures while retaining dense pixel-level local details and providing inherent multi-level explainability. ESG-ViT addresses these limitations through two complementary branches. GS-ViT inserts the superpixel graph topology directly into transformer attention, while WP-ViT retains dense pixel-level information through local windowed attention. The proposed method therefore uses superpixels as an adaptive structural representation without relying exclusively on region-level features. 2.2. Vision Transformers for Hyperspectral Images Transformers have attracted increasing interest in hyperspectral image classification because self-attention can model dependencies beyond local convolutional neighborhoods [9,19]. SpectralFormer treats spectral signatures as sequences and introduces group-wise spectral embeddings with cross-layer adaptive fusion [20]. SSFTT combines convolutional feature extraction with spectral–spatial tokenization and transformer encoding [21]. Standard vision transformers usually generate tokens from fixed grid patches. Such patches may cross natural region boundaries and mix pixels belonging to different materials. However, applying global attention directly to dense pixel tokens also increases computational cost. Recent methods have introduced multiscale, sparse, or hierarchical attention mechanisms to address these issues [22,23]. Superpixel-based tokenization provides another direction by replacing fixed grid partitions with adaptive regions [24,25]. ESG-ViT extends this idea for hyperspectral analysis by representing superpixels into a graph structure, injecting adjacency information into self-attention, and retaining a parallel windowed pixel branch. In this context, modern Vision Transformers specifically tailored for HSI have redefined spectral–spatial feature learning. For instance, SpectralFormer [20] leverages group-wise spectral embeddings and cross-layer adaptive fusion, while SSFTT [21] combines 3D/2D CNN stems with a Gaussian-weighted tokenization transformer. ESG-ViT extends these transformer architectures by representing superpixels as a graph structure and directly embedding the adjacency prior into the self-attention mechanism. Furthermore, as highlighted in the meta-analysis by Kasetty and Krishnan [26], transform-aware deep learning architectures integrated with explainable AI (XAI) mechanisms represent a critical paradigm shift in remote sensing, enabling models to extract complex spatial–spectral representations while offering transparent decision boundaries. 2.3. Explainable Hyperspectral Image Analysis Explainability remains less developed than classification accuracy in hyperspectral image analysis. Existing approaches commonly use gradient responses or SHAP-based methods to estimate the contribution of input pixels and spectral channels [27,28,29,30]. In land use and land cover (LULC) classification, SHAP-based interpretable frameworks have been successfully applied by Temenos et al. [31] to quantify feature contributions and land-cover boundary influences. However, feature-level SHAP values often entail heavy sampling overheads when scaled to high-dimensional hyperspectral cubes. To make XAI feasible for resource-constrained edge computing environments, De Lucia et al. [32] demonstrated that explainability mechanisms must be co-designed with computationally efficient model backbones. Band-level explanations are useful because different materials may depend on different wavelength ranges. However, channel importance alone does not explain where the model identifies class-related evidence in the scene. Attention visualization provides another form of interpretation, but raw attention weights do not fully describe the contribution of input features to a prediction. Attention rollout and attention flow have been proposed to trace interactions through stacked transformer layers [33]. ESG-ViT combines graph-aware attention analysis with gradient-based explanations. Class-specific gradients are aggregated within superpixel regions to produce spatially coherent relevance maps and accumulated across spatial positions to estimate spectral-channel importance. This provides complementary spatial and spectral evidence for each class prediction. 3. Methodology 3.1. Overall Architecture Hyperspectral image analysis requires a representation that can simultaneously preserve fine spectral–spatial details at the pixel level and exploit the structural consistency of larger homogeneous regions. Pixel-wise deep models are effective for modeling local spectral variations, but they usually process the image on a regular Euclidean grid and may require expensive dense interactions to capture broad spatial context. In contrast, superpixel- and graph-based methods provide a compact representation of spatially coherent regions and are well suited to irregular land-cover structures [7,8]. However, if the image is represented only by superpixel nodes, fine boundaries and within-region spectral variations may be weakened by region averaging. Motivated by these complementary strengths and limitations, the proposed framework adopts a dual-branch transformer design. One branch performs graph-aware reasoning over superpixel tokens, while the other performs local self-attention over dense pixel tokens. The resulting architecture aims to combine region-level semantic consistency, pixel-level detail preservation, and built-in explainability. Let the input hyperspectral image (HIS) be denoted by X∈RH×W×B, where H and W are the spatial dimensions and B denotes the number of spectral bands. The goal is to estimate a pixel-wise class probability map Y^∈RN×C, where N=H×W denotes the number of pixels and C is the number of land-cover classes. Before transformer encoding, the original spectral cube is standardized and passed through a lightweight spectral transformation stem:(1)F=ϕstemX, F∈RH×W×D where ϕstem⋅ denotes the learnable spectral projection and D is the latent feature dimension. In the implementation, D is set to 128. The first main branch is the Graph Superpixel Vision Transformer, denoted as GS-ViT. A superpixel partition is used to convert the image into a set of irregular but spatially coherent regions. Let Q∈0,1N×M denote the pixel-to-superpixel assignment matrix, where M is the number of superpixels. The graph–superpixel branch uses Q to aggregate dense latent features into superpixel tokens and uses the superpixel adjacency matrix A∈RM×M to describe spatial and spectral neighborhood relationships among regions, where the superpixel construction follows an existing LDA-SLIC style strategy [7]. In GS-ViT, superpixel tokens interact through self-attention whose attention scores are biased by the graph structure, allowing the model to retain the flexibility of transformer attention while respecting the spatial organization encoded by A. The second main branch is the Windowed Pixel Vision Transformer, denoted as WP-ViT. This branch operates directly on the dense latent feature map F and regards each pixel location as a fine-grained token. Applying global self-attention to all H×W pixels is usually impractical for hyperspectral scenes because the number of tokens can be very large. Therefore, inspired by [19], WP-ViT adopts local window self-attention, together with shifted windows across successive layers, to capture local spectral–spatial dependencies efficiently. This branch is responsible for preserving details that may be lost during superpixel aggregation, including class boundaries, small objects, and within-superpixel spectral variation. The two branches produce complementary dense representations. The graph–superpixel branch outputs a pixel-restored graph contextual feature Zg∈RN×D, where each pixel receives the graph-enhanced representation associated with its superpixel; the windowed pixel branch outputs a dense pixel feature Zp∈RN×D, which retains local spatial detail and spectral discriminability. The prediction module then adaptively combines these two representations and generates the final class probability map:(2)Y^=softmaxfclsffuseZp,Zg where ffuse⋅ denotes the adaptive pixel–graph transformer fusion operation, and fcls(⋅) denotes the final pixel-wise classifier. Explainability is not attached as a post hoc visualization independent of the model design. Instead, it is supported by the same hierarchical representations used for classification. The graph branch naturally provides region-level evidence because each superpixel token corresponds to a spatially coherent image region. Attention flow [33] among graph–superpixel tokens can therefore be projected back to the image plane, producing interpretable maps that indicate which regions contribute most strongly to the prediction. In addition, gradients with respect to the input spectral bands provide channel-level importance scores, allowing the model to identify which wavelengths are most influential for each class. Consequently, the proposed framework produces explanations at three aligned levels: graph–superpixel attention for region-level reasoning, pixel-level relevance for local spatial evidence, and spectral-band relevance for material-sensitive interpretation. 3.2. Graph Superpixel Vision Transformer (GS-ViT) GS-ViT is designed to model hyperspectral images at the superpixel level. A pixel-level representation preserves local details, but it does not explicitly encode the irregular structure of land-cover regions. Superpixels reduce this redundancy by grouping neighboring pixels with similar spectral–spatial properties, whereas a graph structure can then describe the adjacency and similarity between these regions [7,8,13]. Different from a standard graph convolution, which mainly propagates features along predefined edges, GS-ViT uses the graph as a bias inside self-attention. This keeps the flexible token interaction of a transformer while adding a spatial prior from the superpixel graph. Given the original input HIS X∈RH×W×B, we perform dimensionality reduction via LDA and apply the SLIC algorithm to partition the image into M superpixels. Let Q∈0,1N×M (where N=H×W) be the binary pixel-to-superpixel assignment matrix. The assignment matrix Q is then used to aggregate the latent feature map X0∈RH×Dstem output by the spectral stem. The column-normalized assignment matrix Q¯∈RN×M is defined element-wise as:(3)Q¯im=Qim∑k=1NQkm=QimRm where Q¯im∈0,1 indicates whether pixel i belongs to superpixel region Rm, and Rm represents the total pixel count in superpixel m. The initial superpixel token is not built from mean pooling alone. For superpixel region Rm, GS-ViT combines average and maximum responses:(4)tm0=Avguii∈Rm, Maxuii∈RmWe+pm where ui∈R1×Dstem denotes the projected stem feature at superpixel i, [⋅,⋅] denotes feature concatenation along the channel dimension, We∈R2Dstem×D is the projection weight matrix used to embed the pooled superpixel features into the transformer’s hidden dimension D, and pm∈R1×D represents the learnable position encoding for the mth superpixel token. Both We and pm are parameters initialized using Xavier normal distribution (with zero mean and standard deviation of 2/(2Dstem+D) and are dynamically updated via backpropagation during end-to-end training of the network. The graph is defined by the weighted adjacency matrix A∈RM×M. The element Aij is nonzero when superpixel i and superpixel j are spatially adjacent. Its value reflects their spatial–spectral similarity, computed using a Gaussian radial basis function (RBF) kernel:(5)Aij=exp−f¯i−f¯j2σspec2−s¯i−s¯j2σspat2 where f¯i∈RB is the mean spectral feature vector of superpixel i, s¯i∈R2 represents its spatial center coordinates, and σspec2 and σspat2 are scaling parameters. The detailed process of the superpixel partitioning, region adjacency graph (RAG) construction, and the resulting weighted adjacency matrix is visually illustrated in Figure 2. Before A is used in attention, node self-loops are added and the matrix is normalized:(6)Ag=A+ImaxA+I where I∈RM×M denotes the identity matrix representing node self-loops, and max(⋅) denotes the maximum element-wise value of A+I, ensuring that entry values in Ag are bounded in 0,1. Thus, Ag provides a bounded graph prior for the transformer layers. For the hth attention head in layer l, GS-ViT computes graph-biased attention as:(7)Phl=softmaxQhlKhlTdh+βhAg+Mvalid where Qhl and Khl denote the query and key projections of the superpixel tokens, dh is the head dimension, βh is a learnable graph-bias coefficient, and Mvalid is the attention mask matrix enforcing validity constraints. The first term measures feature similarity between tokens. The second term increases the attention score between graph-connected superpixels. Therefore, the graph does not replace self-attention; it guides the attention distribution. To reduce the information loss caused by superpixel pooling, GS-ViT also merges pixel-level evidence into the graph token stream. Let Zp be the pixel representation pooled by the same superpixel assignment. The fusing update can be represented as:(8)T~l=Tl+ασWgTl,Q¯TZp⊙Q¯TZp where α denotes a learnable scale, σ⋅ is the sigmoid function, ⊙ denotes element-wise multiplication, and Q¯TZp denotes the aligned representation from pixel- to superpixel-level. This gate lets each superpixel token selectively use pixel-level information before graph attention. The graph-biased attention output is then followed by the transformer residual update:(9)Tl+1=T~l+ProjPhlVhl+MLPLNT~l+ProjPhlVhl where Vhl denotes the value projections of the superpixel tokens. After several layers, the refined superpixel tokens are mapped back to the pixel grid. For pixel i, the restored graph feature is:(10)Zgi=TLgi where gi denotes the superpixel index of pixel i, and TL is the final superpixel features. The output Zg is a dense feature map aligned with the original image. It contains graph-level context from neighboring regions and is later fused with the pixel-level representation from WP-ViT. Because the tokens correspond to superpixels, the attention weights in GS-ViT can also be visualized as region-level evidence for the model prediction. 3.3. Windowed Pixel Vision Transformer (WP-ViT) WP-ViT is introduced to preserve dense pixel-level information that may be weakened by superpixel aggregation. Although GS-ViT provides compact region-level context, each superpixel token inevitably summarizes multiple pixels. This is useful for semantic consistency, but it can also smooth subtle spectral differences, narrow boundaries, and small land-cover structures. These details are important in hyperspectral classification, where different classes may have similar spatial appearances but distinct local spectral responses. A direct pixel-level transformer could model these variations, but global self-attention over all pixels is computationally expensive for full HSI scenes. WP-ViT therefore uses local window attention to retain pixel-level resolution while controlling the attention cost. Instead of applying attention to all N pixels at once, WP-ViT partitions the feature map into local windows. To enable spatial–spectral interaction across adjacent windows while maintaining low computational cost, we adopt a shifted window mechanism. In layer l, the feature map of size H×W×C is partitioned into regular non-overlapping windows of size Sw×Sh (denoted as Ωr). In the subsequent layer l+1, the window partitioning is shifted by ([Sw/2],[Sh/2]) pixels from the top-left corner. For a window partition Ωr, self-attention is computed only among the pixels inside that window [19]. For the hth attention head at layer l, the attention matrix is represented as:(11)Ph,rl=softmaxQh,rlKh,rlTdh where Qh,rl, Kh,rl and Vh,rl are the query, key, and value projections of the pixel tokens in window Ωr. The corresponding attention output is:(12)Eh,rl=Ph,rlVh,rl Each WP-ViT block follows a residual transformer structure. After window attention and MLP refinement, the update is then updated as:(13)El+1=El+ProjWAttnLNEl+MLPLNEl+ProjWAttnLNEl In addition, WP-ViT employs a residual path to keep a spectral skip connection from the input latent feature vector to the output pixel representation. This skip path helps retain the original spectral evidence after local spatial attention, which summarized the final pixel-level representation as:(14)Zp=ϕoutEL+ϕskipFp where EL denotes the final pixel features, ϕout(⋅) projects the transformer output to the fusion dimension, and ϕskip(⋅) maps the original latent pixel features to the same dimension. The output Zp is a dense representation aligned with the original image grid. It complements the graph-contextual feature Zg from GS-ViT. WP-ViT emphasizes local spectral–spatial detail, while GS-ViT emphasizes region-level graph context. This separation is important because it prevents the model from relying only on coarse superpixel representations and gives the later fusion module access to both fine and contextual evidence. 3.4. Pixel–Graph Fusion and Classification (PG-FC) The GS-ViT and WP-ViT branches provide different types of evidence. GS-ViT produces a graph-contextual representation in which each pixel receives information from its superpixel and neighboring regions. This is useful for region consistency and long-range spatial context. WP-ViT produces a dense pixel representation that preserves local spectral–spatial details and boundary information. Using either branch alone would leave part of the problem under-modeled, where a graph–superpixel branch may smooth local variations, whereas a pixel branch may lack explicit region-level structure. PG-FC is therefore used to combine the two transformer representations before prediction. After the dense graph-contextual representation, Zg and the dense pixel representation Zp are produced by GS-ViT and WP-ViT, respectively. Since both are aligned with the original image grid, they can be fused pixel by pixel. The fusion module first estimates a soft gate from the concatenated features:(15)G=σWfZp,Zg+bf where [⋅,⋅] denotes channel-wise concatenation, σ(⋅) is the sigmoid function, Wf and bf are learnable parameters and bias, respectively. The gate controls how much graph–superpixel context should be added to each pixel representation. The fused transformer representation is then computed as:(16)Zf=ffuseZp,Zg=Zp,Zg,Zp+G⊙Zg This residual form keeps the dense pixel representation as the base feature and selectively injects graph-contextual information. It is useful for HSI classification because the need for graph context may vary across the image. The final classifier receives the pixel representation, the graph representation, and the fused representation, produces Y^ as shown in Equation (2). During training, only labeled pixels are included in the objective. Let Y be the one-hot ground-truth label matrix and Mlabel∈0,1N×1 be the binary label mask. The masked cross-entropy loss is derived as:(17)L=−∑i=1N∑c=1CMlable,icYiclogY^ic This objective follows the standard sparse-label setting in hyperspectral image classification, where only a small subset of pixels is used for supervision. The resulting prediction combines the local precision of WP-ViT and the region-level context of GS-ViT through adaptive pixel–graph transformer fusion. 3.5. Explainable Attention and Gradient Analysis (EAGA) EAGA is designed to identify which spatial regions and spectral bands support the model prediction. This is important for hyperspectral image analysis because a class decision is often determined by both spatial context and wavelength-specific responses [1]. Although transformer attention can indicate interactions among tokens, attention alone does not directly quantify how the input spectrum affects a class score [33]. Therefore, the main explanation in EAGA is based on class-specific gradients with respect to the input HSI. These gradients are then organized into pixel-level relevance, superpixel-level relevance, and spectral-band importance. For a target class c, let sc denote the class score used for explanation. The score may correspond to the response at a selected pixel or to an aggregated class response over a predicted class region. The sensitivity of this score to the input value at pixel j and spectral band b is defined as:(18)Gcj,b=∂sc∂Xj,b The absolute value is used because both positive and negative changes in the input can indicate that a spatial–spectral component influences the class decision. By summing the sensitivity over all spectral bands, the pixel-level class relevance is obtained as:(19)Rcpixelj=∑b=1BGcj,b This relevance map indicates which image locations most affect the target class score. Pixel-level gradients can be spatially fragmented, especially in hyperspectral scenes where neighboring pixels often belong to the same material. Since the proposed model reasons explicitly over superpixel regions, EAGA further aggregates pixel relevance within each superpixel. For the mth superpixel region Rm, the superpixel-level relevance can be expressed as:(20)Rcspm=1Rm∑j∈RmRcpixelj This is the main spatial explanation used in EAGA. It converts dense gradient sensitivity into region-level evidence aligned with the graph–superpixel representation. The region relevance can be restored to the image plane by assigning each pixel the relevance value of its corresponding superpixel:(21)R~cspj=Rcspgj where gj denotes the superpixel index of pixel j. This produces an explanation map whose spatial units are consistent with the GS-ViT tokens. The same gradient tensor is also used to derive spectral-band importance. Instead of summing over bands, the sensitivity of each band is accumulated over all spatial positions:(22)Rcbandb=∑j=1NGcj,b This score measures how strongly the bth spectral channel contributes to the target class score across the image. To compare the relative contribution of different bands within the same class, the band relevance is computed:(23)R¯cbandb=Rcbandb∑b′=1BRcbandb′+ϵ where ϵ denotes a small positive constant used to avoid division by zero. The ranked values of R¯cband(b) identify the wavelengths that are most influential for class c. This provides a spectral explanation that is directly tied to the physical nature of hyperspectral data. Attention-based evidence is used as a complementary explanation. The attention flow in GS-ViT indicates how information is transferred among superpixel tokens, while graph-biased attention shows how adjacency-guided region interactions affect the prediction. These attention responses are projected back to the image grid through the superpixel assignment. Together, gradient relevance and attention evidence provide a multi-level explanation: pixel relevance describes local sensitivity, superpixel relevance describes region-level class evidence, spectral-band importance describes wavelength contribution, and attention maps describe graph–superpixel interaction. 4. Experiments 4.1. Datasets Experiments are conducted on four widely used hyperspectral image classification benchmarks: Indian Pines, Pavia University, Salinas [34], and WHU-Hi-LongKou [35]. These datasets cover different land-cover distributions and scene structures, allowing the proposed method to be evaluated under both agricultural and urban conditions. Indiana Pines contains agricultural categories with strong class imbalance and high inter-class spectral similarity. Pavia University represents an urban scene with classes such as asphalt, meadows, gravel, trees, bare soil, and shadows. Salinas is an agricultural scene with larger homogeneous crop regions and several spectrally similar vegetation categories. To further validate the robustness and generalization of ESG-ViT, we evaluate its performance on a modern, high-resolution UAV-borne HSI dataset: WHU-Hi-LongKou [35], acquired by a Headwall Nano-Hyperspec sensor over an agricultural scene with nine land-cover categories. The Indian Pines image has a spatial size of 145×145, with 200 spectral bands after removing water absorption bands, and contains 16 land-cover classes. The Pavia University image has a spatial size of 610×340, with one hundred and three spectral bands and nine classes. The Salinas image has a spatial size of 512×217, with 204 spectral bands and 16 classes. Background pixels are excluded from model training and evaluation. The WHU-Hi-LongKou image has a spatial size of 550×400, with two hundred and seventy spectral bands, and contains nine land-cover classes. Background pixels are excluded from model training and evaluation. The class-wise sample information and the training, validation, and test splits are reported separately for the four datasets in Table 1, Table 2, Table 3 and Table 4. 4.2. Experimental Settings Each hyperspectral cube is standardized band-wise before being input to the network. Training samples are selected class by class according to the specified training ratio. For Indian Pines, Pavia University, and Salinas, the default training sample ratios are set to 1%, 0.57%, and 0.48%, respectively, with 1% of non-background pixels sampled as the validation set and the rest used for testing. For WHU-Hi-LongKou, a fixed split of 100 labeled samples per category is randomly selected for training and validation, as outlined in Table 4. Each experiment is repeated over five random seeds, and the final quantitative results are reported as mean ± standard deviation. The proposed model is optimized using Adam with a learning rate of 5×10−4. The maximum number of training epochs is set to 600, and the model checkpoint with the lowest validation loss is selected for final testing. Superpixels are generated before network training using the adopted LDA-SLIC-style preprocessing strategy [7]. Unless otherwise stated, the superpixel scale is set to 100. The spectral transformation stem maps the input HSI into 128 latent channels. The GS-ViT and WP-ViT branches use 64-dimensional transformer embeddings in the main configuration, and WP-ViT uses local window attention for efficient dense pixel modeling. The proposed model is optimized using the Adam optimizer with an initial learning rate of 5×10−4, weight decay of 10−4. The maximum number of training epochs is set to 600, and the model checkpoint with the lowest validation loss is selected for final testing. Superpixels are generated before network training using the adopted LDA-SLIC-style preprocessing strategy [7]. Unless otherwise stated, the superpixel scale is set to 100. The spectral transformation stem maps the input HSI into 128 latent channels (C=128). The GS-ViT branch consists of Lgs=4 graph transformer blocks with embedding dimension D=64 and Hgs=4 attention heads. The WP-ViT branch comprises Lwp=4 windowed transformer blocks with the same embedding dimension D=64 and Hwp=4 attention heads, using a local window size of Sw×Sh=7×7. All experiments are conducted on an NVIDIA GeForce RTX 4080 GPU with 16 GB of VRAM under the PyTorch 1.11 framework. The evaluation metrics include overall accuracy (OA), average accuracy (AA), Cohen’s kappa coefficient, and per-class accuracy. OA measures the percentage of correctly classified test pixels, while AA computes the mean accuracy over all classes and is more sensitive to class imbalance. Cohen’s kappa evaluates the agreement between prediction and ground truth after accounting for chance agreement. In addition to quantitative metrics, explanation maps are used to evaluate spatial consistency, boundary preservation, and interpretability. 4.3. Overall Comparison The proposed method is compared with DBDA [36], DBMA [37], FDSSC [38], SSRN [39], CEGCN [7], FDGCN [40], WFCG [41], and CEGAT [8] on Indian Pines, Salinas, and Pavia University; SVM, FNEA-OO [42], SVRFMC [43], CNNCRF [35] on WHU-Hi-LongKou dataset. SSFTT [21] and SpectralFormer [20] are compared as transformer-based baselines. The detailed class-wise accuracies and summary metrics are reported in Table 5, Table 6, Table 7 and Table 8. The evaluation uses overall accuracy (OA), average accuracy (AA), and Cohen’s kappa coefficient. The value in parentheses denotes the standard deviation over repeated runs. For the Indian Pines dataset (Table 5), which is characterized by severe class imbalance and high spectral similarity, the proposed ESG-ViT achieves the highest overall accuracy (OA) of 99.10%, average accuracy (AA) of 98.75%, and a kappa coefficient of 98.97%. Compared to the strongest competing traditional baseline, CEGAT, the proposed method yields improvements of 0.96% in OA, 0.55% in AA, and 1.09% in kappa. Notably, the performance gap is even wider when compared to the newly integrated HSI Transformer baselines: ESG-ViT outperforms SSFTT (97.61% OA) and SpectralFormer (68.49% OA) by 1.49% and 30.61%, respectively. The class-wise metrics further reveal that the proposed model secures the best classification accuracy across most categories, demonstrating the effectiveness of the dual-branch architecture under constrained training sizes. Table 6 presents the classification performance on the Salinas dataset. Here, the proposed model obtains 99.23% OA, 99.66% AA, and 99.15% kappa, outperforming all compared methods and establishing the most balanced land-cover classification map. Relative to CEGAT, the strongest competing traditional baseline, the proposed method enhances OA from 99.18% to 99.23%, AA from 99.47% to 99.66%, and kappa from 99.08% to 99.15%. Crucially, ESG-ViT maintains a clear superiority over the transformer baselines SSFTT (98.32% OA) and SpectralFormer (82.78% OA). While classification on Salinas is often close to saturation, the graph–superpixel context in ESG-ViT successfully stabilizes predictions across large homogeneous crop regions, while the parallel pixel branch retains the discriminative local information necessary to separate fine classes. On the urban scene of the Pavia University dataset (Table 7), the proposed method secures the leading position with 99.33% OA, 98.94% AA, and 99.03% kappa. This represents a steady improvement over the strongest competing baseline, CEGAT (99.20% OA, 98.83% AA, 98.90% kappa), and substantially surpasses the HSI transformer models SSFTT (97.15% OA) and SpectralFormer (78.70% OA). Class-wise evaluation highlights that the model achieves perfect accuracy (100%) on classes 2, 5, and 6, and delivers the highest performance on classes 7 and 8. These results support the merit of combining region-level graph reasoning and dense pixel-level modeling in urban environments containing sharp geometric boundaries and mixed materials. Finally, the model’s scalability was validated on the high-resolution UAV-borne WHU-Hi-LongKou dataset (Table 8). ESG-ViT achieves an outstanding OA of 99.71%, AA of 99.07%, and kappa of 99.62%, consistently outperforming all reference methods. Specifically, compared with its closest competitor, SSFTT, the proposed method yields improvements of 0.30% in OA and 0.39% in kappa, while outperforming CNNCRF and SpectralFormer by 0.80% and 3.04% in OA. The results confirm that embedding the superpixel graph topology as a bias in the self-attention matrix effectively preserves crop boundaries in fine-scale agricultural mapping. It is worth noting that the performance of SpectralFormer, a pure spectral–spatial transformer baseline, is significantly lower than that of SSFTT and the proposed ESG-ViT across the datasets. This disparity highlights a fundamental limitation of pure Transformer architectures in hyperspectral image classification: the lack of local inductive biases. Unlike standard vision tasks with massive pre-training datasets, HSI classification frequently suffers from extremely limited training samples. When trained from scratch, a pure self-attention mechanism struggles to learn local spatial correlations and is highly prone to overfitting. In contrast, SSFTT mitigates this by incorporating a convolutional (3D/2D CNN) stem to extract local spatial–spectral features prior to the transformer blocks. The proposed ESG-ViT goes a step further by directly embedding the superpixel graph topology as a structural bias in the self-attention matrix. The superior performance of SSFTT and ESG-ViT over SpectralFormer demonstrates that incorporating spatial structural priors (either grid-based convolutions or irregular graph topologies) is crucial for Transformer-based architectures to generalize effectively under small-sample constraints. Overall, the proposed method consistently achieves the best classification metrics across all four HSI benchmarks. While the performance gain is particularly prominent on more challenging datasets like Indian Pines and WHU-Hi-LongKou, it remains robust and stable on Salinas and Pavia University. These experimental findings validate the core design of ESG-ViT: the GS-ViT branch ensures global, graph-level regional consistency, the WP-ViT branch preserves local, pixel-level details, and their joint fusion provides robust, edge-preserving classification in diverse remote sensing environments. 4.4. Ablation Studies To systematically evaluate the contribution and necessity of each branch in the dual-branch ESG-ViT architecture, we conduct detailed model ablation experiments on the Salinas dataset under a standard training ratio of 0.48%. Specifically, we compare three distinct configurations: (1) the GS-ViT branch only, (2) the WP-ViT branch only, and (3) the complete dual-branch ESG-ViT model. The experimental results in Table 9 demonstrate that the complete ESG-ViT achieves the highest performance with an OA of 99.23% ± 0.30%. Disabling the GS-ViT branch (WP-ViT only) results in a classification performance of 96.84% ± 0.40% OA, representing a significant accuracy drop of 2.39%. This occurs because, without the GS-ViT branch, the model loses the ability to capture region-level spatial–spectral consistency and long-range topological relationships over irregular land-cover structures, relying solely on local grid-based windows. Conversely, disabling the WP-ViT branch (GS-ViT only) leads to a larger performance degradation of 3.88%. This more severe drop indicates that while the superpixel-level representation is efficient for global context, the spatial aggregation/pooling step inevitably smooths out fine spatial details, narrow crop boundaries, and sub-superpixel spectral variations. Without the dense pixel-level modeling of WP-ViT to preserve local boundaries and details, the model’s discriminative capability is heavily compromised. Therefore, the synergy between the two branches is essential: the GS-ViT branch ensures global and regional structural consistency, while the WP-ViT branch preserves fine spatial–spectral boundaries, and their dynamic fusion via the PG-FC gate yields optimal HSI classification. In the proposed framework, the scale parameter S of the LDA-SLIC algorithm controls the initial size and total number of segmented superpixels (M), which determines the graph topology of the GS-ViT branch. To evaluate the sensitivity and robustness of ESG-ViT to this hyperparameter, we analyze the model’s classification performance under scale parameters of 50, 100, 150, and 200 on the Salinas dataset. Table 9 reports the overall accuracy (OA), average accuracy (AA), and kappa coefficient for each scale. As shown in Table 10, the classification performance of ESG-ViT remains highly stable across the entire range of scale values. The overall accuracy varies from a peak of 99.23% ± 0.29% at scale 100 to 99.18% ± 0.14% at scale 200, representing an extremely narrow fluctuation margin of only 0.05%. The average accuracy (AA) and kappa coefficient exhibit similar robustness, consistently staying above 99.40% and 99.00%, respectively. This parameter stability can be attributed to two main factors: (1) the dual-branch complementary architecture, where the pixel-level branch (WP-ViT) operates independently of the superpixel scale and acts as a “safety net” to capture fine boundary features even when the superpixels are partitioned too coarsely; and (2) the adaptive fusion gate in the PG-FC module, which dynamically regulates the information blend between the two branches pixel-by-pixel. Consequently, if the superpixel scale is set sub-optimally, the fusion module automatically increases the attention weight of the pixel-level branch to compensate for the loss of detail. This structural self-regulation reduces the need for extensive hyperparameter tuning during real-world deployments. 4.5. Computational Cost and Efficiency Evaluation To evaluate the practical efficiency and resource trade-offs of ESG-ViT, we conduct a comprehensive empirical benchmark on the Salinas dataset. Table 11 presents the empirical measurement results, including trainable parameter count (Params, M), floating-point operations (FLOPs, G), training time per epoch (seconds), test inference time per full scene (seconds), peak GPU memory footprint (VRAM, GB), and OA. As presented in Table 11, standard Vision Transformers like SpectralFormer [20] suffer from immense computational overhead, requiring 6748.489 G FLOPs and taking 2.8414 s per scene for test inference. Similarly, SSFTT [21] requires 1164.069 G FLOPs and 0.8579 s per scene. In sharp contrast, the proposed ESG-ViT requires only 231.301 G FLOPs, representing a 29.2-time reduction in FLOPs compared to SpectralFormer and a five-time reduction compared to SSFTT, while completing full-scene test inference in just 0.0412 s (over 68 times faster than SpectralFormer and 20 times faster than SSFTT). Furthermore, Table 11 incorporates branch ablation baselines (GS-ViT Only and WP-ViT Only). GS-ViT Only requires 0.815 M parameters and 138.539 G FLOPs with 95.35% OA, whereas WP-ViT Only requires 0.168 M parameters and 76.712 G FLOPs with 96.84% OA. Fusing both branches into ESG-ViT (1.137 M parameters, 231.301 G FLOPs) boosts classification accuracy to 99.23% OA, demonstrating that the dual-branch integration yields substantial performance gains with negligible inference latency (0.0412 s). As emphasized by De Lucia et al. [32], reducing computational complexity and inference latency while retaining explainability is critical for onboard hyperspectral analysis in resource-constrained edge computing environments. 4.6. Explainability Analysis The explainability analysis evaluates whether the proposed ESG-ViT framework provides meaningful spatial and spectral evidence for its predictions. Hyperspectral image classification depends on both where a material appears (spatial layout) and which spectral channels distinguish it from other classes (spectral signatures). Therefore, our gradient-based Explainable Attention and Gradient Analysis (EAGA) module generates visualizations from two complementary perspectives: (1) region-level spatial explanation, where class-specific gradients are aggregated onto superpixels, and (2) spectral channel importance, which displays a class-wise importance heatmap across the hyperspectral bands. To contextualize the spectral channel analysis, it is important to note that the hyperspectral datasets used in our experiments were acquired by different imaging sensors with distinct physical designs: (1) the Indian Pines and Salinas datasets were captured by the Airborne Visible/Infrared Imaging Spectrometer (AVIRIS) sensor [44], which features 224 spectral bands spanning 400 nm to 2500 nm; (2) the Pavia University dataset was acquired by the Reflective Optics System Imaging Spectrometer (ROSIS-03) sensor [45], recording 115 bands across 430 nm to 860 nm; and (3) the WHU-Hi-LongKou dataset was gathered via a UAV-borne Headwall Nano-Hyperspec sensor [35], which collects 270 channels in the visible and near-infrared range (400 nm to 1000 nm). The preprocessing stage for each dataset removes noisy and atmospheric water absorption bands, resulting in 200, 204, 103, and 270 channels for Indian Pines, Salinas, Pavia University, and WHU-Hi-LongKou, respectively. 4.6.1. Indian Pines Dataset On the Indian Pines dataset, the spatial importance maps (Figure 3) demonstrate that the model successfully concentrates its gradients within the ground-truth boundaries of agricultural fields. For instance, Corn-notill (Class 2) and Soybean-notill (Class 10), which are represented as regular rectangular blocks in the scene, show highly concentrated importance values within their respective field boundaries, showing no leakage into adjacent fields of different categories. This spatial alignment demonstrates that the superpixel-level aggregation effectively suppresses pixel-level noise, mapping class relevance directly to meaningful spatial regions. Spectrally, the channel importance heatmap (Figure 4) provides a macro-level physical explanation of band contribution. Instead of showing scattered, arbitrary band sensitivities, the model exhibits high physical consistency: around channel 90, all categories show complete insensitivity. This region corresponds directly to the strong atmospheric water vapor absorption bands (specifically AVIRIS bands 104–108), where the signal is heavily attenuated and noisy; the model correctly learns to ignore these zero-signal channels. Furthermore, around channel 144, classes 13 to 16 (Wheat, Woods, Buildings-Grass-Trees-Drives, and Stone-Steel-Towers) exhibit a highly pronounced, localized insensitivity, whereas crop classes remain active, suggesting that the model’s feature representation aligns with the distinct spectral profiles of man-made and non-vegetated materials. 4.6.2. Salinas Dataset On the Salinas dataset, which contains large, continuous, and homogeneous crop fields, the spatial relevance maps (Figure 5) highlight the entire fields with high internal homogeneity. For Fallow (Class 3) and Vineyard untrained (Class 15), the highlighted superpixels align precisely with their large-scale crop boundaries. This visual uniformity confirms that the GS-ViT branch successfully propagates spatial–spectral context across irregular superpixel graph nodes, ensuring that agricultural regions are processed as cohesive semantic units. In the spectral domain (Figure 6), the model shows a strong suppression of boundary and noise bands. All classes exhibit near-zero sensitivity around channel 1 and channel 110. The suppression at channel 1 likely represents sensor boundary noise (edge effect), while the band near channel 110 corresponds to the water vapor absorption bands, which are heavily impacted by atmospheric noise and attenuation, thus offering limited discriminative information. In contrast, Class 12 (Lettuce_romaine_5wk) and Class 15 (Vineyard untrained) show highly distinct sensitivity intervals compared to other classes, which is consistent with their characteristic spectral reflectance profiles and crop properties. 4.6.3. Pavia University Dataset The Pavia University dataset represents a complex urban scene containing narrow roads and irregular roofs. The spatial relevance maps (Figure 7) illustrate that the model accurately delineates thin and adjacent urban structures. For instance, Asphalt (Class 1) and Bitumen (Class 7) are sharply distinguished, with the vertical and horizontal asphalt road structures highlighted for Class 1, and bitumen roofs highlighted for Class 7. This sharp spatial delineation confirms that the windowed pixel-level branch (WP-ViT) prevents regional superpixel features from over-smoothing boundaries in fine-scale urban environments Spectrally (Figure 8), all classes show near-zero sensitivity around channel 1 and channel 75. The low sensitivity at channel 1 is consistent with the edge effect of the ROSIS-03 sensor, while the low response around channel 75 may stem from sensor-level response variations or noise bands in this region. Interestingly, the very last channel exhibits high sensitivity across several urban classes, suggesting that this boundary band captures critical spectral information for separating artificial materials. Furthermore, Class 3 (Gravel) and Class 6 (Bare Soil) exhibit highly distinct sensitivity intervals compared to other vegetation-dominated classes (such as Meadows and Trees), reflecting their non-vegetated mineral composition. 4.6.4. WHU-Hi-LongKou Dataset On the high-resolution UAV-borne WHU-Hi-LongKou dataset, the spatial relevance maps (Figure 9) reveal a distinct edge-sensitivity characteristic. Rather than highlighting the uniform interior regions of the classes, the high-gradient superpixels (colored in red and yellow) are concentrated along the spatial transition boundaries (edges) of each category. For example, in the Water category (Class 7), the highlighted regions are located strictly along the canal banks, while the uniform center of the river remains unhighlighted. A similar pattern is observed for crops like Corn (Class 1) and Rice (Class 6), where the outline boundaries of the agricultural plots are highlighted. This indicates that the model’s EAGA gradients are highly sensitive to spatial boundaries where the contrast is highest, representing a limitation in illustrating internal uniformity, but confirming the model’s reliance on edge-preserving details In the spectral domain (Figure 10), the first few channels exhibit near-zero sensitivity across all classes, indicating the model suppresses sensor edge noise. More importantly, two distinct vertical stripes of complete insensitivity are observed around channel 73 and channel 244 for all classes. These regions likely align with noisy channels or spectral response gaps typical of UAV-borne hyperspectral sensors, where the signal contributions are naturally minimized during preprocessing. Meanwhile, Class 3 (Sesame), Class 4 (Broad-leaf soybean), and Class 8 (Roads and houses) show prominent, widespread high sensitivity across many channels. This broad spectral response suggests that the model coordinates visible pigment bands and multiple NIR bands to successfully distinguish these classes from nearby vegetated and man-made backgrounds. 4.6.5. Discussion on Explainability and Interpretation Overall, these visual explanations across all four HSI benchmarks confirm that the proposed ESG-ViT does not generate fragmented, pixel-level noise, nor does it rely on arbitrary global features. The spatial relevance maps are highly coherent, showing a strong alignment with the irregular land-cover boundaries. Meanwhile, the spectral channel heatmaps demonstrate that the model automatically learns physical spectral properties (such as vegetation red-edges, chlorophyll absorption bands, and water absorption characteristics) from the data. This dual-level explainability provides a reliable, physically grounded verification of the model’s decision-making process, making ESG-ViT a robust and transparent tool for remote sensing HSI classification. 5. Conclusions This paper proposed an Explainable Superpixel-Guided Graph Vision Transformer (ESG-ViT) for hyperspectral image analysis. The proposed framework combines two complementary transformer branches. GS-ViT represents irregular land-cover regions as superpixel tokens and incorporates graph adjacency information directly into self-attention. WP-ViT preserves dense local information through windowed pixel-level attention. Their adaptive fusion enables the model to use region-level context without losing important local spectral–spatial details. ESG-ViT also provides explanations from spatial and spectral perspectives. Class-specific gradient responses are aggregated within superpixels to generate coherent region relevance maps, while channel-wise aggregation produces spectral importance heatmaps for different categories. The visualizations show that the model emphasizes relevant spatial regions and uses distinct spectral channels for different classes. Experiments on the Indian Pines, Salinas, and Pavia University datasets demonstrate that ESG-ViT consistently achieves strong classification performance compared with representative methods.