---
title: Illumination-Guided MSA in Low-Light Image Enhancement
url: https://www.emergentmind.com/topics/illumination-guided-multi-head-self-attention-ig-msa
type: topic
---

# Illumination-Guided MSA in Low-Light Image Enhancement

Illumination-Guided Multi-head Self-Attention (IG-MSA) is the illumination-conditioned attention mechanism introduced in the SAIGFormer framework for low-light image enhancement, specifically to address non-uniform lighting scenarios such as backlit and shadow, which can otherwise appear as over-exposure or inadequate brightness restoration. Within SAIGFormer, IG-MSA leverages a spatially varying illumination map to calibrate lightness-relevant features, and it is formulated as the first sub-layer in each Spatially-Adaptive Illumination-Guided Transformer (SAIGT) block [2507.15520].

## 1. Position within the SAIGT block

Within each SAIGT block, IG-MSA is applied before the dual-gated feed-forward network (DG-FFN). Denoting the input feature map at stage \(i\) by \(F_i\in\mathbb{R}^{H\times W\times C}\) and the corresponding illumination map by \(I_{L_i}\in\mathbb{R}^{H_i\times W_i\times3}\), the block is defined as
\[
F_i' \;=\; F_i \;+\;\mathrm{IG\text{-}MSA}\bigl(\mathrm{LN}(F_i),\,I_{L_i}\bigr),
\]
\[
F_{i+1}\;=\;F_i' \;+\;\mathrm{DG\text{-}FFN}\bigl(\mathrm{LN}(F_i')\bigr).
\]

This places IG-MSA in the residual attention pathway, where it receives the LayerNorm-normalized feature tensor together with the stage-aligned illumination map. In functional terms, the module is not an auxiliary branch detached from the main representation stream; it directly participates in the feature update that precedes the feed-forward transformation. A plausible implication is that illumination guidance is injected at the point where contextual interactions are formed, rather than only at reconstruction time.

## 2. Feature projections and illumination embedding

Let \(\hat F=\mathrm{LN}(F)\in\mathbb{R}^{H\times W\times C}\). IG-MSA first extracts query, key, and value embeddings by applying a pointwise convolution followed by a depthwise-separable convolution:
\[
T \;=\; W_d\bigl(W_p\,\hat F\bigr)\;\in\;\mathbb{R}^{H\times W\times(3C)},
\quad
[\,Q,K,V\,]\;=\;\mathrm{split}_\mathrm{chan}(T).
\]

Here, \(W_p\) is a \(1\times1\) convolution mapping \(\mathbb{R}^{H\times W\times C}\) to \(\mathbb{R}^{H\times W\times3C}\), \(W_d\) is a \(3\times3\) depthwise-separable convolution, and \(\mathrm{split}_\mathrm{chan}\) partitions the \(3C\) channels into three tensors \(Q,K,V\in\mathbb{R}^{H\times W\times C}\).

The illumination signal is processed separately. The illumination map is first brought to the same spatial resolution as the feature representation and then channel-aligned:
\[
\widetilde I
\;=\;
\mathrm{Conv}^{4\times4}_\mathrm{DS}(I_{L_i})
\;\in\;\mathbb{R}^{H\times W\times3},
\quad
I_{\rm emb}
\;=\;
W_p^\mathrm{ill}\bigl(\widetilde I\bigr)
\;\in\;\mathbb{R}^{H\times W\times3}.
\]

The resulting illumination embedding is concatenated to the query:
\[
Q_{\rm lg}
\;=\;
\mathrm{Concat}_{\rm chan}\bigl(Q,\;I_{\rm emb}\bigr)
\;\in\;\mathbb{R}^{H\times W\times (C+3)}.
\]

The defining structural feature of IG-MSA is therefore not merely the presence of an illumination prior, but its explicit insertion into the query tensor. This means that illumination information modulates affinity formation rather than being fused only after attention has been computed.

## 3. Channel-wise self-attention formulation

To perform channel-wise self-attention, IG-MSA flattens the spatial dimensions so that \(N=H\cdot W\):
\[
Q_{\rm lg}\;\mapsto\;\mathbf Q\in\mathbb{R}^{N\times (C+3)},\quad
\mathbf K,\mathbf V\;\in\mathbb{R}^{N\times C}.
\]

The attention scores are then formed with a learnable scalar \(\alpha\):
\[
S \;=\;\alpha\;\mathbf K^{T}\,\mathbf Q
\quad\in\quad\mathbb{R}^{C\times (C+3)},
\]
\[
A \;=\;\mathrm{softmax}\,(S)
\quad\text{(softmax along each row of \(S\))},
\]
\[
\mathbf O
\;=\;
\mathbf V\;A
\quad\in\quad\mathbb{R}^{N\times (C+3)}.
\]

Finally, the attended representation is projected back to \(C\) channels and reshaped to the spatial layout:
\[
\mathbf O'\;=\;W_p^\mathrm{out}\,\mathbf O
\;\in\;\mathbb{R}^{N\times C},
\quad
F' \;=\;\mathrm{reshape}\bigl(\mathbf O',\,H,W,C\bigr).
\]

Several aspects of this formulation are technically distinctive. First, the attention is channel-wise rather than spatial-token-wise: the interaction tensor has shape \(C\times(C+3)\), not \(N\times N\). Second, the extra \(3\) dimensions introduced by illumination guidance persist through the score formation and output aggregation steps before the final projection restores the original channel dimension. Third, the learnable scalar \(\alpha\) explicitly calibrates the magnitude of the attention scores. In the paper’s summary, this is presented as a mechanism for fine-tuning the impact of illumination guidance on the attention scores [2507.15520].

## 4. Forward-pass realization

The forward pass is specified procedurally as follows:

```text
function IG_MSA(F, I_L):
  # 1) LayerNorm and shallow convs → Q,K,V
  X   = LayerNorm(F)                     # (H,W,C)
  T   = Conv1x1_expand(X)                # (H,W,3C)
  T   = DepthwiseSepConv3x3(T)           # (H,W,3C)
  Q,K,V = split_along_channels(T, C)     # each (H,W,C)

  # 2) Downsample & align illumination
  I_ds  = DepthwiseSepConv4x4(I_L)       # (H,W,3)
  I_emb = Conv1x1_ill(I_ds)              # (H,W,3)

  # 3) Concatenate illumination to query
  Q_lg = concat_channels(Q, I_emb)       # (H,W,C+3)

  # 4) Flatten spatial dims → (N x D)
  Qb = flatten_spatial(Q_lg)             # (N, C+3)
  Kb = flatten_spatial(K)                # (N, C)
  Vb = flatten_spatial(V)                # (N, C)

  # 5) Compute channel-wise attention
  S    = alpha * (Kb^T @ Qb)             # (C x (C+3))
  A    = softmax(S, dim=1)               # row-wise
  Ob   = Vb @ A                          # (N, C+3)

  # 6) Project & reshape
  Ob'  = Conv1x1_out(Ob)                 # (N, C)
  F'   = reshape_to_HW(Ob', H, W, C)     # (H,W,C)
  return F'
end function
```

This implementation-level view makes explicit that the illumination pathway is shallow but not trivial: it includes a \(4\times4\) depthwise-separable convolution followed by a \(1\times1\) convolution before concatenation. It also makes clear that the output projection is applied after attention has already mixed the original feature channels with the illumination-augmented query space. This suggests that the illumination signal is used to steer feature interactions while still allowing the final representation to remain dimensionally compatible with the residual backbone.

## 5. Distinction from vanilla multi-head self-attention

The paper contrasts IG-MSA with vanilla multi-head self-attention as used, for example, in ViT. Vanilla MSA constructs \(Q\), \(K\), and \(V\) by three independent linear projections or \(1\times1\) convolutions of \(F\), flattens spatial tokens, and computes \(\mathrm{softmax}\bigl(QK^T/\sqrt{d}\bigr)\,V\). IG-MSA differs in four stated respects [2507.15520].

First, \(Q\), \(K\), and \(V\) are generated via depthwise-separable convolutions to better preserve local context in \(F\). Second, the mechanism performs channel-wise self-attention, treating the \(C\) feature channels as tokens rather than attending over spatial tokens. Third, it explicitly concatenates the illumination embedding \(I_{\rm emb}\) into the queries, allowing the spatially varying illumination map to modulate the dot-product affinities. Fourth, it introduces a learnable scale \(\alpha\) for fine-tuning the impact of illumination guidance on the attention scores.

The intended consequence of these modifications is also stated directly: they permit the module to steer the Transformer’s focus onto channels that are relevant to reconstructing the correct local brightness, thereby avoiding the over- or under-exposure artifacts common in uniform, end-to-end approaches. A common misconception would be to treat IG-MSA as a standard attention block with a side-channel prior added after attention. Its defining property is stronger than post-hoc conditioning: the illumination map participates in the query representation that determines affinity itself.

## 6. Empirical effects and ablation evidence

The ablation study reported on LOL-v2-Real isolates the contribution of IG-MSA and its interaction with the Spatially-Adaptive Integral Illumination Estimator (SAI\(^2\)E). The reported PSNR/SSIM results are as follows [2507.15520]:

| Configuration | PSNR | SSIM |
|---|---:|---:|
| baseline (pure U-shaped transformer) | 23.01 dB | 0.867 |
| + IG-MSA (with simple mean-RGB prior instead of SAI\(^2\)E) | 23.22 dB | 0.871 |
| + IG-MSA + SAI\(^2\)E (full illumination guidance) | 23.84 dB | 0.873 |

On these figures, IG-MSA alone yields a \(+0.21\) dB PSNR uplift over the baseline, and the combination of IG-MSA with SAI\(^2\)E yields a \(+0.83\) dB gain over the baseline. Qualitative residual-map visualizations in Fig. 8 are described as showing that IG-MSA produces residuals that tightly follow the non-uniform illumination pattern, whereas a model without IG-MSA brightens uniformly and loses detail in shadow and backlit regions.

Within the larger SAIGFormer framework, these observations are presented as evidence that illumination-guided attention is particularly relevant when enhancement quality depends on spatially adaptive brightness restoration rather than global exposure correction. A plausible implication is that the module’s value is highest in settings where the dominant failure mode is not insufficient global context, but incorrect local lightness calibration across heterogeneous illumination fields.

Source: https://www.emergentmind.com/topics/illumination-guided-multi-head-self-attention-ig-msa