Restoring Images in Adverse Weather Conditions via Histogram Transformer

Shangquan Sun, Wenqi Ren, Xinwei Gao, Rui Wang, Xiaochun Cao

Abstract

Transformer-based image restoration methods in adverse weather have achieved significant progress. Most of them use self-attention along the channel dimension or within spatially fixed-range blocks to reduce computational load. However, such a compromise results in limitations in capturing long-range spatial features. Inspired by the observation that the weather-induced degradation factors mainly cause similar occlusion and brightness, in this work, we propose an efficient Histogram Transformer (Histoformer) for restoring images affected by adverse weather. It is powered by a mechanism dubbed histogram self-attention, which sorts and segments spatial features into intensity-based bins. Self-attention is then applied across bins or within each bin to selectively focus on spatial features of dynamic range and process similar degraded pixels of the long range together. To boost histogram self-attention, we present a dynamic-range convolution enabling conventional convolution to conduct operation over similar pixels rather than neighbor pixels. We also observe that the common pixel-wise losses neglect linear association and correlation between output and ground-truth. Thus, we propose to leverage the Pearson correlation coefficient as a loss function to enforce the recovered pixels following the identical order as ground-truth. Extensive experiments demonstrate the efficacy and superiority of our proposed method.

Introduction

Restoring images captured in adverse weather conditions like rain, fog, and snow is a fundamental challenge in computer vision. While Convolutional Neural Networks (CNNs) and Transformers have significantly advanced the field, they often struggle with a critical trade-off between computational efficiency and the ability to capture global context. Standard Transformers are computationally expensive due to the quadratic complexity of global self-attention. Consequently, many existing methods restrict self-attention to small local windows or perform it across the channel dimension.

Input patches of various weather degradations and existing self-attention mechanisms.

However, weather degradation is rarely a purely local phenomenon. A snowflake in one corner of an image often shares nearly identical visual characteristics—such as brightness and texture—with a snowflake in the opposite corner. Local-window Transformers fail to exploit these long-range similarities. The proposed Histogram Transformer (Histoformer) addresses this by grouping pixels based on their intensity rather than their spatial proximity, allowing the model to learn from similar degradation patterns across the entire image without the overhead of global attention.

Methodology: The Histoformer Architecture

The core innovation of Histoformer lies in its ability to break spatial constraints and process pixels with similar degradation characteristics together. This is achieved through three primary components:

Dynamic-range Histogram Self-Attention (DHSA)

Instead of operating on a fixed spatial grid, DHSA sorts and segments spatial features into "bins" based on their intensity values. This process, termed Histogram Categorization, allows the model to apply self-attention either within a specific bin or across different bins. By doing so, the network can selectively focus on spatial features within a specific dynamic range, effectively processing similar degraded pixels together regardless of their physical distance in the image.

The Histogram Categorization process, sorting weather-affected patterns and background pixels into intensity-based bins.

Dynamic-range Convolution

Standard convolutions are limited by a fixed, local receptive field. Histoformer introduces Dynamic-range Convolution, which sorts pixels by intensity before performing a separable convolution. This allows the convolution operation to act on pixels with similar visual characteristics rather than just immediate spatial neighbors, enhancing the model's ability to handle non-local weather artifacts.

Dual-scale Gated Feed-Forward (DGFF)

Weather artifacts vary significantly in size, from fine rain streaks to large, out-of-focus snowflakes. To address this multi-scale nature, the DGFF module utilizes two parallel pathways with different kernel sizes and dilations. This ensures the model captures both fine-grained details and broader structural information.

Pearson Correlation Loss

Traditional restoration models often rely on pixel-wise losses like L1 or L2. However, these metrics can neglect the linear association and correlation between the restored output and the ground truth. Histoformer incorporates a loss function based on the Pearson correlation coefficient. This ensures that the recovered pixels maintain the same relative intensity ordering as the clean ground-truth image, leading to more structurally consistent results.

Experimental Evaluation

The Histoformer was evaluated against state-of-the-art methods on several benchmark datasets, including Snow100K, Outdoor-Rain, and RainDrop. The authors also tested the model on 1,329 real-world snowy images to demonstrate practical robustness.

Key Results

Histoformer achieved superior performance across multiple tasks. On the Snow100K-S dataset, it reached a PSNR of 37.41 dB, outperforming the previous state-of-the-art (AWRCP) by approximately 0.5 dB. In raindrop removal, it achieved 33.06 dB PSNR, a significant improvement over the popular Restormer model (32.18 dB).

Qualitatively, Histoformer excels at removing large, bright snow spots and thick haze that typically leave "ghosting" artifacts in other models. Furthermore, downstream testing using the Google Vision API showed that images restored by Histoformer significantly improved object detection accuracy for obscured objects like doors and pedestrians.

Conclusion and Future Work

Histoformer introduces a novel paradigm for image restoration by leveraging intensity-based histogramming to capture long-range spatial dependencies efficiently. By breaking the traditional spatial bias of vision models, it effectively handles the global nature of weather degradation. While highly effective, the authors noted that increasing the number of histogram bins can lead to high memory consumption on current GPU architectures. Future research will focus on optimizing the sorting mechanism for better hardware efficiency and exploring the application of histogram-based attention to other restoration tasks.

Summary updated

BibTeX
@inproceedings{sun2024restoring,
  author = {Shangquan Sun and Wenqi Ren and Xinwei Gao and Rui Wang and Xiaochun Cao},
  title = {{Restoring Images in Adverse Weather Conditions via Histogram Transformer}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-72670-5\_7},
}
Figure