matrix.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. static float IDENTITY[9] = {
  3. // clang-format off
  4. 1, 0, 0,
  5. 0, 1, 0,
  6. 0, 0, 1,
  7. // clang-format on
  8. };
  9. static float XYZD50_to_D65[] = {
  10. // clang-format off
  11. 0.9555766f, -0.0230393f, 0.0631636f,
  12. -0.0282895f, 1.0099416f, 0.0210077f,
  13. 0.0122982f, -0.0204830f, 1.3299098f
  14. // clang-format on
  15. };
  16. static float XYZD65_to_sRGB[] = {
  17. // clang-format off
  18. 3.2406f, -1.5372f, -0.4986f,
  19. -0.9689f, 1.8758f, 0.0415f,
  20. 0.0557f, -0.2040f, 1.0570f
  21. // clang-format on
  22. };
  23. static float sRGB_to_XYZD65[] = {
  24. // clang-format off
  25. 0.4124564f, 0.3575761f, 0.1804375f,
  26. 0.2126729f, 0.7151522f, 0.0721750f,
  27. 0.0193339f, 0.1191920f, 0.9503041f,
  28. // clang-format on
  29. };
  30. static float YUV_to_RGB[] = {
  31. // clang-format off
  32. 0.299f, 0.587f, 0.114f,
  33. -0.299f, -0.587f, 0.886f,
  34. 0.701f, -0.597f, -0.114f
  35. // clang-format on
  36. };
  37. void print_matrix(float m[9]);
  38. void multiply_matrices(const float a[9], const float b[9], float out[9]);
  39. void invert_matrix(const float in[9], float out[9]);
  40. void transpose_matrix(const float in[9], float out[9]);