Given the chromaticity coordinates of an RGB system (xr, yr), (xg, yg) and (xb, yb) and its reference white (XW, YW, ZW), here is the method to compute the 3 × 3 matrix for converting RGB to XYZ:
![]()
where

Implementation Notes:
Using the chromaticities and reference whites of common RGB working spaces, I have done the math for you to compute the RGB-to-XYZ and XYZ-to-RGB matrices. Note that these matrices are given relative to their own reference whites. If you examine the matrices for these working spaces found inside ICC profiles (through the redColorantTag, greenColorantTag and blueColorantTag), those matrices will always be relative to D50, and therefore, the colorants have been subjected to a chromatic adaptation transformation if the working space reference white is not also D50.
| RGB Working Space | Reference White | RGB to XYZ [M] | XYZ to RGB [M]-1 |
| Adobe RGB (1998) | D65 | 0.576700 0.297361 0.0270328 |
2.04148 -0.969258 0.0134455 |
| Apple RGB | D65 | 0.449695 0.244634 0.0251829 |
2.95176 -1.0851 0.0854804 |
| BestRGB | D50 | 0.632670 0.228457 0.000000 |
1.75526 -0.544134 0.00634681 |
| Beta RGB | D50 | 0.671254 0.303273 0.000000 |
1.68323 -0.771023 0.0400012 |
| BruceRGB | D65 | 0.467384 0.240995 0.0219086 |
2.74566 -0.969257 0.0112707 |
| CIE | E | 0.488718 0.176204 0.000000 |
2.37067 -0.513885 0.00529818 |
| ColorMatch | D50 | 0.509344 0.274884 0.0242545 |
2.64229 -1.11198 0.0821698 |
| DonRGB4 | D50 | 0.645771 0.278350 0.00371134 |
1.76039 -0.712629 0.00782072 |
| ECI | D50 | 0.650204 0.320250 0.000000 |
1.78276 -0.959362 0.0859318 |
| Ekta Space PS5 | D50 | 0.593891 0.260629 0.000000 |
2.00438 -0.711029 0.0381263 |
| NTSC | C | 0.606734 0.298839 0.000000 |
1.91049 -0.984310 0.0583744 |
| PAL / SECAM | D65 | 0.430587 0.222021 0.0201837 |
3.06313 -0.969258 0.0678674 |
| ProPhoto | D50 | 0.797675 0.288040 0.000000 |
1.34594 -0.544599 0.000000 |
| SMPTE-C | D65 | 0.393555 0.212395 0.0187407 |
3.50570 -1.06906 0.0563117 |
| sRGB | D65 | 0.412424 0.212656 0.0193324 |
3.24071 -0.969258 0.0556352 |
| WideGamut | D50 | 0.716105 0.258187 0.000000 |
1.46281 -0.521793 0.0349342 |