@dragonspark/chroma-kit
    Preparing search index...

    Function contrastWeber

    • Calculates the Weber contrast between two XYZ colors based on their luminance values.

      The Weber contrast is commonly used in vision science to measure the contrast between a stimulus and its background. It was developed by Ernst Weber in the 19th century as part of his work on just-noticeable differences in perception.

      Formula: (Lmax - Lmin) / Lmin

      Key characteristics:

      • Produces values from 0 to potentially infinity, where 0 indicates no contrast
      • Asymmetric with respect to the two luminance values
      • Particularly useful for measuring contrast of small features against a uniform background
      • Commonly used in psychophysics and visual perception research

      Limitations:

      • Not bounded on the upper end (can approach infinity as Lmin approaches zero)
      • Not symmetric (swapping the two colors can produce different results)
      • Less suitable for patterns with equal light and dark areas
      • Becomes unstable when the reference luminance is very low

      Parameters

      • color1: XYZColor

        The first color, represented in the XYZ color space.

      • color2: XYZColor

        The second color, represented in the XYZ color space.

      Returns number

      The Weber contrast value for the two input colors.

      • Used when the darker color has zero luminance