[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Openexr-user] retrieving light informations from an exr image
From: |
Florian Kainz |
Subject: |
Re: [Openexr-user] retrieving light informations from an exr image |
Date: |
Tue, 02 Mar 2004 21:18:39 -0800 |
Enrico Borrione wrote:
>
> hi all,
> new mail, old problems...
> good enough my cubemap is working... just it is 8 bit converted. I think
> it isn't possible to take advantage of 16 bit framebuffers 4 the
> visualization part yet.
> Anyway, i'd like to extract the actual light infos from the image
> itself... somehow. I think my target is to get the Y part out of the rgb
> half values. Is it right? the formula is Y=R*w+G*w+B*w?? Y is the light
> intensity radiated from that direction?
>
> Difficult subject for my limited brain :)
>
> thx all!!
>
A pixel's luminance, Y, is a weighted sum of the pixel's R, G and B
values. The proper weighting factors can be derived from the
chromaticities of R, G, B and white.
Given an OpenEXR file's "chromaticities" and "whiteLuminance" attributes,
the code snippet below computes a pixel's absolute luminance, in candelas
per square meter. (If one or both of the attributes are missing, the code
falls back to reasonable default values.)
RgbaInputFile in (...)
Chromaticities cr;
float wl = 1;
if (hasChromaticities (in.header()))
cr = chromaticities (in.header());
if (hasWhiteLuminance (in.header()))
wl = whiteLuminance (in.header());
M44f m = RGBtoXYZ (cr, wl);
Rgba &pixel = ...
float Y = pixel.r * m[0][1] + pixel.g * m[1][1] + pixel.b * m[2][1];
(Note that "luminance" is not the same as "intensity". For definitions
of the terms, see http://www.schorsch.com/kbase/glossary/luminance.html,
http://www.schorsch.com/kbase/glossary/luminous_intensity.html, and
http://www.schorsch.com/kbase/glossary/radiant_intensity.html.)