Color.ChromaticAdaptation (Color v0.4.0)

Copy Markdown

Chromatic adaptation transforms between reference whites.

Supported methods: :xyz_scaling, :bradford (default), :von_kries, :sharp, :cmccat2000, :cat02. Matrices are from Bruce Lindbloom (http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html) and the CAT02 / CMCCAT2000 literature.

All math is done with plain Elixir lists and floats; no Nx dependency is required. Adaptation matrices are computed lazily and memoised in :persistent_term.

Summary

Functions

Returns the (ρ, γ, β) cone response of a reference white under the given adaptation method.

Functions

adaptation_matrix_list(source_illuminant, source_observer_angle, dest_illuminant, dest_observer_angle, adaptation_method \\ :bradford)

Returns the 3x3 chromatic adaptation matrix as a list of rows.

Arguments

  • source_illuminant is the source reference white atom.

  • source_observer_angle is 2 or 10.

  • dest_illuminant is the destination reference white atom.

  • dest_observer_angle is 2 or 10.

  • adaptation_method defaults to :bradford.

Returns

  • A list of three three-element rows.

Examples

iex> m = Color.ChromaticAdaptation.adaptation_matrix_list(:D50, 2, :D65, 2)
iex> [[a, _, _] | _] = m
iex> Float.round(a, 4)
0.9556

adaptation_methods()

adaptations()

ργβ(illuminant, observer_angle, adaptation_method \\ :bradford)

Returns the (ρ, γ, β) cone response of a reference white under the given adaptation method.

Arguments

  • illuminant is the illuminant atom.

  • observer_angle is 2 or 10.

  • adaptation_method defaults to :bradford.

Returns

  • A {ρ, γ, β} tuple.