home/ atoms/ color-space-conversion-matrix

Converting between linear RGB color spaces is a 3x3 matrix multiplication

When two color spaces share the same TRC (linear) but have different primaries, converting any color from one to the other is a linear transformation: each output channel is a weighted sum of all three input channels. These weights form a 3×3 matrix. Matching the pure R, G, and B primaries individually (via Grassmann’s law) yields the three columns of the matrix; the inverse matrix gives the reverse conversion. All real-world color profile conversions chain through CIE XYZ as an intermediate.

Examples

RGB→RGB: R’ = 0.712·R + 0.221·G + 0.067·B; G’ = 0.100·R + 0.690·G + 0.210·B; B’ = 0.024·R + 0.000·G + 0.976·B. In GLSL: vec3 converted = colorMatrix * originalColor;

Assessment

Given the forward conversion matrix from space A to B, how would you derive the matrix to convert back from B to A? Why does this only work for linear (non-gamma-encoded) color spaces?

“3×3 matrix that defines the conversion from RGB to RGB. If you're familiar with matrices and vectors, you might have already realized that the transformation we did was a plain old matrix times vector multiplication.”
corpus · color-spaces-bartosz-ciechanowski-interactive-article · chunk 5