Copypasted from google cache.
Add Alpha To Shatter Image
While editing one of the cosmosphere movies, we wanted to extract a "window shattering" effect from the original movie, and superimpose that over a new movie.
However, that proved problematic as the shatter image didn't have alpha, and it was complex to edit in Photoshop. Wizzardx wrote a quick Python utility to help add alpha by analysing each pixels brightness.
From the original post, here here:
A bit more complicated than changing black pixels alpha to 0 (that looked really bad). Basically taking all the dark pixels (with R,G, and B below 100), and using the average of their R,G,and B values for alpha.
Here's the script so you can try it yourself. It should be easy to tweak so you can try different things:
1) Install python and pygame (see my previous readme)
2) Copy your png files to a subdirectory (under script location) called "input"
3) Create a directory called "output"
4) Run the script
The script will create a series of TGA files with alpha (pygame limitation), but you can convert those to PNG easily.