[visit-developers] [NCCS-vis] PIL tool to extract alpha channel
Meredith, Jeremy S.
jsmeredith at ornl.gov
Wed Oct 1 15:48:28 EDT 2008
Ah, nice to have that encapsulated, thanks!
Just as a reminder, IIRC values with low opacity lose a lot of accuracy
when determining their original color. This typically doesn't matter
since you often want to re-composite anyway, and their low opacity means
the accuracy loss has little impact, but it's worth mentioning because
it can impact other uses.
Oak Ridge National Laboratory
> -----Original Message-----
> From: nccs-vis-bounces at email.ornl.gov [mailto:nccs-vis-
> bounces at email.ornl.gov] On Behalf Of Sean Ahern
> Sent: Wednesday, October 01, 2008 3:31 PM
> To: NCCS Vis; VisIt Developers
> Subject: [NCCS-vis] PIL tool to extract alpha channel
> There are many times where I want to get an alpha channel from an
> I'm generating in VisIt. This really isn't possible in many cases,
> since we don't keep alpha around in the frame buffer. It's especially
> difficult for really transparent volume renderings.
> However, it's possible to calculate an alpha channel by rendering an
> image twice, once with a white background and again with a black
> background. You can then do some math to calculate alpha and what the
> original R,G,B values are.
> I've created a python script using PIL that does this work. I've
> attached it here. USAGE: alpha.py whiteImage blackImage outputImage
> As an example, I've also attached some PNGs and an output PNG that
> demonstrate the script. I ran it as "alpha white.png black.png
> output.png". (Yes, I know I also changed the foreground color.
> really hurt.)
> Sean Ahern
> Oak Ridge National Laboratory
> AIM: ornlsean
More information about the visit-developers