Calculate gamma correction values from input, output, and gamma, or convert sRGB encoded color to linear light with 0–1 and 0–255 results.
Gamma Correction Formula
In the “Pure Gamma” (power-law) model, gamma decoding (linearization) and gamma encoding are related by the following equations.
\begin{aligned}
O &= I^{\gamma} \\
I &= O^{1/\gamma}
\end{aligned}Variables:
- O is the linear-light (decoded) output value (0 to 1)
- I is the gamma-encoded (nonlinear) input value (0 to 1)
- γ (gamma) is the gamma exponent (γ > 0)
To decode/linearize a gamma-encoded value, raise it to the power of γ (O = I^γ). To encode a linear-light value, raise it to the power of 1/γ (I = O^(1/γ)). Note: real standards such as sRGB are not a pure power law across the whole range; use the “sRGB Transfer” tab for the standard piecewise sRGB conversion.
What is Gamma Correction?
Gamma correction is a nonlinear operation used to encode or decode luminance (or tristimulus) values in video and still-image systems. In practice, it is used to convert between linear light (where values are proportional to physical light intensity) and a nonlinear signal representation designed to match display behavior and human visual perception. Depending on direction, gamma correction may mean encoding (applying a 1/γ power) or decoding/linearization (applying a γ power).
How to Calculate Gamma Correction?
The following steps outline how to calculate a gamma conversion using the pure power-law model.
- Decide whether you are decoding/linearizing (O = I^γ) or encoding (I = O^(1/γ)).
- Determine the normalized value(s) (I and/or O), each between 0 and 1.
- Determine the gamma exponent (γ), which should be greater than 0.
- Use the appropriate formula to calculate the unknown value.
- Enter the known values into the calculator above to confirm your result.
Example Problem :
Use the following variables as an example problem to test your knowledge.
Input value (I) = 0.5
Gamma (γ) = 2.2
Using the decoding/linearization formula O = I^γ, the output value (O) is calculated as:
O = 0.5^2.2 ≈ 0.218
