Abstract
Vector image representation is a popular choice when editability and flexibility in resolution are desired. However, most images are only available in raster form, making raster-to-vector image conversion (vectorization) an important task. Classical methods for vectorization are either domain-specific or yield an abundance of shapes which limits editability and interpretability. Learning-based methods, that use differentiable rendering, have revolutionized vectorization, at the cost of poor generalization to out-of-training distribution domains, and optimization-based counterparts are either slow or produce non-editable and redundant shapes. In this work, we propose Optimize & Reduce (O&R), a top-down approach to vectorization that is both fast and domain-agnostic. O&R aims to attain a compact representation of input images by iteratively optimizing Bézier curve parameters and significantly reducing the number of shapes, using a devised importance measure. We contribute a benchmark of five datasets comprising images from a broad spectrum of image complexities - from emojis to natural-like images. Through extensive experiments on hundreds of images, we demonstrate that our method is domain agnostic and outperforms existing works in both reconstruction and perceptual quality for a fixed number of shapes. Moreover, we show that our algorithm is $\times 10$ faster than the state-of-the-art optimization-based method.
Introduction
Most digital imagery exists in raster format—grids of pixels that lose quality when scaled and are difficult to manipulate at a structural level. In contrast, vector images are defined by mathematical paths, offering infinite resolution and intuitive editability. Converting raster images to vectors, a process known as vectorization, remains a significant challenge in computer vision.
Existing solutions typically fall into three categories, each with distinct drawbacks:
- Classical methods (e.g., Potrace): These often generate thousands of tiny, fragmented shapes, making the resulting file nearly impossible to edit manually.
- Learning-based methods: While fast, these models often fail to generalize to images outside their specific training distribution.
- Optimization-based methods (e.g., LIVE): These produce high-quality, compact results but are computationally expensive because they build images "bottom-up," adding one shape at a time.
To address these issues, we introduce Optimize & Reduce (O&R), a framework designed to provide the quality and compactness of optimization-based methods without the massive computational overhead.
The O&R Framework
O&R utilizes a top-down approach. Rather than building an image shape-by-shape, it begins with a surplus of shapes and systematically prunes them to reach a target budget.
Smart Initialization
Differentiable rendering is highly sensitive to the starting positions of shapes. To avoid poor local minima, O&R uses DBSCAN clustering to identify primary color regions in the input image. Initial Bézier shapes (circles) are placed at the centers of these clusters, providing a "warm start" for the optimization process.
The Optimization Loop
The core of the algorithm is an iterative process:
- Optimize: Using DiffVG (a differentiable rasterizer), the system adjusts the coordinates and colors of the Bézier curves to minimize the Mean Squared Error (MSE) between the vector output and the original raster image.
- Reduce: The system calculates an "importance measure" for every shape by evaluating the potential drop in image quality if that specific shape were removed. It then deletes the least important shapes (typically half of the current set) and repeats the optimization.
Geometric and Semantic Constraints
To ensure the resulting shapes remain simple and editable, we introduced a novel geometric loss function that penalizes self-intersections and prevents shapes from becoming overly convoluted or "spiky." Additionally, by incorporating CLIP loss (a semantic vision-language model), the method can be tuned to prioritize the "semantic essence" of an image over pixel-perfect reconstruction, facilitating artistic abstraction.
Experimental Setup and Datasets
To test the domain-agnostic nature of O&R, we introduced a diverse benchmark of five datasets representing varying levels of complexity:
- Old Emojis: Simple, flat-color icons.
- New Emojis (2022): Complex icons featuring gradients.
- Free-SVG: Intricate clipart images.
- NFT-Apes: 100 images from the Bored Ape Yacht Club with varied accessories.
- Midjourney: 100 AI-generated, natural-like images used to stress-test the vectorization of complex textures.
Results and Key Insights
Our experiments demonstrate that O&R is roughly 10x faster than the current state-of-the-art optimization method, LIVE. Despite the speed increase, O&R consistently achieves lower MSE and better perceptual scores (LPIPS) across all tested datasets for a fixed number of shapes.
Key takeaways include:
- Top-Down Efficiency: Pruning from a large set is significantly more efficient than the layer-wise addition used in previous methods.
- Compactness and Editability: By forcing the model to work within a small shape budget (e.g., 32 or 64 shapes), the resulting SVG becomes semantically meaningful. A single shape might represent an entire anatomical feature or garment, making manual color swaps or path adjustments trivial for designers.
- Detail Recovery: For highly complex images, we found that selectively adding shapes back into high-error regions after the reduction phase allows the model to recover fine details, such as eyes or small textures, that might otherwise be lost.
Limitations and Future Work
While O&R represents a significant leap in speed for optimization-based vectorization, it remains an iterative process that is slower than single-pass neural networks. Furthermore, extremely high-frequency textures (such as fur or grass) remain a challenge for low-budget vector representations. Future research will explore more sophisticated importance measures and refined geometric constraints to handle increasingly complex topological structures.
Summary updated