Pattern Analogies: Learning to Perform Programmatic Image Edits by Analogy

Aditya Ganeshan, Thibault Groueix, Paul Guerrero, Radomír Mech, Matthew Fisher, Daniel Ritchie · DOI

TL;DR

This paper introduces a new way to edit complex visual patterns by using simple "pattern analogies" (a pair of example edits) and a novel diffusion model called TriFuser. This approach bypasses the need to understand the underlying program of a pattern, making programmatic edits more intuitive and accessible, especially for real-world designs.

What Problem Does This Paper Address?

Editing visual patterns, like those found in textiles or wallpapers, is challenging because the desired changes are often "programmatic." This means they involve altering the underlying rules or program that generates the pattern, rather than just superficial visual tweaks. Existing methods for this, called Visual Program Inference (VPI), struggle with complex patterns and produce programs that are hard to understand and edit. The authors aim to provide a more intuitive and effective way to perform these structure-aware edits without needing to infer the complex underlying programs.

Methods

The core of the proposed solution lies in two main components:

  • SPLITWEAVE: A domain-specific language (DSL) designed for creating and manipulating visual patterns. SPLITWEAVE allows users to define patterns using a node-based visual interface, enabling parametric control over pattern elements and structure. Crucially, it's used to generate both the "analogy" patterns (A, A') and the target patterns (B) for training.
  • TRIFUSER: A Latent Diffusion Model (LDM) specifically adapted for analogical pattern editing. Unlike standard LDMs, TRIFUSER incorporates several architectural enhancements to handle the nuances of pattern editing:
  • Detail Erosion Mitigation: It fuses features from both early and late layers of the feature encoder to retain fine-grained pattern details.
  • Semantic Bias Reduction: It combines features from both text-image (CLIP) and self-supervised (DiNOv2) encoders to balance high-level semantics with spatial details.
  • Token Entanglement Solution: It uses 3D positional encodings to explicitly inform the model about a token's spatial location within a pattern and its source image (A, A', or B).

The overall workflow involves using SPLITWEAVE to create synthetic "analogical quartets" (A, A', B, B') where the edit from A to A' mirrors the edit from B to B'. These quartets are then used to train TRIFUSER.

Datasets

  • Synthetic Dataset: Approximately 1 million analogical quartets were generated using SPLITWEAVE, covering two primary pattern styles: Split Filling Patterns (SFP) and Motif Tiling Patterns (MTP). For MTP, 100,000 distinct tiles were synthesized using the LayerDiffuse model.
  • Synthetic Test Set: 1,000 analogical quartets were created for evaluating performance on unseen synthetic data.
  • Real-World Test Set: A curated dataset of 50 patterns from Adobe Stock, spanning seven distinct styles (including MTP and SFP, plus others like Memphis-style, geometric, and digital textile). For these, simple analogical pairs (A, A') were generated using SPLITWEAVE to demonstrate desired edits.

Key Insights and Ideas

  • Analogy as a Programmatic Edit Interface: The paper demonstrates that simple visual analogies (A, A') can effectively convey complex, structure-aware edits without requiring explicit program inference. This shifts the burden from understanding the pattern's internal logic to demonstrating the desired transformation.
  • Synthetic Data for Generalization: The creation of a large, high-quality synthetic dataset using SPLITWEAVE is crucial for training a model that can generalize to real-world, artist-sourced patterns, even those from styles not seen during training.
  • LDM Adaptation is Key: Standard LDMs struggle with analogical pattern editing due to issues like detail erosion and semantic bias. The architectural modifications in TRIFUSER are essential for achieving high-fidelity, programmatic edits.
  • 3D Positional Encoding for Context: Explicitly encoding spatial location and source image for each patch-level token is vital for the model to correctly identify the target pattern and the intended edit.

Key Results

  • Human Preference Study: In a perceptual study comparing TRIFUSER with three baselines (Analogist, LatentMod, Inpainter), TRIFUSER was preferred in the overwhelming majority of judgments (89.24% vs. Analogist, 80.59% vs. LatentMod, 72.05% vs. Inpainter).
  • Generalization: TRIFUSER effectively edits patterns from novel styles not present in its training data, demonstrating strong generalization capabilities.
  • Quantitative Evaluation: On a synthetic validation set, TRIFUSER outperformed baselines across multiple perceptual metrics (DSIM, DISTS, LPIPS, SSIM), indicating higher perceptual similarity to ground truth.
  • Ablation Studies: Removing any of TRIFUSER's key components (like 3D positional encoding or feature fusion) led to a significant degradation in performance, highlighting the importance of each modification.

Limitations and Future Work

  • Limitations:
    • The paper acknowledges that while TRIFUSER performs well on stylistic edits, its primary strength is in programmatic edits.
  • The "Inpainter" baseline achieved slightly higher SSIM scores, suggesting potential benefits from combining approaches.
  • Future Work:
    • The authors aim to extend this analogical editing framework to other domains, such as semi-parametric 3D modeling.
  • They also plan to continue improving synthetic data generation techniques.
  • Combining TRIFUSER's approach with methods like Inpainter could be beneficial.

Summary updated

BibTeX
@inproceedings{ganeshan2025pattern,
  author = {Aditya Ganeshan and Thibault Groueix and Paul Guerrero and Radomír Mech and Matthew Fisher and Daniel Ritchie},
  title = {{Pattern Analogies: Learning to Perform Programmatic Image Edits by Analogy}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.02674},
}
Figure