arXiv:2610.08770cs.CVOct 2026

Manuscript Offprint

arXiv:2610.08770

Data Leakage in Patch-Based Hyperspectral Image Classification: Quantifying the Impact of Spatial Overlap

Mohammed Q. Alkhatib

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Patch-based learning improves hyperspectral image (HSI) classification by exploiting local spectral-spatial information, but random train-test sampling from the same image can cause spatial patch overlap, leading to data leakage and optimistic performance estimates. This paper investigates same-class train-test spatial overlap in patch-based HSI classification using two measures: overlap percentage (OP), which quantifies the global amount of overlapped testing patch pixels, and average overlap ratio (AOR), which measures the local severity among affected testing patches. Experiments on the Pavia University dataset compare random and non-random spatial sampling using SVM, MLP, 2D-CNN, 3D-CNN, ViT, and MorpMamba. The results show that deep patch-based models achieve high accuracy under random sampling, with 3D-CNN reaching 96.17% Overall Accuracy (OA), but drop substantially under non-random spatial sampling, where 3D-CNN decreases to 55.20% and ViT and 2D-CNN drop by 40.71 and 38.81 percentage points (PP), respectively. Patch-size analysis further shows that increasing the patch size from 5×55 \times 5 to 19×1919 \times 19 raises the random-sampling overlap percentage from 23.28% to 77.02%. These findings demonstrate that random patch-based evaluation can substantially inflate classification performance, especially for models that strongly exploit spatial context. The code associated with this paper is available at: https://github.com/mqalkhatib/Data_Leakage_in_HSI_Classification.

Index Terms— HSI classification, Data Leakage, Spatial Overlap, Deep Learning, Patch-Based Learning

1. INTRODUCTION

Hyperspectral image (HSI) classification assigns semantic labels to pixels using their spectral responses across many contiguous bands. Compared with Optical imagery, HSI captures richer material-specific information, which improves the discrimination of visually similar land-cover classes. This makes HSI classification important for fine-grained scene understanding, particularly when different materials exhibit similar spatial appearance but distinct spectral signatures. However, the task remains challenging due to high dimensionality, spectral redundancy, spatial variability within the same class, and the limited availability of labeled samples.

Traditional methods, such as Support Vector Machines (SVMs) [1] and Multilayer Perceptrons (MLPs) [2], have been widely used for HSI classification, but they often depend mainly on spectral features and have limited ability to exploit spatial context. Deep learning methods address this limitation by learning spectral-spatial representations directly from HSI data [3]. Convolutional neural network (CNN)-based models have progressed from spectral 1D-CNNs [4] to spatial 2D-CNNs [5], joint spectral-spatial 3D-CNNs [6], and hybrid 2D-3D CNNs [7]. More recently, transformer- and Mamba-based models have been introduced to capture long-range dependencies and improve spectral-spatial modeling [8, 9].

Despite these advances, many HSI classifiers still rely on patch-based learning, where a spatial neighborhood around each labeled pixel is used as input. Although this improves spectral-spatial representation, it can introduce data leakage when training and testing samples are randomly selected from the same image. In such cases, their patches may spatially overlap, causing shared pixels to appear in both sets, weakening train-test independence and producing overly optimistic performance estimates [10, 11]. This leakage becomes more severe with larger patch sizes and higher training ratios, and is further amplified by spatial autocorrelation, where neighboring pixels often have similar spectra [11]. Although spatially disjoint sampling can reduce this issue [12], it may further reduce the already limited number of labeled training samples.

To better understand and quantify data leakage, this paper investigates the relationship between same-class train-test spatial overlap and classification performance across six classifiers and two sampling protocols. Unlike prior studies that mainly identify or mitigate leakage, this study jointly quantifies its global extent and local severity using overlap percentage and average overlap ratio. SVM, MLP, 2D-CNN, 3D-CNN, Vision Transformer (ViT), and MorpMamba are evaluated under random and non-random spatial sampling to assess model sensitivity and quantify the resulting accuracy inflation.