How can I get an "average" of several images?
January 22, 2008 10:57 AM   Subscribe

How can I generate a "visual average" from a group of digital images?

A few years ago, I saw a BoingBoing post in which a guy had taken the pixel means of Playboy centerfolds for several decades. I'd like to use the same technique and am wondering if there's any off-the-shelf (preferably free) stuff that can do that.
posted by k7lim to Computers & Internet (5 answers total) 14 users marked this as a favorite
 
It's a one-step job with ImageMagick. Say you have a bunch of .png files in a directory.

convert -average *.png output.png

and you're done. The source files do need to be cropped so they're all the same size first.
posted by Wolfdog at 11:20 AM on January 22, 2008 [1 favorite]


This is fairly common (if not standard procedure) in Astrophotography. It's easily done in photoshop, and I imagine that it could be done in The Gimp as well.

For basic averaging, the first image remains as-is. The second image is layered on top, with an opacity of 50%. The third image gets an opacity of 33%. Continue for n images, giving each image an opacity of 1/x, where x= the position of the image in the stack.

I also noticed Salavon's work, and I tried to replicate it with a large stack of one type of image. I had about 20 layers, and it didn't look so hot - you might want to start out with more than that.

I imagine that it also wouldn't be that hard to write a script that analyzes the value of each pixel of all your images, and averages, and then writes the file, but I don't know that much about the individual image formats. I do remember there being linux-based command line software out there for Astrophotography image stacking, but I could never get it to work. If the photoshop/gimp route doesn't work for you, some googleing of "Astrophotography image stacking" should do you good.

On preview - Oh damn! Imagemagick. That would certainly do the trick, as long as they're all the same size. Having dealt with Imagemagick, though, I'd say that the photoshop/gimp process would be a bit more user-friendly.

posted by god hates math at 11:24 AM on January 22, 2008


If you want to do it by hand in photoshop, simply combine the first 2 at %50. Add the 3rd image at %33 percent, to that add the 4th at %25 and so on, adding the next picture as a percentage of 1/(the number of pictures used so far)
posted by StickyCarpet at 12:10 PM on January 22, 2008


um, or what that other guy said. But while I'm here again lets note that if you have 8 bit image components and, say 500 pictures, those last ones will round off to zero impact. So the best thing would add them all into a floating point of deeper bit representation, then average down in one shot.
posted by StickyCarpet at 12:18 PM on January 22, 2008


This fpp a few years back about a guy combining flickr images links to code that does this as well
posted by uandt at 2:29 PM on January 22, 2008


« Older Help me not get screwed by adding my house to the...   |   Please help me find a temporary bike rack for my... Newer »
This thread is closed to new comments.