HNHacker News
TopNewBestAskShowJobs

rh12503

120 karma · joined April 19, 2021

submissionscomments
rh12503··on Show HN: Triangula can now create polygonal art from images
I've added a few examples of polygonal output to the README here [0].

Many people commented on my initial post on how Triangula could be used for LQIPs. I've created a library called tip [1] for this purpose, which is currently not production ready but should work for almost all cases.

Any feedback for both projects is appreciated!

[0] https://github.com/RH12503/triangula#polygonal [1] https://github.com/RH12503/tip

rh12503··on Show HN: I built a tool to generate triangulated art from images
Actually, the initialization is completely random. The reason why it might seem too optimal is because the algorithm chooses the colors most similar to the image when rendering the triangles.
rh12503··on Show HN: I built a tool to generate triangulated art from images
Cool! I'm guessing you use an edge detection algorithm like https://github.com/esimov/triangle?
rh12503··on Show HN: I built a tool to generate triangulated art from images
This is amazing! Is there any way to download this in a 3D file format?
rh12503··on Show HN: I built a tool to generate triangulated art from images
For low-poly art, I wonder if there could be a way to only triangulate a specific area. (eg. only the pet and not the background)

Also, if you need something less aliased, check out Triangle [1], a similar and awesome tool!

[1] https://github.com/esimov/triangle

rh12503··on Show HN: I built a tool to generate triangulated art from images
That sounds super cool! I'd be interested in seeing a picture if you end up doing it. Let me know if you need any help with the API!
rh12503··on Show HN: I built a tool to generate triangulated art from images
I originally intended this to be a generative art side project, but there's been a magnitude of great ideas commented here!

The graph idea could work, but the algorithm produces slightly different results each time it is ran. It still could be really interesting to try!

rh12503··on Show HN: I built a tool to generate triangulated art from images
Not particularly, but Go is fast, compiles to small binaries, and supports multithreading with coroutines which works well for genetic algorithms.
rh12503··on Show HN: I built a tool to generate triangulated art from images
Triangula uses a modified genetic algorithm which I wrote about on the wiki here [1]. The reason I didn't use simulated annealing is because I ran some tests and found it was generally less effective for my case.

[1] https://github.com/RH12503/Triangula/wiki/Explanation-of-the...

rh12503··on Show HN: I built a tool to generate triangulated art from images
I found Wails very simple to use, and would highly recommend it to anyone looking for a lightweight GUI library.

However, Wails v1 uses mshtml (basically ie11) on Windows, so some features are unavailable.

Wails uses Webpack so you need npm installed when developing your app.

You might also be interested in Tauri [1] which is a similar framework but in Rust.

[1] https://github.com/tauri-apps/tauri

rh12503··on Show HN: I built a tool to generate triangulated art from images
Blurring is a good idea! It could work with placeholder images, but it'll probably be better with smaller ones (eg. profile pictures).
rh12503··on Show HN: I built a tool to generate triangulated art from images
Thanks! The algorithm works iteratively, so essentially each iteration it makes small changes and then checks if these changes are optimal. (There are many more details described on the wiki [1])

The frames of the glasses were preserved because the algorithm "decided" that it was optimal to keep them with the limited number of points it has to work with.

[1] https://github.com/RH12503/Triangula/wiki/Explanation-of-the...

rh12503··on Show HN: I built a tool to generate triangulated art from images
That's an interesting idea! I suppose it could be used for compression, although my intentions were for this to be a generative art project.

I triangulated a 1988×1491 jpg using 10,000 points and managed to reduce the size to 20% of the original size, but the triangles could still obviously be seen.

rh12503··on Show HN: I built a tool to generate triangulated art from images
I was just thinking about adding another wiki page for that, but I'll give a brief explanation here:

Firstly, a triangulation is made from the points and colors are chosen for each triangle.

Then, the variance between the triangles and the original image is calculated using Welford's online algorithm [1]. The variance is computed by iterating over the pixels of each triangle and comparing the pixel color of the original image to the color of that triangle.

Lastly, the fitness is multiplied by a weight to ensure that it covers the entire canvas.

The source code may be a bit confusing because I've applied many optimizations which make it 10-20x faster.

[1] https://en.wikipedia.org/wiki/Algorithms_for_calculating_var...

rh12503··on Show HN: I built a tool to generate triangulated art from images
Thanks! One main difference from Primitive is that Primitive's shapes can overlap, while Triangula generates a triangulation.
rh12503··on Show HN: I built a tool to generate triangulated art from images
I'm a bit unsure of what you mean, but the genetic algorithm is used to find an optimal set of points, and then a Delaunay triangulation is created from those points.
rh12503··on Show HN: I built a tool to generate triangulated art from images
Wails v1 (which this project uses) uses Webview for rendering it's frontend. You can read more about how Wails works here: https://wails.app/about/concepts/

Also because I'm pretty sure you're going to be the only one to see this post, do you have any feedback on the app?