Better HN
topnewbestaskshowjobs
Log inSign up

rh12503

120 karma · joined Apr 19, 2021 (5y ago) · 22 submissions

Submissions

comment 5y ago · link · parent

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

2.

Show HN: Triangula can now create polygonal art from images(github.com ↗)

1 points · by rh12503 · 5y ago · 1 comment

comment 5y ago · link · parent

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.

comment 5y ago · link · parent

Cool! I'm guessing you use an edge detection algorithm like https://github.com/esimov/triangle?

comment 5y ago · link · parent

This is amazing! Is there any way to download this in a 3D file format?

comment 5y ago · link · parent

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

comment 5y ago · link · parent

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!

comment 5y ago · link · parent

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!

comment 5y ago · link · parent

Not particularly, but Go is fast, compiles to small binaries, and supports multithreading with coroutines which works well for genetic algorithms.

comment 5y ago · link · parent

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...

comment 5y ago · link · parent

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

comment 5y ago · link · parent

Blurring is a good idea! It could work with placeholder images, but it'll probably be better with smaller ones (eg. profile pictures).

comment 5y ago · link · parent

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...

comment 5y ago · link · parent

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.

comment 5y ago · link · parent

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...

comment 5y ago · link · parent

Thanks! One main difference from Primitive is that Primitive's shapes can overlap, while Triangula generates a triangulation.

comment 5y ago · link · parent

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.

comment 5y ago · link · parent

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?

19.

Show HN: I built a tool to generate triangulated art from images(github.com ↗)

296 points · by rh12503 · 5y ago · 69 comments

20.

Triangula: An iterative algorithm to generate high quality triangulated images(github.com ↗)

1 points · by rh12503 · 5y ago · discuss