Dim the Lights

We all know that the real world is made of polygons. With TriPics, you can reveal the triangles which are hidden in all your pictures.

After having read a tutorial on *"How to give a picture a low poly style with your favourite image editor"*, I was asking myself if it was possible to do it with a piece of software.

When asking myself this kind of question, I have the bad habit of crafting my own answer before searching for an existing one.

This work was really interesting from an algorithm point of view, and I think it can become even better in a near future.

The principle here is quite easy:

- I decompose the picture in three main triangles and add them to a queue.
- I take the first triangle and check if its size or its variance are meeting the required criteria.
- If yes, I draw this triangle with its median colour.
- If not, I divide it in three sets of two hypothetical triangles using the medians of the parent one.
- For each triangle, I calculate the statistical variance of the colour components of each pixel inside the triangle.
- I choose the pair of triangles that shows the lowest variance
*(i.e. closest pixel colour inside the triangle)*, and add it to the queue.

The process is working but it has several drawbacks.

The main one is the loss of information. If a relatively big triangle gets a value under the threshold of variance, the process stops and we possibly lose details of the picture.

Another problem is the form of the resulting triangles.
Quite often, triangles becomes really long and thin, which is not the kind of aesthetic result I was looking for.

A potential solution I'm working on is the decomposition of the picture using the Delaunay triangulation.