Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. % Here is a matlab script for calculating a direct transformation matrix for daltonization.
  2. %
  3. % These are the results:
  4. %
  5. %Protanope:
  6. %ans =
  7. %
  8. % 1.0000 0 0
  9. % 0.5089 0.4911 0.0000
  10. % 0.6173 -0.6173 1.0000
  11. %
  12. %Deuteranope:
  13. %ans =
  14. %
  15. % 1.0000 0 0
  16. % 0.2023 0.7977 -0.0000
  17. % 0.5174 -0.5174 1.0000
  18. %
  19. %Trianope:
  20. %ans =
  21. %
  22. % 1.0000 0 0
  23. % -0.1385 1.1385 0.0000
  24. % 3.3656 -3.3656 1.0000
  25. %
  26. % Used http://mudcu.be/labs/Color-Vision/Javascript/Color.Vision.Daltonize.js as reference
  27. %
  28. function daltonize
  29.  
  30. function ret = calculateMatrix(CVDmatrix)
  31. LMSrgb = [17.8824 43.5161 4.11935;
  32. 3.45565 27.1554 3.86714;
  33. 0.0299566 0.184309 1.46709];
  34.  
  35. RGBlms = [ 0.0809444479 -0.130504409 0.116721066;
  36. -0.0102485335 0.0540193266 -0.113614708;
  37. -0.000365296938 -0.00412161469 0.693511405];
  38.  
  39. RGBrgb = RGBlms * CVDmatrix * LMSrgb;
  40.  
  41. errrgb = eye(3) - RGBrgb;
  42.  
  43. RRGGBBrgb = [0 0 0; 0.7 1 0; 0.7 0 1] * errrgb;
  44.  
  45. ret = RRGGBBrgb + eye(3);
  46. end
  47.  
  48. Protanope = [0.0, 2.02344, -2.52581,
  49. 0.0, 1.0, 0.0,
  50. 0.0, 0.0, 1.0];
  51.  
  52. Deuteranope = [1.0, 0.0, 0.0;
  53. 0.494207, 0.0, 1.24827;
  54. 0.0, 0.0, 1.0];
  55.  
  56. Trianope = [1.0, 0.0, 0.0;
  57. 0.0, 1.0, 0.0;
  58. -0.395913, 0.801109, 0.0];
  59.  
  60.  
  61. fprintf('Protanope:');
  62. calculateMatrix(Protanope)
  63.  
  64. fprintf('Deuteranope:');
  65. calculateMatrix(Deuteranope)
  66.  
  67. fprintf('Trianope:');
  68. calculateMatrix(Trianope)
  69.  
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement