esimov / triangle

Convert images to computer generated art using delaunay triangulation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Overlapping/excessive triangles

evilfunnybird opened this issue · comments

So, whenever I try to triangulate an image, there is a problem with some random triangles that are drawn above the necessary ones. Sometimes they are a something like a line, and sometimes they are gigantic. I tried to change value of all of the parameters/flags but no luck.
In the attached files is the source and generated images with flags: -pts 5000 -blur 1.

173
173
img31
img31

I might try to resolve it but it can be a tricky one.

The thing is, wierd triangles are actually overlapping (there are "normal" triangles underneath) and they are not in the end af the generated file (if they were, I could've just not include them, but figuring out excessive triangles sounds like a resourse-intensive task)

I assume you analyzed the svg version.

A little bit, yeah, since I parse it to get triangles for a thing I'm making

commented

facemask

I have the same issue. I don't use any svg features.

I was asking because you mentioned that the there are normal triangles underneath the artifacts. Meantime I have checked also myself and that's correct. I don't know yet why, but I will try to debug to understand why this is happening.

commented

facemask

Here's an extreme example.

commented

I'm going to assume there was a regression in a recent update to the code. Perhaps in the last year. Because I think you would have seen this effect when you first wrote the package.

I restored back to a few commit points to see if these artifacts are still present in the previous versions. Unfortunately this issue is present on the earliest versions too, but they are showing only occasionally.

So, by any chance, do you have an idea, what might cause this issue? For testing purposes I additionally ran this in single and multi thread and with different options, still no luck.

I'm sorry for the late response, it was a tricky bug to capture, because it happened only occasionally. The reason was due to wrong type conversion. Because in almost any part of the code base the conversion was from float to int, it happened that in the renamed polygon.go file I used integers instead of floats and this affected the end results. During the debugging session I realized that the API does not stand up from the architecture point of view so I have refactored completely the code and also extended with additional features in order to be even more customizable, which results in a more appealing visual output. But this in the next release, which is coming soon.

Here is an example of using the old method and the new one.

triangle_old
triangle_new

I have published a new v1.3.0 release, which as I mentioned now has a completely rewritten API, new logic for a better visual output, extended CLI options for a more advanced customization etc. If you don't have any objections I will close this issue.

So, indeed, the new version resolved this issue, thank you

One more bonus to 1.3.0 - svg files are more compact now (for me it's like 20-30%)