Photo colour sorting

I came across a brilliant thread on stack exchange that tasked people with creating an image containing every 15-bit RGB colour a single time. The clear winner was József Fejes, whose beautifully simple algorithm for placing coloured pixels according to their closest neighbours in RGB space produces some fantastic images. It’s amazing that such a simple premise, and algorithm to solve the problem, creates such intricate and interesting images. The full blog post describing the method and variations is fantastic by the way.

I really liked the concept, and given my recent explorations of manipulating photographs to give more abstract representations of their structures and colours, I wanted to see what the output would look like when the colour sorting algorithm was applied to photos. I ported József Fejes’ original code to Processing and tried it out on a few images (the code is on Github, but be warned, it’s a mess!).

sortRGB28002The path ahead

Small changes like shuffling or calculating the difference between colours in HSV rather than RGB space, produces very different results. The images you can make vary from cloud-like to cartoonish depending on the variation on starting conditions and algorithm.

sortRGB194841DSC03513 sortRGB1777095sortRGB155465SONY DSC sortRGB25068

Watching them grow is also fascinating, but so slow! I’m sure there are many things I could do to speed it up, if I thought about it a bit more. There are definitely many possibilities of generating interesting stuff with spatially biasing the pixel placement, changing the distance metric etc, worth more exploration.


Leave a Reply

Your email address will not be published. Required fields are marked *