logoalt Hacker News

Iterative image reconstruction using random cubic bézier strokes

66 pointsby luthenwaldlast Thursday at 1:27 PM16 commentsview on HN

Comments

mattdesltoday at 6:06 PM

Nice work, the outputs look ethereal and quite beautiful. For some related work using genetic algorithms and evolution strategies, see[1].

Sketch synthesis is an area I'm pretty interested in lately; I'm currently exploring similar things with CLIP to guide fitness, natural evolution strategy to optimize the rendered results, and using an implicit neural representation to represent pen plotter paths (rather than a series of explicit curves/strokes).[2]

[1] https://es-clip.github.io/

[2] https://x.com/mattdesl/status/2011434166022476109

show 1 reply
atulvitoday at 5:55 PM

I tried something like this years ago but using genetic algorithms https://a.tulv.in/genetic-art.html

kvnhntoday at 5:12 PM

I made a simple web UI[1] for generating images like this. It uses a Go library by Michael Fogleman[2] for all the heavy lifting—hat’s off to him.

For Bézier curves in particular, iteratively constraining the search around initial matches seems key to retaining detail (see the “rep” argument in Fogleman’s work), for example in the eyes of the Vermeer portrait in the OP.

[1]: https://github.com/kevin-hanselman/primitive-web-ui

[2]: https://github.com/fogleman/primitive

behnamohtoday at 5:14 PM

The project references Geometrize: https://github.com/Tw1ddle/geometrize and I find both insanely cool!

show 1 reply
bArraytoday at 5:15 PM

I wrote something similar years ago, which would instead convert an image into a mesh of polygons. The idea was to have a vector low-size SVG that could be used as an image placeholder or background for web pages.

I think I lost the code, but it was initially a genetic algorithm that randomly placed overlapping polygons, but the later improved method had connected polygons that shared points - which was far more computationally cheaper.

Another method I explored was to compose a representative image via a two-colour binarised bitmap, which provided a pixelated version of the image as a placeholder.

The core idea is that you drop the image as a small Data URI straight into the page, and then fetch the high-detail version later. From the user's perspective, they are getting a very usable web page early on, even on poor connections.

anematodetoday at 6:34 PM

Awesome stuff :) The results are really impressive.

GPU acceleration is a really good idea; my CPU implementation of a similar idea with triangles (https://github.com/anematode/triangle-stacking) was compute constrained for smaller images (which was fixable with good SIMD optimizations) but became bandwidth constrained for very large images that don't fit in L2. I think a port to OpenCL would have been a good idea.

Sharlintoday at 5:14 PM

Back in the 00s a friend and I played with the idea of using genetic programming and random line segments to approximate images (ie. maintain a population of candidates, take the best n percent, "breed" them to create the next generation, add some "mutations", repeat). This implementation seems to use a basic hill-climbing algorithm to reach a local optimum – something like simulated annealing might improve both quality and speed of convergence.

jeremyscanvictoday at 7:32 PM

Really cool! Any specific reason for the choice of Oklab instead of say HSL/HSV?

show 1 reply
9021007today at 6:00 PM

Nice to see Tangled used out there in the wild :)

akoboldfryingtoday at 9:12 PM

I think you'll find that most of the retained curves are short, because these are the ones that are able to provide local detail. Maybe you could improve the detail level by choosing the 4 control points to be nearby most of the time?

I made a similar thing a few years ago using randomly placed translucent circles of random sizes and fixed opacity level (about 20% as I recall). Initially the circles had unknown colours; after placing them all, for each of the R, G and B channels, I used a linear programming solver to solve exactly for the intensities in that channel that would minimise an overall error (I had to use the L1 distance, since the more usual squared error couldn't be expressed in the solver). This produced some quite nice images, that were also fun to animate :)

odyssey7today at 8:06 PM

See also: Differentiable Vector Graphics Rasterization

https://people.csail.mit.edu/tzumao/diffvg/

seg_loltoday at 5:45 PM

For historic reference, back in 2008, Roger https://www.rogeralsing.com/2008/12/07/genetic-programming-e... kicked this off by attempting to reproduce the Mona Lisa using evolved polygons.

https://news.ycombinator.com/item?id=389727