Re: [Oiio-dev] oiio::UnassociatedAlpha question

2017-08-10 Thread Akihiro Yamasaki
Thank you for the answer. I understand the attribute means and OIIO design.

For PSD, I think there is a bug the last layer's ImageSpec only has
oiio::UnassociatedAlpha attribute. All layer's ImageSpec should have the
attribute.

For SGI, we need to process as unassociated alpha because of the
compatibility. (e.g. Photoshop SGI plug-in saves unassocia
ted alpha) It would be helpful if I could know the the correct alpha type
that I actually read: associated, unassociated, UNKNOWN.

Akihiro

2017年8月10日(木) 16:35 Larry Gritz :

> 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 convention.
>
> 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 
> 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
> l...@larrygritz.com
>
>
>
>
> ___
> Oiio-dev mailing list
> Oiio-dev@lists.openimageio.org
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
>
___
Oiio-dev mailing list
Oiio-dev@lists.openimageio.org
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org


Re: [Oiio-dev] oiio::UnassociatedAlpha question

2017-08-10 Thread Larry Gritz
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 
convention.

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  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
l...@larrygritz.com




___
Oiio-dev mailing list
Oiio-dev@lists.openimageio.org
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org