short pixel sorting tutorial


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]:
<matplotlib.image.AxesImage at 0x7fabc11a0090>

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]:
<matplotlib.image.AxesImage at 0x7fabacc1ba50>

In [8]:
# save the ouput
sorted_island.save("../images/island_sorted_once.jpg")