# Spectral Information Divergence-Driven Diffusion Networks for Hyperspectral Target Detection
## 3 Proposed Method
### Target Detection  
The target detection process corresponds to the reverse denoising process in DDPM. Starting from a predefined pseudo-background noise, the trained denoising network iteratively restores all spectral samples in reverse order, from step \(t=T\) to \(t=0\).The final output spectral samples closely approximate the true data distribution, denoted as \(\hat{\mathcal{H}}\).  
Effective target detection is achieved by analyzing the differences in reconstructed spectra between \(\hat{\mathcal{H}}\) and \(\mathcal{H}\). In this study, the spectral angle mapper (SAM) function is utilized, as proposed by previous scholars, to evaluate the degree of change in samples before and after reconstruction. For each \(\mathbf{h}_{(i,j)}\) and \(\mathbf{\hat{h}}_{(i,j)}\), the SAD is calculated using the Equation (22):  
\[\begin{split}\mathbf{d}_{M}^{i,j}&=\cos^{-1}\left( \frac{\left(\mathbf{h}_{(i,j)}\right)^{T}\mathbf{\hat{h}}_{(i,j)}}{\left( \left\|\mathbf{h}_{(i,j)}\right\|\right)\left(\left\|\mathbf{\hat{h}}_{(i,j)} \right\|\right)}\right)\\ &=\cos^{-1}\left(\frac{\mathbf{h}_{(i,j)}\mathbf{\hat{h}}_{(i,j)} }{\sqrt{\left(\mathbf{\hat{h}}_{(i,j)}\right)^{T}\mathbf{\hat{h}}_{(i,j)}} \sqrt{\left(\mathbf{h}_{(i,j)}\right)^{T}\mathbf{h}_{(i,j)}}}\right)\end{split} \tag{22}\]  
where \(\mathbf{h}_{(i,j)}\) and \(\mathbf{\hat{h}}_{(i,j)}\) represent the spectral profiles of the original and reconstructed spectra at various \((i,j)\), respectively, and \(\mathbf{d}_{M}^{i,j}\) represents the distance difference map at different \((i,j)\). To obtain detection targets, \(\mathbf{d}_{M}^{i,j}\) at each position is multiplied by the detection map \(\mathbf{\hat{D}}\), which is weighted by the two coarse detections. However, hyperspectral data often exhibit special cases like spectral variability, where poor reconstruction accuracy can cause localized degradation in background suppression. To address this issue, a non-linearfunction is introduced to suppress pixels with smaller response values while preserving those with higher response values. The nonlinear function \(f(x)\) is defined as:  
\[f(x)=\begin{cases}1-e^{-\beta x},&x\geq 0\\ 0,&x<0\end{cases} \tag{23}\]  
where \(\beta\) is a parameter that determines the background suppression capability. Each detected pixel \(\mathbf{d}_{M}^{i,j}\) is multiplied pixel-wise with the weighted detection map \(\hat{D}\) after being processed through the non-linear variation, as defined by the following Equation (24):  
\[\hat{\mathbf{d}}_{M}^{i,j}=\mathbf{d}_{M}^{i,j}\odot f\left(\hat{\mathbf{D}}_ {(i,j)}\right) \tag{24}\]  
By this method, the final result is the detection map \(\mathbf{R}\in\mathbb{R}^{h\times w}\). The overall performance of the HSI is significantly improved, demonstrating substantial enhancement across different datasets. Algorithm 1 summarizes the pseudocode flow of the SID-DN model that we proposed.  
```
0: HSI tensor \(\mathcal{X}\), prior target spectrum \(\mathbf{d}\)
1: Compute a coarse detection result \(\hat{\mathbf{D}}\) from input \(\mathcal{B}\) by (5)
2: Construct the background training set \(X_{B}\) from binarized map \(\mathbf{D}\) and input \(\mathcal{X}\) by (6)
3:for each epoch do
4: Minimize the loss function \(\mathcal{L}_{total}\) in (21)
5:endfor
6: Reconstruct \(\hat{\mathcal{H}}\) with the trained model.
7: Compute the spectral distance map \(\mathbf{d}_{M}\) by (22)
8: Compute \(\mathbf{R}\) from \(\hat{\mathbf{D}}\) and \(\mathbf{d}_{M}\) by (23) and (24)
8:Ensure: Target map \(\mathbf{R}\)
```  
**Algorithm 1** SID-DN for HSI Target Detection