In hyperspectral images, where every pixel records a full reflectance spectrum of about a hundred wavelengths, segmentation networks still struggle where it matters most clinically: the blurred margin where one tissue fades into another. Current models settle these pixels mostly by looking at the surrounding anatomy. That habit breaks when organs are resected, occluded, or covered, and it is tied to one camera's band layout. We propose instead to decide each ambiguous boundary pixel by asking how well its spectrum is explained as a blend of the two tissues on either side, as measured from confident interior pixels of the same image. The answer is a mixing fraction, not a hard label, and it comes from within-image comparison rather than from memorized absolute spectra or memorized anatomy.
The reason this matters is a simple invariance. If a boundary spectrum $s$ is a linear blend of interior spectra $p_A$ and $p_B$, the relation still holds after any linear change of sensor, whether that is per-band gain, illumination color, or resampling 100 bands into 16 or into RGB. A boundary decision stated as within-image unmixing should therefore transfer across cameras by construction, while a classifier on absolute spectra does not. We build a hybrid model around this idea. A convolutional network finds confident interiors. A wavelength-anchored spectral encoder reads each pixel's spectrum as an ordered sequence. An attention step lets each uncertain pixel compare itself to interior prototypes drawn from the whole image. We then test whether the design improves boundary accuracy under geometric and cross-sensor shift on surgical hyperspectral data.
Core Claim
Our claim concerns where errors fall. Low-contrast margin errors under domain shift can be cut by resolving boundary pixels through within-image spectral unmixing against learned interior prototypes, instead of through spatial context. The gain should be largest exactly where existing models fail: out-of-distribution scene geometry and unseen sensors. For a boundary pixel with spectrum $s(\lambda)$ at wavelength $\lambda$ and adjacent-class interior prototypes $p_A(\lambda), p_B(\lambda)$ estimated from the same image, the refinement step fits
$$ \hat\alpha = \arg\min_{\alpha \in [0,1]} \big\| s - \alpha\, p_A - (1-\alpha)\, p_B \big\|^2 , $$
where $\hat\alpha$ is the estimated fraction of tissue $A$. Replacing every spectrum $x$ by $Rx$ for any linear sensor response $R$ leaves the true $\alpha$ a solution. That is why we expect the raw-space term to transfer, and it is also why we keep it separate from learned features, which carry no such guarantee.
Several papers in the file motivate this. Semantic Segmentation of Surgical Hyperspectral Images Under Geometric Domain Shifts shows that image-level models lean on a "context crutch" and lose about 45% DSC on HSI under resection, occlusion, and linens. Robust deep learning-based semantic organ segmentation in hyperspectral images shows the other side: pixel-level models generalize better across surgeries, but full-image models win in-domain (mean DSC 0.90 ± 0.04). Our design keeps spatial context for interiors and removes it as the deciding signal at margins. Towards machine learning-based quantitative hyperspectral image guidance for brain tumor resection classifies infiltrating margins from unmixed fluorophore abundances, reporting 86% margin accuracy. That supports the mixing view of margins, but the paper uses fixed endmembers and no spatial model. We learn the endmembers per image from the interior.
Research Program
The model has three parts. The first is a convolutional encoder-decoder that produces a coarse segmentation and a per-pixel confidence map. We use convolutions here because A Guide to Robust Generalization finds that convolutional and small hybrid models hold up better than pure Vision Transformers under shift and limited data. The second is a spectral encoder in the style of CARL. It treats each pixel's bands as a sequence of tokens tagged with their physical wavelength in nanometers, not their array index, so a 100-band, 16-band, or 3-band input enters the same model. CARL supplies this technique for scene-level transfer. It has no boundary mechanism, and its spectral-to-spatial distillation compresses away exactly the per-pixel mixing structure we want to keep.
The third part is the new component, a boundary refinement stage. Pixels whose confidence falls below a learned threshold form the "uncertain band." We derive this band from the network's own uncertainty, not from fixed erosion and dilation as in Polyper, whose fixed structuring elements cannot adapt to lesion scale. For each class present in the image, prototypes are pooled from high-confidence interior pixels across the whole image. This is the global step, done by attention from uncertain pixels to prototypes. Each uncertain pixel then gets two signals. One is the raw-space unmixing fit above: the fraction, the residual norm, and the identity of the best-fitting class pair. The other is attention similarity in the learned spectral embedding. A small head combines them into a final soft label.
Polyper's interior-to-boundary cross-attention is the closest relative. It attends over spatial RGB features, so on a three-channel image it is still partly a context mechanism. Ours compares spectra and spatial position never enters the score.
Training uses Dice and cross-entropy on the final mask. We add an auxiliary loss on the unmixing fraction from synthetic margins: we composite two annotated tissues from the same image, blend spectra across a soft seam with known fractions, and supervise $\hat\alpha$. The composites borrow the cut-and-paste mechanics of Organ Transplantation, but they target margin mixing rather than context removal. Cross-sensor training samples random linear band resamplings of the 100-band data, including the reconstructed RGB the dataset provides and simulated 16-band multispectral responses.
Baselines
The naive reference is a pixel-wise 1D-CNN on L1-normalized spectra, as in Robust deep learning-based semantic organ segmentation in hyperspectral images. It has no spatial context and so cannot have a context crutch, which makes it the right floor for shifted conditions. We also run it with a dense conditional random field (a post-processing step that smooths labels between neighboring pixels with similar spectra), because that pairing is the obvious cheap form of "compare spectra at the boundary."
The strongest in-domain baseline is the full-image U-Net with an EfficientNet-b5 encoder from the same paper. It reports mean DSC 0.90 (± 0.04) on the porcine organ data, which is roughly the inter-rater level of 0.89. The strongest shifted-geometry baseline is that U-Net trained with Organ Transplantation from Semantic Segmentation of Surgical Hyperspectral Images Under Geometric Domain Shifts, which improved out-of-distribution DSC by up to 90% for HSI and ranked first among seven augmentations. The strongest cross-sensor baseline is CARL with a standard segmentation decoder. CARL reports 50.1 vs 44.6 mIoU against camera-specific models on HSICity, but I found no reported result on Lacuna for CARL on the porcine surgical data at the boundary level. We also include CARL plus a Polyper-style spatial boundary head, which is the "just stack the existing modules" competitor.
All baselines use the same subject-level splits, including Sellner et al.'s geometric out-of-distribution splits, the same input normalization, and the same GPU-hour budget. Each gets an equal number of hyperparameter search trials. Organ Transplantation is offered to every model, including ours, so the comparison isolates architecture rather than augmentation.
Two ablations isolate the key ingredient. In the first, the raw-space unmixing term is removed, leaving only learned-embedding attention. In the second, prototype attention is replaced by spatial cross-attention, Polyper-style, on the same features. The result that counts as beating the baselines is a clear improvement in boundary-band DSC and normalized surface distance over U-Net plus Organ Transplantation on the geometric-shift splits, and over CARL on held-out simulated sensors, with in-domain whole-image DSC no more than one standard deviation below 0.90.
Why not just…?
Why not just use a pixel classifier with CRF smoothing? This is a real threat. A dense CRF already compares neighboring spectra, and pixel models already avoid the context crutch. The differences are threefold. A CRF compares each pixel to its neighbors rather than to whole-image interior prototypes. Its similarity kernel is fixed and depends on the sensor. It returns no mixing fraction. If pixel plus CRF matches our boundary metrics under both geometric and sensor shift, the prototype mechanism is unnecessary, and we will report that.
Why not just train a standard U-Net with Organ Transplantation? This is the best-documented fix for geometric shift, and it may fully close the whole-image DSC gap. It does nothing for an unseen sensor, though, and nothing makes it estimate partial-tissue margins. The decisive tests are its performance on held-out band configurations and on synthetic margins with known fractions. We expect it to be competitive under geometric shift alone. If it also matches us at boundaries there, our contribution narrows to the cross-sensor claim.
Why not just bolt Polyper's boundary module onto a CARL encoder? This tests whether our gain comes from a boundary module of any kind or specifically from spectral, context-free comparison. The spatial-cross-attention ablation answers it directly. Our prediction is that the spatial version helps in-domain and degrades under geometric shift, because it reintroduces context at exactly the pixels where context misleads.
Why not just add iterative refinement like RecycleNet? RecycleNet recycles latent features to sharpen fuzzy boundaries, raising BTCV DSC from 91.47 (nnU-Net) to 93.48 on CT and MRI. It is complementary rather than competing. It does not change what evidence settles a boundary pixel, so it should inherit the context crutch. We include a recycled U-Net as an extra baseline on the geometric splits.
Proposed Experiments
The main data are the porcine open-surgery organ dataset (19 classes, 100 bands, 500–1000 nm) with Sellner et al.'s geometric shift splits, plus HeiPorSPECTRAL (5,758 cubes, 20 organs) for more subjects. Metrics are whole-image DSC and DSC restricted to a band of fixed width around ground-truth contours. Because the dataset's 0.89 inter-rater figure suggests annotation noise concentrates at margins, we also report normalized surface distance with tolerance set to that noise level, and calibration of boundary pixels.
Three checks are decisive. The first is the synthetic-margin test: on held-out composites with known blending fractions, does $\hat\alpha$ track the truth, and does that accuracy survive transfer to resampled sensors? It should if the linear-invariance argument holds, and failure here falsifies the core mechanism. The second is the cross-sensor test: train on 100-band data, then evaluate on reconstructed RGB and on simulated 16-band inputs never seen in training. We report the relative drop in boundary-band DSC for every model, and we expect ours to drop least, with the raw-unmixing ablation showing where the robustness comes from. The third is the context test: on occlusion and resection splits, does the gap between our model and the U-Net widen in the boundary band more than in interiors?
As a stress test of the method's limits, we also run on RGB polyp benchmarks, where Polyper reports 86.51% mDice on ETIS. With three bands the unmixing is weakly constrained, and we predict little or no gain there. That result would confirm the method draws its power from spectral resolution rather than from extra architecture.
References
- Semantic Segmentation of Surgical Hyperspectral Images Under Geometric Domain Shifts
- Robust deep learning-based semantic organ segmentation in hyperspectral images
- Towards machine learning-based quantitative hyperspectral image guidance for brain tumor resection
- A Guide to Robust Generalization: The Impact of Architecture, Pre-training, and Optimization Strategy
- CARL: Camera-Agnostic Representation Learning for Spectral Image Analysis
- Polyper: Boundary Sensitive Polyp Segmentation
- RecycleNet: Latent Feature Recycling Leads to Iterative Decision Refinement
- HeiPorSPECTRAL - the Heidelberg Porcine HyperSPECTRAL Imaging Dataset of 20 Physiological Organs