IamIC
IamIC

Reputation: 18239

Where do all the numbers come from in the standard 2.2 gamma correction for RGB?

Here is the standard fwd Gamma 2.22 (1 / 0.45) correction formula:

for R,G,B < 0.018
R´ = 4.5 * R
G´ = 4.5 * G
B´ = 4.5 * B
for R,G,B ≥ 0.018
R´ = 1.099 * R^0.45 - 0.099
G´ = 1.099 * G^0.45 - 0.099
B´ = 1.099 * B^0.45 - 0.099

Where do the figures 0.18, 4.5, 1.099, and 0.099 come from? I specifically need to know how they are derived.

I need to know because I am writing a gamma correction function, and the simple approach of using a power and scaling, rather than the above, yields different results.

Upvotes: 1

Views: 1183

Answers (1)

St&#233;phane
St&#233;phane

Reputation: 6905

So here is how far I figured it.

The gamma correction function had to be designed with the following requirements (see this paper):

  • the voltage for 0 intensity must be 0
  • the voltage for 1 intensity must be 1
  • it must behave like a power function (exponent 1/2.22=0.45) close to intensity 1
  • it must be linear close to the origin (to reduce the effect of sensor noise at low intensity)
  • it must be continuous and continuously differentiable in [0,1]

so this problem can be solved by finding the numbers {a,b,c,x0} defining a function g:x->g(x) such as:

  • g(x) = a*x^.45+b in [x0,1]
  • g(x) = cx im [0,x0[
  • g(1) = 1
  • g(0) = 0
  • lim{x->x0-}(g) = lim{x->x0+}(g)
  • lim{x->x0-}(dg/dx) = lim{x->x0+}(dg/dx)

which yields the following equations:

  • a+b=1
  • c*x0=a*x0^.45+b
  • c=0.45*a*x0^-0.55

equivalent to:

  • a=1/(1-.55*x0^.45)
  • b=-.55*x0^.45/(1-.55*x0^.45)
  • c=.45*x0^-.55/(1-.55*x0^.45)

if you set x0 to 0.018, you get :

  • a=1.099
  • b=-.099
  • c=4.5

The remaining questions is: how did they choose x0? I could not find any justification for the 0.018 value... Or they could have started with any of the other 3 parameters (for instance, set the toe slope to 4.5, they derive a,b and x0).

Not sure this will solve your problem, anyway I hope this helps (I had fun with the math).

Upvotes: 1

Related Questions