4 ms·
My main concern is why the choice of a (slow) genetic algorithm vs a more traditional Delaunay triangulation algorithm?
by trinovantes 6y ago
My main concern is why the choice of a (slow) genetic algorithm vs a more traditional Delaunay triangulation algorithm?
- rh12503 6y agoI'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.
- trinovantes 6y agoAh, I must've misread the wiki. I thought it meant you used genetic algorithm for triangulation instead of point selection. What's your criteria for calculating the fitness for a candidate set of points? https://github.com/RH12503/Triangula/wiki/Explanation-of-the-algorithm https://github.com/RH12503/Triangula/wiki/Explanation-of-the...
- rh12503 6y agoI 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_variance#Welford's_online_algorithm https://en.wikipedia.org/wiki/Algorithms_for_calculating_var...