Class ModifiedGammaMapping

java.lang.Object
imagingbook.common.color.gamma.ModifiedGammaMapping
All Implemented Interfaces:
GammaMapping

public class ModifiedGammaMapping extends Object implements GammaMapping

Defines the "modified gamma correction" used for converting linear to non-linear color component values. The mapping function consists of a linear and non-linear part. In the forward mapping (applyFwd(double)), the linear part covers input values between a = 0,...,a0, while values a = a0,...,1 are mapped non-linearly. For the inverse mapping (applyInv(double)), the linear part is b = 0,...,b0, the non-linear part is b = b0,...,1. Theoretically all mapping parameters can be derived from parameters gamma and a0 (the linear to non-linear transition point) only. Note that gamma specifies the nominal γ parameter for the forward (i.e., linear to non-linear) mapping, e.g., γ = 1/2.4 for sRGB. See Sec. 3.7.6 of [1] for more details.

[1] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction, 3rd ed, Springer (2022).

Version:
2022/11/14
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Gamma mapping function instance for ITU-R BT.709 (see Table 3.1 of [1]).
    Gamma mapping function instance for sRGB (see Table 3.1 of [1]).
  • Constructor Summary

    Constructors
    Constructor
    Description
    ModifiedGammaMapping(double gamma, double a0)
    Constructor, derives parameters s and d from gamma and a0 (see Eq.
    ModifiedGammaMapping(double gamma, double a0, double s, double d)
    Constructor, accepts explicit parameters s and d to allow for minor inaccuracies in published standards.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    applyFwd(double a)
    Forward Gamma mapping (from linear to non-linear component values).
    float
    applyFwd(float a)
    float[]
    applyFwd(float[] A)
    Forward Gamma mapping (from linear to non-linear component values).
    double
    applyInv(double b)
    Inverse Gamma mapping (from non-linear to linear component values).
    float
    applyInv(float b)
    float[]
    applyInv(float[] B)
    Inverse Gamma mapping (from non-linear to linear component values).
    protected static double
    d(double gamma, double a0)
    Function d(gamma, a0) derives the offset d of the non-linear section from parameters gamma and a0 (see Eq.
    protected static double
    s(double gamma, double a0)
    Function s(gamma, a0) derives the slope s of the linear section from parameters gamma and a0 (see Eq.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ITU709

      Gamma mapping function instance for ITU-R BT.709 (see Table 3.1 of [1]).
    • sRGB

      public static ModifiedGammaMapping sRGB
      Gamma mapping function instance for sRGB (see Table 3.1 of [1]). Note that we need to specify parameters s and d too to comply strictly with the sRGB standard.
  • Constructor Details

    • ModifiedGammaMapping

      public ModifiedGammaMapping(double gamma, double a0)
      Constructor, derives parameters s and d from gamma and a0 (see Eq. 3.35 in [1]).
      Parameters:
      gamma - in [0,1], the nominal gamma value for the forward mapping (e.g., gamma = 1/2.4 for sRGB)
      a0 - in [0,1], the linear to non-linear transition point (e.g., a0 = 1/2.4 for sRGB)
    • ModifiedGammaMapping

      public ModifiedGammaMapping(double gamma, double a0, double s, double d)
      Constructor, accepts explicit parameters s and d to allow for minor inaccuracies in published standards.
      Parameters:
      gamma - in [0,1], the nominal gamma value for the forward mapping (e.g., gamma = 1/2.4 for sRGB)
      a0 - in [0,1], the linear to non-linear transition point (e.g., a0 = 1/2.4 for sRGB)
      s - > 0, the slope s of the linear section (e.g., s = 12.92 for sRGB)
      d - ≥ 0 the offset d of the non-linear section (e.g., s = 0.055 for sRGB)
  • Method Details

    • s

      protected static double s(double gamma, double a0)
      Function s(gamma, a0) derives the slope s of the linear section from parameters gamma and a0 (see Eq. 3.35 in [1]).
      Parameters:
      gamma - the nominal gamma value for the forward mapping
      a0 - the linear to non-linear transition point
      Returns:
      the slope s of the linear section
    • d

      protected static double d(double gamma, double a0)
      Function d(gamma, a0) derives the offset d of the non-linear section from parameters gamma and a0 (see Eq. 3.35 in [1]).
      Parameters:
      gamma - the nominal gamma value for the forward mapping
      a0 - the linear to non-linear transition point
      Returns:
      the offset d of the non-linear section
    • applyFwd

      public double applyFwd(double a)
      Description copied from interface: GammaMapping
      Forward Gamma mapping (from linear to non-linear component values).
      Specified by:
      applyFwd in interface GammaMapping
      Parameters:
      a - linear component value in [0,1]
      Returns:
      the gamma-corrected (non-linear) component value
    • applyInv

      public double applyInv(double b)
      Description copied from interface: GammaMapping
      Inverse Gamma mapping (from non-linear to linear component values).
      Specified by:
      applyInv in interface GammaMapping
      Parameters:
      b - non-linear (Gamma-corrected) component value in [0,1]
      Returns:
      the linear component value
    • applyFwd

      public float applyFwd(float a)
      Description copied from interface: GammaMapping
      Specified by:
      applyFwd in interface GammaMapping
      Parameters:
      a - linear component value in [0,1]
      Returns:
      the gamma-corrected (non-linear) component value
    • applyInv

      public float applyInv(float b)
      Description copied from interface: GammaMapping
      Specified by:
      applyInv in interface GammaMapping
      Parameters:
      b - non-linear (Gamma-corrected) component value in [0,1]
      Returns:
      the linear component value
    • applyFwd

      public float[] applyFwd(float[] A)
      Forward Gamma mapping (from linear to non-linear component values).
      Parameters:
      A - an array of linear component values in [0,1]
      Returns:
      an array of gamma-corrected (non-linear) component values
    • applyInv

      public float[] applyInv(float[] B)
      Inverse Gamma mapping (from non-linear to linear component values).
      Parameters:
      B - an array of non-linear (Gamma-corrected) component value in [0,1]
      Returns:
      an array of linear component values