This is more complicated than you think.  

Do you really need to convert to HSL, manipulate, then convert back to RGB? Or 
is enough to just be able to compute the luminance for each pixel and then do 
scaling based on that?  (Am I wrong to think that once you know the scaling 
factor, you can apply that to each of the original channels independently?)

The formula for luminance depends on what color space you think the RGB 
represents.  If you think you have linear RGB in Rec709 space (not a bad 
default assumption), then I believe the formula is that

        L = 0.212507 * R +  0.71535 * G +  0.0721427 * B

But if you really wanted to be pedantic about it, you'd want this adjusted for 
other color systems.

(Jeremy, if OCIO doesn't provide basic color utilities, such as conversion 
between RGB and other handy non-spectral color spaces, or calculating luminance 
in a color-aware way, perhaps it should? Or is that intentionally beyond the 
scope of OCIO's design?)




On Jun 27, 2012, at 3:40 AM, Stefan Stavrev wrote:

> I need to go RGB <-> HSI, internally only for the algorithms.
> 
> I also found this in the "enhancment" list for OIIO:
> 
> https://github.com/OpenImageIO/oiio/issues/193
> 
> Jeremy, maybe if you have such optimized conversion functions already,
> I could use them?
> 
> Thanks
> 

--
Larry Gritz
l...@larrygritz.com


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

Reply via email to