Change the CVD simulation matrices to use the more accurate Viénot model #28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi! I've recently been reviewing the CVD simulation models used in opensource software, and it turns out that the currently used ColorMatrix from colorjack.com are very inaccurate. I wrote a full article about that, but in a nutshell these matrices were a quick hack that the author himself recognized to be a very inaccurate approximation of the more complex "HCIRN Color Blind Simulation function". The implementation used in Coblis by MaPePeR shows the comment:
A more solid reference is the paper of Viénot, Brettel and Mollon in 1999 Digital video colourmaps for checking the legibility of displays by dichromats. This is the simulation part used by most daltonization algorithms. The cool thing is that it also reduces to a single 3x3 matrix at the end, so this PR switches to these matrices instead of the ones from colorjack.com.
An important note is that for all these models to be correct we first need to go from the sRGB color space to a linear RGB color space. Fortunately this is easy to enforce for SVG filters with
color-interpolation-filters="linearRGB"
. This PR also adds that.This Viénot model is pretty good for protanopia and deuteranopia (with all the limits of that kind of simulator of course..), but not great for tritanopia. However none will be great with a single matrix, we'd need to implement for example the Brettel, Viénot and Mollon Computerized simulation of color appearance for dichromats 1997 algorithm for that, but it requires two matrices and a per-pixel dot product test to find out which projection it should use. I'm not very familiar with SVG filters but it does not seem trivial to do, so the Viénot model is probably a reasonable single-matrix fallback.
An alternative to Viénot 1999 would be the Machado 2009 algorithm, they also provide single precomputed 3x3 matrices on their website. I picked Viénot in this PR because I'm more familiar with it but the final results will be kind of similar anyway.
I've included a Jupyter notebook to show how I dumped the precomputed values for each deficiency. For the anomalous versions, I picked 0.6 as the severity factor to be close to the original "HCIRN Color Blind Simulation function" code. There is no real justification to pick that number versus another, but I guess it's a reasonable choice to give an idea of what a less severe deficiency would look like.
Hope this helps!