Using the physiologically-based model for simulating color vision deficiency (CVD)
of Machado et al. (2009), different kinds of limitations can be
emulated: deuteranope (green cone cells defective), protanope (red cone cells defective),
and tritanope (blue cone cells defective).
The workhorse function to do so is simulate_cvd
which can take any vector
of valid R colors and transform them according to a certain CVD transformation
matrix (see cvd
) and transformation equation.
The functions deutan
, protan
, and tritan
are the high-level functions for
simulating the corresponding kind of colorblindness with a given severity.
Internally, they all call simulate_cvd
along with a (possibly interpolated)
version of the matrices from cvd
. Matrix interpolation can be carried out with
the function interpolate_cvd_transform
(see examples).
If input col
is a matrix with three rows named R
, G
, and
B
(top down) they are interpreted as Red-Green-Blue values within the
range [0-255]
. Then the CVD transformation is applied directly to these
coordinates avoiding any further conversions.
Finally, if col
is a formal color-class
object, then its
coordinates are transformed to (s)RGB coordinates, as described above, and returned as a formal
object of the same class after the color vision deficiency simulation.
Up to version 2.0-3 of the package, the CVD transformations had been applied
directly to the gamma-corrected sRGB coordinates (corresponding to the hex coordinates
of the colors), following the illustrations of Machado et al. (2009). However,
the paper implicitly relies on a linear RGB space (see page 1294, column 1) where their
linear matrix transformations for simulating color vision deficiencies are applied.
Therefore, starting from version 2.1-0 of the package, a new argument linear = TRUE
has been added that first maps the provided colors to linearized RGB coordinates, applies
the color vision deficiency transformation, and then maps back to gamma-corrected sRGB
coordinates. Optionally, linear = FALSE
can be used to restore the behavior
from previous versions. For most colors the difference between the two strategies is
negligible but for some highly-saturated colors it becomes more noticable, e.g., for
red, purple, or orange.