Similar to how Star Wars can be enjoyed in Chronological or Release order, this post is a prequel to the original Drarwing post. When developing Drarwing, I originally started out creating a Pointillist style. When iterating and improving this algorithm, it became something much more versatile, eventually resulting in the Painting style as shown in the original post. While I think the Painting style algorithm beats the Pointillism style in many ways, I still wanted to show the Pointillist algorithm in this dedicated post.
The codebase is the same as in the original post and can be found on GitHub.
Some examples of results. All original images are from unsplash.com
Make sure to click these images to open the nicely scaling corresponding SVGs!
The Pointillism algorithm is simple. We first create a color palette from the input image by clustering the input colors and extracting a fixed number of cluster centers. We then create some variations based off of these colors. Choosing to use an RGB or HSV color space has interesting effects on the results. I prefer using the HSV color space because adding some slightly more saturated colors can really make a picture pop, and by shifting hues you can really add some crazier color variations that make a picture feel artsy and unique. Using this palette, the algorithm basically scouts our specimen for a location that should be improved next, and also picks a suitabel color. None of these decisions are direct optimizations; instead, we base everything off of probabilities based on the difference between target and source image. This allows our genetic algorithm to be a bit more unpredictable, leading to results that could be interpreted as more "creative".
The most significant drawback of the original Pointillism algorithm is that it is SLOW. As we do not vary the size of the ellipses much, it takes a huge amount of time before the backdrop of a painting has been covered, before proper refinement can begin. In this first "phase" (it is not programmed as a phase, it is just a behaviour we observe), it does not even really matter what color is chosen for an ellipse, as any color often improves the fitness score. This means that for a long time the algorithm will bascially get away with any change, until a base level of coverage is reached, and it starts to finally direct the changes more towards the target image. We could prevent this by choosing a different canvas color at the beginning, but in any case we would like the entire canvas to be covered with ellipses, and not simply retain its original even coloring. We could also decide to use a faster sampling algorithm (like Poisson disc sampling as used in Toucan) to get some initial coverage, at the risk of creating a more uniform looking distribution of ellipses. This same problem was tackled in the Painting algorithm by starting off with huge brush strokes, quickly covering a lot of area, and then scaling brush stroke size down as the fitness score increases, to allow for fine-grained refinement in the later generations of the genetic algorithm. Just to keep things simple and let the Pointillism and Painting algorithms have their own distinct looks, I decided not to backport the improvements I made for the Painting algorithm to the Pointillism algorithm. Therefore, the Pointillism algorithm is still very, very, unoptimized and slow.