Posts Tagged image processing

Fun with Python and image processing

Today I got to work with something I’ve been meaning to for a while – Image processing with Python, in particular the PIL/Pillow library. (Pillow’s a forked, more up to date version of PIL, and it’s in PyPi.)

So about 30 minutes after planning and googling and reading the docs, I have a first version that takes a bunch of images, all the same size (it doesn’t check though), and randomises the list, then cuts vertical stripes of equal sizes out of them, and assembles it into something like this:

This is made up of stripes of 120 photos

Then I moved into variations – swapping the red and blue channels with this code. (Result)

Or how about staggering the rgb channels so each stripe is built with the red channel from the first image, green from the second, and blue from the third? (Again, oddly funky result.)

And finally, just combining channels from three different images wholesale, without the vertical striping? (The result looks pretty interesting with the pink glow.)

What will I do next? Probably look at combining different sized images – have some way of calculating the height & width of images and cropping random portions out of them such that they can be pieced together. Not like the random shapes of a jigsaw puzzle (PIL only supports box shapes), but a collage almost.

I’m still getting over the ‘this is awesome’ and wondering how the random number generators will affect the outcome of the image though.

, ,

No Comments