openexr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Openexr-devel] newbie questions: alpha-only files and linear conver


From: Paul Schneider
Subject: Re: [Openexr-devel] newbie questions: alpha-only files and linear conversion on save
Date: Thu, 20 Jan 2005 12:47:50 -0800


Also, don't forget that, according to the EXR spec, the RGB channels in an EXR are premultiplied by the alpha channel (if one exists), and this multiplication happened on linear RGB values. If you're going to do image processing on 8-bit color channels, you'll probably be gamma-correcting them and then operating on the gamma-corrected pixels. If you're going to do this, you'll want to disassociate the alpha from the color channels first (i.e. unmult them). This is what the Photoshop plugin does.

So, lets say your application produces an 8-bit RGBA premultiplied color image, where the RGB channels are gamma corrected and the alpha channel is not. If you want to save this buffer to an EXR, you'll need to:

1) unmult the image
2) linearize the color channels
3) premultiply the linearized color channels with the alpha channel
4) save those values to the EXR

You'd want to promote your buffer to half or float before doing any of this, so as not to lose data when linearizing. If your application produces a disassociated 8-bit RGBA image (aka straight, unmatted, etc), you'd do the same thing, but skip step 1. To read an EXR into such an 8-bit pipeline, reverse the steps.

For an alpha-only file, I would expect the alpha to already be linear, but as Florian says, it depends on where you got that channel from. Generally, alpha channels are linear, and since color fidelity and high dynamic range aren't (usually) issues, 8 bits are often enough.

- Paul


On Jan 20, 2005, at 12:04 PM, Florian Kainz wrote:

1) Using the RGBA-only interface, one way to write an alpha-only
   image is to open the file like this:

        RgbaOutputFile file (fileName, width, height, WRITE_A);

   With the general (arbitrary set of channels) interface, you can
   open an alpha-only file like this:

        Header header (width, height);
        header.channels().insert ("A", Channel (HALF));
        OutputFile file (fileName, header);

2) 8-bit (0-255) pixel data are typically not linear in the sense
   that the amount of light represented by the pixel is proportional
   to the number stored in the pixel.  8-bit pixel data are usually
   gamma-corrected; the amount of light represented by  a pixel with
   value v is roughly proportional to pow(v,gamma), where gamma is
   about 2.2.  (For details see Charle's Poynton's Gamma FAQ at
   http://www.poynton.com/GammaFAQ.html.)

   OpenEXR expects pixel data to be linear.  In order to convert
   8-bit pixels to OpenEXR's "half" you should linearize the data:

        half h = pow (v, 1/gamma) / 255.0;

   Note that this may apply only to RGB data.  In many file formats
   alpha is linear.  The opacity represented by the alpha channel
   is proportional to the 8-bit value stored in the pixel.


Paul Miller wrote:
Hi guys. I'm adding EXR support to our up-coming cross-platform rotoscoping system (Silhouette Roto).
I have two questions:
1) what is the proper way to set up the header for an "alpha-only" image? 2) when saving generic linear color data (ie. 0-255), is it sufficient to just normalize to 0-1 and stuff the components into the output half types? This seems to work ok when reading the image back in, as long as I adjust the gamma to 1.0. If I should apply the output gamma correction, can someone post a code snippet?
Thanks!
_______________________________________________
Openexr-devel mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/openexr-devel





_______________________________________________
Openexr-devel mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/openexr-devel





reply via email to

[Prev in Thread] Current Thread [Next in Thread]