Converting between linear RGB spaces is a matrix operation:
XYZ=MRGB→XYZRGB
RGB to XYZ Matrix
For sRGB (ITU-R 709 primaries):
M709→XYZ=0.41240.21260.01930.35760.71520.11920.18050.07220.9505

Between RGB Spaces
To convert from sRGB to Rec. 2020:
R2020G2020B2020=MXYZ→2020⋅M709→XYZR709G709B709
Steps
- Linearise: Remove gamma encoding
- Convert to XYZ: Apply MRGB→XYZ
- Convert to target: Apply MXYZ→RGB−1
- Re-encode: Apply target gamma
Computing RGB to XYZ Matrix
Given primaries (xR,yR), (xG,yG), (xB,yB) and white point (xW,yW):
P=xR/yR1(1−xR−yR)/yRxG/yG1(1−xG−yG)/yGxB/yB1(1−xB−yB)/yB
Step 2: Solve for Scaling Factors
SRSGSB=P−1xW/yW1(1−xW−yW)/yW
MRGB→XYZ=SRxR/yRSRSR(1−xR−yR)/yRSGxG/yGSGSG(1−xG−yG)/yGSBxB/yBSBSB(1−xB−yB)/yB
Mapping to a Display with Custom Primaries
Given:
- Target spectrum L
- Display primary spectra PRGB (N×3 matrix)
- CIE XYZ matching functions SXYZ (N×3 matrix)
Algorithm
- Find XYZ of target:
CXYZ=SXYZ⊤L=XYZ
- Construct primary matrix:
MRGB→XYZ=SXYZ⊤PRGB
- Solve for RGB:
RGB=MRGB→XYZ−1CXYZ
- Apply display encoding:
R′G′B′=R1/γG1/γB1/γ
Luma (display-encoded luminance approximation):
Y′=0.2126R′+0.7152G′+0.0722B′
Important Note
Luma ≠ Luminance:
- Luma uses gamma-corrected (display-encoded) values
- Luminance uses linear values
- Luma is an approximation for video processing
Gamut Mapping
When converting between spaces with different gamuts:
| Situation | Action |
|---|
| Colour inside both gamuts | Direct mapping |
| Colour outside destination | Gamut mapping required |
Gamut Mapping Strategies
| Strategy | Description |
|---|
| Clipping | Clip to nearest in-gamut colour |
| Compression | Reduce saturation proportionally |
| Perceptual | Preserve relationships, compress into gamut |
Summary
- Linear RGB to XYZ conversion uses 3×3 matrices
- Transform between RGB spaces via XYZ intermediate
- Matrix derivation requires primaries and white point
- Luma approximates luminance from gamma-encoded values
Past Paper Questions
2024 Paper 3 Question 4: How would you convert a colour from sRGB to Rec. 2020? What steps are involved?
2023 Paper 3 Question 4: Derive the RGB to XYZ transformation matrix given the primaries and white point.
2022 Paper 3 Question 3: What is the difference between luma and luminance?