-
Simeis 147: Pixel sorting algorithm comparison.
Kim Asendorf recently released his pixel sorting code. This was incredibly exciting for me because his images were the inspiration for my own venture down the pixel sorting road.
I decided to run an image of Simeis 147 (a supernova remnant) through both pieces of code to compare the outputs and highlight the differences and similarities between them. The output from my code is on top, Kim’s is on the bottom.
The code that I wrote only sorts in one direction at a time, right to left, from bright to dark. If I want the lines to appear vertically I have to feed the image into the algorithm rotated 90degrees. Kim’s will sort both vertically and horizontally at the same time, but for reasons that I don’t yet understand, the horizontal sorts are more prominent.
My code also runs on whats known as the quick sort algorithm. When I want to move certain pixels, I tell my code to grab a range of values determined by brightness, rgb, saturation, or hue and plug them into the quick sort. Quick sort divides up the array into tiny pieces so that the computer can manage them more efficiently. This is very important. Even with an image that is only 1280x850 pixels, that ends up being over a million individual pixels to rearrange. The image I sorted for the File Arts was roughly 7000x3000 pixels, which ends up at a staggering 21 million.
As far as I can tell, Kim’s is running on a sorting method that he constructed himself.
If I understand it right, it will sort from the first not-black value if finds in a row or column until it reaches a user-set black value. Then it moves on in the same row/column to find a value that is less than a user-set brightness value, and sort that pixel until it encounters the threshold. Finally it will search for the first not-white value and sort that until it reaches the white value set by the user.
I tried to grab a set of similar values using both pieces of code; I think the results are remarkably similar. It’s also interesting to see how two different approaches can yield similar yet minutely different outcomes. Isn’t code great?!
If you’d like to see a copy of my code and read a bit more about my process, it’s now available (along with the aforementioned 21million pixel image) for just $5 over at The File Arts. http://www.thefilearts.com
Kim Asendorf’s code can be found here
http://kimasendorf.tumblr.com/post/32936480093/processing-source-code