RE: Re: associated alpha

Bob Friesenhahn <[email protected]> Fri, 11 Feb 2005 08:32:19 -0600 (CST)
Newsgroups gmane.comp.video.graphicsmagick.core
Message-ID <[email protected]>
On Fri, 11 Feb 2005, davidk wrote:

> As I understand this, Photoshop transparency is managed with
> associated/premultiplied alpha. Photoshop also has a separate
> "channels" palette where you can have an unlimited number of
> masks (Red, Green, Blue, Alpha 1, Alpha 2, etc). Channels have
> many uses in Photoshop besides transparency, but if you want to
> use them to create a transparent image, here's how to do it:
>
> - double click the background layer
> - make "Layer 0" (this unlocks the backround layer)
> - use the Select->Load Selection command.
> - select an alpha Channel and check Invert.
> - go to Edit->Cut

Thanks for this useful advice.

> It seems to make sense that TIFF unassociated alphas would be be
> converted to Photoshop channels, since Photoshop channels are just
> masks (like unassociated alphas) that can be saved with an image.
>
> Now as for colormapped images (whether Photoshop, PNG, etc), they
> just aren't supposted to have associated alpha. I understand that
> files created with Imagemagick/Graphicsmagick were set incorrectly.
> Can we assume that all colormapped images with an associated alpha
> were marked that way by mistake, and just not pre-multiply?

According to the TIFF specification, colormapped images can have 
associated alpha.  This is actually quite feasable since the RGB part 
of an associated associated alpha image lookes like it is composited 
on a black background so it is easy to make it colormapped.  The alpha 
is still stored in a separate channel.  For GraphicsMagick it would be 
necessary to re-quantize the image to create the new colormap, and 
some quality would be lost.  The main problem with colormapped 
associated alpha images is that they can't really be modified without 
promoting then to something else.

> If it isn't a colormapped image, I think you're right to pre-multiply
> pixel data when saving the associated alpha type, and attempt to
> reverse as best as possible on the way in. I like this idea:
> -define tiff:alpha={associated|unassociated|undefined}
> On import, it would override the alpha typed marked in the file.
> On export, it would pre-multiply whenever marked as associated.

I have this implemented in my copy.  I also have associated alpha 
support working (as the default mode), but I would like to improve the 
implementation a bit.  The problem is that in my copy, the image is 
being altered for associated alpha while it is being saved.  This is 
allowable, and works fine for the command line utilities, but may not 
be so acceptable for API users.

Bob
======================================
Bob Friesenhahn
[email protected]
http://www.simplesystems.org/users/bfriesen


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click