Diffusion-based Aesthetic QR Code Generation via Scanning-Robust Perceptual Guidance

Jia-Wei Liao, Winston Wang, Tzu-Sian Wang, Li-Xuan Peng, Cheng-Fu Chou, Jun-Cheng ChenarXiv 2024 · DOI

Introduction

The ubiquity of Quick Response (QR) codes in modern digital life is undeniable, yet their visual design remains largely utilitarian—characterized by stark, black-and-white geometric modules. While recent advancements in generative AI, particularly Stable Diffusion and ControlNet, have enabled the blending of QR codes into artistic imagery, a fundamental "scannability-aesthetics dilemma" persists. High guidance scales often lead to "robotic" artifacts and unnatural patterns, while low guidance compromises the functional integrity of the code. This paper presents a novel framework designed to bridge this gap, producing high-quality digital art that remains robustly scannable by standard smartphone readers.

Aesthetic QR code generation examples across various artistic styles, showing the original QR code and four generated variations with their respective prompts.

Methodology

The proposed framework, Scanning-Robust Perceptual Guidance (SRPG), introduces several key innovations to maintain the balance between visual beauty and functional utility.

Scanning-Robust Loss (SRL)

The core of the approach is a differentiable loss function, SRL, which emulates the binarization process of a physical QR scanner. Recognizing that scanners are most sensitive to the centers of modules, the SRL employs a Gaussian kernel to re-weight pixels. By prioritizing the center of each module, the model can effectively "hide" the necessary data logic within the natural textures and gradients of the generated artwork.

Scanning-Robust Guidance (SRG) and Early Stopping

During the denoising steps of the diffusion process, the gradient of the SRL is used to iteratively "nudge" the image toward scannability. A critical feature of this guidance is the early-stopping mechanism. Once a specific module reaches a threshold of scannability, the model ceases optimization for that area. This prevents the over-optimization that typically results in the blocky, artificial artifacts seen in previous methods, allowing the diffusion model to focus exclusively on aesthetics for those regions.

Two-Stage Refinement Pipeline

The SRPG framework operates in two distinct stages:

  1. Initial Generation: A preliminary aesthetic image is generated using a standard ControlNet setup (e.g., QR Code Monster v2).
  2. Perceptual Refinement: The image is refined using Scanning-Robust Perceptual Guidance. This stage balances scannability (via SRL) with perceptual similarity (using LPIPS) to ensure the final output adheres to the original artistic intent while maximizing scan success.

For applications requiring absolute reliability, the authors also introduce SRPGD, a post-processing step using Projected Gradient Descent to make minute, mathematically optimized pixel adjustments that guarantee a 100% scanning success rate.

Experimental Evaluation

The researchers evaluated their framework using the Stable Diffusion "Cetus-Mix Whalefall" checkpoint and a test set of 30 diverse prompts generated by GPT-4. Performance was measured using the Scanning Success Rate (SSR) on an iPhone 13 and the LAION Aesthetics Predictor (LAS).

The results demonstrate a significant leap over existing state-of-the-art tools. While the baseline "QR Code Monster" achieved a 46.67% SSR, the SRPG two-stage pipeline reached 86.67%. When combined with the SRPGD post-processing, the framework achieved a 100% SSR. Crucially, this functional robustness did not come at the cost of beauty; the LAS scores remained high (6.9 to 7.1), and a user study involving 387 participants ranked the proposed method as the most visually appealing.

Conclusion and Future Work

This research successfully addresses the trade-off between artistic expression and functional utility in QR code generation. By focusing on the "center pixel" priority and implementing an early-stopping mechanism, the SRPG framework produces aesthetic QR codes that are both beautiful and reliable. Future work will focus on refining the post-processing stage to eliminate minor visual noise and exploring more complex error-correction mechanisms to embed data within even more intricate artistic patterns.

Summary updated

BibTeX
@misc{liao2024diffusion,
  author = {Jia-Wei Liao and Winston Wang and Tzu-Sian Wang and Li-Xuan Peng and Cheng-Fu Chou and Jun-Cheng Chen},
  title = {{Diffusion-based Aesthetic QR Code Generation via Scanning-Robust Perceptual Guidance}},
  year = {2024},
  eprint = {2403.15878},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.15878},
}
Figure