Computer generated art

I woke up yesterday with a simple idea for generating a picture based on an input string. I don’t exactly know where the idea came from, but i think i’ve been influenced by Nick Huggins, whose abstract work i adore, and also in a way by QR codes. I’m not a particularly artistic person, but i figured i could come up with an algorithm and let the computer do the creative bit for me! :)

So i installed the open source tools ImageMagick and RMagick, learned a bit about the RVG library, and set about trying some ideas. I fiddled and tweaked the algorithm until it seemed to consistently output something that was reasonably pleasant. Here is the picture for my name, and for my twitter id.

aimee @sermoa

Having tried random numbers and obvious inputs like my name, i searched for other input sources. Being interested in community generated content, i wrote a script to fetch the current top twitter trends. Here are the results.

Kim Hee Chul Solomon Burke Steamed Bun #thingsyoushouldntsay HEEBUM
#badsongsinjail Limera1n Aiden #bsr_tousounow One Direction

As you can see, some come out better than others. I’m adding the input string mostly for debugging purposes so that i can see how the image was seeded. When i get one that i like, i can increase the blur and remove the input string. For example, i really like the images produced by “Kim Hee Chul” and “#bsr_tousounow”, so let’s try with a bit more blur.

Kim Hee Chul (with more blur) #bsr_tousounow

Nice, hey?! Not sure they’re ready for a gallery just yet, but certainly an interesting experiment.

Everything in the picture is generated from the input string: the size, colour, number of boxes, box sizes, opacity, border style. It is extremely unlikely that any two input strings would ever generate the same picture. However, the algorithm is not random. Given an input string, you’ll always get the same picture, though i may choose to do some post-processing on it (such as blur, frame, lighten or darken).

In the interests of sharing knowledge here is the main structure of my generator, but the really creative part is in how it comes up with the numbers, which is going to remain a secret, sorry!

I am willing to generate images for anybody who asks nicely! :)

Advertisements

The Wessex Wyvern as SVG

I needed to find a good quality image of a Wyvern, the symbol of Wessex, ancient kingdom of the West Saxons. The best i could find was the image on the Wessex Flag, below, but it is poor quality and can’t be scaled up. So i had to learn a bit about path tracing and scalable vector graphics.

Wessex Wyvern (low quality)

Wessex Flag by Chrys Fear, found at fotw.net/flags/gb-wessx.html

I used a combination of the free open source graphics tools GIMP, Inkscape and Potrace to trace the shape into vector format. Even at the same size, it’s already much better, saved here in PNG format:

Wessex Wyvern (higher quality)

The SVG is infinitely scalable and you can download it here: wessex-wyvern.svg

Here you can see the quality improvement:

Before and after - close up

Here is a close up of the eye, which took a bit of work to get the paths just right:

Close up of the Wyvern's eye

I needed the Wyvern to form part of the Bi Wessex flag. Here is what we are affectionately calling the Bivern!

The Bivern (Bi Wessex Wyvern)

The Bi Wessex flag is also available as SVG, should you want it: bi-wessex-flag.svg

If you need to improve the quality of an image, i hope you will feel encouraged that it is possible, with a little bit of effort and experimentation.

the best free entertainment i’ve seen all year

This last week i’ve been enjoying watching A Very Potter Musical on youtube. It’s a most hilarious Harry Potter parody with fantastic acting and delightfully catchy songs!

The star of the show has to be Lauren Lopez who plays Draco Malfoy and spends most of the time rolling around seductively on the floor/bench/harry/hermione! Lauren’s sense of comic timing is incredible, and the voice and facial expressions are just adorable!

Lauren Lopez as Draco Malfoy

Voldemort and Quirrel are beautifully played with some very touching moments together. Snape is hilarious, like all the characters, much exaggerated!

I think the best songs are near the end. “Not Alone” (Act 2 Scene 5) is a beautifully composed piece of music, and “Voldemort Is Goin’ Down” (Act 2 Scene 8) is magnificently performed by the cast.

I’ve enjoyed it so much that i’m making myself a dvd to take to show friends and family. I love it that the whole thing is freely available. By the fans, for the fans, and yep, the fans are loving it!

I also love how linux gives me free tools to be able to create a dvd. This morning i did not know how to do it, but using todisc and tovid i’ve been able to combine all the scenes into a sequence, with a menu. I used mplayer to extract the audio of one song, and audacity to split out the song that i wanted to use as an introduction when the menu is shown. I used kino to look at the frames one by one and export a frame to use as the background for the menu. I used the gimp to darken the image and reduce the contrast.

The menu for my dvd is hopefully going to look something like this:

A Very Potter Musical dvd menu

I’ll update again if it works! Currently it is encoding each of the scenes into dvd format, which seems to take a very long time … and creates files 5 times bigger than the originals!

Update: it worked!! From youtube to my television!!

A Very Potter Musical

Potter Musical on my television!

A Very Potter Musical

Thank you to StarKidPotter, youtube, keepvid.com and to free open source software and the ubuntu community! Now i can take A Very Potter Musical with me to show anyone who has a dvd player! :D

GeoURL WordPress plugin now available!

My plugin got approved, and it is available for download here: GeoURL WordPress plugin.

Apparently it has had 18 downloads already. Okay, one of them was me, just testing it zipped up correctly, but even so … have i helped 17 blogs to become GeoURL enabled?! :)

I wish there was a way to tell who has installed it … would be lovely to see it in action for other people!

In other news, Twitter has been so thrilled by the UK snow that the hashtag #uksnow has been at the top of the trending topics all afternoon! It’s quite fun to watch twitterfall.com/#uksnow and see the tweets fly in from around the UK. People are giving marks out of ten for their area, and posting pictures of good snow scenes! :)

We don’t get good snow very often in the UK, and we are predicted 15cm by the morning! That will require wellies to walk to work!! It’s the heaviest snowfall in 6 years apparently, so you can understand why we’re all so excited!

Why Git is better

See this site: Why Git is better than ‘X’. It’s well worth a good read. It explains all the best things about Git, and compares other software configuration management systems to see how they measure up.

But that’s not the reason i’m posting. It’s more exciting than that! See those Expand all | Collapse all links? … i did that! :) The site source code is available on GitHub. I forked it, made the change, submitted a pull request. 14 minutes later it was deployed live.

Other people have been translating the site into different languages. Git and GitHub are wonderful things!

In a similar way, we had open source dinner tonight. I took Saturday’s leftover stew, forked it, added matzo dumplings, submitted a pull request, which was accepted! It was lovely dinner! :D

Update: and now i see even the US government is going open source! Everything on change.gov is now freely available for the world to copy, change and redistribute, provided they attribute the source. Nice one, Obama! :) In fact, i’m going to make use of that creative commons licence right now:

President-elect Obama has championed the creation of a more open, transparent, and participatory government. To that end, Change.gov adopted a new copyright policy this weekend. In an effort to create a vibrant and open public conversation about the Obama-Biden Transition Project, all website content now falls under the Creative Commons Attribution 3.0 License.

Towards a 21st century government on change.gov/newsroom

LilyPond Love

Tonight i decided to write out “Mamma Mia” for my cousin whom i teach piano. I got out my pad of music lines, but hadn’t even set pen to paper before thinking, “I hate doing this! I wonder if there’s an open-source music notation package …”

One quick search later and i remembered LilyPond! A friend showed me this years ago, and i was really intrigued by it. As a programmer, this is very satisfying to me. You write your music as a kind of code, ‘compile’ it, and it outputs PDF, PS and, if you want it, a MIDI file.

Mamma Mia LilyPond code     Mamma Mia PDF output

We used to do this on Windows, with Cygwin. It is very pleasing to use it on its intended operating system now! :) It was easy to input, and i do love the pure geekiness of the notation! :D