2
$\begingroup$

I have a video feed generating a stream of of Y'CbCr frames (specifically 8-bit component Y'CbCr 4:2:0, luma range of 16-235, chroma range of 16-240) from which I'd like to calculate relative luminance of specific pixels in each frame with a margin of error at ~2%.

My understanding is that the Y' channel in a Y'CbCr signal is not luminance but luma, and therefore further work is required to reverse that conversion into its linear form.

Of course, to do that I need to know what values were used to compress the signal from its original linear RGB form into its current Y'CbCr state.

I understand there's usually a compression function used to convert linear RGB into R'G'B', so if I know what these are – I should have a fairly good shot at doing it. (That's assuming that not having the camera response curves isn't a problem, as I'm hoping that these are used to transform non-linear raw camera data into a linear form – and so for my purposes there isn't a benefit to reversing the signal transform this far.)

Available to me with the feed are references to a 'transfer function' (usually some ITU standard – BT.601-4 on my test device), a Y'CbCr Matrix (another ITU standard – BT.709-2 on my test device), and some color primaries (P3 D65 on my test device) and white balance gain values.

What steps are required to convert 'luma' to luminance given the available data?

My naive approach is to simply apply the inverse of the transfer function to the luma channel but my concern is that this will be grossly inaccurate. Also, white balance might be a factor too, but perhaps marginally enough to be within the 2% margin of error.

$\endgroup$
5
  • $\begingroup$ When you say, convert RGB to R'G'B', by the latter are you meaning sRGB encoded values? $\endgroup$
    – Simon F
    Dec 3, 2019 at 16:30
  • $\begingroup$ Good question. It could theoretically be any non-linear color space. I have to rely on the meta data. My test device lists a BT.601 'transfer function' (same as sRGB as I understand) but then a BT.709-2 Y'CbCr matrix, and P3 D65 color primaries. I was hoping someone might shed some light on how these, on the surface conflicting standards, might coexist in the context of the above. $\endgroup$
    – Tricky
    Dec 3, 2019 at 16:56
  • $\begingroup$ I (possibly incorrectly) have just assumed the steps are YCbCr => Apply Matrix=> r'g'b' (==sRGB) => apply gamma to decompress to linear RGB. $\endgroup$
    – Simon F
    Dec 4, 2019 at 9:24
  • $\begingroup$ I think you're right, although I'm not sure how the color space comes into play. This article from MS goes through the steps: docs.microsoft.com/en-us/windows/win32/medfound/… I'm assuming after step 4 you can calculate luminance using the primaries from the meta data? $\endgroup$
    – Tricky
    Dec 4, 2019 at 11:53
  • 1
    $\begingroup$ Chapter 3 of "Video Demystified" might be of use to you sites.cs.ucsb.edu/~mturk/Courses/CS281B-2011/Misc/VideoDe.pdf $\endgroup$
    – Simon F
    Dec 4, 2019 at 14:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.