Correct gamma🔗

Compresses or expands gray or RGB levels using a non-linear power-law function. In gamma expansion, the intensity level of an output pixel is generally calculated as f$ I{out} = I{in}^gamma f$, where I is a normalized intensity in the range [0, 1]. The output will be scaled so that the original intensity range is preserved. In gamma compression, the inverse of f$ gamma f$ is used. In sRGB mode, the equation has a linear portion to fight numerical instability.

Gamma expansion is needed when non-linear color channels are linearized. For example, most consumer-grade digital cameras use the non-linear sRGB color space. To correctly apply many color transforming algorithms one must linearize (i.e. expand) the color channels first.

Gamma compression is needed to transform linear colors back to the standard sRGB color space, for example. Industrial-grade machine vision cameras also produce linear color, which need to be gamma-compressed to display correctly. The gamma value for a typical computer monitor is about 2.2. (Old Macs have 1.8.)

Inputs🔗

  • image: Input image.

  • mode: Gamma correction mode.

  • gamma: The gamma. A value of one means no transformation. Use the mode input parameter to invert gamma. If gamma is NaN, standard sRGB gamma function will be applied.

Outputs🔗

  • image: Gamma-corrected image.

enum Mode🔗

Correction mode.

Values:

enumerator Expand🔗

Expand value range with rule out = in^gamma.

enumerator Compress🔗

Compress value range with rule out = in^(1/gamma)