Log in

View Full Version : What is Color Matrix, Primaries, and Transfer?


PRAGMA
11th June 2021, 12:10
I'm reading around Doom9 and I'm getting very confused on what they actually are. Posts are constantly talking about x/y/z being recommended values in z/y/x scenario, or giving a brief explanation (one sentence, <20 words).

What doesn't help is a lot of the posts are very old and these so called recommendations (with no sources backing them up) are probably outdated.

That being said, if I wanted to transcode a DVD MPEG-2 (with seemingly no original color information) to a H264, what should I do?

Are the mat/prim/trans different per standard? Is it different for a Spanish DVD vs. a British DVD? What about a Brazil DVD which is in a weird PAL/NTSC state to do with color?

What if I'm taking the DVD (let's say PAL 720x576) and transcoding it to H264 at 1440x1080 (4:3) does that resolution change matter?

--

What I have so far is that the Color Matrix Co-efficients are used when converting from YUV -> RGB. That they are used when deriving the luma and chroma from the RGB primaries. What does that mean? What is a Co-efficient? What are RGB primaries, is that related to "Color Primaries"?

--

To give you an example, I have a PAL DVD of a Mickey Mouse short. It seemingly has no "Colorimetry" specified in the stream. DGIndex reports that it's probably "BT.470-2 B,G".

As for Color Primaries and Transfer? No idea. If I loaded it up in VapourSynth or AviSynth (or even FFmpeg), what should I tell it to use as the input Color Matrix, Primaries, and Transfer for an encode to an upscaled 1440x1080? BT.709 on all 3? BT.709 on all but the Color Matrix and instead use BT.470-2 B,G for that?

--

I guess ultimately what I want to know, is what the values end up doing in the modern day. Is it truly a lossless operation to go from YUV->RGB->YUV.

feisty2
11th June 2021, 13:45
the mathematical model that defines what's considered "color" in the physical world is called CIE XYZ, it is the standard colorspace that all other colorspaces ultimately refer to.
then you have this "derivation chain": CIE XYZ -> Linear RGB -> Gamma Compressed RGB -> YUV
color primaries are the coordinates that locate where the Linear RGB colorspace is embedded in CIE XYZ
transfer characteristics (aka gamma curve) describe the nonlinearity of your compressed colorspace, this basically assigns more quantization precision to the "darker" interval of the recorded intensities, cuz human vision is more sensitive to dark scenes.
color matrix is a bunch of coefficients that generate a "brightness / chrominance" representation (e.g. YUV) from an intensity-based model (e.g. RGB).

Balling
31st August 2021, 16:43
"What is a Co-efficient? What are RGB primaries, is that related to "Color Primaries"?"

Matrix of 3x3 is actually constructed from just 2 numbers, which are called matrix coeff. They are derived from (and here you are wrong) from white point and primaries, not just primaries. You can look into SMPTE RP 177 as to how it is done. Or H.273. Or EBU 3237 Suppl. 1.