Gamma

More precisely - this is a “gamma encoding” that is originally used to correct for the old-school CRT-type monitors' \(x^{2.2}\) voltage correction. Read more details on Wikipedia.

Gamma encoding is calculated as a power function, where each pixel's \(L\) component (in HSL color space) is corrected.

For now we are using a simplified single-curve method which will eventually be replaced with a more sophisticated multi-point curve that would allow a user to specify a curve using up to \(N\) knee points (at which point it will no longer be proper to call this “gamma” but rather something else).

Implementation-wise there's nothing special about this (assuming \(L \in [0..1]\) and \(\_gamma \leq 1\)):

// pseudo-code
void gamma(/*array of pixels*/image, double _gamma){
  for(const & pixel: image){
    pixel.luma = power(pixel.luma, _gamma);
  }
}