What the attribute means is:  If the image file has unassociated alpha, KEEP it 
unassociated (preserving the original data values from the file), rather than 
the usual practice of converting to associated alpha, as is the normal OIIO 

It does not convert an associated alpha file into unassociated alpha. As you 
noted, if you want to force unassociated alpha from an associated alpha file, 
you'll need to do the math to deassociate it yourself.

You mentioned psd and sgi. I think that for PSD, the alpha is ALWAYS 
unassociated, so using this attribute ought to keep it from being 
auto-converted to associated. (Unless you are claiming that there is a bug.) 
The sgi format spec doesn't specify anything about this issue, so we assume 
that the data are always associated alpha (that should be the default 
assumption, except for the few misguided formats that say they store 
unassociated), and therefore the sgi reader doesn't pay any attention to this 
attribute because there's no behavior change expected.

I think it's important to point out that there is a reason why associated alpha 
is the default and is preferred -- there are useful RGBA values that can be 
represented as associated but cannot be represented at all as unassociated. So 
converting associated alpha to unassociated alpha may involve irretrievable 
data loss.

> On Aug 10, 2017, at 12:02 AM, Akihiro Yamasaki <aki.yamas...@gmail.com> wrote:
> Hi there,
> I'm running into the alpha channel issue. I want to read an image as 
> unassociated alpha. So I used following code:
> ImageSpec config;
> config.attribute("oiio:UnassociatedAlpha", 1);
> ImageInput *image_in = ImageInput::open(filename, &config);
> image_in->read_image(...);
> But I noticed that some files are read as associated alpha image. I looked 
> into it and found the following solution:
> // After above code
> if (image_in->spec().get_int_attribute("oiio:UnassociatedAlpha") != 1) {
>   // convert associated alpha image to unassociated alpha
>   deassociateAlpha(...);
> }
> Now some format (associated alpha tiff) works correctly, but some format 
> (psd, sgi) is still wrong. I expected the ImageSpec always has the 
> "oiio::UnassociatedAlpha" attribute if read_image returns unassociated alpha 
> image.
> Is it an issue of psd/sgi input? Or is there any misunderstanding?
> Thanks,
> Akihiro Yamasaki
> _______________________________________________
> Oiio-dev mailing list
> Oiio-dev@lists.openimageio.org
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Larry Gritz

Oiio-dev mailing list

Reply via email to