Class ViewingConditions

java.lang.Object
org.pushingpixels.ephemeral.chroma.hct.ViewingConditions

public final class ViewingConditions extends Object
In traditional color spaces, a color can be identified solely by the observer's measurement of the color. Color appearance models such as CAM16 also use information about the environment where the color was observed, known as the viewing conditions.

For example, white under the traditional assumption of a midday sun white point is accurately measured as a slightly chromatic blue by CAM16. (roughly, hue 203, chroma 3, lightness 100)

This class caches intermediate values of the CAM16 conversion process that depend only on viewing conditions, enabling speed ups.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final double
     
    private final double
     
    static final ViewingConditions
    sRGB-like viewing conditions.
    private final double
     
    private final double
     
    private final double
     
    private final double
     
    private final double
     
    private final double
     
    private final double[]
     
    private final double
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    ViewingConditions(double n, double aw, double nbb, double ncb, double c, double nc, double[] rgbD, double fl, double flRoot, double z)
    Parameters are intermediate values of the CAM16 conversion process.
  • Method Summary

    Modifier and Type
    Method
    Description
    Create sRGB-like viewing conditions with a custom background lstar.
    double
     
    (package private) double
     
    (package private) double
     
    double
     
    double
     
    double
     
    (package private) double
     
    (package private) double
     
    double[]
     
    (package private) double
     
    make(double[] whitePoint, double adaptingLuminance, double backgroundLstar, double surround, boolean discountingIlluminant)
    Create ViewingConditions from a simple, physically relevant, set of parameters.

    Methods inherited from class Object

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

    • DEFAULT

      public static final ViewingConditions DEFAULT
      sRGB-like viewing conditions.
    • aw

      private final double aw
    • nbb

      private final double nbb
    • ncb

      private final double ncb
    • c

      private final double c
    • nc

      private final double nc
    • n

      private final double n
    • rgbD

      private final double[] rgbD
    • fl

      private final double fl
    • flRoot

      private final double flRoot
    • z

      private final double z
  • Constructor Details

    • ViewingConditions

      private ViewingConditions(double n, double aw, double nbb, double ncb, double c, double nc, double[] rgbD, double fl, double flRoot, double z)
      Parameters are intermediate values of the CAM16 conversion process. Their names are shorthand for technical color science terminology, this class would not benefit from documenting them individually. A brief overview is available in the CAM16 specification, and a complete overview requires a color science textbook, such as Fairchild's Color Appearance Models.
  • Method Details

    • getAw

      public double getAw()
    • getN

      public double getN()
    • getNbb

      public double getNbb()
    • getNcb

      double getNcb()
    • getC

      double getC()
    • getNc

      double getNc()
    • getRgbD

      public double[] getRgbD()
    • getFl

      double getFl()
    • getFlRoot

      public double getFlRoot()
    • getZ

      double getZ()
    • make

      public static ViewingConditions make(double[] whitePoint, double adaptingLuminance, double backgroundLstar, double surround, boolean discountingIlluminant)
      Create ViewingConditions from a simple, physically relevant, set of parameters.
      Parameters:
      whitePoint - White point, measured in the XYZ color space. default = D65, or sunny day afternoon
      adaptingLuminance - The luminance of the adapting field. Informally, how bright it is in the room where the color is viewed. Can be calculated from lux by multiplying lux by 0.0586. default = 11.72, or 200 lux.
      backgroundLstar - The lightness of the area surrounding the color. measured by L* in L*a*b*. default = 50.0
      surround - A general description of the lighting surrounding the color. 0 is pitch dark, like watching a movie in a theater. 1.0 is a dimly light room, like watching TV at home at night. 2.0 means there is no difference between the lighting on the color and around it. default = 2.0
      discountingIlluminant - Whether the eye accounts for the tint of the ambient lighting, such as knowing an apple is still red in green light. default = false, the eye does not perform this process on self-luminous objects like displays.
    • defaultWithBackgroundLstar

      public static ViewingConditions defaultWithBackgroundLstar(double lstar)
      Create sRGB-like viewing conditions with a custom background lstar.

      Default viewing conditions have a lstar of 50, midgray.