POV-Ray : Newsgroups : povray.pov4.discussion.general : Gamma correction of input colours/image files : Re: Gamma correction of input colours/image files Server Time
3 May 2024 02:27:00 EDT (-0400)
  Re: Gamma correction of input colours/image files  
From: Kyle
Date: 10 Oct 2008 11:12:09
Message: <qdrue4p555v8qjoi9503k39lf44g2ucja4@4ax.com>
On Fri, 10 Oct 2008 16:17:02 +0200, "scott" <sco### [at] scottcom> wrote:

>Because you are used to how POV handles colours :-)  But seriously, in the 
>top row, the *colours* (not brightness) are actually different from what you 
>specified in the SDL.  It is easiest to see this with the orange ball, 
>anybody trying to make some promotional material where the colours need to 
>be accurate for a certain brand (eg the Sony Ericsson "orange") would likely 
>get the top row thrown back at them for being the wrong colour.  The bottom 
>row preserves the correct colour.
>
>The reason is that for "colours" (where RGB are not equal), gamma will 
>modify the brightness of each channel a different amount, so you are 
>actually changing the colour that you see, not just the brightness.  Your 
>eye is very sensitive to changes in colour, even when the brightness is 
>different.
>

This can be demonstrated in your favorite image editor, GIMP in my case.  Open up two
copies of the image, then adjust the gamma of one copy by 0.45, which is 1/2.2 gamma. 
The colors of the top row
of the gamma adjusted image will closely match the center row of the original image.

>The brightness is easily controlled by the diffuse value in the finish 
>statement, or by cranking up the light colour.  Maybe I should have rendered 
>with more brightness to avoid the confusion between change in brightness and 
>change of colour?

You can do the same experiment above, but instead try and adjust the brightness and
contrast.  The colors will never match.  

The issue is definitely related to how POV-Ray handles gamma in pigments.  For solid
pigments, the gamma-adjusted levels can be easily calculated manually.  For image
pigments, a macro can be used...

// Macro to adjust APGPig pigment by APGGam gamma value
// Adapted from the CIE_Imagemap macro by Jaime Vives Piqueres
#macro AdjustPigmentGamma(APGPig, APGGam)
  #local APGfn = function { pigment { APGPig } }
  pigment {
    average
    pigment_map {
      [function { pow(APGfn(x,y,z).red, APGGam) }   color_map { [0 rgb 0][1 rgb
<3,0,0>] } ]
      [function { pow(APGfn(x,y,z).green, APGGam) } color_map { [0 rgb 0][1 rgb
<0,3,0>] } ]
      [function { pow(APGfn(x,y,z).blue, APGGam) }  color_map { [0 rgb 0][1 rgb
<0,0,3>] } ]
    }
  }
#end


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.