JEOS RP ISSN02 | Page 131

126
J. Eur. Opt. Society-Rapid Publ. 21, 43( 2025)
Fig. 3. Framework of the proposed method.
4. Constraints generation module( CGM): Integrate intrinsic constraints and external constraints into self-attention constraints, and input into CSATM.
3.1 Image pyramid
Input the hyperspectral image Y ð0Þ 2 R HWB and perform progressive spatial downsampling at a ratio of 1 / 2 to obtain
Y( 0), Y( 2), andY( 3). Y( 3) will enter the subsequent modules as the input for the first layer, and after the intrinsic constraints and external constraints of the first layer are fed back to CSATM, Y( 2) will be inputted. The same operation is used for Y( 1) and Y( 0).
3.2 Dual-window preprocessing
Take the input Y( 0) of the fourth layer as an example. Y( 0) performs boundary padding to ensure normal processing of boundaries by the dual-window and is then extracted as a set of“ center pixels – dual-window inner pixels” by the dual-window with outer window size win out and inner window size win in. The set is represented as:
i ¼ 1; 2;...; N
X ¼ P j; Pi j ð5Þ i ¼ 1; 2;...; M where N ¼ win 2 out � win2 in, M = H W.
The purpose of the overall framework is to learn the level of difference between the central pixel and the surrounding background, and the required residuals are obtained as follows: e i j ¼ P j
� P i j: ð6Þ
In this section, the hyperspectral image Y( 0) 2 R H W B is converted into e 2 R M N B, which can be processed by CSATM.
3.2 CSATM
The differential data e 2 R M N B is encoded as deep features in this module, and the anomaly score is finally obtained. The fully connected layer in the Embedded module performs a linear transformation on e and adds positional information. The encoded vector is passed through a constrained transformer encoder and finally processed by Mean and MLP to obtain the anomaly score S. The forward process is as follows:
z 0 ¼ eE þ E pos;
E 2 R BD; E pos 2 R MND
Z 0 t ¼ CMSA ð LN ð Z t�1ÞÞþ
Z t�1;
�
�
Z t ¼ MLP LN Z 0 0 t þ Z t;
t ¼ 1; 2;...; L
S ¼ MLPðMeanðLNðZ t
ÞÞÞþZ t
S 2 R M:
ð7Þ
Where CMSA( x) = concat( CSA 1, CSA 2,..., CSA h). The new weights obtained by adding constraints to self-attention weights are as follows:
� CSA ¼ Softmax QK T Norm cc T V; ð8Þ v I ¼ c ¼ Flatteningðv I þ v E Þ; ð9Þ
x i I jxi I ¼ x I � xi I; vA ¼ x i E jxi E ¼ x E � xi E: ð10Þ where x I is the value corresponding to the central pixel in the intrinsic constraints; x i Iði ¼ 1; 2;...; NÞ is the value corresponding to pixels within the dual-window in the intrinsic constraints; x E is the value corresponding to the central pixel in the external constraints; x i Eði ¼ 1; 2;...; NÞ is the value corresponding to the pixels within the double window in the external constraints. Figure 4 shows the positions of x I and x i I, with the same distribution of external constraints. x i I is the central pixel to be tested, and x I is the surrounding background pixel.