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 overall sentiment of the Hacker News discussion is overwhelmingly positive and appreciative. Commenters express significant admiration for the `splined` project's results and its technical approach, while simultaneously engaging in a highly constructive dialogue by referencing related historical and contemporary work and offering thoughtful, non-critical suggestions for potential algorithmic enhancements or alternative methods.
In Agreement
- The outputs produced by `splined` are highly aesthetic, described as "ethereal and quite beautiful" and "really impressive."
- GPU acceleration is a crucial and "really good idea" for performance, preventing compute or bandwidth constraints seen in CPU-only implementations.
- The choice of OKLab color space is technically sound and advantageous due to its superior perceptual uniformity compared to alternatives like HSL/HSV, which aids in accurate color processing.
- The project is generally considered "awesome stuff" and "insanely cool."
Opposed
- The iterative hill-climbing algorithm used could potentially be improved by alternative optimization methods such as genetic algorithms, evolution strategies, or simulated annealing, which might lead to better quality and/or faster convergence.
- Exploring "differentiable vector graphics rasterization" could offer a more modern or powerful approach to optimizing stroke placement and appearance.
- To retain more fine detail with Bézier curves, strategies like iteratively constraining the search around initial matches or ensuring control points are frequently chosen to be nearby could be implemented.
- Broadening GPU backend support beyond Apple's Metal (e.g., to OpenCL or WebAssembly) would increase the tool's accessibility and utility across different hardware and platforms.