Watercolors

Moça do corpo dourado
Do Sol de Ipanema
O seu balançado
É mais que um poema
(Garota de Ipanema, João Gilberto)

Sometimes I think about the reasons why I spend so many time doing experiments and writing my discoveries in a blog. Even although the main reason to start this blog was some kind of vanity, today I have pretty clear why I still keep writing it: to keep my mind tuned. I really enjoy looking for ideas, learning new algorithms, figuring out the way to translate them into code and trying to discover new territories going a step further. I cannot imagine my life without coding. Many good times in the last years have been in front of my laptop listening music and drinking a beer. In these strange times, confined at house, coding has became in something more important. It keeps me ahead from the sad news and moves my mind to places where everything is quiet, friendly and perfect. Blogging is my therapy, my mindfulness.

This post is inspired in this post from Softology, an amazing blog I recommend you to read. In it, you can find a description of the stepping stone cellular automaton as well as a appealing collection of images generated using this technique. I modified the original algorithm described in the post to create images like these, which remind me a watercolor painting:

I begin with a 400 x 400 null matrix. After that, I choose a number of random pixels that will act as centers of circles. Around them I substitute the initial zeros by numbers drawned from a normal distribution which mean depends on the distance of pixels to the center. The next step is to apply the stepping stone algorithm. For each pixel, I substitute its value by a weighted average of itself and the value of some of its neighbors, choosen randomly. I always mix values of the pixels. The original algorithm, as described in the Softology’s blog, performs these mixings randomly. Another difference is that I mix values intead interchanging them, as the original algorithm does. Once I repeat this process a number of times, I pick a nice palette from COLOURLovers and turn values of pixels into colors with ggplot:

The code is here. Let me know if you do something interesting with it. Turning numbers into bright colors: I cannot imagine a better way to spend some hours in these shadowy times.

7 thoughts on “Watercolors

  1. Very nice! I follow your GitHub account and it’s always a nice feeling when a new repo of yours comes up when I log in. Good on you to use your confinement time productively. Cheers from the UK.

  2. Hi! Thanks for sharing your code. It’s nice to look at something that isn’t to do with covid-19 for a few minutes. Cheers – Martin

  3. This is so beautiful. Your code and blog provides a sort of course and knowledge windw into the making of these algorithms and is very very awe stricking and also inspiring. I’m so grateful to you. Also this post in particular is even more amazing because it links cellular automata to the universe’s astronimical structure, which is a thing i think is the most beautiful window in science. I was working on something and this helped me and also inspired me to further the relatition between neuronal networking and cosmos structure. Thanks!

Leave a Reply

Your email address will not be published.