the original pixel sorting algorithm is by Kim Asendorf
http://prostheticknowledge.tumblr.com/post/32963838252/kim-asendorfs-pixel-sorting-code-is-now
In [1]:
from PIL import Image # so we can work with images
In [2]:
from pixel_sorting import sort_image # so we can sort the pixels of the image
In [3]:
from matplotlib import pyplot # so we can see the resulting images
In [4]:
# we load the image we'll be working with
island = Image.open("../images/island.jpg")
In [5]:
# let's see what it looks like
pyplot.imshow(island)
Out[5]:
In [6]:
# sort the image, this might take a while (< 10 sec usually)
sorted_island = sort_image(island, 0, 0)
In [7]:
# let's see what it looks like
pyplot.imshow(sorted_island)
Out[7]:
In [8]:
# save the ouput
sorted_island.save("../images/island_sorted_once.jpg")