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

ML NNGTB Other ML CV SST PDL
2026年10月06日
基于图像块的学习方法通过挖掘局部的光谱-空间信息,提升了高光谱图像(HSI)分类性能;但若在同一幅图像内对训练集和测试集进行随机采样,则可能导致空间上图像块重叠,从而引发数据泄露,并造成对模型性能的过度乐观估计。本文针对基于图像块的HSI分类任务,系统考察了同类样本在训练集与测试集之间存在的空间重叠问题,并提出两种量化指标:重叠像素占比(Overlap Percentage, OP),用于衡量所有测试图像块中发生重叠的像素在整个测试集中的全局占比;平均重叠率(Average Overlap Ratio, AOR),用于刻画受重叠影响的各测试图像块内部重叠程度的局部严重性。我们在“帕维亚大学”(Pavia University)数据集上开展了实验,对比分析了随机空间采样与非随机空间采样两种策略下,支持向量机(SVM)、多层感知机(MLP)、二维卷积神经网络(2D-CNN)、三维卷积神经网络(3D-CNN)、视觉Transformer(ViT)以及MorpMamba等模型的分类性能。结果表明:在随机采样设置下,各类深度图像块模型均取得了较高的分类精度,其中3D-CNN的整体分类精度(Overall Accuracy, OA)达96.17%;但在非随机空间采样设置下,其性能出现显著下降——3D-CNN的OA降至55.20%,ViT与2D-CNN的OA则分别下降了40.71和38.81个百分点(percentage points, PP)。进一步开展图像块尺寸分析发现:当图像块尺寸从5×5增大至19×19时,随机采样下的重叠像素占比(OP)从23.28%大幅上升至77.02%。上述结果充分说明,采用随机图像块采样方式进行评估,会严重高估分类性能,尤其对于高度依赖空间上下文信息的模型而言,该问题更为突出。本文所用全部代码已开源,地址为:https://github.com/mqalkhatib/Data_Leakage_in_HSI_Classification。
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 5x5 to 19x19 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.
许愿