Skip to contents

Simulate color vision deficiency

Usage

clr_protan(col, severity = 1)

clr_deutan(col, severity = 1)

clr_tritan(col, severity = 1)

Arguments

col

A colors object (see color()) or a vector of any of the three kinds of R color specifications, i.e., either a color name (as listed by grDevices::colors()), a hexadecimal string (see col2rgb()), or a positive integer i meaning grDevices::palette()[i].

severity

A numeric indicating the severity of the color vision defect. Must be a number between 0 and 1, where 0 means no deficiency, and 1 means complete deficiency. Defaults to 1.

Value

A colors object of the same length as col.

Details

The matrices used to perform transformations have been taken as the 1.0 value in table 1 in http://www.inf.ufrgs.br/~oliveira/pubs_files/CVD_Simulation/CVD_Simulation.html. Values for severity values between 0 and 1 will be linearly interpolated.

References

Gustavo M. Machado, Manuel M. Oliveira, and Leandro A. F. Fernandes "A Physiologically-based Model for Simulation of Color Vision Deficiency". IEEE Transactions on Visualization and Computer Graphics. Volume 15 (2009), Number 6, November/December 2009. pp. 1291-1298.

Examples

rainbow_colors <- color(rainbow(10))

plot(clr_protan(rainbow_colors))

plot(clr_deutan(rainbow_colors))

plot(clr_tritan(rainbow_colors))


viridis_colors <- c(
  "#4B0055FF", "#422C70FF", "#185086FF", "#007094FF",
  "#008E98FF", "#00A890FF", "#00BE7DFF", "#6CD05EFF",
  "#BBDD38FF", "#FDE333FF"
)

plot(clr_protan(viridis_colors))

plot(clr_deutan(viridis_colors))

plot(clr_tritan(viridis_colors))