Given that my internal format is linear light, I'd like to just ignore
gamma issues, and was hoping a generic image library like OIIO would
handle everything behind my back.
I was vaguely assuming that if I used floating-point values with
{read,write}_scanline, that they would represent linear values (in the
appropriate color space, e.g. for jpeg, it would be sRGB without gamma
correction).
However after some experimentation, it seems this isn't the case, and
I suppose that makes some sense for consistency reasons -- UINT8
values really need to be gamma corrected, and it might be confusing if
{read,write}_scanline used a different interpretation for FLOAT
values.
So I guess I need to do gamma correction myself. [Ok, not so hard, I
do that already when not using OIIO.]
But as I obviously want to keep things as generic as possible, and
avoid special handling of specific image types, how should I find the
gamma value to use for gamma correction? I certainly want to use
gamma correction for most 8-bit formats, because not doing so (even
when the format makes it possible) often results in worse image
quality.
The OIIO docs dont' seem to suggest a simple strategy that works well
for all formats.
Idea:
1) Set the "oiio:ColorSpace" attribute to "Linear".
This seems simple to use, and it sounds like it will work OK for
formats like JPEG with a fixed gamma correction, because OIIO
will then do the proper gamma correction itself.
But it also appears that it will do the wrong thing for formats
like PNG which have a user-definable gamma correction, but are
still only 8-bit formats -- then I'll get quality impacts from
using linear values.
2) Retrieve the format's gamma correction value by getting the
"oiio:Gamma" attribute and doing the gamma correction myself.
Not too difficult, but if I'm interpreting the docs correctly,
this attribute is only valid when oiio:ColorSpace is
"GammaCorrected."
Thus it seems I'd have to look at oiio:ColorSpace and do specific
handling for every value of that. However, maybe it's necessary
to do this anyway, for color-space conversion correctly.
In practice, it looks like I could get it "mostly" right by
doing something like
"if (oiio:ColorSpace == "Linear") gamma = 1; else gamma = 2.2;"
... ><
Any suggestions for how one is _supposed_ to do this stuff?
Thanks,
-Miles
--
「寒いね」と話しかければ「寒いね」と答える人のいるあったかさ [俵万智]
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org