pixelsort.py
if you’ve been paying attention to the image glitching scene, you may have noticed a particular effect popping up known as pixelsorting. i had a lot of fun trying my hand at it and making GIFs from various NASA images.
in pseudocode, the technique for sorting a single frame looks like:
for column in image:
for pixel in column:
if pixel < BLACK_THRESHOLD or pixel > WHITE_THRESHOLD:
if not starting_pixel:
starting_pixel = pixel
else:
ending_pixel = pixel
sort_pixels_between(starting_pixel, ending_pixel)
I thought the effect was interesting, but I also wanted to create animated GIFs, so I added the ability to generate intermediate frames: the idea is to show the progression of pixels as they get sorted - creating a sort of drooping effect.