---
title: Spectral Angle Prompting in Hyperspectral Imaging
url: https://www.emergentmind.com/topics/spectral-angle-prompting
type: topic
---

# Spectral Angle Prompting in Hyperspectral Imaging

Spectral Angle Prompting denotes a family of conditioning mechanisms in which spectral similarity, usually expressed through a spectral angle or an angle-equivalent cosine geometry, is converted into a prompt, guidance map, or auxiliary constraint for downstream inference. In the strictest current usage, the term is explicitly introduced in hyperspectral medical image segmentation, where a pixel-wise similarity map between user clicks and a hyperspectral image is used to guide Segment Anything from the input stage [2508.00493]. In a broader research sense, closely related systems use spectral-angle-aware affinity maps for tracking, spectral-angle-aware reconstruction losses for self-supervised hyperspectral learning, or cosine-regularized angular prompt manifolds for visual prompting in open-set defect recognition [2403.05852] [2512.12445] [2604.02905]. The literature therefore treats spectral angle prompting less as a single canonical algorithm than as a prompt-design pattern: spectral or frequency-domain descriptors establish a directional similarity signal, and that signal conditions prediction.

## 1. Definition and conceptual scope

The available literature shows several distinct but related uses of spectral-angle-based prompting. The most literal form appears in "SAMSA 2.0" [2508.00493], which defines spectral angle prompting as a pixel-wise similarity map between user clicks and the image. Each click yields a reference spectrum, every image pixel is compared against that spectrum, and the resulting dense similarity field acts as a soft constraint. This map is not used as a post hoc thresholded mask; it is fused into the prompting pathway of a SAM2.1-based segmenter.

A broader family of methods uses angular similarity as a prompt-like guidance signal without using the exact phrase. In "SSF-Net" [2403.05852], spectral angle awareness is implemented through a template-conditioned affinity map between hyperspectral template and search regions, together with a spectral angle awareness loss that separates positive and negative regions. In "UniSpector" [2604.02905], the relevant structure is not a classical spectral angle between raw spectra but a combination of frequency-domain prompt descriptors and cosine-regularized prompt topology; the paper explicitly characterizes this as spectral feature extraction plus angular prompt-space regularization rather than a literal spectral-angle metric. In "Knowledge-Guided Masked Autoencoder with Linear Spectral Mixing and Spectral-Angle-Aware Reconstruction" [2512.12445], spectral angle functions as a geometry-aware reconstruction signal inside a masked autoencoder, which suggests a loss-driven form of prompting rather than an explicit input prompt.

| Variant | Mechanism | Representative papers |
|---|---|---|
| Dense input prompting | Click-conditioned spectral-angle similarity map fused with image input | [2508.00493] |
| Template-conditioned regional prompting | Spectral-angular affinity map and triplet-style supervision in tracking | [2403.05852] |
| Angular prompt-space structuring | Frequency-domain prompt features with cosine and angular-margin organization | [2604.02905] |
| Reconstruction guidance | SAM-based geometric constraint in self-supervised hyperspectral reconstruction | [2512.12445] |

This suggests that the term now covers both a strict interactive-segmentation meaning and a looser methodological meaning in which angular spectral geometry is used to steer representation learning or prompt-conditioned inference.

## 2. Mathematical foundations

The classical mathematical substrate is the Spectral Angle Mapper (SAM), which measures the angle between two spectral vectors:
\[
\alpha(\mathbf{x}_1,\mathbf{x}_2)=\cos^{-1}\!\left(\frac{\mathbf{x}_1^T\mathbf{x}_2}{\|\mathbf{x}_1\|\,\|\mathbf{x}_2\|}\right).
\]
In hyperspectral classification, this angle has been used directly as a class-conditional unary energy in a spatial-spectral Markov random field, with
\[
E_i(y_i=c)=\min_{\mathbf{x}_{tc}\in\mathcal{T}_c}\alpha(\mathbf{x}_i,\mathbf{x}_{tc}),
\]
so that angle-derived local evidence is later regularized by a Potts spatial prior [1610.06985]. That formulation is not prompting in the modern vision-foundation-model sense, but it already exhibits the essential logic of spectral angle prompting: a direction-based similarity score conditions later inference.

The literature also contains alternative angular measures. "A new hybrid spectral similarity measure for discrimination of Vigna species" [1509.05767] defines the Spectral Correlation Angle (SCA) through the Pearson correlation coefficient,
\[
\operatorname{SCA}(\mathbf{s}_i,\mathbf{s}_j)=\cos^{-1}\!\left(\frac{r_{\mathbf{s}_i,\mathbf{s}_j}+1}{2}\right),
\]
and combines it with Spectral Information Divergence (SID) to form
\[
\operatorname{SIDSCA}_{\tan}(\mathbf{s}_i,\mathbf{s}_j)=\operatorname{SID}(\mathbf{s}_i,\mathbf{s}_j)\cdot \tan\!\big(\operatorname{SCA}(\mathbf{s}_i,\mathbf{s}_j)\big).
\]
These constructions are relevant because they show that “spectral angle” in prompting need not be limited to raw SAM; correlation-derived or divergence-hybrid angular signals can also serve as compatibility functions.

Modern prompting papers often replace explicit angles by cosine-normalized surrogates. "SAMSA 2.0" [2508.00493] computes, for a clicked reference spectrum \(\mathbf{x}_i\) and a pixel spectrum \(\mathbf{x}_{h,w}\),
\[
\theta_{h,w}^{(i)}=\cos^{-1}\left(\frac{\langle \mathbf{x}_{h,w},\mathbf{x}_i\rangle}{\|\mathbf{x}_{h,w}\|_2\cdot \|\mathbf{x}_i\|_2}\right),
\]
then converts it into a similarity map by
\[
\hat{Y}_{\text{SCF}(h,w)}=\max_{i=1,\dots,N}\left(1-\frac{\theta_{h,w}^{(i)}}{\pi}\right).
\]
By contrast, "SSF-Net" [2403.05852] operationalizes spectral angle through cosine similarity on learned hyperspectral feature vectors,
\[
\cos \theta_{(i,j)}=\frac{\langle f(z)_{(i,j,:)},f(x)_{(i,j,:)}\rangle}{\|f(z)_{(i,j,:)}\|\cdot \|f(x)_{(i,j,:)}\|},
\]
and lifts that local notion to a region-level affinity map via embedding and cross-correlation.

A further generalization appears in "KARMA" [2512.12445], where SAM is embedded in the training objective:
\[
\mathcal{L}_{\text{SAM}}=\frac{1}{N}\sum_{i=1}^{N}\arccos\!\left(\frac{\langle \hat{\mathbf{r}}_i,\mathbf{r}_i\rangle}{\|\hat{\mathbf{r}}_i\|_2\,\|\mathbf{r}_i\|_2+\epsilon}\right).
\]
This is paired with Huber reconstruction loss and an LSMM consistency term, so the model is pushed toward reconstructions that are numerically accurate, geometrically aligned, and physically plausible.

In prompt-space learning, the angular object need not be a raw spectrum at all. "UniSpector" [2604.02905] defines cosine similarity between a prompt embedding \(\mathbf{e}_k\) and a class prototype \(\mathbf{p}_c\),
\[
\cos \theta_{c,k}=\frac{\mathbf{p}_c^\top \mathbf{e}_k}{\|\mathbf{p}_c\|_2\|\mathbf{e}_k\|_2},
\]
and regularizes the prompt space with an ArcFace-inspired angular-margin contrastive loss. The paper explicitly states that this is not a classical spectral angle metric between raw spectra, but it is mathematically close in the sense that it uses L2-normalized angular comparisons.

## 3. Dense spectral prompt maps in interactive segmentation

The clearest operational instantiation of spectral angle prompting is the SAMSA 2.0 framework for hyperspectral interactive medical image segmentation [2508.00493]. The input hyperspectral cube is
\[
X\in\mathbb{R}^{H\times W\times C},
\]
with a pseudo-RGB projection
\[
X_{rgb}\in\mathbb{R}^{H\times W\times 3}.
\]
User interaction is given by a click set
\[
\mathcal{I}=\{(i,j)\},
\]
and each click defines a reference spectrum. The model computes a dense spectral-angle similarity map over the entire image, applies histogram equalization to enhance regional separability, resizes the map to the pseudo-RGB resolution, and concatenates it channel-wise with \(X_{rgb}\). The fused SAM2.1-based predictor is written as
\[
\hat{Y}_{\text{SAMSA2.0}}=\text{SAM2.1}(X_{rgb},\hat{Y}_{\text{SCF}}^{\text{eq}},\mathcal{I}).
\]

This architecture is described as early fusion. Unlike the original SAMSA, which incorporates spectral similarity maps only in the later stages, SAMSA 2.0 integrates spectral information directly at the input of the prompt encoder. The paper’s formulation is explicit that the spectral-angle map acts as a soft, spatially aligned prompt rather than a separate segmentation branch. A practical consequence is that SAM’s spatial reasoning can exploit spectral evidence “from the start,” instead of receiving it only as a later correction.

The reported empirical pattern is diagnostically important. Pure spectral-angle baselines contain strong class information but weak spatial calibration: on Hib, the SA baseline yields DICE@0.5 (1 click) of \(0.37423\) but DICE@Max (1 click) of \(0.88924\), indicating threshold sensitivity and limited spatial robustness. When spectral angle prompting is integrated into SAMSA 2.0, performance improves relative both to RGB-only models and to prior spectral fusion. Averaged across datasets, SAMSA2.0-Small reaches DICE@0.5 (1-click) of \(0.8418\), compared with \(0.8112\) for SAMSA and \(0.8036\) for the best RGB-only model; the abstract summarizes the improvement as up to \(+3.8\%\) over RGB-only models and up to \(+3.1\%\) over prior spectral fusion methods [2508.00493].

The interaction model also matters. The initial click is placed at the center of the largest connected component in the target class, and later clicks are generated from the least similar or most incorrect foreground locations. This makes the spectral prompt dynamic: as clicks accumulate, the maximum-over-clicks spectral similarity field changes, so the prompt is refined jointly by user interaction and spectral evidence.

## 4. Template-conditioned angular guidance in hyperspectral tracking

In hyperspectral object tracking, spectral angle prompting appears as template-conditioned regional guidance rather than click-conditioned dense prompting. "SSF-Net" [2403.05852] argues that RGB tracking pipelines and band-regrouping strategies underuse a uniquely hyperspectral cue: spectral correlation or material consistency between template image and search image. The proposed architecture therefore adds a Spectral Angle Awareness Module (SAAM) and a Spectral Angle Awareness Loss (SAAL) on top of a spatial-spectral backbone \(S^2\)FB and a Spectral Attention Fusion Module (SAFM).

The key operational object is a region-level spectral-angular affinity map. Hyperspectral template and search features are embedded and matched through cross-correlation, then projected by a \(1\times1\) convolution to obtain a spectral angular affinity map:
\[
M_{SAA}=CV2D_{1\times1}(Sim(f_z^{embed},f_x^{embed})).
\]
The paper describes this branch as a complement to the classification head. It is not merely a side loss: during inference it enhances the response of regions in the search image that are spectrally similar to the template object, improving localization under visual similarity, background clutter, and related failure modes.

SAAL provides the supervisory counterpart. Positive positions are defined inside an inner ellipse \(E1\), negative positions outside an outer ellipse \(E2\), and the template feature acts as the anchor. The paper states that the loss maximizes \(Sim(a,p)\) and minimizes \(Sim(a,n)\), effectively transferring triplet-style optimization into dense hyperspectral tracking [2403.05852]. This is a prompt-like mechanism because the template’s spectral signature conditions the search-time response map.

The ablation results isolate the contribution of spectral-angle guidance. On HOTC, the baseline \(B\) obtains AUC \(0.661\) and DP\(_{20}\) \(0.924\). Replacing the hyperspectral backbone yields \(0.673/0.932\), adding SAFM gives \(0.675/0.934\), and adding SAAM plus SAAL yields \(0.680/0.939\). The gain of the spectral-angle-related addition over \(S+F\) is therefore \(+0.005\) AUC and \(+0.005\) DP\(_{20}\) [2403.05852]. The qualitative analysis further reports that SAAM retains strongest response on the true target in scenes with visually similar distractors, indicating that spectral-angle awareness provides a materially grounded conditioning signal that standard classification maps may miss.

## 5. Angularly structured prompt spaces and reconstruction-guided variants

A more abstract use of spectral-angle prompting appears in prompt embedding design. "UniSpector" [2604.02905] addresses open-set defect localization with a Spatial-Spectral Prompt Encoder (SSPE), a Contrastive Prompt Encoder (CPE), and Prompt-guided Query Selection (PQS). Its spectral branch computes a 2D DFT of the prompt region, averages Fourier magnitudes over concentric rings, and produces a 1D radial spectrum that is orientation-invariant. This descriptor is fused with a masked-cross-attention spatial prompt code:
\[
\mathbf{e}_k=f_{\text{align}}(z_k^{\text{spatial}})+v_{\text{align}}(z_k^{\text{freq}}).
\]
The angular component then organizes prompt embeddings through cosine similarity, L2-normalized comparisons, and an ArcFace-style additive angular margin. The paper is explicit that this is not a literal spectral-angle mapper between raw spectra; its closest characterization is spectral feature extraction plus cosine/angular prompt-space regularization.

The empirical case for this design is strong. UniSpector introduces Inspect Anything, a benchmark with \(67{,}173\) images, \(83{,}482\) defect instances, and \(360\) defect categories. Overall performance reaches \(\mathrm{AP}_{50}^{b}=40.9\) and \(\mathrm{AP}_{50}^{m}=35.4\), exceeding baselines by at least \(19.7\%\) and \(15.8\%\), respectively. On the Real-IAD ablation, the baseline obtains \(24.0\) \(AP_{50}^{b}\) and \(20.0\) \(AP_{50}^{m}\); adding SSPE gives \(43.0/34.8\), adding CPE yields \(65.8/53.1\), and adding PQS yields \(69.1/56.7\) [2604.02905]. The paper’s own interpretation is that spectral processing improves the quality of prompt embeddings, while angular regularization improves the geometry of the prompt space.

Self-supervised hyperspectral reconstruction offers another extension. In KARMA, a ViT-MAE is augmented with an LSMM-based decoder branch and a spectral-angle-aware reconstruction objective [2512.12445]. The physical branch predicts abundance vectors through a softmax-constrained MLP,
\[
\hat{\mathbf{x}}=\operatorname{softmax}(f_\theta(\mathbf{z})),
\]
and reconstructs spectra by
\[
\hat{\mathbf{r}}_{\text{phys}}=\mathbf{A}\hat{\mathbf{x}},
\]
with \(\mathbf{A}\in\mathbb{R}^{218\times M}\) learned end-to-end. The total loss is
\[
\mathcal{L}=\lambda_1\mathcal{L}_{\text{Huber}}+\lambda_2\mathcal{L}_{\text{SAM}}+\lambda_3\mathcal{L}_{\text{phys}}.
\]
The paper does not call this prompting, but it explicitly frames SAM as a geometry-aware guidance signal during reconstruction. A plausible implication is that spectral angle prompting can be realized not only through input prompts or affinity maps, but also through loss surfaces that bias latent representations toward directional spectral consistency.

The reported results support that interpretation. On EnMAP hyperspectral imagery, baseline ViTMAE reaches average PSNR \(24.61\) and SSIM \(0.55\), whereas KARMA reaches \(27.38\) and \(0.68\), corresponding to \(+11.26\%\) PSNR and \(+23.64\%\) SSIM. The training-time overhead per sample is \(7.19\) ms for baseline ViTMAE, \(9.06\) ms for ViTMAE+SAM, and \(9.47\) ms for full KARMA [2512.12445]. The method therefore demonstrates that angular spectral supervision can improve both reconstruction and downstream transfer, albeit with measurable computational cost.

## 6. Limitations, misconceptions, and adjacent meanings

A central limitation is terminological. Spectral Angle Prompting is not yet a universally standardized term. In one strand, it refers narrowly to click-conditioned spectral-angle maps for SAM-based segmentation [2508.00493]. In another, it denotes any prompting or guidance strategy that uses spectral features plus angular geometry, even when no classical spectral-angle metric is computed between raw spectra [2604.02905]. This creates a persistent ambiguity between strict SAM-based prompting and broader angular-contrastive prompt design.

Another limitation is that spectral angle by itself rarely suffices. The SAMSA 2.0 results show that spectral-only maps can exhibit high DICE@Max but poor fixed-threshold performance, which indicates strong discriminative content but weak spatial calibration [2508.00493]. SSF-Net likewise treats spectral-angle awareness as a complement to classification and localization heads rather than a full replacement [2403.05852]. The broad pattern is that spectral angle is most effective when coupled with a spatial prior, structured decoder, or prompt-conditioned attention mechanism.

Several papers also note unresolved implementation issues. UniSpector states that its angular manifold is conceptual rather than formally differential-geometric, that the exact masked cross-attention prompt extraction and exact formula for token relevance scores are only described conceptually, and that the Fourier-radial branch may suppress useful directional information for some defect types [2604.02905]. KARMA does not fully isolate the marginal benefit of SAM from LSMM, does not explicitly disambiguate whether SAM is computed per pixel or per patch-level spectral unit, and uses an endmember matrix \(\mathbf{A}\) that is learned rather than fixed from a physical library [2512.12445]. SSF-Net leaves unspecified the exact ellipse sizes for positive and negative regions, the embedding dimensionality of \(E_z\) and \(E_x\), and the exact margin used in SAAL [2403.05852].

The phrase should also not be conflated with unrelated “spectral” and “angle” problems. In angle-robust on-chip spectral imaging, for example, the relevant quantity is incidence angle, and the objective is to engineer metasurface transmission spectra so that \(\mathbf{T}(\theta)\approx \mathbf{T}(0)\) over a \(30^\circ\) field of view [2212.07813]. That line of work concerns angular invariance of spectral devices rather than prompting by angular spectral similarity.

Taken together, the literature indicates that spectral angle prompting is best understood as a directional-conditioning paradigm. Its strict form uses spectral-angle similarity maps as explicit prompts; its broader form uses cosine- or angle-structured spectral signals to organize prompt spaces, affinity maps, or reconstruction objectives. The unifying principle is consistent across these variants: when spectral shape carries material or semantic identity, angular similarity provides a scale-robust conditioning signal that can guide segmentation, tracking, recognition, and representation learning more effectively than spatial cues alone.

Source: https://www.emergentmind.com/topics/spectral-angle-prompting