More is less
If we do not bound the amount of polygons used, then we can use a polygon for each pixel, making it to perfectly recreate any image. This however results in a useless vector image. The image does not look better when zoomed in, and the image size is not less than that of the raster image. If we wish our polygons to capture the structure of the image, we must attempt to recreate the image with a little polygons as possible. Simpler is more.
In Vectorizer this condition is reflected in the fitness function. A solutions fitness is decreased for each polygon and each polygon point it has. Currently I decrease the fitness just a very tiny amount, which has proven effective in preventing unnessecary solution growth.
In Vectorizer this condition is reflected in the fitness function. A solutions fitness is decreased for each polygon and each polygon point it has. Currently I decrease the fitness just a very tiny amount, which has proven effective in preventing unnessecary solution growth.
Picture evaluation
The very simple vector picture evaluation algorithm that I use draws all polygons from top to bottom, and afterwards draws a black background.
Simple drawing
I have two polygon drawing algorithms. One is a very simple brute force algorithm, shown below. It uses the fact that any point that is inside the polygon has an uneven amount of polygon lines to its left and right.
Box drawing
The more advanced polygon drawing algorithm that I have uses boxes. A polygon consists of points. The first box starts at the lowest y-coordinate of those points, and ends at the second-lowest y-coordinate. A box has no left or right boundary. Each polygon line is inserted into all the boxes that it crosses. We only work with polygon that do not self-intersect, so the lines inside a box can be ordered from left to right. Drawing the polygon is done by going over all the boxes. For each box we take the first and second line, and then the third and fourth, and so on. For each pair of lines, we draw all points enclosed by those two lines and the borders of the box. The code is shown below.