Metal-Accelerated Image Reconstruction with Random Bézier Strokes

Splined is a Rust program that reconstructs images by iteratively adding random cubic Bézier strokes, accelerated with Metal and guided by OKLab error reduction. It provides a robust CLI for performance and quality control, supports both single images and directories, and can export intermediate frames for animations. The project is inspired by Geometrize and plans better antialiasing and broader GPU backend support.
Key Points
- Iterative algorithm: sample random cubic Bézier strokes, compute coverage, set stroke color from coverage-weighted target pixels, and accept strokes only if they reduce squared OKLab error.
- GPU-accelerated on Metal with batched evaluation; users can cap GPU usage, set batch sizes, and control stroke limits for performance and quality trade-offs.
- CLI features include seeding for reproducibility, background color and alpha, resume-from-canvas, periodic frame saving (--nth), and directory processing that mirrors input structure.
- Showcase demonstrates varied reconstructions from the same input using different seeds, enabling simple animations.
- Future work targets improved antialiasing and additional GPU backends (e.g., wasm) to broaden platform support.
Sentiment
The Hacker News community is enthusiastically supportive of this project. Commenters widely praise the visual quality, share their own related implementations spanning nearly two decades of similar work, and offer constructive technical suggestions for improvement. There is no real opposition or criticism — the discussion is a celebration of this creative coding genre with rich cross-pollination of ideas and historical references.
In Agreement
- The outputs look ethereal and beautiful, demonstrating impressive visual quality from a relatively simple iterative algorithm
- GPU acceleration via Metal is a smart approach for this computationally intensive task, addressing bandwidth constraints that plague CPU implementations on large images
- The concept of iterative image reconstruction with geometric primitives is fascinating and connects to a rich history dating back to 2008
- OKLab is a well-chosen color space due to its perceptual uniformity, which makes error minimization more meaningful than in HSL/HSV
Opposed
- The basic hill-climbing algorithm could be improved with simulated annealing for better quality and faster convergence
- Most retained curves are likely short; constraining control points to be nearby or adaptively reducing curve size after rejections could significantly improve detail retention
- Randomly directed brush strokes lose the deliberate alignment that real paintings exhibit, which matters when aiming for artistic rather than photorealistic results