1. Introduction
Apples are high-value horticultural products, yet their quality is frequently compromised by mechanical impacts during postharvest handling. Unlike visible decay, early bruises are often subsurface, involving cell wall rupture, intracellular fluid leakage, and enzymatic browning driven by polyphenol oxidase. These subtle physiological changes are initially masked by the epidermis, making them difficult to detect using conventional RGB imaging or manual inspection [
1]. As early bruises may progressively expand and lead to secondary deterioration, rapid and non-destructive detection of these weak internal changes is essential for reliable fruit quality evaluation and automated grading [
2,
3].
Hyperspectral imaging (HSI) has emerged as an effective tool for fruit quality assessment by integrating spatial and spectral information. By capturing absorption features associated with water (O-H) and organic compounds such as sugars and phenolics, HSI enables early detection of tissue changes before visible symptoms appear [
4]. However, conventional HSI systems rely on full-spectrum acquisition with hundreds of contiguous bands, resulting in substantial data redundancy and increased computational complexity. High spectral dimensionality may introduce additional noise and affect model optimization stability under complex experimental conditions [
5]. Therefore, reducing spectral dimensionality while preserving discriminative information remains a key challenge for practical HSI applications in food quality assessment [
6].
To reduce hyperspectral dimensionality in apple bruise detection, various feature selection and projection methods have been reported [
7]. Principal Component Analysis (PCA) reduces dimensionality through linear transformation but often loses non-linear discriminative features and physical interpretability [
8]. Competitive Adaptive Reweighted Sampling (CARS) selects variables based on regression coefficients but may suffer from instability under sample noise [
9]. The Successive Projections Algorithm (SPA) alleviates multicollinearity; however, its search strategy is prone to local optima [
10]. Attention-based visualization methods such as Grad-CAM [
11] have also been introduced to interpret spectral importance, yet their selected regions may exhibit aggregation or redundancy. Although these approaches reduce dimensionality to some extent, simultaneously achieving global optimization capability, selection stability, and physical interpretability remains challenging [
12]. Particularly in early invisible apple bruise detection, the combination of weak discriminative signals, blurred class boundaries, and high spectral dimensionality increases the risk of premature convergence and unstable band subsets [
12]. Consequently, there is a need for a refined optimization strategy that ensures both selection stability and physical interpretability [
13].
In parallel with band optimization research, various modeling strategies have been applied to hyperspectral fruit damage detection [
14], including Partial Least Squares Discriminant Analysis (PLS-DA) [
15], Support Vector Machines (SVM) [
16], one-dimensional Convolutional Neural Networks (1D-CNN) [
17], and recurrent neural networks. These methods have shown progressively improved capability in capturing complex spectral characteristics associated with bruising. More recently, studies have further explored spectral–spatial feature enhancement using 3D convolutional neural networks [
18], NIR characteristic wavelength imaging combined with image segmentation [
19], and ANN-based regression for bruise area prediction [
20]. From a methodological perspective, existing hyperspectral bruise-detection studies generally follow two main technical paradigms. The first directly applies deep learning models to full-spectrum hyperspectral data, which often provides strong representation capability but suffers from substantial spectral redundancy, increased computational burden [
21], and limited deployment efficiency. The second combines waveband-selection strategies with traditional machine learning classifiers to improve efficiency; however, such approaches may exhibit limited capability for modeling nonlinear interactions and global dependencies [
22] among sparse discrete spectral features. In addition, most existing methods either treat the detection process as a black box without interpretability or rely on conventional pipelines that do not explicitly reveal which spectral bands contribute most strongly to the final decision. More importantly, practical waveband optimization often produces sparse and non-contiguous spectral subsets rather than continuous spectral sequences. Under such conditions, conventional convolutional or recurrent architectures that implicitly assume local spectral continuity may become structurally mismatched to the actual input characteristics, potentially weakening discriminative feature representation. Furthermore, early bruise samples usually exhibit extremely subtle spectral perturbations, resulting in many hard-to-classify instances. Traditional loss functions are often dominated by easy healthy samples, suppressing the learning of weak bruise-related signals and reducing recall performance [
23,
24]. Therefore, under the discrete-input framework, developing a classification model that balances global collaborative modeling with enhanced learning for hard-to-classify samples has become a critical issue.
Overall, transitioning from continuous spectra to discrete key bands is essential. However, this may introduce challenges for traditional deep learning models: 1D-CNNs and RNNs rely, to a certain extent, on local spectral continuity—an assumption that may not hold when inputs are non-contiguous [
25,
26]. Furthermore, the inherent “hard-to-classify” nature of weak browning signals and the challenge of capturing subtle spectral features often lead to low recall in standard models. There is a need for a framework that can both interpret discrete spectral interactions and enhance weak signal detection [
27]. To address these issues, this study proposes an integrated hyperspectral measurement and modeling framework for early apple bruise detection [
28,
29]. The framework aims to simplify hyperspectral acquisition, reduce system burden, and improve optimization stability under discrete key band conditions. The main contributions are summarized as follows:
(1) Unlike conventional full-spectrum hyperspectral learning frameworks, a sparse waveband optimization strategy integrating SR-IGWO and SHAP analysis was introduced to reduce spectral redundancy while preserving representative bruise-sensitive spectral information and improving feature interpretability.
(2) Different from traditional classifiers operating on selected wavebands, a structurally matched CNN–Transformer framework was designed for sparse and non-contiguous spectral by combining pointwise spectral embedding with global dependency modeling, thereby improving weak bruise detection under reduced spectral dimensionality.
(3) A visualization-based detection strategy was established to enable spatial localization of bruise regions, supporting intuitive interpretation of early damage distribution.
4. Discussion
In this study, the SR-IGWO algorithm identified an 18-waveband subset from continuous hyperspectral data to detect early apple bruising. Previous hyperspectral bruise-detection studies have primarily focused either on full-spectrum deep learning frameworks or on conventional waveband-selection methods combined with shallow classifiers [
14,
36], while relatively limited attention has been paid to the interpretability of sparse discrete spectral modeling. In this work, SHAP-based analysis was incorporated to provide additional insight into the spectral-band-level contributions associated with the detection process. Based on SHAP analysis, highly weighted wavebands such as 1839.6 nm and 1402.7 nm correspond to known absorption regions associated with water (O–H) and structural carbohydrates (C–H/C–O). This observation suggests that early bruising may involve sub-epidermal moisture redistribution and localized cell wall degradation. However, these interpretations should be considered with caution. The SHAP analysis only explains feature importance within the Random Forest model used during the band-selection stage, rather than the DSFormer classifier itself [
75]. This methodological distinction means the inferred biochemical associations, while consistent with existing literature, remain strictly correlative rather than causative, and require further validation through direct biochemical assays to establish a definitive link [
76,
77].
At the modeling level, conventional sequence-based approaches rely on local spectral continuity, which may be suboptimal when inputs consist of sparsely distributed discrete wavebands [
68]. Therefore, the present work does not aim to replace existing full-spectrum hyperspectral learning paradigms but rather to explore whether structurally matched modeling strategies can improve representation efficiency under heavily compressed discrete spectral conditions. The DSFormer architecture attempts to address this issue by embedding discrete wavebands and modeling their global relationships using a self-attention mechanism. Beyond architectural considerations, we also incorporated repeated-run statistical analyses to assess performance reproducibility and uncertainty. Specifically, all models were independently evaluated over ten runs using different random seeds, and the resulting metrics were further analyzed using confidence intervals and non-parametric statistical comparisons [
78]. Although these analyses improve the reliability of the reported performance trends under the current experimental setting, statistical reproducibility observed on a controlled dataset does not inherently guarantee equivalent robustness under unseen cultivars, acquisition systems, or industrial processing environments. Nevertheless, the relatively low variance observed across repeated runs suggests that the proposed framework maintains stable optimization behavior under sparse spectral inputs. This design helps the network concentrate on subtle spectral variations associated with early bruising while reducing the risk of missed detections [
79].
A key methodological concern in pixel-level hyperspectral analysis is the potential dependence among samples, particularly due to spatial correlation and ROI overlap within the same fruit. To mitigate this issue, the dataset was constructed from 100 independent apples, yielding over 11,000 spectral samples (approximately 5700 bruised and 6000 healthy regions). A strict fruit-wise partitioning strategy was adopted to ensure that all samples from the same apple were assigned exclusively to a single subset, thereby substantially helping reduce the risk of direct data leakage between training and testing phases. Nevertheless, because multiple pixel-level ROIs extracted from the same fruit inherently share similar physiological and structural characteristics, residual intra-fruit correlations may still persist. Consequently, the reported performance should be interpreted as reflecting reproducible discrimination capability under the current controlled experimental setting, rather than fully independent population-level generalization.
Despite the promising results obtained in this study, several methodological limitations should be explicitly acknowledged when considering the broader applicability of the proposed framework [
70]. The current experiments were conducted using a single apple cultivar under controlled impact conditions and within a relatively narrow post-impact time window (1–4 h). Consequently, the spectral distributions represented in this study may not fully capture the variability encountered in practical postharvest environments, where cultivar-dependent optical properties, illumination conditions, surface characteristics, storage states, and handling procedures may differ substantially [
15,
63]. Although a preliminary cross-cultivar external validation was incorporated in the study, the additional evaluation was still conducted under controlled laboratory conditions using only one supplementary cultivar. Therefore, the current validation should not yet be regarded as comprehensive external validation across diverse industrial scenarios or large-scale postharvest processing environments. Furthermore, although repeated-run statistical analyses improved the reliability assessment of the reported performance, the overall experimental diversity remains relatively limited. Under practical distribution shifts, performance consistency across broader application scenarios remains to be further verified. Accordingly, the proposed framework should presently be regarded as a preliminary but encouraging step toward efficient low-dimensional hyperspectral bruise detection, while further large-scale multi-cultivar, multi-device, and multi-environment validation remains necessary before practical deployment.
5. Conclusions
This study developed a hyperspectral framework integrating waveband optimization and discrete spectral modeling for early apple bruise detection. Using the SR-IGWO algorithm, 18 representative wavebands were selected from 273 original spectral channels, achieving a 93.4% reduction in spectral dimensionality. Stability analysis across 20 repeated optimization runs indicated that the selected bands consistently concentrated on spectrally meaningful regions under the current experimental setting.
The proposed DSFormer model, specifically designed for discrete waveband inputs, achieved a classification accuracy of 99.11% ± 0.08%, a recall of 96.04% ± 1.08%, and an F1-score of 95.95% ± 0.39% on the independent test set. Repeated-run statistical analyses further suggested that the observed performance improvements remained relatively stable under different random initializations within the current dataset. Compared with conventional methods (e.g., SVM, PLS-DA, and 1D-CNN), DSFormer achieved improved recall and F1-score under substantially reduced spectral dimensionality. Ablation experiments further suggested that pointwise embedding, Transformer-based global dependency modeling, and Focal Loss collectively contributed to improved bruise detection performance under sparse spectral input conditions. Visualization results additionally demonstrated spatially coherent bruise localization with relatively limited background interference under controlled imaging conditions.
Nevertheless, several important limitations should be acknowledged when interpreting these findings. The current study was conducted using a single apple cultivar under controlled laboratory conditions and within a limited post-impact time window. Although fruit-wise partitioning, repeated-run statistical analyses, and preliminary cross-cultivar evaluation were incorporated to improve evaluation reliability, the framework has not yet undergone extensive large-scale external validation across diverse cultivars, acquisition batches, imaging systems, or practical industrial processing environments. Consequently, the reported robustness and generalization capability should presently be interpreted within the scope of the current experimental setting rather than as evidence of fully established real-world applicability.
Overall, the present study provides a preliminary but encouraging exploration of combining targeted waveband selection with structurally matched discrete spectral modeling for efficient early bruise detection. Further multi-domain validation and real-world evaluation remain necessary before broader practical deployment can be considered.