| 1 |
# All matrices in this file are adapted from https://github.com/njsmith/colorspacious/blob/master/colorspacious/cvd.py |
| 2 |
|
| 3 |
#' Color Vision Deficiency (CVD) Conversion Tables |
| 4 |
#' |
| 5 |
#' Conversion tables for simulating different types of color vision deficiency (CVD): |
| 6 |
#' Protanomaly, deutanomaly, tritanomaly. |
| 7 |
#' |
| 8 |
#' Machado et al. (2009) have established a novel model, that allows to handle normal color |
| 9 |
#' vision, anomalous trichromacy, and dichromacy in a unified way. They also provide conversion |
| 10 |
#' formulas along with tables of certain constants that allow to simulate various types of |
| 11 |
#' CVD. See \code{\link{simulate_cvd}} for the corresponding simulation functions. |
| 12 |
#' |
| 13 |
#' @name cvd |
| 14 |
#' @rdname cvd |
| 15 |
#' @format Lists of 3x3 RGB-color transformation matrices for the various types of CVD. Each list contains 11 transformation matrices |
| 16 |
#' representing increasingly severe color vision deficiency. |
| 17 |
#' @usage NULL |
| 18 |
#' @seealso \code{\link{simulate_cvd}} |
| 19 |
#' @references Machado GM, Oliveira MM, Fernandes LAF (2009). |
| 20 |
#' A Physiologically-Based Model for Simulation of Color Vision Deficiency. |
| 21 |
#' \emph{IEEE Transactions on Visualization and Computer Graphics}. \bold{15}(6), 1291--1298. |
| 22 |
#' \doi{10.1109/TVCG.2009.113} |
| 23 |
#' Online version with supplements at |
| 24 |
#' \url{http://www.inf.ufrgs.br/~oliveira/pubs_files/CVD_Simulation/CVD_Simulation.html}. |
| 25 |
#' |
| 26 |
#' Zeileis A, Fisher JC, Hornik K, Ihaka R, McWhite CD, Murrell P, Stauffer R, Wilke CO (2020). |
| 27 |
#' \dQuote{colorspace: A Toolbox for Manipulating and Assessing Colors and Palettes.} |
| 28 |
#' \emph{Journal of Statistical Software}, \bold{96}(1), 1--49. \doi{10.18637/jss.v096.i01} |
| 29 |
NULL |
| 30 |
|
| 31 |
#' @rdname cvd |
| 32 |
#' @format NULL |
| 33 |
#' @usage protanomaly_cvd |
| 34 |
#' @export |
| 35 |
protanomaly_cvd <- list( |
| 36 |
"0" = matrix(c( |
| 37 |
1.000000, 0.000000, -0.000000, |
| 38 |
0.000000, 1.000000, 0.000000, |
| 39 |
-0.000000, -0.000000, 1.000000 |
| 40 |
), 3,3,byrow = TRUE), |
| 41 |
"1" = matrix(c( |
| 42 |
0.856167, 0.182038, -0.038205, |
| 43 |
0.029342, 0.955115, 0.015544, |
| 44 |
-0.002880, -0.001563, 1.004443 |
| 45 |
),3,3,byrow=TRUE), |
| 46 |
"2" = matrix(c( |
| 47 |
0.734766, 0.334872, -0.069637, |
| 48 |
0.051840, 0.919198, 0.028963, |
| 49 |
-0.004928, -0.004209, 1.009137 |
| 50 |
),3,3,byrow=TRUE), |
| 51 |
"3" = matrix(c( |
| 52 |
0.630323, 0.465641, -0.095964, |
| 53 |
0.069181, 0.890046, 0.040773, |
| 54 |
-0.006308, -0.007724, 1.014032 |
| 55 |
),3,3,byrow=TRUE), |
| 56 |
"4" = matrix(c( |
| 57 |
0.539009, 0.579343, -0.118352, |
| 58 |
0.082546, 0.866121, 0.051332, |
| 59 |
-0.007136, -0.011959, 1.019095 |
| 60 |
),3,3,byrow=TRUE), |
| 61 |
"5" = matrix(c( |
| 62 |
0.458064, 0.679578, -0.137642, |
| 63 |
0.092785, 0.846313, 0.060902, |
| 64 |
-0.007494, -0.016807, 1.024301 |
| 65 |
),3,3,byrow=TRUE), |
| 66 |
"6" = matrix(c( |
| 67 |
0.385450, 0.769005, -0.154455, |
| 68 |
0.100526, 0.829802, 0.069673, |
| 69 |
-0.007442, -0.022190, 1.029632 |
| 70 |
),3,3,byrow=TRUE), |
| 71 |
"7" = matrix(c( |
| 72 |
0.319627, 0.849633, -0.169261, |
| 73 |
0.106241, 0.815969, 0.077790, |
| 74 |
-0.007025, -0.028051, 1.035076 |
| 75 |
),3,3,byrow=TRUE), |
| 76 |
"8" = matrix(c( |
| 77 |
0.259411, 0.923008, -0.182420, |
| 78 |
0.110296, 0.804340, 0.085364, |
| 79 |
-0.006276, -0.034346, 1.040622 |
| 80 |
),3,3,byrow=TRUE), |
| 81 |
"9" = matrix(c( |
| 82 |
0.203876, 0.990338, -0.194214, |
| 83 |
0.112975, 0.794542, 0.092483, |
| 84 |
-0.005222, -0.041043, 1.046265 |
| 85 |
),3,3,byrow=TRUE), |
| 86 |
"10" = matrix(c( |
| 87 |
0.152286, 1.052583, -0.204868, |
| 88 |
0.114503, 0.786281, 0.099216, |
| 89 |
-0.003882, -0.048116, 1.051998 |
| 90 |
),3,3,byrow=TRUE) |
| 91 |
|
| 92 |
) |
| 93 |
|
| 94 |
#' @rdname cvd |
| 95 |
#' @format NULL |
| 96 |
#' @usage deutanomaly_cvd |
| 97 |
#' @export |
| 98 |
deutanomaly_cvd <- list( |
| 99 |
"0" = matrix(c( |
| 100 |
1.000000, 0.000000, -0.000000, |
| 101 |
0.000000, 1.000000, 0.000000, |
| 102 |
-0.000000, -0.000000, 1.000000 |
| 103 |
),3,3,byrow=TRUE), |
| 104 |
"1" = matrix(c( |
| 105 |
0.866435, 0.177704, -0.044139, |
| 106 |
0.049567, 0.939063, 0.011370, |
| 107 |
-0.003453, 0.007233, 0.996220 |
| 108 |
),3,3,byrow=TRUE), |
| 109 |
"2" = matrix(c( |
| 110 |
0.760729, 0.319078, -0.079807, |
| 111 |
0.090568, 0.889315, 0.020117, |
| 112 |
-0.006027, 0.013325, 0.992702 |
| 113 |
),3,3,byrow=TRUE), |
| 114 |
"3" = matrix(c( |
| 115 |
0.675425, 0.433850, -0.109275, |
| 116 |
0.125303, 0.847755, 0.026942, |
| 117 |
-0.007950, 0.018572, 0.989378 |
| 118 |
),3,3,byrow=TRUE), |
| 119 |
"4" = matrix(c( |
| 120 |
0.605511, 0.528560, -0.134071, |
| 121 |
0.155318, 0.812366, 0.032316, |
| 122 |
-0.009376, 0.023176, 0.986200 |
| 123 |
),3,3,byrow=TRUE), |
| 124 |
"5" = matrix(c( |
| 125 |
0.547494, 0.607765, -0.155259, |
| 126 |
0.181692, 0.781742, 0.036566, |
| 127 |
-0.010410, 0.027275, 0.983136 |
| 128 |
),3,3,byrow=TRUE), |
| 129 |
"6" = matrix(c( |
| 130 |
0.498864, 0.674741, -0.173604, |
| 131 |
0.205199, 0.754872, 0.039929, |
| 132 |
-0.011131, 0.030969, 0.980162 |
| 133 |
),3,3,byrow=TRUE), |
| 134 |
"7" = matrix(c( |
| 135 |
0.457771, 0.731899, -0.189670, |
| 136 |
0.226409, 0.731012, 0.042579, |
| 137 |
-0.011595, 0.034333, 0.977261 |
| 138 |
),3,3,byrow=TRUE), |
| 139 |
"8" = matrix(c( |
| 140 |
0.422823, 0.781057, -0.203881, |
| 141 |
0.245752, 0.709602, 0.044646, |
| 142 |
-0.011843, 0.037423, 0.974421 |
| 143 |
),3,3,byrow=TRUE), |
| 144 |
"9" = matrix(c( |
| 145 |
0.392952, 0.823610, -0.216562, |
| 146 |
0.263559, 0.690210, 0.046232, |
| 147 |
-0.011910, 0.040281, 0.971630 |
| 148 |
),3,3,byrow=TRUE), |
| 149 |
"10" = matrix(c( |
| 150 |
0.367322, 0.860646, -0.227968, |
| 151 |
0.280085, 0.672501, 0.047413, |
| 152 |
-0.011820, 0.042940, 0.968881 |
| 153 |
),3,3,byrow=TRUE) |
| 154 |
) |
| 155 |
|
| 156 |
#' @rdname cvd |
| 157 |
#' @format NULL |
| 158 |
#' @usage tritanomaly_cvd |
| 159 |
#' @export |
| 160 |
tritanomaly_cvd <- list( |
| 161 |
"0" = matrix(c( |
| 162 |
1.000000, 0.000000, -0.000000, |
| 163 |
0.000000, 1.000000, 0.000000, |
| 164 |
-0.000000, -0.000000, 1.000000 |
| 165 |
),3,3,byrow=TRUE), |
| 166 |
"1" = matrix(c( |
| 167 |
0.926670, 0.092514, -0.019184, |
| 168 |
0.021191, 0.964503, 0.014306, |
| 169 |
0.008437, 0.054813, 0.936750 |
| 170 |
),3,3,byrow=TRUE), |
| 171 |
"2" = matrix(c( |
| 172 |
0.895720, 0.133330, -0.029050, |
| 173 |
0.029997, 0.945400, 0.024603, |
| 174 |
0.013027, 0.104707, 0.882266 |
| 175 |
),3,3,byrow=TRUE), |
| 176 |
"3" = matrix(c( |
| 177 |
0.905871, 0.127791, -0.033662, |
| 178 |
0.026856, 0.941251, 0.031893, |
| 179 |
0.013410, 0.148296, 0.838294 |
| 180 |
),3,3,byrow=TRUE), |
| 181 |
"4" = matrix(c( |
| 182 |
0.948035, 0.089490, -0.037526, |
| 183 |
0.014364, 0.946792, 0.038844, |
| 184 |
0.010853, 0.193991, 0.795156 |
| 185 |
),3,3,byrow=TRUE), |
| 186 |
"5" = matrix(c( |
| 187 |
1.017277, 0.027029, -0.044306, |
| 188 |
-0.006113, 0.958479, 0.047634, |
| 189 |
0.006379, 0.248708, 0.744913 |
| 190 |
),3,3,byrow=TRUE), |
| 191 |
"6" = matrix(c( |
| 192 |
1.104996, -0.046633, -0.058363, |
| 193 |
-0.032137, 0.971635, 0.060503, |
| 194 |
0.001336, 0.317922, 0.680742 |
| 195 |
),3,3,byrow=TRUE), |
| 196 |
"7" = matrix(c( |
| 197 |
1.193214, -0.109812, -0.083402, |
| 198 |
-0.058496, 0.979410, 0.079086, |
| 199 |
-0.002346, 0.403492, 0.598854 |
| 200 |
),3,3,byrow=TRUE), |
| 201 |
"8" = matrix(c( |
| 202 |
1.257728, -0.139648, -0.118081, |
| 203 |
-0.078003, 0.975409, 0.102594, |
| 204 |
-0.003316, 0.501214, 0.502102 |
| 205 |
),3,3,byrow=TRUE), |
| 206 |
"9" = matrix(c( |
| 207 |
1.278864, -0.125333, -0.153531, |
| 208 |
-0.084748, 0.957674, 0.127074, |
| 209 |
-0.000989, 0.601151, 0.399838 |
| 210 |
),3,3,byrow=TRUE), |
| 211 |
"10" = matrix(c( |
| 212 |
1.255528, -0.076749, -0.178779, |
| 213 |
-0.078411, 0.930809, 0.147602, |
| 214 |
0.004733, 0.691367, 0.303900 |
| 215 |
),3,3,byrow=TRUE) |
| 216 |
) |
| 217 |
|